|
@@ -1,35 +1,39 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.qhse.danger;
|
|
package cn.iocoder.yudao.module.pms.controller.admin.qhse.danger;
|
|
|
|
|
|
|
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourcePageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourcePageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.danger.vo.IotDangerSourceSaveReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.IotMeasureBookController;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger.IotDangerSourceDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger.IotDangerSourceDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.danger.IotDangerSourceMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.qhse.danger.IotDangerSourceService;
|
|
import cn.iocoder.yudao.module.pms.service.qhse.danger.IotDangerSourceService;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
-
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
-
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
-
|
|
|
|
|
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
-
|
|
|
|
|
-import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
-import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
|
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
|
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 危险源")
|
|
@Tag(name = "管理后台 - 危险源")
|
|
@@ -40,6 +44,12 @@ public class IotDangerSourceController {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private IotDangerSourceService iotDangerSourceService;
|
|
private IotDangerSourceService iotDangerSourceService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DeptService deptService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IotDangerSourceMapper iotDangerSourceMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DictDataService dictDataService;
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建危险源")
|
|
@Operation(summary = "创建危险源")
|
|
@@ -95,4 +105,31 @@ public class IotDangerSourceController {
|
|
|
BeanUtils.toBean(list, IotDangerSourceRespVO.class));
|
|
BeanUtils.toBean(list, IotDangerSourceRespVO.class));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/stat")
|
|
|
|
|
+ @Operation(summary = "危险源统计")
|
|
|
|
|
+ public CommonResult<ImmutableMap> generateNum(Long deptId) {
|
|
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
|
|
+ if (Objects.nonNull(deptId)) {
|
|
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(deptId);
|
|
|
|
|
+ ids.add(deptId);
|
|
|
|
|
+ }
|
|
|
|
|
+ IotDangerSourcePageReqVO reqVO = new IotDangerSourcePageReqVO();
|
|
|
|
|
+ List<IotDangerSourceDO> iotDangerSourceDOS = iotDangerSourceMapper.selectListByDept(reqVO, ids);
|
|
|
|
|
+ Map<String, Long> classifyCountMap = iotDangerSourceDOS.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ IotDangerSourceDO::getRiskGrade,
|
|
|
|
|
+ Collectors.counting() // 直接统计每个分组的数量
|
|
|
|
|
+ ));
|
|
|
|
|
+ List<IotMeasureBookController.ClassifyMeasureBookStatVo> results = new ArrayList<>();
|
|
|
|
|
+ List<DictDataDO> dictType = dictDataService.getDictDataListByDictType("danger_grade");
|
|
|
|
|
+ classifyCountMap.forEach((key, value) -> dictType.stream().filter(e -> e.getValue().equals(key)).findFirst().ifPresent(f ->{
|
|
|
|
|
+ IotMeasureBookController.ClassifyMeasureBookStatVo statVo = new IotMeasureBookController.ClassifyMeasureBookStatVo();
|
|
|
|
|
+ statVo.setClassify(f.getLabel());
|
|
|
|
|
+ statVo.setCount(value);
|
|
|
|
|
+ results.add(statVo);
|
|
|
|
|
+ }));
|
|
|
|
|
+
|
|
|
|
|
+ return success(ImmutableMap.of("classify", results));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|