zhangcl 2 долоо хоног өмнө
parent
commit
bad800e0a5
43 өөрчлөгдсөн 2083 нэмэгдсэн , 265 устгасан
  1. 4 0
      yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java
  2. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/config/PmsDataPermissionConfiguration.java
  3. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmodeltemplateattrs/vo/IotModelTemplateAttrsRespVO.java
  4. 3 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmodeltemplateattrs/vo/IotModelTemplateAttrsSaveReqVO.java
  5. 252 74
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/IotOpeationFillController.java
  6. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOpeationFillPageReqVO.java
  7. 1 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOpeationFillRespVO.java
  8. 1 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOpeationFillSaveReqVO.java
  9. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotoperationplan/vo/IotOperationPlanPageReqVO.java
  10. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotoperationplan/vo/IotOperationPlanRespVO.java
  11. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotoperationplan/vo/IotOperationPlanSaveReqVO.java
  12. 23 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotprojecttask/IotProjectTaskController.java
  13. 3 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotprojecttask/vo/IotProjectTaskRespVO.java
  14. 27 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java
  15. 8 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportPageReqVO.java
  16. 3 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportRespVO.java
  17. 5 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportSaveReqVO.java
  18. 93 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/IotRyDailyReportController.java
  19. 128 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportPageReqVO.java
  20. 156 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportRespVO.java
  21. 115 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportSaveReqVO.java
  22. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotdevicerunlog/IotDeviceRunLogDO.java
  23. 6 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotmodeltemplateattrs/IotModelTemplateAttrsDO.java
  24. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotoperationplan/IotOperationPlanDO.java
  25. 165 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotrydailyreport/IotRyDailyReportDO.java
  26. 1 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java
  27. 19 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotdevicerunlog/IotDeviceRunLogMapper.java
  28. 40 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotopeationfill/IotOpeationFillMapper.java
  29. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotopeationfill/IotOpeationFillOrderMapper.java
  30. 2 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotoperationplan/IotOperationPlanMapper.java
  31. 13 3
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrhdailyreport/IotRhDailyReportMapper.java
  32. 57 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrydailyreport/IotRyDailyReportMapper.java
  33. 174 25
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/IotOperationPlanJob.java
  34. 27 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotopeationfill/IotOpeationFillService.java
  35. 83 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotopeationfill/IotOpeationFillServiceImpl.java
  36. 25 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportService.java
  37. 186 141
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java
  38. 55 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrydailyreport/IotRyDailyReportService.java
  39. 72 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrydailyreport/IotRyDailyReportServiceImpl.java
  40. 262 6
      yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml
  41. 26 1
      yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOperationPlanMapper.xml
  42. 17 7
      yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotProjectTaskMapper.xml
  43. 15 0
      yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRhDailyReportMapper.xml

+ 4 - 0
yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java

