diff --git a/api/app/lib/models/report_automatic.js b/api/app/lib/models/report_automatic.js
index 88b8029..e0dfeb1 100644
--- a/api/app/lib/models/report_automatic.js
+++ b/api/app/lib/models/report_automatic.js
@@ -17,7 +17,7 @@ module.exports = dc => {
},
reportName: {
type: DataTypes.STRING,
- allowNull: false,
+ allowNull: true,
defaultValue: null,
comment: "",
primaryKey: false,
@@ -87,8 +87,17 @@ module.exports = dc => {
field: "ratifier",
autoIncrement: false
},
+ coverTime: {
+ type: DataTypes.DATE,
+ allowNull: true,
+ defaultValue: null,
+ comment: "",
+ primaryKey: false,
+ field: "cover_time",
+ autoIncrement: false
+ },
structId: {
- type: DataTypes.INTEGER,
+ type: DataTypes.ARRAY(DataTypes.INTEGER),
allowNull: false,
defaultValue: null,
comment: "",
@@ -96,9 +105,18 @@ module.exports = dc => {
field: "struct_id",
autoIncrement: false
},
+ structList: {
+ type: DataTypes.JSON,
+ allowNull: true,
+ defaultValue: null,
+ comment: "",
+ primaryKey: false,
+ field: "struct_list",
+ autoIncrement: false
+ },
projectOverview: {
type: DataTypes.STRING,
- allowNull: false,
+ allowNull: true,
defaultValue: null,
comment: "",
primaryKey: false,
@@ -107,7 +125,7 @@ module.exports = dc => {
},
reportStartTime: {
type: DataTypes.DATE,
- allowNull: false,
+ allowNull: true,
defaultValue: null,
comment: "开始时间",
primaryKey: false,
@@ -116,7 +134,7 @@ module.exports = dc => {
},
reportEndTime: {
type: DataTypes.DATE,
- allowNull: false,
+ allowNull: true,
defaultValue: null,
comment: "开始时间",
primaryKey: false,
@@ -134,7 +152,7 @@ module.exports = dc => {
},
factors: {
type: DataTypes.JSON,
- allowNull: false,
+ allowNull: true,
defaultValue: null,
comment: "",
primaryKey: false,
diff --git a/script/4.4/schema/1.update_report_automatic.sql b/script/4.4/schema/1.update_report_automatic.sql
new file mode 100644
index 0000000..7c4e4a1
--- /dev/null
+++ b/script/4.4/schema/1.update_report_automatic.sql
@@ -0,0 +1,22 @@
+alter table report_automatic alter column report_name drop not null;
+
+alter table report_automatic alter column report_start_time drop not null;
+
+alter table report_automatic alter column report_end_time drop not null;
+
+alter table report_automatic alter column factors drop not null;
+
+alter table report_automatic alter column project_overview drop not null;
+
+alter table report_automatic
+ add cover_time timestamp;
+
+alter table report_automatic
+ add struct_list json;
+
+alter table report_automatic drop column struct_id;
+
+alter table report_automatic
+ add struct_id integer[] not null;
+
+
diff --git a/web/client/src/sections/analysis/containers/network.jsx b/web/client/src/sections/analysis/containers/network.jsx
index 45a38b7..bfc1480 100644
--- a/web/client/src/sections/analysis/containers/network.jsx
+++ b/web/client/src/sections/analysis/containers/network.jsx
@@ -92,7 +92,7 @@ const Network = ({
>
{
- setProjectValue(v)
- setSpinning(true)
- form.current.setValue('projectId', v)
+ if (projectValue != v) {
+ setProjectValue(v)
+ setSpinning(true)
+ form.current.setValue('projectId', v)
+ }
}}
/>
({ value: d.thingId, label: d.strucName })) || []}
onSelect={v => {
- setSpinning(true)
- setThingId(v)
- form.current.setValue('thingId', v)
+ if (thingId != v) {
+ setSpinning(true)
+ setThingId(v)
+ form.current.setValue('thingId', v)
+ }
}}
/>
diff --git a/web/client/src/sections/service/components/automatic-Modal.jsx b/web/client/src/sections/service/components/automatic-Modal.jsx
index b3d5460..e666797 100644
--- a/web/client/src/sections/service/components/automatic-Modal.jsx
+++ b/web/client/src/sections/service/components/automatic-Modal.jsx
@@ -12,10 +12,11 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
const [strucData, setStrucData] = useState([]) //结构物数据
const [projectId, setProjectId] = useState(); //项目id
- const [structId, setStructId] = useState(); //结构物id
+ const [structId, setStructId] = useState([]); //结构物id
const [factorId, setFactorId] = useState([]); //监测因素id
const [factorList, setFactorList] = useState([]); //监测因素
- const [factorChech, setFactorChech] = useState([]); //选中的监测因素
+ const [structChech, setStructChech] = useState([]); //选中的结构物
+ const [factorChech, setFactorChech] = useState({}); //选中的结构物
const [activeKey, setActiveKey] = useState([]); //
const [correlationId, setCorrelationId] = useState([]); //
@@ -23,13 +24,18 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
useEffect(async () => {
if (eidtData?.id) {
setProjectId(eidtData?.projectId)
- setStructId(eidtData?.structId)
+ setStructId(eidtData?.structId || [])
setFactorId(eidtData?.factors?.map(s => s.codeName) || [])
let data = await getData(eidtData?.projectId)
- let Factor = data?.find(s => s.strucId == eidtData?.structId)?.factor || []
- setFactorList(Factor)
- setFactorChech(Factor?.filter(s => eidtData?.factors?.map(s => s.codeName)?.includes(s.proto)))
+ let struc = data?.filter(s => eidtData?.structId?.includes(s.strucId)) || []
+
+ setStructChech(struc)
+ let Factor = {}
+ struc?.forEach(d => {
+ Factor[d.strucId] = d.factor?.filter(w => eidtData?.structList?.find(h => h.structId == d.strucId)?.factors?.map(g => g.codeName)?.includes(w.id))
+ })
+ setFactorChech(Factor)
// setActiveKey(eidtData?.factors?.map(s => s.codeName) || [])
}
}, [])
@@ -48,76 +54,110 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
return (
<>
{
form.current.validate().then((v) => {
+ // console.log(11, v);
let data = {
id: eidtData?.id,
- reportName: v.reportName,
- projectId: v.projectId,
- projectName: v.projectName,
- reportType: v.reportType,
- reportPicPath: v.reportPicPath[0]?.response?.url,
- overview: v.overview[0]?.response?.url,
- framer: v.framer,
- auditor: v.auditor,
- ratifier: v.ratifier,
- structId: v.structId,
- projectOverview: v.projectOverview,
- reportStartTime: moment(v.reportTime[0]).format('YYYY-MM-DD HH:mm:ss'),
- reportEndTime: moment(v.reportTime[1]).format('YYYY-MM-DD HH:mm:ss'),
- time: eidtData?.time && moment(eidtData?.time).format('YYYY-MM-DD HH:mm:ss') || null,
- factors: []
+ reportName: v.reportName, //报表名称
+ projectId: v.projectId, //所属项目
+ projectName: v.projectName, //项目名称
+ reportType: v.reportType, //报表类型
+ reportPicPath: v.reportPicPath && v.reportPicPath[0] && v.reportPicPath[0]?.response?.url || eidtData.reportPicPath, //首页图片
+ framer: v.framer, //制定者
+ auditor: v.auditor, //审核者
+ ratifier: v.ratifier, //批准者
+ coverTime: v.coverTime && moment(v.coverTime),
+ structId: v.structId, //结构物id
+ structList: []
}
- v.factorId?.forEach(d => {
- let index = d.length
- let factorData = {}
+ v.structId?.forEach(p => {
+ let structFind = eidtData?.structList?.find(d => d.structId == p) || {}
+ let structData = { structId: p }
+ let structNameIndex = p.toString().length || 0
+
for (let key in v) {
- factorData.codeName = d
- factorData.tempName = factorData.tempName || []
- if (key?.indexOf(d) != -1) {
- if (key?.slice(index) == 'pointDescrip') factorData.pointDescrip = v[key]
- if (key?.slice(index) == 'pointPicPath') factorData.pointPicPath = v[key] && v[key][0]?.response?.url
- if (key?.slice(index) == 'factorDescrip') factorData.factorDescrip = v[key]
- if (key?.slice(index) == 'sensorNames') factorData.sensorNames = factorChech?.find(p => p.proto == d)?.sensor?.filter(f => v[key]?.includes(f.id))?.map(c => ({ id: c.id, name: c.name })) || []
- if (key?.slice(index) == 'startEndTime') {
- factorData.startTime = v[key] && moment(v[key][0]).format('YYYY-MM-DD HH:mm:ss')
- factorData.endTime = v[key] && moment(v[key][1]).format('YYYY-MM-DD HH:mm:ss')
- }
- if (key?.slice(index) == 'tempName1') {
- factorData.tempName?.push({
- index: 1,
- id: v[key],
- name: factorChech?.find(p => p.proto == d)?.sensor?.find(f => v[key] == f.id)?.name
- })
- }
- if (key?.slice(index) == 'tempName2') {
- factorData.tempName?.push({
- index: 2,
- id: v[key],
- name: factorChech?.find(p => p.proto == 1004)?.sensor?.find(f => v[key] == f.id)?.name
- })
- }
- if (key?.slice(index) == 'factorDescrip') factorData.factorDescrip = v[key]
- // if (key?.slice(index) == 'glStaName') factorData.glStaName = v[key]
- // if (key?.slice(index) == 'tempStaName') factorData.tempStaName = v[key]
- if (key?.slice(index) == 'initialTime') factorData.initialTime = v[key] && moment(v[key]).format('YYYY-MM-DD HH:mm:ss')
- if (key?.slice(index) == 'releTime') {
- factorData.releStartTime = v[key] && moment(v[key][0]).format('YYYY-MM-DD HH:mm:ss')
- factorData.releEndTime = v[key] && moment(v[key][1]).format('YYYY-MM-DD HH:mm:ss')
+ if (key?.indexOf(p) != -1) {
+ //结构物概况图片
+ if (key?.slice(structNameIndex) == 'overview') structData.overview = v[key] && v[key][0]?.response?.url || structFind.overview
+ //结构物描述
+ if (key?.slice(structNameIndex) == 'projectOverview') structData.projectOverview = v[key]
+ //结论
+ if (key?.slice(structNameIndex) == 'conclusion') structData.conclusion = v[key]
+ //开始结束时间
+ if (key?.slice(structNameIndex) == 'reportTime') {
+ structData.reportStartTime = v[key] && v[key][0] && moment(v[key][0])
+ structData.reportEndTime = v[key] && v[key][1] && moment(v[key][1])
}
+ //包含的监测因素
+ structData.factors = []
}
}
- factorData.glStaName = 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)
+
+ // debugger
+
+ v[p + 'factorId']?.forEach(d => {
+ let factorFind = structFind?.factors?.find(c => c.codeName == d) || {}
+ let index = d.toString().length + structNameIndex + 5
+ let factorData = {}
+ for (let key in v) {
+ factorData.codeName = d
+ factorData.tempName = factorData.tempName || []
+ if (key?.indexOf(p + 'struc') != -1 && key?.indexOf('struc' + d) != -1) {
+ //布点描述
+ if (key?.slice(index) == 'pointDescrip') factorData.pointDescrip = v[key]
+ //布点图片
+ if (key?.slice(index) == 'pointPicPath') factorData.pointPicPath = v[key] && v[key][0]?.response?.url ||
+ factorFind.pointPicPath
+ //索力监测描述
+ if (key?.slice(index) == 'factorDescrip') factorData.factorDescrip = v[key]
+ //测点选择
+ if (key?.slice(index) == 'sensorNames') factorData.sensorNames = factorChech[p]?.find(p => p.id == d)?.sensor?.filter(f => v[key]?.includes(f.id))?.map(c => ({ id: c.id, name: c.name })) || []
+ //开始结束时间
+ if (key?.slice(index) == 'startEndTime') {
+ factorData.startTime = v[key] && v[key][0] && moment(v[key][0])
+ factorData.endTime = v[key] && v[key][1] && moment(v[key][1])
+ }
+ //关联温度的测点
+ if (key?.slice(index) == 'tempName1') {
+ factorData.tempName?.push({
+ index: 1,
+ id: v[key],
+ name: factorChech[p]?.find(p => p.id == d)?.sensor?.find(f => v[key] == f.id)?.name
+ })
+ }
+ //温度测点
+ if (key?.slice(index) == 'tempName2') {
+ factorData.tempName?.push({
+ index: 2,
+ id: v[key],
+ name: factorChech[p]?.find(p => p.proto == 1004)?.sensor?.find(f => v[key] == f.id)?.name
+ })
+ }
+ //数据初始时间
+ if (key?.slice(index) == 'initialTime') factorData.initialTime = v[key] && moment(v[key])
+ //关联开始结束时间
+ if (key?.slice(index) == 'releTime') {
+ factorData.releStartTime = v[key] && v[key][0] && moment(v[key][0])
+ factorData.releEndTime = v[key] && v[key][1] && moment(v[key][1])
+ }
+ }
+ }
+ factorData.glStaName = 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
+ structData.factors?.push(factorData)
+ })
+
+ data.structList.push(structData)
})
+ // console.log(222, data);
dispatch(service.postAutomaticReport(data)).then((res) => {
if (res.success) {
close()
@@ -127,7 +167,7 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
})
}}
- width={700}
+ width={770}
onCancel={() => close()}
>
{
setProjectId(v)
getData(v)
- form.current.setValue('structId', null)
- setStructId("")
- setFactorList([])
- form.current.setValue('factorId', [])
- setFactorChech([])
+ form.current.setValue('structId', [])
+ setStructId([])
+ // setFactorList([])
+ // form.current.setValue('factorId', [])
+ setStructChech([])
}} >
{projectList?.map((item) => {
- return
+ return
})}
-
- } theme="light">
- 文件上传
-
-
+
+
{
- setFactorList(strucData?.find(s => s.strucId == v)?.factor || [])
+ // setFactorList(strucData?.find(s => v.includes(s.stdrucId)) || [])
setStructId(v)
- form.current.setValue('factorId', [])
- setFactorChech([])
+ // form.current.setValue('factorId', [])
+ setStructChech(strucData?.filter(s => v.includes(s.strucId)) || [])
}} >
{strucData?.map((item) => {
- return
-
- })}
-
+ return
-
-
- s.codeName) || []}
- rules={[{ required: true, message: "请选择监测因素" }]} disabled={structId ? false : true}
- onChange={v => {
- setFactorChech(factorList?.filter(s => v.includes(s.proto)))
- // setActiveKey(v)
- }} >
- {factorList?.map((item) => {
- return
})}
-
- {factorChech?.length > 0 ? 0 ? {
@@ -245,86 +259,131 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
}}
>
{
- factorChech?.map(s => {
- return
+ structChech?.map(s => {
+ let structFind = eidtData?.structList?.find(d => d.structId == s.strucId) || {}
+ return
-
c.codeName == s.proto)?.pointDescrip || ""}
- rules={[{ required: true, message: "请输入布点描述" }]}
- />
- c.codeName == s.proto)?.pointPicPath && [{ url: `/_file-server/${eidtData?.factors?.find(c => c.codeName == s.proto)?.pointPicPath?.slice(qiniuUrl.length + 1)}`, name: eidtData?.factors?.find(c => c.codeName == s.proto)?.pointPicPath?.split('/')?.pop(), status: 'success', preview: ['png', 'jpg', 'jpeg'].includes(eidtData?.factors?.find(c => c.codeName == s.proto)?.pointPicPath?.split('.')?.pop()?.replace('.', '')) }] || null}
- rules={[{ required: true, message: "请上传布点图片" }]}
+
} theme="light">
文件上传
-
- {s.proto == 2001 &&
- c.codeName == s.proto)?.factorDescrip || ""}
- />
- }
-
- c.codeName == s.proto)?.sensorNames?.map(a => a.id) || []}
- rules={[{ required: true, message: "请选择测点选择" }]}
- >
- {s.sensor?.map((item) => {
- return
- })}
-
- c.codeName == s.proto)?.startTime && [moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.startTime).format('YYYY-MM-DD HH:mm:ss'), moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.endTime).format('YYYY-MM-DD HH:mm:ss')] || null}
- rules={[{ required: true, message: "请选择开始结束时间" }]}
+
- {
- ['2001', '4004', '4007', '4008'].includes(s.proto) &&
- c.codeName == s.proto)?.initialTime && moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.initialTime).format('YYYY-MM-DD HH:mm:ss')}
- />
- }
- {
- ['4009', '3001', '4004', '4001', '4007'].includes(s.proto) && <>
- c.codeName == s.proto)?.tempName?.find(c => c.index == 1)?.id || ""}
- onChange={v => {
-
-
- }}
- >
- {s.sensor?.map((item) => {
- return
-
- })}
-
- c.codeName == s.proto)?.tempName?.find(c => c.index == 2)?.id || ""}
- >
- {factorList?.find(d => d.proto == 1004 || d.proto == 1002)?.sensor?.map((item) => {
- return
-
- })}
-
- 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}
- />
- >
- }
-
- {/* c.codeName == s.proto)?.glStaName || ""}
+ d.structId == s.strucId)?.conclusion || ""}
+ // rules={[{ required: true, message: "请输入结论" }]}
/>
- c.codeName == s.proto)?.tempStaName || ""}
- /> */}
-
+
+ s.codeName) || []}
+ rules={[{ required: true, message: "请选择监测因素" }]} disabled={structId ? false : true}
+ onChange={v => {
+ setFactorChech({ ...factorChech, [s.strucId]: s.factor?.filter(d => v.includes(d.id)) || [] })
+ // setActiveKey(v)
+ }} >
+ {s.factor?.map((item) => {
+ return
+ })}
+
+ {factorChech[s.strucId] ? {
+ // setActiveKey(v)
+ }}
+ >
+ {
+ factorChech[s.strucId]?.map(p => {
+ let factorFind = structFind?.factors?.find(c => c.codeName == p.id) || {}
+ return
+
+
+
+ } theme="light">
+ 文件上传
+
+
+
+ {s.proto == 2001 &&
+
+ }
+
+ a.id) || []}
+ rules={[{ required: true, message: "请选择测点选择" }]}
+ >
+ {p.sensor?.map((item) => {
+ return
+ })}
+
+
+ {
+ ['2001', '4004', '4007', '4008'].includes(p.proto) &&
+
+ }
+ {
+ ['4009', '3001', '4004', '4001', '4007'].includes(s.proto) && <>
+ c.index == 1)?.id || ""}
+ onChange={v => {
+
+
+ }}
+ >
+ {p.sensor?.map((item) => {
+ return
+
+ })}
+
+ c.index == 2)?.id || ""}
+ >
+ {s.factors?.find(d => d.proto == 1004 || d.proto == 1002)?.sensor?.map((item) => {
+ return
+
+ })}
+
+
+ >
+ }
+
+
+ })
+ }
+
+
+ : ""}
})
@@ -333,6 +392,7 @@ const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtDat
: ""}
+
>
diff --git a/web/client/src/sections/service/containers/automaticReport.jsx b/web/client/src/sections/service/containers/automaticReport.jsx
index e4f7763..107c045 100644
--- a/web/client/src/sections/service/containers/automaticReport.jsx
+++ b/web/client/src/sections/service/containers/automaticReport.jsx
@@ -134,11 +134,11 @@ const AutomaticReport = ({ dispatch, actions, user, clientHeight, loading, gener
4007: 'QDQXJC',
1004: 'JGWDJC'
}
- row?.factors?.forEach(d => {
- d.codeName = dataList[d.codeName]
- })
-
- dispatch(service.postGenerateReport(row)).then((res) => {
+ // row?.factors?.forEach(d => {
+ // d.codeName = dataList[d.codeName]
+ // })
+ // console.log(1212, row);
+ dispatch(service.postGenerateReport({ ...row, structId: "" })).then((res) => {
if (res.success) {
setQuery({ limit: 10, page: 0 })
getData({ limit: 10, page: 0, keyword: keyword })