|
|
@@ -10,9 +10,12 @@ import cn.iocoder.yudao.module.pms.controller.admin.qhse.devicecert.vo.QhseDevic
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.devicecert.vo.QhseDeviceCertRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.devicecert.vo.QhseDeviceCertSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.devicecert.QhseDeviceCertDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.devicecert.QhseDeviceCertMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.qhse.devicecert.QhseDeviceCertService;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+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;
|
|
|
@@ -25,8 +28,10 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
@@ -43,6 +48,10 @@ public class QhseDeviceCertController {
|
|
|
private QhseDeviceCertService qhseDeviceCertService;
|
|
|
@Autowired
|
|
|
private DeptApi deptApi;
|
|
|
+ @Autowired
|
|
|
+ private DeptService deptService;
|
|
|
+ @Autowired
|
|
|
+ private QhseDeviceCertMapper qhseDeviceCertMapper;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建QHSE应检设备证书")
|
|
|
@@ -123,4 +132,25 @@ public class QhseDeviceCertController {
|
|
|
BeanUtils.toBean(list, QhseDeviceCertRespVO.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);
|
|
|
+ }
|
|
|
+ //到期
|
|
|
+ QhseDeviceCertPageReqVO reqVO = new QhseDeviceCertPageReqVO();
|
|
|
+ reqVO.setExpired(true);
|
|
|
+ long expired = qhseDeviceCertMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
|
|
|
+ reqVO.setExpired(null);
|
|
|
+ reqVO.setAlertWarn(true);
|
|
|
+ //90天预警
|
|
|
+ long warn = qhseDeviceCertMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
|
|
|
+ reqVO.setAlertWarn(null);
|
|
|
+ Long total = qhseDeviceCertMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
|
|
|
+ return success(ImmutableMap.of("expired", expired, "warn", warn, "total", total));
|
|
|
+ }
|
|
|
}
|