wenhongquan 1 yıl önce
ebeveyn
işleme
55b42941bb

+ 29 - 17
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/controller/StatisticController.java

@@ -91,26 +91,38 @@ public class StatisticController extends TblBaseController {
            return R.fail("参数不对");
         }
 
-
-
         Map<String,Object> temp = new HashMap<>();
         try{
-            TblCarInfoBo bo = new TblCarInfoBo();
-            getDepts(dataScopeService,bo);
-            if(bo.getParams().get("depts")!=null){
+            if(data.get("depts")!=null || data.get("carnum")!=null) {
+
+
+                TblCarInfoBo bo = new TblCarInfoBo();
+                try {
+                    if (data.get("depts") != null) {
+                        bo.getParams().put("depts", data.get("depts"));
+                    }
+                    if (data.get("carnum") != null) {
+                        bo.setCarNum(data.get("carnum").toString());
+                    }
+                } catch (Exception e) {
+
+                }
+                getDepts(dataScopeService, bo);
                 List<String> allcodes = new ArrayList<>();
-               List<TblCarInfoVo> carInfos =  carInfoService.queryList(bo);
-
-                carInfos.forEach(carInfo->{
-                    try{
-                        JSONUtil.parseArray(carInfo.getDeviceInfos()).toList(JSONObject.class).forEach(deviceInfo -> {
-                          if(deviceInfo.getStr("type").equals("people_count")){
-                              allcodes.add(StrUtil.format("'{}'",deviceInfo.getStr("code")));
-                           }
-                        });
-                    }catch (Exception e){}
-                });
-                temp.put("devicecodes",allcodes.stream().collect(Collectors.joining(",")));
+                List<TblCarInfoVo> carInfos = carInfoService.queryList(bo);
+                if (carInfos.size() > 0) {
+                    carInfos.forEach(carInfo -> {
+                        try {
+                            JSONUtil.parseArray(carInfo.getDeviceInfos()).toList(JSONObject.class).forEach(deviceInfo -> {
+                                if (deviceInfo.getStr("type").equals("people_count")) {
+                                    allcodes.add(StrUtil.format("'{}'", deviceInfo.getStr("code")));
+                                }
+                            });
+                        } catch (Exception e) {
+                        }
+                    });
+                    temp.put("devicecodes", allcodes.stream().collect(Collectors.joining(",")));
+                }
             }
         }catch (Exception e){}
 

+ 5 - 1
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/controller/TblBaseController.java

@@ -18,7 +18,11 @@ public class TblBaseController extends BaseController {
           if(LoginHelper.isSuperAdmin()||LoginHelper.isTenantAdmin()||LoginHelper.getLoginUser().getDeptId().equals(100L)|| StrUtil.isEmptyIfStr(depts)){
 
           }else{
-              entity.getParams().put("depts",depts);
+              if(entity.getParams().get("depts")!=null){
+                  entity.getParams().put("depts",depts+","+entity.getParams().get("depts"));
+              }else{
+                  entity.getParams().put("depts",depts);
+              }
           }
 
         }