Browse Source

关联的温度测点

dev
wenlele 1 year ago
parent
commit
ca7ca17692
  1. 6
      api/app/lib/controllers/service/report.js
  2. 2
      api/app/lib/models/report_automatic.js
  3. 2
      script/3.6/schema/2.create_report_automatic.sql
  4. 23
      web/client/src/sections/service/components/automatic-Modal.jsx
  5. 14
      web/client/src/sections/service/containers/automaticReport.jsx
  6. 6
      web/client/src/sections/service/containers/reportFile.jsx

6
api/app/lib/controllers/service/report.js

@ -258,6 +258,12 @@ async function postGenerateReport (ctx) {
startTime: moment().format('YYYY-MM-DD HH:mm:ss'), startTime: moment().format('YYYY-MM-DD HH:mm:ss'),
reportType: data.reportType reportType: data.reportType
}) })
await models.ReportAutomatic.update({ time: moment().format('YYYY-MM-DD HH:mm:ss') }, {
where: {
id: data.id
}
})
ctx.status = 200; ctx.status = 200;
ctx.body = res.outLink ctx.body = res.outLink
} else { } else {

2
api/app/lib/models/report_automatic.js

@ -125,7 +125,7 @@ module.exports = dc => {
}, },
time: { time: {
type: DataTypes.DATE, type: DataTypes.DATE,
allowNull: false, allowNull: true,
defaultValue: null, defaultValue: null,
comment: "", comment: "",
primaryKey: false, primaryKey: false,

2
script/3.6/schema/2.create_report_automatic.sql

@ -24,3 +24,5 @@ alter table report_automatic
add constraint report_automatic_pk add constraint report_automatic_pk
primary key (id); primary key (id);
alter table report_automatic alter column time drop not null;

23
web/client/src/sections/service/components/automatic-Modal.jsx

@ -17,10 +17,12 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
const [factorList, setFactorList] = useState([]); // const [factorList, setFactorList] = useState([]); //
const [factorChech, setFactorChech] = useState([]); // const [factorChech, setFactorChech] = useState([]); //
const [activeKey, setActiveKey] = useState([]); // const [activeKey, setActiveKey] = useState([]); //
const [correlationId, setCorrelationId] = useState([]); //
useEffect(async () => { useEffect(async () => {
if (eidtData?.id) { if (eidtData?.id) {
console.log(eidtData);
setProjectId(eidtData?.projectId) setProjectId(eidtData?.projectId)
setStructId(eidtData?.structId) setStructId(eidtData?.structId)
setFactorId(eidtData?.factors?.map(s => s.codeName) || []) setFactorId(eidtData?.factors?.map(s => s.codeName) || [])
@ -68,7 +70,7 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
projectOverview: v.projectOverview, projectOverview: v.projectOverview,
reportStartTime: moment(v.reportTime[0]).format('YYYY-MM-DD HH:mm:ss'), reportStartTime: moment(v.reportTime[0]).format('YYYY-MM-DD HH:mm:ss'),
reportEndTime: moment(v.reportTime[1]).format('YYYY-MM-DD HH:mm:ss'), reportEndTime: moment(v.reportTime[1]).format('YYYY-MM-DD HH:mm:ss'),
time: moment().format('YYYY-MM-DD HH:mm:ss'), time: eidtData?.time && moment(eidtData?.time).format('YYYY-MM-DD HH:mm:ss') || null,
factors: [] factors: []
} }
@ -115,7 +117,6 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
factorData.tempStaName = factorData?.tempName?.find(s => s.index == 2)?.name || factorData?.tempName?.find(s => s.index == 1)?.name factorData.tempStaName = factorData?.tempName?.find(s => s.index == 2)?.name || factorData?.tempName?.find(s => s.index == 1)?.name
data.factors?.push(factorData) data.factors?.push(factorData)
}) })
console.log(111, data);
dispatch(service.postAutomaticReport(data)).then((res) => { dispatch(service.postAutomaticReport(data)).then((res) => {
if (res.success) { if (res.success) {
@ -138,7 +139,7 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
> >
<Form.Input field="reportName" label='报表名称' style={{ width: 300 }} placeholder="请输入报表名称" showClear <Form.Input field="reportName" label='报表名称' style={{ width: 300 }} placeholder="请输入报表名称" showClear
initValue={eidtData?.reportName || ""} initValue={eidtData?.reportName || ""}
rules={[{ required: true, message: "请输入报表名称" }]} rules={[{ required: true, message: "请输入报表名称,15字以内", max: 15 }]}
/> />
<Form.Select label="所属项目" field="projectId" placeholder="请选择项目" showClear style={{ width: 300 }} filter <Form.Select label="所属项目" field="projectId" placeholder="请选择项目" showClear style={{ width: 300 }} filter
initValue={eidtData?.projectId || ""} initValue={eidtData?.projectId || ""}
@ -159,7 +160,7 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
</Form.Select> </Form.Select>
<Form.Input field="projectName" label='项目名称' style={{ width: 300 }} placeholder="请输入项目名称" showClear <Form.Input field="projectName" label='项目名称' style={{ width: 300 }} placeholder="请输入项目名称" showClear
initValue={eidtData?.projectName || ""} initValue={eidtData?.projectName || ""}
rules={[{ required: true, message: "请输入项目名称" }]} rules={[{ required: true, message: "请输入项目名称,15字以内", max: 15 }]}
/> />
<Form.Select label="报表类型" field="reportType" placeholder="请选择报表类型" showClear style={{ width: 300 }} <Form.Select label="报表类型" field="reportType" placeholder="请选择报表类型" showClear style={{ width: 300 }}
rules={[{ required: true, message: "请选择报表类型" }]} rules={[{ required: true, message: "请选择报表类型" }]}
@ -235,7 +236,7 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
> >
{ {
factorChech?.map(s => { factorChech?.map(s => {
return <Collapse.Panel header={s.name} itemKey={s.proto}> return <Collapse.Panel header={s.proto + s.name} itemKey={s.proto} key={s.proto}>
<div style={{ background: "#FFF" }}> <div style={{ background: "#FFF" }}>
<Form.TextArea field={s.proto + "pointDescrip"} label='布点描述' style={{ width: 400 }} autosize={{ minRows: 2, maxRows: 10 }} placeholder="请输入布点描述" showClear <Form.TextArea field={s.proto + "pointDescrip"} label='布点描述' style={{ width: 400 }} autosize={{ minRows: 2, maxRows: 10 }} placeholder="请输入布点描述" showClear
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.pointDescrip || ""} initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.pointDescrip || ""}
@ -274,6 +275,7 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
{ {
['2001', '4004', '4007', '4008'].includes(s.proto) && ['2001', '4004', '4007', '4008'].includes(s.proto) &&
<Form.DatePicker field={s.proto + 'initialTime'} label='数据初始时间' type='dateTime' showClear <Form.DatePicker field={s.proto + 'initialTime'} label='数据初始时间' type='dateTime' showClear
rules={[{ required: true, message: "请选择数据初始时间" }]}
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.initialTime && moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.initialTime).format('YYYY-MM-DD HH:mm:ss')} initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.initialTime && moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.initialTime).format('YYYY-MM-DD HH:mm:ss')}
/> />
} }
@ -281,6 +283,10 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
['4009', '3001', '4004', '4001', '4007'].includes(s.proto) && <> ['4009', '3001', '4004', '4001', '4007'].includes(s.proto) && <>
<Form.Select label="关联温度的测点" field={s.proto + "tempName1"} showClear placeholder="请选择关联的温度测点" style={{ width: 300 }} filter <Form.Select label="关联温度的测点" field={s.proto + "tempName1"} showClear placeholder="请选择关联的温度测点" style={{ width: 300 }} filter
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.tempName?.find(c => c.index == 1)?.id || ""} initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.tempName?.find(c => c.index == 1)?.id || ""}
onChange={v => {
}}
> >
{s.sensor?.map((item) => { {s.sensor?.map((item) => {
return <Form.Select.Option value={item.id} label={item.name}></Form.Select.Option> return <Form.Select.Option value={item.id} label={item.name}></Form.Select.Option>
@ -295,6 +301,9 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
})} })}
</Form.Select> </Form.Select>
<Form.DatePicker field={s.proto + 'releTime'} label='关联开始结束时间' type='dateTimeRange' showClear style={{ width: 360 }}
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.releStartTime && [moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.releStartTime).format('YYYY-MM-DD HH:mm:ss'), moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.releEndTime).format('YYYY-MM-DD HH:mm:ss')] || null}
/>
</> </>
} }
@ -304,9 +313,7 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
<Form.Input field={s.proto + "tempStaName"} label='关联温度名称' style={{ width: 300 }} placeholder="请输入关联温度名称" showClear <Form.Input field={s.proto + "tempStaName"} label='关联温度名称' style={{ width: 300 }} placeholder="请输入关联温度名称" showClear
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.tempStaName || ""} initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.tempStaName || ""}
/> */} /> */}
<Form.DatePicker field={s.proto + 'releTime'} label='关联开始结束时间' type='dateTimeRange' showClear style={{ width: 360 }}
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.releStartTime && [moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.releStartTime).format('YYYY-MM-DD HH:mm:ss'), moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.releEndTime).format('YYYY-MM-DD HH:mm:ss')] || null}
/>
</div> </div>
</Collapse.Panel> </Collapse.Panel>

