Browse Source

提交巡查 -默认gis轨迹

release_0.0.4
LUCAS 2 years ago
parent
commit
98ca3e7ba6
  1. 24
      api/app/lib/controllers/report/index.js
  2. 28
      web/client/src/sections/fillion/components/gis/patrolGis.js
  3. 17
      web/client/src/sections/fillion/components/patrolTable.js

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

@ -1,15 +1,15 @@
'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 } = ctx.query
const { limit, page, startTime, endTime, keyword, userId, reportType, isTop } = ctx.query
let findOption = {
where: {
},
attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'roadSectionEnd', 'reportType', 'content', 'longitude','latitude'],
attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'roadSectionEnd', 'reportType', 'content', 'longitude', 'latitude'],
include: [{
model: models.User,
attributes: ['name']
@ -39,7 +39,15 @@ async function reportList (ctx) {
if (reportType) {
findOption.where.reportType = reportType
}
const reportRes = await models.Report.findAll(findOption)
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 sequelize = ctx.fs.dc.ORM;
reportRes = sequelize.query(sqlStr, { type: QueryTypes.SELECT });
} else {
reportRes = await models.Report.findAll(findOption)
}
ctx.status = 200;
ctx.body = reportRes
@ -52,7 +60,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
@ -102,7 +110,7 @@ async function reportPosition (ctx) {
}
}
async function reportDetail (ctx) {
async function reportDetail(ctx) {
try {
const models = ctx.fs.dc.models;
const { reportId } = ctx.params
@ -124,7 +132,7 @@ async function reportDetail (ctx) {
}
}
async function createReport (ctx) {
async function createReport(ctx) {
try {
const { userId } = ctx.fs.api
const models = ctx.fs.dc.models;
@ -146,7 +154,7 @@ async function createReport (ctx) {
}
}
async function deleteReport (ctx) {
async function deleteReport(ctx) {
try {
const models = ctx.fs.dc.models;
const { reportId } = ctx.params;

28
web/client/src/sections/fillion/components/gis/patrolGis.js

@ -5,13 +5,15 @@ import { useState } from 'react';
import { DatePicker } from 'antd';
import Bounds from './bounds';
import moment from 'moment';
import { getReportList } from '../../actions/patrol'
const { RangePicker } = DatePicker;
function PatrolGis(props) {
const { reportList, userId, dispatch } = props;
const [mapComplete, setMapComplete] = useState(false);
const [mapObj, setMapObj] = useState();
const [dateRange, setDateRange] = useState();
let markers = [];
let PATH = [];
useEffect(() => {
if (AMap) loadMap();
return () => {
@ -24,8 +26,20 @@ function PatrolGis(props) {
}, [true])
useEffect(() => {
if (mapObj) {
mapObj.remove(markers);
mapObj.remove(PATH);
}
let query = { userId, reportType: 'patrol' }
if (userId) {
if ((dateRange && dateRange instanceof Array)) {
query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss')
query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
}
dispatch(getReportList(query));
} else {
query.isTop = true;
dispatch(getReportList(query));
}
}, [userId, dateRange])
@ -91,6 +105,7 @@ function PatrolGis(props) {
}
});
// marker.setTitle(s.name);
markers.push(marker);
map.add(marker);
})
}
@ -111,6 +126,7 @@ function PatrolGis(props) {
if (longitude && latitude)
path.push([item.longitude, item.latitude])
});
PATH = path;
var polyline1 = new AMap.Polyline({
map: map,
path: path, // 设置线覆盖物路径
@ -122,9 +138,13 @@ function PatrolGis(props) {
}
return (
<div style={{ width: '100%', backgroundColor: '#101824', height: '100%', minHeight: 700 }}>
<div style={{ width: '100%', backgroundColor: '#101824', height: '100%', minHeight: 700, position: 'relative' }}>
<div id='amapId' style={{ width: '100%', height: '100%', background: "#101824", minHeight: 700 }} />
<RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} />
<div style={{ position: 'absolute', top: 8, left: 20, display: userId ? 'block' : 'none' }}>
<RangePicker
onChange={(date, dateString) => { setDateRange(dateString) }}
/>
</div>
{mapObj ? <Bounds map={mapObj} /> : ''}
</div >
)

17
web/client/src/sections/fillion/components/patrolTable.js

@ -301,16 +301,29 @@ const PatrolTable = (props) => {
<DetailList reportList={reportList} record={record} loading={reportListLoading} dispatch={dispatch} handleOpen={handleOpen} handelRefresh={handelRefresh} />
</Card>
</div>],
tab2: <PatrolGis userId={(record ||{}).id} dispatch={dispatch} />
tab2: <PatrolGis userId={(record || {}).id} dispatch={dispatch} reportList={reportList} />
};
const [activeTabKey1, setActiveTabKey1] = useState('tab1');
const onTab1Change = (key) => {
setActiveTabKey1(key);
};
const handleChangeRecord = (newRecord) => {
let target = null;
if (!record || newRecord.id != record.id) {
target = newRecord;
}
setRecord(target);
}
return (
<div className='card-protable'>
<Card >
<PatrolNameList onChange={(record) => setRecord(record)} record={record} userList={userList} loading={userLoading} />
<PatrolNameList
onChange={(record) => handleChangeRecord(record)}
record={record}
userList={userList}
loading={userLoading} />
</Card>
<Card
style={{ flex: 1 }}

Loading…
Cancel
Save