From 8c45b9326a6fde9e61abaabec6a4f748470e7542 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Mon, 10 Jul 2023 21:00:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E7=BB=9F=E8=AE=A1=E8=80=83?= =?UTF-8?q?=E6=A0=B8=E5=BE=97=E5=88=86=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/data/assess.js | 38 +++- api/app/lib/routes/data/index.js | 9 +- .../src/sections/quanju/actions/example.js | 37 ++-- .../footer/conserve/left/left-center.js | 109 ++++++++++-- .../footer/conserve/right/right-center.js | 162 ++++++++++++------ .../footer/conserve/right/right-top.js | 154 +++++++++++++---- .../footer/leadership/left/left-center.js | 2 +- web/client/src/utils/webapi.js | 3 +- web/package-lock.json | 16 +- web/package.json | 1 + 10 files changed, 410 insertions(+), 121 deletions(-) diff --git a/api/app/lib/controllers/data/assess.js b/api/app/lib/controllers/data/assess.js index 0ff55cb1..71145f50 100644 --- a/api/app/lib/controllers/data/assess.js +++ b/api/app/lib/controllers/data/assess.js @@ -102,6 +102,42 @@ async function assessDel (ctx) { } } +async function nearestSourceData (ctx) { + try { + const { models } = ctx.fs.dc; + const { monthRange } = ctx.query + + // 查最近的有数据的月份的数据 + const nearestRes = await models.Assess.findOne({ + order: [['month', 'DESC']], + }) + + let rslt = [] + if (nearestRes) { + rslt = await models.Assess.findAll({ + attributes: ['totalPoints', 'unit', 'month'], + where: { + month: { + $between: [ + moment(nearestRes.month).subtract(monthRange || 0, 'month').startOf('month').format(), moment(nearestRes.month).endOf('month').format() + ] + } + }, + order: [['month', 'DESC']], + }) + } + + ctx.status = 200; + ctx.body = rslt + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: error`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + module.exports = { - assessGet, assessEdit, assessDel, + assessGet, assessEdit, assessDel, nearestSourceData, }; \ No newline at end of file diff --git a/api/app/lib/routes/data/index.js b/api/app/lib/routes/data/index.js index bc2d012a..93d1030e 100644 --- a/api/app/lib/routes/data/index.js +++ b/api/app/lib/routes/data/index.js @@ -23,7 +23,7 @@ module.exports = function (app, router, opts) { // 运政 //货运 - async function setFreightType(ctx, next) { + async function setFreightType (ctx, next) { ctx.request.body = { ...(ctx.request.body || {}), type: 'freight' @@ -40,7 +40,7 @@ module.exports = function (app, router, opts) { router.del('/vehicle/freight/:id', setFreightType, vehicle.del); //客运车 - async function setVehicleType(ctx, next) { + async function setVehicleType (ctx, next) { ctx.request.body = { ...(ctx.request.body || {}), type: 'vehicle' @@ -57,7 +57,7 @@ module.exports = function (app, router, opts) { router.del('/vehicle/:id', setVehicleType, vehicle.del); // 路政 - async function setRoadManageType(ctx, next) { + async function setRoadManageType (ctx, next) { ctx.request.body = { ...(ctx.request.body || {}), type: 'road_manage' @@ -192,5 +192,8 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['DEL/assess/:assessId'] = { content: '删除评分考核数据', visible: false }; router.del('/assess/:assessId', assess.assessDel); + + app.fs.api.logAttr['GET/assess/nearest'] = { content: '获取评分考核最近的月份的所有考核单位的数据', visible: true }; + router.get('/assess/nearest', assess.nearestSourceData); // 评分考核 END }; diff --git a/web/client/src/sections/quanju/actions/example.js b/web/client/src/sections/quanju/actions/example.js index cab22344..adc5ce0e 100644 --- a/web/client/src/sections/quanju/actions/example.js +++ b/web/client/src/sections/quanju/actions/example.js @@ -3,7 +3,7 @@ import { basicAction } from '@peace/utils' import { ApiTable } from '$utils' -export function getMembers(orgId) { +export function getMembers (orgId) { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -16,7 +16,7 @@ export function getMembers(orgId) { //获取大屏道路统计信息 -export function getdaolutongji() { +export function getdaolutongji () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -28,7 +28,7 @@ export function getdaolutongji() { } //获取治超监测点处理数据信息 -export function getjiandmanage() { +export function getjiandmanage () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -41,7 +41,7 @@ export function getjiandmanage() { //获取治超详情列 -export function getjiandetail() { +export function getjiandetail () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -53,7 +53,7 @@ export function getjiandetail() { } // <<<<<<< HEAD // 获取运政数据统计 -export function getyunzheng() { +export function getyunzheng () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -64,7 +64,7 @@ export function getyunzheng() { }); } // 获取道路养护数据统计及列表 -export function getRoadmaintain() { +export function getRoadmaintain () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -75,7 +75,7 @@ export function getRoadmaintain() { }); } // 获取治超详情列 -export function getZhichaolist() { +export function getZhichaolist () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -88,7 +88,7 @@ export function getZhichaolist() { } //获取宣传数据 -export function getxuanchuan() { +export function getxuanchuan () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -100,7 +100,7 @@ export function getxuanchuan() { } //获取公交车辆层级信息 -export function getBusTierList() { +export function getBusTierList () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -112,7 +112,7 @@ export function getBusTierList() { }); } //获取道路拥堵指数 -export function getGodshuju() { +export function getGodshuju () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -125,7 +125,7 @@ export function getGodshuju() { } //获取路政列表 -export function getHighwayList() { +export function getHighwayList () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -136,7 +136,7 @@ export function getHighwayList() { }); } //获取道路养护统计及列表 -export function getRoadMaintenanceList() { +export function getRoadMaintenanceList () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -147,7 +147,7 @@ export function getRoadMaintenanceList() { }); } //获取管养单位概况 -export function getCustodyunit() { +export function getCustodyunit () { return dispatch => basicAction({ type: 'get', dispatch: dispatch, @@ -156,4 +156,15 @@ export function getCustodyunit() { msg: { error: '获取管养单位概况失败' }, // reducer: { name: 'roadMaintenances' } }); +} + +export function getNearestAssessData (query = {}) { + return dispatch => basicAction({ + type: 'get', + query, + dispatch: dispatch, + actionType: 'GET_NEAREST_ASSESS_DATA', + url: ApiTable.nearestAssessData, + msg: { error: '获取各乡镇考核得分情况失败' }, + }); } \ No newline at end of file diff --git a/web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js b/web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js index 6a1180b4..f092903d 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js @@ -6,33 +6,114 @@ import * as echarts from 'echarts'; import ZheXian from "./zhexin" import PieChart from "./shituzujian" import Lunbo from './lunbo'; +import { connect } from 'react-redux' +import ReactECharts from 'echarts-for-react'; +import { getNearestAssessData } from "../../../../actions/example" +import moment from 'moment' const LeftCenter = (props) => { - const { data, shuju } = props + const { data, shuju, dispatch } = props const style = { height: "31%", marginTop: "3%" } // const chartRef = useState(); // const { roadData } = props const [flag, setFlag] = useState(true) // const [colorFlage, setColorFlage] = useState(true) + const [chartData, setChartData] = useState({ + series: [], + xAxis: [] + }) + + useEffect(() => { + dispatch(getNearestAssessData({ monthRange: 6 })).then(res => { + if (res.success) { + let nextChartSeries = [] + let nextXAxis = new Set() + let data = res.payload.data + data.reverse() + for (let d of data) { + let corUnitSeries = nextChartSeries.find(item => item.name == d.unit) + let month = moment(d.month).format('YYYY-MM') + nextXAxis.add(month) + if (corUnitSeries) { + corUnitSeries.data.push(d.totalPoints) + } else { + nextChartSeries.push({ + type: 'line', + smooth: true, + data: [d.totalPoints], + name: d.unit, + }) + } + } + setChartData({ + series: nextChartSeries, + xAxis: [...nextXAxis] + }) + } + }) + }, []) return ( <> - -
{ - setFlag(false) - }} style={{ position: "absolute", top: "38.5%", left: "80%", width: "50px", height: "20px", background: "linear-gradient(270deg, rgba(15,74,159,0) 0%, rgba(17,75,160,0.95) 100%)", float: "right", textAlign: "center", zIndex: 100, marginRight: "4%", borderLeft: "solid 2px #6E7A83" }} > - {/* */} -

累计

-
{ - setFlag(true) - }} style={{ position: "absolute", width: "50px", left: "60%", top: "38.5%", height: "20px", background: "linear-gradient(270deg, rgba(15,74,159,0) 0%, rgba(17,75,160,0.95) 100%)", float: "right", textAlign: "center", zIndex: 100, marginRight: "2%", borderLeft: "solid 2px #6E7A83", }}> - {/* */} -

