Ver código fonte

Merge remote-tracking branch 'origin/master'

lipenghui 3 meses atrás
pai
commit
bc579e9185
32 arquivos alterados com 768 adições e 26 exclusões
  1. 1 0
      yudao-module-pms/yudao-module-pms-api/src/main/java/cn/iocoder/yudao/module/pms/enums/ErrorCodeConstant.java
  2. 93 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotdevicerunlog/IotDeviceRunLogController.java
  3. 70 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotdevicerunlog/vo/IotDeviceRunLogPageReqVO.java
  4. 80 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotdevicerunlog/vo/IotDeviceRunLogRespVO.java
  5. 58 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotdevicerunlog/vo/IotDeviceRunLogSaveReqVO.java
  6. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainplanbommaterial/vo/IotMainPlanBomMaterialPageReqVO.java
  7. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainplanbommaterial/vo/IotMainPlanBomMaterialRespVO.java
  8. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainplanbommaterial/vo/IotMainPlanBomMaterialSaveReqVO.java
  9. 2 3
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmaintenancebom/vo/IotMaintenanceBomPageReqVO.java
  10. 13 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmaintenancebom/vo/IotMaintenanceBomRespVO.java
  11. 12 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmaintenancebom/vo/IotMaintenanceBomSaveReqVO.java
  12. 5 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorder/vo/IotMainWorkOrderRespVO.java
  13. 2 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbom/vo/IotMainWorkOrderBomPageReqVO.java
  14. 2 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbom/vo/IotMainWorkOrderBomRespVO.java
  15. 2 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbom/vo/IotMainWorkOrderBomSaveReqVO.java
  16. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbommaterial/vo/IotMainWorkOrderBomMaterialPageReqVO.java
  17. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbommaterial/vo/IotMainWorkOrderBomMaterialRespVO.java
  18. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbommaterial/vo/IotMainWorkOrderBomMaterialSaveReqVO.java
  19. 9 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotDeviceRespVO.java
  20. 89 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotdevicerunlog/IotDeviceRunLogDO.java
  21. 14 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotmaintenancebom/IotMaintenanceBomDO.java
  22. 2 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotmainworkorderbom/IotMainWorkOrderBomDO.java
  23. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotmainworkorderbommaterial/IotMainWorkOrderBomMaterialDO.java
  24. 38 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotdevicerunlog/IotDeviceRunLogMapper.java
  25. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotmainplanbommaterial/IotMainPlanBomMaterialMapper.java
  26. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotmaintenancebom/IotMaintenanceBomMapper.java
  27. 2 2
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotmainworkorderbom/IotMainWorkOrderBomMapper.java
  28. 1 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotmainworkorderbommaterial/IotMainWorkOrderBomMaterialMapper.java
  29. 116 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/mainworkorder/CreateMainWorkOrderJob.java
  30. 55 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotdevicerunlog/IotDeviceRunLogService.java
  31. 71 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotdevicerunlog/IotDeviceRunLogServiceImpl.java
  32. 22 0
      yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotDeviceMapper.xml

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

@@ -48,4 +48,5 @@ public interface ErrorCodeConstant{
     ErrorCode IOT_MAIN_WORK_ORDER_BOM_MATERIAL_NOT_EXISTS = new ErrorCode(139,"保养bom物料不存在");
     ErrorCode IOT_MAINTENANCE_PLAN_NO_EXISTS = new ErrorCode(140,"维修计划不存在");
     ErrorCode IOT_MAIN_WORK_ORDER_NOT_EXISTS = new ErrorCode(141,"保养工单不存在");
+    ErrorCode IOT_DEVICE_RUN_LOG_NOT_EXISTS = new ErrorCode(142, "设备运行数据记录 中间表不存在");
 }

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

