|
|
@@ -10,12 +10,16 @@ import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBo
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.measure.IotMeasureBookMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.qhse.measure.IotMeasureBookService;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
|
|
+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.Parameters;
|
|
|
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.*;
|
|
|
@@ -25,7 +29,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 static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
@@ -39,6 +46,10 @@ public class IotMeasureBookController {
|
|
|
|
|
|
@Resource
|
|
|
private IotMeasureBookService iotMeasureBookService;
|
|
|
+ @Autowired
|
|
|
+ private IotMeasureBookMapper iotMeasureBookMapper;
|
|
|
+ @Autowired
|
|
|
+ private DeptService deptService;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建计量器具台账")
|
|
|
@@ -111,4 +122,26 @@ public class IotMeasureBookController {
|
|
|
BeanUtils.toBean(list, IotMeasureBookRespVO.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);
|
|
|
+ }
|
|
|
+ //到期
|
|
|
+ IotMeasureBookPageReqVO reqVO = new IotMeasureBookPageReqVO();
|
|
|
+ reqVO.setExpired(true);
|
|
|
+ long expired = iotMeasureBookMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
|
|
|
+ reqVO.setExpired(null);
|
|
|
+ reqVO.setAlertWarn(true);
|
|
|
+ //90天预警
|
|
|
+ long warn = iotMeasureBookMapper.selectCountByDeptAndExpireAndWarn(reqVO, ids);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return success(ImmutableMap.of("expired", expired, "warn", warn));
|
|
|
+ }
|
|
|
}
|