From 9db673e6a50075aae4a35c19ce7cf6d6c3494e83 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 19 Jul 2023 15:30:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BB=E6=8A=A4=E5=B8=83=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/report/index.js | 41 +++- .../src/sections/quanju/containers/example.js | 26 +- .../containers/footer/conserve/index.js | 5 +- .../quanju/containers/public/olMap.js | 232 +++++++++++++++++- web/client/src/utils/webapi.js | 1 - 5 files changed, 290 insertions(+), 15 deletions(-) diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index e4fc1476..8ab4c205 100644 --- a/api/app/lib/controllers/report/index.js +++ b/api/app/lib/controllers/report/index.js @@ -1,7 +1,7 @@ 'use strict'; const { QueryTypes } = require('sequelize'); -async function reportList(ctx) { +async function reportList (ctx) { try { const models = ctx.fs.dc.models; const { limit, page, startTime, endTime, keyword, userId, reportType, isTop, asc, projectType, handleState = '', performerId = '' } = ctx.query @@ -44,7 +44,7 @@ async function reportList(ctx) { }, attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'performerId', 'roadSectionEnd', 'reportType', - 'content', 'longitude', 'latitude', 'projectName', 'handleState', 'codeRoad', 'handleContent', 'handlePic','videoUrl'], + 'content', 'longitude', 'latitude', 'projectName', 'handleState', 'codeRoad', 'handleContent', 'handlePic', 'videoUrl'], include: [{ model: models.User, attributes: ['name'] @@ -100,8 +100,33 @@ async function reportList(ctx) { let reportRes = null; if (isTop) { - const sqlStr = 'select * from (SELECT R.*, "row_number"() OVER(PARTITION BY R.user_id ORDER BY R."time" DESC) AS NEWINDEX FROM report AS R ) AS NR WHERE NEWINDEX = 1' + 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; + ` 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) } @@ -117,7 +142,7 @@ async function reportList(ctx) { } } -async function reportPosition(ctx) { +async function reportPosition (ctx) { try { const models = ctx.fs.dc.models; const { startTime, endTime, userId, reportType } = ctx.query @@ -167,7 +192,7 @@ async function reportPosition(ctx) { } } -async function reportDetail(ctx) { +async function reportDetail (ctx) { try { const models = ctx.fs.dc.models; const { reportId } = ctx.params @@ -189,7 +214,7 @@ async function reportDetail(ctx) { } } -async function reportHandle(ctx) { +async function reportHandle (ctx) { try { const { models } = ctx.fs.dc; @@ -219,7 +244,7 @@ async function reportHandle(ctx) { } } -async function createReport(ctx) { +async function createReport (ctx) { try { const { userId } = ctx.fs.api const models = ctx.fs.dc.models; @@ -241,7 +266,7 @@ async function createReport(ctx) { } } -async function deleteReport(ctx) { +async function deleteReport (ctx) { try { const models = ctx.fs.dc.models; const { reportId } = ctx.params; diff --git a/web/client/src/sections/quanju/containers/example.js b/web/client/src/sections/quanju/containers/example.js index 030c4cc0..7d511841 100644 --- a/web/client/src/sections/quanju/containers/example.js +++ b/web/client/src/sections/quanju/containers/example.js @@ -8,17 +8,39 @@ import Footer from './footer'; import ProTable, { TableDropdown } from '@ant-design/pro-table'; import Gis from './footer/gis/gis'; import OlMap from './public/olMap' +import { getReportList } from '../../fillion/actions/patrol' const MAPID = 'screenGis' const Example = (props) => { const { dispatch, actions, user, loading } = props const [tabKey, setTabKey] = useState('leadership') - const [mapObj, setMapObj] = useState(); + const [patrolList, setPatrolList] = useState([]); + const [roadProjectList, setRoadProjectList] = useState([]); const tabChange = (tab) => { setTabKey(tab) // dispatch({ type: 'TAB-CHANGE', data: tab }) + console.log(tab); + if (tab === 'conserve') { + dispatch(getReportList({ + reportType: 'patrol', + isTop: true + })).then(res => { + console.log(res); + if (res.success) { + setPatrolList(res.payload.data || []) + } + }) + dispatch(getReportList({ + reportType: 'road', + isTop: true + })).then(res => { + if (res.success) { + setRoadProjectList(res.payload.data || []) + } + }) + } } return ( @@ -34,7 +56,7 @@ const Example = (props) => {
{/* */} - +
diff --git a/web/client/src/sections/quanju/containers/footer/conserve/index.js b/web/client/src/sections/quanju/containers/footer/conserve/index.js index eeb36b55..87ac88e1 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/index.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/index.js @@ -4,8 +4,7 @@ import Right from './right' import { connect } from 'react-redux' import moment from 'moment'; import { getdaolutongji } from '../../../actions/example' -import { getHighways, getRoadMaintenances, getxiuyang,getMaintenance } from './action' - +import { getHighways, getRoadMaintenances, getxiuyang, getMaintenance } from './action' const Conserve = (props) => { const [roadData, setRoadData] = useState() @@ -45,7 +44,7 @@ const Conserve = (props) => { ) } -function mapStateToProps(state) { +function mapStateToProps (state) { // const { auth } = state; diff --git a/web/client/src/sections/quanju/containers/public/olMap.js b/web/client/src/sections/quanju/containers/public/olMap.js index cc7cebe8..816ac777 100644 --- a/web/client/src/sections/quanju/containers/public/olMap.js +++ b/web/client/src/sections/quanju/containers/public/olMap.js @@ -1,11 +1,16 @@ import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import request from 'superagent' +import Hua from '../footer/leadership/centerleft/hudong' +import moment from 'moment'; import { OlMapRequest } from '$utils' const OlMap = (props) => { - const { dispatch, actions, user, olMapArcgisHost, olMapGeoDataHost } = props + const { dispatch, actions, user, olMapArcgisHost, olMapGeoDataHost, patrolList, roadProjectList } = props const [olMapOpenData, setOlMapOpenData] = useState([]) + const [olMap, setOlMap] = useState() + const [pointItem, setPointItem] = useState({}) + useEffect(() => { }, []) @@ -48,7 +53,9 @@ const OlMap = (props) => { }) olMapTool.map.on('singleclick', function (p) { setOlMapOpenData([]) + setPointItem({}) olMapTool.closeOverlay('clickOpen') + olMapTool.closeOverlay('pointClickOpen') olMapTool.removeGeometryLayer('geometry0') request.post(`${olMapGeoDataHost || 'http://36.2.6.32:8811'}/geoserver-pg/rest/bufferSearch`) @@ -136,9 +143,120 @@ const OlMap = (props) => { } }) }) + setOlMap(olMapTool) } }, [olMapGeoDataHost]) + useEffect(() => { + if (patrolList.length && olMap) { + patrolList.forEach((d, index) => { + console.log(d, index); + olMap.addGeometryLayer({ + features: [ + { + name: 'patrolPoint', + attributes: { + callbackParams: { + type: 'patrolPoint', + id: d.id, + }, + callback: (p) => { + setPointItem(d) + olMap.addOverlay('pointClickOpen', { + id: 'pointClickOpen', + offset: [0, 25], // 偏移 + position: [d.longitude, d.latitude], // 坐标 + autoPan: true, + autoPanMargin: 100, + positioning: 'top-right' + }) + } + }, + geometry: [d.longitude, d.latitude], + geometryType: 'Point', + }, + ], + style: { + icon: { + src: '/assets/images/worker.png', + // anchor: [0.5, 1], + scale: 0.08, // 图标引用 + }, + // stroke: { width: 1, color: '#ffff00' }, + // circle: { + // radius: 12, // 直径 + // fill: '#ff0000', // 颜色 + // stroke: { width: 1, color: '#ffff00' }, + // }, + }, + selectStyle: { + icon: { + src: '/assets/images/worker.png', + // anchor: [0.5, 1], + scale: 0.08, // 图标引用 + }, + // circle: { + // radius: 16, // 直径 + // fill: '#ff0000', // 颜色 + // stroke: { width: 2, color: '#ffff00' }, + // }, + // stroke: { width: 2, color: '#ffff00' }, + }, + layerName: 'geometry_patrol_' + index + }); + }); + } + }, [patrolList, olMap]) + + useEffect(() => { + if (roadProjectList.length && olMap) { + roadProjectList.forEach((d, index) => { + olMap.addGeometryLayer({ + features: [ + { + name: 'roadPoint', + attributes: { + callbackParams: { + type: 'roadPoint', + id: d.id, + }, + callback: (p) => { + setPointItem(d) + olMap.addOverlay('pointClickOpen', { + id: 'pointClickOpen', + offset: [0, 25], // 偏移 + position: [d.longitude, d.latitude], // 坐标 + // position: [115.944220000000, 28.545380000000], + autoPan: true, + autoPanMargin: 100, + positioning: 'top-right' + }) + } + }, + geometry: [d.longitude, d.latitude], + // geometry: [115.944220000000, 28.545380000000], + geometryType: 'Point', + }, + ], + style: { + icon: { + src: '/assets/images/worker.png', + scale: 0.08, // 图标引用 + }, + }, + selectStyle: { + icon: { + src: '/assets/images/worker.png', + scale: 0.08, // 图标引用 + }, + }, + layerName: 'geometry_road_' + index + }); + }); + } + }, [roadProjectList, olMap]) + + const isRoadProject = pointItem.report_type == 'road' return (
@@ -171,6 +289,118 @@ const OlMap = (props) => { }
+
+
+ {/* */} +
+
+ { + pointItem.id ? + + : '' + } +
+
+

+ { + isRoadProject ? + pointItem.user_name || '--' + : + <> + { + pointItem.road_section_start ? pointItem.road_section_start : "" + }{ + pointItem.road_section_start && pointItem.road_section_end ? "——" : "" + }{ + pointItem.road_section_end ? pointItem.road_section_end : "" + }{ + pointItem.road_section_start || pointItem.road_section_end ? "" : "--" + } + + } + +

+

+ { + isRoadProject ? '上报内容' : '养护内容' + } + + { + pointItem.content ? pointItem.content : "--" + } + +

+ { + isRoadProject ? '' : +

+ 负责人 + + { + pointItem.user_name ? pointItem.user_name : "--" + } + +

+ } +

+ 日期 + + { + pointItem.time ? moment(pointItem.time).format("YYYY-MM-DD") : "--" + } + +

+
+
+ + { + isRoadProject && pointItem.project ? +
+ {[{ + n: '项目名称', + k: 'entryName', + }, { + n: '项目规模(公里)', + k: 'projectMileage', + }, { + n: '项目投资(万元)', + k: 'investment', + }, { + n: '开工时间', + k: 'startTime', + },].map(s => { + return ( +

+ {s.n} + + { + s.k == 'startTime' ? + pointItem.project[s.k] ? moment(pointItem.project[s.k]).format("YYYY-MM-DD") : "--" + : + pointItem.project[s.k] || "--" + } + +

+ ) + })} +
+ : '' + } +
+
) } diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index e16c5015..c45ebbad 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -2,7 +2,6 @@ import { ProxyRequest } from "@peace/utils"; export const GodTransRequest = new ProxyRequest("_godTrans"); -export const OlMapRequest = new ProxyRequest("_olMap"); export const ApiTable = { login: 'login',