@@ -72,6 +72,7 @@ public interface ErrorCodeConstant{
     ErrorCode IOT_MATERIAL_REQUISITION_DETAIL_NOT_EXISTS = new ErrorCode(155, "PMS 物料领用明细不存在");
     ErrorCode IOT_PROJECT_INFO_NOT_EXISTS = new ErrorCode(152, "项目信息不存在");
     ErrorCode IOT_PROJECT_TASK_NOT_EXISTS = new ErrorCode(153, "该任务不存在");
+    ErrorCode IOT_PROJECT_TASK_NOT_RELATED = new ErrorCode(264, "当前部门没有关联项目任务");
     ErrorCode PRODUCT_EXITS_CHILDREN = new ErrorCode(1_002_004_003, "存在子分类,无法删除");
     ErrorCode INSPECT_DEVICE_CHANGE = new ErrorCode(154, "设备已调拨");
     ErrorCode IOT_APP_NOT_EXISTS = new ErrorCode(155, "app版本不存在");
@@ -86,4 +87,7 @@ public interface ErrorCodeConstant{
     ErrorCode IOT_DAILY_REPORT_ATTRS_NOT_EXISTS = new ErrorCode(261, "日报扩展模板属性不存在");
     ErrorCode IOT_PROJECT_DAILY_REPORT_NOT_EXISTS = new ErrorCode(262, "项目日报不存在");
     ErrorCode IOT_RH_DAILY_REPORT_NOT_EXISTS = new ErrorCode(263, "瑞恒日报不存在");
+    ErrorCode IOT_RH_DAILY_REPORT_NO_DATE = new ErrorCode(265, "未传递运行记录生成日期");
+    ErrorCode IOT_RH_DAILY_REPORT_NO_DEPT = new ErrorCode(266, "未传递运行记录所属部门");
+    ErrorCode IOT_RY_DAILY_REPORT_NOT_EXISTS = new ErrorCode(267, "瑞鹰日报不存在");
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/config/PmsDataPermissionConfiguration.java

@@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectPlanDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectRouteDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotlockstock.IotLockStockDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorder.IotMainWorkOrderDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstock.IotSapStockDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.maintain.IotMaintainDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.maintenance.IotMaintenancePlanDO;
@@ -51,6 +52,7 @@ public class PmsDataPermissionConfiguration {
             rule.addDeptColumn(IotMainWorkOrderDO.class, "dept_id");
             rule.addDeptColumn(IotMaintenancePlanDO.class, "dept_id");
             rule.addDeptColumn(IotSapStockDO.class, "dept_id");
+            rule.addDeptColumn(IotRhDailyReportDO.class, "dept_id");
             // user
 //            rule.addUserColumn(SupplierDO.class);
             rule.addUserColumn(AdminUserDO.class, "id");

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmodeltemplateattrs/vo/IotModelTemplateAttrsRespVO.java

@@ -113,4 +113,6 @@ public class IotModelTemplateAttrsRespVO {
      * 累计属性ID
      */
     private Long sumId;
+
+    private int dailyReport;
 }

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmodeltemplateattrs/vo/IotModelTemplateAttrsSaveReqVO.java

@@ -75,4 +75,7 @@ public class IotModelTemplateAttrsSaveReqVO {
      */
     private Long sumId;
 
+
+    private int dailyReport;
+
 }

+ 252 - 74
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/IotOpeationFillController.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
@@ -8,6 +9,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplateattrs.vo.Iot
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO;
 import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillSaveReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.DeviceVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
 import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO;
@@ -22,10 +24,14 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModel
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotThingsModelDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO;
+
 import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.YfDeviceDO;
+
 import cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant;
 import cn.iocoder.yudao.module.pms.service.IDeviceService;
 import cn.iocoder.yudao.module.pms.service.iotopeationfill.IotOpeationFillService;
+
+import cn.iocoder.yudao.module.pms.service.iotrhdailyreport.IotRhDailyReportService;
 import cn.iocoder.yudao.module.pms.service.yanfan.YfDeviceService;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
 import com.aliyun.tea.utils.StringUtils;
@@ -79,6 +85,8 @@ public class IotOpeationFillController {
     private YfDeviceService yfDeviceService;
     @Resource
     private DeptService deptService;
+    @Resource
+    private IotRhDailyReportService iotRhDailyReportService;
 
     @PostMapping("/create")
     @Operation(summary = "创建运行记录填报")
@@ -127,6 +135,11 @@ public class IotOpeationFillController {
             deviceRunLogDO.setCreateTime(LocalDateTime.of(fill.getCreateTime(),localTime));
             deviceRunLogDO.setPointName(fill.getPointName());
             deviceRunLogDO.setTotalRunTime(fill.getTotalRunTime());
+            if(fill.getIsSum()==0){
+                deviceRunLogDO.setIsSum(0);
+            }else{
+                deviceRunLogDO.setIsSum(1);
+            }
 
             logDO.add(deviceRunLogDO);
         }
@@ -178,7 +191,53 @@ public class IotOpeationFillController {
             iotOpeationFillService.updateFillOrder2(deviceRunLogDO);
         }
 
-        return success(iotOpeationFillService.insertLog(logDO));
+        for (IotDeviceRunLogDO log:logDO) {
+            //根据设备编码,属性名称和时间查询run_log表
+            //有数据则更新,无数据则插入
+            IotDeviceRunLogDO fillData = iotOpeationFillService.reportData(log);
+            if(fillData == null){
+                iotOpeationFillService.insertLog1(log);
+            }else{
+                if(log.getIsSum() == 0){
+                    iotOpeationFillService.updateLog(log);
+                }else{
+                    iotOpeationFillService.updateSumLog(log);
+                }
+            }
+        }
+
+        IotDeviceRunLogDO runDo = logDO.get(0);
+
+        IotOpeationFillDO reportDO = new IotOpeationFillDO();
+        reportDO.setDeviceId(runDo.getDeviceId());
+        reportDO.setCreateTime(runDo.getCreateTime());
+        IotOpeationFillDO fillDO1 = iotOpeationFillService.isReport(reportDO);
+
+        //虚拟设备插入日报
+        if(fillDO1.getIsReport()==1){
+
+            IotRhDailyReportSaveReqVO saveReqVO = new IotRhDailyReportSaveReqVO();
+            Map<String, Object> stringObjectMap = BeanUtil.beanToMap(saveReqVO);
+
+            for (IotDeviceRunLogDO logDO1:logDO) {
+
+                IotDeviceRunLogDO descDO = iotOpeationFillService.getDesc(logDO1);
+
+                if(descDO!=null){
+                    stringObjectMap.forEach((k,v)->{
+                        if(k.equals(descDO.getPointName())){
+                            stringObjectMap.put(k,logDO1.getFillContent());
+                        }
+                    });
+                }
+            }
+                IotRhDailyReportSaveReqVO saveReqVO1 = BeanUtil.mapToBean(stringObjectMap,IotRhDailyReportSaveReqVO.class,false);
+                saveReqVO1.setDeptId(fillDO1.getDeptId());
+                saveReqVO1.setFillOrderCreateTime(fillList.get(0).getCreateTime().atStartOfDay());
+                iotRhDailyReportService.createIotRhDailyReport(saveReqVO1);
+            }
+
+        return success(1);
     }
 
     @PutMapping("/update")
@@ -234,9 +293,6 @@ public class IotOpeationFillController {
              */
             fillList = iotOpeationFillService.fillListByUserId(pageReqVO);
 
-        if (CollUtil.isEmpty(fillList)) {
-            throw new ServiceException(ErrorCodeConstant.IOT_OPEATION_FILL_NOT_EXISTS1);
-        }
         return success(BeanUtils.toBean(fillList, IotOpeationFillDO.class));
     }
 
@@ -289,6 +345,7 @@ public class IotOpeationFillController {
          */
         for (IotOpeationFillOrderDO orderDO : fillList.getList()) {
             fill.setOrderId(orderDO.getId());
+            fill.setDeptId(orderDO.getDeptId());
             List<IotOpeationFillDO> dList = iotOpeationFillService.fillListByDeptId(fill);
             IotOpeationFillDO devList = iotOpeationFillService.devListByOrderId(fill);
             if(dList.size()>0){
@@ -361,63 +418,198 @@ public class IotOpeationFillController {
     @Parameter(name = "deviceCategoryName", description = "名称", required = true, example = "1024")
     public CommonResult<List<IotModelTemplateAttrsDO1>> getModelAttrs(@Valid IotModelTemplateAttrsRespVO vo) throws SQLException{
 
+        //判断是否为虚拟设备
+        //如果是走原来逻辑
+        //不是走虚拟设备逻辑
+        IotOpeationFillDO fillDO = new IotOpeationFillDO();
+        fillDO.setDeviceId(vo.getDeviceId());
+        fillDO.setCreateTime(vo.getCreateTime().atStartOfDay());
+        IotOpeationFillDO fillDO1 = iotOpeationFillService.isReport(fillDO);
+
+
+        List<IotModelTemplateAttrsDO1> resut = new ArrayList<>();
         List<IotModelTemplateAttrsDO> list = iotOpeationFillService.getAttrsById(vo );
 
+        if(fillDO1.getIsReport()==1){
+
+            IotOpeationFillDO fillDO2 = iotOpeationFillService.orderDO(fillDO);
 
-        List<YfDeviceDO> allDevice = yfDeviceService.getAllDevice();
+            List<IotOpeationFillDO> reportList = new ArrayList<>();
+            List<IotOpeationFillDO> reportList1 = new ArrayList<>();
 
+            if(fillDO2!=null){
+                reportList = iotOpeationFillService.reportList(fillDO2);
+                reportList1 = iotOpeationFillService.reportList1(fillDO2);
+            }
 
 
-        LocalTime localTime = LocalTime.of(0,0,0);
-        LocalTime localTime1 = LocalTime.of(23,59,59);
+            for (IotModelTemplateAttrsDO attrsDO:list) {
 
-        LocalDateTime start = LocalDateTime.of(vo.getCreateTime(),localTime);
-        LocalDateTime end = LocalDateTime.of(vo.getCreateTime(),localTime1);
 
-        Timestamp startTime = Timestamp.valueOf(start);
-        Timestamp endTime = Timestamp.valueOf(end);
+                //根据日报取值设备赋值
+                if(reportList.size()>0){
 
+                    List<IotOpeationFillDO> cxLixt = reportList.stream().filter(e->e.getOrgName().equals(attrsDO.getName())).collect(Collectors.toList());
+                    //虚拟设备取值
+                    List<IotOpeationFillDO> cxLixt1 = reportList1.stream().filter(e->e.getOrgName().equals(attrsDO.getName())).collect(Collectors.toList());
 
-        List<YfDeviceDO> existList = allDevice.stream().filter(e->e.getStatus()==3).collect(Collectors.toList());
-        boolean exists1 = existList.stream().anyMatch(yfDeviceDO->yfDeviceDO.getSerialNumber().equals(vo.getDeviceCode()));
+                    if(cxLixt.size()>0){
+                        // 使用Map按orgName分组存储累加结果
+                        Map<String, String> orgNameToFillContent = new HashMap<>();
 
-        IotDeviceRunLogDO logDO1 = new IotDeviceRunLogDO();
-        logDO1.setDeviceId(vo.getDeviceId());
-        LocalTime local = LocalTime.of(12, 0);
-        logDO1.setCreateTime(LocalDateTime.of(vo.getCreateTime(),local));
+                        for (IotOpeationFillDO reportData : cxLixt) {
+                            IotDeviceRunLogDO report = new IotDeviceRunLogDO();
+                            report.setDeviceId(reportData.getDeviceId());
+                            report.setPointName(reportData.getOrgName());
+                            report.setCreateTime(reportData.getCreateTime());
 
-        if(exists1){
-            for (IotModelTemplateAttrsDO attrsDO:list) {
+                            IotDeviceRunLogDO reportCx = iotOpeationFillService.reportData(report);
 
-                DeviceVO dv= new DeviceVO();
-                dv.setDeviceName(vo.getDeviceCode().toLowerCase());
-                dv.setColName(attrsDO.getModelAttr());
-                dv.setTs(startTime);
-                dv.setTs1(endTime);
-
-                DeviceVO deviceVO = iDeviceService.getYesInfo(dv);
-
-                if(!StringUtils.isEmpty(deviceVO) && !deviceVO.getEarliestData().equals("0.0")){
-                    attrsDO.setFillContent(
-                            String.valueOf(Double.parseDouble(deviceVO.getLatestData())-Double.parseDouble(deviceVO.getEarliestData())));
-                    attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
-                    /**
-                     * 设置为数采
-                     */
-                    attrsDO.setIsCollection(1);
-                }else{
+                            String currentContent = "";
+                            if(reportCx==null){
+                                attrsDO.setFillContent("");
+                            }else{
+                                currentContent = reportCx.getFillContent() != null ? reportCx.getFillContent() : "";
+                            }
+
+
+                            // 获取当前orgName
+                            String orgName = reportData.getOrgName();
+
+                            // 累加相同orgName的内容
+                            if (orgNameToFillContent.containsKey(orgName)) {
+                                String existingContent = orgNameToFillContent.get(orgName);
+
+                                double existingValue = safeParseInt(existingContent);
+                                double currentValue = safeParseInt(currentContent);
+
+                                if((existingValue + currentValue)==0){
+                                    orgNameToFillContent.put(orgName, "");
+                                }else{
+                                    orgNameToFillContent.put(orgName, String.valueOf(existingValue + currentValue));
+                                }
+
+                            } else {
+                                orgNameToFillContent.put(orgName, currentContent);
+                            }
+                            attrsDO.setFillContent(orgNameToFillContent.get(reportData.getOrgName()));
+
+                        }
+                    }
+
+                    if(cxLixt1.size()>0){
+                        for (IotOpeationFillDO reportData : cxLixt1) {
+                            IotDeviceRunLogDO report = new IotDeviceRunLogDO();
+                            report.setDeviceId(reportData.getDeviceId());
+                            report.setPointName(reportData.getOrgName());
+                            report.setCreateTime(reportData.getCreateTime());
+                            IotDeviceRunLogDO reportCx = iotOpeationFillService.reportData(report);
+
+                            String currentContent = "";
+                            if(reportCx!=null){
+                                currentContent = reportCx.getFillContent() != null ? reportCx.getFillContent() : "";
+                                attrsDO.setFillContent(currentContent);
+                            }
+                        }
+                    }
+
+                }
+
+                attrsDO.setIsCollection(0);
+                attrsDO.setIsSum(0);
+            }
+
+
+
+        }else{
+
+
+
+            List<YfDeviceDO> allDevice = yfDeviceService.getAllDevice();
+
+
+
+            LocalTime localTime = LocalTime.of(0,0,0);
+            LocalTime localTime1 = LocalTime.of(23,59,59);
+
+            LocalDateTime start = LocalDateTime.of(vo.getCreateTime(),localTime);
+            LocalDateTime end = LocalDateTime.of(vo.getCreateTime(),localTime1);
+
+            Timestamp startTime = Timestamp.valueOf(start);
+            Timestamp endTime = Timestamp.valueOf(end);
+
+
+            List<YfDeviceDO> existList = allDevice.stream().filter(e->e.getStatus()==3).collect(Collectors.toList());
+            boolean exists1 = existList.stream().anyMatch(yfDeviceDO->yfDeviceDO.getSerialNumber().equals(vo.getDeviceCode()));
+
+            IotDeviceRunLogDO logDO1 = new IotDeviceRunLogDO();
+            logDO1.setDeviceId(vo.getDeviceId());
+            LocalTime local = LocalTime.of(12, 0);
+            logDO1.setCreateTime(LocalDateTime.of(vo.getCreateTime(),local));
+
+            if(exists1){
+                for (IotModelTemplateAttrsDO attrsDO:list) {
+
+                    DeviceVO dv= new DeviceVO();
+                    dv.setDeviceName(vo.getDeviceCode().toLowerCase());
+                    dv.setColName(attrsDO.getModelAttr());
+                    dv.setTs(startTime);
+                    dv.setTs1(endTime);
+
+                    DeviceVO deviceVO = iDeviceService.getYesInfo(dv);
+
+                    if(!StringUtils.isEmpty(deviceVO) && !deviceVO.getEarliestData().equals("0.0")){
+                        attrsDO.setFillContent(
+                                String.valueOf(Double.parseDouble(deviceVO.getLatestData())-Double.parseDouble(deviceVO.getEarliestData())));
+                        attrsDO.setTotalRunTime(BigDecimal.valueOf(Double.parseDouble(deviceVO.getLatestData())));
+                        /**
+                         * 设置为数采
+                         */
+                        attrsDO.setIsCollection(1);
+                    }else{
+                        logDO1.setPointName(attrsDO.getName());
+                        IotDeviceRunLogDO logInfo = iotOpeationFillService.getLogInfo(logDO1);
+                        IotDeviceRunLogDO maxLog = iotOpeationFillService.getMaxFillInfo(logDO1);
+                        if(!StringUtils.isEmpty(logInfo)){
+
+                            attrsDO.setFillContent(logInfo.getFillContent());
+
+                            if(StringUtils.isEmpty(maxLog)){
+                                attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
+                            }else{
+                                attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
+                            }
+                            /**
+                             * 设置为非数采
+                             */
+                            attrsDO.setIsCollection(0);
+
+
+                        }else{
+                            attrsDO.setFillContent("");
+                            if(StringUtils.isEmpty(maxLog)){
+                                attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
+                            }else{
+                                attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
+                            }
+                            /**
+                             * 设置为非数采
+                             */
+                            attrsDO.setIsCollection(0);
+                        }
+                    }
+                }
+            }else{
+
+                for (IotModelTemplateAttrsDO attrsDO:list) {
                     logDO1.setPointName(attrsDO.getName());
                     IotDeviceRunLogDO logInfo = iotOpeationFillService.getLogInfo(logDO1);
                     IotDeviceRunLogDO maxLog = iotOpeationFillService.getMaxFillInfo(logDO1);
                     if(!StringUtils.isEmpty(logInfo)){
 
                         attrsDO.setFillContent(logInfo.getFillContent());
+                        attrsDO.setTotalRunTime(logInfo.getTotalRunTime());
 
-                        if(StringUtils.isEmpty(maxLog)){
-                            attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
-                        }else{
-                            attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
-                        }
                         /**
                          * 设置为非数采
                          */
@@ -431,52 +623,23 @@ public class IotOpeationFillController {
                         }else{
                             attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
                         }
+
                         /**
                          * 设置为非数采
                          */
                         attrsDO.setIsCollection(0);
-                    }
-                }
-            }
-        }else{
 
-            for (IotModelTemplateAttrsDO attrsDO:list) {
-                logDO1.setPointName(attrsDO.getName());
-                IotDeviceRunLogDO logInfo = iotOpeationFillService.getLogInfo(logDO1);
-                IotDeviceRunLogDO maxLog = iotOpeationFillService.getMaxFillInfo(logDO1);
-                if(!StringUtils.isEmpty(logInfo)){
-
-                    attrsDO.setFillContent(logInfo.getFillContent());
-                    attrsDO.setTotalRunTime(logInfo.getTotalRunTime());
-
-                    /**
-                     * 设置为非数采
-                     */
-                    attrsDO.setIsCollection(0);
-
-
-                }else{
-                    attrsDO.setFillContent("");
-                    if(StringUtils.isEmpty(maxLog)){
-                        attrsDO.setTotalRunTime(BigDecimal.valueOf(0));
-                    }else{
-                        attrsDO.setTotalRunTime(maxLog.getTotalRunTime());
                     }
 
-                    /**
-                     * 设置为非数采
-                     */
-                    attrsDO.setIsCollection(0);
-
                 }
 
-           }
+            }
+
 
-        }
 
 
-        List<IotModelTemplateAttrsDO1> resut = new ArrayList<>();
 
+        }
         List<IotModelTemplateAttrsDO> sumList = list.stream().filter(e->e.getIsSum()==1).collect(Collectors.toList());
         List<IotModelTemplateAttrsDO> nonSumList = list.stream().filter(e->e.getIsSum()==0).collect(Collectors.toList());
 
@@ -487,9 +650,23 @@ public class IotOpeationFillController {
 
         resut.add(sum);
 
+
         return success(BeanUtils.toBean(resut,IotModelTemplateAttrsDO1.class));
     }
 
+    // 工具方法:将字符串转换为整数,空字符串视为0
+    private double safeParseInt(String str) {
+        if (str == null || str.trim().isEmpty()) {
+            return 0;
+        }
+        try {
+            return Integer.parseInt(str);
+        } catch (NumberFormatException e) {
+            // 如果字符串不是有效的整数格式,也返回0或根据实际需求处理
+            return 0;
+        }
+    }
+
     @GetMapping("/getDeivceFillInfo")
     @PermitAll
     @Operation(summary = "获得PMS 功能优化 设备模板属性")
@@ -512,4 +689,5 @@ public class IotOpeationFillController {
                         BeanUtils.toBean(list, IotOpeationFillRespVO.class));
     }
 
+
 }

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOpeationFillPageReqVO.java

@@ -77,6 +77,6 @@ public class IotOpeationFillPageReqVO extends PageParam {
     private Integer orderStatus;
     private Integer userId;
     private String userName;
-
+    private int isReport;
     private List<Long> deptIds;
 }

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOpeationFillRespVO.java

@@ -88,4 +88,5 @@ public class IotOpeationFillRespVO {
     private Long orderId;
 
     private Integer deviceId;
+    private int isReport;
 }

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotopeationfill/vo/IotOpeationFillSaveReqVO.java

@@ -90,4 +90,5 @@ public class IotOpeationFillSaveReqVO {
     private Long sumId;
 
     private String reason;
+    private int isReport;
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotoperationplan/vo/IotOperationPlanPageReqVO.java

@@ -58,4 +58,6 @@ public class IotOperationPlanPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] beginCreateTime;
 
+    private int isReport;
+
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotoperationplan/vo/IotOperationPlanRespVO.java

@@ -72,4 +72,6 @@ public class IotOperationPlanRespVO {
     private String createName;
     private String deptName;
 
+    private int isReport;
+
 }

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotoperationplan/vo/IotOperationPlanSaveReqVO.java

@@ -59,4 +59,6 @@ public class IotOperationPlanSaveReqVO {
 
     List<IotOperationPlanDevDO> planDevList;
 
+    private int isReport;
+
 }

+ 23 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotprojecttask/IotProjectTaskController.java

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
@@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojectinfo.IotProjectInfoD
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
 import cn.iocoder.yudao.module.pms.service.iotprojectinfo.IotProjectInfoService;
 import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
+import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -101,7 +103,8 @@ public class IotProjectTaskController {
     public CommonResult<PageResult<IotProjectTaskRespVO>> getTaskList( IotProjectTaskPageReqVO pageReqVO) {
         Set<Long> idList = new HashSet<>();
         PageResult<IotProjectTaskDO> taskList = iotProjectTaskService.taskList(pageReqVO,idList);
-        // return success(BeanUtils.toBean(taskList, IotProjectTaskRespVO.class));
+        // 设置每个任务的施工队伍
+
         return success(new PageResult<>(buildProjectTaskList(taskList.getList()), taskList.getTotal()));
     }
 
@@ -111,6 +114,15 @@ public class IotProjectTaskController {
         }
         // 设备部门信息
         List<Long> projectIds = convertList(tasks, IotProjectTaskDO::getProjectId);
+        // 查询当前分页任务的关联 施工队伍信息
+        Set<Long> deptIds = new HashSet<>();
+        tasks.forEach(task -> {
+            if (CollUtil.isNotEmpty(task.getDeptIds())) {
+                deptIds.addAll(task.getDeptIds());
+            }
+        });
+        // 查询当前分布任务关联的施工队伍信息
+        Map<Long, DeptDO> deptMap = deptService.getDeptMap(deptIds);
         Map<Long, Long> projectDeptPair = new HashMap<>();
         if (CollUtil.isNotEmpty(projectIds)) {
             // 查询 任务 关联的项目信息
@@ -130,6 +142,16 @@ public class IotProjectTaskController {
             if (projectDeptPair.containsKey(taskVO.getProjectId())) {
                 taskVO.setProjectDeptId(projectDeptPair.get(taskVO.getProjectId()));
             }
+            // 设置施工队伍名称
+            if (CollUtil.isNotEmpty(taskVO.getDeptIds())) {
+                Set<String> deptNames = new HashSet<>();
+                taskVO.getDeptIds().forEach(deptId -> {
+                    if (deptMap.containsKey(deptId)) {
+                        deptNames.add(deptMap.get(deptId).getName());
+                    }
+                });
+                taskVO.setDeptNames(StrUtil.join(StrUtil.COMMA, deptNames));
+            }
         });
     }
 

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotprojecttask/vo/IotProjectTaskRespVO.java

@@ -104,4 +104,7 @@ public class IotProjectTaskRespVO {
 
     @Schema(description = "任务扩展属性", example = "[{\"a\": 1},{\"b\": 2}]")
     private List<IotTaskAttrModelProperty> extProperty;
+
+    @Schema(description = "施工队伍", example = "THA1,THA2")
+    private String deptNames;
 }

+ 27 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/IotRhDailyReportController.java

@@ -34,6 +34,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -89,14 +90,28 @@ public class IotRhDailyReportController {
     @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:query')")
     public CommonResult<IotRhDailyReportRespVO> getIotRhDailyReport(@RequestParam("id") Long id) {
         IotRhDailyReportDO iotRhDailyReport = iotRhDailyReportService.getIotRhDailyReport(id);
-        return success(BeanUtils.toBean(iotRhDailyReport, IotRhDailyReportRespVO.class));
+        // 查询当前日报关联的 部门下 增压机 的产能
+        BigDecimal capacity = iotRhDailyReportService.queryCapacity(iotRhDailyReport.getDeptId());
+        IotRhDailyReportRespVO result = BeanUtils.toBean(iotRhDailyReport, IotRhDailyReportRespVO.class);
+        result.setCapacity(capacity);
+        return success(result);
     }
 
     @GetMapping("/page")
     @Operation(summary = "获得瑞恒日报分页")
     @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:query')")
     public CommonResult<PageResult<IotRhDailyReportRespVO>> getIotRhDailyReportPage(@Valid IotRhDailyReportPageReqVO pageReqVO) {
+        // 根据查询参数筛选出 符合条件 的记录id 再传入 颁布查询
         PageResult<IotRhDailyReportDO> pageResult = iotRhDailyReportService.getIotRhDailyReportPage(pageReqVO);
+        return success(new PageResult<>(buildRhDailyReports(pageResult.getList()), pageResult.getTotal()));
+    }
+
+    @GetMapping("/dailyReportSummary")
+    @Operation(summary = "瑞恒日报汇总")
+    @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:query')")
+    public CommonResult<PageResult<IotRhDailyReportRespVO>> dailyReportSummary(@Valid IotRhDailyReportPageReqVO pageReqVO) {
+        // 根据查询参数筛选出 符合条件 的记录id 再传入 颁布查询
+        PageResult<IotRhDailyReportDO> pageResult = iotRhDailyReportService.dailyReportSummary(pageReqVO);
 
         // List<IotRhDailyReportRespVO> rhDailyReports = IotRhDailyReportConvert.INSTANCE.convertList(pageResult.getList(), deptMap);
         return success(new PageResult<>(buildRhDailyReports(pageResult.getList()), pageResult.getTotal()));
@@ -129,6 +144,8 @@ public class IotRhDailyReportController {
         Map<Long, String> taskPair = new HashMap<>();
         // key任务id   value设计注气量
         Map<Long, String> taskExtPropertyPair = new HashMap<>();
+        // 搬迁安装天数
+        Map<Long, BigDecimal> relocationDaysPair = new HashMap<>();
         DataPermissionUtils.executeIgnore(() -> {
             // 查询日报关联的项目信息
             IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
@@ -159,8 +176,14 @@ public class IotRhDailyReportController {
                     }
                 });
             }
-            // 查询任务中维护的 设计注气量
+            // 查询每个任务的搬迁安装天数
+            List<IotRhDailyReportDO> relocationDays = iotRhDailyReportService.relocationDays(null);
 
+            if (CollUtil.isNotEmpty(relocationDays)) {
+                relocationDays.forEach(day -> {
+                    relocationDaysPair.put(day.getTaskId(), day.getRelocationDays());
+                });
+            }
         });
         // 2. 拼接数据
         return BeanUtils.toBean(reports, IotRhDailyReportRespVO.class, (reportVO) -> {
@@ -172,6 +195,8 @@ public class IotRhDailyReportController {
             findAndThen(taskPair, reportVO.getTaskId(), taskName -> reportVO.setTaskName(taskName));
             // 2.4 设计注气量
             findAndThen(taskExtPropertyPair, reportVO.getTaskId(), designInjection -> reportVO.setDesignInjection(designInjection));
+            // 2.5 搬迁安装天数
+            findAndThen(relocationDaysPair, reportVO.getTaskId(), relocationDays -> reportVO.setRelocationDays(relocationDays));
         });
     }
 

+ 8 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportPageReqVO.java

@@ -112,4 +112,12 @@ public class IotRhDailyReportPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    /**
+     * 扩展字段
+     */
+    @Schema(description = "项目/合同名称", example = "测试")
+    private String contractName;
+
+    @Schema(description = "任务标识", example = "#33 - 一厂")
+    private String taskName;
 }

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportRespVO.java

@@ -148,4 +148,7 @@ public class IotRhDailyReportRespVO {
     @Schema(description = "设计注气量")
     private String designInjection;
 
+    @Schema(description = "产能")
+    private BigDecimal capacity;
+
 }

+ 5 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrhdailyreport/vo/IotRhDailyReportSaveReqVO.java

@@ -97,4 +97,9 @@ public class IotRhDailyReportSaveReqVO {
     @Schema(description = "审批状态 未提交、审批中、审批通过、审批不通过、已取消", example = "1")
     private Integer auditStatus;
 
+    /**
+     * 扩展字段
+     */
+    @Schema(description = "运行记录工单创建日期")
+    private LocalDateTime fillOrderCreateTime;
 }

+ 93 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/IotRyDailyReportController.java

@@ -0,0 +1,93 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
+import cn.iocoder.yudao.module.pms.service.iotrydailyreport.IotRyDailyReportService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Tag(name = "管理后台 - 瑞鹰日报")
+@RestController
+@RequestMapping("/pms/iot-ry-daily-report")
+@Validated
+public class IotRyDailyReportController {
+
+    @Resource
+    private IotRyDailyReportService iotRyDailyReportService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建瑞鹰日报")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:create')")
+    public CommonResult<Long> createIotRyDailyReport(@Valid @RequestBody IotRyDailyReportSaveReqVO createReqVO) {
+        return success(iotRyDailyReportService.createIotRyDailyReport(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新瑞鹰日报")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:update')")
+    public CommonResult<Boolean> updateIotRyDailyReport(@Valid @RequestBody IotRyDailyReportSaveReqVO updateReqVO) {
+        iotRyDailyReportService.updateIotRyDailyReport(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除瑞鹰日报")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:delete')")
+    public CommonResult<Boolean> deleteIotRyDailyReport(@RequestParam("id") Long id) {
+        iotRyDailyReportService.deleteIotRyDailyReport(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得瑞鹰日报")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:query')")
+    public CommonResult<IotRyDailyReportRespVO> getIotRyDailyReport(@RequestParam("id") Long id) {
+        IotRyDailyReportDO iotRyDailyReport = iotRyDailyReportService.getIotRyDailyReport(id);
+        return success(BeanUtils.toBean(iotRyDailyReport, IotRyDailyReportRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得瑞鹰日报分页")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:query')")
+    public CommonResult<PageResult<IotRyDailyReportRespVO>> getIotRyDailyReportPage(@Valid IotRyDailyReportPageReqVO pageReqVO) {
+        PageResult<IotRyDailyReportDO> pageResult = iotRyDailyReportService.getIotRyDailyReportPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotRyDailyReportRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出瑞鹰日报 Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-ry-daily-report:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotRyDailyReportExcel(@Valid IotRyDailyReportPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotRyDailyReportDO> list = iotRyDailyReportService.getIotRyDailyReportPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "瑞鹰日报.xls", "数据", IotRyDailyReportRespVO.class,
+                        BeanUtils.toBean(list, IotRyDailyReportRespVO.class));
+    }
+
+}

+ 128 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportPageReqVO.java

@@ -0,0 +1,128 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 瑞鹰日报分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotRyDailyReportPageReqVO extends PageParam {
+
+    @Schema(description = "施工队伍id", example = "29285")
+    private Long deptId;
+
+    @Schema(description = "项目id", example = "23929")
+    private Long projectId;
+
+    @Schema(description = "任务id", example = "1515")
+    private Long taskId;
+
+    @Schema(description = "项目类别(钻井 修井 注氮 酸化压裂... )")
+    private String projectClassification;
+
+    @Schema(description = "搬迁安装天数(D)")
+    private BigDecimal relocationDays;
+
+    @Schema(description = "上井次完井时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] lastestWellDoneTime;
+
+    @Schema(description = "当前井深(m)")
+    private BigDecimal currentDepth;
+
+    @Schema(description = "日进尺(m)")
+    private BigDecimal dailyFootage;
+
+    @Schema(description = "月进尺(m)")
+    private BigDecimal monthlyFootage;
+
+    @Schema(description = "年累计进尺(m)")
+    private BigDecimal annualFootage;
+
+    @Schema(description = "当日用电量(kWh)")
+    private BigDecimal dailyPowerUsage;
+
+    @Schema(description = "当月用电量(kWh)")
+    private BigDecimal monthlyPowerUsage;
+
+    @Schema(description = "当日油耗(吨)")
+    private BigDecimal dailyFuel;
+
+    @Schema(description = "当月油耗(吨)")
+    private BigDecimal monthlyFuel;
+
+    @Schema(description = "非生产时间(H)")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private BigDecimal[] nonProductionTime;
+
+    @Schema(description = "非生产时间原因", example = "不香")
+    private String nptReason;
+
+    @Schema(description = "施工开始日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] constructionStartDate;
+
+    @Schema(description = "施工结束日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] constructionEndDate;
+
+    @Schema(description = "当日生产情况生产动态", example = "1")
+    private String productionStatus;
+
+    @Schema(description = "下步工作计划")
+    private String nextPlan;
+
+    @Schema(description = "施工状态(动迁 准备 施工 完工)", example = "1")
+    private Integer rigStatus;
+
+    @Schema(description = "人员情况")
+    private String personnel;
+
+    @Schema(description = "泥浆性能-密度(g/cm³)")
+    private BigDecimal mudDensity;
+
+    @Schema(description = "泥浆性能-粘度(S)")
+    private BigDecimal mudViscosity;
+
+    @Schema(description = "水平段长度(m) 适用于水平井")
+    private BigDecimal lateralLength;
+
+    @Schema(description = "井斜(°)")
+    private BigDecimal wellInclination;
+
+    @Schema(description = "方位(°)")
+    private BigDecimal azimuth;
+
+    @Schema(description = "不同专业公司的扩展属性值")
+    private String extProperty;
+
+    @Schema(description = "排序值")
+    private Integer sort;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+    @Schema(description = "状态(0启用 1禁用)", example = "2")
+    private Integer status;
+
+    @Schema(description = "流程实例id", example = "7723")
+    private String processInstanceId;
+
+    @Schema(description = "审批状态 未提交、审批中、审批通过、审批不通过、已取消", example = "2")
+    private Integer auditStatus;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 156 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportRespVO.java

@@ -0,0 +1,156 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 瑞鹰日报 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotRyDailyReportRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "25152")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "施工队伍id", example = "29285")
+    @ExcelProperty("施工队伍id")
+    private Long deptId;
+
+    @Schema(description = "项目id", example = "23929")
+    @ExcelProperty("项目id")
+    private Long projectId;
+
+    @Schema(description = "任务id", example = "1515")
+    @ExcelProperty("任务id")
+    private Long taskId;
+
+    @Schema(description = "项目类别(钻井 修井 注氮 酸化压裂... )")
+    @ExcelProperty("项目类别(钻井 修井 注氮 酸化压裂... )")
+    private String projectClassification;
+
+    @Schema(description = "搬迁安装天数(D)")
+    @ExcelProperty("搬迁安装天数(D)")
+    private BigDecimal relocationDays;
+
+    @Schema(description = "上井次完井时间")
+    @ExcelProperty("上井次完井时间")
+    private LocalDateTime lastestWellDoneTime;
+
+    @Schema(description = "当前井深(m)")
+    @ExcelProperty("当前井深(m)")
+    private BigDecimal currentDepth;
+
+    @Schema(description = "日进尺(m)")
+    @ExcelProperty("日进尺(m)")
+    private BigDecimal dailyFootage;
+
+    @Schema(description = "月进尺(m)")
+    @ExcelProperty("月进尺(m)")
+    private BigDecimal monthlyFootage;
+
+    @Schema(description = "年累计进尺(m)")
+    @ExcelProperty("年累计进尺(m)")
+    private BigDecimal annualFootage;
+
+    @Schema(description = "当日用电量(kWh)")
+    @ExcelProperty("当日用电量(kWh)")
+    private BigDecimal dailyPowerUsage;
+
+    @Schema(description = "当月用电量(kWh)")
+    @ExcelProperty("当月用电量(kWh)")
+    private BigDecimal monthlyPowerUsage;
+
+    @Schema(description = "当日油耗(吨)")
+    @ExcelProperty("当日油耗(吨)")
+    private BigDecimal dailyFuel;
+
+    @Schema(description = "当月油耗(吨)")
+    @ExcelProperty("当月油耗(吨)")
+    private BigDecimal monthlyFuel;
+
+    @Schema(description = "非生产时间(H)")
+    @ExcelProperty("非生产时间(H)")
+    private BigDecimal nonProductionTime;
+
+    @Schema(description = "非生产时间原因", example = "不香")
+    @ExcelProperty("非生产时间原因")
+    private String nptReason;
+
+    @Schema(description = "施工开始日期")
+    @ExcelProperty("施工开始日期")
+    private LocalDateTime constructionStartDate;
+
+    @Schema(description = "施工结束日期")
+    @ExcelProperty("施工结束日期")
+    private LocalDateTime constructionEndDate;
+
+    @Schema(description = "当日生产情况生产动态", example = "1")
+    @ExcelProperty("当日生产情况生产动态")
+    private String productionStatus;
+
+    @Schema(description = "下步工作计划")
+    @ExcelProperty("下步工作计划")
+    private String nextPlan;
+
+    @Schema(description = "施工状态(动迁 准备 施工 完工)", example = "1")
+    @ExcelProperty("施工状态(动迁 准备 施工 完工)")
+    private Integer rigStatus;
+
+    @Schema(description = "人员情况")
+    @ExcelProperty("人员情况")
+    private String personnel;
+
+    @Schema(description = "泥浆性能-密度(g/cm³)")
+    @ExcelProperty("泥浆性能-密度(g/cm³)")
+    private BigDecimal mudDensity;
+
+    @Schema(description = "泥浆性能-粘度(S)")
+    @ExcelProperty("泥浆性能-粘度(S)")
+    private BigDecimal mudViscosity;
+
+    @Schema(description = "水平段长度(m) 适用于水平井")
+    @ExcelProperty("水平段长度(m) 适用于水平井")
+    private BigDecimal lateralLength;
+
+    @Schema(description = "井斜(°)")
+    @ExcelProperty("井斜(°)")
+    private BigDecimal wellInclination;
+
+    @Schema(description = "方位(°)")
+    @ExcelProperty("方位(°)")
+    private BigDecimal azimuth;
+
+    @Schema(description = "不同专业公司的扩展属性值")
+    @ExcelProperty("不同专业公司的扩展属性值")
+    private String extProperty;
+
+    @Schema(description = "排序值")
+    @ExcelProperty("排序值")
+    private Integer sort;
+
+    @Schema(description = "备注", example = "随便")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "状态(0启用 1禁用)", example = "2")
+    @ExcelProperty("状态(0启用 1禁用)")
+    private Integer status;
+
+    @Schema(description = "流程实例id", example = "7723")
+    @ExcelProperty("流程实例id")
+    private String processInstanceId;
+
+    @Schema(description = "审批状态 未提交、审批中、审批通过、审批不通过、已取消", example = "2")
+    @ExcelProperty("审批状态 未提交、审批中、审批通过、审批不通过、已取消")
+    private Integer auditStatus;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 115 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotrydailyreport/vo/IotRyDailyReportSaveReqVO.java

@@ -0,0 +1,115 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 瑞鹰日报新增/修改 Request VO")
+@Data
+public class IotRyDailyReportSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "25152")
+    private Long id;
+
+    @Schema(description = "施工队伍id", example = "29285")
+    private Long deptId;
+
+    @Schema(description = "项目id", example = "23929")
+    private Long projectId;
+
+    @Schema(description = "任务id", example = "1515")
+    private Long taskId;
+
+    @Schema(description = "项目类别(钻井 修井 注氮 酸化压裂... )")
+    private String projectClassification;
+
+    @Schema(description = "搬迁安装天数(D)")
+    private BigDecimal relocationDays;
+
+    @Schema(description = "上井次完井时间")
+    private LocalDateTime lastestWellDoneTime;
+
+    @Schema(description = "当前井深(m)")
+    private BigDecimal currentDepth;
+
+    @Schema(description = "日进尺(m)")
+    private BigDecimal dailyFootage;
+
+    @Schema(description = "月进尺(m)")
+    private BigDecimal monthlyFootage;
+
+    @Schema(description = "年累计进尺(m)")
+    private BigDecimal annualFootage;
+
+    @Schema(description = "当日用电量(kWh)")
+    private BigDecimal dailyPowerUsage;
+
+    @Schema(description = "当月用电量(kWh)")
+    private BigDecimal monthlyPowerUsage;
+
+    @Schema(description = "当日油耗(吨)")
+    private BigDecimal dailyFuel;
+
+    @Schema(description = "当月油耗(吨)")
+    private BigDecimal monthlyFuel;
+
+    @Schema(description = "非生产时间(H)")
+    private BigDecimal nonProductionTime;
+
+    @Schema(description = "非生产时间原因", example = "不香")
+    private String nptReason;
+
+    @Schema(description = "施工开始日期")
+    private LocalDateTime constructionStartDate;
+
+    @Schema(description = "施工结束日期")
+    private LocalDateTime constructionEndDate;
+
+    @Schema(description = "当日生产情况生产动态", example = "1")
+    private String productionStatus;
+
+    @Schema(description = "下步工作计划")
+    private String nextPlan;
+
+    @Schema(description = "施工状态(动迁 准备 施工 完工)", example = "1")
+    private Integer rigStatus;
+
+    @Schema(description = "人员情况")
+    private String personnel;
+
+    @Schema(description = "泥浆性能-密度(g/cm³)")
+    private BigDecimal mudDensity;
+
+    @Schema(description = "泥浆性能-粘度(S)")
+    private BigDecimal mudViscosity;
+
+    @Schema(description = "水平段长度(m) 适用于水平井")
+    private BigDecimal lateralLength;
+
+    @Schema(description = "井斜(°)")
+    private BigDecimal wellInclination;
+
+    @Schema(description = "方位(°)")
+    private BigDecimal azimuth;
+
+    @Schema(description = "不同专业公司的扩展属性值")
+    private String extProperty;
+
+    @Schema(description = "排序值")
+    private Integer sort;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+    @Schema(description = "状态(0启用 1禁用)", example = "2")
+    private Integer status;
+
+    @Schema(description = "流程实例id", example = "7723")
+    private String processInstanceId;
+
+    @Schema(description = "审批状态 未提交、审批中、审批通过、审批不通过、已取消", example = "2")
+    private Integer auditStatus;
+
+}

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotdevicerunlog/IotDeviceRunLogDO.java

@@ -95,4 +95,6 @@ public class IotDeviceRunLogDO extends BaseDO {
 
     private String fillContent;
 
+    private int isSum;
+
 }

+ 6 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotmodeltemplateattrs/IotModelTemplateAttrsDO.java

@@ -115,6 +115,12 @@ public class IotModelTemplateAttrsDO extends BaseDO {
      */
     private Long sumId;
 
+    /**
+     * 日报取值
+     * 1是0否
+     */
+    private int dailyReport;
+
 
 
 

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotoperationplan/IotOperationPlanDO.java

@@ -79,4 +79,6 @@ public class IotOperationPlanDO extends BaseDO {
      */
     private LocalDateTime beginCreateTime;
 
+    private int isReport;
+
 }

+ 165 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotrydailyreport/IotRyDailyReportDO.java

@@ -0,0 +1,165 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 瑞鹰日报 DO
+ *
+ * @author ruiqi
+ */
+@TableName("rq_iot_ry_daily_report")
+@KeySequence("rq_iot_ry_daily_report_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotRyDailyReportDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 施工队伍id
+     */
+    private Long deptId;
+    /**
+     * 项目id
+     */
+    private Long projectId;
+    /**
+     * 任务id
+     */
+    private Long taskId;
+    /**
+     * 项目类别(钻井 修井 注氮 酸化压裂... )
+     */
+    private String projectClassification;
+    /**
+     * 搬迁安装天数(D)
+     */
+    private BigDecimal relocationDays;
+    /**
+     * 上井次完井时间
+     */
+    private LocalDateTime lastestWellDoneTime;
+    /**
+     * 当前井深(m)
+     */
+    private BigDecimal currentDepth;
+    /**
+     * 日进尺(m)
+     */
+    private BigDecimal dailyFootage;
+    /**
+     * 月进尺(m)
+     */
+    private BigDecimal monthlyFootage;
+    /**
+     * 年累计进尺(m)
+     */
+    private BigDecimal annualFootage;
+    /**
+     * 当日用电量(kWh)
+     */
+    private BigDecimal dailyPowerUsage;
+    /**
+     * 当月用电量(kWh)
+     */
+    private BigDecimal monthlyPowerUsage;
+    /**
+     * 当日油耗(吨)
+     */
+    private BigDecimal dailyFuel;
+    /**
+     * 当月油耗(吨)
+     */
+    private BigDecimal monthlyFuel;
+    /**
+     * 非生产时间(H)
+     */
+    private BigDecimal nonProductionTime;
+    /**
+     * 非生产时间原因
+     */
+    private String nptReason;
+    /**
+     * 施工开始日期
+     */
+    private LocalDateTime constructionStartDate;
+    /**
+     * 施工结束日期
+     */
+    private LocalDateTime constructionEndDate;
+    /**
+     * 当日生产情况生产动态
+     */
+    private String productionStatus;
+    /**
+     * 下步工作计划
+     */
+    private String nextPlan;
+    /**
+     * 施工状态(动迁 准备 施工 完工)
+     */
+    private Integer rigStatus;
+    /**
+     * 人员情况
+     */
+    private String personnel;
+    /**
+     * 泥浆性能-密度(g/cm³)
+     */
+    private BigDecimal mudDensity;
+    /**
+     * 泥浆性能-粘度(S)
+     */
+    private BigDecimal mudViscosity;
+    /**
+     * 水平段长度(m) 适用于水平井
+     */
+    private BigDecimal lateralLength;
+    /**
+     * 井斜(°)
+     */
+    private BigDecimal wellInclination;
+    /**
+     * 方位(°)
+     */
+    private BigDecimal azimuth;
+    /**
+     * 不同专业公司的扩展属性值
+     */
+    private String extProperty;
+    /**
+     * 排序值
+     */
+    private Integer sort;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 状态(0启用 1禁用)
+     */
+    private Integer status;
+    /**
+     * 流程实例id
+     */
+    private String processInstanceId;
+    /**
+     * 审批状态 未提交、审批中、审批通过、审批不通过、已取消
+     */
+    private Integer auditStatus;
+
+}

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/IotDeviceMapper.java

@@ -80,6 +80,7 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
                 .inIfPresent(IotDeviceDO::getId, reqVO.getDeviceIds())
                 .likeIfPresent(IotDeviceDO::getDeviceCode, reqVO.getDeviceCode())
                 .likeIfPresent(IotDeviceDO::getDeviceName, reqVO.getDeviceName())
+                .eqIfPresent(IotDeviceDO::getDeptId, reqVO.getDeptId())
                 .eqIfPresent(IotDeviceDO::getBrand, reqVO.getBrand())
                 .eqIfPresent(IotDeviceDO::getModel, reqVO.getModel())
                 .eqIfPresent(IotDeviceDO::getDeviceStatus, reqVO.getDeviceStatus())

+ 19 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotdevicerunlog/IotDeviceRunLogMapper.java

@@ -83,19 +83,37 @@ public interface IotDeviceRunLogMapper extends BaseMapperX<IotDeviceRunLogDO> {
      * @param deviceIds 设备ID集合
      * @return fill_content字段数值总和
      */
-    @TenantIgnore
+    /* @TenantIgnore
     @Select("SELECT SUM(CAST(fill_content AS DECIMAL(15,3))) " +
             "FROM rq_iot_device_run_log " +
             "WHERE dept_id = #{deptId} " +
             "AND device_id IN (${deviceIds}) " +
             "AND point_name = '当日注气量' " +
             "AND create_time BETWEEN #{startOfYear} AND #{currentTime}")
+    BigDecimal selectCurrentYearFillContentSum(@Param("deptId") Long deptId,
+                                               @Param("deviceIds") Collection<Long> deviceIds,
+                                               @Param("startOfYear") LocalDateTime startOfYear,
+                                               @Param("currentTime") LocalDateTime currentTime); */
+
+    @TenantIgnore
+    @Select("<script>" +
+            "SELECT SUM(CAST(fill_content AS DECIMAL(15,3))) " +
+            "FROM rq_iot_device_run_log " +
+            "WHERE dept_id = #{deptId} " +
+            "AND device_id IN " +
+            "  <foreach item='id' collection='deviceIds' open='(' separator=',' close=')'>" +
+            "    #{id}" +
+            "  </foreach>" +
+            "AND point_name = '当日注气量' " +
+            "AND create_time BETWEEN #{startOfYear} AND #{currentTime}" +
+            "</script>")
     BigDecimal selectCurrentYearFillContentSum(@Param("deptId") Long deptId,
                                                @Param("deviceIds") Collection<Long> deviceIds,
                                                @Param("startOfYear") LocalDateTime startOfYear,
                                                @Param("currentTime") LocalDateTime currentTime);
 
     // 可以在Service层提供便捷方法
+    @TenantIgnore
     default BigDecimal selectCurrentYearFillContentSum(Long deptId, Collection<Long> deviceIds) {
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime startOfYear = LocalDate.of(Year.now().getValue(), 1, 1).atStartOfDay();

+ 40 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotopeationfill/IotOpeationFillMapper.java

@@ -92,6 +92,7 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
      * @param year   当前时间 年
      * @return 返回符合条件的瑞恒日报记录
      */
+    @TenantIgnore
     List<IotOpeationFillDO> selectReportsByYear(@Param("deptId")Long deptId, @Param("year")int year);
 
     @TenantIgnore
@@ -137,13 +138,28 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
     List<IotOpeationFillDO> flList(IotOpeationFillDO vo);
 
     @TenantIgnore
-    List<IotOpeationFillDO> pdList(@Param("deviceIds")List<Long> deviceIds);
+    List<IotOpeationFillDO> pdList(@Param("deviceIds")Collection<Long> deviceIds);
+
+    @TenantIgnore
+    List<IotOpeationFillDO> pdList2(@Param("deviceIds")Collection<Long> deviceIds);
+
+    @TenantIgnore
+    List<IotOpeationFillOrderDO> allOrder(@Param("localDateTime")LocalDateTime localDateTime,@Param("userNames")Collection<String> userNames);
+
+
     List<IotOpeationFillDO> deviceList(IotOpeationFillRespVO vo);
     @TenantIgnore
     PageResult<IotOpeationFillDO> fillList1(IotOpeationFillPageReqVO vo);
 
-
+    @TenantIgnore
     int insertLog(List<IotDeviceRunLogDO> logDO);
+    @TenantIgnore
+    int insertLog1(IotDeviceRunLogDO logDO);
+    @TenantIgnore
+    int updateLog(IotDeviceRunLogDO logDO);
+    @TenantIgnore
+    int updateSumLog(IotDeviceRunLogDO logDO);
+
     @TenantIgnore
     int updateFill(IotOpeationFillSaveReqVO vo);
     @TenantIgnore
@@ -200,5 +216,27 @@ public interface IotOpeationFillMapper extends BaseMapperX<IotOpeationFillDO> {
     @TenantIgnore
     IPage<IotDeviceCountData> deviceCountList(IPage<IotOpeationFillPageReqVO> page, @Param("deptId") Long deptId,
                                               @Param("createTime")LocalDateTime[] createTime,@Param("isFill") Integer isFill,@Param("orderName") String orderName);
+    List<IotOpeationFillOrderDO> childList(IotOpeationFillOrderDO fillDO);
+
+    @TenantIgnore
+    IotOpeationFillDO isReport(IotOpeationFillDO fillDO);
+
+    @TenantIgnore
+    IotOpeationFillDO orderDO(IotOpeationFillDO fillDO);
+
+    @TenantIgnore
+    List<IotOpeationFillDO> reportList(IotOpeationFillDO fillDO);
+
+    @TenantIgnore
+    List<IotOpeationFillDO> reportList1(IotOpeationFillDO fillDO);
+
+    @TenantIgnore
+    IotDeviceRunLogDO reportData(IotDeviceRunLogDO runLogDO);
+
+    @TenantIgnore
+    IotDeviceRunLogDO reportData1(IotDeviceRunLogDO runLogDO);
+
+    @TenantIgnore
+    IotDeviceRunLogDO getDesc(IotDeviceRunLogDO runLogDO);
 
 }

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotopeationfill/IotOpeationFillOrderMapper.java

@@ -36,7 +36,7 @@ public interface IotOpeationFillOrderMapper extends BaseMapperX<IotOpeationFillO
                 .orderByDesc(IotOpeationFillOrderDO::getId));
     }
     @TenantIgnore
-    default PageResult<IotOpeationFillOrderDO> selectPage1(IotOpeationFillPageReqVO reqVO,
+    default PageResult<IotOpeationFillOrderDO>  selectPage1(IotOpeationFillPageReqVO reqVO,
                                                            Collection<Long> deptIds,
                                                            Collection<Long> orderIds
                                                            ) {

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotoperationplan/IotOperationPlanMapper.java

@@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotoperationplan.IotOperationPlanDO;
 import org.apache.ibatis.annotations.Mapper;
 import cn.iocoder.yudao.module.pms.controller.admin.iotoperationplan.vo.*;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 运行记录计划 Mapper
@@ -37,5 +38,6 @@ public interface IotOperationPlanMapper extends BaseMapperX<IotOperationPlanDO>
 
     List<IotOperationPlanDO> getPlanList();
 
+    List<IotOperationPlanDO> getReportPlan(@Param("deviceIds")Collection<Long> deviceIds);
 
 }

+ 13 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrhdailyreport/IotRhDailyReportMapper.java

@@ -1,5 +1,7 @@
 package cn.iocoder.yudao.module.pms.dal.mysql.iotrhdailyreport;
 
+import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@@ -50,7 +52,7 @@ public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO>
                 .eqIfPresent(IotRhDailyReportDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                 .eqIfPresent(IotRhDailyReportDO::getAuditStatus, reqVO.getAuditStatus())
                 .betweenIfPresent(IotRhDailyReportDO::getCreateTime, reqVO.getCreateTime())
-                .orderByDesc(IotRhDailyReportDO::getId));
+                .orderByDesc(IotRhDailyReportDO::getCreateTime));
     }
 
     /* default List<IotRhDailyReportDO> selectList(IotRhDailyReportPageReqVO reqVO) {
@@ -88,6 +90,13 @@ public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO>
     // 修改selectList方法,使用XML实现
     List<IotRhDailyReportDO> selectListGrouped(@Param("reqVO") IotRhDailyReportPageReqVO reqVO);
 
+    /**
+     * 查询每个任务的搬迁安装天数
+     * @param reqVO
+     * @return
+     */
+    List<IotRhDailyReportDO> relocationDays(@Param("reqVO") IotRhDailyReportPageReqVO reqVO);
+
     /**
      * 根据条件查询瑞恒日报记录
      *
@@ -97,12 +106,13 @@ public interface IotRhDailyReportMapper extends BaseMapperX<IotRhDailyReportDO>
      * @return 返回符合条件的瑞恒日报记录
      */
     default IotRhDailyReportDO selectExistReport(Long deptId, Long taskId, LocalDateTime dateTime) {
-        String dateStr = dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        String dateStr = ObjUtil.isNotEmpty(dateTime) ? dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) : StrUtil.EMPTY;
         // 使用LambdaQueryWrapperX构建查询条件,根据传入的参数动态添加查询条件
         return selectOne(new LambdaQueryWrapperX<IotRhDailyReportDO>()
                 .eqIfPresent(IotRhDailyReportDO::getDeptId, deptId)
                 .eqIfPresent(IotRhDailyReportDO::getTaskId, taskId)
-                .apply("DATE(create_time) = {0}", dateStr));
+                .apply(StrUtil.isNotBlank(dateStr), "DATE(create_time) = {0}", dateStr)
+                .last("limit 1"));
     }
 
 }

+ 57 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotrydailyreport/IotRyDailyReportMapper.java

@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.iotrydailyreport;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 瑞鹰日报 Mapper
+ *
+ * @author ruiqi
+ */
+@Mapper
+public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO> {
+
+    default PageResult<IotRyDailyReportDO> selectPage(IotRyDailyReportPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotRyDailyReportDO>()
+                .eqIfPresent(IotRyDailyReportDO::getDeptId, reqVO.getDeptId())
+                .eqIfPresent(IotRyDailyReportDO::getProjectId, reqVO.getProjectId())
+                .eqIfPresent(IotRyDailyReportDO::getTaskId, reqVO.getTaskId())
+                .eqIfPresent(IotRyDailyReportDO::getProjectClassification, reqVO.getProjectClassification())
+                .eqIfPresent(IotRyDailyReportDO::getRelocationDays, reqVO.getRelocationDays())
+                .betweenIfPresent(IotRyDailyReportDO::getLastestWellDoneTime, reqVO.getLastestWellDoneTime())
+                .eqIfPresent(IotRyDailyReportDO::getCurrentDepth, reqVO.getCurrentDepth())
+                .eqIfPresent(IotRyDailyReportDO::getDailyFootage, reqVO.getDailyFootage())
+                .eqIfPresent(IotRyDailyReportDO::getMonthlyFootage, reqVO.getMonthlyFootage())
+                .eqIfPresent(IotRyDailyReportDO::getAnnualFootage, reqVO.getAnnualFootage())
+                .eqIfPresent(IotRyDailyReportDO::getDailyPowerUsage, reqVO.getDailyPowerUsage())
+                .eqIfPresent(IotRyDailyReportDO::getMonthlyPowerUsage, reqVO.getMonthlyPowerUsage())
+                .eqIfPresent(IotRyDailyReportDO::getDailyFuel, reqVO.getDailyFuel())
+                .eqIfPresent(IotRyDailyReportDO::getMonthlyFuel, reqVO.getMonthlyFuel())
+                .betweenIfPresent(IotRyDailyReportDO::getNonProductionTime, reqVO.getNonProductionTime())
+                .eqIfPresent(IotRyDailyReportDO::getNptReason, reqVO.getNptReason())
+                .betweenIfPresent(IotRyDailyReportDO::getConstructionStartDate, reqVO.getConstructionStartDate())
+                .betweenIfPresent(IotRyDailyReportDO::getConstructionEndDate, reqVO.getConstructionEndDate())
+                .eqIfPresent(IotRyDailyReportDO::getProductionStatus, reqVO.getProductionStatus())
+                .eqIfPresent(IotRyDailyReportDO::getNextPlan, reqVO.getNextPlan())
+                .eqIfPresent(IotRyDailyReportDO::getRigStatus, reqVO.getRigStatus())
+                .eqIfPresent(IotRyDailyReportDO::getPersonnel, reqVO.getPersonnel())
+                .eqIfPresent(IotRyDailyReportDO::getMudDensity, reqVO.getMudDensity())
+                .eqIfPresent(IotRyDailyReportDO::getMudViscosity, reqVO.getMudViscosity())
+                .eqIfPresent(IotRyDailyReportDO::getLateralLength, reqVO.getLateralLength())
+                .eqIfPresent(IotRyDailyReportDO::getWellInclination, reqVO.getWellInclination())
+                .eqIfPresent(IotRyDailyReportDO::getAzimuth, reqVO.getAzimuth())
+                .eqIfPresent(IotRyDailyReportDO::getExtProperty, reqVO.getExtProperty())
+                .eqIfPresent(IotRyDailyReportDO::getSort, reqVO.getSort())
+                .eqIfPresent(IotRyDailyReportDO::getRemark, reqVO.getRemark())
+                .eqIfPresent(IotRyDailyReportDO::getStatus, reqVO.getStatus())
+                .eqIfPresent(IotRyDailyReportDO::getProcessInstanceId, reqVO.getProcessInstanceId())
+                .eqIfPresent(IotRyDailyReportDO::getAuditStatus, reqVO.getAuditStatus())
+                .betweenIfPresent(IotRyDailyReportDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(IotRyDailyReportDO::getId));
+    }
+
+}

+ 174 - 25
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/IotOperationPlanJob.java

@@ -17,9 +17,11 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillOrde
 import cn.iocoder.yudao.module.pms.dal.mysql.iotoperationplan.IotOperationPlanMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotoperationplandev.IotOperationPlanDevMapper;
 import cn.iocoder.yudao.module.pms.message.PmsMessage;
+import cn.iocoder.yudao.module.pms.service.iotopeationfill.IotOpeationFillService;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
@@ -59,6 +61,8 @@ public class IotOperationPlanJob implements JobHandler {
     private IotOperationPlanDevMapper planDevMapper;
     @Resource
     private DeptService deptService;
+    @Resource
+    private IotOpeationFillService opeationFillService;
 
     /**
      * 1、查询开启状态运行计划
@@ -222,47 +226,192 @@ public class IotOperationPlanJob implements JobHandler {
                 .filter(obj -> idList.contains(obj.getUserId()))
                 .collect(Collectors.toList());
 
+        Set<Long> idList1 = new HashSet<>();
+        idList1 =  deptService.getChildDeptIdListFromCache(157L);
+        idList1.add(157L);
 
+        boolean containPlan = idList1.contains(plan.getDeptId());
 
-        iotOpeationFillOrderMapper.insertBatch(orderList1);
+        List<IotOpeationFillOrderDO> orderList2 = new ArrayList<>();
+        List<IotOperationPlanDO> rpList = new ArrayList<>();
 
+        Set<Long> pdeptList = new HashSet<>();
+        pdeptList =  deptService.getChildDeptIdListFromCache(plan.getDeptId());
+        pdeptList.add(plan.getDeptId());
 
-        //发送钉钉通知
-        pmsThreadPoolTaskExecutor.execute(()->{
-            try{
-                for (IotOpeationFillOrderDO order:orderList1) {
-                    pmsMessage.sendMessage(order.getId(), order.getOrderName(), PmsConstants.GENERATE_OPERATION, (long)order.getUserId(), order.getMobile());
+        //查询日报计划
+        rpList = planMapper.getReportPlan(pdeptList);
+        List<Long> rpdList = rpList.stream().map(IotOperationPlanDO::getDeptId).collect(Collectors.toList());
+
+        if(rpdList.size()>0){
+            orderList2 = orderList.stream().filter(e->rpdList.contains(e.getDeptId())).collect(Collectors.toList());
+        }
+
+
+
+        if(containPlan){
+
+
+
+            if(rpList.size()>0){
+
+                //有责任人,但设备不满足条件,而且属于瑞恒
+                List<IotOpeationFillDO> pdList2 = iotOpeationFillMapper.pdList2(pdeptList);
+                //有责任人,且满足条件,而且属于瑞恒
+
+                //判断是否与日报计划所属部门一致
+                pdList2 = pdList2.stream().filter(e->rpdList.contains(e.getDeptId())).collect(Collectors.toList());
+
+                if(pdList2.size()>0){
+                    orderList2 = new ArrayList<>();
+                    try{
+                        for (IotOpeationFillDO pd:pdList2) {
+
+                            IotOpeationFillOrderDO fillDO = new IotOpeationFillOrderDO();
+
+                            fillDO.setOrderName(pd.getOrgName()+"/"+LocalDate.now()+"运行记录填报");
+                            fillDO.setDeptId(pd.getDeptId());
+                            fillDO.setOrderStatus(0);
+                            fillDO.setCreateTime(LocalDateTime.now());
+                            fillDO.setUserName(pd.getUserName());
+                            fillDO.setUserId(pd.getUserId());
+                            fillDO.setMobile(pd.getMobile());
+                            orderList2.add(fillDO);
+
+                        }
+
+                        orderList1.addAll(orderList2);
+
+                    }catch (Exception e){
+                        e.printStackTrace();
+                    }
+                }else if(orderList2.size()>0){
+                    orderList1.addAll(orderList2);
                 }
-            }catch (Exception e){
-                e.printStackTrace();
-            }
-        });
 
+            }else{
+                List<IotOpeationFillDO> pdList2 = iotOpeationFillMapper.pdList2(pdeptList);
+
+                if(pdList2.size()>0){
+
+                    try{
+                        for (IotOpeationFillDO pd:pdList2) {
+
+                            IotOpeationFillOrderDO fillDO = new IotOpeationFillOrderDO();
+
+                            fillDO.setOrderName(pd.getOrgName()+"/"+LocalDate.now()+"运行记录填报");
+                            fillDO.setDeptId(pd.getDeptId());
+                            fillDO.setOrderStatus(0);
+                            fillDO.setCreateTime(LocalDateTime.now());
+                            fillDO.setUserName(pd.getUserName());
+                            fillDO.setUserId(pd.getUserId());
+                            fillDO.setMobile(pd.getMobile());
+                            orderList1.add(fillDO);
+                        }
 
-        for (IotOpeationFillDO device:deviceList) {
-            System.out.println("deviceUser"+device.getUserId());
-            for (IotOpeationFillOrderDO order:orderList1) {
-                System.out.println("orderId"+order.getUserId());
-                if(device.getUserId().intValue()==order.getUserId().intValue()){
-                    System.out.println("-----相等-------");
-                    device.setOrderId(order.getId());
+                    }catch (Exception e){
+                        e.printStackTrace();
+                    }
                 }
             }
         }
 
+        IotOpeationFillOrderDO todayTime = new IotOpeationFillOrderDO();
+        todayTime.setCreateTime(localDateTime);
 
-        System.out.println("***********创建运行记录填报工单执行结束*********8");
+        List<String> userList = orderList1.stream().map(IotOpeationFillOrderDO::getUserName).collect(Collectors.toList());
 
+        List<IotOpeationFillOrderDO> allOrder = iotOpeationFillMapper.allOrder(localDateTime,userList);
 
-        System.out.println("*****************插入运行记录设备表***********************");
+        if(allOrder.size()>0){
 
-        for (IotOpeationFillDO re:deviceList) {
-            re.setDeviceId(re.getId());
-        }
-        iotOpeationFillMapper.insertFill(deviceList);
+        }else{
 
+            iotOpeationFillOrderMapper.insertBatch(orderList1);
 
-        System.out.println("*****************插入运行记录设备表完成***********************");
-    }
 
+                 /* //发送钉钉通知
+            pmsThreadPoolTaskExecutor.execute(()->{
+                try{
+                    for (IotOpeationFillOrderDO order:orderList1) {
+                        pmsMessage.sendMessage(order.getId(), order.getOrderName(), PmsConstants.GENERATE_OPERATION, (long)order.getUserId(), order.getMobile());
+                    }
+                }catch (Exception e){
+                    e.printStackTrace();
+                }
+            });*/
+
+            for (IotOpeationFillDO device:deviceList) {
+                System.out.println("deviceUser"+device.getUserId());
+                for (IotOpeationFillOrderDO order:orderList1) {
+                    System.out.println("orderId"+order.getUserId());
+                    if(device.getUserId().intValue()==order.getUserId().intValue()){
+                        System.out.println("-----相等-------");
+                        device.setOrderId(order.getId());
+                    }
+                }
+            }
+
+
+            System.out.println("***********创建运行记录填报工单执行结束*********8");
+
+
+            System.out.println("*****************插入运行记录设备表***********************");
+
+            for (IotOpeationFillDO re:deviceList) {
+                re.setDeviceId(re.getId());
+                re.setIsReport(0);
+            }
+            iotOpeationFillMapper.insertFill(deviceList);
+
+
+
+
+            List<Long> oDeptList = new ArrayList<>();
+
+            if(rpList.size()>0){
+                oDeptList = orderList2.stream().map(IotOpeationFillOrderDO::getDeptId).collect(Collectors.toList());
+
+                // 先判断oDeptList是否为空,如果为空则根据业务需求设置exist的值
+                boolean exist;
+                if (oDeptList.isEmpty()) {
+                    // 当oDeptList为空时,这里可以根据实际场景设置默认值
+                    // 例如:空列表认为所有元素都被包含,设置为true
+                    exist = false;
+                    // 或者认为不满足,设置为false
+                    // exist = false;
+                } else {
+                    exist = idList1.containsAll(oDeptList);
+                }
+
+                if(exist){
+                    List <IotOpeationFillDO> devList = opeationFillService.reportMethod(orderList2);
+                    //插入虚拟设备
+                    iotOpeationFillMapper.insertFill(devList);
+                }
+
+
+            }else{
+                oDeptList = orderList1.stream().map(IotOpeationFillOrderDO::getDeptId).collect(Collectors.toList());
+
+                // 先判断oDeptList是否为空,如果为空则根据业务需求设置exist的值
+                boolean exist;
+                if (oDeptList.isEmpty()) {
+                    // 当oDeptList为空时,这里可以根据实际场景设置默认值
+                    // 例如:空列表认为所有元素都被包含,设置为true
+                    exist = false;
+                    // 或者认为不满足,设置为false
+                    // exist = false;
+                } else {
+                    exist = idList1.containsAll(oDeptList);
+                }
+
+                if(exist){
+                    List <IotOpeationFillDO> devList = opeationFillService.reportMethod(orderList1);
+                    //插入虚拟设备
+                    iotOpeationFillMapper.insertFill(devList);
+                }
+            }
+        }
+    }
 }

+ 27 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotopeationfill/IotOpeationFillService.java

@@ -98,6 +98,13 @@ public interface IotOpeationFillService {
 
     int insertLog(List<IotDeviceRunLogDO> logDO);
 
+
+    int insertLog1(IotDeviceRunLogDO logDO);
+
+    int updateLog(IotDeviceRunLogDO logDO);
+
+    int updateSumLog(IotDeviceRunLogDO logDO);
+
     /**
      * 更新填写状态
      * @param vo
@@ -150,4 +157,24 @@ public interface IotOpeationFillService {
 
     List<IotCountDataDO> countDeviceList(IotCountDataDO dataDO);
 
+    /**
+     * 日报执行方法
+     * @return
+     */
+    List<IotOpeationFillDO> reportMethod(List<IotOpeationFillOrderDO> orderList);
+
+    IotOpeationFillDO isReport(IotOpeationFillDO fillDO);
+
+    IotOpeationFillDO orderDO(IotOpeationFillDO fillDO);
+
+    List<IotOpeationFillDO> reportList(IotOpeationFillDO fillDO);
+
+    List<IotOpeationFillDO> reportList1(IotOpeationFillDO fillDO);
+
+    IotDeviceRunLogDO reportData(IotDeviceRunLogDO runLogDO);
+
+    IotDeviceRunLogDO reportData1(IotDeviceRunLogDO runLogDO);
+
+    IotDeviceRunLogDO getDesc(IotDeviceRunLogDO runLogDO);
+
 }

+ 83 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotopeationfill/IotOpeationFillServiceImpl.java

@@ -29,6 +29,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -50,6 +51,8 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
     @Resource
     private DeptService deptService;
 
+    private static Long RH_CLASS_ID = 226L;
+
     @Override
     public Long createIotOpeationFill(IotOpeationFillSaveReqVO createReqVO) {
         // 插入
@@ -200,6 +203,21 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
         return iotOpeationFillMapper.insertLog(logDO);
     }
 
+    @Override
+    public int insertLog1(IotDeviceRunLogDO logDO) {
+        return iotOpeationFillMapper.insertLog1(logDO);
+    }
+
+    @Override
+    public int updateLog(IotDeviceRunLogDO logDO) {
+        return iotOpeationFillMapper.updateLog(logDO);
+    }
+
+    @Override
+    public int updateSumLog(IotDeviceRunLogDO logDO) {
+        return iotOpeationFillMapper.updateSumLog(logDO);
+    }
+
     @Override
     public int updateFill(IotOpeationFillSaveReqVO vo) {
         return iotOpeationFillMapper.updateFill(vo);
@@ -302,4 +320,69 @@ public class IotOpeationFillServiceImpl implements IotOpeationFillService {
         return iotOpeationFillMapper.countDeviceList(dataDO);
     }
 
+    @Override
+    public List<IotOpeationFillDO> reportMethod(List<IotOpeationFillOrderDO> orderList) {
+        List<IotOpeationFillDO> devList = new ArrayList<>();
+        //判断工单主数据是否有值
+        if(orderList.size()>0){
+            //遍历工单主数据,根据dept_id查询是否为根节点
+            for (IotOpeationFillOrderDO orderDO:orderList) {
+                List<IotOpeationFillOrderDO> childList = iotOpeationFillMapper.childList(orderDO);
+
+                int randomNum = ThreadLocalRandom.current().nextInt(100000, 1000000);
+
+                //如果是根节点,则证明该部门为小队并且属于瑞恒,创建对应日报虚拟设备
+                if(childList.size()==0){
+                    IotOpeationFillDO devOrder = new IotOpeationFillDO();
+                    devOrder.setDeviceCode("");
+                    devOrder.setDeviceName("生产日报");
+                    devOrder.setDeviceCategoryId(RH_CLASS_ID);
+                    devOrder.setDeptId(orderDO.getDeptId());
+                    devOrder.setIsReport(1);
+                    devOrder.setOrderId(orderDO.getId());
+                    devOrder.setDeviceId((long) randomNum);
+                    devOrder.setCreateTime(orderDO.getCreateTime());
+                    devList.add(devOrder);
+                }
+            }
+        }
+
+        return devList;
+    }
+
+    @Override
+    public IotOpeationFillDO isReport(IotOpeationFillDO fillDO) {
+        return iotOpeationFillMapper.isReport(fillDO);
+    }
+
+    @Override
+    public IotOpeationFillDO orderDO(IotOpeationFillDO fillDO) {
+        return iotOpeationFillMapper.orderDO(fillDO);
+    }
+
+    @Override
+    public List<IotOpeationFillDO> reportList(IotOpeationFillDO fillDO) {
+        return iotOpeationFillMapper.reportList(fillDO);
+    }
+
+    @Override
+    public List<IotOpeationFillDO> reportList1(IotOpeationFillDO fillDO) {
+        return iotOpeationFillMapper.reportList1(fillDO);
+    }
+
+    @Override
+    public IotDeviceRunLogDO reportData(IotDeviceRunLogDO runLogDO) {
+        return iotOpeationFillMapper.reportData(runLogDO);
+    }
+
+    @Override
+    public IotDeviceRunLogDO reportData1(IotDeviceRunLogDO runLogDO) {
+        return iotOpeationFillMapper.reportData1(runLogDO);
+    }
+
+    @Override
+    public IotDeviceRunLogDO getDesc(IotDeviceRunLogDO runLogDO) {
+        return iotOpeationFillMapper.getDesc(runLogDO);
+    }
+
 }

+ 25 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportService.java

@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDai
 import cn.iocoder.yudao.module.pms.dal.dataobject.iotrhdailyreport.IotRhDailyReportDO;
 
 import javax.validation.Valid;
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -60,4 +61,28 @@ public interface IotRhDailyReportService {
      * @return 从日报中提取任务的实际进度
      */
     List<IotRhDailyReportDO> taskActualProgress(IotRhDailyReportPageReqVO reqVO);
+
+    /**
+     * 查询每个任务的搬迁安装天数
+     *
+     * @param reqVO taskId
+     * @return 每个任务的搬迁安装天数
+     */
+    List<IotRhDailyReportDO> relocationDays(IotRhDailyReportPageReqVO reqVO);
+
+    /**
+     * 查询指定队伍下包含的增压机的产能
+     *
+     * @param deptId
+     * @return 增压机 产能
+     */
+    BigDecimal queryCapacity(Long deptId);
+
+    /**
+     * 瑞恒日报汇总
+     *
+     * @param
+     * @return 增压机 产能
+     */
+    PageResult<IotRhDailyReportDO> dailyReportSummary(IotRhDailyReportPageReqVO pageReqVO);
 }

+ 186 - 141
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrhdailyreport/IotRhDailyReportServiceImpl.java

@@ -19,8 +19,10 @@ import cn.iocoder.yudao.module.pms.dal.mysql.iotdevicerunlog.IotDeviceRunLogMapp
 import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper;
 import cn.iocoder.yudao.module.pms.dal.mysql.iotrhdailyreport.IotRhDailyReportMapper;
-import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
+import cn.iocoder.yudao.module.pms.enums.common.FailureAuditStatusEnum;
+import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
+import cn.iocoder.yudao.module.system.service.dept.DeptService;
 import cn.iocoder.yudao.module.system.service.dict.DictDataService;
 import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
 import com.google.gson.Gson;
@@ -34,15 +36,11 @@ import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_PROJECT_TASK_NOT_EXISTS;
-import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_RH_DAILY_REPORT_NOT_EXISTS;
+import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.*;
 
 /**
  * 瑞恒日报 Service 实现类
@@ -67,166 +65,209 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
     private IotOpeationFillMapper iotOpeationFillMapper;
     @Resource
     private IotDeviceRunLogMapper iotDeviceRunLogMapper;
-
+    @Resource
+    private DeptService deptService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Long createIotRhDailyReport(IotRhDailyReportSaveReqVO createReqVO) {
         // 插入
         IotRhDailyReportDO iotRhDailyReport = BeanUtils.toBean(createReqVO, IotRhDailyReportDO.class);
+        LocalDateTime reportDate = createReqVO.getFillOrderCreateTime();
+        if (ObjUtil.isEmpty(reportDate)) {
+            throw exception(IOT_RH_DAILY_REPORT_NO_DATE);
+        }
+        if (ObjUtil.isEmpty(createReqVO.getDeptId())) {
+            throw exception(IOT_RH_DAILY_REPORT_NO_DEPT);
+        }
         // 根据日报的 施工队伍 deptId 查询队伍所在的 项目 任务
         // 根据日报的施工状态 更新 对应任务的 状态
-        if (ObjUtil.isNotEmpty(createReqVO.getDeptId())) {
-            Long taskId = Long.MIN_VALUE;
-            Set<Long> deviceIds = new HashSet<>();
-            IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
-            reqVO.setDeptId(createReqVO.getDeptId());
-            // 查询包含当前日报施工队伍的任务
-            List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(reqVO);
-            if (CollUtil.isNotEmpty(tasks)) {
-                IotProjectTaskDO task = tasks.get(0);
-                // 暂时只考虑1个施工队伍只属于1个任务
-                iotRhDailyReport.setProjectId(task.getProjectId());
-                iotRhDailyReport.setTaskId(task.getId());
-                taskId = task.getId();
-                // 根据日报状态 查询 日报所属任务的状态
-                if (ObjUtil.isNotEmpty(createReqVO.getConstructionStatus())) {
-                    task.setStatus(createReqVO.getConstructionStatus());
-                    // 更新任务状态
-                    iotProjectTaskMapper.updateById(task);
-                }
-                // 查询任务的设备列表
-                deviceIds = task.getDeviceIds();
+        Long taskId = Long.MIN_VALUE;
+        Set<Long> deviceIds = new HashSet<>();
+        IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
+        reqVO.setDeptId(createReqVO.getDeptId());
+        // 查询包含当前日报施工队伍的任务
+        List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(reqVO);
+        if (CollUtil.isNotEmpty(tasks)) {
+            IotProjectTaskDO task = tasks.get(0);
+            // 暂时只考虑1个施工队伍只属于1个任务
+            iotRhDailyReport.setProjectId(task.getProjectId());
+            iotRhDailyReport.setTaskId(task.getId());
+            taskId = task.getId();
+            // 根据日报状态 查询 日报所属任务的状态
+            if (ObjUtil.isNotEmpty(createReqVO.getConstructionStatus())) {
+                task.setStatus(createReqVO.getConstructionStatus());
+                // 更新任务状态
+                iotProjectTaskMapper.updateById(task);
             }
+            // 查询任务的设备列表
+            deviceIds = task.getDeviceIds();
+        } else {
+            // 当前队伍没有关联任务 不生成日报
+            throw exception(IOT_PROJECT_TASK_NOT_RELATED);
+        }
 
-            // 查询当前任务下关联的所有设备 查询这些设备的当日注气量 进而计算累计注气量
-            IotDevicePageReqVO deptDeviceReqVO = new IotDevicePageReqVO();
-            deptDeviceReqVO.setDeptId(createReqVO.getDeptId());
-            List<IotDeviceDO> deptDevices = iotDeviceMapper.selectList(deptDeviceReqVO);
-            Set<String> deviceCodes = new HashSet<>();
-            if (CollUtil.isNotEmpty(deptDevices)) {
-                deptDevices.forEach(device -> {
-                    deviceCodes.add(device.getDeviceCode());
+        // 查询当前任务下关联的所有设备 查询这些设备的当日注气量 进而计算累计注气量
+        IotDevicePageReqVO deptDeviceReqVO = new IotDevicePageReqVO();
+        deptDeviceReqVO.setDeptId(createReqVO.getDeptId());
+        List<IotDeviceDO> deptDevices = iotDeviceMapper.selectList(deptDeviceReqVO);
+        Set<String> deviceCodes = new HashSet<>();
+        if (CollUtil.isNotEmpty(deptDevices)) {
+            deptDevices.forEach(device -> {
+                deviceCodes.add(device.getDeviceCode());
+            });
+            // 查询当前小队在运行记录填报结果表中 生产日报虚拟设备id 查询当年的日报
+            // 然后根据 虚拟设备id 在 rq_iot_device_run_log 表中查询 日报中填写的 当日注气量
+            List<IotOpeationFillDO> reports = iotOpeationFillMapper.selectReportsByYear(createReqVO.getDeptId(), LocalDateTime.now().getYear());
+            Set<Long> reportDeviceIds = new HashSet<>();
+            if (CollUtil.isNotEmpty(reports)) {
+                reports.forEach(report -> {
+                    reportDeviceIds.add(report.getDeviceId());
                 });
-                // 查询当前小队在运行记录填报结果表中 生产日报虚拟设备id 查询当年的日报
-                // 然后根据 虚拟设备id 在 rq_iot_device_run_log 表中查询 日报中填写的 当日注气量
-                List<IotOpeationFillDO> reports = iotOpeationFillMapper.selectReportsByYear(createReqVO.getDeptId(), LocalDateTime.now().getYear());
-                Set<Long> reportDeviceIds = new HashSet<>();
-                if (CollUtil.isNotEmpty(reports)) {
-                    reports.forEach(report -> {
-                        reportDeviceIds.add(report.getDeviceId());
-                    });
-                    // 累计注气量
-                    BigDecimal currentYearFillContentSum = iotDeviceRunLogMapper.selectCurrentYearFillContentSum(createReqVO.getDeptId(), reportDeviceIds);
-                    iotRhDailyReport.setTotalGasInjection(currentYearFillContentSum);
-                }
+                // 累计注气量
+                BigDecimal currentYearFillContentSum = iotDeviceRunLogMapper.selectCurrentYearFillContentSum(createReqVO.getDeptId(), reportDeviceIds);
+                iotRhDailyReport.setTotalGasInjection(currentYearFillContentSum);
             }
+        }
 
-            // 找到当前小队下的 电驱增压机 分类下设备的产能 计算 运行时效
-            DictTypeDO dictType = dictTypeService.getDictType("rq_iot_charger_device_category");
-            AtomicReference<BigDecimal> capacity = new AtomicReference<>(BigDecimal.ZERO);
-            if (ObjUtil.isNotEmpty(dictType)) {
-                if (StrUtil.isNotBlank(dictType.getRemark())) {
-                    IotDevicePageReqVO capacityReqVO = new IotDevicePageReqVO();
-                    capacityReqVO.setDeptId(createReqVO.getDeptId());
-                    capacityReqVO.setAssetClass(Long.valueOf(dictType.getRemark()));
-                    List<IotDeviceDO> capacityDevices = iotDeviceMapper.selectList(capacityReqVO);
-                    if (CollUtil.isNotEmpty(capacityDevices)) {
-                        // 解析每个设备的 扩展属性 找出 已经设置 了产能的设备并提取值
-                        capacityDevices.forEach(device -> {
-                            if (StrUtil.isNotBlank(device.getTemplateJson())) {
-                                Gson gson = new Gson();
-                                Type listType = new TypeToken<List<IotDeviceProperty>>(){}.getType();
-                                List<IotDeviceProperty> deviceProperties = gson.fromJson(device.getTemplateJson(), listType);
-                                if (CollUtil.isNotEmpty(deviceProperties)) {
-                                    deviceProperties.forEach(property -> {
-                                        if ("产能".equals(property.getName()) && StrUtil.isNotBlank(property.getValue())) {
-                                            // 当前扩展属性已经维护了 产能 值
-                                            capacity.set(new BigDecimal(property.getValue()));
-                                        }
-                                    });
-                                }
+        BigDecimal capacity = queryCapacity(createReqVO.getDeptId());
+        // 计算运行时效 当日注气量/产能
+        if (ObjUtil.isNotEmpty(createReqVO.getDailyGasInjection()) && (capacity.compareTo(BigDecimal.ZERO)>0)) {
+            // 将当日注气量单位 换算成 万方
+            // 将当日注气量单位由"方"换算成"万方"
+            iotRhDailyReport.setTransitTime(createReqVO.getDailyGasInjection().divide(capacity, 4, RoundingMode.HALF_UP));
+        }
+
+        // 查询当前日报所属任务关联的设备 更新设备状态
+        /* if (CollUtil.isNotEmpty(deviceIds)) {
+            // 查询当前任务下关联的所有设备
+            IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
+            // deviceReqVO.setDeptId(createReqVO.getDeptId());
+            deviceReqVO.setDeviceIds(new ArrayList<>(deviceIds));
+            List<IotDeviceDO> devices = iotDeviceMapper.selectList(deviceReqVO);
+            if (CollUtil.isNotEmpty(devices)) {
+                AtomicReference<String> deviceNewStatus = new AtomicReference<>(StrUtil.EMPTY);
+                // 日报状态 与 设备状态 对应关系
+                // 动迁 施工 现场待命/驻地待命(待命) pms_device_status
+                List<DictDataDO> dictDatas = dictDataService.getDictDataListByDictType("constructionStatus");
+                AtomicReference<String> dailyDictLabel = new AtomicReference<>(StrUtil.EMPTY);
+                List<DictDataDO> deviceDictDatas = dictDataService.getDictDataListByDictType("pms_device_status");
+                if (CollUtil.isNotEmpty(dictDatas)) {
+                    dictDatas.forEach(data -> {
+                        if (createReqVO.getConstructionStatus().equals(Integer.valueOf(data.getValue()))) {
+                            dailyDictLabel.set(data.getLabel());
+                        }
+                    });
+                    if (CollUtil.isNotEmpty(deviceDictDatas)) {
+                        deviceDictDatas.forEach(data -> {
+                            if (dailyDictLabel.equals(data.getLabel())) {
+                                // 动迁 施工
+                                deviceNewStatus.set(data.getValue());
+                            }
+                            if (data.getLabel().contains(dailyDictLabel.get())) {
+                                // 现场待命/驻地待命(待命)
+                                deviceNewStatus.set(data.getValue());
                             }
                         });
-                        // 计算运行时效 当日注气量/产能
-                        if (ObjUtil.isNotEmpty(createReqVO.getDailyGasInjection()) && (capacity.get().compareTo(BigDecimal.ZERO)>0)) {
-                            // 将当日注气量单位 换算成 万方
-                            // 将当日注气量单位由"方"换算成"万方"
-                            /* BigDecimal dailyGasInjectionInTenThousand = createReqVO.getDailyGasInjection()
-                                    .divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP); */
-                            iotRhDailyReport.setTransitTime(createReqVO.getDailyGasInjection().divide(capacity.get(), 4, RoundingMode.HALF_UP));
-                        }
                     }
                 }
+                // 批量更新设备状态
+                devices.forEach(device -> {
+                    device.setDeviceStatus(deviceNewStatus.get());
+                });
+                iotDeviceMapper.updateBatch(devices);
             }
+        } */
 
