Compare commits

...

2 Commits

  1. 101
      api/app/lib/controllers/report/index.js
  2. 2
      web/client/src/sections/fillion/components/spotCheck.js

101
api/app/lib/controllers/report/index.js

@ -1129,36 +1129,30 @@ async function roadSpotChange (ctx) {
let milData = {}
let differenceValue = (parseFloat(curChangeRoad.chainageMileage) - parseFloat(curOriginRoad.chainageMileage)) || 0
if (level == '县') {
previewRes.gather && previewRes.gather.forEach(d => {
if (!d.code) {
d.countyPresent = d.countyPresent + differenceValue
d.countyDifferenceValue = d.countyDifferenceValue + differenceValue
if (previewRes.gather) {
let town = previewRes.gather['countyRoad']
if (town) {
town.countyPresent = town.countyPresent + differenceValue
town.countyDifferenceValue = town.countyDifferenceValue + differenceValue
town.countyRoadId = [...(town.countyRoadId.filter(d => d != originRoadId) || []), changeRoadId]
}
})
}
milData = { countryMil: previewRes.countryMil + differenceValue, gather: previewRes.gather }
} else if (level == '乡') {
previewRes.gather && previewRes.gather.forEach(d => {
if (d.code == curOriginRoad.townshipCode) {
d.townshipPresent = d.townshipPresent - parseFloat(curOriginRoad.chainageMileage)
d.townshipDifferenceValue = d.townshipDifferenceValue - parseFloat(curOriginRoad.chainageMileage)
}
if (d.code == curOriginRoad.curChangeRoad) {
d.villagePresent = d.villagePresent + parseFloat(curChangeRoad.chainageMileage)
d.townshipDifferenceValue = d.townshipDifferenceValue + parseFloat(curChangeRoad.chainageMileage)
}
}) || []
let town = previewRes.gather[curOriginRoad.townshipCode]
if (town) {
town.townshipPresent = town.townshipPresent + differenceValue
town.townshipDifferenceValue = town.townshipDifferenceValue + differenceValue
town.townRoadId = [...(town.townRoadId.filter(d => d != originRoadId) || []), changeRoadId]
}
milData = { townMil: previewRes.townMil + differenceValue, gather: previewRes.gather }
} else if (level == '村') {
previewRes.gather && previewRes.gather.forEach(d => {
if (d.code == curOriginRoad.townshipCode) {
d.villageParticipate = d.villageParticipate - parseFloat(curOriginRoad.chainageMileage)
d.villageDifferenceValue = d.villageDifferenceValue - parseFloat(curOriginRoad.chainageMileage)
}
if (d.code == curOriginRoad.curChangeRoad) {
d.villageParticipate = d.villageParticipate + parseFloat(curChangeRoad.chainageMileage)
d.villageDifferenceValue = d.villageDifferenceValue + parseFloat(curChangeRoad.chainageMileage)
}
}) || []
let town = previewRes.gather[curOriginRoad.townshipCode]
if (town) {
town.villagePresent = town.villagePresent + differenceValue
town.villageDifferenceValue = town.villageDifferenceValue + differenceValue
town.villageRoadId = [...(town.villageRoadId.filter(d => d != originRoadId) || []), changeRoadId]
}
milData = { villageMil: previewRes.villageMil + differenceValue, gather: previewRes.gather }
}
@ -1748,7 +1742,7 @@ async function roadSpotPrepare (ctx) {
let spotCheckCreate = await models.RoadSpotCheckPreview.update({
townshipRoadId: spotTownRoadIds,
villageRoadId: spotVillageIds,
villageRoadId: spotVillageRoadIds,
villageId: spotVillageIds,
townMil,
villageMil,
@ -1796,6 +1790,15 @@ async function exportSpotRode (ctx) {
}
})
let lastCounty = await models.RoadSpotCheckPreview.findOne({
where: {
checked: true,
id: { $lt: previewId }
},
limit: 1,
order: [['date', 'DESC']],
})
let options = {
where: {
prepareId: previewId
@ -1876,10 +1879,54 @@ async function exportSpotRode (ctx) {
subgradeWidth: road.subgradeWidth || 0,
chainageMileage: road.chainageMileage || 0,
maintenanceCount: item.maintenanceCount,
remark: true
}
})
let option = {
where: {
prepareId: lastCounty.id
},
include: [{
model: models.Road,
where: {
del: false,
}
}]
}
if (code) {
if (code == 'countyRoad') {
option.where.roadId = { $in: lastCounty.nextAbstract && lastCounty.nextAbstract['county'] || [] }
} else {
option.where.roadId = { $in: [...(lastCounty.nextAbstract && lastCounty.nextAbstract['town'] || []), ...(lastCounty.nextAbstract && lastCounty.nextAbstract['village'] || [])] }
option.include[0].where.level = { $in: ['乡', '村'] }
}
} else {
option.where.roadId = { $in: [...(lastCounty.nextAbstract && lastCounty.nextAbstract['county'] || []), ...(lastCounty.nextAbstract && lastCounty.nextAbstract['town'] || []), ...(lastCounty.nextAbstract && lastCounty.nextAbstract['village'] || [])] }
}
const res = await models.RoadSpotCheck.findAll(option) || []
if (res.length) {
res.forEach(({ dataValues: item }) => {
let road = item.road && item.road.dataValues || {}
exportData.push({
townshipCode: (town.find(d => d.code == road.townshipCode) || {}).name || '--',
villageId: (village.find(d => road.villageId == d.id) || {}).name || '--',
routeName: road.routeName,
routeCode: road.routeCode,
startStation: road.startStation || 0,
stopStation: road.stopStation || 0,
technicalLevel: road.technicalLevel,
pavementType: road.pavementType,
pavementWidth: road.pavementWidth || 0,
subgradeWidth: road.subgradeWidth || 0,
chainageMileage: road.chainageMileage || 0,
maintenanceCount: item.maintenanceCount,
remark: true
})
})
}
const fileName = `${moment(previewRes.date).format('YYYY年MM月DD日HH时mm分')}道路抽查记录` + '.csv'
let data = {

2
web/client/src/sections/fillion/components/spotCheck.js

@ -212,7 +212,7 @@ const SpotCheck = ({ dispatch, user, loading, reportDetail, editData, onCancel,
</Form.Item>
<Form.Item >
<Button disabled={countyRoadTime} style={{}} type='primary' >
<a href={`/_api/road/spot/export?token=${user?.token}&previewId=${currentValue.id}&code='countyRoad'&roadId=${currentValue?.gather && currentValue?.gather['countyRoad']?.countyRoadId?.join()}`}> 导出</a>
<a href={`/_api/road/spot/export?token=${user?.token}&previewId=${currentValue.id}&code=countyRoad&roadId=${currentValue?.gather && currentValue?.gather['countyRoad']?.countyRoadId?.join()}`}> 导出</a>
</Button>
</Form.Item>
</div>

Loading…
Cancel
Save