@@ -0,0 +1,93 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog;
+
+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.iotdevicerunlog.vo.IotDeviceRunLogPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO;
+import cn.iocoder.yudao.module.pms.service.iotdevicerunlog.IotDeviceRunLogService;
+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-device-run-log")
+@Validated
+public class IotDeviceRunLogController {
+
+    @Resource
+    private IotDeviceRunLogService iotDeviceRunLogService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建设备运行数据记录 中间表")
+    @PreAuthorize("@ss.hasPermission('pms:iot-device-run-log:create')")
+    public CommonResult<Long> createIotDeviceRunLog(@Valid @RequestBody IotDeviceRunLogSaveReqVO createReqVO) {
+        return success(iotDeviceRunLogService.createIotDeviceRunLog(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新设备运行数据记录 中间表")
+    @PreAuthorize("@ss.hasPermission('pms:iot-device-run-log:update')")
+    public CommonResult<Boolean> updateIotDeviceRunLog(@Valid @RequestBody IotDeviceRunLogSaveReqVO updateReqVO) {
+        iotDeviceRunLogService.updateIotDeviceRunLog(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除设备运行数据记录 中间表")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('pms:iot-device-run-log:delete')")
+    public CommonResult<Boolean> deleteIotDeviceRunLog(@RequestParam("id") Long id) {
+        iotDeviceRunLogService.deleteIotDeviceRunLog(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得设备运行数据记录 中间表")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('pms:iot-device-run-log:query')")
+    public CommonResult<IotDeviceRunLogRespVO> getIotDeviceRunLog(@RequestParam("id") Long id) {
+        IotDeviceRunLogDO iotDeviceRunLog = iotDeviceRunLogService.getIotDeviceRunLog(id);
+        return success(BeanUtils.toBean(iotDeviceRunLog, IotDeviceRunLogRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得设备运行数据记录 中间表分页")
+    @PreAuthorize("@ss.hasPermission('pms:iot-device-run-log:query')")
+    public CommonResult<PageResult<IotDeviceRunLogRespVO>> getIotDeviceRunLogPage(@Valid IotDeviceRunLogPageReqVO pageReqVO) {
+        PageResult<IotDeviceRunLogDO> pageResult = iotDeviceRunLogService.getIotDeviceRunLogPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotDeviceRunLogRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出设备运行数据记录 中间表 Excel")
+    @PreAuthorize("@ss.hasPermission('pms:iot-device-run-log:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotDeviceRunLogExcel(@Valid IotDeviceRunLogPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotDeviceRunLogDO> list = iotDeviceRunLogService.getIotDeviceRunLogPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "设备运行数据记录 中间表.xls", "数据", IotDeviceRunLogRespVO.class,
+                        BeanUtils.toBean(list, IotDeviceRunLogRespVO.class));
+    }
+
+}

+ 70 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotdevicerunlog/vo/IotDeviceRunLogPageReqVO.java

@@ -0,0 +1,70 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.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 IotDeviceRunLogPageReqVO extends PageParam {
+
+    @Schema(description = "部门id 所属小队", example = "4540")
+    private Long deptId;
+
+    @Schema(description = "设备id", example = "9192")
+    private Long deviceId;
+
+    @Schema(description = "设备编码")
+    private String deviceCode;
+
+    @Schema(description = "设备部件")
+    private String deviceComp;
+
+    @Schema(description = "采集点位 信息 code")
+    private String pointCode;
+
+    @Schema(description = "采集点位信息 名称", example = "李四")
+    private String pointName;
+
+    @Schema(description = "数据类型 1手动填报 2自动采集", example = "1")
+    private Integer type;
+
+    @Schema(description = "设备运行记录值 运行公里数km 运行公里数H")
+    private BigDecimal value;
+
+    @Schema(description = "填报时间 or 采集时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] time;
+
+    @Schema(description = "当日运行时间 H")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private BigDecimal[] dailyRunTime;
+
+    @Schema(description = "累计运行时间 H")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private BigDecimal[] totalRunTime;
+
+    @Schema(description = "当日运行里程 H")
+    private BigDecimal dailyMileage;
+
+    @Schema(description = "累计运行里程 H")
+    private BigDecimal totalMileage;
+
+    @Schema(description = "备注", example = "你猜")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 80 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotdevicerunlog/vo/IotDeviceRunLogRespVO.java

@@ -0,0 +1,80 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.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 IotDeviceRunLogRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12620")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "部门id 所属小队", example = "4540")
+    @ExcelProperty("部门id 所属小队")
+    private Long deptId;
+
+    @Schema(description = "设备id", example = "9192")
+    @ExcelProperty("设备id")
+    private Long deviceId;
+
+    @Schema(description = "设备编码")
+    @ExcelProperty("设备编码")
+    private String deviceCode;
+
+    @Schema(description = "设备部件")
+    @ExcelProperty("设备部件")
+    private String deviceComp;
+
+    @Schema(description = "采集点位 信息 code")
+    @ExcelProperty("采集点位 信息 code")
+    private String pointCode;
+
+    @Schema(description = "采集点位信息 名称", example = "李四")
+    @ExcelProperty("采集点位信息 名称")
+    private String pointName;
+
+    @Schema(description = "数据类型 1手动填报 2自动采集", example = "1")
+    @ExcelProperty("数据类型 1手动填报 2自动采集")
+    private Integer type;
+
+    @Schema(description = "设备运行记录值 运行公里数km 运行公里数H")
+    @ExcelProperty("设备运行记录值 运行公里数km 运行公里数H")
+    private BigDecimal value;
+
+    @Schema(description = "填报时间 or 采集时间")
+    @ExcelProperty("填报时间 or 采集时间")
+    private LocalDateTime time;
+
+    @Schema(description = "当日运行时间 H")
+    @ExcelProperty("当日运行时间 H")
+    private BigDecimal dailyRunTime;
+
+    @Schema(description = "累计运行时间 H")
+    @ExcelProperty("累计运行时间 H")
+    private BigDecimal totalRunTime;
+
+    @Schema(description = "当日运行里程 H")
+    @ExcelProperty("当日运行里程 H")
+    private BigDecimal dailyMileage;
+
+    @Schema(description = "累计运行里程 H")
+    @ExcelProperty("累计运行里程 H")
+    private BigDecimal totalMileage;
+
+    @Schema(description = "备注", example = "你猜")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 58 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotdevicerunlog/vo/IotDeviceRunLogSaveReqVO.java

@@ -0,0 +1,58 @@
+package cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.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 IotDeviceRunLogSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12620")
+    private Long id;
+
+    @Schema(description = "部门id 所属小队", example = "4540")
+    private Long deptId;
+
+    @Schema(description = "设备id", example = "9192")
+    private Long deviceId;
+
+    @Schema(description = "设备编码")
+    private String deviceCode;
+
+    @Schema(description = "设备部件")
+    private String deviceComp;
+
+    @Schema(description = "采集点位 信息 code")
+    private String pointCode;
+
+    @Schema(description = "采集点位信息 名称", example = "李四")
+    private String pointName;
+
+    @Schema(description = "数据类型 1手动填报 2自动采集", example = "1")
+    private Integer type;
+
+    @Schema(description = "设备运行记录值 运行公里数km 运行公里数H")
+    private BigDecimal value;
+
+    @Schema(description = "填报时间 or 采集时间")
+    private LocalDateTime time;
+
+    @Schema(description = "当日运行时间 H")
+    private BigDecimal dailyRunTime;
+
+    @Schema(description = "累计运行时间 H")
+    private BigDecimal totalRunTime;
+
+    @Schema(description = "当日运行里程 H")
+    private BigDecimal dailyMileage;
+
+    @Schema(description = "累计运行里程 H")
+    private BigDecimal totalMileage;
+
+    @Schema(description = "备注", example = "你猜")
+    private String remark;
+
+}

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

@@ -61,7 +61,7 @@ public class IotMainPlanBomMaterialPageReqVO extends PageParam {
     private BigDecimal naturalDatePeriod;
 
     @Schema(description = "自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "排序")
     private Integer sort;

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

@@ -75,7 +75,7 @@ public class IotMainPlanBomMaterialRespVO {
 
     @Schema(description = "自然日周期-提前量(天)")
     @ExcelProperty("自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "排序")
     @ExcelProperty("排序")

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

@@ -55,7 +55,7 @@ public class IotMainPlanBomMaterialSaveReqVO {
     private BigDecimal naturalDatePeriod;
 
     @Schema(description = "自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "排序")
     private Integer sort;

+ 2 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmaintenancebom/vo/IotMaintenanceBomPageReqVO.java

@@ -56,11 +56,10 @@ public class IotMaintenanceBomPageReqVO extends PageParam {
 
     @Schema(description = "上次保养自然日期(天)")
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private BigDecimal[] lastNaturalDate;
+    private LocalDateTime[] lastNaturalDate;
 
     @Schema(description = "下次保养自然日期(天)")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private BigDecimal[] nextNaturalDate;
+    private BigDecimal nextNaturalDate;
 
     @Schema(description = "BOM节点 id", example = "18063")
     private Long bomNodeId;

+ 13 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmaintenancebom/vo/IotMaintenanceBomRespVO.java

@@ -52,6 +52,10 @@ public class IotMaintenanceBomRespVO {
     @ExcelProperty("下次保养运行时长(小时)")
     private BigDecimal nextRunningTime;
 
+    @Schema(description = "运行时长周期提前量 H")
+    @ExcelProperty("运行时长周期提前量 H")
+    private BigDecimal timePeriodLead;
+
     @Schema(description = "上次保养运行公里数(千米)")
     @ExcelProperty("上次保养运行公里数(千米)")
     private BigDecimal lastRunningKilometers;
@@ -60,14 +64,22 @@ public class IotMaintenanceBomRespVO {
     @ExcelProperty("下次保养运行公里数(千米)")
     private BigDecimal nextRunningKilometers;
 
+    @Schema(description = "公里数周期-提前量 km")
+    @ExcelProperty("公里数周期-提前量 km")
+    private BigDecimal kiloCycleLead;
+
     @Schema(description = "上次保养自然日期(天)")
     @ExcelProperty("上次保养自然日期(天)")
-    private BigDecimal lastNaturalDate;
+    private LocalDateTime lastNaturalDate;
 
     @Schema(description = "下次保养自然日期(天)")
     @ExcelProperty("下次保养自然日期(天)")
     private BigDecimal nextNaturalDate;
 
+    @Schema(description = "自然日周期-提前量(天)")
+    @ExcelProperty("自然日周期-提前量(天)")
+    private BigDecimal naturalDatePeriodLead;
+
     @Schema(description = "BOM节点 id", example = "18063")
     private Long bomNodeId;
 

+ 12 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmaintenancebom/vo/IotMaintenanceBomSaveReqVO.java

@@ -1,9 +1,11 @@
 package cn.iocoder.yudao.module.pms.controller.admin.iotmaintenancebom.vo;
 
+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 = "管理后台 - PMS 保养计划明细BOM新增/修改 Request VO")
 @Data
@@ -40,18 +42,27 @@ public class IotMaintenanceBomSaveReqVO {
     @Schema(description = "下次保养运行时长(小时)")
     private BigDecimal nextRunningTime;
 
+    @Schema(description = "运行时长周期提前量 H")
+    private BigDecimal timePeriodLead;
+
     @Schema(description = "上次保养运行公里数(千米)")
     private BigDecimal lastRunningKilometers;
 
     @Schema(description = "下次保养运行公里数(千米)")
     private BigDecimal nextRunningKilometers;
 
+    @Schema(description = "公里数周期-提前量 km")
+    private BigDecimal kiloCycleLead;
+
     @Schema(description = "上次保养自然日期(天)")
-    private BigDecimal lastNaturalDate;
+    private LocalDateTime lastNaturalDate;
 
     @Schema(description = "下次保养自然日期(天)")
     private BigDecimal nextNaturalDate;
 
+    @Schema(description = "自然日周期-提前量(天)")
+    private BigDecimal naturalDatePeriodLead;
+
     @Schema(description = "BOM节点 id", example = "18063")
     private Long bomNodeId;
 

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

@@ -97,4 +97,9 @@ public class IotMainWorkOrderRespVO {
     @ExcelProperty("创建时间")
     private LocalDateTime createTime;
 
+    /**
+     * 扩展字段
+     */
+    @Schema(description = "距离保养时间")
+    private BigDecimal remainingTime;
 }

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbom/vo/IotMainWorkOrderBomPageReqVO.java

@@ -63,7 +63,7 @@ public class IotMainWorkOrderBomPageReqVO extends PageParam {
     private BigDecimal nextRunningKilometers;
 
     @Schema(description = "推迟运行公里数(千米)")
-    private BigDecimal delayKilomaters;
+    private BigDecimal delayKilometers;
 
     @Schema(description = "上次保养自然日期(天)")
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@@ -100,7 +100,7 @@ public class IotMainWorkOrderBomPageReqVO extends PageParam {
     private BigDecimal naturalDatePeriod;
 
     @Schema(description = "自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "BOM节点id", example = "13933")
     private Long bomNodeId;

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbom/vo/IotMainWorkOrderBomRespVO.java

@@ -75,7 +75,7 @@ public class IotMainWorkOrderBomRespVO {
 
     @Schema(description = "推迟运行公里数(千米)")
     @ExcelProperty("推迟运行公里数(千米)")
-    private BigDecimal delayKilomaters;
+    private BigDecimal delayKilometers;
 
     @Schema(description = "上次保养自然日期(天)")
     @ExcelProperty("上次保养自然日期(天)")
@@ -119,7 +119,7 @@ public class IotMainWorkOrderBomRespVO {
 
     @Schema(description = "自然日周期-提前量(天)")
     @ExcelProperty("自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "BOM节点id", example = "13933")
     @ExcelProperty("BOM节点id")

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmainworkorderbom/vo/IotMainWorkOrderBomSaveReqVO.java

@@ -56,7 +56,7 @@ public class IotMainWorkOrderBomSaveReqVO {
     private BigDecimal nextRunningKilometers;
 
     @Schema(description = "推迟运行公里数(千米)")
-    private BigDecimal delayKilomaters;
+    private BigDecimal delayKilometers;
 
     @Schema(description = "上次保养自然日期(天)")
     private BigDecimal lastNaturalDate;
@@ -89,7 +89,7 @@ public class IotMainWorkOrderBomSaveReqVO {
     private BigDecimal naturalDatePeriod;
 
     @Schema(description = "自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "BOM节点id", example = "13933")
     private Long bomNodeId;

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

@@ -73,7 +73,7 @@ public class IotMainWorkOrderBomMaterialPageReqVO extends PageParam {
     private BigDecimal naturalDatePeriod;
 
     @Schema(description = "自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "物料来源 (SAP库存 本地库存...)")
     private String materialSource;

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

@@ -91,7 +91,7 @@ public class IotMainWorkOrderBomMaterialRespVO {
 
     @Schema(description = "自然日周期-提前量(天)")
     @ExcelProperty("自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "物料来源 (SAP库存 本地库存...)")
     @ExcelProperty("物料来源 (SAP库存 本地库存...)")

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

@@ -67,7 +67,7 @@ public class IotMainWorkOrderBomMaterialSaveReqVO {
     private BigDecimal naturalDatePeriod;
 
     @Schema(description = "自然日周期-提前量(天)")
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
 
     @Schema(description = "物料来源 (SAP库存 本地库存...)")
     private String materialSource;

+ 9 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotDeviceRespVO.java

@@ -5,6 +5,7 @@ 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")
@@ -153,4 +154,12 @@ public class IotDeviceRespVO {
     private String name;
     @Schema(description = "bom节点编码")
     private String code;
+
+    /**
+     * 计算字段
+     */
+    @Schema(description = "设备累计运行里程")
+    private BigDecimal totalMileage;
+    @Schema(description = "设备累计运行时间")
+    private BigDecimal totalRunTime;
 }

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

@@ -0,0 +1,89 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog;
+
+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_device_run_log")
+@KeySequence("rq_iot_device_run_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotDeviceRunLogDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 部门id 所属小队
+     */
+    private Long deptId;
+    /**
+     * 设备id
+     */
+    private Long deviceId;
+    /**
+     * 设备编码
+     */
+    private String deviceCode;
+    /**
+     * 设备部件
+     */
+    private String deviceComp;
+    /**
+     * 采集点位 信息 code
+     */
+    private String pointCode;
+    /**
+     * 采集点位信息 名称
+     */
+    private String pointName;
+    /**
+     * 数据类型 1手动填报 2自动采集
+     */
+    private Integer type;
+    /**
+     * 设备运行记录值 运行公里数km 运行公里数H
+     */
+    private BigDecimal value;
+    /**
+     * 填报时间 or 采集时间
+     */
+    private LocalDateTime time;
+    /**
+     * 当日运行时间 H
+     */
+    private BigDecimal dailyRunTime;
+    /**
+     * 累计运行时间 H
+     */
+    private BigDecimal totalRunTime;
+    /**
+     * 当日运行里程 H
+     */
+    private BigDecimal dailyMileage;
+    /**
+     * 累计运行里程 H
+     */
+    private BigDecimal totalMileage;
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 14 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotmaintenancebom/IotMaintenanceBomDO.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.*;
 
 import java.math.BigDecimal;
+import java.time.LocalDateTime;
 
 /**
  * PMS 保养计划明细BOM DO
@@ -68,6 +69,10 @@ public class IotMaintenanceBomDO extends BaseDO {
      * 下次保养运行时长(小时)
      */
     private BigDecimal nextRunningTime;
+    /**
+     * 运行时长周期提前量 H
+     */
+    private BigDecimal timePeriodLead;
     /**
      * 上次保养运行公里数(千米)
      */
@@ -76,14 +81,22 @@ public class IotMaintenanceBomDO extends BaseDO {
      * 下次保养运行公里数(千米)
      */
     private BigDecimal nextRunningKilometers;
+    /**
+     * 公里数周期-提前量 km
+     */
+    private BigDecimal kiloCycleLead;
     /**
      * 上次保养自然日期(天)
      */
-    private BigDecimal lastNaturalDate;
+    private LocalDateTime lastNaturalDate;
     /**
      * 下次保养自然日期(天)
      */
     private BigDecimal nextNaturalDate;
+    /**
+     * 自然日周期-提前量(天)
+     */
+    private BigDecimal naturalDatePeriodLead;
     /**
      * BOM节点id
      */

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotmainworkorderbom/IotMainWorkOrderBomDO.java

@@ -88,7 +88,7 @@ public class IotMainWorkOrderBomDO extends BaseDO {
     /**
      * 推迟运行公里数(千米)
      */
-    private BigDecimal delayKilomaters;
+    private BigDecimal delayKilometers;
     /**
      * 上次保养自然日期(天)
      */
@@ -132,7 +132,7 @@ public class IotMainWorkOrderBomDO extends BaseDO {
     /**
      * 自然日周期-提前量(天)
      */
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
     /**
      * BOM节点id
      */

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/iotmainworkorderbommaterial/IotMainWorkOrderBomMaterialDO.java

@@ -103,7 +103,7 @@ public class IotMainWorkOrderBomMaterialDO extends BaseDO {
     /**
      * 自然日周期-提前量(天)
      */
-    private BigDecimal naturalDatePeroidLead;
+    private BigDecimal naturalDatePeriodLead;
     /**
      * 物料来源 (SAP库存 本地库存...)
      */

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

@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.iotdevicerunlog;
+
+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.iotdevicerunlog.vo.IotDeviceRunLogPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 设备运行数据记录 中间表 Mapper
+ *
+ * @author ruiqi
+ */
+@Mapper
+public interface IotDeviceRunLogMapper extends BaseMapperX<IotDeviceRunLogDO> {
+
+    default PageResult<IotDeviceRunLogDO> selectPage(IotDeviceRunLogPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceRunLogDO>()
+                .eqIfPresent(IotDeviceRunLogDO::getDeptId, reqVO.getDeptId())
+                .eqIfPresent(IotDeviceRunLogDO::getDeviceId, reqVO.getDeviceId())
+                .eqIfPresent(IotDeviceRunLogDO::getDeviceCode, reqVO.getDeviceCode())
+                .eqIfPresent(IotDeviceRunLogDO::getDeviceComp, reqVO.getDeviceComp())
+                .eqIfPresent(IotDeviceRunLogDO::getPointCode, reqVO.getPointCode())
+                .likeIfPresent(IotDeviceRunLogDO::getPointName, reqVO.getPointName())
+                .eqIfPresent(IotDeviceRunLogDO::getType, reqVO.getType())
+                .eqIfPresent(IotDeviceRunLogDO::getValue, reqVO.getValue())
+                .betweenIfPresent(IotDeviceRunLogDO::getTime, reqVO.getTime())
+                .betweenIfPresent(IotDeviceRunLogDO::getDailyRunTime, reqVO.getDailyRunTime())
+                .betweenIfPresent(IotDeviceRunLogDO::getTotalRunTime, reqVO.getTotalRunTime())
+                .eqIfPresent(IotDeviceRunLogDO::getDailyMileage, reqVO.getDailyMileage())
+                .eqIfPresent(IotDeviceRunLogDO::getTotalMileage, reqVO.getTotalMileage())
+                .eqIfPresent(IotDeviceRunLogDO::getRemark, reqVO.getRemark())
+                .betweenIfPresent(IotDeviceRunLogDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(IotDeviceRunLogDO::getId));
+    }
+
+}

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

@@ -31,7 +31,7 @@ public interface IotMainPlanBomMaterialMapper extends BaseMapperX<IotMainPlanBom
                 .eqIfPresent(IotMainPlanBomMaterialDO::getTimePeriod, reqVO.getTimePeriod())
                 .eqIfPresent(IotMainPlanBomMaterialDO::getTimePeriodLead, reqVO.getTimePeriodLead())
                 .eqIfPresent(IotMainPlanBomMaterialDO::getNaturalDatePeriod, reqVO.getNaturalDatePeriod())
-                .eqIfPresent(IotMainPlanBomMaterialDO::getNaturalDatePeroidLead, reqVO.getNaturalDatePeroidLead())
+                .eqIfPresent(IotMainPlanBomMaterialDO::getNaturalDatePeroidLead, reqVO.getNaturalDatePeriodLead())
                 .eqIfPresent(IotMainPlanBomMaterialDO::getSort, reqVO.getSort())
                 .eqIfPresent(IotMainPlanBomMaterialDO::getStatus, reqVO.getStatus())
                 .eqIfPresent(IotMainPlanBomMaterialDO::getRemark, reqVO.getRemark())

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

@@ -30,7 +30,7 @@ public interface IotMaintenanceBomMapper extends BaseMapperX<IotMaintenanceBomDO
                 .eqIfPresent(IotMaintenanceBomDO::getLastRunningKilometers, reqVO.getLastRunningKilometers())
                 .eqIfPresent(IotMaintenanceBomDO::getNextRunningKilometers, reqVO.getNextRunningKilometers())
                 .betweenIfPresent(IotMaintenanceBomDO::getLastNaturalDate, reqVO.getLastNaturalDate())
-                .betweenIfPresent(IotMaintenanceBomDO::getNextNaturalDate, reqVO.getNextNaturalDate())
+                .eqIfPresent(IotMaintenanceBomDO::getNextNaturalDate, reqVO.getNextNaturalDate())
                 .likeIfPresent(IotMaintenanceBomDO::getName, reqVO.getName())
                 .eqIfPresent(IotMaintenanceBomDO::getCode, reqVO.getCode())
                 .eqIfPresent(IotMaintenanceBomDO::getParentId, reqVO.getParentId())

+ 2 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotmainworkorderbom/IotMainWorkOrderBomMapper.java

@@ -31,7 +31,7 @@ public interface IotMainWorkOrderBomMapper extends BaseMapperX<IotMainWorkOrderB
                 .eqIfPresent(IotMainWorkOrderBomDO::getDelayDuration, reqVO.getDelayDuration())
                 .eqIfPresent(IotMainWorkOrderBomDO::getLastRunningKilometers, reqVO.getLastRunningKilometers())
                 .eqIfPresent(IotMainWorkOrderBomDO::getNextRunningKilometers, reqVO.getNextRunningKilometers())
-                .eqIfPresent(IotMainWorkOrderBomDO::getDelayKilomaters, reqVO.getDelayKilomaters())
+                .eqIfPresent(IotMainWorkOrderBomDO::getDelayKilometers, reqVO.getDelayKilometers())
                 .betweenIfPresent(IotMainWorkOrderBomDO::getLastNaturalDate, reqVO.getLastNaturalDate())
                 .betweenIfPresent(IotMainWorkOrderBomDO::getNextNaturalDate, reqVO.getNextNaturalDate())
                 .betweenIfPresent(IotMainWorkOrderBomDO::getDelayNaturalDate, reqVO.getDelayNaturalDate())
@@ -42,7 +42,7 @@ public interface IotMainWorkOrderBomMapper extends BaseMapperX<IotMainWorkOrderB
                 .eqIfPresent(IotMainWorkOrderBomDO::getKilometerCycle, reqVO.getKilometerCycle())
                 .eqIfPresent(IotMainWorkOrderBomDO::getKiloCycleLead, reqVO.getKiloCycleLead())
                 .eqIfPresent(IotMainWorkOrderBomDO::getNaturalDatePeriod, reqVO.getNaturalDatePeriod())
-                .eqIfPresent(IotMainWorkOrderBomDO::getNaturalDatePeroidLead, reqVO.getNaturalDatePeroidLead())
+                .eqIfPresent(IotMainWorkOrderBomDO::getNaturalDatePeriodLead, reqVO.getNaturalDatePeriodLead())
                 .eqIfPresent(IotMainWorkOrderBomDO::getBomNodeId, reqVO.getBomNodeId())
                 .likeIfPresent(IotMainWorkOrderBomDO::getName, reqVO.getName())
                 .eqIfPresent(IotMainWorkOrderBomDO::getCode, reqVO.getCode())

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

@@ -35,7 +35,7 @@ public interface IotMainWorkOrderBomMaterialMapper extends BaseMapperX<IotMainWo
                 .eqIfPresent(IotMainWorkOrderBomMaterialDO::getTimePeriod, reqVO.getTimePeriod())
                 .eqIfPresent(IotMainWorkOrderBomMaterialDO::getTimePeriodLead, reqVO.getTimePeriodLead())
                 .eqIfPresent(IotMainWorkOrderBomMaterialDO::getNaturalDatePeriod, reqVO.getNaturalDatePeriod())
-                .eqIfPresent(IotMainWorkOrderBomMaterialDO::getNaturalDatePeroidLead, reqVO.getNaturalDatePeroidLead())
+                .eqIfPresent(IotMainWorkOrderBomMaterialDO::getNaturalDatePeriodLead, reqVO.getNaturalDatePeriodLead())
                 .eqIfPresent(IotMainWorkOrderBomMaterialDO::getMaterialSource, reqVO.getMaterialSource())
                 .eqIfPresent(IotMainWorkOrderBomMaterialDO::getInventoryAddress, reqVO.getInventoryAddress())
                 .eqIfPresent(IotMainWorkOrderBomMaterialDO::getSort, reqVO.getSort())

+ 116 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/mainworkorder/CreateMainWorkOrderJob.java

@@ -0,0 +1,116 @@
+package cn.iocoder.yudao.module.pms.job.mainworkorder;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
+import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
+import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectOrderDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectOrderDetailDO;
+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.mysql.inspect.IotInspectOrderDetailMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectPlanMapper;
+import cn.iocoder.yudao.module.pms.service.iotmainworkorder.IotMainWorkOrderService;
+import cn.iocoder.yudao.module.pms.service.maintenance.IotMaintenancePlanService;
+import com.alibaba.fastjson.JSON;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.time.ZoneId;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Component
+@Slf4j
+public class CreateMainWorkOrderJob implements JobHandler {
+    @Resource
+    private IotInspectPlanMapper iotInspectPlanMapper;
+    @Resource
+    private IotInspectOrderMapper iotInspectOrderMapper;
+    @Autowired
+    private IotInspectOrderDetailMapper iotInspectOrderDetailMapper;
+
+    @Resource
+    private IotMaintenancePlanService iotMaintenancePlanService;
+    @Resource
+    private IotMainWorkOrderService iotMainWorkOrderService;
+
+    @Override
+    @TenantJob
+    public String execute(String param) throws Exception {
+        // 查询所有的 保养计划
+        List<IotInspectPlanDO> plans = iotInspectPlanMapper.selectList();
+        plans.forEach(plan -> {
+            if (plan.getLastCreateTime()==null) {
+                Date date = Date.from(
+                        plan.getCreateTime().atZone(ZoneId.systemDefault()) // 使用系统默认时区
+                                .toInstant()                    // 转为 Instant(时间戳)
+                );
+                deal(plan, date);
+            } else {
+                Date lastdate = Date.from(
+                        plan.getLastCreateTime().atZone(ZoneId.systemDefault()) // 使用系统默认时区
+                                .toInstant()                    // 转为 Instant(时间戳)
+                );
+                deal(plan, lastdate);
+            }
+        });
+        return "创建成功";
+    }
+
+    private void deal(IotInspectPlanDO plan, Date date) {
+        Date date1 = new Date();
+        if ("hour".equals(plan.getPlanUnit())){
+            //todo
+            DateTime dateTime = DateUtil.offsetMinute(date, Integer.parseInt(StringUtils.substringBeforeLast(String.valueOf(plan.getPlanCycle()),".")));
+            if (date1.compareTo(dateTime) > 0){
+                createPlan(plan);
+            }
+        } else if ("day".equals(plan.getPlanUnit())){
+            DateTime dateTime = DateUtil.offsetDay(date, Integer.parseInt(String.valueOf(plan.getPlanCycle())));
+            if (date1.compareTo(dateTime) > 0){
+                createPlan(plan);
+            }
+        } else if ("month".equals(plan.getPlanUnit())){
+            DateTime dateTime = DateUtil.offsetMonth(date, Integer.parseInt(String.valueOf(plan.getPlanCycle())));
+            if (date1.compareTo(dateTime) > 0){
+                createPlan(plan);
+            }
+        }
+    }
+
+    private void createPlan(IotInspectPlanDO iotInspectPlan) {
+        IotInspectOrderDO iotInspectOrderDO = new IotInspectOrderDO();
+        iotInspectOrderDO.setInspectOrderTitle(iotInspectPlan.getPlanTitle()+"-巡检工单");
+        iotInspectOrderDO.setInspectOrderCode("IN"+ DateUtil.format(new Date(),"yyyyMMddHHmmss"));
+        String collect = Arrays.stream(iotInspectPlan.getCharge().split(",")).map(charge -> "io" + charge + "io").collect(Collectors.joining(","));
+        iotInspectOrderDO.setCharge(collect);
+        iotInspectOrderDO.setStatus("todo");
+        iotInspectOrderDO.setDeviceIds(iotInspectPlan.getDeviceIds());
+        iotInspectOrderDO.setType("计划生成");
+        iotInspectOrderDO.setPlanCode(iotInspectPlan.getPlanCode());
+        iotInspectOrderDO.setDeleted(false);
+        iotInspectOrderDO.setChargeName(iotInspectPlan.getChargeName());
+        iotInspectOrderMapper.insert(iotInspectOrderDO);
+        List<IotInspectRouteDO> routeDOS = JSON.parseArray(iotInspectPlan.getDeviceIds(), IotInspectRouteDO.class);
+        List<IotInspectOrderDetailDO> results = new ArrayList<>();
+        //处理巡检项
+        routeDOS.forEach(routeDO -> {
+            List<Map> itemos = JSON.parseArray(routeDO.getItemJson(), Map.class);
+            itemos.forEach(item -> {
+                IotInspectOrderDetailDO detailDO = new IotInspectOrderDetailDO();
+                detailDO.setOrderId(iotInspectOrderDO.getId());
+                detailDO.setDeviceId(routeDO.getDeviceId());
+                detailDO.setItemId(Long.valueOf(String.valueOf(item.get("itemId"))));
+                detailDO.setIndexId(Long.valueOf(String.valueOf(item.get("index"))));
+                detailDO.setDeleted(false);
+                results.add(detailDO);
+            });
+        });
+        iotInspectOrderDetailMapper.insertBatch(results);
+    }
+}

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

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.pms.service.iotdevicerunlog;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO;
+
+import javax.validation.Valid;
+
+/**
+ * 设备运行数据记录 中间表 Service 接口
+ *
+ * @author ruiqi
+ */
+public interface IotDeviceRunLogService {
+
+    /**
+     * 创建设备运行数据记录 中间表
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotDeviceRunLog(@Valid IotDeviceRunLogSaveReqVO createReqVO);
+
+    /**
+     * 更新设备运行数据记录 中间表
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotDeviceRunLog(@Valid IotDeviceRunLogSaveReqVO updateReqVO);
+
+    /**
+     * 删除设备运行数据记录 中间表
+     *
+     * @param id 编号
+     */
+    void deleteIotDeviceRunLog(Long id);
+
+    /**
+     * 获得设备运行数据记录 中间表
+     *
+     * @param id 编号
+     * @return 设备运行数据记录 中间表
+     */
+    IotDeviceRunLogDO getIotDeviceRunLog(Long id);
+
+    /**
+     * 获得设备运行数据记录 中间表分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 设备运行数据记录 中间表分页
+     */
+    PageResult<IotDeviceRunLogDO> getIotDeviceRunLogPage(IotDeviceRunLogPageReqVO pageReqVO);
+
+}

+ 71 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotdevicerunlog/IotDeviceRunLogServiceImpl.java

@@ -0,0 +1,71 @@
+package cn.iocoder.yudao.module.pms.service.iotdevicerunlog;
+
+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.iotdevicerunlog.vo.IotDeviceRunLogPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicerunlog.IotDeviceRunLogDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.iotdevicerunlog.IotDeviceRunLogMapper;
+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_DEVICE_RUN_LOG_NOT_EXISTS;
+
+/**
+ * 设备运行数据记录 中间表 Service 实现类
+ *
+ * @author ruiqi
+ */
+@Service
+@Validated
+public class IotDeviceRunLogServiceImpl implements IotDeviceRunLogService {
+
+    @Resource
+    private IotDeviceRunLogMapper iotDeviceRunLogMapper;
+
+    @Override
+    public Long createIotDeviceRunLog(IotDeviceRunLogSaveReqVO createReqVO) {
+        // 插入
+        IotDeviceRunLogDO iotDeviceRunLog = BeanUtils.toBean(createReqVO, IotDeviceRunLogDO.class);
+        iotDeviceRunLogMapper.insert(iotDeviceRunLog);
+        // 返回
+        return iotDeviceRunLog.getId();
+    }
+
+    @Override
+    public void updateIotDeviceRunLog(IotDeviceRunLogSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotDeviceRunLogExists(updateReqVO.getId());
+        // 更新
+        IotDeviceRunLogDO updateObj = BeanUtils.toBean(updateReqVO, IotDeviceRunLogDO.class);
+        iotDeviceRunLogMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotDeviceRunLog(Long id) {
+        // 校验存在
+        validateIotDeviceRunLogExists(id);
+        // 删除
+        iotDeviceRunLogMapper.deleteById(id);
+    }
+
+    private void validateIotDeviceRunLogExists(Long id) {
+        if (iotDeviceRunLogMapper.selectById(id) == null) {
+            throw exception(IOT_DEVICE_RUN_LOG_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public IotDeviceRunLogDO getIotDeviceRunLog(Long id) {
+        return iotDeviceRunLogMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<IotDeviceRunLogDO> getIotDeviceRunLogPage(IotDeviceRunLogPageReqVO pageReqVO) {
+        return iotDeviceRunLogMapper.selectPage(pageReqVO);
+    }
+
+}

+ 22 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/resources/mapper/static/IotDeviceMapper.xml

@@ -49,6 +49,8 @@
 
     <select id="deviceAssociateBomList"
             resultType="cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceRespVO">
+        SELECT *
+        FROM (
         SELECT
         t.id ,
         t.device_code,
@@ -79,5 +81,25 @@
                 #{key}
             </foreach>
         </if>
+        )t2
+        LEFT JOIN (
+        SELECT
+        l.device_id,
+        l.total_run_time,
+        l.total_mileage,
+        l.time
+        FROM rq_iot_device_run_log l
+        RIGHT JOIN (
+        SELECT
+        device_id,
+        MAX(time) AS latest_time,
+        MAX(id)	AS max_id
+        FROM rq_iot_device_run_log
+        GROUP BY device_id
+        ) AS latest
+        ON l.device_id = latest.device_id
+        AND l.time = latest.latest_time
+        AND l.id = latest.max_id
+        ) tmp ON tmp.device_id = t2.id
     </select>
 </mapper>