From 0ae3ae84553fc3f0cdf615b1f915cbb9f9a344a9 Mon Sep 17 00:00:00 2001 From: tangxilong Date: Wed, 27 Dec 2023 10:06:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BD=A6=E8=BE=86=E6=8A=93?= =?UTF-8?q?=E6=8B=8D=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/.vscode/launch.json | 4 +- api/app/lib/controllers/images/index.js | 90 +++++++++++++ api/app/lib/models/car_images.js | 44 +++++++ api/app/lib/routes/images/index.js | 10 ++ api/package.json | 1 + api/sequelize-automate.config.js | 2 +- scripts/1.4.2/1.create_car_images.sql | 16 +++ .../src/sections/fillion/actions/carimages.js | 15 +++ .../sections/fillion/containers/carimages.js | 124 ++++++++++++++++++ web/client/src/sections/fillion/nav-item.js | 17 ++- web/client/src/sections/fillion/routes.js | 35 +++-- web/client/src/utils/webapi.js | 14 +- web/package.json | 1 + 13 files changed, 345 insertions(+), 28 deletions(-) create mode 100644 api/app/lib/controllers/images/index.js create mode 100644 api/app/lib/models/car_images.js create mode 100644 api/app/lib/routes/images/index.js create mode 100644 scripts/1.4.2/1.create_car_images.sql create mode 100644 web/client/src/sections/fillion/actions/carimages.js create mode 100644 web/client/src/sections/fillion/containers/carimages.js diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 70665660..9801c188 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -16,8 +16,8 @@ "-p 13400", "-f http://localhost:13400", // "-g postgres://FashionAdmin:123456@10.8.16.184:5432/sihaogonglu", - // "-g postgres://postgres:123@10.8.30.32:5432/highways4good", - "-g postgres://postgres:123@10.8.30.32:5432/highway4test", + "-g postgres://postgres:123@10.8.30.32:5432/highways4good", + // "-g postgres://postgres:123@10.8.30.32:5432/highway4test", // "-g postgres://FashionAdmin:123456@10.8.30.156:5432/highway4goodn0728", "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", "--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", diff --git a/api/app/lib/controllers/images/index.js b/api/app/lib/controllers/images/index.js new file mode 100644 index 00000000..bad53b91 --- /dev/null +++ b/api/app/lib/controllers/images/index.js @@ -0,0 +1,90 @@ +'use strict' + +const request = require('superagent') +const moment = require('moment') + + +// function getFileCarImages (opts) { + +// return async function (ctx, next) { +// let error = { message: '文件夹名称更新失败' } +// const models = ctx.fs.dc.models +// const { page, limit, } = ctx.query +// try { +// let searchWhere = {} +// let option = { +// where: searchWhere, +// order: [["id", "desc"]], +// } + + +// option.where = searchWhere + +// let limit_ = limit || 10 +// let page_ = page || 1 +// let offset = (page_ - 1) * limit_ +// if (limit && page) { +// option.limit = limit_ +// option.offset = offset +// } + +// const res = await models.CarImages.findAndCount(option) + +// error = null +// } catch (err) { +// ctx.status = 500 +// ctx.body = { detail: err, ...error } +// } + +// if (error) { +// ctx.status = 400 +// ctx.body = { ...error } +// } else { +// ctx.status = 200 +// ctx.body = { message: '文件夹名称更新成功' } +// } +// } +// } + + + +function getFileCarImages (opts) { + return async function (ctx, next) { + + const models = ctx.fs.dc.models + const { page, limit, } = ctx.query + const Op = ctx.fs.dc.ORM.Op + let errMsg = { message: '获取图片失败' } + try { + let searchWhere = {} + let option = { + where: searchWhere, + order: [["id", "ASC"]], + } + + + option.where = searchWhere + + let limit_ = limit || 10 + let page_ = page || 1 + let offset = (page_ - 1) * limit_ + if (limit && page) { + option.limit = limit_ + option.offset = offset + } + + const res = await models.CarImages.findAndCount(option) + ctx.status = 200 + ctx.body = res + } catch (error) { + + ctx.status = 400 + ctx.body = errMsg + } + } +} + + +module.exports = { + getFileCarImages +} \ No newline at end of file diff --git a/api/app/lib/models/car_images.js b/api/app/lib/models/car_images.js new file mode 100644 index 00000000..f14ba4cc --- /dev/null +++ b/api/app/lib/models/car_images.js @@ -0,0 +1,44 @@ +/* eslint-disable*/ + +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const CarImages = sequelize.define("carImages", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true, + unique: "car_images_id_uindex" + }, + url: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "图片路径", + primaryKey: false, + field: "url", + autoIncrement: false + }, + time: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: "时间", + primaryKey: false, + field: "time", + autoIncrement: false + } + }, { + tableName: "car_images", + comment: "", + indexes: [] + }); + dc.models.CarImages = CarImages; + return CarImages; +}; \ No newline at end of file diff --git a/api/app/lib/routes/images/index.js b/api/app/lib/routes/images/index.js new file mode 100644 index 00000000..2db06525 --- /dev/null +++ b/api/app/lib/routes/images/index.js @@ -0,0 +1,10 @@ +'use strict' + +const images = require('../../controllers/images') + +module.exports = function (app, router, opts, panCode) { + + router.get('/car/images', images.getFileCarImages(opts)) + + +} \ No newline at end of file diff --git a/api/package.json b/api/package.json index 747055b6..f757ff54 100644 --- a/api/package.json +++ b/api/package.json @@ -36,6 +36,7 @@ "redis": "^3.1.2", "request": "^2.88.2", "rimraf": "^3.0.2", + "sequelize-automate-freesun": "^1.2.2", "superagent": "^3.5.2", "swagger-jsdoc": "^6.1.0", "uuid": "^3.3.2", diff --git a/api/sequelize-automate.config.js b/api/sequelize-automate.config.js index 00839eee..6fa0051b 100644 --- a/api/sequelize-automate.config.js +++ b/api/sequelize-automate.config.js @@ -35,7 +35,7 @@ module.exports = { dir: './app/lib/models', // 指定输出 models 文件的目录 typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义 emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir` - tables: ['road_spot_check_preview'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 + tables: ['car_images'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性 skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性 tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中 ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面 diff --git a/scripts/1.4.2/1.create_car_images.sql b/scripts/1.4.2/1.create_car_images.sql new file mode 100644 index 00000000..516f1b0e --- /dev/null +++ b/scripts/1.4.2/1.create_car_images.sql @@ -0,0 +1,16 @@ +create table car_images +( + id serial + constraint car_images_pk + primary key, + url varchar, + time timestamptz +); + +comment on column car_images.url is '图片路径'; + +comment on column car_images.time is '时间'; + +create unique index car_images_id_uindex + on car_images (id); + diff --git a/web/client/src/sections/fillion/actions/carimages.js b/web/client/src/sections/fillion/actions/carimages.js new file mode 100644 index 00000000..8e5001c5 --- /dev/null +++ b/web/client/src/sections/fillion/actions/carimages.js @@ -0,0 +1,15 @@ +import { basicAction } from '@peace/utils' +import { ApiTable } from '$utils' + + +export function getCarImages (query) { + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + actionType: 'GET_CAR_IMAGES', + url: ApiTable.getCarImages, + query, + msg: { error: '获取图片失败' }, + reducer: { name: 'carimage' } + }) +} \ No newline at end of file diff --git a/web/client/src/sections/fillion/containers/carimages.js b/web/client/src/sections/fillion/containers/carimages.js new file mode 100644 index 00000000..6e354754 --- /dev/null +++ b/web/client/src/sections/fillion/containers/carimages.js @@ -0,0 +1,124 @@ +import React, { useState, useEffect } from 'react' +import { connect } from 'react-redux' +import { getCarImages } from '../actions/carimages' +import ProTable from '@ant-design/pro-table' +import { Form, Space, DatePicker, Button, Select, Popconfirm, Image, Tooltip } from 'antd' +import moment from 'moment' + + +function Carimages (props) { + const { dispatch, assess, user } = props + const [query, setQuery] = useState({ page: 1, pageSize: 10, }) + const [loading, setLoading] = useState(false) + const [datasource, setdatasource] = useState([]) + const [dateRange, setDateRange] = useState(['1970-1-1', '2099-12-31']) + const { RangePicker } = DatePicker + const [total, settotal] = useState(0) + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.find(i => i.resourceId === 'ASSESSMANAGE')?.isshow === "true" ? true : '') + useEffect(() => { + + return () => { } + }, []) + + useEffect(() => { + getData() + }, [query]) + + + + + const getData = () => { + console.log(query, 'query') + dispatch(getCarImages({ ...query })).then(res => { + if (res?.success) { + setdatasource(res?.payload?.data?.rows) + settotal(res?.payload?.data?.count) + } + }) + } + + + return ( +
+
+
{ + + setQuery({ + ...query, page: 1, unit: v.unit, startTime: v?.time && moment(v?.time[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss'), + endTime: v?.time && moment(v?.time[1]).add(1, 'days').endOf('day').format('YYYY-MM-DD HH:mm:ss') + }) + }}> + + {/* + + */} +
+ + {/* */} +
+ { + if (r?.url && r?.id) { + return + + + } else { + return '--' + } + } + }, + { + title: '日期', + dataIndex: 'time', + key: 'time', + render: (t, r) => { + const localTime = moment.utc(r?.time).format('YYYY-MM-DD HH:mm:ss') + return r?.time ? localTime : '--' + } + }, + ]} + dataSource={datasource || []} + loading={loading} + pagination={{ + total: total || 0, + pageSize: 10, + defaultPageSize: 10, + showSizeChanger: false, + onChange: (page, pageSize) => { + setQuery({ + ...query, + page, + limit: pageSize + }) + } + }} + rowKey="key" + toolBarRender={false} + search={false} + /> + +
+ ) +} +function mapStateToProps (state) { + const { auth, assess } = state + return { + user: auth.user, + assess: assess.data || [], + } +} +export default connect(mapStateToProps)(Carimages) \ No newline at end of file diff --git a/web/client/src/sections/fillion/nav-item.js b/web/client/src/sections/fillion/nav-item.js index 15b62a9d..80b147c1 100644 --- a/web/client/src/sections/fillion/nav-item.js +++ b/web/client/src/sections/fillion/nav-item.js @@ -1,8 +1,8 @@ -import React from 'react'; -import { Link } from 'react-router-dom'; -import { Menu } from 'antd'; -import { ReadOutlined } from '@ant-design/icons'; -const SubMenu = Menu.SubMenu; +import React from 'react' +import { Link } from 'react-router-dom' +import { Menu } from 'antd' +import { ReadOutlined } from '@ant-design/icons' +const SubMenu = Menu.SubMenu export function getNavItem (user, dispatch) { const isshow = user?.userResources?. some(i => i.resourceId === 'OVERLOADMANAGE' || @@ -72,6 +72,11 @@ export function getNavItem (user, dispatch) { 治超管理 : ''} + + {user?.username == 'SuperAdmin' || user?.userResources?.some(i => i.resourceId === 'OVERLOADMANAGE') ? + + 车辆抓拍管理 + : ''} : '' } @@ -148,5 +153,5 @@ export function getNavItem (user, dispatch) { : null - ); + ) } diff --git a/web/client/src/sections/fillion/routes.js b/web/client/src/sections/fillion/routes.js index bd4f6d1b..9e32bce8 100644 --- a/web/client/src/sections/fillion/routes.js +++ b/web/client/src/sections/fillion/routes.js @@ -1,21 +1,22 @@ -'use strict'; -import { Infor } from './containers'; -import { transportation } from './containers'; -import { BridgeTable } from './containers'; -import { HigHways } from './containers'; -import { OperaTional } from './containers'; -import { Enforce } from './containers'; -import { Public } from './containers'; -import { Videois } from './containers'; -import { PromoTional } from './containers'; +'use strict' +import { Infor } from './containers' +import { transportation } from './containers' +import { BridgeTable } from './containers' +import { HigHways } from './containers' +import { OperaTional } from './containers' +import { Enforce } from './containers' +import { Public } from './containers' +import { Videois } from './containers' +import { PromoTional } from './containers' import { Maintenance } from './containers' import { Patrol } from './containers' -import { File } from './containers'; +import { File } from './containers' import { Jiekouguanli } from './containers' import { Task, Assess, VideoCenter, } from './containers' import { Building } from './containers' import { MaintenanceSpotCheckNew, AdjustLog } from './containers' -import Luzheng from './containers/luzheng'; +import Carimages from './containers/carimages' +import Luzheng from './containers/luzheng' export default [{ type: 'inner', route: { @@ -32,6 +33,14 @@ export default [{ breadcrumb: '治超管理', authCode: 'OVERLOADMANAGE' }, + { + path: '/carimages', + key: 'fillioncarimages', + menuSelectKeys: ['fillioncarimages'], + component: Carimages, + breadcrumb: '车辆抓拍管理', + authCode: 'OVERLOADMANAGE' + }, { path: '/luzheng', key: 'luzheng', @@ -203,4 +212,4 @@ export default [{ } ] } -}]; +}] diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 24a28ac5..281796c8 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -1,7 +1,7 @@ -'use strict'; -import { ProxyRequest } from "@peace/utils"; +'use strict' +import { ProxyRequest } from "@peace/utils" -export const GodTransRequest = new ProxyRequest("_godTrans"); +export const GodTransRequest = new ProxyRequest("_godTrans") export const ApiTable = { login: 'login', @@ -70,7 +70,7 @@ export const ApiTable = { getRoadway: 'road', putRoadway: 'road', delRoadway: 'road/{roadId}', - getVillageList:'village/list', //获取村庄 + getVillageList: 'village/list', //获取村庄 //道路统计 getBgroadstatistics: "build/road_state", @@ -314,11 +314,13 @@ export const ApiTable = { getRoadadministration: '/getRoadadministration', // 发送短信 pushAppointSMS: 'pushAppointSMS', -}; + // 获取图片 + getCarImages: '/car/images' +} export const RouteTable = { apiRoot: '/api/root', fileUpload: '/_upload/new', cleanUpUploadTrash: '/_upload/cleanup', -}; \ No newline at end of file +} \ No newline at end of file diff --git a/web/package.json b/web/package.json index 398df73a..59ad3ed2 100644 --- a/web/package.json +++ b/web/package.json @@ -89,6 +89,7 @@ "react-color": "^2.19.3", "react-router-breadcrumbs-hoc": "^4.0.1", "react-sortable-hoc": "^2.0.0", + "sequelize-automate-freesun": "^1.2.2", "superagent": "^6.1.0", "swiper": "^8.3.1", "uuid": "^8.3.1",