14
web/client/src/sections/service/containers/automaticReport.jsx

@ -23,6 +23,7 @@ const AutomaticReport = ({ dispatch, actions, user, clientHeight, loading, gener
const [projectId, setProjectId] = useState() //id const [projectId, setProjectId] = useState() //id
const [projectSearch, setProjectSearch] = useState() // const [projectSearch, setProjectSearch] = useState() //
const [keyword, setKeyword] = useState() // const [keyword, setKeyword] = useState() //
const [id, setId] = useState()
const page = useRef(query.page);// const page = useRef(query.page);//
@ -44,6 +45,7 @@ const AutomaticReport = ({ dispatch, actions, user, clientHeight, loading, gener
if (res.success) { if (res.success) {
setTableData(res.payload.data?.rows) setTableData(res.payload.data?.rows)
setLimits(res.payload.data?.count) setLimits(res.payload.data?.count)
setId("")
} }
}) })
} }
@ -70,7 +72,7 @@ const AutomaticReport = ({ dispatch, actions, user, clientHeight, loading, gener
dataIndex: "reportType", dataIndex: "reportType",
key: 'reportType', key: 'reportType',
}, { }, {
title: "最近生时间", title: "最近生时间",
dataIndex: "time", dataIndex: "time",
key: 'time', key: 'time',
render: (txet, row) => txet && moment(txet).format('YYYY-MM-DD HH:mm:ss') || '--' render: (txet, row) => txet && moment(txet).format('YYYY-MM-DD HH:mm:ss') || '--'
@ -103,7 +105,8 @@ const AutomaticReport = ({ dispatch, actions, user, clientHeight, loading, gener
> >
<Button theme="borderless" type='danger'>删除</Button> <Button theme="borderless" type='danger'>删除</Button>
</Popconfirm> </Popconfirm>
<Button theme="borderless" loading={generateloading} onClick={() => { <Button theme="borderless" loading={id == row?.id && generateloading ? true : false} onClick={() => {
setId(row?.id)
// WSDJC(湿) 1002 // WSDJC(湿) 1002
// FSFXJC() 1001 // FSFXJC() 1001
// SSFJC() 4009 // SSFJC() 4009
@ -135,7 +138,12 @@ const AutomaticReport = ({ dispatch, actions, user, clientHeight, loading, gener
d.codeName = dataList[d.codeName] d.codeName = dataList[d.codeName]
}) })
dispatch(service.postGenerateReport(row)) dispatch(service.postGenerateReport(row)).then((res) => {
if (res.success) {
setQuery({ limit: 10, page: 0 })
getData({ limit: 10, page: 0, keyword: keyword })
}
})
}}> }}>
立即生成 立即生成
</Button> </Button>

6
web/client/src/sections/service/containers/reportFile.jsx

@ -68,10 +68,8 @@ const ReportFile = ({ dispatch, actions, user, clientHeight, loading, socket, qi
render: (_, row) => { render: (_, row) => {
return ( return (
<div style={{ display: "flex" }}> <div style={{ display: "flex" }}>
<Button theme="borderless" onClick={() => { <Button theme="borderless">
console.log(`/_file-server/${row?.url?.slice(qiniuUrl.length + 1) + '?filename=' + encodeURIComponent(row?.fileName)}`); <a href={`/_file-server/${row?.url?.slice(qiniuUrl.length + 1) + '?filename=' + encodeURIComponent(row?.fileName + '.' + row?.url.split('.')?.pop())}`}>
}}>
<a href={`/_file-server/${row?.url?.slice(qiniuUrl.length + 1) + '?filename=' + encodeURIComponent(row?.fileName)}`}>
下载 下载
</a> </a>
</Button> </Button>

Loading…
Cancel
Save