|
|
@@ -1,32 +1,16 @@
|
|
|
package org.dromara.system.controller;
|
|
|
|
|
|
-import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
-import jakarta.servlet.http.HttpServletResponse;
|
|
|
-import jakarta.validation.constraints.NotEmpty;
|
|
|
-import jakarta.validation.constraints.NotNull;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
-import org.dromara.common.core.validate.AddGroup;
|
|
|
-import org.dromara.common.core.validate.EditGroup;
|
|
|
-import org.dromara.common.excel.utils.ExcelUtil;
|
|
|
-import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
|
|
-import org.dromara.common.log.annotation.Log;
|
|
|
-import org.dromara.common.log.enums.BusinessType;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.common.web.core.BaseController;
|
|
|
-import org.dromara.system.domain.CountData;
|
|
|
-import org.dromara.system.domain.GpsData;
|
|
|
-import org.dromara.system.domain.bo.CountDataBo;
|
|
|
-import org.dromara.system.domain.bo.GpsDataBo;
|
|
|
-import org.dromara.system.domain.bo.TblCarInfoBo;
|
|
|
-import org.dromara.system.domain.vo.CountDataVo;
|
|
|
-import org.dromara.system.domain.vo.GpsDataVo;
|
|
|
-import org.dromara.system.domain.vo.TblCarInfoVo;
|
|
|
-import org.dromara.system.service.ITblCarInfoService;
|
|
|
-import org.dromara.system.service.ITblCountDataService;
|
|
|
-import org.dromara.system.service.ITblGpsDataService;
|
|
|
-import org.dromara.util.MessageUtils;
|
|
|
+import org.dromara.system.domain.bo.*;
|
|
|
+import org.dromara.system.domain.vo.*;
|
|
|
+import org.dromara.system.service.*;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -34,6 +18,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
/**
|
|
|
* 车辆信息
|
|
|
@@ -51,6 +36,11 @@ public class TblGpsDataController extends BaseController {
|
|
|
|
|
|
private final ITblCountDataService countDataService;
|
|
|
|
|
|
+ private final ISysDictDataService sysDictDataService;
|
|
|
+
|
|
|
+ private final ITblCarScheduleService carScheduleService;
|
|
|
+ private final ITblCarInfoService carInfoService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询车辆信息列表
|
|
|
*/
|
|
|
@@ -61,6 +51,9 @@ public class TblGpsDataController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询设备人流量
|
|
|
+ */
|
|
|
@GetMapping("/peoplecount/list")
|
|
|
public Object list(CountDataBo bo) {
|
|
|
if(bo.getParams()!=null && bo.getParams().get("times")!=null){
|
|
|
@@ -104,4 +97,130 @@ public class TblGpsDataController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询站点人流量列表
|
|
|
+ */
|
|
|
+ @GetMapping("/sites/flow")
|
|
|
+ public TableDataInfo<SysDictDataVo> listFalow(SysDictDataBo bo, PageQuery pageQuery) {
|
|
|
+
|
|
|
+ bo.setDictType("tbl_sites");
|
|
|
+ //查询站点
|
|
|
+ TableDataInfo<SysDictDataVo> sites = sysDictDataService.selectPageDictDataList(bo, pageQuery);
|
|
|
+
|
|
|
+
|
|
|
+ List<TblCarScheduleVo> usedSchedule = new ArrayList<>();
|
|
|
+ //查询时间段内包含上述站点的排班
|
|
|
+ TblCarScheduleBo bo1 = new TblCarScheduleBo();
|
|
|
+ bo1.setParams(bo.getParams());
|
|
|
+ List<TblCarScheduleVo> scheduleVos = carScheduleService.queryList(bo1);
|
|
|
+ scheduleVos.forEach(item->{
|
|
|
+ if(!StrUtil.isEmptyIfStr(item.getExt1())){
|
|
|
+ for (int i = 0; i < sites.getRows().size(); i++) {
|
|
|
+ SysDictDataVo site = sites.getRows().get(i);
|
|
|
+ if(item.getExt1().contains(site.getDictLabel())){
|
|
|
+ usedSchedule.add(item);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(usedSchedule.size()<1) return sites;
|
|
|
+ //获取车牌
|
|
|
+ TblCarInfoBo bo3 = new TblCarInfoBo();
|
|
|
+ bo3.getParams().put("carNums",usedSchedule.stream().map(TblCarScheduleVo::getCarNum).toList());
|
|
|
+ List<TblCarInfoVo> carInfoVos = carInfoService.queryList(bo3);
|
|
|
+ // 站点 设备 时间范围
|
|
|
+ Map<String,Map<String,List<Map<String,String>>>> sitesMap = new HashMap<>();
|
|
|
+ //车牌设备
|
|
|
+ Map<String,List<String>> deviceMap = new HashMap<>();
|
|
|
+ carInfoVos.forEach(item->{
|
|
|
+ JSONUtil.parseArray(item.getDeviceInfos()).toList(JSONObject.class).forEach(deviceInfo -> {
|
|
|
+ if(deviceInfo.getStr("type").contains("people_count")){
|
|
|
+ if(deviceMap.get(item.getCarNum())==null) deviceMap.put(item.getCarNum(),new ArrayList<>());
|
|
|
+ deviceMap.get(item.getCarNum()).add(deviceInfo.getStr("code"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ //{
|
|
|
+ // "程家垄": {
|
|
|
+ // "intime": "2024-05-07 10:48:34",
|
|
|
+ // "outtime": "2024-05-07 10:48:39"
|
|
|
+ // },
|
|
|
+ // "福安客运站": {
|
|
|
+ // "intime": "2024-05-07 10:47:42",
|
|
|
+ // "outtime": "2024-05-07 10:48:01"
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ usedSchedule.forEach(item->{
|
|
|
+ if(deviceMap.get(item.getCarNum())!=null) {
|
|
|
+ JSONObject ext1 = JSONUtil.parseObj(item.getExt1());
|
|
|
+ for (String key : ext1.keySet()) {
|
|
|
+ if (sitesMap.get(key) == null) {
|
|
|
+ sitesMap.put(key, new HashMap<>());
|
|
|
+ }
|
|
|
+ Map<String, List<Map<String, String>>> ideviceMap = sitesMap.get(key);
|
|
|
+ deviceMap.get(item.getCarNum()).forEach(deviceCode->{
|
|
|
+ if(ideviceMap.get(deviceCode)==null) ideviceMap.put(deviceCode,new ArrayList<>());
|
|
|
+ ideviceMap.get(deviceCode).add(ext1.get(key, Map.class));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Map<String,Map<String,Object>> sitesc = new HashMap<>();
|
|
|
+ sitesMap.forEach((key,value)->{
|
|
|
+ AtomicReference<Integer> incount = new AtomicReference<>(0);
|
|
|
+ AtomicReference<Integer> outcount = new AtomicReference<>(0);
|
|
|
+ value.forEach((deviceCode,times)->{
|
|
|
+ times.forEach(time->{
|
|
|
+ CountDataBo bo2 = new CountDataBo();
|
|
|
+ bo2.getParams().put("starttime",time.get("intime"));
|
|
|
+ bo2.getParams().put("endtime",time.get("outtime"));
|
|
|
+ bo2.setDevicecode(deviceCode);
|
|
|
+ List<CountDataVo> countDataVos = countDataService.queryList(bo2);
|
|
|
+ countDataVos.forEach(item1->{
|
|
|
+ incount.updateAndGet(v -> v + item1.getIncount());
|
|
|
+ outcount.updateAndGet(v -> v + item1.getOutcount());
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ sitesc.put(key,Map.of("incount",incount.get(),"outcount",outcount.get()));
|
|
|
+ });
|
|
|
+
|
|
|
+ sites.getRows().forEach(item->{
|
|
|
+ item.setOthers(new HashMap<>());
|
|
|
+ if(sitesc.get(item.getDictLabel())!=null){
|
|
|
+ item.setOthers(sitesc.get(item.getDictLabel()));
|
|
|
+ }else{
|
|
|
+ item.getOthers().put("incount",0);
|
|
|
+ item.getOthers().put("outcount",0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+// //查询人流量数据
|
|
|
+// CountDataBo bo2 = new CountDataBo();
|
|
|
+// bo2.getParams().put("starttime",bo.getParams().get("starttime"));
|
|
|
+// bo2.getParams().put("endtime",bo.getParams().get("endtime"));
|
|
|
+// bo2.getParams().put("deviceCodes",);
|
|
|
+// countDataService.queryList(bo2)
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// //根据排班查询车辆在站点时间
|
|
|
+// for (TblCarScheduleVo scheduleVo : usedSchedule) {
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ //根据车辆查人流量数据
|
|
|
+
|
|
|
+ //统计
|
|
|
+
|
|
|
+ return sites;
|
|
|
+
|
|
|
+// return gpsDataService.queryPageList(bo, pageQuery);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|