-            // todo 根据当日注气量 计算累计注气量
+        // 当天如果已经有此小队的记录 新增 当天如果没有此小队的日报记录 修改
+        // deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录 不能使用 LocalDateTime.now() 来查询,应该使用 运行记录工单的创建日期查询
+        IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, reportDate);
+        if (ObjUtil.isEmpty(existReport)) {
+            // 今天下午4点
+            LocalDateTime today4pm = reportDate.withHour(16).withMinute(0).withSecond(0).withNano(0);
+            // 昨天下午4点
+            LocalDateTime yesterday4pm = today4pm.minusDays(1);
+            iotRhDailyReport.setConstructionStartDate(yesterday4pm);
+            iotRhDailyReport.setConstructionEndDate(today4pm);
+            iotRhDailyReport.setCreateTime(reportDate);
+            iotRhDailyReport.setUpdateTime(reportDate);
+            iotRhDailyReportMapper.insert(iotRhDailyReport);
+        } else {
+            // 修改现有记录
+            iotRhDailyReport.setId(existReport.getId());
+            iotRhDailyReportMapper.updateById(iotRhDailyReport);
+        }
+        // 返回
+        return iotRhDailyReport.getId();
+    }
 
-            // 查询当前日报所属任务关联的设备 更新设备状态
-            if (CollUtil.isNotEmpty(deviceIds)) {
-                // 查询当前任务下关联的所有设备
-                IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
-                // deviceReqVO.setDeptId(createReqVO.getDeptId());
-                deviceReqVO.setDeviceIds(new ArrayList<>(deviceIds));
-                List<IotDeviceDO> devices = iotDeviceMapper.selectList(deviceReqVO);
-                if (CollUtil.isNotEmpty(devices)) {
-                    AtomicReference<String> deviceNewStatus = new AtomicReference<>(StrUtil.EMPTY);
-                    // 日报状态 与 设备状态 对应关系
-                    // 动迁 施工 现场待命/驻地待命(待命) pms_device_status
-                    List<DictDataDO> dictDatas = dictDataService.getDictDataListByDictType("constructionStatus");
-                    AtomicReference<String> dailyDictLabel = new AtomicReference<>(StrUtil.EMPTY);
-                    List<DictDataDO> deviceDictDatas = dictDataService.getDictDataListByDictType("pms_device_status");
-                    if (CollUtil.isNotEmpty(dictDatas)) {
-                        dictDatas.forEach(data -> {
-                            if (createReqVO.getConstructionStatus().equals(Integer.valueOf(data.getValue()))) {
-                                dailyDictLabel.set(data.getLabel());
+    /***
+     * 计算指定队伍下包含的 增压机设备的产能
+     */
+    public BigDecimal queryCapacity(Long deptId) {
+        // 找到当前小队下的 电驱增压机 分类下设备的产能 计算 运行时效
+        DictTypeDO dictType = dictTypeService.getDictType("rq_iot_charger_device_category");
+        AtomicReference<BigDecimal> capacity = new AtomicReference<>(BigDecimal.ZERO);
+        if (ObjUtil.isNotEmpty(dictType)) {
+            if (StrUtil.isNotBlank(dictType.getRemark())) {
+                IotDevicePageReqVO capacityReqVO = new IotDevicePageReqVO();
+                capacityReqVO.setDeptId(deptId);
+                capacityReqVO.setAssetClass(Long.valueOf(dictType.getRemark()));
+                List<IotDeviceDO> capacityDevices = iotDeviceMapper.selectList(capacityReqVO);
+                if (CollUtil.isNotEmpty(capacityDevices)) {
+                    // 解析每个设备的 扩展属性 找出 已经设置 了产能的设备并提取值
+                    capacityDevices.forEach(device -> {
+                        if (StrUtil.isNotBlank(device.getTemplateJson())) {
+                            Gson gson = new Gson();
+                            Type listType = new TypeToken<List<IotDeviceProperty>>(){}.getType();
+                            List<IotDeviceProperty> deviceProperties = gson.fromJson(device.getTemplateJson(), listType);
+                            if (CollUtil.isNotEmpty(deviceProperties)) {
+                                deviceProperties.forEach(property -> {
+                                    if ("产能".equals(property.getName()) && StrUtil.isNotBlank(property.getValue())) {
+                                        // 当前扩展属性已经维护了 产能 值
+                                        capacity.set(new BigDecimal(property.getValue()));
+                                    }
+                                });
                             }
-                        });
-                        if (CollUtil.isNotEmpty(deviceDictDatas)) {
-                            deviceDictDatas.forEach(data -> {
-                                if (dailyDictLabel.equals(data.getLabel())) {
-                                    // 动迁 施工
-                                    deviceNewStatus.set(data.getValue());
-                                }
-                                if (data.getLabel().contains(dailyDictLabel.get())) {
-                                    // 现场待命/驻地待命(待命)
-                                    deviceNewStatus.set(data.getValue());
-                                }
-                            });
                         }
-                    }
-                    // 批量更新设备状态
-                    devices.forEach(device -> {
-                        device.setDeviceStatus(deviceNewStatus.get());
                     });
-                    iotDeviceMapper.updateBatch(devices);
                 }
             }
+        }
+        return capacity.get();
+    }
 
-            // 当天如果已经有此小队的记录 新增 当天如果没有此小队的日报记录 修改
-            // deptId - taskId - createTime(yyyy-MM-dd) 确定唯一一条记录
-            IotRhDailyReportDO existReport = iotRhDailyReportMapper.selectExistReport(createReqVO.getDeptId(), taskId, LocalDateTime.now());
-            if (ObjUtil.isEmpty(existReport)) {
-                // 设置任务时间范围 昨天下午4点到今天下午4点
-                // 设置任务时间范围 昨天下午4点到今天下午4点
-                LocalDateTime now = LocalDateTime.now();
-                // 今天下午4点
-                LocalDateTime today4pm = now.withHour(16).withMinute(0).withSecond(0).withNano(0);
-                // 昨天下午4点
-                LocalDateTime yesterday4pm = today4pm.minusDays(1);
-                iotRhDailyReport.setConstructionStartDate(yesterday4pm);
-                iotRhDailyReport.setConstructionEndDate(today4pm);
 
-                iotRhDailyReportMapper.insert(iotRhDailyReport);
-            } else {
-                // 修改现有记录
-                iotRhDailyReport.setId(existReport.getId());
-                iotRhDailyReportMapper.updateById(iotRhDailyReport);
+
+    @Override
+    public PageResult<IotRhDailyReportDO> dailyReportSummary(IotRhDailyReportPageReqVO pageReqVO) {
+        // 查询 瑞恒兴域 下所有项目部级别的部门
+        // 组装成 map key项目部id     value项目部下包含的部门集合
+        Set<Long> projectDeptIds = new HashSet<>();
+        Map<Long, Set<Long>> projectSubDeptPair = new HashMap<>();
+        Map<Long, String> deptMap = new HashMap<>();
+        Set<Long> rhChildDeptIds = deptService.getChildDeptIdListFromCache(157l);
+        List<DeptDO> depts =deptService.getDeptList(rhChildDeptIds);
+        // 找出名称中包含 项目部 的部门
+        if (CollUtil.isNotEmpty(depts)) {
+            depts.forEach(dept -> {
+                if (dept.getName().contains("项目部")) {
+                    projectDeptIds.add(dept.getId());
+                }
+                deptMap.put(dept.getId(), dept.getName());
+            });
+            // 查询每个项目部下所有子部门 小队
+            if (CollUtil.isNotEmpty(projectDeptIds)) {
+                projectDeptIds.forEach(deptId -> {
+                    Set<Long> tempDeptIds = deptService.getChildDeptIdListFromCache(deptId);
+                    tempDeptIds.add(deptId);
+                    projectSubDeptPair.put(deptId, tempDeptIds);
+                });
             }
-        }
+            // 查询所有瑞恒日报数据
 
-        // 返回
-        return iotRhDailyReport.getId();
+        }
+        return null;
     }
 
     @Override
@@ -235,6 +276,8 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         validateIotRhDailyReportExists(updateReqVO.getId());
         // 更新
         IotRhDailyReportDO updateObj = BeanUtils.toBean(updateReqVO, IotRhDailyReportDO.class);
+        // 编辑后 直接设置 已经 审核通过
+        updateObj.setAuditStatus(FailureAuditStatusEnum.APPROVE.getStatus());
         iotRhDailyReportMapper.updateById(updateObj);
     }
 
@@ -271,10 +314,12 @@ public class IotRhDailyReportServiceImpl implements IotRhDailyReportService {
         IotRhDailyReportPageReqVO reportReqVO = new IotRhDailyReportPageReqVO();
         reportReqVO.setTaskId(reqVO.getTaskId());
         List<IotRhDailyReportDO> dailyReports = iotRhDailyReportMapper.selectListGrouped(reportReqVO);
-        if (CollUtil.isNotEmpty(dailyReports)) {
-
-        }
         return dailyReports;
     }
 
+    @Override
+    public List<IotRhDailyReportDO> relocationDays(IotRhDailyReportPageReqVO reqVO) {
+        return iotRhDailyReportMapper.relocationDays(reqVO);
+    }
+
 }

+ 55 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrydailyreport/IotRyDailyReportService.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.pms.service.iotrydailyreport;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
+
+import javax.validation.Valid;
+
+/**
+ * 瑞鹰日报 Service 接口
+ *
+ * @author ruiqi
+ */
+public interface IotRyDailyReportService {
+
+    /**
+     * 创建瑞鹰日报
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotRyDailyReport(@Valid IotRyDailyReportSaveReqVO createReqVO);
+
+    /**
+     * 更新瑞鹰日报
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotRyDailyReport(@Valid IotRyDailyReportSaveReqVO updateReqVO);
+
+    /**
+     * 删除瑞鹰日报
+     *
+     * @param id 编号
+     */
+    void deleteIotRyDailyReport(Long id);
+
+    /**
+     * 获得瑞鹰日报
+     *
+     * @param id 编号
+     * @return 瑞鹰日报
+     */
+    IotRyDailyReportDO getIotRyDailyReport(Long id);
+
+    /**
+     * 获得瑞鹰日报分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 瑞鹰日报分页
+     */
+    PageResult<IotRyDailyReportDO> getIotRyDailyReportPage(IotRyDailyReportPageReqVO pageReqVO);
+
+}

+ 72 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotrydailyreport/IotRyDailyReportServiceImpl.java

@@ -0,0 +1,72 @@
+package cn.iocoder.yudao.module.pms.service.iotrydailyreport;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.iotrydailyreport.IotRyDailyReportMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_RY_DAILY_REPORT_NOT_EXISTS;
+
+
+/**
+ * 瑞鹰日报 Service 实现类
+ *
+ * @author ruiqi
+ */
+@Service
+@Validated
+public class IotRyDailyReportServiceImpl implements IotRyDailyReportService {
+
+    @Resource
+    private IotRyDailyReportMapper iotRyDailyReportMapper;
+
+    @Override
+    public Long createIotRyDailyReport(IotRyDailyReportSaveReqVO createReqVO) {
+        // 插入
+        IotRyDailyReportDO iotRyDailyReport = BeanUtils.toBean(createReqVO, IotRyDailyReportDO.class);
+        iotRyDailyReportMapper.insert(iotRyDailyReport);
+        // 返回
+        return iotRyDailyReport.getId();
+    }
+
+    @Override
+    public void updateIotRyDailyReport(IotRyDailyReportSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotRyDailyReportExists(updateReqVO.getId());
+        // 更新
+        IotRyDailyReportDO updateObj = BeanUtils.toBean(updateReqVO, IotRyDailyReportDO.class);
+        iotRyDailyReportMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotRyDailyReport(Long id) {
+        // 校验存在
+        validateIotRyDailyReportExists(id);
+        // 删除
+        iotRyDailyReportMapper.deleteById(id);
+    }
+
+    private void validateIotRyDailyReportExists(Long id) {
+        if (iotRyDailyReportMapper.selectById(id) == null) {
+            throw exception(IOT_RY_DAILY_REPORT_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public IotRyDailyReportDO getIotRyDailyReport(Long id) {
+        return iotRyDailyReportMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<IotRyDailyReportDO> getIotRyDailyReportPage(IotRyDailyReportPageReqVO pageReqVO) {
+        return iotRyDailyReportMapper.selectPage(pageReqVO);
+    }
+
+}

+ 262 - 6
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOpeationFillMapper.xml

@@ -135,7 +135,7 @@
         and
         a.device_category_id = g.id
         and
-        c.device_status in ('sg','dm')
+        c.device_status = 'sg'
         and
         a.deleted = 0
         and
@@ -155,11 +155,11 @@
 
     <insert id="insertFill"
     parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
-       insert into rq_iot_opeation_fill(device_id,device_code,device_name,device_category_id,create_time,dept_id,order_id)
+       insert into rq_iot_opeation_fill(device_id,device_code,device_name,device_category_id,create_time,dept_id,order_id,is_report)
            values
         <foreach collection="list" item="item" separator=",">
             (#{item.deviceId},#{item.deviceCode},#{item.deviceName},
-            #{item.deviceCategoryId},#{item.createTime},#{item.deptId},#{item.orderId})
+            #{item.deviceCategoryId},#{item.createTime},#{item.deptId},#{item.orderId},#{item.isReport})
         </foreach>
     </insert>
 
@@ -178,15 +178,52 @@
     <insert id="insertLog"
             parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
         insert into rq_iot_device_run_log
-            (dept_id,device_id,device_code,point_code,fill_content,create_time,point_name,total_run_time)
+            (dept_id,device_id,device_code,point_code,fill_content,create_time,point_name,total_run_time,is_sum)
         values
         <foreach collection="list" item="item" separator=",">
             (#{item.deptId},#{item.deviceId},#{item.deviceCode},
-            #{item.pointCode},#{item.fillContent},#{item.createTime},#{item.pointName},#{item.totalRunTime})
+            #{item.pointCode},#{item.fillContent},#{item.createTime},#{item.pointName},#{item.totalRunTime},#{item.isSum})
         </foreach>
 
     </insert>
 
+    <insert id="insertLog1"
+            parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
+        insert into rq_iot_device_run_log
+        (dept_id, device_id, device_code, point_code, fill_content, create_time, point_name, total_run_time,is_sum)
+        values
+        (#{deptId}, #{deviceId}, #{deviceCode},
+         #{pointCode}, #{fillContent}, #{createTime}, #{pointName}, #{totalRunTime},#{isSum})
+    </insert>
+
+    <update id="updateLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
+        update rq_iot_device_run_log
+        set
+        fill_content = #{fillContent}
+        where
+            device_code = #{deviceCode}
+        and
+            point_name = #{pointName}
+        and
+            DATE(create_time) = #{createTime}
+        and
+           is_sum = 0
+    </update>
+
+    <update id="updateSumLog" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
+        update rq_iot_device_run_log
+        set
+            total_run_time = #{totalRunTime}
+        where
+            device_code = #{deviceCode}
+          and
+            point_name = #{pointName}
+          and
+            DATE(create_time) = #{createTime}
+          and
+            is_sum = 1
+    </update>
+
    <!-- <select id="fillList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
     resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         SELECT * FROM
@@ -296,6 +333,9 @@
             1=1
         </if>-->
         )
+        ORDER BY
+        CASE WHEN device_code IS NULL OR device_code = '' THEN 1 ELSE 0 END ASC,
+        CAST(SUBSTRING(device_code, 3) AS UNSIGNED) ASC
     </select>
 
 
@@ -361,6 +401,19 @@
             rq_iot_opeation_fill
         WHERE
             order_id = #{orderId}
+        and
+            dept_id IN (
+                SELECT id FROM (
+                                   SELECT d1.id FROM system_dept d1 WHERE d1.id = #{deptId}
+                                   UNION ALL
+                                   SELECT d2.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id WHERE d1.id = #{deptId}
+                                   UNION ALL
+                                   SELECT d3.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id WHERE d1.id = #{deptId}
+                                   UNION ALL
+                                   SELECT d4.id FROM system_dept d1 JOIN system_dept d2 ON d2.parent_id = d1.id JOIN system_dept d3 ON d3.parent_id = d2.id JOIN system_dept d4 ON d4.parent_id = d3.id WHERE d1.id = #{deptId}
+                               ) AS dept_hierarchy
+            )
+        and device_name != '日报填报'
     </select>
 
     <!--  -->
@@ -503,6 +556,76 @@
         </if>
     </select>
 
+
+    <select id="allOrder" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
+        select distinct user_name
+        from
+            rq_iot_opeation_fill_order
+        where
+            DATE(create_time) = DATE(#{localDateTime})
+            <if test="userNames != null and !userNames.isEmpty()">
+                and user_name  in
+                <foreach collection="userNames" item="userName" open="(" separator="," close=")">
+                    #{userName}
+                </foreach>
+            </if>
+    </select>
+
+    <select id="pdList2" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        select
+            distinct
+            b.id user_id,
+            b.nickname user_name,
+            c.id dept_id,
+            b.mobile,
+            c.name orgName
+        from
+            rq_iot_device_person a
+                left join
+            system_users b
+            on
+                a.person_id = b.id
+                left join
+            system_dept c
+            on
+                b.dept_id = c.id
+        where
+            b.id is not null
+          and
+            c.id is not null
+        <if test="deviceIds != null and !deviceIds.isEmpty()">
+            and c.id  in
+            <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+          and
+            a.person_id
+            not in
+              (select
+                   distinct
+                   d.person_id
+               from
+                   rq_iot_model_template a,
+                   rq_iot_model_template_attrs b,
+                   rq_iot_device c,
+                   rq_iot_device_person d
+               where
+                   a.device_category_id = b.device_category_id
+                 and
+                   a.device_category_id = c.asset_class
+                 and
+                   c.id = d.device_id
+                 and
+                   c.device_status in ('sg','dm')
+                 and
+                   a.deleted = 0
+                 and
+                   c.deleted = 0
+                 and
+                   d.deleted = 0)
+    </select>
+
     <select id="fillList1" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillRespVO"
             resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
         SELECT * FROM
@@ -524,7 +647,8 @@
             is_sum,
             threshold,
             default_value,
-            sum_id
+            sum_id,
+            description
         from
             rq_iot_model_template_attrs
         where
@@ -694,6 +818,7 @@
         and e.deleted = 0
         WHERE a.deleted = 0
         and e.order_name is not null
+        and a.device_name != '生产日报'
         AND b.id IN (
         SELECT id FROM system_dept WHERE id = #{deptId}
         UNION ALL
@@ -857,6 +982,7 @@
         and e.deleted = 0
         WHERE a.deleted = 0
         and e.order_name is not null
+        and a.device_name != '生产日报'
         AND b.id IN (
         SELECT id FROM system_dept WHERE id = #{deptId}
         UNION ALL
@@ -884,4 +1010,134 @@
         </if>) a
     </select>
 
+
+    <select id="childList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO"
+    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO">
+        SELECT id dept_id
+        FROM system_dept
+        WHERE parent_id = #{deptId}
+          AND deleted = 0
+    </select>
+
+    <select id="isReport" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
+    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        select * from
+            rq_iot_opeation_fill
+        where
+            device_id = #{deviceId}
+        and
+            DATE(create_time) = #{createTime}
+        LIMIT 1
+    </select>
+
+    <select id="orderDO" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        select
+            order_id
+        from
+            rq_iot_opeation_fill
+        where
+            device_id = #{deviceId}
+        and
+            DATE(create_time) = #{createTime}
+    </select>
+
+    <select id="reportList" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        SELECT DISTINCT
+            a.device_id,
+            a.device_code,
+            a.device_name,
+            a.create_time,
+            b.name AS org_name
+        FROM
+            rq_iot_opeation_fill a
+        INNER JOIN
+            rq_iot_model_template_attrs b
+        ON
+            a.device_category_id = b.device_category_id
+        WHERE
+            a.order_id = #{orderId}
+        AND (
+        -- 第一个查询的条件
+            (a.is_report = 1 AND b.daily_report = 0
+            AND b.name NOT IN (
+                    SELECT
+                        DISTINCT
+                        b2.name
+                    FROM
+                        rq_iot_opeation_fill a2
+                    INNER JOIN
+                        rq_iot_model_template_attrs b2
+                    ON
+                        a2.device_category_id = b2.device_category_id
+                    WHERE
+                       a2.order_id =  #{orderId}
+                    AND
+                       a2.is_report = 0
+                    AND
+                       b2.daily_report = 1
+                ))
+            -- 第二个查询的条件(通过OR代替UNION)
+             OR (a.is_report = 0 AND b.daily_report = 1)
+            )
+    </select>
+
+    <select id="reportList1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO">
+        SELECT DISTINCT
+            a.device_id,
+            a.device_code,
+            a.device_name,
+            a.create_time,
+            b.name AS org_name
+        FROM
+            rq_iot_opeation_fill a
+                INNER JOIN
+            rq_iot_model_template_attrs b
+            ON
+                a.device_category_id = b.device_category_id
+        WHERE
+            a.order_id = #{orderId}
+          and
+            a.is_report = 1
+    </select>
+
+    <select id="reportData" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
+        select * from
+            rq_iot_device_run_log
+        where
+            device_id = #{deviceId}
+          and
+            point_name = #{pointName}
+          and DATE(create_time) = DATE(#{createTime})
+    </select>
+
+    <select id="reportData1" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
+        select * from
+            rq_iot_device_run_log
+        where
+            device_id = #{deviceId}
+          and
+            point_name = #{pointName}
+          and DATE(create_time) = DATE(#{createTime})
+    </select>
+
+    <select id="getDesc" parameterType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO"
+            resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO">
+        select
+            description point_name
+        from
+            rq_iot_model_template_attrs
+        where
+            name = #{pointName}
+          and
+            device_category_id =
+            (select device_category_id  from rq_iot_opeation_fill where device_id = #{deviceId} and DATE(create_time) = #{createTime})
+    </select>
+
+
+
 </mapper>

+ 26 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotOperationPlanMapper.xml

@@ -11,7 +11,32 @@
 
 
     <select id="getPlanList" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotoperationplan.IotOperationPlanDO">
-        select * from rq_iot_operation_plan where status = 0 and deleted = 0
+        select * from
+            rq_iot_operation_plan
+        where
+            status = 0
+        and
+            deleted = 0
+        and
+            is_report is null
+        or  is_report != 1
+    </select>
+
+    <select id="getReportPlan" resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotoperationplan.IotOperationPlanDO">
+        select * from
+            rq_iot_operation_plan
+        where
+                status = 0
+                and
+                deleted = 0
+                and
+                is_report = 1
+            <if test="deviceIds != null and !deviceIds.isEmpty()">
+                and dept_id  in
+                <foreach collection="deviceIds" item="id" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
     </select>
 
 </mapper>

+ 17 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotProjectTaskMapper.xml

@@ -2,14 +2,24 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper">
 
-    <!--
-        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
-        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
-        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
-        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-     -->
+    <resultMap id="IotProjectTaskResultMap" type="cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO">
+        <id column="id" property="id" />
+        <result column="project_id" property="projectId" />
+        <result column="well_name" property="wellName" />
+        <result column="well_type" property="wellType" />
+        <result column="location" property="location" />
+        <result column="technique" property="technique" />
+        <result column="workload_design" property="workloadDesign" />
+        <result column="create_time" property="createTime" />
+        <result column="dept_ids" property="deptIds" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
+        <result column="remark" property="remark" />
+        <result column="manufacture_name" property="manufactureName" />
+        <result column="contract_name" property="contractName" />
+        <result column="contract_code" property="contractCode" />
+    </resultMap>
+
     <select id="taskList" parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO"
-    resultType="cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO">
+    resultMap="IotProjectTaskResultMap">
         select
         a.id,
         a.project_id,

+ 15 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/iotprojecttask/IotRhDailyReportMapper.xml

@@ -13,6 +13,7 @@
         <result column="construction_status" property="constructionStatus" />
         <result column="construction_start_date" property="constructionStartDate" />
         <result column="construction_end_date" property="constructionEndDate" />
+        <result column="relocation_days" property="relocationDays" />
         <!-- 其他字段映射 -->
     </resultMap>
 
@@ -97,4 +98,18 @@
         ORDER BY g.min_start_date ASC
     </select>
 
+    <select id="relocationDays" resultMap="BaseResultMap"
+            parameterType="cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportPageReqVO">
+        SELECT
+            task_id,
+            DATEDIFF(
+                    MIN(CASE WHEN construction_status = 3 THEN construction_start_date END),
+                    MIN(CASE WHEN construction_status = 1 THEN construction_start_date END)
+            ) AS relocation_days
+        FROM rq_iot_rh_daily_report
+        WHERE construction_status IN (1, 3)
+          AND deleted = 0
+        GROUP BY task_id;
+    </select>
+
 </mapper>