From e0d6dd0140f3910f716c53330093954f4687eda6 Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Fri, 22 Dec 2023 09:18:29 +0800 Subject: [PATCH] =?UTF-8?q?(*)=20=E8=B0=83=E6=95=B4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/report/index.js | 65 ++++++++++++------- .../containers/maintenanceSpotCheck-new.js | 3 +- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index 3baa64df..de760445 100644 --- a/api/app/lib/controllers/report/index.js +++ b/api/app/lib/controllers/report/index.js @@ -3,7 +3,8 @@ const { QueryTypes } = require('sequelize'); const moment = require('moment'); const xlsxDownload = require('../../../../utils/xlsxDownload.js'); const fs = require('fs'); -async function reportList (ctx) { +const data = require('../../routes/data/index.js'); +async function reportList(ctx) { try { const models = ctx.fs.dc.models; const { limit, page, startTime, endTime, keyword, userId, reportType, isTop, asc, projectType, handleState = '', performerId = '', codeRoad } = ctx.query @@ -149,7 +150,7 @@ async function reportList (ctx) { } } -async function reportPosition (ctx) { +async function reportPosition(ctx) { try { const models = ctx.fs.dc.models; const { startTime, endTime, userId, reportType } = ctx.query @@ -199,7 +200,7 @@ async function reportPosition (ctx) { } } -async function reportDetail (ctx) { +async function reportDetail(ctx) { try { const models = ctx.fs.dc.models; const { reportId } = ctx.params @@ -228,7 +229,7 @@ async function reportDetail (ctx) { } } -async function reportHandle (ctx) { +async function reportHandle(ctx) { try { const { models } = ctx.fs.dc; @@ -258,7 +259,7 @@ async function reportHandle (ctx) { } } -async function createReport (ctx) { +async function createReport(ctx) { try { const { userId } = ctx.fs.api const models = ctx.fs.dc.models; @@ -280,7 +281,7 @@ async function createReport (ctx) { } } -async function deleteReport (ctx) { +async function deleteReport(ctx) { try { const models = ctx.fs.dc.models; const { reportId } = ctx.params; @@ -302,7 +303,7 @@ async function deleteReport (ctx) { } // TODO 小程序填写道路名称的时候的道路筛选 是一起都返回 还是不断传关键字搜索返回 -async function spotPrepare (ctx) { +async function spotPrepare(ctx) { try { const { models } = ctx.fs.dc; const sequelize = ctx.fs.dc.orm; @@ -374,7 +375,7 @@ async function spotPrepare (ctx) { } } -async function spotCheck (ctx) { +async function spotCheck(ctx) { const transaction = await ctx.fs.dc.orm.transaction(); try { const { models } = ctx.fs.dc; @@ -476,7 +477,7 @@ async function spotCheck (ctx) { } } } -async function spotCheckDetail (ctx) { +async function spotCheckDetail(ctx) { const { models } = ctx.fs.dc const { startTime, endTime } = ctx.query try { @@ -515,7 +516,7 @@ async function spotCheckDetail (ctx) { } -async function roadSpotPrepare (ctx) { +async function roadSpotPrepare(ctx) { try { const { models } = ctx.fs.dc; const sequelize = ctx.fs.dc.orm; @@ -592,7 +593,7 @@ async function roadSpotPrepare (ctx) { '乡': `route_code LIKE 'Y%'`, '村': `route_code LIKE 'C%'` } - async function getRoadTotalMileage (key, otherWhere = [], spot) { + async function getRoadTotalMileage(key, otherWhere = [], spot) { let res = await sequelize.query(` SELECT SUM(COALESCE(CAST(chainage_mileage AS DOUBLE PRECISION), 0)) AS total_mileage @@ -604,7 +605,7 @@ async function roadSpotPrepare (ctx) { return res[0][0].total_mileage || 0 } - async function getRoadSpot (key, lastRoadIds = [], inOrNot, otherWhere = []) { + async function getRoadSpot(key, lastRoadIds = [], inOrNot, otherWhere = []) { if (!lastRoadIds.length && !inOrNot) { return [] } @@ -623,11 +624,11 @@ async function roadSpotPrepare (ctx) { `, { type: QueryTypes.SELECT }); } - async function spotRoadId (key, lastRoadIds, targetMileage, otherWhere = [], villageIdList = []) { + async function spotRoadId(key, lastRoadIds, targetMileage, otherWhere = [], villageIdList = []) { let spotRoadIds = [] let accumulationMileage = 0 - async function filterRoad (otherWhere, getRepeat = true) { + async function filterRoad(otherWhere, getRepeat = true) { if (key == '村' && getRepeat == true) { @@ -859,7 +860,7 @@ async function roadSpotPrepare (ctx) { } } -async function confirmRoadSpot (ctx) { +async function confirmRoadSpot(ctx) { const transaction = await ctx.fs.dc.orm.transaction(); try { const { models } = ctx.fs.dc; @@ -919,7 +920,7 @@ async function confirmRoadSpot (ctx) { } } -async function roadSpotList (ctx) { +async function roadSpotList(ctx) { try { const { models } = ctx.fs.dc; const { startTime, endTime, page, limit } = ctx.query @@ -973,7 +974,7 @@ async function roadSpotList (ctx) { } } -async function roadSpotDetail (ctx) { +async function roadSpotDetail(ctx) { try { const { models } = ctx.fs.dc; const { previewId, keyword } = ctx.query @@ -1010,7 +1011,7 @@ async function roadSpotDetail (ctx) { } } -async function roadSpotChange (ctx) { +async function roadSpotChange(ctx) { const transaction = await ctx.fs.dc.orm.transaction(); try { const { models } = ctx.fs.dc; @@ -1032,7 +1033,7 @@ async function roadSpotChange (ctx) { } let previewUpdated = false - async function updatePreview (key) { + async function updatePreview(key) { if (previewUpdated) return if (previewRes[key] && previewRes[key].includes(originRoadId)) { @@ -1074,6 +1075,24 @@ async function roadSpotChange (ctx) { let content = '' let curOriginRoad = roadRes.find(item => item.id == originRoadId) let curChangeRoad = roadRes.find(item => item.id == changeRoadId) + const level = curChangeRoad.level; + let milData = {} + if (level == '县') { + milData = { countryMil: previewRes.countryMil + parseFloat(curChangeRoad.chainageMileage) - parseFloat(curOriginRoad.chainageMileage) } + } else if (level == '乡') { + milData = { townMil: previewRes.townMil + parseFloat(curChangeRoad.chainageMileage) - parseFloat(curOriginRoad.chainageMileage) } + } else if (level == '村') { + milData = { villageMil: previewRes.villageMil + parseFloat(curChangeRoad.chainageMileage) - parseFloat(curOriginRoad.chainageMileage) } + } + + await models.RoadSpotCheckPreview.update({ + ...milData + }, { + where: { + id: previewId + }, + transaction + }) content = `将${curOriginRoad.routeName}从${curOriginRoad.startingPlaceName}到${curOriginRoad.stopPlaceName}改为${curChangeRoad.routeName}从${curChangeRoad.startingPlaceName}到${curChangeRoad.stopPlaceName}` @@ -1117,7 +1136,7 @@ async function roadSpotChange (ctx) { } } -async function roadSpotChangList (ctx) { +async function roadSpotChangList(ctx) { try { const { models } = ctx.fs.dc; const { startTime, endTime, page, limit } = ctx.query @@ -1170,7 +1189,7 @@ async function roadSpotChangList (ctx) { } } -async function exportSpotRode (ctx) { +async function exportSpotRode(ctx) { try { const { models } = ctx.fs.dc; const { previewId } = ctx.query @@ -1220,7 +1239,7 @@ async function exportSpotRode (ctx) { title: '养护次数(次)', },] - function judgeLevel (routeCode) { + function judgeLevel(routeCode) { if (routeCode) { if (routeCode.startsWith('X')) { return '县道' @@ -1254,7 +1273,7 @@ async function exportSpotRode (ctx) { const fileName = `${moment(previewRes.date).format('YYYY年MM月DD日HH时mm分')}道路抽查记录` + '.csv' const filePath = await xlsxDownload.simpleExcelDown({ // data: exportData, header, fileName: fileName, gather: { data: previewRes.gather || [] } - data: exportData, header, fileName: fileName, + data: exportData, header, fileName: fileName, }) const fileData = fs.readFileSync(filePath); diff --git a/web/client/src/sections/fillion/containers/maintenanceSpotCheck-new.js b/web/client/src/sections/fillion/containers/maintenanceSpotCheck-new.js index 07a2a9a0..a447e19b 100644 --- a/web/client/src/sections/fillion/containers/maintenanceSpotCheck-new.js +++ b/web/client/src/sections/fillion/containers/maintenanceSpotCheck-new.js @@ -345,6 +345,7 @@ const MaintenanceSpotCheck = (props) => { }} onOk={() => { detailData({ previewId: expandedRowKeys[0], keyword: keyword }) + queryData() }} /> } @@ -354,7 +355,7 @@ const MaintenanceSpotCheck = (props) => { ) } -function mapStateToProps (state) { +function mapStateToProps(state) { const { auth, roadSpotList, reportDetail, roadSpotDetail } = state //('state1', state) return {