Parcourir la source

feat: 缙云新版大屏左侧数据接口修改

xufz il y a 2 ans
Parent
commit
b6a8247360

+ 39 - 6
qhiot-fr/src/main/java/com/qhiot/nfr/jinyun/controller/JinyunController.java

@@ -43,6 +43,9 @@ public class JinyunController extends BaseController {
     @Autowired
     private AreaService areaService;
 
+    @Autowired
+    private StationService stationService;
+
     @RequestMapping(method = RequestMethod.GET)
     public Object report() {
         ModelAndView modelAndView = new ModelAndView();
@@ -56,7 +59,8 @@ public class JinyunController extends BaseController {
         try {
             List<Long> stationIdList = jinyunService.getStationIdList(areaId, category, getTargetTenantId());
             List<DataDTO> list = jinyunService.getCount(stationIdList, field, getTargetTenantId());
-            return AjaxResponse.success().put("list", list);
+            Integer total = list.stream().mapToInt(dto -> Integer.valueOf(String.valueOf(dto.getData()))).sum();
+            return AjaxResponse.success().put("list", list).put("total", total);
         }catch (Exception e) {
             log.error(e.getMessage(), e);
             return AjaxResponse.fail(e.getMessage());
@@ -70,12 +74,21 @@ public class JinyunController extends BaseController {
             Example example = new Example(Area.class);
             example.createCriteria().andEqualTo("parentAreaId", areaId);
             List<Area> areaList = areaService.selectByExample(example);
+            Area thisArea = areaService.selectByPrimaryKey(areaId);
+            areaList.add(thisArea);
             List<DataDTO> result = new ArrayList<>();
             Map<Long, Future<List<DataDTO>>> futureMap = new HashMap<>();
             Long tenantId = getTargetTenantId();
             for (Area area : areaList) {
                 Future<List<DataDTO>> future = ThreadUtil.submit(() -> {
-                    List<Long> stationIdList = jinyunService.getStationIdList(area.getAreaId(), category, tenantId);
+                    List<Long> stationIdList;
+                    if (areaId.equals(area.getAreaId())) {
+                        Example example1 = new Example(Station.class);
+                        example1.createCriteria().andEqualTo("areaId", areaId).andEqualTo("isDel", 1);
+                        stationIdList = stationService.selectByEx(example1);
+                    }else {
+                        stationIdList = jinyunService.getStationIdList(area.getAreaId(), category, tenantId);
+                    }
                     List<DataDTO> list = jinyunService.getCount(stationIdList, field, tenantId);
                     return list;
                 });
@@ -89,7 +102,12 @@ public class JinyunController extends BaseController {
                 result.add(dataDTO);
             }
             result = jinyunService.handlerChildSeries(result);
-            return AjaxResponse.success().put("list", result);
+            Integer total = 0;
+            for (DataDTO dataDTO : result) {
+                List<DataDTO> list = (List) dataDTO.getData();
+                total += list.stream().mapToInt(dto -> Integer.valueOf(String.valueOf(dto.getData()))).sum();
+            }
+            return AjaxResponse.success().put("list", result).put("total", total);
         }catch (Exception e) {
             log.error(e.getMessage(), e);
             return AjaxResponse.fail(e.getMessage());
@@ -103,7 +121,8 @@ public class JinyunController extends BaseController {
         try {
             List<Long> stationIdList = jinyunService.getStationIdList(areaId, category, getTargetTenantId());
             List<DataDTO> list = jinyunService.getSum(stationIdList, field, sumField, getTargetTenantId());
-            return AjaxResponse.success().put("list", list);
+            Integer total = list.stream().mapToInt(dto -> Integer.valueOf(String.valueOf(dto.getData()))).sum();
+            return AjaxResponse.success().put("list", list).put("total", total);
         }catch (Exception e) {
             log.error(e.getMessage(), e);
             return AjaxResponse.fail(e.getMessage());
@@ -118,12 +137,21 @@ public class JinyunController extends BaseController {
             Example example = new Example(Area.class);
             example.createCriteria().andEqualTo("parentAreaId", areaId);
             List<Area> areaList = areaService.selectByExample(example);
+            Area thisArea = areaService.selectByPrimaryKey(areaId);
+            areaList.add(thisArea);
             List<DataDTO> result = new ArrayList<>();
             Map<Long, Future<List<DataDTO>>> futureMap = new HashMap<>();
             Long tenantId = getTargetTenantId();
             for (Area area : areaList) {
                 Future<List<DataDTO>> future = ThreadUtil.submit(() -> {
-                    List<Long> stationIdList = jinyunService.getStationIdList(area.getAreaId(), category, tenantId);
+                    List<Long> stationIdList;
+                    if (areaId.equals(area.getAreaId())) {
+                        Example example1 = new Example(Station.class);
+                        example1.createCriteria().andEqualTo("areaId", areaId).andEqualTo("isDel", 1);
+                        stationIdList = stationService.selectByEx(example1);
+                    }else {
+                        stationIdList = jinyunService.getStationIdList(area.getAreaId(), category, tenantId);
+                    }
                     List<DataDTO> list = jinyunService.getSum(stationIdList, field, sumField, tenantId);
                     return list;
                 });
@@ -137,7 +165,12 @@ public class JinyunController extends BaseController {
                 result.add(dataDTO);
             }
             result = jinyunService.handlerChildSeries(result);
-            return AjaxResponse.success().put("list", result);
+            Integer total = 0;
+            for (DataDTO dataDTO : result) {
+                List<DataDTO> list = (List) dataDTO.getData();
+                total += list.stream().mapToInt(dto -> Integer.valueOf(String.valueOf(dto.getData()))).sum();
+            }
+            return AjaxResponse.success().put("list", result).put("total", total);
         }catch (Exception e) {
             log.error(e.getMessage(), e);
             return AjaxResponse.fail(e.getMessage());

+ 1 - 1
qhiot-fr/src/main/java/com/qhiot/nfr/jinyun/service/JinyunService.java

@@ -105,7 +105,7 @@ public class JinyunService {
     }
 
     /**
-     *
+     * 不同区域下所含有的站点类型不尽相同,在此处将区域下没有的类型补全,并置0
      * @param list
      * @return
      * @throws ServiceException