上月

+ { - flag ? : + false ? + <> +
{ + setFlag(false) + }} style={{ position: "absolute", top: "38.5%", left: "80%", width: "50px", height: "20px", background: "linear-gradient(270deg, rgba(15,74,159,0) 0%, rgba(17,75,160,0.95) 100%)", float: "right", textAlign: "center", zIndex: 100, marginRight: "4%", borderLeft: "solid 2px #6E7A83" }} > + {/* */} +

累计

+
{ + setFlag(true) + }} style={{ position: "absolute", width: "50px", left: "60%", top: "38.5%", height: "20px", background: "linear-gradient(270deg, rgba(15,74,159,0) 0%, rgba(17,75,160,0.95) 100%)", float: "right", textAlign: "center", zIndex: 100, marginRight: "2%", borderLeft: "solid 2px #6E7A83", }}> + {/* */} +

上月

+ { + flag ? : + } + : '' } + + +
) } -export default LeftCenter \ No newline at end of file +function mapStateToProps (state) { + return { + + } +} +export default connect(mapStateToProps)(LeftCenter) \ No newline at end of file diff --git a/web/client/src/sections/quanju/containers/footer/conserve/right/right-center.js b/web/client/src/sections/quanju/containers/footer/conserve/right/right-center.js index 7189d83d..ebcbef5f 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/right/right-center.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/right/right-center.js @@ -1,61 +1,123 @@ import React from 'react' import Module from '../../../public/module' import { Col, Row } from 'antd' +import { useEffect, useState } from 'react' +import { connect } from 'react-redux' +import ReactECharts from 'echarts-for-react'; +import { getNearestAssessData } from "../../../../actions/example" // const unit =['个','个',] const icon = [ - 'assets/images/quanju/jiancha.png', - 'assets/images/quanju/yushui.png', - 'assets/images/quanju/lupai.png', - 'assets/images/quanju/zerenpai.png' + 'assets/images/quanju/jiancha.png', + 'assets/images/quanju/yushui.png', + 'assets/images/quanju/lupai.png', + 'assets/images/quanju/zerenpai.png' ] const RightCenter = (props) => { - const { highwaysData } = props - const style = { height: "31%", marginTop: "3%" } - const textStyle = { fontSize: 14, color: '#E9F7FF' } - const numStyle = { color: '#fff', fontSize: 21, fontFamily: 'YouSheBiaoTiHei', textShadow: '0px 0px 8px #1C60FE', marginTop: 8 } - let list = highwaysData?.sort((a, b) => a.id - b.id) - list = highwaysData?.slice(4, 8).map((h,index)=>{ + const { highwaysData, dispatch } = props + + const [data, setData] = useState([]) + + const style = { height: "31%", marginTop: "3%" } + // const textStyle = { fontSize: 14, color: '#E9F7FF' } + // const numStyle = { color: '#fff', fontSize: 21, fontFamily: 'YouSheBiaoTiHei', textShadow: '0px 0px 8px #1C60FE', marginTop: 8 } + // let list = highwaysData?.sort((a, b) => a.id - b.id) + // list = highwaysData?.slice(4, 8).map((h, index) => { + // return { + // id: h.id, + // name: h.name, + // count: h.count, + // // unit:unit[index], + // icon: icon[index] + // } + // }) + // const arrayChunk = (array, size) => { + // let data = [] + // for (let i = 0; i < array.length; i += size) { + // data.push(array.slice(i, i + size)) + // } + // return data + // } + // let lists = list ? arrayChunk(list, 2) : [] + + + useEffect(() => { + dispatch(getNearestAssessData()).then(res => { + if (res.success) { + setData(res.payload.data) + } + }) + }, []) + + + return ( + <> + +
+ {/* { + lists?.map((item, index) => { + return
+ { + item?.map(i => ( +
+ icon +
+
{i.name}
+
{`${i.count}个`}
+
+
+ )) + } +
+ }) + } */} + d.unit), + axisTick: { + show: false + } + }, + yAxis: { + type: 'value', + splitLine: { + show: false + } + }, + tooltip: { + trigger: "axis" + }, + series: [ + { + data: data.map(d => d.totalPoints), + type: 'bar', + showBackground: true, + backgroundStyle: { + color: 'rgba(180, 180, 180, 0.2)' + } + } + ], + grid: { + left: '3%', + right: '4%', + bottom: '21%', + top: '4%', + containLabel: true + }, + }} + /> +
+
+ + ) +} +function mapStateToProps (state) { return { - id:h.id, - name:h.name, - count:h.count, - // unit:unit[index], - icon:icon[index] - } - }) - const arrayChunk = (array, size) => { - let data = [] - for (let i = 0; i < array.length; i += size) { - data.push(array.slice(i, i + size)) + } - return data - } - let lists = list ? arrayChunk(list, 2) : [] - return ( - <> - -
- { - lists?.map((item, index) => { - return
- { - item?.map(i => ( -
- icon -
-
{i.name}
-
{`${i.count}个`}
-
-
- )) - } -
- }) - } -
-
- - ) } -export default RightCenter \ No newline at end of file +export default connect(mapStateToProps)(RightCenter) \ No newline at end of file diff --git a/web/client/src/sections/quanju/containers/footer/conserve/right/right-top.js b/web/client/src/sections/quanju/containers/footer/conserve/right/right-top.js index 44d92965..6b708e43 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/right/right-top.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/right/right-top.js @@ -1,46 +1,114 @@ import { Col, Row } from 'antd' import React, { useState, useEffect } from 'react' import Module from '../../../public/module' - +import { connect } from 'react-redux' +import Lun from "../../leadership/right/lunbo" +import { getRoadmaintain } from "../../../../actions/example" +import Hua from "../../leadership/right/hudong" +import moment from 'moment' const iconSrc = [ - 'assets/images/quanju/biaoxian.png', - 'assets/images/quanju/renxing.png', - 'assets/images/quanju/biaozhi.png', - 'assets/images/quanju/fanghu.png' + 'assets/images/quanju/biaoxian.png', + 'assets/images/quanju/renxing.png', + 'assets/images/quanju/biaozhi.png', + 'assets/images/quanju/fanghu.png' ] const unit = ['km', '处', '个', 'km'] const RightTop = (props) => { - const { highwaysData } = props - const style = { height: "31%", marginTop: "3%" } - const textStyle = { fontSize: 14, color: '#E9F7FF' } - const numStyle = { color: '#fff', fontSize: 21, fontFamily: 'YouSheBiaoTiHei', textShadow: '0px 0px 8px #1C60FE', marginTop: 8 } - let list = highwaysData?.sort((a, b) => a.id - b.id) - list = highwaysData?.slice(0, 4).map((h, index) => { - return { - id: h.id, - name: h.name, - count: h.count, - unit: unit[index], - icon: iconSrc[index] + const { highwaysData, dispatch } = props + const [roadmaintainList, setRoadmaintainList] = useState([]) + const [beijing, setBeijing] = useState() + const [num, setNum] = useState() - } - }) + const style = { height: "31%", marginTop: "3%" } + // const textStyle = { fontSize: 14, color: '#E9F7FF' } + // const numStyle = { color: '#fff', fontSize: 21, fontFamily: 'YouSheBiaoTiHei', textShadow: '0px 0px 8px #1C60FE', marginTop: 8 } + // let list = highwaysData?.sort((a, b) => a.id - b.id) + // list = highwaysData?.slice(0, 4).map((h, index) => { + // return { + // id: h.id, + // name: h.name, + // count: h.count, + // unit: unit[index], + // icon: iconSrc[index] + + // } + // }) - const arrayChunk = (array, size) => { - let data = [] - for (let i = 0; i < array.length; i += size) { - data.push(array.slice(i, i + size)) + // const arrayChunk = (array, size) => { + // let data = [] + // for (let i = 0; i < array.length; i += size) { + // data.push(array.slice(i, i + size)) + // } + // return data + // } + // let lists = list ? arrayChunk(list, 2) : [] + + useEffect(() => { + dispatch(getRoadmaintain()).then((res) => { + setRoadmaintainList(res.payload.data.reportList.filter((item, index) => { + return item.projectType == "road" + })) + }) + }, []) + + const renderBody = () => { + return ( +
+ { + roadmaintainList.map((item, index) => { + return ( +
  • { + setBeijing(index) + setNum(index) + }} onMouseLeave={() => { + setBeijing() + setNum() + }}> + {beijing == index ? : ""} + {beijing == index ? : ""} +

    {item?.user?.name || '--'}

    +

    {item.road ? item.road : "--"}

    +

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

    + { + num == index ? +
    + +
    + +
    +
    +

    + {item.roadSectionStart ? item.roadSectionStart : ""}{item.roadSectionStart && item.roadSectionEnd ? "——" : ""}{item.roadSectionEnd ? item.roadSectionEnd : ""}{item.roadSectionStart || item.roadSectionEnd ? "" : "--"} +

    +

    养护类型日常养护

    +

    负责人{item.user?.name ? item.user.name : "--"}

    +

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

    +
    +
    : "" + } +
  • + ) + }) + } +
    + ) } - return data - } - let lists = list ? arrayChunk(list, 2) : [] - return ( - <> - -
    - { + + return ( + <> + +
    + {/* { lists?.map((item, index) => { return
    { @@ -56,10 +124,22 @@ const RightTop = (props) => { }
    }) - } -
    -
    - - ) + } */} + +
    +
    + + ) +} +function mapStateToProps (state) { + return { + + } } -export default RightTop \ No newline at end of file +export default connect(mapStateToProps)(RightTop) \ No newline at end of file diff --git a/web/client/src/sections/quanju/containers/footer/leadership/left/left-center.js b/web/client/src/sections/quanju/containers/footer/leadership/left/left-center.js index 542a8743..3f3dd1ca 100644 --- a/web/client/src/sections/quanju/containers/footer/leadership/left/left-center.js +++ b/web/client/src/sections/quanju/containers/footer/leadership/left/left-center.js @@ -59,7 +59,7 @@ const Leftcenter = () => {
    {/*

    {title || []}

    */} - 主要路段拥堵情况分析 + 主要路段拥堵情况
    diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index cdda9456..28bf9745 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -170,7 +170,8 @@ export const ApiTable = { getAssess: 'assess', editAssess: 'assess', delAssess: 'assess/{assessId}', - + nearestAssessData:'assess/nearest', + //工程数据 getProject: 'project', putProject: 'project', diff --git a/web/package-lock.json b/web/package-lock.json index 0cf7743c..d57679af 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -4446,7 +4446,7 @@ }, "cross-env": { "version": "7.0.3", - "resolved": "http://10.8.30.22:7000/cross-env/-/cross-env-7.0.3.tgz", + "resolved": "http://npm.anxinyun.cn/cross-env/-/cross-env-7.0.3.tgz", "integrity": "sha1-hlJkspZ33AFbqEGJGJZd0jL8VM8=", "requires": { "cross-spawn": "^7.0.1" @@ -4964,6 +4964,15 @@ } } }, + "echarts-for-react": { + "version": "3.0.2", + "resolved": "http://10.8.30.22:7000/echarts-for-react/-/echarts-for-react-3.0.2.tgz", + "integrity": "sha512-DRwIiTzx8JfwPOVgGttDytBqdp5VzCSyMRIxubgU/g2n9y3VLUmF2FK7Icmg/sNVkv4+rktmrLN9w22U2yy3fA==", + "requires": { + "fast-deep-equal": "^3.1.3", + "size-sensor": "^1.0.1" + } + }, "ee-first": { "version": "1.1.1", "resolved": "http://npm.anxinyun.cn/ee-first/-/ee-first-1.1.1.tgz", @@ -10299,6 +10308,11 @@ "totalist": "^1.0.0" } }, + "size-sensor": { + "version": "1.0.1", + "resolved": "http://10.8.30.22:7000/size-sensor/-/size-sensor-1.0.1.tgz", + "integrity": "sha1-+E5GIG0+JZ+v8dVI5LO+ypMhnbs=" + }, "smart-buffer": { "version": "4.2.0", "resolved": "http://npm.anxinyun.cn/smart-buffer/-/smart-buffer-4.2.0.tgz", diff --git a/web/package.json b/web/package.json index e91b1530..92625325 100644 --- a/web/package.json +++ b/web/package.json @@ -77,6 +77,7 @@ "co-busboy": "^1.4.1", "cross-env": "^7.0.3", "echarts": "^5.3.2", + "echarts-for-react": "^3.0.2", "fs-web-server-scaffold": "^1.0.6", "koa-better-http-proxy": "^0.2.5", "koa-convert": "^2.0.0",