|
|
@@ -1,12 +1,16 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
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.iotmainworkorderbom.vo.IotMainWorkOrderBomPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrddailyreport.vo.IotRdDailyReportPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.stat.vo.AllOrderResp;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
@@ -14,6 +18,9 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorderbom.IotMainWorkOrderBomDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrddailyreport.IotRdDailyReportDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderDeviceMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderMapper;
|
|
|
@@ -40,6 +47,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.security.PermitAll;
|
|
|
import javax.validation.Valid;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -71,6 +81,8 @@ public class IotReportOrderController {
|
|
|
@Operation(summary = "各工单状态数量统计")
|
|
|
@GetMapping("/number")
|
|
|
public CommonResult<ImmutableMap> getOrderStat(@Valid IotMaintainPageReqVO pageReqVO) {
|
|
|
+ LocalDateTime startTime = pageReqVO.getCreateTime()[0];
|
|
|
+ LocalDateTime endTime = pageReqVO.getCreateTime()[1];
|
|
|
Set<Long> ids;
|
|
|
if (Objects.isNull(pageReqVO.getDeptId())){
|
|
|
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
|
|
@@ -84,8 +96,25 @@ public class IotReportOrderController {
|
|
|
List<AllOrderResp> maintains = iotMaintainMapper.selectStatusNumber(pageReqVO);
|
|
|
List<AllOrderResp> inspects = iotInspectOrderMapper.selectStatusNumber(pageReqVO);
|
|
|
List<AllOrderResp> operations = iotOpeationFillMapper.selectStatusNumber(pageReqVO);
|
|
|
+ // 保养
|
|
|
List<AllOrderResp> workOrders = iotMainWorkOrderMapper.selectStatusNumber(pageReqVO);
|
|
|
+ // 保养工单总数量
|
|
|
+ Long byNum = 0l;
|
|
|
+ if (CollUtil.isNotEmpty(workOrders)) {
|
|
|
+ for (AllOrderResp order : workOrders) {
|
|
|
+ if (ObjUtil.isNotEmpty(order.getNum())) {
|
|
|
+ byNum = byNum + order.getNum();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Long tbByNum = 0l;
|
|
|
+ Long hbByNum = 0l;
|
|
|
// 日报
|
|
|
+ Long tbRbNum = 0l;
|
|
|
+ Long hbRbNum = 0l;
|
|
|
+ // 同比 去年同期相同统计数据对比 无数据
|
|
|
+ tbByNum = tbByNum == null ? 0l : tbByNum;
|
|
|
+
|
|
|
List<AllOrderResp> dailyReports = iotRhDailyReportMapper.selectStatusNumber(pageReqVO);
|
|
|
List<AllOrderResp> ryDailyReports = iotRyDailyReportMapper.selectStatusNumber(pageReqVO);
|
|
|
List<AllOrderResp> rdDailyReports = iotRdDailyReportMapper.selectStatusNumber(pageReqVO);
|
|
|
@@ -121,12 +150,107 @@ public class IotReportOrderController {
|
|
|
}
|
|
|
AllOrderResp noReport = new AllOrderResp();
|
|
|
noReport.setStatus("0");
|
|
|
- noReport.setNum(Long.valueOf(noStatus.get()));
|
|
|
+ noReport.setNum(noStatus.get());
|
|
|
reports.add(noReport);
|
|
|
AllOrderResp yesReport = new AllOrderResp();
|
|
|
yesReport.setStatus("1");
|
|
|
- yesReport.setNum(Long.valueOf(yesStatus.get()));
|
|
|
+ yesReport.setNum(yesStatus.get());
|
|
|
reports.add(yesReport);
|
|
|
+ // 当前日报总数量
|
|
|
+ Long rbNum = yesStatus.get() + noStatus.get();
|
|
|
+
|
|
|
+ if ("year".equals(pageReqVO.getTimeType())){
|
|
|
+ // 保养 年 无同比环比数据
|
|
|
+ hbByNum = hbByNum==null ? 0l : hbByNum;
|
|
|
+ } else if ("month".equals(pageReqVO.getTimeType())){
|
|
|
+ LocalDateTime lastMonthStart = startTime.minusMonths(1);
|
|
|
+ LocalDateTime lastMonthEnd = endTime.minusMonths(1);
|
|
|
+ LocalDateTime[] monthTime = pageReqVO.getCreateTime();
|
|
|
+ monthTime[0] = lastMonthStart;
|
|
|
+ monthTime[1] = lastMonthEnd;
|
|
|
+ pageReqVO.setCreateTime(monthTime);
|
|
|
+ List<AllOrderResp> monthWorkOrders = iotMainWorkOrderMapper.selectStatusNumber(pageReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(monthWorkOrders)) {
|
|
|
+ for (AllOrderResp order : monthWorkOrders) {
|
|
|
+ if (ObjUtil.isNotEmpty(order.getNum())) {
|
|
|
+ hbByNum = hbByNum + order.getNum();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ IotRhDailyReportPageReqVO reqVO = new IotRhDailyReportPageReqVO();
|
|
|
+ reqVO.setCreateTime(monthTime);
|
|
|
+ reqVO.setDeptIds(ids);
|
|
|
+ List<IotRhDailyReportDO> monthDailyReports = iotRhDailyReportMapper.dailyReports(reqVO);
|
|
|
+ if (CollUtil.isNotEmpty(monthDailyReports)) {
|
|
|
+ hbRbNum = hbRbNum + monthDailyReports.size();
|
|
|
+ }
|
|
|
+ IotRyDailyReportPageReqVO ryReqVO = new IotRyDailyReportPageReqVO();
|
|
|
+ ryReqVO.setCreateTime(monthTime);
|
|
|
+ ryReqVO.setDeptIds(ids);
|
|
|
+ List<IotRyDailyReportDO> monthRyDailyReports = iotRyDailyReportMapper.dailyReports(ryReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(monthRyDailyReports)) {
|
|
|
+ hbRbNum = hbRbNum + monthRyDailyReports.size();
|
|
|
+ }
|
|
|
+ IotRdDailyReportPageReqVO rdReqVO = new IotRdDailyReportPageReqVO();
|
|
|
+ rdReqVO.setCreateTime(monthTime);
|
|
|
+ rdReqVO.setDeptIds(ids);
|
|
|
+ List<IotRdDailyReportDO> monthRdDailyReports = iotRdDailyReportMapper.dailyReports(rdReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(monthRdDailyReports)) {
|
|
|
+ hbRbNum = hbRbNum + monthRdDailyReports.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ("day".equals(pageReqVO.getTimeType())){
|
|
|
+ LocalDateTime lastDayStart = startTime.minusDays(1);
|
|
|
+ LocalDateTime lastDayEnd = endTime.minusDays(1);
|
|
|
+ LocalDateTime[] dayTime = pageReqVO.getCreateTime();
|
|
|
+ dayTime[0] = lastDayStart;
|
|
|
+ dayTime[1] = lastDayEnd;
|
|
|
+ pageReqVO.setCreateTime(dayTime);
|
|
|
+ List<AllOrderResp> dayWorkOrders = iotMainWorkOrderMapper.selectStatusNumber(pageReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(dayWorkOrders)) {
|
|
|
+ for (AllOrderResp order : dayWorkOrders) {
|
|
|
+ if (ObjUtil.isNotEmpty(order.getNum())) {
|
|
|
+ hbByNum = hbByNum + order.getNum();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ IotRhDailyReportPageReqVO reqVO = new IotRhDailyReportPageReqVO();
|
|
|
+ reqVO.setCreateTime(dayTime);
|
|
|
+ reqVO.setDeptIds(ids);
|
|
|
+ List<IotRhDailyReportDO> monthDailyReports = iotRhDailyReportMapper.dailyReports(reqVO);
|
|
|
+ if (CollUtil.isNotEmpty(monthDailyReports)) {
|
|
|
+ hbRbNum = hbRbNum + monthDailyReports.size();
|
|
|
+ }
|
|
|
+ IotRyDailyReportPageReqVO ryReqVO = new IotRyDailyReportPageReqVO();
|
|
|
+ ryReqVO.setCreateTime(dayTime);
|
|
|
+ ryReqVO.setDeptIds(ids);
|
|
|
+ List<IotRyDailyReportDO> monthRyDailyReports = iotRyDailyReportMapper.dailyReports(ryReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(monthRyDailyReports)) {
|
|
|
+ hbRbNum = hbRbNum + monthRyDailyReports.size();
|
|
|
+ }
|
|
|
+ IotRdDailyReportPageReqVO rdReqVO = new IotRdDailyReportPageReqVO();
|
|
|
+ rdReqVO.setCreateTime(dayTime);
|
|
|
+ rdReqVO.setDeptIds(ids);
|
|
|
+ List<IotRdDailyReportDO> monthRdDailyReports = iotRdDailyReportMapper.dailyReports(rdReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(monthRdDailyReports)) {
|
|
|
+ hbRbNum = hbRbNum + monthRdDailyReports.size();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> byMap = new HashMap<>();
|
|
|
+ byMap.put("total", byNum);
|
|
|
+ byMap.put("hb", (hbByNum==null || hbByNum==0l) ? hbByNum :
|
|
|
+ ((new BigDecimal(byNum).subtract(new BigDecimal(hbByNum))).divide(new BigDecimal(hbByNum),2, RoundingMode.HALF_UP)));
|
|
|
+ byMap.put("tb", (tbByNum==null || tbByNum==0l) ? tbByNum :
|
|
|
+ ((new BigDecimal(byNum).subtract(new BigDecimal(tbByNum))).divide(new BigDecimal(tbByNum),2, RoundingMode.HALF_UP)));
|
|
|
+
|
|
|
+ Map<String, Object> rbMap = new HashMap<>();
|
|
|
+ rbMap.put("total", rbNum);
|
|
|
+ rbMap.put("hb", (hbRbNum==null || hbRbNum==0l) ? hbRbNum :
|
|
|
+ ((new BigDecimal(rbNum).subtract(new BigDecimal(hbRbNum))).divide(new BigDecimal(hbRbNum),2, RoundingMode.HALF_UP)));
|
|
|
+ rbMap.put("tb", (tbRbNum==null || tbRbNum==0l) ? tbRbNum :
|
|
|
+ ((new BigDecimal(rbNum).subtract(new BigDecimal(tbRbNum))).divide(new BigDecimal(tbRbNum),2, RoundingMode.HALF_UP)));
|
|
|
+
|
|
|
return CommonResult.success(ImmutableMap.of("wx", maintains, "xj", inspects, "yx", operations, "by", workOrders, "rb", reports));
|
|
|
}
|
|
|
|