feat(mes): 添加MES数采功能支持MQTT设备数据采集
- 在application-kyzn.yaml、application-local.yaml和application-test.yaml中添加MES数采MQTT配置
- 新增数采相关错误码定义包括设备编号重复、未绑定等异常情况
- 扩展MesDvMachineryDO实体类增加数采设备编号和启用状态字段
- 更新导入导出Excel VO添加数采设备编号映射
- 修改MesDvMachineryMapper增加数采相关查询方法和条件筛选
- 在设备台账页面请求和响应对象中添加数采相关字段
- 实现数采设备编号唯一性校验逻辑防止重复绑定
- 添加数采报警记录数据对象和相关枚举定义
- 实现数采历史数据清理定时任务配置数据保留策略
- 新增数采监控控制器提供设备状态、实时数据、报警等查询接口
- 添加数采周期过程数据和报警记录的数据访问层实现
- 实现数采报文解析工具支持JSON数据格式化处理
| | |
| | | <artifactId>yudao-spring-boot-starter-excel</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- æ°é MQTT 客æ·ç«¯ --> |
| | | <dependency> |
| | | <groupId>org.eclipse.paho</groupId> |
| | | <artifactId>org.eclipse.paho.client.mqttv3</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- Test æµè¯ç¸å
³ --> |
| | | <dependency> |
| | | <groupId>cn.iocoder.boot</groupId> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.collect.vo.*; |
| | | import cn.iocoder.yudao.module.mes.service.collect.MesCollectQueryService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @Tag(name = "管çåå° - MES æ°éçæ§") |
| | | @RestController |
| | | @RequestMapping("/mes/collect") |
| | | @Validated |
| | | public class MesCollectController { |
| | | |
| | | @Resource |
| | | private MesCollectQueryService queryService; |
| | | |
| | | @GetMapping("/device/list") |
| | | @Operation(summary = "è·åæ°é设å¤ç¶æå表") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<List<MesCollectDeviceRespVO>> getDeviceList() { |
| | | return success(queryService.getDeviceList()); |
| | | } |
| | | |
| | | @GetMapping("/realtime/get") |
| | | @Operation(summary = "è·åè®¾å¤ææ°å®æ¶ç¶æ") |
| | | @Parameter(name = "deviceCode", description = "æ°é设å¤ç¼å·", required = true, example = "C01") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<MesCollectRealtimeRespVO> getRealtime(@RequestParam("deviceCode") String deviceCode) { |
| | | return success(queryService.getRealtime(deviceCode)); |
| | | } |
| | | |
| | | @GetMapping("/realtime/history-page") |
| | | @Operation(summary = "å页æ¥è¯¢å®æ¶ç¶æåå²") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<PageResult<MesCollectRealtimeRespVO>> getRealtimeHistoryPage( |
| | | @Valid MesCollectRealtimeHistoryPageReqVO reqVO) { |
| | | return success(queryService.getRealtimeHistoryPage(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/cycle/page") |
| | | @Operation(summary = "å页æ¥è¯¢å¨æè¿ç¨æ°æ®") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<PageResult<MesCollectCycleRespVO>> getCyclePage(@Valid MesCollectCyclePageReqVO reqVO) { |
| | | return success(queryService.getCyclePage(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/cycle/get") |
| | | @Operation(summary = "è·å卿è¿ç¨æ°æ®æç»") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<MesCollectCycleRespVO> getCycle(@RequestParam("id") Long id) { |
| | | return success(queryService.getCycle(id)); |
| | | } |
| | | |
| | | @GetMapping("/tech/get") |
| | | @Operation(summary = "è·åè®¾å¤ææ°å·¥èºåæ°å¿«ç
§") |
| | | @Parameter(name = "deviceCode", description = "æ°é设å¤ç¼å·", required = true, example = "C01") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<MesCollectTechRespVO> getTech(@RequestParam("deviceCode") String deviceCode) { |
| | | return success(queryService.getTech(deviceCode)); |
| | | } |
| | | |
| | | @GetMapping("/operate-log/page") |
| | | @Operation(summary = "å页æ¥è¯¢åæ°åæ´æ¥å¿") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<PageResult<MesCollectOperateLogRespVO>> getOperateLogPage( |
| | | @Valid MesCollectOperateLogPageReqVO reqVO) { |
| | | return success(queryService.getOperateLogPage(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/alarm/page") |
| | | @Operation(summary = "å页æ¥è¯¢æ¥è¦è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<PageResult<MesCollectAlarmRespVO>> getAlarmPage(@Valid MesCollectAlarmPageReqVO reqVO) { |
| | | return success(queryService.getAlarmPage(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/alarm/ack") |
| | | @Operation(summary = "人工确认æ¶é¤æ¥è¦") |
| | | @Parameter(name = "id", description = "æ¥è¦è®°å½ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect-alarm:ack')") |
| | | public CommonResult<Boolean> ackAlarm(@RequestParam("id") Long id) { |
| | | queryService.ackAlarm(id); |
| | | return success(true); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.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.time.LocalDateTime; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°éæ¥è¦å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesCollectAlarmPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | |
| | | @Schema(description = "ç¶æï¼0æªæ¶é¤ 1å·²æ¶é¤", example = "0") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "æ¥è¦æ¶é´") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] wmTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°éæ¥è¦ Response VO") |
| | | @Data |
| | | public class MesCollectAlarmRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "æ¥è¦æ è¯ï¼2产ç 0æ¶å¤±", example = "2") |
| | | private Integer wmId; |
| | | @Schema(description = "æ¥è¦å
容", example = "å®å
¨é¨æªå
³") |
| | | private String wmMsg; |
| | | @Schema(description = "æ¥è¦æ¶é´") |
| | | private LocalDateTime wmTime; |
| | | @Schema(description = "ç¶æï¼0æªæ¶é¤ 1å·²æ¶é¤", example = "0") |
| | | private Integer status; |
| | | @Schema(description = "ç¶æåç§°", example = "æªæ¶é¤") |
| | | private String statusName; |
| | | @Schema(description = "æ¶é¤æ¶é´") |
| | | private LocalDateTime clearTime; |
| | | @Schema(description = "æ¥æééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "宿´æ°æ® JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.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.time.LocalDateTime; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°é卿è¿ç¨å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesCollectCyclePageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | |
| | | @Schema(description = "ééæ¶é´") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] collectTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°é卿è¿ç¨æ°æ® Response VO") |
| | | @Data |
| | | public class MesCollectCycleRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "卿åºå·ï¼CYCNï¼", example = "100") |
| | | private Long cycleNo; |
| | | @Schema(description = "ééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "卿æ¶é´ï¼ECYCTï¼") |
| | | private BigDecimal ecyct; |
| | | @Schema(description = "å°åºèµ·ç¹ï¼EISSï¼") |
| | | private BigDecimal eiss; |
| | | @Schema(description = "æå¤§å°éï¼EIVMï¼") |
| | | private BigDecimal eivm; |
| | | @Schema(description = "æå¤§å°åï¼EIPMï¼") |
| | | private BigDecimal eipm; |
| | | @Schema(description = "转ä¿åæ¶é´ï¼ESIPTï¼") |
| | | private BigDecimal esipt; |
| | | @Schema(description = "转ä¿åååï¼ESIPPï¼") |
| | | private BigDecimal esipp; |
| | | @Schema(description = "转ä¿åä½ç½®ï¼ESIPSï¼") |
| | | private BigDecimal esips; |
| | | @Schema(description = "å°åºæ¶é´ï¼EIPTï¼") |
| | | private BigDecimal eipt; |
| | | @Schema(description = "å°åºç»ç¹ä½ç½®ï¼EIPSEï¼") |
| | | private BigDecimal eipse; |
| | | @Schema(description = "卿æ¶é´ï¼EPLSTï¼") |
| | | private BigDecimal eplst; |
| | | @Schema(description = "卿ç»ç¹ï¼EPLSSEï¼") |
| | | private BigDecimal eplsse; |
| | | @Schema(description = "æå¤§å¨æååï¼EPLSPMï¼") |
| | | private BigDecimal eplspm; |
| | | @Schema(description = "ç产温度 JSONï¼ET1..ETnï¼") |
| | | private String etTemps; |
| | | @Schema(description = "宿´æ°æ® JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°é设å¤ç¶æ Response VO") |
| | | @Data |
| | | public class MesCollectDeviceRespVO { |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "设å¤ç¼ç ", example = "MC_20260818001") |
| | | private String machineryCode; |
| | | @Schema(description = "设å¤åç§°", example = "æ³¨å¡æº 1 å·") |
| | | private String machineryName; |
| | | @Schema(description = "å·¥ä½ç«ç¼å·", example = "1") |
| | | private Long workstationId; |
| | | @Schema(description = "å·¥ä½ç«åç§°", example = "注å¡å·¥ä½ç«") |
| | | private String workstationName; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String collectDeviceCode; |
| | | @Schema(description = "æ¯å¦å¯ç¨æ°é", example = "true") |
| | | private Boolean collectEnabled; |
| | | @Schema(description = "æè¿ééæ¶é´") |
| | | private LocalDateTime lastCollectTime; |
| | | @Schema(description = "æ¯å¦å¨çº¿ï¼5 åéå
ææ°æ®ï¼", example = "true") |
| | | private Boolean online; |
| | | @Schema(description = "è¿è¡ç¶æï¼1å¾
æº 2ç产", example = "2") |
| | | private Integer sts; |
| | | @Schema(description = "è¿è¡ç¶æåç§°", example = "ç产") |
| | | private String stsName; |
| | | @Schema(description = "è¿è¡æ¨¡å¼ï¼0æå¨ 1åèªå¨ 2çµç¼èªå¨ 3æ¶é´èªå¨ 4è°æ¨¡ä½¿ç¨", example = "2") |
| | | private Integer opm; |
| | | @Schema(description = "è¿è¡æ¨¡å¼åç§°", example = "çµç¼èªå¨") |
| | | private String opmName; |
| | | @Schema(description = "油温", example = "26.5") |
| | | private BigDecimal ot; |
| | | @Schema(description = "åæ®µæ¸©åº¦ JSON") |
| | | private String temps; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产任å¡ç¼ç ", example = "PT202610200001") |
| | | private String taskCode; |
| | | @Schema(description = "ç产任å¡åç§°", example = "注å¡ä»»å¡") |
| | | private String taskName; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "ç产工åç¼ç ", example = "PO202610200001") |
| | | private String workOrderCode; |
| | | @Schema(description = "æªæ¶é¤æ¥è¦æ°é", example = "1") |
| | | private Long activeAlarmCount; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.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.time.LocalDateTime; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°éåæ°åæ´å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesCollectOperateLogPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | |
| | | @Schema(description = "åéç¼ç ", example = "SIPS") |
| | | private String varId; |
| | | |
| | | @Schema(description = "ä¿®æ¹æ¶é´") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] modifyTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°éåæ°åæ´ Response VO") |
| | | @Data |
| | | public class MesCollectOperateLogRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "åéç¼ç ", example = "SIPS") |
| | | private String varId; |
| | | @Schema(description = "ä¿®æ¹åçå¼", example = "37") |
| | | private String oldValue; |
| | | @Schema(description = "ä¿®æ¹åçå¼", example = "37.5") |
| | | private String newValue; |
| | | @Schema(description = "åæ°ä¿®æ¹æ¶é´") |
| | | private LocalDateTime modifyTime; |
| | | @Schema(description = "æ¥æééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "宿´æ°æ® JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.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.time.LocalDateTime; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°é宿¶åå²å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesCollectRealtimeHistoryPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | |
| | | @Schema(description = "ééæ¶é´") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] collectTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°é宿¶æ°æ® Response VO") |
| | | @Data |
| | | public class MesCollectRealtimeRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "ééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "è¿è¡ç¶æï¼1å¾
æº 2ç产", example = "2") |
| | | private Integer sts; |
| | | @Schema(description = "è¿è¡ç¶æåç§°", example = "ç产") |
| | | private String stsName; |
| | | @Schema(description = "è¿è¡æ¨¡å¼ï¼0æå¨ 1åèªå¨ 2çµç¼èªå¨ 3æ¶é´èªå¨ 4è°æ¨¡ä½¿ç¨", example = "2") |
| | | private Integer opm; |
| | | @Schema(description = "è¿è¡æ¨¡å¼åç§°", example = "çµç¼èªå¨") |
| | | private String opmName; |
| | | @Schema(description = "éå ç¶æ", example = "0") |
| | | private Integer asts; |
| | | @Schema(description = "油温", example = "26.5") |
| | | private BigDecimal ot; |
| | | @Schema(description = "åæ®µæ¸©åº¦ JSON") |
| | | private String temps; |
| | | @Schema(description = "宿´æ°æ® JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°éå·¥èºåæ° Response VO") |
| | | @Data |
| | | public class MesCollectTechRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "ééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "å·¥èºåæ°å®æ´å¿«ç
§ JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| | |
| | | @ExcelProperty("å·¥ä½ç«ç¼ç ") |
| | | private String workstationCode; |
| | | |
| | | @ExcelProperty("æ°é设å¤ç¼å·") |
| | | private String collectDeviceCode; |
| | | |
| | | } |
| | |
| | | @Schema(description = "å·¥ä½ç«ç¼å·", example = "300") |
| | | private Long workstationId; |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·ï¼MQTT devIdï¼", example = "C01") |
| | | private String collectDeviceCode; |
| | | |
| | | @Schema(description = "æ¯å¦å¯ç¨æ°é", example = "true") |
| | | private Boolean collectEnabled; |
| | | |
| | | } |
| | |
| | | @ExcelProperty("å·¥ä½ç«") |
| | | private String workstationName; |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·ï¼MQTT devIdï¼", example = "C01") |
| | | @ExcelProperty("æ°é设å¤ç¼å·") |
| | | private String collectDeviceCode; |
| | | |
| | | @Schema(description = "æ¯å¦å¯ç¨æ°é", example = "true") |
| | | @ExcelProperty("æ¯å¦å¯ç¨æ°é") |
| | | private Boolean collectEnabled; |
| | | |
| | | @Schema(description = "å建æ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @ExcelProperty("å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | |
| | | @Schema(description = "å·¥ä½ç«ç¼å·", example = "300") |
| | | private Long workstationId; |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·ï¼MQTT devIdï¼", example = "C01") |
| | | private String collectDeviceCode; |
| | | |
| | | @Schema(description = "æ¯å¦å¯ç¨æ°é", example = "true") |
| | | private Boolean collectEnabled; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-æ¥è¦è®°å½ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_alarm") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectAlarmDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private Integer wmId; |
| | | private String wmMsg; |
| | | private LocalDateTime wmTime; |
| | | private Integer status; |
| | | private LocalDateTime clearTime; |
| | | private LocalDateTime collectTime; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-卿è¿ç¨æ°æ® DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_cycle") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectCycleDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private Long cycleNo; |
| | | private LocalDateTime collectTime; |
| | | private BigDecimal ecyct; |
| | | private BigDecimal eiss; |
| | | private BigDecimal eivm; |
| | | private BigDecimal eipm; |
| | | private BigDecimal esipt; |
| | | private BigDecimal esipp; |
| | | private BigDecimal esips; |
| | | private BigDecimal eipt; |
| | | private BigDecimal eipse; |
| | | private BigDecimal eplst; |
| | | private BigDecimal eplsse; |
| | | private BigDecimal eplspm; |
| | | private String etTemps; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-åå§æ¥æ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_message") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectMessageDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private String mqttTopic; |
| | | private String msgType; |
| | | private LocalDateTime eventTime; |
| | | private String rawPayload; |
| | | private Integer processStatus; |
| | | private String errorMsg; |
| | | private LocalDateTime receiveTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-åæ°åæ´æ¥å¿ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_operate_log") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectOperateLogDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private String varId; |
| | | private String oldValue; |
| | | private String newValue; |
| | | private LocalDateTime modifyTime; |
| | | private LocalDateTime collectTime; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-设å¤å®æ¶ç¶æ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_realtime") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectRealtimeDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private LocalDateTime collectTime; |
| | | private Integer sts; |
| | | private Integer opm; |
| | | private Integer asts; |
| | | private BigDecimal ot; |
| | | private String temps; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-宿¶ç¶æåå² DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_realtime_history") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectRealtimeHistoryDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private LocalDateTime collectTime; |
| | | private Integer sts; |
| | | private Integer opm; |
| | | private Integer asts; |
| | | private BigDecimal ot; |
| | | private String temps; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-å·¥èºåæ°å¿«ç
§ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_tech") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectTechDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private LocalDateTime collectTime; |
| | | private String dataJson; |
| | | |
| | | } |
| | |
| | | * å
³è {@link cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO#getId()} |
| | | */ |
| | | private Long workstationId; |
| | | /** |
| | | * æ°é设å¤ç¼å·ï¼MQTT devIdï¼å¦ C01ï¼ |
| | | */ |
| | | private String collectDeviceCode; |
| | | /** |
| | | * æ¯å¦å¯ç¨æ°é |
| | | */ |
| | | private Boolean collectEnabled; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | 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.mes.controller.admin.collect.vo.MesCollectAlarmPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectAlarmDO; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-æ¥è¦è®°å½ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectAlarmMapper extends BaseMapperX<MesCollectAlarmDO> { |
| | | |
| | | default PageResult<MesCollectAlarmDO> selectPage(MesCollectAlarmPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesCollectAlarmDO>() |
| | | .eqIfPresent(MesCollectAlarmDO::getDeviceCode, reqVO.getDeviceCode()) |
| | | .eqIfPresent(MesCollectAlarmDO::getMachineryId, reqVO.getMachineryId()) |
| | | .eqIfPresent(MesCollectAlarmDO::getWorkOrderId, reqVO.getWorkOrderId()) |
| | | .eqIfPresent(MesCollectAlarmDO::getStatus, reqVO.getStatus()) |
| | | .betweenIfPresent(MesCollectAlarmDO::getWmTime, reqVO.getWmTime()) |
| | | .orderByDesc(MesCollectAlarmDO::getWmTime)); |
| | | } |
| | | |
| | | default Long selectActiveCountByDeviceCode(String deviceCode) { |
| | | return selectCount(new LambdaQueryWrapperX<MesCollectAlarmDO>() |
| | | .eq(MesCollectAlarmDO::getDeviceCode, deviceCode) |
| | | .eq(MesCollectAlarmDO::getStatus, 0)); |
| | | } |
| | | |
| | | default int clearActiveByDeviceCode(String deviceCode, LocalDateTime clearTime) { |
| | | return update(null, new LambdaUpdateWrapper<MesCollectAlarmDO>() |
| | | .eq(MesCollectAlarmDO::getDeviceCode, deviceCode) |
| | | .eq(MesCollectAlarmDO::getStatus, 0) |
| | | .set(MesCollectAlarmDO::getStatus, 1) |
| | | .set(MesCollectAlarmDO::getClearTime, clearTime)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | 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.mes.controller.admin.collect.vo.MesCollectCyclePageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectCycleDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES æ°é-卿è¿ç¨æ°æ® Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectCycleMapper extends BaseMapperX<MesCollectCycleDO> { |
| | | |
| | | default PageResult<MesCollectCycleDO> selectPage(MesCollectCyclePageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesCollectCycleDO>() |
| | | .eqIfPresent(MesCollectCycleDO::getDeviceCode, reqVO.getDeviceCode()) |
| | | .eqIfPresent(MesCollectCycleDO::getMachineryId, reqVO.getMachineryId()) |
| | | .eqIfPresent(MesCollectCycleDO::getTaskId, reqVO.getTaskId()) |
| | | .eqIfPresent(MesCollectCycleDO::getWorkOrderId, reqVO.getWorkOrderId()) |
| | | .betweenIfPresent(MesCollectCycleDO::getCollectTime, reqVO.getCollectTime()) |
| | | .orderByDesc(MesCollectCycleDO::getCollectTime)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectMessageDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-åå§æ¥æ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectMessageMapper extends BaseMapperX<MesCollectMessageDO> { |
| | | |
| | | default int deleteBefore(LocalDateTime before, int limit) { |
| | | return delete(new LambdaQueryWrapperX<MesCollectMessageDO>() |
| | | .lt(MesCollectMessageDO::getReceiveTime, before) |
| | | .last("LIMIT " + limit)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | 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.mes.controller.admin.collect.vo.MesCollectOperateLogPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectOperateLogDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES æ°é-åæ°åæ´æ¥å¿ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectOperateLogMapper extends BaseMapperX<MesCollectOperateLogDO> { |
| | | |
| | | default PageResult<MesCollectOperateLogDO> selectPage(MesCollectOperateLogPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesCollectOperateLogDO>() |
| | | .eqIfPresent(MesCollectOperateLogDO::getDeviceCode, reqVO.getDeviceCode()) |
| | | .eqIfPresent(MesCollectOperateLogDO::getMachineryId, reqVO.getMachineryId()) |
| | | .eqIfPresent(MesCollectOperateLogDO::getWorkOrderId, reqVO.getWorkOrderId()) |
| | | .eqIfPresent(MesCollectOperateLogDO::getVarId, reqVO.getVarId()) |
| | | .betweenIfPresent(MesCollectOperateLogDO::getModifyTime, reqVO.getModifyTime()) |
| | | .orderByDesc(MesCollectOperateLogDO::getModifyTime)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | 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.mes.controller.admin.collect.vo.MesCollectRealtimeHistoryPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectRealtimeHistoryDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-宿¶ç¶æåå² Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectRealtimeHistoryMapper extends BaseMapperX<MesCollectRealtimeHistoryDO> { |
| | | |
| | | default PageResult<MesCollectRealtimeHistoryDO> selectPage(MesCollectRealtimeHistoryPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesCollectRealtimeHistoryDO>() |
| | | .eqIfPresent(MesCollectRealtimeHistoryDO::getDeviceCode, reqVO.getDeviceCode()) |
| | | .eqIfPresent(MesCollectRealtimeHistoryDO::getMachineryId, reqVO.getMachineryId()) |
| | | .eqIfPresent(MesCollectRealtimeHistoryDO::getTaskId, reqVO.getTaskId()) |
| | | .eqIfPresent(MesCollectRealtimeHistoryDO::getWorkOrderId, reqVO.getWorkOrderId()) |
| | | .betweenIfPresent(MesCollectRealtimeHistoryDO::getCollectTime, reqVO.getCollectTime()) |
| | | .orderByDesc(MesCollectRealtimeHistoryDO::getCollectTime)); |
| | | } |
| | | |
| | | default int deleteBefore(LocalDateTime before, int limit) { |
| | | return delete(new LambdaQueryWrapperX<MesCollectRealtimeHistoryDO>() |
| | | .lt(MesCollectRealtimeHistoryDO::getCollectTime, before) |
| | | .last("LIMIT " + limit)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectRealtimeDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES æ°é-设å¤å®æ¶ç¶æ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectRealtimeMapper extends BaseMapperX<MesCollectRealtimeDO> { |
| | | |
| | | default MesCollectRealtimeDO selectByDeviceCode(String deviceCode) { |
| | | return selectOne(MesCollectRealtimeDO::getDeviceCode, deviceCode); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectTechDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES æ°é-å·¥èºåæ°å¿«ç
§ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectTechMapper extends BaseMapperX<MesCollectTechDO> { |
| | | |
| | | default MesCollectTechDO selectByDeviceCode(String deviceCode) { |
| | | return selectOne(MesCollectTechDO::getDeviceCode, deviceCode); |
| | | } |
| | | |
| | | } |
| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * MES 设å¤å°è´¦ Mapper |
| | | * |
| | |
| | | .inIfPresent(MesDvMachineryDO::getMachineryTypeId, reqVO.getMachineryTypeIds()) |
| | | .eqIfPresent(MesDvMachineryDO::getWorkshopId, reqVO.getWorkshopId()) |
| | | .eqIfPresent(MesDvMachineryDO::getWorkstationId, reqVO.getWorkstationId()) |
| | | .eqIfPresent(MesDvMachineryDO::getCollectDeviceCode, reqVO.getCollectDeviceCode()) |
| | | .eqIfPresent(MesDvMachineryDO::getCollectEnabled, reqVO.getCollectEnabled()) |
| | | .eqIfPresent(MesDvMachineryDO::getStatus, reqVO.getStatus()) |
| | | .orderByDesc(MesDvMachineryDO::getId)); |
| | | } |
| | |
| | | return selectOne(MesDvMachineryDO::getCode, code); |
| | | } |
| | | |
| | | default MesDvMachineryDO selectByCollectDeviceCode(String collectDeviceCode) { |
| | | return selectOne(MesDvMachineryDO::getCollectDeviceCode, collectDeviceCode); |
| | | } |
| | | |
| | | default List<MesDvMachineryDO> selectListWithCollectDeviceCode() { |
| | | return selectList(new LambdaQueryWrapperX<MesDvMachineryDO>() |
| | | .isNotNull(MesDvMachineryDO::getCollectDeviceCode) |
| | | .orderByAsc(MesDvMachineryDO::getId)); |
| | | } |
| | | |
| | | default Long selectCountByMachineryTypeId(Long machineryTypeId) { |
| | | return selectCount(MesDvMachineryDO::getMachineryTypeId, machineryTypeId); |
| | | } |
| | |
| | | return selectPage(reqVO, query); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å·¥ä½ç«ä¸æ£å¨è¿è¡çä»»å¡ï¼ç产ä¸ãé¨å宿ãå·²åå·¥ |
| | | */ |
| | | default MesProTaskDO selectRunningTaskByWorkstationId(Long workstationId) { |
| | | return selectOne(new LambdaQueryWrapperX<MesProTaskDO>() |
| | | .eq(MesProTaskDO::getWorkstationId, workstationId) |
| | | .in(MesProTaskDO::getStatus, MesProTaskStatusEnum.PRODUCING.getStatus(), |
| | | MesProTaskStatusEnum.PARTIAL_FINISHED.getStatus(), MesProTaskStatusEnum.PAUSED.getStatus()) |
| | | .orderByDesc(MesProTaskDO::getLastFeedbackTime) |
| | | .orderByDesc(MesProTaskDO::getId) |
| | | .last("LIMIT 1")); |
| | | } |
| | | |
| | | default List<MesProTaskDO> selectListByWorkOrderId(Long workOrderId) { |
| | | return selectList(new LambdaQueryWrapperX<MesProTaskDO>() |
| | | .eqIfPresent(MesProTaskDO::getWorkOrderId, workOrderId) |
| | |
| | | ErrorCode DV_MACHINERY_HAS_MAINTEN_RECORD = new ErrorCode(1_040_301_005, "设å¤å·²å
³èä¿å
»è®°å½ï¼æ æ³å é¤"); |
| | | ErrorCode DV_MACHINERY_HAS_REPAIR = new ErrorCode(1_040_301_006, "设å¤å·²å
³è维修工åï¼æ æ³å é¤"); |
| | | ErrorCode DV_MACHINERY_WORKSTATION_NOT_EXISTS = new ErrorCode(1_040_301_008, "å·¥ä½ç«ç¼ç ä¸åå¨"); |
| | | ErrorCode DV_MACHINERY_COLLECT_CODE_DUPLICATE = new ErrorCode(1_040_301_009, "æ°é设å¤ç¼å·å·²è¢«å
¶ä»è®¾å¤å ç¨"); |
| | | |
| | | // ========== MES 设å¤ç®¡ç-ç¹æ£ä¿å
»é¡¹ç®ï¼1-040-304-000ï¼ ========== |
| | | ErrorCode DV_SUBJECT_NOT_EXISTS = new ErrorCode(1_040_304_000, "ç¹æ£ä¿å
»é¡¹ç®ä¸åå¨"); |
| | |
| | | ErrorCode WMS_APPROVAL_STATUS_INVALID = new ErrorCode(1_040_900_004, "åæ®ç¶æä¸æ£ç¡®ï¼æ æ³æäº¤å®¡æ¹"); |
| | | ErrorCode WMS_APPROVAL_ALREADY_SUBMITTED = new ErrorCode(1_040_900_005, "忮已æäº¤å®¡æ¹ï¼è¯·å¿éå¤æäº¤"); |
| | | |
| | | // ========== MES 设å¤ç®¡ç-æ°éï¼1-040-920-000ï¼ ========== |
| | | ErrorCode COLLECT_DEVICE_NOT_BOUND = new ErrorCode(1_040_920_000, "æ°é设å¤[{}]æªç»å®è®¾å¤å°è´¦ï¼è¯·å
å¨è®¾å¤å°è´¦ç»´æ¤æ°é设å¤ç¼å·"); |
| | | ErrorCode COLLECT_ALARM_NOT_EXISTS = new ErrorCode(1_040_920_001, "æ¥è¦è®°å½ä¸åå¨"); |
| | | ErrorCode COLLECT_ALARM_ALREADY_CLEARED = new ErrorCode(1_040_920_002, "该æ¥è¦å·²æ¶é¤ï¼æ ééå¤ç¡®è®¤"); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.collect; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * MES æ°éæ¥è¦ç¶æ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum MesCollectAlarmStatusEnum { |
| | | |
| | | ACTIVE(0, "æªæ¶é¤"), |
| | | CLEARED(1, "å·²æ¶é¤"); |
| | | |
| | | private final Integer status; |
| | | private final String name; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.collect; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * MES æ°éæ¥æç±»å |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum MesCollectMsgTypeEnum { |
| | | |
| | | REALTIME("realtime", "宿¶æ°æ®"), |
| | | SPC("spc", "卿è¿ç¨æ°æ®"), |
| | | TECH("tech", "å·¥èºåæ°"), |
| | | OP_LOG("opLog", "åæ°åæ´æ¥å¿"), |
| | | ALARM("alarm", "æ¥è¦"), |
| | | UNKNOWN("unknown", "æªç¥ç±»å"); |
| | | |
| | | private final String type; |
| | | private final String name; |
| | | |
| | | public static MesCollectMsgTypeEnum getByType(String type) { |
| | | for (MesCollectMsgTypeEnum value : values()) { |
| | | if (value.type.equalsIgnoreCase(type)) { |
| | | return value; |
| | | } |
| | | } |
| | | return UNKNOWN; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.collect; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * MES æ°é设å¤è¿è¡æ¨¡å¼ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum MesCollectOperateModeEnum { |
| | | |
| | | MANUAL(0, "æå¨"), |
| | | SEMI_AUTO(1, "åèªå¨"), |
| | | EYE_AUTO(2, "çµç¼èªå¨"), |
| | | TIME_AUTO(3, "æ¶é´èªå¨"), |
| | | MOLD_ADJUST(4, "è°æ¨¡ä½¿ç¨"); |
| | | |
| | | private final Integer mode; |
| | | private final String name; |
| | | |
| | | public static String getNameByMode(Integer mode) { |
| | | if (mode == null) { |
| | | return null; |
| | | } |
| | | for (MesCollectOperateModeEnum value : values()) { |
| | | if (value.mode.equals(mode)) { |
| | | return value.name; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.collect; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * MES æ°é设å¤è¿è¡ç¶æ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum MesCollectRunStatusEnum { |
| | | |
| | | STANDBY(1, "å¾
æº"), |
| | | PRODUCING(2, "ç产"); |
| | | |
| | | private final Integer status; |
| | | private final String name; |
| | | |
| | | public static String getNameByStatus(Integer status) { |
| | | if (status == null) { |
| | | return null; |
| | | } |
| | | for (MesCollectRunStatusEnum value : values()) { |
| | | if (value.status.equals(status)) { |
| | | return value.name; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.framework.collect.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * MES æ°éé
ç½® |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @ConfigurationProperties(prefix = "yudao.mes.collect") |
| | | @Data |
| | | public class MesCollectProperties { |
| | | |
| | | private Mqtt mqtt = new Mqtt(); |
| | | private Retention retention = new Retention(); |
| | | |
| | | @Data |
| | | public static class Mqtt { |
| | | |
| | | /** |
| | | * æ¯å¦å¯ç¨æ°é MQTT 订é
|
| | | */ |
| | | private Boolean enabled = false; |
| | | /** |
| | | * Broker å°åï¼ä¾å¦ tcp://36.213.90.123:1883 |
| | | */ |
| | | private String url; |
| | | private String username; |
| | | private String password; |
| | | /** |
| | | * 客æ·ç«¯ ID åç¼ |
| | | */ |
| | | private String clientIdPrefix = "mes-collect"; |
| | | /** |
| | | * 主é¢åç¼ï¼ä¾å¦ /YLCY/IMM |
| | | */ |
| | | private String topicPrefix = "/YLCY/IMM"; |
| | | private Integer qos = 0; |
| | | private Integer keepAlive = 65; |
| | | private Integer connectionTimeout = 10; |
| | | /** |
| | | * æ¥è¦ä¸»é¢åç¼ï¼æ¥æ topic åæ®µæä¸»é¢æ«æ®µå½ä¸æ¶ææ¥è¦å¤ç |
| | | */ |
| | | private String alarmTopicSuffix = "wm"; |
| | | |
| | | } |
| | | |
| | | @Data |
| | | public static class Retention { |
| | | |
| | | /** |
| | | * åå§æ¥æä¿çå¤©æ° |
| | | */ |
| | | private Integer rawDays = 7; |
| | | /** |
| | | * 宿¶åå²ä¿çå¤©æ° |
| | | */ |
| | | private Integer realtimeDays = 30; |
| | | /** |
| | | * 忬¡æ¸
çæ¡æ° |
| | | */ |
| | | private Integer batchSize = 50000; |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.framework.collect.mqtt; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.mes.framework.collect.config.MesCollectProperties; |
| | | import cn.iocoder.yudao.module.mes.service.collect.MesCollectMessageDispatcher; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.paho.client.mqttv3.*; |
| | | import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; |
| | | import org.springframework.context.SmartLifecycle; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.ScheduledExecutorService; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * MES æ°é MQTT 客æ·ç«¯ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesCollectMqttClient implements SmartLifecycle { |
| | | |
| | | private static final long RECONNECT_DELAY_SECONDS = 30L; |
| | | |
| | | @Resource |
| | | private MesCollectProperties properties; |
| | | @Resource |
| | | private MesCollectMessageDispatcher dispatcher; |
| | | |
| | | private volatile boolean running = false; |
| | | private MqttClient client; |
| | | private ScheduledExecutorService scheduler; |
| | | |
| | | @Override |
| | | public void start() { |
| | | MesCollectProperties.Mqtt mqtt = properties.getMqtt(); |
| | | if (!Boolean.TRUE.equals(mqtt.getEnabled())) { |
| | | log.info("[start][æ°é MQTT æªå¯ç¨]"); |
| | | return; |
| | | } |
| | | if (StrUtil.isBlank(mqtt.getUrl())) { |
| | | log.warn("[start][æ°é MQTT å·²å¯ç¨ä½ url 为空ï¼è·³è¿è¿æ¥]"); |
| | | return; |
| | | } |
| | | running = true; |
| | | scheduler = Executors.newSingleThreadScheduledExecutor(runnable -> { |
| | | Thread thread = new Thread(runnable, "mes-collect-mqtt-reconnect"); |
| | | thread.setDaemon(true); |
| | | return thread; |
| | | }); |
| | | scheduler.scheduleWithFixedDelay(this::ensureConnected, 0, RECONNECT_DELAY_SECONDS, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | private void ensureConnected() { |
| | | if (!running) { |
| | | return; |
| | | } |
| | | MesCollectProperties.Mqtt mqtt = properties.getMqtt(); |
| | | try { |
| | | if (client == null) { |
| | | client = new MqttClient(mqtt.getUrl(), buildClientId(), new MemoryPersistence()); |
| | | client.setCallback(new MqttCallbackExtended() { |
| | | @Override |
| | | public void connectComplete(boolean reconnect, String serverURI) { |
| | | subscribe(); |
| | | } |
| | | |
| | | @Override |
| | | public void connectionLost(Throwable cause) { |
| | | log.warn("[connectionLost][æ°é MQTT è¿æ¥æå¼ï¼{}]", cause == null ? "æªç¥åå " : cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public void messageArrived(String topic, MqttMessage message) { |
| | | String payload = new String(message.getPayload(), StandardCharsets.UTF_8); |
| | | try { |
| | | dispatcher.dispatch(topic, payload); |
| | | } catch (Exception e) { |
| | | log.error("[messageArrived][主é¢({}) å
¥é失败]", topic, e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deliveryComplete(IMqttDeliveryToken token) { |
| | | // å½ååªè®¢é
ï¼ä¸åå¸ |
| | | } |
| | | }); |
| | | } |
| | | if (!client.isConnected()) { |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | | options.setAutomaticReconnect(true); |
| | | options.setCleanSession(true); |
| | | options.setKeepAliveInterval(mqtt.getKeepAlive()); |
| | | options.setConnectionTimeout(mqtt.getConnectionTimeout()); |
| | | if (StrUtil.isNotBlank(mqtt.getUsername())) { |
| | | options.setUserName(mqtt.getUsername()); |
| | | } |
| | | if (mqtt.getPassword() != null) { |
| | | options.setPassword(mqtt.getPassword().toCharArray()); |
| | | } |
| | | client.connect(options); |
| | | log.info("[ensureConnected][æ°é MQTT å·²è¿æ¥ï¼{}]", mqtt.getUrl()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("[ensureConnected][æ°é MQTT è¿æ¥/订é
失败ï¼{} ç§åéè¯ï¼{}]", |
| | | RECONNECT_DELAY_SECONDS, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | private void subscribe() { |
| | | MesCollectProperties.Mqtt mqtt = properties.getMqtt(); |
| | | String topic = normalizeTopicPrefix(mqtt.getTopicPrefix()) + "+/+"; |
| | | try { |
| | | client.subscribe(topic, mqtt.getQos()); |
| | | log.info("[subscribe][æ°é MQTT 订é
æåï¼{}]", topic); |
| | | } catch (Exception e) { |
| | | log.error("[subscribe][æ°é MQTT 订é
失败ï¼{}]", topic, e); |
| | | } |
| | | } |
| | | |
| | | private String normalizeTopicPrefix(String prefix) { |
| | | if (StrUtil.isBlank(prefix)) { |
| | | return ""; |
| | | } |
| | | return prefix.endsWith("/") ? prefix : prefix + "/"; |
| | | } |
| | | |
| | | private String buildClientId() { |
| | | String host; |
| | | try { |
| | | host = InetAddress.getLocalHost().getHostName(); |
| | | } catch (Exception e) { |
| | | host = "host"; |
| | | } |
| | | host = host.replaceAll("[^a-zA-Z0-9_-]", "_"); |
| | | String clientId = properties.getMqtt().getClientIdPrefix() + "-" + host + "-" |
| | | + Long.toHexString(System.nanoTime()); |
| | | return StrUtil.maxLength(clientId, 64); |
| | | } |
| | | |
| | | @Override |
| | | public void stop() { |
| | | running = false; |
| | | if (scheduler != null) { |
| | | scheduler.shutdownNow(); |
| | | scheduler = null; |
| | | } |
| | | if (client != null) { |
| | | try { |
| | | if (client.isConnected()) { |
| | | client.disconnect(); |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("[stop][æ°é MQTT æå¼å¤±è´¥ï¼{}]", e.getMessage()); |
| | | } |
| | | try { |
| | | client.close(true); |
| | | } catch (Exception e) { |
| | | log.warn("[stop][æ°é MQTT å
³é失败ï¼{}]", e.getMessage()); |
| | | } |
| | | client = null; |
| | | } |
| | | log.info("[stop][æ°é MQTT 已忢]"); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isRunning() { |
| | | return running; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.job.collect; |
| | | |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.collect.MesCollectMessageMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.collect.MesCollectRealtimeHistoryMapper; |
| | | import cn.iocoder.yudao.module.mes.framework.collect.config.MesCollectProperties; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°éå岿°æ®æ¸
çä»»å¡ |
| | | * |
| | | * <p>åå§æ¥æä¿ç 7 天ï¼å®æ¶åå²ä¿ç 30 å¤©ï¼æ¯æ¥ 03:30 æ§è¡ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesCollectCleanupJob { |
| | | |
| | | @Resource |
| | | private MesCollectProperties properties; |
| | | @Resource |
| | | private MesCollectMessageMapper messageMapper; |
| | | @Resource |
| | | private MesCollectRealtimeHistoryMapper realtimeHistoryMapper; |
| | | |
| | | @Scheduled(cron = "0 30 3 * * ?") |
| | | public void execute() { |
| | | MesCollectProperties.Retention retention = properties.getRetention(); |
| | | int batchSize = retention.getBatchSize() == null || retention.getBatchSize() <= 0 |
| | | ? 50000 : retention.getBatchSize(); |
| | | int rawDeleted = deleteInBatches(() -> messageMapper.deleteBefore( |
| | | LocalDateTime.now().minusDays(retention.getRawDays()), batchSize), batchSize); |
| | | int realtimeDeleted = deleteInBatches(() -> realtimeHistoryMapper.deleteBefore( |
| | | LocalDateTime.now().minusDays(retention.getRealtimeDays()), batchSize), batchSize); |
| | | log.info("[execute][æ°éå岿¸
ç宿ï¼åå§æ¥æ {} æ¡ï¼å®æ¶åå² {} æ¡]", rawDeleted, realtimeDeleted); |
| | | } |
| | | |
| | | private int deleteInBatches(DeleteAction action, int batchSize) { |
| | | int total = 0; |
| | | int deleted; |
| | | do { |
| | | deleted = action.delete(); |
| | | total += deleted; |
| | | } while (deleted >= batchSize); |
| | | return total; |
| | | } |
| | | |
| | | @FunctionalInterface |
| | | private interface DeleteAction { |
| | | int delete(); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectMsgTypeEnum; |
| | | import tools.jackson.databind.JsonNode; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * MES æ°éæ¥æè§£æå·¥å
· |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesCollectDataParser { |
| | | |
| | | private static final DateTimeFormatter DATE_TIME_FORMATTER = |
| | | DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss[.SSS]"); |
| | | |
| | | public JsonNode parsePayload(String payload) { |
| | | return JsonUtils.parseTree(payload); |
| | | } |
| | | |
| | | public JsonNode parseData(JsonNode root) { |
| | | JsonNode data = root.get("Data"); |
| | | if (data != null && data.isTextual()) { |
| | | try { |
| | | data = JsonUtils.parseTree(data.asText()); |
| | | } catch (Exception e) { |
| | | log.warn("[parseData][Data åæ®µä¸æ¯åæ³ JSONï¼æåæå¤çï¼{}]", StrUtil.maxLength(data.asText(), 200)); |
| | | return root; |
| | | } |
| | | } |
| | | return data != null && data.isObject() ? data : root; |
| | | } |
| | | |
| | | public String getText(JsonNode node, String field) { |
| | | JsonNode value = node.get(field); |
| | | return value == null || value.isNull() ? null : value.asText(); |
| | | } |
| | | |
| | | public Integer getInteger(JsonNode node, String field) { |
| | | JsonNode value = node.get(field); |
| | | if (value == null || value.isNull()) { |
| | | return null; |
| | | } |
| | | if (value.isNumber()) { |
| | | return value.intValue(); |
| | | } |
| | | try { |
| | | return Integer.valueOf(value.asText().trim()); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public Long getLong(JsonNode node, String field) { |
| | | JsonNode value = node.get(field); |
| | | if (value == null || value.isNull()) { |
| | | return null; |
| | | } |
| | | if (value.isNumber()) { |
| | | return value.longValue(); |
| | | } |
| | | try { |
| | | return Long.valueOf(value.asText().trim()); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public BigDecimal getDecimal(JsonNode node, String field) { |
| | | JsonNode value = node.get(field); |
| | | if (value == null || value.isNull()) { |
| | | return null; |
| | | } |
| | | if (value.isNumber()) { |
| | | return value.decimalValue(); |
| | | } |
| | | try { |
| | | return new BigDecimal(value.asText().trim()); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æåæå®åç¼ + æ°åçåæ®µï¼å¦ T1..TnãET1..ETn |
| | | */ |
| | | public String extractNumberedFields(JsonNode data, String prefix) { |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | data.properties().forEach(entry -> { |
| | | String name = entry.getKey(); |
| | | if (!name.startsWith(prefix) || name.length() == prefix.length()) { |
| | | return; |
| | | } |
| | | String suffix = name.substring(prefix.length()); |
| | | if (!suffix.chars().allMatch(Character::isDigit)) { |
| | | return; |
| | | } |
| | | JsonNode value = entry.getValue(); |
| | | result.put(name, value != null && value.isNumber() ? value.decimalValue() : value == null ? null : value.asText()); |
| | | }); |
| | | if (result.isEmpty()) { |
| | | return null; |
| | | } |
| | | return JsonUtils.toJsonString(result); |
| | | } |
| | | |
| | | public LocalDateTime parseEventTime(JsonNode root) { |
| | | LocalDateTime time = parseTimeText(getText(root, "time")); |
| | | if (time != null) { |
| | | return time; |
| | | } |
| | | Long timestamp = getLong(root, "timestamp"); |
| | | if (timestamp == null) { |
| | | timestamp = getLong(root, "sendStamp"); |
| | | } |
| | | if (timestamp != null && timestamp > 0) { |
| | | Instant instant = timestamp > 1_000_000_000_000L |
| | | ? Instant.ofEpochMilli(timestamp) : Instant.ofEpochSecond(timestamp); |
| | | return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); |
| | | } |
| | | return LocalDateTime.now(); |
| | | } |
| | | |
| | | public LocalDateTime parseTimeText(String text) { |
| | | if (StrUtil.isBlank(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return LocalDateTime.parse(text.trim(), DATE_TIME_FORMATTER); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public String valueToString(JsonNode value) { |
| | | if (value == null || value.isNull()) { |
| | | return null; |
| | | } |
| | | return value.isValueNode() ? value.asText() : value.toString(); |
| | | } |
| | | |
| | | public MesCollectMsgTypeEnum resolveMsgType(String topicField, String mqttTopic, |
| | | JsonNode data, String alarmTopicSuffix) { |
| | | MesCollectMsgTypeEnum type = MesCollectMsgTypeEnum.getByType(topicField); |
| | | if (type != MesCollectMsgTypeEnum.UNKNOWN) { |
| | | return type; |
| | | } |
| | | if (StrUtil.isNotBlank(topicField) && StrUtil.equalsIgnoreCase(topicField, alarmTopicSuffix)) { |
| | | return MesCollectMsgTypeEnum.ALARM; |
| | | } |
| | | String suffix = extractTopicSuffix(mqttTopic); |
| | | if (StrUtil.isNotBlank(suffix)) { |
| | | type = MesCollectMsgTypeEnum.getByType(suffix); |
| | | if (type != MesCollectMsgTypeEnum.UNKNOWN) { |
| | | return type; |
| | | } |
| | | if (StrUtil.equalsIgnoreCase(suffix, alarmTopicSuffix)) { |
| | | return MesCollectMsgTypeEnum.ALARM; |
| | | } |
| | | } |
| | | if (data == null) { |
| | | return MesCollectMsgTypeEnum.UNKNOWN; |
| | | } |
| | | if (data.has("wmId")) { |
| | | return MesCollectMsgTypeEnum.ALARM; |
| | | } |
| | | if (data.has("varId")) { |
| | | return MesCollectMsgTypeEnum.OP_LOG; |
| | | } |
| | | if (data.has("CYCN")) { |
| | | return MesCollectMsgTypeEnum.SPC; |
| | | } |
| | | if (data.has("STS") || data.has("OPM")) { |
| | | return MesCollectMsgTypeEnum.REALTIME; |
| | | } |
| | | if (data.has("TS1") || data.has("CP1M")) { |
| | | return MesCollectMsgTypeEnum.TECH; |
| | | } |
| | | return MesCollectMsgTypeEnum.UNKNOWN; |
| | | } |
| | | |
| | | public String resolveDeviceId(JsonNode root, String mqttTopic) { |
| | | String deviceId = getText(root, "devId"); |
| | | if (StrUtil.isNotBlank(deviceId)) { |
| | | return deviceId.trim(); |
| | | } |
| | | String[] parts = mqttTopic == null ? new String[0] : mqttTopic.split("/"); |
| | | return parts.length >= 2 ? parts[parts.length - 2] : null; |
| | | } |
| | | |
| | | private String extractTopicSuffix(String mqttTopic) { |
| | | if (StrUtil.isBlank(mqttTopic)) { |
| | | return null; |
| | | } |
| | | String[] parts = mqttTopic.split("/"); |
| | | return parts.length == 0 ? null : parts[parts.length - 1]; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.*; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.collect.*; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectAlarmStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectMsgTypeEnum; |
| | | import tools.jackson.databind.JsonNode; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.dao.DuplicateKeyException; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°éæ°æ®è½åº Service |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class MesCollectDataService { |
| | | |
| | | @Resource |
| | | private MesCollectDataParser parser; |
| | | @Resource |
| | | private MesCollectMessageMapper messageMapper; |
| | | @Resource |
| | | private MesCollectRealtimeMapper realtimeMapper; |
| | | @Resource |
| | | private MesCollectRealtimeHistoryMapper realtimeHistoryMapper; |
| | | @Resource |
| | | private MesCollectCycleMapper cycleMapper; |
| | | @Resource |
| | | private MesCollectTechMapper techMapper; |
| | | @Resource |
| | | private MesCollectOperateLogMapper collectOperateLogMapper; |
| | | @Resource |
| | | private MesCollectAlarmMapper alarmMapper; |
| | | |
| | | public Long saveRawMessage(String deviceCode, Long machineryId, String mqttTopic, |
| | | MesCollectMsgTypeEnum msgType, LocalDateTime eventTime, String payload) { |
| | | MesCollectMessageDO message = MesCollectMessageDO.builder() |
| | | .deviceCode(deviceCode).machineryId(machineryId).mqttTopic(mqttTopic) |
| | | .msgType(msgType.getType()).eventTime(eventTime).rawPayload(payload) |
| | | .processStatus(0).receiveTime(LocalDateTime.now()).build(); |
| | | messageMapper.insert(message); |
| | | return message.getId(); |
| | | } |
| | | |
| | | public void markRawMessageFailed(Long id, String error) { |
| | | if (id == null) { |
| | | return; |
| | | } |
| | | messageMapper.updateById(MesCollectMessageDO.builder() |
| | | .id(id).processStatus(1).errorMsg(StrUtil.maxLength(error, 1000)).build()); |
| | | } |
| | | |
| | | public void saveRealtime(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | MesCollectRealtimeDO snapshot = MesCollectRealtimeDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .collectTime(eventTime) |
| | | .sts(parser.getInteger(data, "STS")) |
| | | .opm(parser.getInteger(data, "OPM")) |
| | | .asts(parser.getInteger(data, "ASTS")) |
| | | .ot(parser.getDecimal(data, "OT")) |
| | | .temps(parser.extractNumberedFields(data, "T")) |
| | | .dataJson(data.toString()) |
| | | .build(); |
| | | MesCollectRealtimeDO existing = realtimeMapper.selectByDeviceCode(deviceCode); |
| | | if (existing != null) { |
| | | snapshot.setId(existing.getId()); |
| | | realtimeMapper.updateById(snapshot); |
| | | } else { |
| | | try { |
| | | realtimeMapper.insert(snapshot); |
| | | } catch (DuplicateKeyException e) { |
| | | MesCollectRealtimeDO current = realtimeMapper.selectByDeviceCode(deviceCode); |
| | | if (current != null) { |
| | | snapshot.setId(current.getId()); |
| | | realtimeMapper.updateById(snapshot); |
| | | } |
| | | } |
| | | } |
| | | |
| | | MesCollectRealtimeHistoryDO history = MesCollectRealtimeHistoryDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .collectTime(eventTime) |
| | | .sts(snapshot.getSts()) |
| | | .opm(snapshot.getOpm()) |
| | | .asts(snapshot.getAsts()) |
| | | .ot(snapshot.getOt()) |
| | | .temps(snapshot.getTemps()) |
| | | .dataJson(snapshot.getDataJson()) |
| | | .build(); |
| | | try { |
| | | realtimeHistoryMapper.insert(history); |
| | | } catch (DuplicateKeyException ignored) { |
| | | // åä¸è®¾å¤åä¸ç§çé夿¥æï¼ç´æ¥å¿½ç¥ |
| | | } |
| | | } |
| | | |
| | | public void saveCycle(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | Long cycleNo = parser.getLong(data, "CYCN"); |
| | | MesCollectCycleDO cycle = MesCollectCycleDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .cycleNo(cycleNo == null ? 0L : cycleNo) |
| | | .collectTime(eventTime) |
| | | .ecyct(parser.getDecimal(data, "ECYCT")) |
| | | .eiss(parser.getDecimal(data, "EISS")) |
| | | .eivm(parser.getDecimal(data, "EIVM")) |
| | | .eipm(parser.getDecimal(data, "EIPM")) |
| | | .esipt(parser.getDecimal(data, "ESIPT")) |
| | | .esipp(parser.getDecimal(data, "ESIPP")) |
| | | .esips(parser.getDecimal(data, "ESIPS")) |
| | | .eipt(parser.getDecimal(data, "EIPT")) |
| | | .eipse(parser.getDecimal(data, "EIPSE")) |
| | | .eplst(parser.getDecimal(data, "EPLST")) |
| | | .eplsse(parser.getDecimal(data, "EPLSSE")) |
| | | .eplspm(parser.getDecimal(data, "EPLSPM")) |
| | | .etTemps(parser.extractNumberedFields(data, "ET")) |
| | | .dataJson(data.toString()) |
| | | .build(); |
| | | try { |
| | | cycleMapper.insert(cycle); |
| | | } catch (DuplicateKeyException ignored) { |
| | | // åä¸å¨æéå¤ä¸æ¥ï¼ç´æ¥å¿½ç¥ |
| | | } |
| | | } |
| | | |
| | | public void saveTech(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | MesCollectTechDO tech = MesCollectTechDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .collectTime(eventTime).dataJson(data.toString()).build(); |
| | | MesCollectTechDO existing = techMapper.selectByDeviceCode(deviceCode); |
| | | if (existing != null) { |
| | | tech.setId(existing.getId()); |
| | | techMapper.updateById(tech); |
| | | } else { |
| | | try { |
| | | techMapper.insert(tech); |
| | | } catch (DuplicateKeyException e) { |
| | | MesCollectTechDO current = techMapper.selectByDeviceCode(deviceCode); |
| | | if (current != null) { |
| | | tech.setId(current.getId()); |
| | | techMapper.updateById(tech); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void saveOperateLog(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | LocalDateTime modifyTime = parser.parseTimeText(parser.getText(data, "modifyTime")); |
| | | collectOperateLogMapper.insert(MesCollectOperateLogDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .varId(parser.getText(data, "varId")) |
| | | .oldValue(StrUtil.maxLength(parser.valueToString(data.get("lastValue")), 500)) |
| | | .newValue(StrUtil.maxLength(parser.valueToString(data.get("value")), 500)) |
| | | .modifyTime(modifyTime == null ? eventTime : modifyTime) |
| | | .collectTime(eventTime).dataJson(data.toString()) |
| | | .build()); |
| | | } |
| | | |
| | | public void saveAlarm(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | Integer wmId = parser.getInteger(data, "wmId"); |
| | | LocalDateTime wmTime = parser.parseTimeText(parser.getText(data, "wmTime")); |
| | | if (wmTime == null) { |
| | | wmTime = eventTime; |
| | | } |
| | | if (wmId != null && wmId == 0) { |
| | | alarmMapper.clearActiveByDeviceCode(deviceCode, wmTime); |
| | | return; |
| | | } |
| | | alarmMapper.insert(MesCollectAlarmDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .wmId(wmId) |
| | | .wmMsg(StrUtil.maxLength(parser.getText(data, "wmMsg"), 500)) |
| | | .wmTime(wmTime) |
| | | .status(MesCollectAlarmStatusEnum.ACTIVE.getStatus()) |
| | | .collectTime(eventTime).dataJson(data.toString()) |
| | | .build()); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectMsgTypeEnum; |
| | | import cn.iocoder.yudao.module.mes.framework.collect.config.MesCollectProperties; |
| | | import tools.jackson.databind.JsonNode; |
| | | import jakarta.annotation.PreDestroy; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.concurrent.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | * MES æ°éæ¥æååå¨ |
| | | * |
| | | * <p>Paho åè°çº¿ç¨åªè´è´£å
¥éï¼è§£æä¸è½åºå¨å线ç¨ä¸ä¸²è¡æ§è¡ï¼ä¿è¯åä¸è®¾å¤æ¥è¦çç¶ææé¡ºåºå¤çã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesCollectMessageDispatcher { |
| | | |
| | | @Resource |
| | | private MesCollectProperties properties; |
| | | @Resource |
| | | private MesCollectDataParser parser; |
| | | @Resource |
| | | private MesCollectDataService dataService; |
| | | @Resource |
| | | private MesDvMachineryMapper machineryMapper; |
| | | @Resource |
| | | private MesCollectTaskResolver taskResolver; |
| | | |
| | | private final ExecutorService executor = new ThreadPoolExecutor(1, 1, |
| | | 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(10_000), |
| | | new ThreadFactory() { |
| | | private final AtomicInteger index = new AtomicInteger(); |
| | | |
| | | @Override |
| | | public Thread newThread(Runnable runnable) { |
| | | Thread thread = new Thread(runnable, "mes-collect-dispatch-" + index.incrementAndGet()); |
| | | thread.setDaemon(true); |
| | | return thread; |
| | | } |
| | | }, new ThreadPoolExecutor.CallerRunsPolicy()); |
| | | |
| | | /** |
| | | * è®¾å¤æªç»å®å°è´¦æ¶çåè¦ç¼åï¼é¿å
æ¯æ¡æ¥æéå¤å·æ¥å¿ |
| | | */ |
| | | private final ConcurrentHashMap<String, Long> unboundWarnCache = new ConcurrentHashMap<>(); |
| | | |
| | | public void dispatch(String topic, String payload) { |
| | | executor.execute(() -> process(topic, payload)); |
| | | } |
| | | |
| | | private void process(String topic, String payload) { |
| | | JsonNode root; |
| | | try { |
| | | root = parser.parsePayload(payload); |
| | | } catch (Exception e) { |
| | | log.warn("[process][主é¢({}) æ¥æä¸æ¯åæ³ JSONï¼{}]", topic, StrUtil.maxLength(payload, 200)); |
| | | dataService.markRawMessageFailed( |
| | | dataService.saveRawMessage(null, null, topic, MesCollectMsgTypeEnum.UNKNOWN, |
| | | LocalDateTime.now(), payload), |
| | | "æ¥æä¸æ¯åæ³ JSONï¼" + e.getMessage()); |
| | | return; |
| | | } |
| | | |
| | | JsonNode data = parser.parseData(root); |
| | | MesCollectMsgTypeEnum msgType = parser.resolveMsgType(parser.getText(root, "topic"), topic, data, |
| | | properties.getMqtt().getAlarmTopicSuffix()); |
| | | String deviceCode = parser.resolveDeviceId(root, topic); |
| | | LocalDateTime eventTime = parser.parseEventTime(root); |
| | | |
| | | MesDvMachineryDO machinery = StrUtil.isBlank(deviceCode) ? null |
| | | : machineryMapper.selectByCollectDeviceCode(deviceCode); |
| | | if (machinery == null && StrUtil.isNotBlank(deviceCode)) { |
| | | warnUnboundDevice(deviceCode); |
| | | } |
| | | Long machineryId = machinery == null ? null : machinery.getId(); |
| | | Long taskId = null; |
| | | Long workOrderId = null; |
| | | if (machinery != null && machinery.getWorkstationId() != null) { |
| | | MesProTaskDO task = taskResolver.resolve(machinery.getWorkstationId()); |
| | | if (task != null) { |
| | | taskId = task.getId(); |
| | | workOrderId = task.getWorkOrderId(); |
| | | } |
| | | } |
| | | |
| | | Long rawId = dataService.saveRawMessage(deviceCode, machineryId, topic, msgType, eventTime, payload); |
| | | try { |
| | | switch (msgType) { |
| | | case REALTIME -> dataService.saveRealtime(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | case SPC -> dataService.saveCycle(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | case TECH -> dataService.saveTech(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | case OP_LOG -> dataService.saveOperateLog(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | case ALARM -> dataService.saveAlarm(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | default -> log.debug("[process][å¿½ç¥æªç¥ç±»åæ¥æï¼ä¸»é¢({})]", topic); |
| | | } |
| | | } catch (Exception e) { |
| | | dataService.markRawMessageFailed(rawId, e.getMessage()); |
| | | log.error("[process][主é¢({}) 设å¤({}) å¤ç失败]", topic, deviceCode, e); |
| | | } |
| | | } |
| | | |
| | | private void warnUnboundDevice(String deviceCode) { |
| | | long now = System.currentTimeMillis(); |
| | | Long last = unboundWarnCache.get(deviceCode); |
| | | if (last != null && now - last < 60_000L) { |
| | | return; |
| | | } |
| | | unboundWarnCache.put(deviceCode, now); |
| | | log.warn("[process][æ°é设å¤({}) æªç»å®ä»»ä½è®¾å¤å°è´¦ï¼æ°æ®å°æè®¾å¤ç¼å·è½åºï¼machineryId 为空]", deviceCode); |
| | | } |
| | | |
| | | @PreDestroy |
| | | public void destroy() { |
| | | executor.shutdownNow(); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.collect.vo.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.collect.*; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectAlarmStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectOperateModeEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectRunStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.COLLECT_ALARM_ALREADY_CLEARED; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.COLLECT_ALARM_NOT_EXISTS; |
| | | |
| | | /** |
| | | * MES æ°éæ°æ®æ¥è¯¢ Service å®ç°ç±» |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class MesCollectQueryService { |
| | | |
| | | /** |
| | | * è¶
è¿è¯¥æ¶é¿æªééæ°æ®è§ä¸ºç¦»çº¿ |
| | | */ |
| | | private static final long ONLINE_TIMEOUT_MINUTES = 5L; |
| | | |
| | | @Resource |
| | | private MesDvMachineryMapper machineryMapper; |
| | | @Resource |
| | | private MesCollectRealtimeMapper realtimeMapper; |
| | | @Resource |
| | | private MesCollectRealtimeHistoryMapper realtimeHistoryMapper; |
| | | @Resource |
| | | private MesCollectCycleMapper cycleMapper; |
| | | @Resource |
| | | private MesCollectTechMapper techMapper; |
| | | @Resource |
| | | private MesCollectOperateLogMapper collectOperateLogMapper; |
| | | @Resource |
| | | private MesCollectAlarmMapper alarmMapper; |
| | | @Resource |
| | | private MesProWorkOrderMapper workOrderMapper; |
| | | @Resource |
| | | private MesCollectTaskResolver taskResolver; |
| | | @Resource |
| | | private MesMdWorkstationService workstationService; |
| | | |
| | | /** |
| | | * è·åå·²é
ç½®æ°éç¼ç ç设å¤å®æ¶ç¶æå表 |
| | | */ |
| | | public List<MesCollectDeviceRespVO> getDeviceList() { |
| | | List<MesDvMachineryDO> machineries = machineryMapper.selectListWithCollectDeviceCode(); |
| | | Map<Long, MesMdWorkstationDO> workstationMap = workstationService.getWorkstationMap( |
| | | machineries.stream().map(MesDvMachineryDO::getWorkstationId).filter(Objects::nonNull).toList()); |
| | | return machineries.stream().map(machinery -> { |
| | | MesCollectDeviceRespVO vo = new MesCollectDeviceRespVO(); |
| | | vo.setMachineryId(machinery.getId()); |
| | | vo.setMachineryCode(machinery.getCode()); |
| | | vo.setMachineryName(machinery.getName()); |
| | | vo.setCollectDeviceCode(machinery.getCollectDeviceCode()); |
| | | vo.setCollectEnabled(Boolean.TRUE.equals(machinery.getCollectEnabled())); |
| | | MesMdWorkstationDO workstation = workstationMap.get(machinery.getWorkstationId()); |
| | | if (workstation != null) { |
| | | vo.setWorkstationId(workstation.getId()); |
| | | vo.setWorkstationName(workstation.getName()); |
| | | } |
| | | |
| | | MesCollectRealtimeDO realtime = realtimeMapper.selectByDeviceCode(machinery.getCollectDeviceCode()); |
| | | if (realtime != null) { |
| | | vo.setLastCollectTime(realtime.getCollectTime()); |
| | | vo.setOnline(realtime.getCollectTime() != null |
| | | && realtime.getCollectTime().isAfter(LocalDateTime.now().minusMinutes(ONLINE_TIMEOUT_MINUTES))); |
| | | vo.setSts(realtime.getSts()); |
| | | vo.setStsName(MesCollectRunStatusEnum.getNameByStatus(realtime.getSts())); |
| | | vo.setOpm(realtime.getOpm()); |
| | | vo.setOpmName(MesCollectOperateModeEnum.getNameByMode(realtime.getOpm())); |
| | | vo.setOt(realtime.getOt()); |
| | | vo.setTemps(realtime.getTemps()); |
| | | } else { |
| | | vo.setOnline(false); |
| | | } |
| | | |
| | | MesProTaskDO task = taskResolver.resolve(machinery.getWorkstationId()); |
| | | if (task != null) { |
| | | vo.setTaskId(task.getId()); |
| | | vo.setTaskCode(task.getCode()); |
| | | vo.setTaskName(task.getName()); |
| | | vo.setWorkOrderId(task.getWorkOrderId()); |
| | | MesProWorkOrderDO workOrder = task.getWorkOrderId() != null |
| | | ? workOrderMapper.selectById(task.getWorkOrderId()) : null; |
| | | if (workOrder != null) { |
| | | vo.setWorkOrderCode(workOrder.getCode()); |
| | | } |
| | | } |
| | | vo.setActiveAlarmCount(alarmMapper.selectActiveCountByDeviceCode(machinery.getCollectDeviceCode())); |
| | | return vo; |
| | | }).toList(); |
| | | } |
| | | |
| | | /** |
| | | * è·åæå®æ°é设å¤ç宿¶ç¶æå¿«ç
§ |
| | | */ |
| | | public MesCollectRealtimeRespVO getRealtime(String deviceCode) { |
| | | MesCollectRealtimeDO realtime = realtimeMapper.selectByDeviceCode(deviceCode); |
| | | if (realtime == null) { |
| | | return null; |
| | | } |
| | | MesCollectRealtimeRespVO vo = BeanUtils.toBean(realtime, MesCollectRealtimeRespVO.class); |
| | | vo.setStsName(MesCollectRunStatusEnum.getNameByStatus(realtime.getSts())); |
| | | vo.setOpmName(MesCollectOperateModeEnum.getNameByMode(realtime.getOpm())); |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢å®æ¶ç¶æåå² |
| | | */ |
| | | public PageResult<MesCollectRealtimeRespVO> getRealtimeHistoryPage(MesCollectRealtimeHistoryPageReqVO reqVO) { |
| | | PageResult<MesCollectRealtimeHistoryDO> pageResult = realtimeHistoryMapper.selectPage(reqVO); |
| | | PageResult<MesCollectRealtimeRespVO> result = BeanUtils.toBean(pageResult, MesCollectRealtimeRespVO.class); |
| | | result.getList().forEach(vo -> { |
| | | vo.setStsName(MesCollectRunStatusEnum.getNameByStatus(vo.getSts())); |
| | | vo.setOpmName(MesCollectOperateModeEnum.getNameByMode(vo.getOpm())); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢å¨æè¿ç¨æ°æ® |
| | | */ |
| | | public PageResult<MesCollectCycleRespVO> getCyclePage(MesCollectCyclePageReqVO reqVO) { |
| | | return BeanUtils.toBean(cycleMapper.selectPage(reqVO), MesCollectCycleRespVO.class); |
| | | } |
| | | |
| | | /** |
| | | * è·å忡卿è¿ç¨æ°æ® |
| | | */ |
| | | public MesCollectCycleRespVO getCycle(Long id) { |
| | | MesCollectCycleDO cycle = cycleMapper.selectById(id); |
| | | return cycle == null ? null : BeanUtils.toBean(cycle, MesCollectCycleRespVO.class); |
| | | } |
| | | |
| | | /** |
| | | * è·åæå®æ°é设å¤çææ°å·¥èºåæ°å¿«ç
§ |
| | | */ |
| | | public MesCollectTechRespVO getTech(String deviceCode) { |
| | | MesCollectTechDO tech = techMapper.selectByDeviceCode(deviceCode); |
| | | return tech == null ? null : BeanUtils.toBean(tech, MesCollectTechRespVO.class); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢åæ°åæ´æ¥å¿ |
| | | */ |
| | | public PageResult<MesCollectOperateLogRespVO> getOperateLogPage(MesCollectOperateLogPageReqVO reqVO) { |
| | | return BeanUtils.toBean(collectOperateLogMapper.selectPage(reqVO), MesCollectOperateLogRespVO.class); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢æ¥è¦è®°å½ |
| | | */ |
| | | public PageResult<MesCollectAlarmRespVO> getAlarmPage(MesCollectAlarmPageReqVO reqVO) { |
| | | PageResult<MesCollectAlarmDO> pageResult = alarmMapper.selectPage(reqVO); |
| | | PageResult<MesCollectAlarmRespVO> result = BeanUtils.toBean(pageResult, MesCollectAlarmRespVO.class); |
| | | result.getList().forEach(vo -> vo.setStatusName(MesCollectAlarmStatusEnum.ACTIVE.getStatus().equals(vo.getStatus()) |
| | | ? MesCollectAlarmStatusEnum.ACTIVE.getName() : MesCollectAlarmStatusEnum.CLEARED.getName())); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 人工确认æ¶é¤æ¥è¦ |
| | | */ |
| | | public void ackAlarm(Long id) { |
| | | MesCollectAlarmDO alarm = alarmMapper.selectById(id); |
| | | if (alarm == null) { |
| | | throw exception(COLLECT_ALARM_NOT_EXISTS); |
| | | } |
| | | if (MesCollectAlarmStatusEnum.CLEARED.getStatus().equals(alarm.getStatus())) { |
| | | throw exception(COLLECT_ALARM_ALREADY_CLEARED); |
| | | } |
| | | MesCollectAlarmDO updateObj = new MesCollectAlarmDO(); |
| | | updateObj.setId(id); |
| | | updateObj.setStatus(MesCollectAlarmStatusEnum.CLEARED.getStatus()); |
| | | updateObj.setClearTime(LocalDateTime.now()); |
| | | alarmMapper.updateById(updateObj); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.task.MesProTaskMapper; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * MES æ°é-ç产任å¡å
³èè§£æ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class MesCollectTaskResolver { |
| | | |
| | | private static final long CACHE_MILLIS = 30_000L; |
| | | |
| | | @Resource |
| | | private MesProTaskMapper taskMapper; |
| | | |
| | | private final ConcurrentHashMap<Long, CachedTask> cache = new ConcurrentHashMap<>(); |
| | | |
| | | /** |
| | | * æ¥è¯¢å·¥ä½ç«ä¸æ£å¨è¿è¡çç产任å¡ï¼ç产ä¸/é¨å宿/å·²åå·¥ï¼ |
| | | */ |
| | | public MesProTaskDO resolve(Long workstationId) { |
| | | if (workstationId == null) { |
| | | return null; |
| | | } |
| | | long now = System.currentTimeMillis(); |
| | | CachedTask cached = cache.get(workstationId); |
| | | if (cached != null && now - cached.time < CACHE_MILLIS) { |
| | | return cached.task; |
| | | } |
| | | MesProTaskDO task = taskMapper.selectRunningTaskByWorkstationId(workstationId); |
| | | cache.put(workstationId, new CachedTask(task, now)); |
| | | return task; |
| | | } |
| | | |
| | | private record CachedTask(MesProTaskDO task, long time) { |
| | | } |
| | | |
| | | } |
| | |
| | | workshopService.getWorkshop(createReqVO.getWorkshopId()); |
| | | // æ ¡éªç¼ç å¯ä¸ |
| | | validateMachineryCodeUnique(null, createReqVO.getCode()); |
| | | // æ ¡éªæ°é设å¤ç¼å·å¯ä¸ |
| | | validateCollectDeviceCodeUnique(null, createReqVO.getCollectDeviceCode()); |
| | | |
| | | // æå
¥ |
| | | MesDvMachineryDO machinery = BeanUtils.toBean(createReqVO, MesDvMachineryDO.class); |
| | |
| | | workshopService.getWorkshop(updateReqVO.getWorkshopId()); |
| | | // æ ¡éªç¼ç å¯ä¸ |
| | | validateMachineryCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); |
| | | // æ ¡éªæ°é设å¤ç¼å·å¯ä¸ |
| | | validateCollectDeviceCodeUnique(updateReqVO.getId(), updateReqVO.getCollectDeviceCode()); |
| | | |
| | | // æ´æ° |
| | | MesDvMachineryDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMachineryDO.class); |
| | |
| | | } |
| | | if (ObjUtil.notEqual(machinery.getId(), id)) { |
| | | throw exception(DV_MACHINERY_CODE_DUPLICATE); |
| | | } |
| | | } |
| | | |
| | | private void validateCollectDeviceCodeUnique(Long id, String collectDeviceCode) { |
| | | if (StrUtil.isBlank(collectDeviceCode)) { |
| | | return; |
| | | } |
| | | MesDvMachineryDO machinery = machineryMapper.selectByCollectDeviceCode(collectDeviceCode); |
| | | if (machinery == null) { |
| | | return; |
| | | } |
| | | if (ObjUtil.notEqual(machinery.getId(), id)) { |
| | | throw exception(DV_MACHINERY_COLLECT_CODE_DUPLICATE); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // 3.5 夿ï¼å建 or æ´æ° |
| | | MesDvMachineryDO existMachinery = machineryMapper.selectByCode(importItem.getCode()); |
| | | if (StrUtil.isNotBlank(importItem.getCollectDeviceCode())) { |
| | | MesDvMachineryDO collectOwner = machineryMapper.selectByCollectDeviceCode(importItem.getCollectDeviceCode()); |
| | | if (collectOwner != null && (existMachinery == null |
| | | || ObjUtil.notEqual(collectOwner.getId(), existMachinery.getId()))) { |
| | | respVO.getFailureCodes().put(key, "æ°é设å¤ç¼å·[" + importItem.getCollectDeviceCode() + "]已被设å¤[" |
| | | + collectOwner.getCode() + "]å ç¨"); |
| | | return; |
| | | } |
| | | } |
| | | if (existMachinery == null) { |
| | | // 3.5.1 å建 |
| | | MesDvMachineryDO machinery = BeanUtils.toBean(importItem, MesDvMachineryDO.class); |
| | |
| | | username: root # å¤ä»½è´¦å·ï¼çç©ºä½¿ç¨æ°æ®æºè´¦å· |
| | | password: 'xd@123456..' # å¤ä»½å¯ç ï¼çç©ºä½¿ç¨æ°æ®æºå¯ç |
| | | command: # mysqldump å½ä»¤ï¼ç空èªå¨æ£æµé¨ç½²ç¯å¢ï¼æ¬æº mysqldump æ Docker MySQL 容å¨ï¼ï¼å¯æå¨æå®ï¼å¦ï¼docker exec mysql8 mysqldump |
| | | mes: |
| | | collect: |
| | | mqtt: # æ³¨å¡æºæ°éï¼EMQX 订é
ï¼è®¾å¤ä»¥ devIdï¼å¦ C01ï¼ç»è®¾å¤å°è´¦ collect_device_code ç»å® |
| | | enabled: true # å
³æåä¸åè¿æ¥ Brokerï¼ä»
ä¿çå岿°æ®æ¥è¯¢ |
| | | url: tcp://36.213.90.123:1883 |
| | | username: admin |
| | | password: public |
| | | client-id-prefix: mes-collect |
| | | topic-prefix: /YLCY/IMM |
| | | qos: 0 |
| | | keep-alive: 65 |
| | | connection-timeout: 10 |
| | | alarm-topic-suffix: wm # æ¥æ topic åæ®µæä¸»é¢æ«æ®µå½ä¸è¯¥åç¼å³ææ¥è¦å¤ç |
| | | retention: |
| | | raw-days: 7 # åå§æ¥æä¿çå¤©æ° |
| | | realtime-days: 30 # 宿¶ç¶æåå²ä¿çå¤©æ° |
| | | batch-size: 50000 # 忬¡æ¸
çæ¡æ° |
| | |
| | | primary: master |
| | | datasource: |
| | | master: |
| | | url: jdbc:mysql://localhost:3306/mom-hm?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X è¿æ¥çç¤ºä¾ |
| | | url: jdbc:mysql://localhost:3306/mom-kyzn?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X è¿æ¥çç¤ºä¾ |
| | | username: root |
| | | password: 123456 |
| | | |
| | |
| | | database-backup: # æ°æ®åºå¤ä»½é
ç½® |
| | | host: localhost # å¤ä»½ç®æ MySQL 主æºï¼ç空èªå¨ä»æ°æ®æº JDBC URL è§£æ |
| | | port: 3306 # å¤ä»½ç®æ MySQL 端å£ï¼ç空èªå¨ä»æ°æ®æº JDBC URL è§£æ |
| | | database: ruoyi-vue-pro # å¤ä»½ç®æ æ°æ®åºï¼ç空èªå¨ä»æ°æ®æº JDBC URL è§£æ |
| | | database: mom-kyzn # å¤ä»½ç®æ æ°æ®åºï¼ç空èªå¨ä»æ°æ®æº JDBC URL è§£æ |
| | | username: root # å¤ä»½è´¦å·ï¼çç©ºä½¿ç¨æ°æ®æºè´¦å· |
| | | password: '123456' # å¤ä»½å¯ç ï¼çç©ºä½¿ç¨æ°æ®æºå¯ç |
| | | command: # mysqldump å½ä»¤ï¼ç空èªå¨æ£æµé¨ç½²ç¯å¢ï¼æ¬æº mysqldump æ Docker MySQL 容å¨ï¼ï¼å¯æå¨æå®ï¼å¦ï¼docker exec mysql8 mysqldump |
| | | mes: |
| | | collect: |
| | | mqtt: # æ³¨å¡æºæ°éï¼æ¬å°é»è®¤ä¸è¿ç产 Brokerï¼éè¦èè°æ¶æ enabled æ¹ä¸º true |
| | | enabled: false |
| | | url: tcp://36.213.90.123:1883 |
| | | username: admin |
| | | password: public |
| | | client-id-prefix: mes-collect-local |
| | | topic-prefix: /YLCY/IMM |
| | | qos: 0 |
| | | keep-alive: 65 |
| | | connection-timeout: 10 |
| | | alarm-topic-suffix: wm |
| | | retention: |
| | | raw-days: 7 |
| | | realtime-days: 30 |
| | | batch-size: 50000 |
| | |
| | | username: root # å¤ä»½è´¦å·ï¼çç©ºä½¿ç¨æ°æ®æºè´¦å· |
| | | password: 'xd@123456..' # å¤ä»½å¯ç ï¼çç©ºä½¿ç¨æ°æ®æºå¯ç |
| | | command: # mysqldump å½ä»¤ï¼ç空èªå¨æ£æµé¨ç½²ç¯å¢ï¼æ¬æº mysqldump æ Docker MySQL 容å¨ï¼ï¼å¯æå¨æå®ï¼å¦ï¼docker exec mysql8 mysqldump |
| | | mes: |
| | | collect: |
| | | mqtt: # æ³¨å¡æºæ°éï¼æµè¯ç¯å¢é»è®¤ä¸è¿ç产 Brokerï¼éè¦èè°æ¶æ enabled æ¹ä¸º true |
| | | enabled: false |
| | | url: tcp://36.213.90.123:1883 |
| | | username: admin |
| | | password: public |
| | | client-id-prefix: mes-collect-test |
| | | topic-prefix: /YLCY/IMM |
| | | qos: 0 |
| | | keep-alive: 65 |
| | | connection-timeout: 10 |
| | | alarm-topic-suffix: wm |
| | | retention: |
| | | raw-days: 7 |
| | | realtime-days: 30 |
| | | batch-size: 50000 |