diff --git a/src/api/biPeople/index.js b/src/api/biPeople/index.js new file mode 100644 index 0000000..abc1b47 --- /dev/null +++ b/src/api/biPeople/index.js @@ -0,0 +1,7 @@ +import { declareRequest } from "@cqsjjb/jjb-dva-runtime"; + +// 人员轨迹按终端或人员编号、时间范围查询,接口参数由轨迹筛选面板传入。 +export const getPeopleTrajectory = declareRequest( + "getPeopleTrajectoryLoading", + "Post > @/personnelPosition/bi/personTrace", +); diff --git a/src/enumerate/namespace/index.js b/src/enumerate/namespace/index.js index a309dde..80113a4 100644 --- a/src/enumerate/namespace/index.js +++ b/src/enumerate/namespace/index.js @@ -9,3 +9,4 @@ export const NS_GLOBAL = defineNamespace("global"); export const NS_BI_STATISTICS = defineNamespace("biStatistics"); export const NS_BI_MARK = defineNamespace("biMark"); export const NS_BI_MARK_INFO = defineNamespace("biMarkInfo"); +export const NS_BI_PEOPLE = defineNamespace("biPeople"); diff --git a/src/pages/Container/Map/components/BottomUtils/index.js b/src/pages/Container/Map/components/BottomUtils/index.js index 8cd2770..8fc1515 100644 --- a/src/pages/Container/Map/components/BottomUtils/index.js +++ b/src/pages/Container/Map/components/BottomUtils/index.js @@ -11,6 +11,7 @@ import { NS_BI_MARK } from "~/enumerate/namespace"; import { branchOfficeUtilsList } from "~/pages/Container/Map/components/BottomUtils/branchOfficeUtilsList"; import { Context } from "~/pages/Container/Map/js/context"; import usePeoplePosition from "~/pages/Container/Map/js/usePeoplePosition"; +import PeopleTrajectorySelect from "~/pages/Container/Map/components/PeopleTrajectorySelect"; import { portUtilsList } from "./portUtilsList"; import { usePortUtilsAnimation } from "./usePortUtilsAnimation"; import "./index.less"; @@ -67,7 +68,12 @@ function BottomUtils(props) { portArea, } = useContext(Context); - const { connect: peoplePositionConnect, disconnect: peoplePositionDisconnect } = usePeoplePosition(mapMethods, currentBranchOffice); + const [peopleList, setPeopleList] = useState([]); + const { connect: peoplePositionConnect, disconnect: peoplePositionDisconnect } = usePeoplePosition( + mapMethods, + currentBranchOffice, + setPeopleList, + ); const bottomUtilsMode = !pureMap && currentPort && !currentBranchOffice ? "port" @@ -92,6 +98,10 @@ function BottomUtils(props) { ); const resetAllCheck = () => { + // 底部工具栏被外部操作重置时,人员定位的 WebSocket 和 Cesium 实体不会随勾选状态自动销毁,需要统一清理。 + peoplePositionDisconnect(); + mapMethods.current.removePeoplePointAll(); + setPeopleList([]); setList(produce((draft) => { draft.forEach((item) => { item.list.forEach((item1) => { @@ -181,6 +191,7 @@ function BottomUtils(props) { if (!check) { if (item.type === "peoplePosition") { resetPeopleTrajectory(index); + mapMethods.current.removePeopleTrajectory(); peoplePositionDisconnect(); return; } @@ -209,6 +220,8 @@ function BottomUtils(props) { await addMarkPoint(item); }; + const isPeopleTrajectoryChecked = list.some(item => item.list?.some(option => option.type === "peopleTrajectory" && option.check)); + const renderPortUtils = () => { if (bottomUtilsMode === "port" && listMode === bottomUtilsMode) { return list.map((item, index) => { @@ -313,6 +326,18 @@ function BottomUtils(props) { return (
+ + {isPeopleTrajectoryChecked && ( + + + + )} + {bottomUtilsMode && ( props.peopleList.map(person => ({ + value: person.terminalNo || person.staffNo, + label: person.staffName, + })), + [props.peopleList], + ); + + useEffect(() => { + return () => mapMethods.current.removePeopleTrajectory(); + }, [mapMethods]); + + const handleQuery = async () => { + const { personId, timeRange } = await form.validateFields(); + const [startTime, endTime] = timeRange.map(time => dayjs(time).valueOf()); + if (endTime - startTime > MAX_TRAJECTORY_RANGE) { + message.warning("时间范围不能超过24小时"); + return; + } + + const person = props.peopleList.find(item => (item.terminalNo || item.staffNo) === personId); + const params = { startTime, endTime }; + if (person?.terminalNo) + params.terminalNo = person.terminalNo; + else + params.staffNo = person?.staffNo; + + setQueryLoading(true); + try { + const { data } = await props.getPeopleTrajectory(params); + const points = data?.points || []; + if (points.length < 2) { + mapMethods.current.removePeopleTrajectory(); + message.warning("该时间范围内没有可绘制的轨迹"); + return; + } + mapMethods.current.addPeopleTrajectory(points); + } + finally { + setQueryLoading(false); + } + }; + + const handleReset = () => { + form.resetFields(); + mapMethods.current.removePeopleTrajectory(); + }; + + return ( +
+ +
+ +