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) {
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 });
const sequelize = ctx.fs.dc.orm;
reportRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT });
} else {
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)) {
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')
} 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));
} else {
@ -47,9 +50,10 @@ function PatrolGis(props) {
if (reportList && mapObj) {
mapObj.clearMap();
renderMarkers();
renderPath();
if (userId)
renderPath();
}
}, [reportList, mapObj])
}, [reportList, mapObj, userId])
const loadMap = () => {
const map = new AMap.Map("amapId", {
@ -100,9 +104,9 @@ function PatrolGis(props) {
position: new AMap.LngLat(longitude, latitude),
icon: icon,
offset: new AMap.Pixel(-12, -12),
extData: {
name: user.name || '',
}
// extData: {
// name: user.name || '',
// }
});
// marker.setTitle(s.name);
markers.push(marker);

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

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

Loading…
Cancel
Save