Browse Source

巡更轨迹查询

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

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

@ -43,8 +43,8 @@ async function reportList(ctx) {
if (isTop) { 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 * 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; const sequelize = ctx.fs.dc.orm;
reportRes = sequelize.query(sqlStr, { type: QueryTypes.SELECT }); reportRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT });
} else { } else {
reportRes = await models.Report.findAll(findOption) reportRes = await models.Report.findAll(findOption)
} }

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

@ -35,6 +35,9 @@ function PatrolGis(props) {
if ((dateRange && dateRange instanceof Array)) { if ((dateRange && dateRange instanceof Array)) {
query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss') 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') query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
} else {
query.startTime = moment().add(-6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss')
query.endTime = moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')
} }
dispatch(getReportList(query)); dispatch(getReportList(query));
} else { } else {
@ -47,9 +50,10 @@ function PatrolGis(props) {
if (reportList && mapObj) { if (reportList && mapObj) {
mapObj.clearMap(); mapObj.clearMap();
renderMarkers(); renderMarkers();
renderPath(); if (userId)
renderPath();
} }
}, [reportList, mapObj]) }, [reportList, mapObj, userId])
const loadMap = () => { const loadMap = () => {
const map = new AMap.Map("amapId", { const map = new AMap.Map("amapId", {
@ -100,9 +104,9 @@ function PatrolGis(props) {
position: new AMap.LngLat(longitude, latitude), position: new AMap.LngLat(longitude, latitude),
icon: icon, icon: icon,
offset: new AMap.Pixel(-12, -12), offset: new AMap.Pixel(-12, -12),
extData: { // extData: {
name: user.name || '', // name: user.name || '',
} // }
}); });
// marker.setTitle(s.name); // marker.setTitle(s.name);
markers.push(marker); markers.push(marker);

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

@ -126,7 +126,7 @@ const DetailList = (props) => {
dataIndex: 'userName', dataIndex: 'userName',
align: 'center', align: 'center',
render: (text, record) => { render: (text, record) => {
return record.user.name return record?.user?.name || ''
} }
}, { }, {
title: '上报时间', title: '上报时间',
@ -254,6 +254,7 @@ const PatrolTable = (props) => {
const [record, setRecord] = useState(); const [record, setRecord] = useState();
const [dateRange, setDateRange] = useState(); const [dateRange, setDateRange] = useState();
const [detailVisible, setDetailVisible] = useState(false) const [detailVisible, setDetailVisible] = useState(false)
const [activeTabKey1, setActiveTabKey1] = useState('tab1');
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
@ -265,15 +266,27 @@ const PatrolTable = (props) => {
useEffect(() => { useEffect(() => {
if (record) { if (record) {
let query = { userId: record.id, reportType: 'patrol' } queryData();
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));
} }
}, [record, dateRange]) }, [record, dateRange])
const queryData = () => {
let query = { userId: record.id, reportType: 'patrol' }
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));
}
useEffect(() => {
if (activeTabKey1 && activeTabKey1 == 'tab2') {
setRecord(null);
} else if (activeTabKey1 && activeTabKey1 == 'tab1') {
setRecord(userList[0]);
}
}, [activeTabKey1])
const handelRefresh = () => { const handelRefresh = () => {
let query = { userId: record.id, reportType: 'patrol' } let query = { userId: record.id, reportType: 'patrol' }
dispatch(getReportList(query)); dispatch(getReportList(query));
@ -303,7 +316,6 @@ const PatrolTable = (props) => {
</div>], </div>],
tab2: <PatrolGis userId={(record || {}).id} dispatch={dispatch} reportList={reportList} /> tab2: <PatrolGis userId={(record || {}).id} dispatch={dispatch} reportList={reportList} />
}; };
const [activeTabKey1, setActiveTabKey1] = useState('tab1');
const onTab1Change = (key) => { const onTab1Change = (key) => {
setActiveTabKey1(key); setActiveTabKey1(key);
}; };

Loading…
Cancel
Save