|
@@ -0,0 +1,74 @@
|
|
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
|
|
|
+
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.failure.vo.IotFailureReportPageReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.failure.IotFailureReportDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.failure.IotFailureReportMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.security.PermitAll;
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+
|
|
|
|
|
+@Tag(name = "报表故障上报接口")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/rq/report/failure")
|
|
|
|
|
+@Validated
|
|
|
|
|
+@PermitAll
|
|
|
|
|
+public class IotReportFailureController {
|
|
|
|
|
+ private final DeptUtil deptUtil;
|
|
|
|
|
+ private final DeptService deptService;
|
|
|
|
|
+ private final IotFailureReportMapper iotFailureReportMapper;
|
|
|
|
|
+
|
|
|
|
|
+ public IotReportFailureController(DeptUtil deptUtil, DeptService deptService, IotFailureReportMapper iotFailureReportMapper) {
|
|
|
|
|
+ this.deptUtil = deptUtil;
|
|
|
|
|
+ this.deptService = deptService;
|
|
|
|
|
+ this.iotFailureReportMapper = iotFailureReportMapper;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/status")
|
|
|
|
|
+ public CommonResult<ImmutableMap> getFailureStat(@Valid IotFailureReportPageReqVO iotFailureReportPageReqVO) {
|
|
|
|
|
+ Set<Long> ids;
|
|
|
|
|
+ String companyCode;
|
|
|
|
|
+ if (Objects.isNull(iotFailureReportPageReqVO.getDeptId())){
|
|
|
|
|
+ Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
|
|
+ companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(iotFailureReportPageReqVO.getDeptId());
|
|
|
|
|
+ ids.add(iotFailureReportPageReqVO.getDeptId());
|
|
|
|
|
+ }
|
|
|
|
|
+ iotFailureReportPageReqVO.setStatus("reporting");
|
|
|
|
|
+ Long reporting = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO, ids);
|
|
|
|
|
+ iotFailureReportPageReqVO.setStatus("trans");
|
|
|
|
|
+ Long trans = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO, ids);
|
|
|
|
|
+ iotFailureReportPageReqVO.setStatus("finished");
|
|
|
|
|
+ Long finished = iotFailureReportMapper.selectCountByTimeAndStatus(iotFailureReportPageReqVO, ids);
|
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("reporting", reporting, "trans", trans, "finished", finished));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
|
+ public CommonResult<PageResult<IotFailureReportDO>> getFailureReportPage(@Valid IotFailureReportPageReqVO iotFailureReportPageReqVO) {
|
|
|
|
|
+ Set<Long> ids;
|
|
|
|
|
+ String companyCode;
|
|
|
|
|
+ if (Objects.isNull(iotFailureReportPageReqVO.getDeptId())){
|
|
|
|
|
+ Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
|
|
+ companyCode = deptUtil.getCompanyCode(loginUserDeptId);
|
|
|
|
|
+ ids = deptUtil.getDeptIds(companyCode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ids = deptService.getChildDeptIdListFromCache(iotFailureReportPageReqVO.getDeptId());
|
|
|
|
|
+ ids.add(iotFailureReportPageReqVO.getDeptId());
|
|
|
|
|
+ }
|
|
|
|
|
+ PageResult<IotFailureReportDO> iotFailureReportDOPageResult = iotFailureReportMapper.selectPage(iotFailureReportPageReqVO, ids);
|
|
|
|
|
+ return CommonResult.success(iotFailureReportDOPageResult);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|