|
@@ -6,12 +6,17 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.IotMeasureBookController;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.ptw.vo.QhsePtwPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.ptw.vo.QhsePtwPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.ptw.vo.QhsePtwRespVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.ptw.vo.QhsePtwRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.ptw.vo.QhsePtwSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.ptw.vo.QhsePtwSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.ptw.QhsePtwDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.ptw.QhsePtwDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.qhse.cert.IotMeasureCertMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.qhse.cert.IotMeasureCertMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.ptw.QhsePtwMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.qhse.ptw.QhsePtwService;
|
|
import cn.iocoder.yudao.module.pms.service.qhse.ptw.QhsePtwService;
|
|
|
|
|
+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 io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -24,7 +29,9 @@ 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.io.IOException;
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@@ -40,6 +47,12 @@ public class QhsePtwController {
|
|
|
private QhsePtwService qhsePtwService;
|
|
private QhsePtwService qhsePtwService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IotMeasureCertMapper iotMeasureCertMapper;
|
|
private IotMeasureCertMapper iotMeasureCertMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DeptService deptService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private QhsePtwMapper qhsePtwMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DictDataService dictDataService;
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建QHSE_PTW作业许可")
|
|
@Operation(summary = "创建QHSE_PTW作业许可")
|
|
@@ -105,4 +118,45 @@ public class QhsePtwController {
|
|
|
// iotMeasureCertDOS.stream()
|
|
// iotMeasureCertDOS.stream()
|
|
|
// return null;
|
|
// return null;
|
|
|
// }
|
|
// }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/type")
|
|
|
|
|
+ public CommonResult<List<IotMeasureBookController.ClassifyMeasureBookStatVo>> getTypeCount(Long deptId) {
|
|
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
|
|
+ if (Objects.nonNull(deptId)) {
|
|
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(deptId);
|
|
|
|
|
+ ids.add(deptId);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<IotMeasureBookController.ClassifyMeasureBookStatVo> results = new ArrayList<>();
|
|
|
|
|
+ QhsePtwPageReqVO pageReqVO = new QhsePtwPageReqVO();
|
|
|
|
|
+ List<QhsePtwDO> list = qhsePtwMapper.selectListByDept(pageReqVO, ids);
|
|
|
|
|
+ Map<String, List<QhsePtwDO>> collect = list.stream().collect(Collectors.groupingBy(QhsePtwDO::getPtwType));
|
|
|
|
|
+ List<DictDataDO> dictType = dictDataService.getDictDataListByDictType("qhse_ptw_type");
|
|
|
|
|
+ collect.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((long) value.size());
|
|
|
|
|
+ statVo.setSort(f.getSort());
|
|
|
|
|
+ results.add(statVo);
|
|
|
|
|
+ }));
|
|
|
|
|
+ return success(results);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/time")
|
|
|
|
|
+ public CommonResult<Map<LocalDate, Long>> getTimeCount(QhsePtwPageReqVO pageReqVO) {
|
|
|
|
|
+ Long deptId = pageReqVO.getDeptId();
|
|
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
|
|
+ if (Objects.nonNull(deptId)) {
|
|
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(deptId);
|
|
|
|
|
+ ids.add(deptId);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<IotMeasureBookController.ClassifyMeasureBookStatVo> results = new ArrayList<>();
|
|
|
|
|
+ List<QhsePtwDO> list = qhsePtwMapper.selectListByDept(pageReqVO, ids);
|
|
|
|
|
+ Map<LocalDate, Long> collect = list.stream()
|
|
|
|
|
+ // 把 LocalDateTime 转 LocalDate
|
|
|
|
|
+ .map(record -> record.getCreateTime().toLocalDate())
|
|
|
|
|
+ // 分组:分类函数直接写 date -> date
|
|
|
|
|
+ .collect(Collectors.groupingBy(date -> date, Collectors.counting()));
|
|
|
|
|
+ return success(collect);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|