|
|
@@ -10,14 +10,18 @@ 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.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummarySaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSourceDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSummaryDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc.IotSocSourceMapper;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc.IotSocSummaryMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.qhse.soc.IotSocSummaryService;
|
|
|
import cn.iocoder.yudao.module.pms.util.SafetyObservationCardGenerator;
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
@@ -33,9 +37,8 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
@@ -52,6 +55,10 @@ public class IotSocSummaryController {
|
|
|
private IotSocSummaryService iotSocSummaryService;
|
|
|
@Autowired
|
|
|
private IotSocSourceMapper iotSocSourceMapper;
|
|
|
+ @Autowired
|
|
|
+ private IotSocSummaryMapper iotSocSummaryMapper;
|
|
|
+ @Autowired
|
|
|
+ private DeptService deptService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建SOC卡汇总")
|
|
|
@@ -195,4 +202,57 @@ public class IotSocSummaryController {
|
|
|
// new SafetyObservationCardGenerator.CheckItem("作业场所", "地面滑(水/雨/雪/油污等)", "Housekeeping", "Slippery floor (Water / Rain / Snow / Oil etc.)")
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/stat")
|
|
|
+ @PermitAll
|
|
|
+ public CommonResult<ImmutableMap> statSoc(IotSocSummaryPageReqVO pageReqVO) {
|
|
|
+ List<IotSocSourceDO> list = iotSocSourceMapper.selectList();
|
|
|
+ Long deptId = pageReqVO.getDeptId();
|
|
|
+ if (Objects.isNull(pageReqVO.getDeptId())) {
|
|
|
+ deptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
+ }
|
|
|
+ Set<Long> ids;
|
|
|
+ if (Objects.nonNull(deptId)) {
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(deptId);
|
|
|
+ ids.add(pageReqVO.getDeptId());
|
|
|
+ } else {
|
|
|
+ ids = new HashSet<>();
|
|
|
+ }
|
|
|
+ List<ImmutableMap> results = new ArrayList<>();
|
|
|
+ Map person = new HashMap();
|
|
|
+ list.stream().filter(e -> "不安全".equals(e.getName())).findFirst().ifPresent(e -> {
|
|
|
+ List<IotSocSourceDO> summaryDOS = iotSocSourceMapper.selectList("parent_id", e.getId());
|
|
|
+ AtomicReference<Long> unsafe = new AtomicReference<>(0L);
|
|
|
+ summaryDOS.forEach(item -> {
|
|
|
+ IotSocSummaryPageReqVO pageReqVO1 = new IotSocSummaryPageReqVO();
|
|
|
+ pageReqVO1.setSocClass(String.valueOf(item.getId()));
|
|
|
+ pageReqVO1.setObservationDate(pageReqVO.getObservationDate());
|
|
|
+ Long count = iotSocSummaryMapper.selectCountBySocClassAndTime(pageReqVO1, ids);
|
|
|
+ results.add(ImmutableMap.of(item.getName(), count));
|
|
|
+ unsafe.set(unsafe.get() + count);
|
|
|
+
|
|
|
+ List<IotSocSourceDO> childIds = iotSocSourceMapper.selectList("parent_id", item.getId());
|
|
|
+ List<ImmutableMap> countList = new ArrayList<>();
|
|
|
+ childIds.forEach(child -> {
|
|
|
+ IotSocSummaryPageReqVO pageReqVO2 = new IotSocSummaryPageReqVO();
|
|
|
+ pageReqVO2.setSocClass(String.valueOf(child.getId()));
|
|
|
+ pageReqVO2.setObservationDate(pageReqVO.getObservationDate());
|
|
|
+ Long childCount = iotSocSummaryMapper.selectCountBySocClassAndTime(pageReqVO2, ids);
|
|
|
+ countList.add(ImmutableMap.of(child.getName(), childCount));
|
|
|
+ });
|
|
|
+ person.put(item.getName(), countList);
|
|
|
+
|
|
|
+ });
|
|
|
+ results.add(ImmutableMap.of("不安全", unsafe.get()));
|
|
|
+ });
|
|
|
+ list.stream().filter(e -> "安全的".equals(e.getName())).findFirst().ifPresent(e -> {
|
|
|
+ IotSocSummaryPageReqVO pageReqVO1 = new IotSocSummaryPageReqVO();
|
|
|
+ pageReqVO1.setSocClass(String.valueOf(e.getId()));
|
|
|
+ pageReqVO1.setObservationDate(pageReqVO.getObservationDate());
|
|
|
+ Long count = iotSocSummaryMapper.selectCountBySocClassAndTime(pageReqVO1, ids);
|
|
|
+ results.add(ImmutableMap.of(e.getName(), count));
|
|
|
+ });
|
|
|
+
|
|
|
+ return success(ImmutableMap.of("total", results, "child", person));
|
|
|
+ }
|
|
|
+
|
|
|
}
|