diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index ba499024..a81030f1 100644 --- a/api/app/lib/controllers/report/index.js +++ b/api/app/lib/controllers/report/index.js @@ -3,24 +3,22 @@ const { QueryTypes } = require('sequelize'); const moment = require('moment'); const xlsxDownload = require('../../../../utils/xlsxDownload.js'); const fs = require('fs'); -const XLSX = require('xlsx') -const path = require('path') -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 - const { userInfo } = ctx.fs.api - const sequelize = ctx.fs.dc.orm; - - let findUsers = [] - if ( - userInfo.loginSource == 'wx' - && userInfo.isAdmin - && userInfo.phone != 'SuperAdmin' - && (!performerId && !handleState) - ) { - // 是管理员但不是超管 查自己部门及下级部门的所有用户的信息 - const sqlStr = ` +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 + const { userInfo } = ctx.fs.api + const sequelize = ctx.fs.dc.orm; + + let findUsers = [] + if ( + userInfo.loginSource == 'wx' + && userInfo.isAdmin + && userInfo.phone != 'SuperAdmin' + && (!performerId && !handleState) + ) { + // 是管理员但不是超管 查自己部门及下级部门的所有用户的信息 + const sqlStr = ` WITH RECURSIVE sub_departments AS ( SELECT id, dependence FROM department @@ -36,295 +34,294 @@ async function reportList (ctx) { WHERE u.delete = false; ` - const res = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }) - findUsers = res.map(item => { - return item.id - }) - findUsers.push(-1) - } - - let findOption = { - where: { + const res = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }) + findUsers = res.map(item => { + return item.id + }) + findUsers.push(-1) + } - }, - attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'performerId', 'roadSectionEnd', 'reportType', 'address', - 'content', 'longitude', 'latitude', 'projectName', 'handleState', 'codeRoad', 'handleContent', 'handlePic', 'videoUrl', - 'scenePic'], - include: [{ - model: models.User, - attributes: ['name'] - }], - //order: [['time', asc ? 'ASC' : 'DESC']], - order: [['time', 'DESC']], + let findOption = { + where: { - } - if (limit) { - findOption.limit = limit - } - if (page && limit) { - findOption.offset = page * limit - } - if (startTime && endTime) { - findOption.where = { - time: { - '$between': [startTime, endTime] - } - } - } - if (keyword) { - if (reportType == 'road') { - findOption.where.projectName = { - '$like': `%${keyword}%` + }, + attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'performerId', 'roadSectionEnd', 'reportType', 'address', + 'content', 'longitude', 'latitude', 'projectName', 'handleState', 'codeRoad', 'handleContent', 'handlePic', 'videoUrl', + 'scenePic'], + include: [{ + model: models.User, + attributes: ['name'] + }], + //order: [['time', asc ? 'ASC' : 'DESC']], + order: [['time', 'DESC']], + + } + if (limit) { + findOption.limit = limit + } + if (page && limit) { + findOption.offset = page * limit + } + if (startTime && endTime) { + findOption.where = { + time: { + '$between': [startTime, endTime] + } } - } else { - findOption.where.road = { - '$like': `%${keyword}%` + } + if (keyword) { + if (reportType == 'road') { + findOption.where.projectName = { + '$like': `%${keyword}%` + } + } else { + findOption.where.road = { + '$like': `%${keyword}%` + } } - } - } - if (userId) { - findOption.where.userId = { $in: userId.split(',').map(Number) } - } - if (findUsers.length) { - findOption.where.userId = { $in: findUsers } - } - if (reportType) { - findOption.where.reportType = reportType - } - if (projectType) { - findOption.where.projectType = projectType - } - if (performerId) { - let performerIds = performerId.split(',') - findOption.where.performerId = { $in: performerIds } - } - if (handleState) { - let handleStates = handleState.split(',') - findOption.where.handleState = { $in: handleStates } - } - if (codeRoad) { - findOption.where.codeRoad = codeRoad - } - - let reportRes = null; - - if (isTop) { - const sqlStr = ` + } + if (userId) { + findOption.where.userId = { $in: userId.split(',').map(Number) } + } + if (findUsers.length) { + findOption.where.userId = { $in: findUsers } + } + if (reportType) { + findOption.where.reportType = reportType + } + if (projectType) { + findOption.where.projectType = projectType + } + if (performerId) { + let performerIds = performerId.split(',') + findOption.where.performerId = { $in: performerIds } + } + if (handleState) { + let handleStates = handleState.split(',') + findOption.where.handleState = { $in: handleStates } + } + if (codeRoad) { + findOption.where.codeRoad = codeRoad + } + + let reportRes = null; + + if (isTop) { + const sqlStr = ` select NR.*, "user".name as user_name from (SELECT R.*, "row_number"() OVER (PARTITION BY R.user_id ORDER BY R."time" DESC) AS NEWINDEX FROM report AS R ${reportType ? ` where report_type = '${reportType}' `: '' - } + } ) AS NR left join "user" on "user".id = NR.user_id WHERE NEWINDEX = 1 order by id desc; ` - reportRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }); - if (reportType == 'road') { - const projectNameArr = reportRes.map(item => item.project_name).filter(item => item) - const projectRes = projectNameArr.length ? await models.Project.findAll({ - where: { - entryName: { $in: projectNameArr } - } - }) : [] - for (let r of reportRes) { - let corProject = projectRes.find(item => item.entryName == r.project_name) - if (corProject) { - r.project = corProject.dataValues - } + reportRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }); + if (reportType == 'road') { + const projectNameArr = reportRes.map(item => item.project_name).filter(item => item) + const projectRes = projectNameArr.length ? await models.Project.findAll({ + where: { + entryName: { $in: projectNameArr } + } + }) : [] + for (let r of reportRes) { + let corProject = projectRes.find(item => item.entryName == r.project_name) + if (corProject) { + r.project = corProject.dataValues + } + } } - } - } else { - reportRes = await models.Report.findAll(findOption) - } - - ctx.status = 200; - ctx.body = reportRes - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + } else { + reportRes = await models.Report.findAll(findOption) + } + + ctx.status = 200; + ctx.body = reportRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function reportPosition (ctx) { - try { - const models = ctx.fs.dc.models; - const { startTime, endTime, userId, reportType } = ctx.query - const sequelize = ctx.fs.dc.ORM; - - let findMxTimeOption = { - attributes: [ - 'userId', - [sequelize.fn('MAX', sequelize.col('time')), 'maxTime'], - ], - where: { - - }, - group: ['report.user_id'], - } +async function reportPosition(ctx) { + try { + const models = ctx.fs.dc.models; + const { startTime, endTime, userId, reportType } = ctx.query + const sequelize = ctx.fs.dc.ORM; + + let findMxTimeOption = { + attributes: [ + 'userId', + [sequelize.fn('MAX', sequelize.col('time')), 'maxTime'], + ], + where: { - if (startTime && endTime) { - findMxTimeOption.where = { - time: { - '$between': [startTime, endTime] + }, + group: ['report.user_id'], + } + + if (startTime && endTime) { + findMxTimeOption.where = { + time: { + '$between': [startTime, endTime] + } } - } - } - - if (userId) { - findMxTimeOption.where.userId = userId - } - if (reportType) { - findMxTimeOption.where.reportType = reportType - } - - const reportMaxTimeRes = await models.Report.findAll(findMxTimeOption) - const timeArr = reportMaxTimeRes.map(item => item.dataValues.maxTime) - const reportRes = await models.Report.findAll({ - where: { - time: { '$in': timeArr } - } - }) - ctx.status = 200; - ctx.body = reportRes - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + } + + if (userId) { + findMxTimeOption.where.userId = userId + } + if (reportType) { + findMxTimeOption.where.reportType = reportType + } + + const reportMaxTimeRes = await models.Report.findAll(findMxTimeOption) + const timeArr = reportMaxTimeRes.map(item => item.dataValues.maxTime) + const reportRes = await models.Report.findAll({ + where: { + time: { '$in': timeArr } + } + }) + ctx.status = 200; + ctx.body = reportRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function reportDetail (ctx) { - try { - const models = ctx.fs.dc.models; - const { reportId } = ctx.params +async function reportDetail(ctx) { + try { + const models = ctx.fs.dc.models; + const { reportId } = ctx.params - const reportRes = await models.Report.findOne({ - where: { - id: reportId - }, - include: [{ - model: models.Road, + const reportRes = await models.Report.findOne({ where: { - del: false + id: reportId }, - as: 'road_', - }], - }) - - ctx.status = 200; - ctx.body = reportRes - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + include: [{ + model: models.Road, + where: { + del: false + }, + as: 'road_', + }], + }) + + ctx.status = 200; + ctx.body = reportRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function reportHandle (ctx) { - try { - const { models } = ctx.fs.dc; - - const { reportId } = ctx.params - const { handleState } = ctx.request.body - const data = ctx.request.body - /** - * data = { - * handleState, - * handleContent, - * handlePic - * } - */ - await models.Report.update(data, { - where: { - id: reportId - } - }) - - ctx.status = 200; - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } +async function reportHandle(ctx) { + try { + const { models } = ctx.fs.dc; + + const { reportId } = ctx.params + const { handleState } = ctx.request.body + const data = ctx.request.body + /** + * data = { + * handleState, + * handleContent, + * handlePic + * } + */ + await models.Report.update(data, { + where: { + id: reportId + } + }) + + ctx.status = 200; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function createReport (ctx) { - try { - const { userId } = ctx.fs.api - const models = ctx.fs.dc.models; - const data = ctx.request.body; - - await models.Report.create({ - ...data, - userId, - time: new Date(), - }) - - ctx.status = 204 - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } +async function createReport(ctx) { + try { + const { userId } = ctx.fs.api + const models = ctx.fs.dc.models; + const data = ctx.request.body; + + await models.Report.create({ + ...data, + userId, + time: new Date(), + }) + + ctx.status = 204 + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function deleteReport (ctx) { - try { - const models = ctx.fs.dc.models; - const { reportId } = ctx.params; - - await models.Report.destroy({ - where: { - id: reportId - } - }) +async function deleteReport(ctx) { + try { + const models = ctx.fs.dc.models; + const { reportId } = ctx.params; - ctx.status = 204 - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + await models.Report.destroy({ + where: { + id: reportId + } + }) + + ctx.status = 204 + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } // TODO 小程序填写道路名称的时候的道路筛选 是一起都返回 还是不断传关键字搜索返回 - -async function spotPrepare (ctx) { - try { - const { models } = ctx.fs.dc; - const sequelize = ctx.fs.dc.orm; - const { percentage } = ctx.request.body; - const departmentIdRes = await models.Department.findAll({ - attributes: ['id', 'name'], - where: { - dependence: null, - delete: false, - } - }) - let lukyDepartment = '' - if (departmentIdRes.length) { - lukyDepartment = departmentIdRes[(Math.round(Math.random() * departmentIdRes.length) || 1) - 1] - } else { - throw `暂无乡镇信息` - } - - const sqlStr = ` +async function spotPrepare(ctx) { + try { + const { models } = ctx.fs.dc; + const sequelize = ctx.fs.dc.orm; + const { percentage } = ctx.request.body; + const departmentIdRes = await models.Department.findAll({ + attributes: ['id', 'name'], + where: { + dependence: null, + delete: false, + } + }) + let lukyDepartment = '' + if (departmentIdRes.length) { + lukyDepartment = departmentIdRes[(Math.round(Math.random() * departmentIdRes.length) || 1) - 1] + } else { + throw `暂无乡镇信息` + } + + const sqlStr = ` WITH RECURSIVE sub_departments AS ( SELECT id, dependence FROM department @@ -340,60 +337,60 @@ async function spotPrepare (ctx) { WHERE u.delete = false; ` - const userRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }) - let findUsers = [] - findUsers = userRes.map(item => { - return item.id - }) - - const reportCount = findUsers.length ? await models.Report.count({ - where: { - reportType: 'conserve', - userId: { $in: findUsers } - } - }) : 0 - - const previewRes = await models.ReportSpotCheckPreview.create({ - percentage: percentage, - departmentId: lukyDepartment.id, - date: moment().format(), - reportCount: reportCount, - checked: false, - }) - + const userRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }) + let findUsers = [] + findUsers = userRes.map(item => { + return item.id + }) - ctx.status = 200; - ctx.body = { - lukyDepartment, - reportCount, - previewId: previewRes.id - } - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + const reportCount = findUsers.length ? await models.Report.count({ + where: { + reportType: 'conserve', + userId: { $in: findUsers } + } + }) : 0 + + const previewRes = await models.ReportSpotCheckPreview.create({ + percentage: percentage, + departmentId: lukyDepartment.id, + date: moment().format(), + reportCount: reportCount, + checked: false, + }) + + + ctx.status = 200; + ctx.body = { + lukyDepartment, + reportCount, + previewId: previewRes.id + } + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function spotCheck (ctx) { - const transaction = await ctx.fs.dc.orm.transaction(); - try { - const { models } = ctx.fs.dc; - const sequelize = ctx.fs.dc.orm; - const { previewId } = ctx.query - if (!previewId) { - throw '参数错误' - } - - const prepareRes = await models.ReportSpotCheckPreview.findOne({ - where: { - id: previewId - } - }) +async function spotCheck(ctx) { + const transaction = await ctx.fs.dc.orm.transaction(); + try { + const { models } = ctx.fs.dc; + const sequelize = ctx.fs.dc.orm; + const { previewId } = ctx.query + if (!previewId) { + throw '参数错误' + } + + const prepareRes = await models.ReportSpotCheckPreview.findOne({ + where: { + id: previewId + } + }) - const sqlStr = ` + const sqlStr = ` WITH RECURSIVE sub_departments AS ( SELECT id, dependence FROM department @@ -409,195 +406,193 @@ async function spotCheck (ctx) { WHERE u.delete = false; ` - const userRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }) - let findUsers = [] - findUsers = userRes.map(item => { - return item.id - }) - let checkCount = Math.ceil(prepareRes.reportCount * (prepareRes.percentage / 100)) + const userRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }) + let findUsers = [] + findUsers = userRes.map(item => { + return item.id + }) + let checkCount = Math.ceil(prepareRes.reportCount * (prepareRes.percentage / 100)) - const reportRes = await findUsers.length && checkCount ? await models.Report.findAll({ - where: { - reportType: 'conserve', - userId: { $in: findUsers }, - }, - include: [{ - model: models.User, - attributes: ['name'] - }], - order: sequelize.random(), // 随机排序 - limit: checkCount, // 限制返回的记录数 - }) : [] - - await models.ReportSpotCheckPreview.update({ - checked: true - }, { - where: { - id: previewId - } - }) - if (reportRes.length) { - let spotDate = moment().format('YYYY-MM-DD') - await models.ReportSpotCheck.bulkCreate(reportRes.map(r => { - return { - reportId: r.id, - spotDate: spotDate, - prepareId: previewId + const reportRes = await findUsers.length && checkCount ? await models.Report.findAll({ + where: { + reportType: 'conserve', + userId: { $in: findUsers }, + }, + include: [{ + model: models.User, + attributes: ['name'] + }], + order: sequelize.random(), // 随机排序 + limit: checkCount, // 限制返回的记录数 + }) : [] + + await models.ReportSpotCheckPreview.update({ + checked: true + }, { + where: { + id: previewId } - })) - } - const rslt = findUsers.length && checkCount ? await models.ReportSpotCheckPreview.findAll({ - where: { - checked: 'true', - id: previewId - }, - include: [{ - model: models.Department, - attributes: ['name'] - }, { - model: models.ReportSpotCheck, + }) + if (reportRes.length) { + let spotDate = moment().format('YYYY-MM-DD') + await models.ReportSpotCheck.bulkCreate(reportRes.map(r => { + return { + reportId: r.id, + spotDate: spotDate, + prepareId: previewId + } + })) + } + const rslt = findUsers.length && checkCount ? await models.ReportSpotCheckPreview.findAll({ + where: { + checked: 'true', + id: previewId + }, include: [{ - model: models.Report, - include: [{ - model: models.User, - attributes: ['name'] - }], - }] - } - ], - }) : [] - - await transaction.commit(); - ctx.status = 200; - ctx.body = rslt - } catch (error) { - await transaction.rollback(); - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + model: models.Department, + attributes: ['name'] + }, { + model: models.ReportSpotCheck, + include: [{ + model: models.Report, + include: [{ + model: models.User, + attributes: ['name'] + }], + }] + } + ], + }) : [] + + await transaction.commit(); + ctx.status = 200; + ctx.body = rslt + } catch (error) { + await transaction.rollback(); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function spotCheckDetail (ctx) { - const { models } = ctx.fs.dc - const { startTime, endTime } = ctx.query - try { - const res = await models.ReportSpotCheckPreview.findAll({ - where: { - checked: 'true' - }, - order: [['date', 'DESC']], - include: [{ - model: models.Department, - attributes: ['name'] - }, { - model: models.ReportSpotCheck, - where: { spotDate: { $between: [moment(startTime).format('YYYY-MM-DD'), moment(endTime).format('YYYY-MM-DD')] } }, - order: [['spot_date', 'DESC']], +async function spotCheckDetail(ctx) { + const { models } = ctx.fs.dc + const { startTime, endTime } = ctx.query + try { + const res = await models.ReportSpotCheckPreview.findAll({ + where: { + checked: 'true' + }, + order: [['date', 'DESC']], include: [{ - model: models.Report, - order: [['date', 'DESC']], - include: [{ - model: models.User, - attributes: ['name'] - }], - }] - } - ], - }) - ctx.body = res - ctx.status = 200 - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) - ctx.status = 400 - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + model: models.Department, + attributes: ['name'] + }, { + model: models.ReportSpotCheck, + where: { spotDate: { $between: [moment(startTime).format('YYYY-MM-DD'), moment(endTime).format('YYYY-MM-DD')] } }, + order: [['spot_date', 'DESC']], + include: [{ + model: models.Report, + order: [['date', 'DESC']], + include: [{ + model: models.User, + attributes: ['name'] + }], + }] + } + ], + }) + ctx.body = res + ctx.status = 200 + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) + ctx.status = 400 + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function roadSpotPrepare (ctx) { - try { - const { models } = ctx.fs.dc; - const sequelize = ctx.fs.dc.orm; - const { countyPercentage } = ctx.request.body; - - const lastSpotRes = await models.RoadSpotCheckPreview.findOne({ - where: { - checked: true - }, - // attributes: ['id', 'countyPercentage', 'date',], - order: [['date', 'DESC']], - // include: [{ - // model: models.RoadSpotCheck, - // include: [{ - // model: models.Road, - // // attributes: ['id', 'name'] - // }] - // }] - }) - - let lastCountyPercentage = 0 // 最后一次的县道百分比 - - let lastCountyRoadIds = [] // 上次查得的县道id - let lastTownRoadIds = [] // 上次查得的乡镇道id - let lastVillageRoadRoadIds = [] // 上次查得的村道id - let lastVillageIds = [] +async function roadSpotPrepare(ctx) { + try { + const { models } = ctx.fs.dc; + const sequelize = ctx.fs.dc.orm; + const { countyPercentage } = ctx.request.body; - if (lastSpotRes) { - lastCountyPercentage = lastSpotRes.countyPercentage - lastCountyRoadIds = lastSpotRes.countyRoadId || [] - - let lastCounty = await models.RoadSpotCheckPreview.findAll({ + const lastSpotRes = await models.RoadSpotCheckPreview.findOne({ where: { - checked: true, - id: { $lt: lastSpotRes.id } + checked: true }, - limit: 3, + // attributes: ['id', 'countyPercentage', 'date',], order: [['date', 'DESC']], - }) - - if (lastCounty) { - lastCounty.forEach(d => { - lastTownRoadIds = lastTownRoadIds.concat(d.townshipRoadId) || [] - + // include: [{ + // model: models.RoadSpotCheck, + // include: [{ + // model: models.Road, + // // attributes: ['id', 'name'] + // }] + // }] + }) + + let lastCountyPercentage = 0 // 最后一次的县道百分比 + let lastCountyRoadIds = [] // 上次查得的县道id + let lastTownRoadIds = [] // 上次查得的乡镇道id + let lastVillageRoadRoadIds = [] // 上次查得的村道id + let lastVillageIds = [] + + if (lastSpotRes) { + lastCountyPercentage = lastSpotRes.countyPercentage + lastCountyRoadIds = lastSpotRes.countyRoadId || [] + + let lastCounty = await models.RoadSpotCheckPreview.findAll({ + where: { + checked: true, + id: { $lt: lastSpotRes.id } + }, + limit: 3, + order: [['date', 'DESC']], }) - } - let lastVillage = await models.RoadSpotCheckPreview.findAll({ - where: { - checked: true, - id: { $lt: lastSpotRes.id } - }, - limit: 9, - order: [['date', 'DESC']], - }) + if (lastCounty) { + lastCounty.forEach(d => { + lastTownRoadIds = lastTownRoadIds.concat(d.townshipRoadId) || [] - if (lastVillage) { - lastVillage.forEach(d => { - lastVillageRoadRoadIds = lastVillageRoadRoadIds.concat(d.villageRoadId) || [] - lastVillageIds = lastVillageIds.concat(d.villageId) || [] + }) + } + let lastVillage = await models.RoadSpotCheckPreview.findAll({ + where: { + checked: true, + id: { $lt: lastSpotRes.id } + }, + limit: 9, + order: [['date', 'DESC']], }) - } + if (lastVillage) { + lastVillage.forEach(d => { + lastVillageRoadRoadIds = lastVillageRoadRoadIds.concat(d.villageRoadId) || [] + lastVillageIds = lastVillageIds.concat(d.villageId) || [] - // lastTownRoadIds = lastSpotRes.townshipRoadId || [] - // lastVillageRoadRoadIds = lastSpotRes.villageRoadId || [] - // lastVillageIds = lastSpotRes.villageId || [] - } + }) + } - // 先查上次没查的范围内的 然后比较百分比 如果重叠 再查上次查过的 - let keyMap = { - '县': `route_code LIKE 'X%'`, - '乡': `route_code LIKE 'Y%'`, - '村': `route_code LIKE 'C%'` - } - async function getRoadTotalMileage (key, otherWhere = []) { - let res = await sequelize.query(` + // lastTownRoadIds = lastSpotRes.townshipRoadId || [] + // lastVillageRoadRoadIds = lastSpotRes.villageRoadId || [] + // lastVillageIds = lastSpotRes.villageId || [] + } + + // 先查上次没查的范围内的 然后比较百分比 如果重叠 再查上次查过的 + let keyMap = { + '县': `route_code LIKE 'X%'`, + '乡': `route_code LIKE 'Y%'`, + '村': `route_code LIKE 'C%'` + } + async function getRoadTotalMileage(key, otherWhere = []) { + let res = await sequelize.query(` SELECT SUM(COALESCE(CAST(chainage_mileage AS DOUBLE PRECISION), 0)) AS total_mileage FROM road @@ -605,97 +600,102 @@ async function roadSpotPrepare (ctx) { AND spot = true AND ${keyMap[key]} ${otherWhere.length ? `AND ${otherWhere.join(' AND ')}` : ''} `) - return res[0][0].total_mileage - } + return res[0][0].total_mileage + } - async function getRoadSpot (key, lastRoadIds = [], inOrNot, otherWhere = []) { - if (!lastRoadIds.length && !inOrNot) { - return [] - } - return await sequelize.query(` + async function getRoadSpot(key, lastRoadIds = [], inOrNot, otherWhere = []) { + if (!lastRoadIds.length && !inOrNot) { + return [] + } + return await sequelize.query(` SELECT id, chainage_mileage FROM road WHERE del = false AND spot = true AND ${keyMap[key]} ${lastRoadIds.length ? - `AND id ${inOrNot ? 'IN' : 'NOT IN'} ( + `AND id ${inOrNot ? 'IN' : 'NOT IN'} ( ${lastRoadIds.map(item => `'${item}'`).join(',')},-1 )` : '' - } + } AND chainage_mileage IS NOT NULL ${otherWhere.length ? `AND ${otherWhere.join(' AND ')}` : ''} ORDER BY RANDOM() `, { type: QueryTypes.SELECT }); - } - - async function spotRoadId (key, lastRoadIds, targetMileage, otherWhere = [], villageIdList = []) { - let spotRoadIds = [] - let accumulationMileage = 0 - - async function filterRoad (otherWhere, getRepeat = true) { - - if (key == '村' && getRepeat == true) { - - } else { - let roadUnSpotedRes = await getRoadSpot(key, lastRoadIds, false, otherWhere) - - for (let r of roadUnSpotedRes) { - spotRoadIds.push(r.id) - accumulationMileage += parseFloat(r.chainage_mileage) - if (accumulationMileage >= targetMileage) { - break; - } - } + } + + async function spotRoadId(key, lastRoadIds, targetMileage, otherWhere = [], villageIdList = []) { + let spotRoadIds = [] + let accumulationMileage = 0 + + async function filterRoad(otherWhere, getRepeat = true) { + + if (key == '村' && getRepeat == true) { + + } else { + let roadUnSpotedRes = await getRoadSpot(key, lastRoadIds, false, otherWhere) + + for (let r of roadUnSpotedRes) { + spotRoadIds.push(r.id) + accumulationMileage += parseFloat(r.chainage_mileage) + if (accumulationMileage >= targetMileage) { + break; + } + } + } + + if (accumulationMileage < targetMileage && getRepeat) { + // 还小于 说明没取够 + let roadUnSpotedRepeatRes = await getRoadSpot( + key, + lastRoadIds, + true, + otherWhere + ) + for (let r of roadUnSpotedRepeatRes) { + spotRoadIds.push(r.id) + accumulationMileage += parseFloat(r.chainage_mileage) + if (accumulationMileage >= targetMileage) { + + break; + } + } + } } - if (accumulationMileage < targetMileage && getRepeat) { - // 还小于 说明没取够 - let roadUnSpotedRepeatRes = await getRoadSpot( - key, - lastRoadIds, - true, - otherWhere - ) - for (let r of roadUnSpotedRepeatRes) { - spotRoadIds.push(r.id) - accumulationMileage += parseFloat(r.chainage_mileage) - if (accumulationMileage >= targetMileage) { - break; - } - } + if (key == '村') { + for await (let villageId of villageIdList) { + await filterRoad([ + ...otherWhere, + `village_id=${villageId}` + ], false) + + spotVillageIds.push(villageId) + + if (accumulationMileage >= targetMileage) { + break; + } + } + if (accumulationMileage < targetMileage) { + // 还小于 说明没取够 + await filterRoad(otherWhere, true) + } + } else { + await filterRoad(otherWhere, true) } - } - if (key == '村') { - for await (let villageId of villageIdList) { - await filterRoad([ - ...otherWhere, - `village_id=${villageId}` - ], false) + return [spotRoadIds, accumulationMileage] + } + let villageMil = 0, townMil = 0, countryMil = 0; - spotVillageIds.push(villageId) - - if (accumulationMileage >= targetMileage) { - break; - } - } - if (accumulationMileage < targetMileage) { - // 还小于 说明没取够 - await filterRoad(otherWhere, true) - } - } else { - await filterRoad(otherWhere, true) - } + // 抽县 + const countryRoadTotalMileage = await getRoadTotalMileage('县') + const countryRoadNeedMileage = countryRoadTotalMileage * countyPercentage / 100 + let spotCountyRoadIdsArr = await spotRoadId('县', lastCountyRoadIds, countryRoadNeedMileage, []) + let spotCountyRoadIds = spotCountyRoadIdsArr[0] + let countryMil_ = spotCountyRoadIdsArr[1] + if (countryMil_) countryMil += countryMil_; - return spotRoadIds - } - - // 抽县 - const countryRoadTotalMileage = await getRoadTotalMileage('县') - const countryRoadNeedMileage = countryRoadTotalMileage * countyPercentage / 100 - let spotCountyRoadIds = await spotRoadId('县', lastCountyRoadIds, countryRoadNeedMileage, []) - - // 抽乡 - const allTownCodeRes = await sequelize.query(` + // 抽乡 + const allTownCodeRes = await sequelize.query(` SELECT DISTINCT township_code FROM road @@ -704,25 +704,28 @@ async function roadSpotPrepare (ctx) { AND township_code IS NOT NULL `, { type: QueryTypes.SELECT }); - let spotTownRoadIds = [] - let spotVillageRoadIds = [] - let spotVillageIds = [] - for await (let t of allTownCodeRes) { - // 遍历每个乡镇并抽取 - let otherWhere = [`township_code='${t.township_code}'`] - const townRoadTotalMileage = await getRoadTotalMileage('乡', otherWhere) - const townRoadNeedMileage = townRoadTotalMileage * 25 / 100 - - let spotTownRoadIds_ = await spotRoadId('乡', lastTownRoadIds, townRoadNeedMileage, otherWhere) - spotTownRoadIds = spotTownRoadIds.concat(spotTownRoadIds_) - - // 抽村 - const villageRoadTotalMileage = await getRoadTotalMileage('村', otherWhere) - const villageRoadNeedMileage = villageRoadTotalMileage * 10 / 100 - - let spotFirstVillageId = -1 - // 随机选取一个不在上次查过的村 - let villageRes = await sequelize.query(` + let spotTownRoadIds = [] + let spotVillageRoadIds = [] + let spotVillageIds = [] + + for await (let t of allTownCodeRes) { + // 遍历每个乡镇并抽取 + let otherWhere = [`township_code='${t.township_code}'`] + const townRoadTotalMileage = await getRoadTotalMileage('乡', otherWhere) + const townRoadNeedMileage = townRoadTotalMileage * 25 / 100 + + let spotTownRoadIdsArr = await spotRoadId('乡', lastTownRoadIds, townRoadNeedMileage, otherWhere) + let spotTownRoadIds_ = spotTownRoadIdsArr[0] + let townMil_ = spotTownRoadIdsArr[1] + spotTownRoadIds = spotTownRoadIds.concat(spotTownRoadIds_) + if (townMil_) townMil += townMil_ + // 抽村 + const villageRoadTotalMileage = await getRoadTotalMileage('村', otherWhere) + const villageRoadNeedMileage = villageRoadTotalMileage * 10 / 100 + + let spotFirstVillageId = -1 + // 随机选取一个不在上次查过的村 + let villageRes = await sequelize.query(` SELECT id FROM village WHERE township_code = '${t.township_code}' ${lastVillageIds.length ? `AND id NOT IN ( @@ -731,80 +734,90 @@ async function roadSpotPrepare (ctx) { ORDER BY RANDOM() LIMIT 1 `, { type: QueryTypes.SELECT }); - if (!villageRes.length) { - // 没有村了,随机选一个 - villageRes = await sequelize.query(` + if (!villageRes.length) { + // 没有村了,随机选一个 + villageRes = await sequelize.query(` SELECT id FROM village WHERE township_code = '${t.township_code}' ORDER BY RANDOM() LIMIT 1 `, { type: QueryTypes.SELECT }); - } - if (villageRes.length) { - spotVillageIds.push(villageRes[0].id) - spotFirstVillageId = villageRes[0].id - } else { - continue; - } + } + if (villageRes.length) { + spotVillageIds.push(villageRes[0].id) + spotFirstVillageId = villageRes[0].id + } else { + continue; + } - const villageNearRes = await sequelize.query(` + const villageNearRes = await sequelize.query(` SELECT id,calc_village,distance FROM village_distance WHERE origin_village = ${spotFirstVillageId} ORDER BY distance ASC `, { type: QueryTypes.SELECT }) - let villageCheckIdList = villageNearRes.map(item => item.calc_village) - villageCheckIdList.unshift(spotFirstVillageId) - villageCheckIdList = [...(new Set(villageCheckIdList))] - - let spotVillageRoadIds_ = await spotRoadId('村', lastVillageRoadRoadIds, villageRoadNeedMileage, otherWhere, villageCheckIdList) - spotVillageRoadIds = spotVillageRoadIds.concat(spotVillageRoadIds_) - } - - const previewRes = await models.RoadSpotCheckPreview.create({ - countyPercentage: countyPercentage, - date: moment().format(), - countyRoadId: spotCountyRoadIds, - townshipRoadId: spotTownRoadIds, - villageRoadId: spotVillageRoadIds, - villageId: spotVillageIds, - checked: false - }) - - ctx.status = 200; - ctx.body = { - previewId: previewRes.id, - spotCountyRoadCount: spotCountyRoadIds.length, - spotTownRoadCount: spotTownRoadIds.length, - spotVillageRoadCount: spotVillageRoadIds.length, - } - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + let villageCheckIdList = villageNearRes.map(item => item.calc_village) + villageCheckIdList.unshift(spotFirstVillageId) + villageCheckIdList = [...(new Set(villageCheckIdList))] + + let spotVillageRoadIdsArr = await spotRoadId('村', lastVillageRoadRoadIds, villageRoadNeedMileage, otherWhere, villageCheckIdList) + let spotVillageRoadIds_ = spotVillageRoadIdsArr[0] + let villageMil_ = spotVillageRoadIdsArr[1] + spotVillageRoadIds = spotVillageRoadIds.concat(spotVillageRoadIds_) + if (villageMil_) villageMil += villageMil_ + } + + const previewRes = await models.RoadSpotCheckPreview.create({ + countyPercentage: countyPercentage, + date: moment().format(), + countyRoadId: spotCountyRoadIds, + townshipRoadId: spotTownRoadIds, + villageRoadId: spotVillageRoadIds, + villageId: spotVillageIds, + checked: false, + villageMil, + townMil, + countryMil + }) + + ctx.status = 200; + ctx.body = { + previewId: previewRes.id, + spotCountyRoadCount: spotCountyRoadIds.length, + spotTownRoadCount: spotTownRoadIds.length, + spotVillageRoadCount: spotVillageRoadIds.length, + villageMil, + townMil, + countryMil + + } + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function confirmRoadSpot (ctx) { - const transaction = await ctx.fs.dc.orm.transaction(); - try { - const { models } = ctx.fs.dc; - const sequelize = ctx.fs.dc.orm; - const { previewId } = ctx.request.body +async function confirmRoadSpot(ctx) { + const transaction = await ctx.fs.dc.orm.transaction(); + try { + const { models } = ctx.fs.dc; + const sequelize = ctx.fs.dc.orm; + const { previewId } = ctx.request.body - const prepareRes = await models.RoadSpotCheckPreview.findOne({ - where: { - id: previewId - } - }) - let spotedRoadIds = [] - spotedRoadIds = spotedRoadIds.concat(prepareRes.dataValues.countyRoadId) - spotedRoadIds = spotedRoadIds.concat(prepareRes.dataValues.townshipRoadId) - spotedRoadIds = spotedRoadIds.concat(prepareRes.dataValues.villageRoadId) + const prepareRes = await models.RoadSpotCheckPreview.findOne({ + where: { + id: previewId + } + }) + let spotedRoadIds = [] + spotedRoadIds = spotedRoadIds.concat(prepareRes.dataValues.countyRoadId) + spotedRoadIds = spotedRoadIds.concat(prepareRes.dataValues.townshipRoadId) + spotedRoadIds = spotedRoadIds.concat(prepareRes.dataValues.villageRoadId) - const conserveCountRes = await sequelize.query(` + const conserveCountRes = await sequelize.query(` SELECT road_id, COUNT(road_id) as count FROM report WHERE road_id IN ( @@ -813,286 +826,289 @@ async function confirmRoadSpot (ctx) { GROUP BY road_id `, { type: QueryTypes.SELECT }) - let spotRslt = [] - for await (let item of spotedRoadIds) { - let corConserveCount = conserveCountRes.find(cc => cc.road_id == item) - spotRslt.push({ - roadId: item, - maintenanceCount: corConserveCount ? corConserveCount.count : 0, - prepareId: previewId - }) - } - - await models.RoadSpotCheck.bulkCreate(spotRslt, { - transaction - }) - await models.RoadSpotCheckPreview.update({ - checked: true - }, { - where: { - id: previewId - }, - transaction - }) + let spotRslt = [] + for await (let item of spotedRoadIds) { + let corConserveCount = conserveCountRes.find(cc => cc.road_id == item) + spotRslt.push({ + roadId: item, + maintenanceCount: corConserveCount ? corConserveCount.count : 0, + prepareId: previewId + }) + } - await transaction.commit(); - ctx.status = 204; - } catch (error) { - await transaction.rollback(); - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + await models.RoadSpotCheck.bulkCreate(spotRslt, { + transaction + }) + await models.RoadSpotCheckPreview.update({ + checked: true + }, { + where: { + id: previewId + }, + transaction + }) + + await transaction.commit(); + ctx.status = 204; + } catch (error) { + await transaction.rollback(); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function roadSpotList (ctx) { - try { - const { models } = ctx.fs.dc; - const { startTime, endTime, page, limit } = ctx.query +async function roadSpotList(ctx) { + try { + const { models } = ctx.fs.dc; + const { startTime, endTime, page, limit } = ctx.query - let findOpt = { - order: [['id', 'DESC']], - where: { - checked: true - } - } + let findOpt = { + order: [['id', 'DESC']], + where: { + checked: true + } + } - if (startTime && endTime) { - findOpt.where.date = { - $between: [moment(startTime).startOf('day').format(), moment(endTime).endOf('day').format()] - } + if (startTime && endTime) { + findOpt.where.date = { + $between: [moment(startTime).startOf('day').format(), moment(endTime).endOf('day').format()] + } - } + } - if (page && limit) { - findOpt.offset = (page - 1) * limit - findOpt.limit = limit - } + if (page && limit) { + findOpt.offset = (page - 1) * limit + findOpt.limit = limit + } - const listRes = await models.RoadSpotCheckPreview.findAll(findOpt) + const listRes = await models.RoadSpotCheckPreview.findAll(findOpt) - ctx.status = 200; - ctx.body = listRes.map(item => { - return { - id: item.id, - date: item.date, - countyPercentage: item.countyPercentage, - spotCountyRoadCount: item.countyRoadId ? item.countyRoadId.length : 0, - spotTownRoadCount: item.townshipRoadId ? item.townshipRoadId.length : 0, - spotVillageRoadCount: item.villageRoadId ? item.villageRoadId.length : 0, - countyRoadId: item.countyRoadId, - townshipRoadId: item.townshipRoadId, - villageRoadId: item.villageRoadId, - } - }) - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + ctx.status = 200; + ctx.body = listRes.map(item => { + return { + id: item.id, + date: item.date, + countyPercentage: item.countyPercentage, + spotCountyRoadCount: item.countyRoadId ? item.countyRoadId.length : 0, + spotTownRoadCount: item.townshipRoadId ? item.townshipRoadId.length : 0, + spotVillageRoadCount: item.villageRoadId ? item.villageRoadId.length : 0, + countyRoadId: item.countyRoadId, + townshipRoadId: item.townshipRoadId, + villageRoadId: item.villageRoadId, + villageMil: item.villageMil, + townMil: item.townMil, + countryMil: item.countryMil + } + }) + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function roadSpotDetail (ctx) { - try { - const { models } = ctx.fs.dc; - const { previewId, keyword } = ctx.query +async function roadSpotDetail(ctx) { + try { + const { models } = ctx.fs.dc; + const { previewId, keyword } = ctx.query - const listRes = await models.RoadSpotCheck.findAll({ - where: { - prepareId: previewId, - }, - include: [{ - model: models.Road, + const listRes = await models.RoadSpotCheck.findAll({ where: { - ...(keyword ? { routeName: { $ilike: `%${keyword}%` } } : {}), - del: false, + prepareId: previewId, }, - }, { - model: models.RoadSpotCheckPreview, - attributes: ['id'], include: [{ - model: models.RoadSpotCheckChangeLog, - attributes: ['id', 'changeRoadId'], + model: models.Road, + where: { + ...(keyword ? { routeName: { $ilike: `%${keyword}%` } } : {}), + del: false, + }, + }, { + model: models.RoadSpotCheckPreview, + attributes: ['id'], + include: [{ + model: models.RoadSpotCheckChangeLog, + attributes: ['id', 'changeRoadId'], + }] }] - }] - }) - - - ctx.status = 200; - ctx.body = listRes - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + }) + + + ctx.status = 200; + ctx.body = listRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function roadSpotChange (ctx) { - const transaction = await ctx.fs.dc.orm.transaction(); - try { - const { models } = ctx.fs.dc; - const sequelize = ctx.fs.dc.orm; - const { originRoadId, changeRoadId, previewId } = ctx.request.body - - if (originRoadId == changeRoadId) { - throw '原路段与目标路段不能相同' - } +async function roadSpotChange(ctx) { + const transaction = await ctx.fs.dc.orm.transaction(); + try { + const { models } = ctx.fs.dc; + const sequelize = ctx.fs.dc.orm; + const { originRoadId, changeRoadId, previewId } = ctx.request.body - const previewRes = await models.RoadSpotCheckPreview.findOne({ - where: { - id: previewId - } - }) + if (originRoadId == changeRoadId) { + throw '原路段与目标路段不能相同' + } - if (!previewRes) { - throw '预览数据不存在' - } - - let previewUpdated = false - async function updatePreview (key) { - if (previewUpdated) return - - if (previewRes[key] && previewRes[key].includes(originRoadId)) { - let originRoadIds = previewRes.dataValues[key] - let originRoadIdIndex = originRoadIds.indexOf(originRoadId) - - originRoadIds.splice(originRoadIdIndex, 1, changeRoadId) - - await models.RoadSpotCheckPreview.update({ - [key]: originRoadIds - }, { - where: { - id: previewId - }, - transaction - }) - previewUpdated = true - } - } - await updatePreview('countyRoadId') - await updatePreview('townshipRoadId') - await updatePreview('villageRoadId') + const previewRes = await models.RoadSpotCheckPreview.findOne({ + where: { + id: previewId + } + }) + + if (!previewRes) { + throw '预览数据不存在' + } + + let previewUpdated = false + async function updatePreview(key) { + if (previewUpdated) return + + if (previewRes[key] && previewRes[key].includes(originRoadId)) { + let originRoadIds = previewRes.dataValues[key] + let originRoadIdIndex = originRoadIds.indexOf(originRoadId) + + originRoadIds.splice(originRoadIdIndex, 1, changeRoadId) + + await models.RoadSpotCheckPreview.update({ + [key]: originRoadIds + }, { + where: { + id: previewId + }, + transaction + }) + previewUpdated = true + } + } + await updatePreview('countyRoadId') + await updatePreview('townshipRoadId') + await updatePreview('villageRoadId') - if (!previewUpdated) { - throw '更改路段不在抽查范围内' - } + if (!previewUpdated) { + throw '更改路段不在抽查范围内' + } - const roadRes = await models.Road.findAll({ - where: { - id: { $in: [originRoadId, changeRoadId] }, - del: false, - } - }) + const roadRes = await models.Road.findAll({ + where: { + id: { $in: [originRoadId, changeRoadId] }, + del: false, + } + }) - if (roadRes.length != 2) { - throw '路段不存在' - } + if (roadRes.length != 2) { + throw '路段不存在' + } - let content = '' - let curOriginRoad = roadRes.find(item => item.id == originRoadId) - let curChangeRoad = roadRes.find(item => item.id == changeRoadId) + let content = '' + let curOriginRoad = roadRes.find(item => item.id == originRoadId) + let curChangeRoad = roadRes.find(item => item.id == changeRoadId) - content = `将${curOriginRoad.routeName}从${curOriginRoad.startingPlaceName}到${curOriginRoad.stopPlaceName}改为${curChangeRoad.routeName}从${curChangeRoad.startingPlaceName}到${curChangeRoad.stopPlaceName}` + content = `将${curOriginRoad.routeName}从${curOriginRoad.startingPlaceName}到${curOriginRoad.stopPlaceName}改为${curChangeRoad.routeName}从${curChangeRoad.startingPlaceName}到${curChangeRoad.stopPlaceName}` - const maintenanceCount = await sequelize.query(` + const maintenanceCount = await sequelize.query(` SELECT COUNT(id) as count FROM report WHERE report_type = 'conserve' AND road_id=${changeRoadId} `, { type: QueryTypes.SELECT }) - await models.RoadSpotCheck.update({ - roadId: changeRoadId, - maintenanceCount: maintenanceCount[0].count - }, { - where: { - roadId: originRoadId, + await models.RoadSpotCheck.update({ + roadId: changeRoadId, + maintenanceCount: maintenanceCount[0].count + }, { + where: { + roadId: originRoadId, + prepareId: previewId + }, + transaction + }) + await models.RoadSpotCheckChangeLog.create({ + userId: ctx.fs.api.userId, + time: moment().format(), + originRoadId: originRoadId, + changeRoadId: changeRoadId, + content: content, prepareId: previewId - }, - transaction - }) - await models.RoadSpotCheckChangeLog.create({ - userId: ctx.fs.api.userId, - time: moment().format(), - originRoadId: originRoadId, - changeRoadId: changeRoadId, - content: content, - prepareId: previewId - }, { - transaction - }) - - - await transaction.commit(); - ctx.status = 204; - } catch (error) { - await transaction.rollback(); - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + }, { + transaction + }) + + + await transaction.commit(); + ctx.status = 204; + } catch (error) { + await transaction.rollback(); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } -async function roadSpotChangList (ctx) { - try { - const { models } = ctx.fs.dc; - const { startTime, endTime, page, limit } = ctx.query - - let findOptPreview = { - where: { - checked: true, - }, - attributes: ['id', 'date'] - } +async function roadSpotChangList(ctx) { + try { + const { models } = ctx.fs.dc; + const { startTime, endTime, page, limit } = ctx.query - if (startTime && endTime) { - findOptPreview.where = { - date: { - $between: [moment(startTime).startOf('day').format(), moment(endTime).endOf('day').format()] + let findOptPreview = { + where: { + checked: true, + }, + attributes: ['id', 'date'] + } + + if (startTime && endTime) { + findOptPreview.where = { + date: { + $between: [moment(startTime).startOf('day').format(), moment(endTime).endOf('day').format()] + } } - } - } - - let findOpt = { - order: [['id', 'DESC']], - where: { - - }, - include: [{ - model: models.RoadSpotCheckPreview, - ...findOptPreview, - required: true, - }, { - model: models.User, - attributes: ['name'] - }] - } - - if (page && limit) { - findOpt.offset = (page - 1) * limit - findOpt.limit = limit - } + } - const listRes = await models.RoadSpotCheckChangeLog.findAll(findOpt) + let findOpt = { + order: [['id', 'DESC']], + where: { - ctx.status = 200; - ctx.body = listRes - } catch (error) { - ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); - ctx.status = 400; - ctx.body = { - message: typeof error == 'string' ? error : undefined - } - } + }, + include: [{ + model: models.RoadSpotCheckPreview, + ...findOptPreview, + required: true, + }, { + model: models.User, + attributes: ['name'] + }] + } + + if (page && limit) { + findOpt.offset = (page - 1) * limit + findOpt.limit = limit + } + + const listRes = await models.RoadSpotCheckChangeLog.findAll(findOpt) + + ctx.status = 200; + ctx.body = listRes + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } } async function exportSpotRode (ctx) { @@ -1197,9 +1213,9 @@ async function exportSpotRode (ctx) { } module.exports = { - reportList, - reportPosition, - reportDetail, createReport, deleteReport, reportHandle, - spotPrepare, spotCheck, spotCheckDetail, - roadSpotPrepare, confirmRoadSpot, roadSpotList, roadSpotDetail, roadSpotChange, roadSpotChangList, exportSpotRode + reportList, + reportPosition, + reportDetail, createReport, deleteReport, reportHandle, + spotPrepare, spotCheck, spotCheckDetail, + roadSpotPrepare, confirmRoadSpot, roadSpotList, roadSpotDetail, roadSpotChange, roadSpotChangList, exportSpotRode }; \ No newline at end of file diff --git a/api/app/lib/models/road_spot_check_preview.js b/api/app/lib/models/road_spot_check_preview.js index c3519155..0dfb16ba 100644 --- a/api/app/lib/models/road_spot_check_preview.js +++ b/api/app/lib/models/road_spot_check_preview.js @@ -2,87 +2,114 @@ 'use strict'; module.exports = dc => { - const DataTypes = dc.ORM; - const sequelize = dc.orm; - const RoadSpotCheckPreview = sequelize.define("roadSpotCheckPreview", { - id: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: null, - primaryKey: true, - field: "id", - autoIncrement: true, - unique: "report_spot_check_preview_v2_id_uindex" - }, - countyPercentage: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: null, - comment: "县道抽查比例", - primaryKey: false, - field: "county_percentage", - autoIncrement: false - }, - date: { - type: DataTypes.DATE, - allowNull: true, - defaultValue: null, - comment: "抽取时间", - primaryKey: false, - field: "date", - autoIncrement: false - }, - countyRoadId: { - type: DataTypes.ARRAY(DataTypes.INTEGER), - allowNull: true, - defaultValue: null, - comment: "抽到的县道id", - primaryKey: false, - field: "county_road_id", - autoIncrement: false - }, - townshipRoadId: { - type: DataTypes.ARRAY(DataTypes.INTEGER), - allowNull: true, - defaultValue: null, - comment: "乡道id", - primaryKey: false, - field: "township_road_id", - autoIncrement: false - }, - checked: { - type: DataTypes.BOOLEAN, - allowNull: false, - defaultValue: null, - comment: "是否应用", - primaryKey: false, - field: "checked", - autoIncrement: false - }, - villageRoadId: { - type: DataTypes.ARRAY(DataTypes.INTEGER), - allowNull: true, - defaultValue: null, - comment: "村道id", - primaryKey: false, - field: "village_road_id", - autoIncrement: false - }, - villageId: { - type: DataTypes.ARRAY(DataTypes.INTEGER), - allowNull: true, - defaultValue: null, - comment: "抽到的村庄的id", - primaryKey: false, - field: "village_id", - autoIncrement: false - } - }, { - tableName: "road_spot_check_preview", - comment: "", - indexes: [] - }); - dc.models.RoadSpotCheckPreview = RoadSpotCheckPreview; - return RoadSpotCheckPreview; + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const RoadSpotCheckPreview = sequelize.define("roadSpotCheckPreview", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true, + unique: "report_spot_check_preview_v2_id_uindex" + }, + countyPercentage: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: "县道抽查比例", + primaryKey: false, + field: "county_percentage", + autoIncrement: false + }, + date: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: "抽取时间", + primaryKey: false, + field: "date", + autoIncrement: false + }, + countyRoadId: { + type: DataTypes.ARRAY(DataTypes.INTEGER), + allowNull: true, + defaultValue: null, + comment: "抽到的县道id", + primaryKey: false, + field: "county_road_id", + autoIncrement: false + }, + townshipRoadId: { + type: DataTypes.ARRAY(DataTypes.INTEGER), + allowNull: true, + defaultValue: null, + comment: "乡道id", + primaryKey: false, + field: "township_road_id", + autoIncrement: false + }, + checked: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: null, + comment: "是否应用", + primaryKey: false, + field: "checked", + autoIncrement: false + }, + villageRoadId: { + type: DataTypes.ARRAY(DataTypes.INTEGER), + allowNull: true, + defaultValue: null, + comment: "村道id", + primaryKey: false, + field: "village_road_id", + autoIncrement: false + }, + villageId: { + type: DataTypes.ARRAY(DataTypes.INTEGER), + allowNull: true, + defaultValue: null, + comment: "抽到的村庄的id", + primaryKey: false, + field: "village_id", + autoIncrement: false + }, + villageMil: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "village_mil", + autoIncrement: false + }, + townMil: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "town_mil", + autoIncrement: false + }, + countryMil: { + type: DataTypes.DOUBLE, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "country_mil", + autoIncrement: false + } + }, { + tableName: "road_spot_check_preview", + comment: "", + indexes: [] + }); + dc.models.RoadSpotCheckPreview = RoadSpotCheckPreview; + return RoadSpotCheckPreview; }; \ No newline at end of file diff --git a/scripts/0.0.1/data/3_init_report_pic_data/data/work.xlsx b/scripts/0.0.1/data/3_init_report_pic_data/data/work.xlsx index 2fd86c39..50aa3837 100644 Binary files a/scripts/0.0.1/data/3_init_report_pic_data/data/work.xlsx and b/scripts/0.0.1/data/3_init_report_pic_data/data/work.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/公交/车辆信息/四公司车辆信息(1).xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/公交/车辆信息/四公司车辆信息(1).xls index f297808d..80fb3a09 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/公交/车辆信息/四公司车辆信息(1).xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/公交/车辆信息/四公司车辆信息(1).xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/公交/运营线路/(四公司)南昌公交运营线路基础信息表2022年6月(总表).xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/公交/运营线路/(四公司)南昌公交运营线路基础信息表2022年6月(总表).xlsx index fd996b51..68d9cecc 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/公交/运营线路/(四公司)南昌公交运营线路基础信息表2022年6月(总表).xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/公交/运营线路/(四公司)南昌公交运营线路基础信息表2022年6月(总表).xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/养护/南昌县农村公路各管养责任单位管养汇总表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/养护/南昌县农村公路各管养责任单位管养汇总表.xlsx index 779bf870..f4c015ce 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/养护/南昌县农村公路各管养责任单位管养汇总表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/养护/南昌县农村公路各管养责任单位管养汇总表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/桥梁.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/桥梁.xls index aa73ae7c..95c8a2ed 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/桥梁.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/桥梁.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/道路.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/道路.xls index 1f938dea..64193237 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/道路.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/工程一览/道路.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/桥梁/桥第三方.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/桥梁/桥第三方.xls index d979c98a..29539e84 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/桥梁/桥第三方.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/桥梁/桥第三方.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/治超/非现场处罚总台账更新至2022.7.5(最新).xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/治超/非现场处罚总台账更新至2022.7.5(最新).xlsx index 6623858e..9936796a 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/治超/非现场处罚总台账更新至2022.7.5(最新).xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/治超/非现场处罚总台账更新至2022.7.5(最新).xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx index 58c13780..c5ef398d 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌南化物流有限责任公司危货业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌南化物流有限责任公司危货业户信息表.xlsx index ef14062f..cda4a4c9 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌南化物流有限责任公司危货业户信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌南化物流有限责任公司危货业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌宁昌物流运输有限公司危货业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌宁昌物流运输有限公司危货业户信息表.xlsx index 48dbf0a0..dad63a6a 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌宁昌物流运输有限公司危货业户信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌宁昌物流运输有限公司危货业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌市万利特种气体有限公司危货业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌市万利特种气体有限公司危货业户信息表.xlsx index 7c3b8507..d2941318 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌市万利特种气体有限公司危货业户信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌市万利特种气体有限公司危货业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌江竹实业有限公司危货业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌江竹实业有限公司危货业户信息表.xlsx index 7578dc21..0166ff83 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌江竹实业有限公司危货业户信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/南昌江竹实业有限公司危货业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西昌海运输有限公司危货业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西昌海运输有限公司危货业户信息表.xlsx index 5c2244d7..ac200f14 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西昌海运输有限公司危货业户信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西昌海运输有限公司危货业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西省通越运输有限公司危货业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西省通越运输有限公司危货业户信息表.xlsx index 5e8340f1..8c9694ca 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西省通越运输有限公司危货业户信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西省通越运输有限公司危货业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西雨辰环保科技有限公司危货业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西雨辰环保科技有限公司危货业户信息表.xlsx index 9f50171a..410ccbc6 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西雨辰环保科技有限公司危货业户信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/危货/江西雨辰环保科技有限公司危货业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/出租车/运输事业发展中心巡游出租车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/出租车/运输事业发展中心巡游出租车辆信息表.xlsx index e080922d..f4d63688 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/出租车/运输事业发展中心巡游出租车辆信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/出租车/运输事业发展中心巡游出租车辆信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌南化物流有限责任公司危货车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌南化物流有限责任公司危货车辆信息表.xlsx index c2a43d00..22034c38 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌南化物流有限责任公司危货车辆信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌南化物流有限责任公司危货车辆信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌宁昌物流运输有限公司危货车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌宁昌物流运输有限公司危货车辆信息表.xlsx index 6e74a426..fa606929 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌宁昌物流运输有限公司危货车辆信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌宁昌物流运输有限公司危货车辆信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌市万利特种气体有限公司危货车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌市万利特种气体有限公司危货车辆信息表.xlsx index d82a2964..ac666063 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌市万利特种气体有限公司危货车辆信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌市万利特种气体有限公司危货车辆信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌江竹实业有限公司危货车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌江竹实业有限公司危货车辆信息表.xlsx index 52fd914f..58d1a927 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌江竹实业有限公司危货车辆信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/南昌江竹实业有限公司危货车辆信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西昌海运输有限公司危货车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西昌海运输有限公司危货车辆信息表.xlsx index a10d3aac..3049d882 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西昌海运输有限公司危货车辆信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西昌海运输有限公司危货车辆信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西省通越运输有限公司危货车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西省通越运输有限公司危货车辆信息表.xlsx index 7f5d21c6..7a0017c1 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西省通越运输有限公司危货车辆信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西省通越运输有限公司危货车辆信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西雨辰环保科技有限公司危货车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西雨辰环保科技有限公司危货车辆信息表.xlsx index aa96a6f3..aff239bc 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西雨辰环保科技有限公司危货车辆信息表.xlsx and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/车辆/危货/江西雨辰环保科技有限公司危货车辆信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/乡道第三方.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/乡道第三方.xls index cf53b8d6..7d1a6bbc 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/乡道第三方.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/乡道第三方.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/县道第三方.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/县道第三方.xls index 4d61104b..2ea57141 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/县道第三方.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/县道第三方.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/村道第三方.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/村道第三方.xls index d23427d4..2048e856 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/村道第三方.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/村道第三方.xls differ diff --git a/scripts/1.3.1/data/1_insert_report_data/data/work.xlsx b/scripts/1.3.1/data/1_insert_report_data/data/work.xlsx index 104dd2c4..a56af238 100644 Binary files a/scripts/1.3.1/data/1_insert_report_data/data/work.xlsx and b/scripts/1.3.1/data/1_insert_report_data/data/work.xlsx differ diff --git a/scripts/1.4.1/data/1_insert_road_data/.vscode/launch.json b/scripts/1.4.1/data/1_insert_road_data/.vscode/launch.json new file mode 100644 index 00000000..3a3fcba2 --- /dev/null +++ b/scripts/1.4.1/data/1_insert_road_data/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "启动程序", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\index.js" + } + ] +} \ No newline at end of file diff --git a/scripts/1.4.1/data/1_insert_road_data/Dockerfile b/scripts/1.4.1/data/1_insert_road_data/Dockerfile new file mode 100644 index 00000000..d0293a8f --- /dev/null +++ b/scripts/1.4.1/data/1_insert_road_data/Dockerfile @@ -0,0 +1,11 @@ +FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2 + +COPY . /var/app + +WORKDIR /var/app + +RUN npm cache clean -f +RUN rm -rf package-lock.json +RUN npm install --registry http://10.8.30.22:7000 + +CMD ["node", "index.js"] \ No newline at end of file diff --git a/scripts/1.4.1/data/1_insert_road_data/Dockerfilenew b/scripts/1.4.1/data/1_insert_road_data/Dockerfilenew new file mode 100644 index 00000000..dba16607 --- /dev/null +++ b/scripts/1.4.1/data/1_insert_road_data/Dockerfilenew @@ -0,0 +1,7 @@ +FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2 +COPY ./scripts/1.3.1/data/1_insert_report_data /var/app +WORKDIR /var/app +RUN npm cache clean -f +RUN rm -rf package-lock.json +RUN npm install --registry https://nexus.ngaiot.com/repository/fs-npm/ +CMD ["node", "index.js"] \ No newline at end of file diff --git a/scripts/1.4.1/data/1_insert_road_data/data/sihao.xlsx b/scripts/1.4.1/data/1_insert_road_data/data/sihao.xlsx new file mode 100644 index 00000000..183e8be8 Binary files /dev/null and b/scripts/1.4.1/data/1_insert_road_data/data/sihao.xlsx differ diff --git a/scripts/1.4.1/data/1_insert_road_data/index.js b/scripts/1.4.1/data/1_insert_road_data/index.js new file mode 100644 index 00000000..ca9f9561 --- /dev/null +++ b/scripts/1.4.1/data/1_insert_road_data/index.js @@ -0,0 +1,269 @@ +try { + const { Pool, Client } = require('pg') + const XLSX = require('xlsx') + const path = require('path') + const fs = require("fs"); + + //开发 + const pool = new Pool({ + user: 'postgres', + host: '10.8.30.32', + database: 'highways4good', + password: '123', + port: 5432, + }) + + // 测试环境 + // const pool = new Pool({ + // user: 'highwayadmin', + // host: '10.8.40.223', + // database: 'highway4good', + // password: 'highway123', + // port: 5432, + // }) + + // 商用环境 + // const pool = new Pool({ + // user: 'highwayadmin', + // host: '10.8.40.223', + // database: 'highway4good', + // password: 'highway123', + // port: 5432, + // }) + // const userId = '' + + const fun = async () => { + const client = await pool.connect() + try { + await client.query('BEGIN') + console.log(`开始`); + + let allVillageRes = (await client.query(`SELECT * FROM village`)).rows + let allRoads = (await client.query(`SELECT * FROM road`)).rows + let towns = (await client.query(`SELECT * FROM town`)).rows + + // 读取数据文件 + let workbook = XLSX.readFile(path.join(__dirname, './data/sihao.xlsx')); + let firstSheetName = workbook.SheetNames[0]; + let worksheet = workbook.Sheets[firstSheetName]; + let res = XLSX.utils.sheet_to_json(worksheet, { + defval: '' + }); + + let villageSql = '' + let noExistVillage = '' + let noExistVillageObj = {} + let delSql = '' + allRoads.forEach(r => { + let isExit = res.find(s => s.route_code == r.route_code && s.section_no == r.section_no && s.route_name == r.route_name) + if (!isExit) { + delSql += `UPDATE road SET del = true WHERE id = ${r.id};\n` + } + }) + if (delSql) fs.writeFileSync('delete_road.sql', delSql, 'utf-8'); + + for (let r of [...res]) { + console.log(r); + // if (r.id == 3259) { + // console.log(r); + // } + let villageId = null + if (r['所属行政村']) { + let v = r['所属行政村'] + v = v.split(' ')[0] + v = v.trim() + if (v) { + let noExist = false + let corV = allVillageRes.find(village => village.name === v) + if (corV) { + villageId = corV.id + } else { + + if (!v.endsWith('村')) { + v += '村' + let corV = allVillageRes.find(village => village.name === v) + if (corV) { + villageId = corV.id + } else { + noExist = true + } + } else { + noExist = true + } + } + + if (noExist) { + if (!noExistVillageObj[v]) { + noExistVillage += `${v}\n` + noExistVillageObj[v] = true + } + + } + } + } + let del = false + let spot = false + + let isDel = r['isdelete'] + + if (isDel) { + isDel = isDel.toString() + isDel = isDel.trim() + if (isDel) { + if (isDel == 1) { + del = true + } + } + } + + let mark = r['mark'] + if (mark) { + spot = true + } else { + spot = false + } + + let rId = r.id + if (rId) { + rId = rId.toString() + rId = rId.trim() + if (rId) { + r.id = rId + } + } + + let town = towns.find(x => x.name == r['乡镇定稿']) + let township_code = town ? town.code : '' + const arr = [] + Object.keys(r).forEach(key => { + arr.push(key) + }) + console.log(arr) + let isExit = allRoads.find(s => s.route_code == r.route_code && s.section_no == r.section_no && s.route_name == r.route_name) + if (isExit) { + villageSql += `UPDATE road SET village_id = ${villageId}, "del" = ${del}, spot = ${spot}, "township_code" = ${township_code ? township_code : `null`} WHERE id = ${r.id};\n` + } else { + const { + route_name = `null`, route_code = `null`, section_no = `null`, township_code = `null`, starting_place_name = `null`, + start_station = `null`, category_of_starting_point_and_dividing_point = `null`, stop_place_name = `null`, + category_of_dead_center_and_dividing_point = `null`, stop_station = `null`, section_type = `null`, + route_code_before_road_network_adjustment = `null`, serial_number_of_original_section = `null`, + starting_stake_number_of_the_original_road_section = `null`, ending_point_stake_no_of_the_original_road_section = `null`, + route_level = `null`, nature_of_road_section = `null`, completion_time = `null`, reconstruction_time = `null`, nature_of_construction = `null`, + gbm_and_civilized_model_road = `null`, landforms = `null`, nature_of_charges = `null`, toll_station = `null`, number_of_culverts = `null`, + technical_level = `null`, pavement_type = `null`, pavement_width = `null`, subgrade_width = `null`, lane_characteristics = `null`, + whether_it_is_open_to_traffic_in_sunny_or_rainy_days = `null`, design_speed_per_hour = `null`, urban_management_section_or_not = `null`, + management_and_maintenance_unit = `null`, road_administration_unit = `null`, alimentation = `null`, source_of_listed_maintenance_funds = `null`, + curing_time = `null`, greening_mileage = `null`, greening_mileaged = `null`, type_of_repeated_road_section = `null`, + serial_number_of_repeated_section = `null`, repeated_section_route_code = `null`, planned_fund_category = `null`, + planned_year = `null`, plan_document_no = `null`, plan_item_unique_code = `null`, planned_project_route_code = `null`, + plan_project_name = `null`, planned_project_type = `null`, completion_status = `null`, year_of_completion = `null`, planned_fund_category__one = `null`, + planned_year__one = `null`, plan_document_no__one = `null`, plan_item_unique_code__one = `null`, plan_project_name__one = `null`, + completion_status__one = `null`, year_of_completion__one = `null`, station_range = `null`, reporting_unit = `null`, reason_for_change = `null`, + change_time = `null`, last_repair_and_maintenance_year = `null`, whether_maintenance_managed_highway = `null`, remarks = `null`, + route_code_of_last_year = `null`, route_name_of_last_year = `null`, starting_station_of_last_year = `null`, + last_years_ending_point_stake_number = `null`, graphic_mileage = `null`, chainage_mileage = `null`, districtcounty = `null`, + location_city = `null`, level = `null`, surface_thickness = `null`, + } = r; + villageSql += ` + INSERT INTO road ( + village_id, + "del", + spot, + route_name, route_code, section_no, township_code, starting_place_name, + start_station, category_of_starting_point_and_dividing_point, stop_place_name, + category_of_dead_center_and_dividing_point, stop_station, section_type, + route_code_before_road_network_adjustment, serial_number_of_original_section, + starting_stake_number_of_the_original_road_section, ending_point_stake_no_of_the_original_road_section, + route_level, nature_of_road_section, completion_time, reconstruction_time, nature_of_construction, + gbm_and_civilized_model_road, landforms, nature_of_charges, toll_station, number_of_culverts, + technical_level, pavement_type, pavement_width, subgrade_width, lane_characteristics, + whether_it_is_open_to_traffic_in_sunny_or_rainy_days, design_speed_per_hour, urban_management_section_or_not, + management_and_maintenance_unit, road_administration_unit, alimentation, source_of_listed_maintenance_funds, + curing_time, greening_mileage, greening_mileaged, type_of_repeated_road_section, + serial_number_of_repeated_section, repeated_section_route_code, planned_fund_category, + planned_year, plan_document_no, plan_item_unique_code, planned_project_route_code, + plan_project_name, planned_project_type, completion_status, year_of_completion, planned_fund_category__one, + planned_year__one, plan_document_no__one, plan_item_unique_code__one, plan_project_name__one, + completion_status__one, year_of_completion__one, station_range, reporting_unit, reason_for_change, + change_time, last_repair_and_maintenance_year, whether_maintenance_managed_highway, remarks, + route_code_of_last_year, route_name_of_last_year, starting_station_of_last_year, + last_years_ending_point_stake_number, graphic_mileage, chainage_mileage, districtcounty, + location_city, level, surface_thickness + ) VALUES ( + ${villageId || `null`}, + ${del}, + ${spot}, + ${route_name ? `'${r.route_name}'` : `null`}, ${route_code ? `'${r.route_code}'` : `null`}, + ${section_no ? `'${r.section_no}'` : `null`}, ${township_code ? `'${r.township_code}'` : `null`}, + ${starting_place_name ? `'${r.starting_place_name}'` : `null`}, + ${start_station ? `'${r.start_station}'` : `null`}, ${category_of_starting_point_and_dividing_point ? `'${r.category_of_starting_point_and_dividing_point}'` : `null`}, + ${stop_place_name ? `'${r.stop_place_name}'` : `null`}, + ${category_of_dead_center_and_dividing_point ? `'${r.category_of_dead_center_and_dividing_point}'` : `null`}, ${stop_station ? `'${r.stop_station}'` : `null`}, + ${section_type ? `'${r.section_type}'` : `null`}, + ${route_code_before_road_network_adjustment ? `'${r.route_code_before_road_network_adjustment}'` : `null`}, ${serial_number_of_original_section ? `'${r.serial_number_of_original_section}'` : `null`}, + ${starting_stake_number_of_the_original_road_section ? `'${r.starting_stake_number_of_the_original_road_section}'` : `null`}, + ${ending_point_stake_no_of_the_original_road_section ? `'${r.ending_point_stake_no_of_the_original_road_section}'` : `null`}, + ${route_level ? `'${r.route_level}'` : `null`}, ${nature_of_road_section ? `'${r.nature_of_road_section}'` : `null`}, + ${completion_time ? `'${r.completion_time}'` : `null`}, + ${reconstruction_time ? `'${r.reconstruction_time}'` : `null`}, ${nature_of_construction ? `'${r.nature_of_construction}'` : `null`}, + ${gbm_and_civilized_model_road ? `'${r.gbm_and_civilized_model_road}'` : `null`}, ${landforms ? `'${r.landforms}'` : `null`}, + ${nature_of_charges ? `'${r.nature_of_charges}'` : `null`}, + ${toll_station ? `'${r.toll_station}'` : `null`}, ${number_of_culverts ? `'${r.number_of_culverts}'` : `null`}, + ${technical_level ? `'${r.technical_level}'` : `null`}, ${pavement_type ? `'${r.pavement_type}'` : `null`}, + ${pavement_width ? `'${r.pavement_width}'` : `null`}, + ${subgrade_width ? `'${r.subgrade_width}'` : `null`}, ${lane_characteristics ? `'${r.lane_characteristics}'` : `null`}, + ${whether_it_is_open_to_traffic_in_sunny_or_rainy_days ? `'${r.whether_it_is_open_to_traffic_in_sunny_or_rainy_days}'` : `null`}, + ${design_speed_per_hour ? `'${r.design_speed_per_hour}'` : `null`}, ${urban_management_section_or_not ? `'${r.urban_management_section_or_not}'` : `null`}, + ${management_and_maintenance_unit ? `'${r.management_and_maintenance_unit}'` : `null`}, ${road_administration_unit ? `'${r.road_administration_unit}'` : `null`}, + ${alimentation ? `'${r.alimentation}'` : `null`}, ${source_of_listed_maintenance_funds ? `'${r.source_of_listed_maintenance_funds}'` : `null`}, + ${curing_time ? `'${r.curing_time}'` : `null`}, ${greening_mileage ? `'${r.greening_mileage}'` : `null`}, + ${greening_mileaged ? `'${r.greening_mileaged}'` : `null`}, + ${type_of_repeated_road_section ? `'${r.type_of_repeated_road_section}'` : `null`}, + ${serial_number_of_repeated_section ? `'${r.serial_number_of_repeated_section}'` : `null`}, + ${repeated_section_route_code ? `'${r.repeated_section_route_code}'` : `null`}, + ${planned_fund_category ? `'${r.planned_fund_category}'` : `null`}, + ${planned_year ? `'${r.planned_year}'` : `null`}, ${plan_document_no ? `'${r.plan_document_no}'` : `null`}, + ${plan_item_unique_code ? `'${r.plan_item_unique_code}'` : `null`}, + ${planned_project_route_code ? `'${r.planned_project_route_code}'` : `null`}, + ${plan_project_name ? `'${r.plan_project_name}'` : `null`}, ${planned_project_type ? `'${r.planned_project_type}'` : `null`}, + ${completion_status ? `'${r.completion_status}'` : `null`}, + ${year_of_completion ? `'${r.year_of_completion}'` : `null`}, ${planned_fund_category__one ? `'${r.planned_fund_category__one}'` : `null`}, + ${planned_year__one ? `'${r.planned_year__one}'` : `null`}, ${plan_document_no__one ? `'${r.plan_document_no__one}'` : `null`}, + ${plan_item_unique_code__one ? `'${r.plan_item_unique_code__one}'` : `null`}, + ${plan_project_name__one ? `'${r.plan_project_name__one}'` : `null`}, + ${completion_status__one ? `'${r.completion_status__one}'` : `null`}, ${year_of_completion__one ? `'${r.year_of_completion__one}'` : `null`}, + ${station_range ? `'${r.station_range}'` : `null`}, ${reporting_unit ? `'${r.reporting_unit}'` : `null`}, + ${reason_for_change ? `'${r.reason_for_change}'` : `null`}, + ${change_time ? `'${r.change_time}'` : `null`}, ${last_repair_and_maintenance_year ? `'${r.last_repair_and_maintenance_year}'` : `null`}, + ${whether_maintenance_managed_highway ? `'${r.whether_maintenance_managed_highway}'` : `null`}, ${remarks ? `'${r.remarks}'` : `null`}, + ${route_code_of_last_year ? `'${r.route_code_of_last_year}'` : `null`}, ${route_name_of_last_year ? `'${r.route_name_of_last_year}'` : `null`}, + ${starting_station_of_last_year ? `'${r.starting_station_of_last_year}'` : `null`}, + ${last_years_ending_point_stake_number ? `'${r.last_years_ending_point_stake_number}'` : `null`}, ${graphic_mileage ? `'${r.graphic_mileage}'` : `null`}, + ${chainage_mileage ? `'${r.chainage_mileage}'` : `null`}, ${districtcounty ? `'${r.districtcounty}'` : `null`}, + ${location_city ? `'${r.location_city}'` : `null`}, ${level ? `'${r.level}'` : `null`}, + ${surface_thickness ? `'${r.surface_thickness}'` : `null`} + );\n` + } + } + + + fs.writeFileSync('road_update.sql', villageSql, 'utf-8'); + // fs.writeFileSync('no_exist_village.txt', noExistVillage, 'utf-8'); + + // await client.query('ROLLBACK') + await client.query('COMMIT') + console.log('执行完毕~') + } catch (e) { + await client.query('ROLLBACK') + console.log('执行错误~' + JSON.stringify(e)) + throw e + } finally { + client.release(); + } + } + + fun() +} catch (error) { + console.error(error) +} diff --git a/scripts/1.4.1/data/1_insert_road_data/insert-towns.sql b/scripts/1.4.1/data/1_insert_road_data/insert-towns.sql new file mode 100644 index 00000000..3e3cea6d --- /dev/null +++ b/scripts/1.4.1/data/1_insert_road_data/insert-towns.sql @@ -0,0 +1,36 @@ + + INSERT INTO town(name,code) VALUES ('八一乡', 360121206000); + + INSERT INTO town(name,code) VALUES ('东新乡', 360121205000); + + INSERT INTO town(name,code) VALUES ('富山乡', 360121204000); + + INSERT INTO town(name,code) VALUES ('冈上镇', 360121107000); + + INSERT INTO town(name,code) VALUES ('广福镇', 360121108000); + + INSERT INTO town(name,code) VALUES ('黄马乡', 360121203000); + + INSERT INTO town(name,code) VALUES ('蒋巷镇', 360121105000); + + INSERT INTO town(name,code) VALUES ('金湖管理处', 330052); + + INSERT INTO town(name,code) VALUES ('泾口乡', 360121200000); + + INSERT INTO town(name,code) VALUES ('莲塘镇', 360121100000); + + INSERT INTO town(name,code) VALUES ('南新乡', 360121201000); + + INSERT INTO town(name,code) VALUES ('三江镇', 360121102000); + + INSERT INTO town(name,code) VALUES ('塔城乡', 360121202000); + + INSERT INTO town(name,code) VALUES ('塘南镇', 360121103000); + + INSERT INTO town(name,code) VALUES ('武阳镇', 360121106000); + + INSERT INTO town(name,code) VALUES ('向塘镇', 360121101000); + + INSERT INTO town(name,code) VALUES ('银三角管委会', 360121471000); + + INSERT INTO town(name,code) VALUES ('幽兰镇', 360121104000); diff --git a/scripts/1.4.1/data/1_insert_road_data/package.json b/scripts/1.4.1/data/1_insert_road_data/package.json new file mode 100644 index 00000000..7da06c06 --- /dev/null +++ b/scripts/1.4.1/data/1_insert_road_data/package.json @@ -0,0 +1,17 @@ +{ + "name": "appkey-generator", + "version": "1.0.0", + "description": "tool", + "main": "index.js", + "scripts": { + "test": "mocha", + "start": "set NODE_ENV=development&&node index" + }, + "author": "liu", + "license": "ISC", + "dependencies": { + "crypto-js": "^4.1.1", + "pg": "^7.18.2", + "xlsx": "^0.17.1" + } +} diff --git a/scripts/1.4.1/schema/1create_table.town.sql b/scripts/1.4.1/schema/1create_table.town.sql new file mode 100644 index 00000000..ab40fb58 --- /dev/null +++ b/scripts/1.4.1/schema/1create_table.town.sql @@ -0,0 +1,11 @@ +create table town +( + id serial + constraint table_name_pk + primary key, + name varchar, + code varchar +); + +create unique index town_id_uindex + on town (id); \ No newline at end of file diff --git a/scripts/1.4.1/schema/2.alter_road.sql b/scripts/1.4.1/schema/2.alter_road.sql new file mode 100644 index 00000000..4fa36b3c --- /dev/null +++ b/scripts/1.4.1/schema/2.alter_road.sql @@ -0,0 +1,8 @@ +alter table road_spot_check_preview + add village_mil float; + +alter table road_spot_check_preview + add town_mil float; + +alter table road_spot_check_preview + add country_mil float; diff --git a/web/client/src/sections/fillion/components/adjustment.js b/web/client/src/sections/fillion/components/adjustment.js index a66128e1..31f701b7 100644 --- a/web/client/src/sections/fillion/components/adjustment.js +++ b/web/client/src/sections/fillion/components/adjustment.js @@ -1,7 +1,7 @@ -import { connect } from 'react-redux'; -import React, { useEffect, useState } from 'react'; +import { connect } from 'react-redux' +import React, { useEffect, useState } from 'react' import { Button, Modal, Form, Input, Divider, Spin, Select, DatePicker, Descriptions, Table } from 'antd' -import { roadSpotChange } from '../actions/spotCheck'; +import { roadSpotChange } from '../actions/spotCheck' import { getRoadway } from "../actions/infor" import moment from 'moment' @@ -21,14 +21,14 @@ const Adjustment = (props) => { const [reportData, setReportData] = useState([]) const [detailList, setDetailList] = useState([]) const [detailVisible, setDetailVisible] = useState(false) - const [dateRange, setDateRange] = useState([]); + const [dateRange, setDateRange] = useState([]) const { RangePicker } = DatePicker - const [nameList, setNameList] = useState([]); - const [codeList, setCodeList] = useState([]); - const [indexList, setIndexList] = useState([]); - const [roadFind, setRoadFind] = useState({}); - const [routeCodeDisabled, setRouteCodeDisabled] = useState(true); - const [sectionNoDisabled, setSectionNoDisabled] = useState(true); + const [nameList, setNameList] = useState([]) + const [codeList, setCodeList] = useState([]) + const [indexList, setIndexList] = useState([]) + const [roadFind, setRoadFind] = useState({}) + const [routeCodeDisabled, setRouteCodeDisabled] = useState(true) + const [sectionNoDisabled, setSectionNoDisabled] = useState(true) @@ -52,7 +52,7 @@ const Adjustment = (props) => { if (v.sectionNo && !index.includes(v.sectionNo)) { index.push(v.sectionNo) } - }); + }) setNameList(name) setCodeList(code) setIndexList(index) @@ -80,10 +80,11 @@ const Adjustment = (props) => { changeRoadId: data?.id })).then(res => { if (res.success) { + console.log(res) onCancel() onOk() } - }); + }) }) @@ -100,7 +101,7 @@ const Adjustment = (props) => { if (v.routeName && !name.includes(v.routeName)) { name.push(v.routeName) } - }); + }) for (let d in changedValues) { if (d == 'routeName') { form.setFieldsValue({ @@ -111,7 +112,7 @@ const Adjustment = (props) => { if (allValues?.routeName && allValues?.routeName == v.routeName && v.routeCode && !code.includes(v.routeCode)) { code.push(v.routeCode) } - }); + }) setCodeList(code) } @@ -129,7 +130,7 @@ const Adjustment = (props) => { if (!allValues?.routeCode && v.routeCode && !code.includes(v.routeCode)) { code.push(v.routeCode) } - }); + }) if (!allValues?.routeCode) { setCodeList(code) } @@ -158,13 +159,13 @@ const Adjustment = (props) => { if (allValues?.routeName && allValues?.routeCode && allValues?.sectionNo) { let find = road?.find(s => allValues?.routeName == s.routeName && allValues?.routeCode == s.routeCode && allValues?.sectionNo == s.sectionNo) form.setFieldsValue({ - 'startingPlaceName': find?.startingPlaceName, - 'stopPlaceName': find?.stopPlaceName + 'startStation': find?.startStation, + 'stopStation': find?.stopStation }) } else { form.setFieldsValue({ - 'startingPlaceName': null, - 'stopPlaceName': null + 'startStation': null, + 'stopStation': null }) } @@ -194,10 +195,10 @@ const Adjustment = (props) => { - + @@ -218,4 +219,4 @@ function mapStateToProps (state) { road: road?.data || [], } } -export default connect(mapStateToProps)(Adjustment); \ No newline at end of file +export default connect(mapStateToProps)(Adjustment) \ No newline at end of file diff --git a/web/client/src/sections/fillion/components/infor/details.js b/web/client/src/sections/fillion/components/infor/details.js index 361c3f85..05e30b17 100644 --- a/web/client/src/sections/fillion/components/infor/details.js +++ b/web/client/src/sections/fillion/components/infor/details.js @@ -13,7 +13,7 @@ const UserModal = (props) => { const [recordsay, setRecordsay] = useState()//必填数据 // const [success, setSuccess] = useState() //状态 // const [establishment, setEstablishment] = useState() //业户类型 - + useEffect(() => { const array = [] if (rewkeys === 'transportation') { @@ -283,6 +283,7 @@ const UserModal = (props) => { label='所属行政村' /> : null } + { /> : null } {newlysay?.map((item, index) => { - return + + return item.type == 'townshipCode' ? + : })} @@ -371,11 +381,18 @@ const UserModal = (props) => { } {newlysay?.map((item, index) => { - return + return item.type == 'townshipCode' ? + : + })} } @@ -386,7 +403,7 @@ const UserModal = (props) => { ) } -function mapStateToProps (state) { +function mapStateToProps(state) { const { depMessage } = state; const pakData = (dep) => { return dep.map((d) => { @@ -403,4 +420,26 @@ function mapStateToProps (state) { depData, }; } -export default connect(mapStateToProps)(UserModal); \ No newline at end of file +export default connect(mapStateToProps)(UserModal); + +export const townCode = [ + { label: "莲塘镇", value: "360121100000" }, + { label: "向塘镇", value: "360121101000" }, + { label: "三江镇", value: "360121102000" }, + { label: "塘南镇", value: "360121103000" }, + { label: "幽兰镇", value: "360121104000" }, + { label: "蒋巷镇", value: "360121105000" }, + { label: "武阳镇", value: "360121106000" }, + { label: "冈上镇", value: "360121107000" }, + { label: "广福镇", value: "360121108000" }, + { label: "泾口乡", value: "360121200000" }, + { label: "南新乡", value: "360121201000" }, + { label: "塔城乡", value: "360121202000" }, + { label: "黄马乡", value: "360121203000" }, + { label: "富山乡", value: "360121204000" }, + { label: "八一乡", value: "360121206000" }, + { label: "银三角管委会", value: "360121471000" }, + { label: "东新乡", value: "360121205000" }, + { label: "金湖管理处", value: "330052" }, +] + diff --git a/web/client/src/sections/fillion/components/transportationTable.js b/web/client/src/sections/fillion/components/transportationTable.js index 3e2c0399..f41fff84 100644 --- a/web/client/src/sections/fillion/components/transportationTable.js +++ b/web/client/src/sections/fillion/components/transportationTable.js @@ -1,23 +1,23 @@ -import React, { useEffect, useState, useRef } from 'react'; -import { connect } from 'react-redux'; -import { Spin, Button, Popconfirm } from 'antd'; -import ProTable from '@ant-design/pro-table'; +import React, { useEffect, useState, useRef } from 'react' +import { connect } from 'react-redux' +import { Spin, Button, Popconfirm } from 'antd' +import ProTable from '@ant-design/pro-table' import './protable.less' -import moment from 'moment'; +import moment from 'moment' import { getRoadway, getProject, delRoadway, delProject, getVillageList } from "../actions/infor" -import UserModal from './infor/details'; -import ProjectModal from './project/project'; +import UserModal from './infor/details' +import ProjectModal from './project/project' const TransporTationTable = (props) => { const { dispatch, user, depData, depMessage, depLoading, villageList } = props const [rowSelected, setRowSelected] = useState([]) const [sitename, setSitename] = useState()//名称 const [counts, setCounts] = useState()//shuju - const [modalVisible, setModalVisible] = useState(false); - const [modalVisibleyilan, setModalVisibleyilan] = useState(false); - const [modalRecord, setModalRecord] = useState(); - const [typecard, setTypecard] = useState(); - const [activeKey, setActiveKey] = useState('tab1'); + const [modalVisible, setModalVisible] = useState(false) + const [modalVisibleyilan, setModalVisibleyilan] = useState(false) + const [modalRecord, setModalRecord] = useState() + const [typecard, setTypecard] = useState() + const [activeKey, setActiveKey] = useState('tab1') const [recortd, setRecortd] = useState() const [whichofits, setWhichofits] = useState('县') const [delet, setDelet] = useState() @@ -30,12 +30,12 @@ const TransporTationTable = (props) => { useEffect(() => { ref.current.reload() }, [whichofits, delet]) //打开弹窗 const openModal = (type, record) => { - setModalVisible(true); + setModalVisible(true) // setModalType(type); if (type == 'edit') { - setModalRecord(record); + setModalRecord(record) } else { - setModalRecord(null); + setModalRecord(null) } } useEffect(() => { @@ -50,12 +50,12 @@ const TransporTationTable = (props) => { // console.log('11111', depMessage) // }, [depMessage]) const yilanModal = (type, record) => { - setModalVisibleyilan(true); + setModalVisibleyilan(true) // setModalType(type); if (type == 'edit') { - setModalRecord(record); + setModalRecord(record) } else { - setModalRecord(null); + setModalRecord(null) } } //删除daolu @@ -78,13 +78,35 @@ const TransporTationTable = (props) => { } + const roadCode = [ + { title: "八一乡", value: "360121206000" }, + { title: "东新乡", value: "360121205000" }, + { title: "富山乡", value: "360121204000" }, + { title: "冈上镇", value: "360121107000" }, + { title: "广福镇", value: "360121108000" }, + { title: "黄马乡", value: "360121203000" }, + { title: "蒋巷镇", value: "360121105000" }, + { title: "金湖管理处", value: "330052" }, + { title: "泾口乡", value: "360121200000" }, + { title: "莲塘镇", value: "360121100000" }, + { title: "南新乡", value: "360121201000" }, + { title: "三江镇", value: "360121102000" }, + { title: "塔城乡", value: "360121202000" }, + { title: "塘南镇", value: "360121103000" }, + { title: "武阳镇", value: "360121106000" }, + { title: "向塘镇", value: "360121101000" }, + { title: "银三角管委会", value: "360121471000" }, + { title: "幽兰镇", value: "360121104000" }, + ] + + useEffect(async () => { dispatch(getVillageList({})) }, []) useEffect(async () => { - + let query = {} if (whichofits === '县') { query.level = '县' @@ -94,7 +116,7 @@ const TransporTationTable = (props) => { query.level = '村' } const res = await dispatch(getRoadway(query)) - const uniqueArray = [...new Set(res.payload.data?.map(item => item.routeName))]; + const uniqueArray = [...new Set(res.payload.data?.map(item => item.routeName))] setRoadData(uniqueArray) }, [whichofits]) @@ -150,13 +172,22 @@ const TransporTationTable = (props) => { } }, { - title: '乡镇编码', + title: '所属乡镇', search: false, - dataIndex: 'time3', + dataIndex: 'time9', valueType: 'dateRange', - width: 120, + + + width: 140, + render: (dom, record) => { - return record.townshipCode + const targetValue = record.townshipCode ?? '' + const foundItem = roadCode.find(item => item.value === targetValue) + if (foundItem) { + return foundItem.title + } else { + return "--" + } }, fieldProps: { getPopupContainer: (triggerNode) => triggerNode.parentNode, @@ -1203,6 +1234,45 @@ const TransporTationTable = (props) => { getPopupContainer: (triggerNode) => triggerNode.parentNode, } }, + + { + title: '所属行政村', + search: false, + dataIndex: 'time9', + valueType: 'dateRange', + + + width: 140, + + render: (dom, record) => { + return record.villageId + }, + fieldProps: { + getPopupContainer: (triggerNode) => triggerNode.parentNode, + } + }, + { + title: '是否隐藏字段', + search: false, + dataIndex: 'time9', + valueType: 'dateRange', + + + width: 140, + + render: (dom, record) => { + console.log(record.spot) + if (record.spot) { + return "是" + } else { + return "否" + } + + }, + fieldProps: { + getPopupContainer: (triggerNode) => triggerNode.parentNode, + } + }, { title: '操作', dataIndex: 'creatTime', @@ -1258,7 +1328,7 @@ const TransporTationTable = (props) => { 导入 */} - ); + ) }, }, ], tab2: [ @@ -1310,13 +1380,22 @@ const TransporTationTable = (props) => { } }, { - title: '乡镇编码', + title: '所属乡镇', search: false, - dataIndex: 'time3', + dataIndex: 'time9', valueType: 'dateRange', - width: 120, + + + width: 140, + render: (dom, record) => { - return record.townshipCode + const targetValue = record.townshipCode ?? '' + const foundItem = roadCode.find(item => item.value === targetValue) + if (foundItem) { + return foundItem.title + } else { + return "--" + } }, fieldProps: { getPopupContainer: (triggerNode) => triggerNode.parentNode, @@ -2363,6 +2442,22 @@ const TransporTationTable = (props) => { getPopupContainer: (triggerNode) => triggerNode.parentNode, } }, + { + title: '所属行政村', + search: false, + dataIndex: 'time9', + valueType: 'dateRange', + + + width: 140, + + render: (dom, record) => { + return record.villageId + }, + fieldProps: { + getPopupContainer: (triggerNode) => triggerNode.parentNode, + } + }, { title: '操作', dataIndex: 'creatTime', @@ -2417,7 +2512,7 @@ const TransporTationTable = (props) => { - ); + ) }, }, ], tab3: [ @@ -2483,16 +2578,25 @@ const TransporTationTable = (props) => { } }, { - title: '乡镇编码', + title: '所属乡镇', search: false, - dataIndex: 'time3', + dataIndex: 'time9', valueType: 'dateRange', - width: 120, + + + width: 140, + render: (dom, record) => { - return record.townshipCode + const targetValue = record.townshipCode ?? '' + const foundItem = roadCode.find(item => item.value === targetValue) + if (foundItem) { + return foundItem.title + } else { + return "--" + } }, fieldProps: { - getPopupContainer: (c) => triggerNode.parentNode, + getPopupContainer: (triggerNode) => triggerNode.parentNode, } }, { title: '起点地名', @@ -3536,6 +3640,7 @@ const TransporTationTable = (props) => { getPopupContainer: (triggerNode) => triggerNode.parentNode, } }, + { title: '操作', dataIndex: 'creatTime', @@ -3592,7 +3697,7 @@ const TransporTationTable = (props) => { - ); + ) }, }, ], tab4: [ @@ -3778,7 +3883,7 @@ const TransporTationTable = (props) => { - ); + ) }, }, ] @@ -3836,7 +3941,7 @@ const TransporTationTable = (props) => { }} scroll={{ x: 800 }} options={false} - ref={c => { finishedProductTable = c; }} + ref={c => { finishedProductTable = c }} style={{ width: "100% ", overflow: "auto", height: '760px' }} rowKey='id' onReset={(v) => { @@ -3845,7 +3950,7 @@ const TransporTationTable = (props) => { rowSelection={{ selectedRowKeys: rowSelected, onChange: (selectedRowKeys) => { - setRowSelected(selectedRowKeys); + setRowSelected(selectedRowKeys) }, }} columns={columns[activeKey]} @@ -3859,8 +3964,8 @@ const TransporTationTable = (props) => { level: '县', road: sitename } - setRowSelected([]); - const res = await dispatch(getRoadway(query)); + setRowSelected([]) + const res = await dispatch(getRoadway(query)) setCounts(departmentInfo ? res.payload.data.filter((item) => { return item.townshipCode === departmentInfo.areaCode @@ -3875,8 +3980,8 @@ const TransporTationTable = (props) => { level: '乡', road: sitename } - setRowSelected([]); - const res = await dispatch(getRoadway(query)); + setRowSelected([]) + const res = await dispatch(getRoadway(query)) setCounts(departmentInfo ? res.payload.data.filter((item) => { return item.townshipCode === departmentInfo.areaCode }) : res.payload.data) @@ -3889,7 +3994,7 @@ const TransporTationTable = (props) => { level: '村', road: sitename } - setRowSelected([]); + setRowSelected([]) const res = await dispatch(getRoadway(query)) setCounts(departmentInfo ? res.payload.data.filter((item) => { return item.townshipCode === departmentInfo.areaCode @@ -3904,7 +4009,7 @@ const TransporTationTable = (props) => { type: 'road', entryName: sitename } - setRowSelected([]); + setRowSelected([]) const res = await dispatch(getProject(query)) console.log('56666666', res) return { @@ -3964,7 +4069,7 @@ const data = [ { name: "路线名称", type: 'routeName' }, { name: "路线代码", type: 'routeCode' }, { name: "路段序号", type: 'sectionNo' }, - { name: "乡镇编码", type: 'townshipCode' }, + { name: "所属乡镇", type: 'townshipCode' }, { name: "起点地名", type: 'startingPlaceName' }, { name: "起点桩号", type: 'startStation' }, { name: "起点分界点类别", type: 'categoryOfStartingPointAndDividingPoint' }, @@ -4038,7 +4143,7 @@ const data = [ { name: "面层厚度", type: 'surfaceThickness' }, ] function mapStateToProps (state) { - const { auth, depMessage, villageList } = state; + const { auth, depMessage, villageList } = state const pakData = (dep) => { return dep.map((d) => { return { @@ -4056,6 +4161,6 @@ function mapStateToProps (state) { depLoading: depMessage.isRequesting, depData, villageList: villageList?.data || [] - }; + } } -export default connect(mapStateToProps)(TransporTationTable); \ No newline at end of file +export default connect(mapStateToProps)(TransporTationTable) \ No newline at end of file diff --git a/web/client/src/sections/fillion/containers/maintenanceSpotCheck-new.js b/web/client/src/sections/fillion/containers/maintenanceSpotCheck-new.js index 4d76d16f..20512602 100644 --- a/web/client/src/sections/fillion/containers/maintenanceSpotCheck-new.js +++ b/web/client/src/sections/fillion/containers/maintenanceSpotCheck-new.js @@ -1,8 +1,9 @@ -import { connect } from 'react-redux'; -import React, { useEffect, useState } from 'react'; +import { connect } from 'react-redux' +import React, { useEffect, useState } from 'react' import { Button, Modal, Form, Input, Divider, Spin, Select, DatePicker, Tooltip, Table } from 'antd' -import { ExclamationCircleOutlined } from '@ant-design/icons'; -import { roadSpotList, roadSpotDetail, roadSpotPrepare, confirmRoadSpot, exportSpotRode } from '../actions/spotCheck'; +import { ExclamationCircleOutlined } from '@ant-design/icons' +import { getVillageList } from "../actions/infor" +import { roadSpotList, roadSpotDetail, roadSpotPrepare, confirmRoadSpot, exportSpotRode } from '../actions/spotCheck' import moment from 'moment' import Adjustment from '../components/adjustment' import '../components/maintenanceTable.less' @@ -22,17 +23,53 @@ const MaintenanceSpotCheck = (props) => { const [reportData, setReportData] = useState([]) const [detailList, setDetailList] = useState([]) const [detailVisible, setDetailVisible] = useState(false) - const [dateRange, setDateRange] = useState([]); + const [dateRange, setDateRange] = useState([]) const { RangePicker } = DatePicker - const [expandedRowKeys, setExpandedRowKeys] = useState([]); - const [isAdjustment, setIsAdjustment] = useState(false); - const [editData, setEditData] = useState({}); - const [keyword, setKeyword] = useState(""); - - + const [expandedRowKeys, setExpandedRowKeys] = useState([]) + const [isAdjustment, setIsAdjustment] = useState(false) + const [editData, setEditData] = useState({}) + const [keyword, setKeyword] = useState("") + + + const roadCode = [ + { title: "八一乡", value: "360121206000" }, + { title: "东新乡", value: "360121205000" }, + { title: "富山乡", value: "360121204000" }, + { title: "冈上镇", value: "360121107000" }, + { title: "广福镇", value: "360121108000" }, + { title: "黄马乡", value: "360121203000" }, + { title: "蒋巷镇", value: "360121105000" }, + { title: "金湖管理处", value: "330052" }, + { title: "泾口乡", value: "360121200000" }, + { title: "莲塘镇", value: "360121100000" }, + { title: "南新乡", value: "360121201000" }, + { title: "三江镇", value: "360121102000" }, + { title: "塔城乡", value: "360121202000" }, + { title: "塘南镇", value: "360121103000" }, + { title: "武阳镇", value: "360121106000" }, + { title: "向塘镇", value: "360121101000" }, + { title: "银三角管委会", value: "360121471000" }, + { title: "幽兰镇", value: "360121104000" }, + ] + const [village, setVillage] = useState() + useEffect(() => { + const fetchData = async () => { + try { + const res = await dispatch(getVillageList({})) + let data = res.payload.data + console.log(data) + data.map(s => { + setVillage(s) + }) + } catch (error) { + console.error(error) + } + } + fetchData() - //里层列名 + }, [dispatch]) + // console.log(village) const columns = [ { title: '抽查日期', @@ -46,19 +83,19 @@ const MaintenanceSpotCheck = (props) => { dataIndex: 'countyPercentage', }, { - title: '抽查县道', - key: 'spotCountyRoadCount', - dataIndex: 'spotCountyRoadCount', + title: '抽查县道(公里)', + key: 'countryMil', + dataIndex: 'countryMil', }, { - title: '抽查乡道', - key: 'spotTownRoadCount', - dataIndex: 'spotTownRoadCount', + title: '抽查乡道(公里)', + key: 'townMil', + dataIndex: 'townMil', }, { - title: '抽查村道', - key: 'spotVillageRoadCount', - dataIndex: 'spotVillageRoadCount', + title: '抽查村道(公里)', + key: 'villageMil', + dataIndex: 'villageMil', }, { title: '操作', @@ -103,9 +140,9 @@ const MaintenanceSpotCheck = (props) => { const res = await dispatch(roadSpotPrepare({ countyPercentage: values.percentValue })) setPreviewId(res?.payload.data?.previewId) form.setFieldsValue({ - 'spotCountyRoadCount': res?.payload.data?.spotCountyRoadCount, - 'spotTownRoadCount': res?.payload.data?.spotTownRoadCount, - 'spotVillageRoadCount': res?.payload.data?.spotVillageRoadCount, + 'countryMil': res?.payload.data?.countryMil, + 'townMil': res?.payload.data?.townMil, + 'villageMil': res?.payload.data?.villageMil, }) } }) @@ -186,14 +223,27 @@ const MaintenanceSpotCheck = (props) => { columns={ [ { - title: '道路类型', key: 'level', dataIndex: 'level', render: (_, r) => r?.road?.level ? (r?.road?.level + '道') : '--' + title: '所属乡镇', key: 'townshipCode', dataIndex: 'townshipCode', render: (_, r) => { + const targetValue = r?.road?.townshipCode ?? '' + const foundItem = roadCode.find(item => item.value === targetValue) + if (foundItem) { + return foundItem.title + } else { + return "--" + } + } }, + { title: '所属行政村', key: 'villageId', dataIndex: 'villageId', render: (_, r) => r.road?.villageId === village.id ? village.name : '--' }, { title: '道路名称', key: 'routeName', dataIndex: 'routeName', render: (_, r) => r.road?.routeName || '--' }, { title: '道路代码', key: 'routeCode', dataIndex: 'routeCode', render: (_, r) => r.road?.routeCode || '--' }, - { title: '路段序号', key: 'sectionNo', dataIndex: 'sectionNo', render: (_, r) => r.road?.sectionNo || '--' }, - { title: '起点地名', key: 'startingPlaceName', dataIndex: 'startingPlaceName', render: (_, r) => r.road?.startingPlaceName || '--' }, - { title: '止点地名', key: 'stopPlaceName', dataIndex: 'stopPlaceName', render: (_, r) => r.road?.stopPlaceName || '--' }, - { title: '里程', key: 'chainageMileage', dataIndex: 'chainageMileage', render: (_, r) => r.road?.chainageMileage || '--' }, + // { title: '路段序号', key: 'sectionNo', dataIndex: 'sectionNo', render: (_, r) => r.road?.sectionNo || '--' }, + { title: '起点桩号', key: 'startStation', dataIndex: 'startStation', render: (_, r) => r.road?.startStation || '--' }, + { title: '止点桩号', key: 'stopStation', dataIndex: 'stopStation', render: (_, r) => r.road?.stopStation || '--' }, + { title: '技术等级', key: 'technicalLevel', dataIndex: 'technicalLevel', render: (_, r) => r.road?.technicalLevel || '--' }, + { title: '路面类型', key: 'pavementType', dataIndex: 'pavementType', render: (_, r) => r.road?.pavementType || '--' }, + { title: '路面宽度', key: 'pavementWidth', dataIndex: 'pavementWidth', render: (_, r) => r.road?.pavementWidth || '--' }, + { title: '路基宽度', key: 'subgradeWidth', dataIndex: 'subgradeWidth', render: (_, r) => r.road?.subgradeWidth || '--' }, + { title: '桩号里程', key: 'chainageMileage', dataIndex: 'chainageMileage', render: (_, r) => r.road?.chainageMileage || '--' }, { title: '养护次数(次)', key: 'maintenanceCount', dataIndex: 'maintenanceCount' }, { title: '操作', @@ -243,7 +293,7 @@ const MaintenanceSpotCheck = (props) => { form.resetFields() setVis(false) } - }); + }) }) }}>
@@ -269,13 +319,13 @@ const MaintenanceSpotCheck = (props) => { }}> - + - + - + @@ -313,4 +363,4 @@ function mapStateToProps (state) { } } -export default connect(mapStateToProps)(MaintenanceSpotCheck); \ No newline at end of file +export default connect(mapStateToProps)(MaintenanceSpotCheck) \ No newline at end of file diff --git a/web/client/src/sections/organization/components/depModal.js b/web/client/src/sections/organization/components/depModal.js index 7bf7997d..7d396dbc 100644 --- a/web/client/src/sections/organization/components/depModal.js +++ b/web/client/src/sections/organization/components/depModal.js @@ -1,35 +1,31 @@ -import React, { useRef, useState, useEffect } from 'react'; -import { connect } from 'react-redux'; -import { Spin, Card, Modal, TreeSelect } from 'antd'; -import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } from '@ant-design/pro-form'; +import React, { useRef, useState, useEffect } from 'react' +import { connect } from 'react-redux' +import { Spin, Card, Modal, TreeSelect } from 'antd' +import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } from '@ant-design/pro-form' const DepModal = (props) => { const { visible, onVisibleChange, onConfirm, depModalType, depData, data } = props console.log('data', data) - const formRef = useRef(); + const formRef = useRef() const roadCode = [ - { title: "莲塘镇", value: "360121100000" }, - { title: "向塘镇", value: "360121101000" }, - { title: "三江镇", value: "360121102000" }, - { title: "塘南镇", value: "360121103000" }, - { title: "幽兰镇", value: "360121104000" }, - { title: "蒋巷镇", value: "360121105000" }, - { title: "武阳镇", value: "360121106000" }, + { title: "八一乡", value: "360121206000" }, + { title: "东新乡", value: "360121205000" }, + { title: "富山乡", value: "360121204000" }, { title: "冈上镇", value: "360121107000" }, { title: "广福镇", value: "360121108000" }, - //{ title: "昌东镇", value: "360121191000" }, - //{ title: "麻丘镇", value: "360121192000" }, + { title: "黄马乡", value: "360121203000" }, + { title: "蒋巷镇", value: "360121105000" }, + { title: "金湖管理处", value: "330052" }, { title: "泾口乡", value: "360121200000" }, + { title: "莲塘镇", value: "360121100000" }, { title: "南新乡", value: "360121201000" }, + { title: "三江镇", value: "360121102000" }, { title: "塔城乡", value: "360121202000" }, - { title: "黄马乡", value: "360121203000" }, - { title: "富山乡", value: "360121204000" }, - //{ title: "东新乡", value: "360121205000" }, - { title: "八一乡", value: "360121206000" }, - //{ title: "小蓝经济开发区", value: "360121403000" }, - { title: "银三角管理委员会", value: "360121471000" }, - // { title: "五星垦殖场", value: "360121501000" }, - // { title: "良种繁殖场", value: "360121572000" }, + { title: "塘南镇", value: "360121103000" }, + { title: "武阳镇", value: "360121106000" }, + { title: "向塘镇", value: "360121101000" }, + { title: "银三角管委会", value: "360121471000" }, + { title: "幽兰镇", value: "360121104000" }, ] useEffect(() => { //console.log('depData', depData) @@ -46,7 +42,7 @@ const DepModal = (props) => { } onConfirm(value) } else { - onConfirm(values); + onConfirm(values) } } @@ -112,8 +108,8 @@ const DepModal = (props) => { ) } -function mapStateToProps(state) { - const { depMessage } = state; +function mapStateToProps (state) { + const { depMessage } = state const pakData = (dep) => { return dep.map((d) => { @@ -134,7 +130,7 @@ function mapStateToProps(state) { return { loading: depMessage.isRequesting, depData, - }; + } } -export default connect(mapStateToProps)(DepModal); \ No newline at end of file +export default connect(mapStateToProps)(DepModal) \ No newline at end of file