From 39f62fa03a2463652e971edfabab56313db6af10 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期六, 28 六月 2025 10:20:34 +0800 Subject: [PATCH] 涉密->工控 --- lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/controller/MsiWebapiJsonController.java | 4 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentAlarmServiceImpl.java | 1 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java | 2 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml | 26 +- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcAlarmInfoMapper.java | 1 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/AndonOrder.java | 20 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOeeInfoMapper.xml | 8 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java | 70 +++-- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java | 3 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml | 10 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentAlarmMapper.java | 2 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/AndonOrderController.java | 42 +- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java | 2 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentRunningSection.java | 11 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcWorkshopInfoMapper.xml | 19 - lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeOperatorMapper.xml | 2 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcAlarmInfoMapper.xml | 1 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOverallEquipmentEfficiencyJob.java | 74 ++++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/AndonOrderServiceImpl.java | 5 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcAlarmInfoServiceImpl.java | 1 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java | 44 +++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java | 138 +---------- lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java | 148 ++++++++---- /dev/null | 29 -- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml | 21 - lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml | 6 26 files changed, 334 insertions(+), 356 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/AndonOrderController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/AndonOrderController.java index a9a33ee..7d707f5 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/AndonOrderController.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/AndonOrderController.java @@ -14,31 +14,31 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - /** - * @Description: andon_order - * @Author: jeecg-boot - * @Date: 2025-06-11 - * @Version: V1.0 - */ +/** +* @Description: andon_order +* @Author: jeecg-boot +* @Date: 2025-06-11 +* @Version: V1.0 +*/ @Api(tags="andon_order") @RestController @RequestMapping("/AndonOrder/andonOrder") @Slf4j public class AndonOrderController extends JeecgController<AndonOrder, IAndonOrderService> { - @Autowired - private IAndonOrderService andonOrderService; + @Autowired + private IAndonOrderService andonOrderService; - /** - * 绋嬪簭鍛煎彨 - * - * @param andonOrder - * @return - */ - @AutoLog(value = "瀹夌伅宸ュ崟-绋嬪簭鍛煎彨") - @ApiOperation(value = "瀹夌伅宸ュ崟-绋嬪簭鍛煎彨", notes = "瀹夌伅宸ュ崟-绋嬪簭鍛煎彨") - @PostMapping(value = "/procedureCall") - public Result<?> procedureCall(@RequestBody AndonOrder andonOrder) { - andonOrderService.procedureCall(andonOrder); - return Result.OK("鍛煎彨鎴愬姛锛�"); - } + /** + * 绋嬪簭鍛煎彨 + * + * @param andonOrder + * @return + */ + @AutoLog(value = "瀹夌伅宸ュ崟-绋嬪簭鍛煎彨") + @ApiOperation(value = "瀹夌伅宸ュ崟-绋嬪簭鍛煎彨", notes = "瀹夌伅宸ュ崟-绋嬪簭鍛煎彨") + @PostMapping(value = "/procedureCall") + public Result<?> procedureCall(@RequestBody AndonOrder andonOrder) { + andonOrderService.procedureCall(andonOrder); + return Result.OK("鍛煎彨鎴愬姛锛�"); + } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/AndonOrder.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/AndonOrder.java index 84d58c3..5a81906 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/AndonOrder.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/AndonOrder.java @@ -1,25 +1,23 @@ package org.jeecg.modules.mdc.entity; -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.util.Date; -import java.math.BigDecimal; - import cn.hutool.core.date.DatePattern; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableLogic; -import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; -import org.jeecg.common.constant.CommonConstant; -import org.springframework.format.annotation.DateTimeFormat; -import org.jeecgframework.poi.excel.annotation.Excel; -import org.jeecg.common.aspect.annotation.Dict; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.jeecg.common.aspect.annotation.Dict; +import org.jeecg.common.constant.CommonConstant; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; /** * @Description: andon_order diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentRunningSection.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentRunningSection.java index 00110c7..df2abf4 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentRunningSection.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentRunningSection.java @@ -100,15 +100,4 @@ @TableField(exist = false) private Set<TmpEquipmentAlarm> tmpEquipmentAlarmSet; - public MdcEquipmentRunningSection() { - } - - public MdcEquipmentRunningSection(Integer status, String equipmentId, Date startTime, Date endTime, Long startLong, Long endLong) { - this.status = status; - this.equipmentId = equipmentId; - this.startTime = startTime; - this.endTime = endTime; - this.startLong = startLong; - this.endLong = endLong; - } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java index 07bbabf..1b9b0c7 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java @@ -101,18 +101,18 @@ mdcEquipmentStatisticalInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId()); mdcEquipmentStatisticalInfoMonth.setTheMonth(date); if (mdcEquipmentStatisticalDto != null) { - mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setProcessLong(mdcEquipmentStatisticalDto.getProcessLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setWaitLong(mdcEquipmentStatisticalDto.getWaitLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); - mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); - mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); - mdcEquipmentStatisticalInfoMonth.setFaultLong(mdcEquipmentStatisticalDto.getFaultLong().intValue()); - mdcEquipmentStatisticalInfoMonth.setFaultRate(mdcEquipmentStatisticalDto.getFaultRate()); - mdcEquipmentStatisticalInfoMonth.setRemoveFaultRate(mdcEquipmentStatisticalDto.getRemoveFaultRate()); - mdcEquipmentStatisticalInfoMonth.setRemoveFaultRunLong(mdcEquipmentStatisticalDto.getRemoveFaultRunLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setCloseLong(mdcEquipmentStatisticalDto.getCloseLong() == null ? 0 : mdcEquipmentStatisticalDto.getCloseLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setErrorLong(mdcEquipmentStatisticalDto.getErrorLong() == null ? 0 : mdcEquipmentStatisticalDto.getErrorLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setOpenLong(mdcEquipmentStatisticalDto.getOpenLong() == null ? 0 : mdcEquipmentStatisticalDto.getOpenLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setProcessLong(mdcEquipmentStatisticalDto.getProcessLong() == null ? 0 : mdcEquipmentStatisticalDto.getProcessLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setWaitLong(mdcEquipmentStatisticalDto.getWaitLong() == null ? 0 : mdcEquipmentStatisticalDto.getWaitLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setOpenRate(mdcEquipmentStatisticalDto.getOpenLong() == null || mdcEquipmentStatisticalDto.getDayNum() == null ? BigDecimal.ZERO : mdcEquipmentStatisticalDto.getOpenLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); + mdcEquipmentStatisticalInfoMonth.setStartRate(mdcEquipmentStatisticalDto.getOpenLong() == null || mdcEquipmentStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (mdcEquipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentStatisticalDto.getProcessLong().divide(mdcEquipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); + mdcEquipmentStatisticalInfoMonth.setUtilizationRate(mdcEquipmentStatisticalDto.getProcessLong() == null || mdcEquipmentStatisticalDto.getDayNum() == null ? BigDecimal.ZERO : mdcEquipmentStatisticalDto.getProcessLong().divide((new BigDecimal("864").multiply(mdcEquipmentStatisticalDto.getDayNum())), 4, RoundingMode.HALF_UP)); + mdcEquipmentStatisticalInfoMonth.setFaultLong(mdcEquipmentStatisticalDto.getFaultLong() == null ? 0 : mdcEquipmentStatisticalDto.getFaultLong().intValue()); + mdcEquipmentStatisticalInfoMonth.setFaultRate(mdcEquipmentStatisticalDto.getFaultRate() == null ? BigDecimal.ZERO : mdcEquipmentStatisticalDto.getFaultRate()); + mdcEquipmentStatisticalInfoMonth.setRemoveFaultRate(mdcEquipmentStatisticalDto.getRemoveFaultRate() == null ? BigDecimal.ZERO : mdcEquipmentStatisticalDto.getRemoveFaultRate()); + mdcEquipmentStatisticalInfoMonth.setRemoveFaultRunLong(mdcEquipmentStatisticalDto.getRemoveFaultRunLong() == null ? 0 : mdcEquipmentStatisticalDto.getRemoveFaultRunLong().intValue()); } mdcEquipmentStatisticalInfoMonthList.add(mdcEquipmentStatisticalInfoMonth); // step.3 姹囨�荤彮娆″埄鐢ㄧ巼鏁版嵁 @@ -122,15 +122,25 @@ mdcEquipmentShiftInfoMonth.setTheMonth(date); mdcEquipmentShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_1); if (mdcEquipmentShiftStatisticalDto != null) { - mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong().intValue()); - mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong().intValue()); - mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong().intValue()); - mdcEquipmentShiftInfoMonth.setErrorLong(mdcEquipmentShiftStatisticalDto.getErrorLong().intValue()); - mdcEquipmentShiftInfoMonth.setWaitLong(mdcEquipmentShiftStatisticalDto.getWaitLong().intValue()); - mdcEquipmentShiftInfoMonth.setProcessLong(mdcEquipmentShiftStatisticalDto.getProcessLong().intValue()); - mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); - mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); - mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); + mdcEquipmentShiftInfoMonth.setCloseLong(mdcEquipmentShiftStatisticalDto.getCloseLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getCloseLong().intValue()); + mdcEquipmentShiftInfoMonth.setTotalLong(mdcEquipmentShiftStatisticalDto.getTotalLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getTotalLong().intValue()); + mdcEquipmentShiftInfoMonth.setOpenLong(mdcEquipmentShiftStatisticalDto.getOpenLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getOpenLong().intValue()); + mdcEquipmentShiftInfoMonth.setErrorLong(mdcEquipmentShiftStatisticalDto.getErrorLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getErrorLong().intValue()); + mdcEquipmentShiftInfoMonth.setWaitLong(mdcEquipmentShiftStatisticalDto.getWaitLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getWaitLong().intValue()); + mdcEquipmentShiftInfoMonth.setProcessLong(mdcEquipmentShiftStatisticalDto.getProcessLong() == null ? 0 : mdcEquipmentShiftStatisticalDto.getProcessLong().intValue()); + mdcEquipmentShiftInfoMonth.setUtilizationRate(mdcEquipmentShiftStatisticalDto.getTotalLong() == null || mdcEquipmentShiftStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); + mdcEquipmentShiftInfoMonth.setStartRate(mdcEquipmentShiftStatisticalDto.getOpenLong() == null || mdcEquipmentShiftStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (mdcEquipmentShiftStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getProcessLong().divide(mdcEquipmentShiftStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); + mdcEquipmentShiftInfoMonth.setOpenRate(mdcEquipmentShiftStatisticalDto.getOpenLong() == null || mdcEquipmentShiftStatisticalDto.getTotalLong() == null ? BigDecimal.ZERO : (mdcEquipmentShiftStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? mdcEquipmentShiftStatisticalDto.getOpenLong().divide(mdcEquipmentShiftStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); + } else { + mdcEquipmentShiftInfoMonth.setCloseLong(0); + mdcEquipmentShiftInfoMonth.setTotalLong(0); + mdcEquipmentShiftInfoMonth.setOpenLong(0); + mdcEquipmentShiftInfoMonth.setErrorLong(0); + mdcEquipmentShiftInfoMonth.setWaitLong(0); + mdcEquipmentShiftInfoMonth.setProcessLong(0); + mdcEquipmentShiftInfoMonth.setUtilizationRate(BigDecimal.ZERO); + mdcEquipmentShiftInfoMonth.setStartRate(BigDecimal.ZERO); + mdcEquipmentShiftInfoMonth.setOpenRate(BigDecimal.ZERO); } mdcEquipmentStatisticalShiftInfoMonthList.add(mdcEquipmentShiftInfoMonth); // step.4 姹囨�诲悇鐝鍒╃敤鐜囨暟鎹� @@ -141,15 +151,15 @@ equipmentStatisticalShiftInfoMonth.setEquipmentId(mdcEquipment.getEquipmentId()); equipmentStatisticalShiftInfoMonth.setTheMonth(date); equipmentStatisticalShiftInfoMonth.setShiftType(CommonConstant.SHIFT_TYPE_2); - equipmentStatisticalShiftInfoMonth.setCloseLong(equipmentStatisticalDto.getCloseLong().intValue()); - equipmentStatisticalShiftInfoMonth.setTotalLong(equipmentStatisticalDto.getTotalLong().intValue()); - equipmentStatisticalShiftInfoMonth.setOpenLong(equipmentStatisticalDto.getOpenLong().intValue()); - equipmentStatisticalShiftInfoMonth.setErrorLong(equipmentStatisticalDto.getErrorLong().intValue()); - equipmentStatisticalShiftInfoMonth.setWaitLong(equipmentStatisticalDto.getWaitLong().intValue()); - equipmentStatisticalShiftInfoMonth.setProcessLong(equipmentStatisticalDto.getProcessLong().intValue()); - equipmentStatisticalShiftInfoMonth.setUtilizationRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); - equipmentStatisticalShiftInfoMonth.setStartRate(equipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); - equipmentStatisticalShiftInfoMonth.setOpenRate(equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getOpenLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); + equipmentStatisticalShiftInfoMonth.setCloseLong(equipmentStatisticalDto.getCloseLong() == null ? 0 : equipmentStatisticalDto.getCloseLong().intValue()); + equipmentStatisticalShiftInfoMonth.setTotalLong(equipmentStatisticalDto.getTotalLong() == null ? 0 : equipmentStatisticalDto.getTotalLong().intValue()); + equipmentStatisticalShiftInfoMonth.setOpenLong(equipmentStatisticalDto.getOpenLong() == null ? 0 : equipmentStatisticalDto.getOpenLong().intValue()); + equipmentStatisticalShiftInfoMonth.setErrorLong(equipmentStatisticalDto.getErrorLong() == null ? 0 : equipmentStatisticalDto.getErrorLong().intValue()); + equipmentStatisticalShiftInfoMonth.setWaitLong(equipmentStatisticalDto.getWaitLong() == null ? 0 : equipmentStatisticalDto.getWaitLong().intValue()); + equipmentStatisticalShiftInfoMonth.setProcessLong(equipmentStatisticalDto.getProcessLong() == null ? 0 : equipmentStatisticalDto.getProcessLong().intValue()); + equipmentStatisticalShiftInfoMonth.setUtilizationRate(equipmentStatisticalDto.getTotalLong() == null || equipmentStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); + equipmentStatisticalShiftInfoMonth.setStartRate(equipmentStatisticalDto.getOpenLong() == null || equipmentStatisticalDto.getProcessLong() == null ? BigDecimal.ZERO : (equipmentStatisticalDto.getOpenLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getProcessLong().divide(equipmentStatisticalDto.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); + equipmentStatisticalShiftInfoMonth.setOpenRate(equipmentStatisticalDto.getTotalLong() == null || equipmentStatisticalDto.getOpenLong() == null ? BigDecimal.ZERO : (equipmentStatisticalDto.getTotalLong().compareTo(BigDecimal.ZERO) > 0 ? equipmentStatisticalDto.getOpenLong().divide(equipmentStatisticalDto.getTotalLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO)); mdcEquipmentStatisticalShiftInfoMonthList.add(equipmentStatisticalShiftInfoMonth); } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ImportXmlToDataJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ImportXmlToDataJob.java deleted file mode 100644 index 57e3f21..0000000 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ImportXmlToDataJob.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.jeecg.modules.mdc.job; - -import lombok.extern.slf4j.Slf4j; -import org.jeecg.common.util.DateUtils; -import org.jeecg.modules.mdc.service.ILogTableService; -import org.jeecg.modules.mdc.util.ThrowableUtil; -import org.jeecg.modules.quartz.entity.QuartzJob; -import org.jeecg.modules.quartz.entity.SysQuartzLog; -import org.jeecg.modules.quartz.service.IQuartzJobService; -import org.jeecg.modules.quartz.service.ISysQuartzLogService; -import org.jeecg.modules.system.service.ISysAnnouncementService; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -import javax.annotation.Resource; -import java.util.Date; -import java.util.List; - -/** - * @author Lius - * @date 2024/12/19 16:43 - */ -@Slf4j -public class ImportXmlToDataJob implements Job { - - @Resource - private ISysQuartzLogService sysQuartzLogService; - - @Resource - private IQuartzJobService quartzJobService; - - @Resource - private ISysAnnouncementService sysAnnouncementService; - - - @Override - public void execute(JobExecutionContext context) throws JobExecutionException { - SysQuartzLog quartzLog = new SysQuartzLog(); - quartzLog.setCreateTime(new Date()); - List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); - if (byJobClassName != null && !byJobClassName.isEmpty()) { - quartzLog.setJobId(byJobClassName.get(0).getId()); - } - log.info("瀹氭椂瀵煎叆sql鏁版嵁浠诲姟 ImportXmlToDataJob start! 鏃堕棿:" + DateUtils.now()); - long startTime = System.currentTimeMillis(); - try { - quartzLog.setIsSuccess(0); - } catch (Exception e) { - quartzLog.setIsSuccess(-1); - quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); - // 鍙戦�佹秷鎭�氱煡 - sysAnnouncementService.jobSendMessage("瀹氭椂瀵煎叆sql鏁版嵁浠诲姟", quartzLog.getExceptionDetail()); - } - long endTime = System.currentTimeMillis(); - quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); - sysQuartzLogService.save(quartzLog); - } -} diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOverallEquipmentEfficiencyJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOverallEquipmentEfficiencyJob.java new file mode 100644 index 0000000..304cc7b --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOverallEquipmentEfficiencyJob.java @@ -0,0 +1,74 @@ +package org.jeecg.modules.mdc.job; + +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.mdc.service.IMdcOverallEquipmentEfficiencyService; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.jeecg.modules.system.service.ISysAnnouncementService; +import org.quartz.*; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * @Description: 瀹氭椂璁$畻璁惧缁煎悎鏁堢巼OEE浠诲姟 + * @author: LiuS + * @create: 2023-07-24 10:26 + */ +@PersistJobDataAfterExecution +@DisallowConcurrentExecution +@Slf4j +public class RunningOverallEquipmentEfficiencyJob implements Job { + + /** + * 鑻ュ弬鏁板彉閲忓悕淇敼 QuartzJobController涓篃闇�瀵瑰簲淇敼 鏃堕棿锛� yyyyMMdd 渚嬶細 20230414 + */ + private String parameter; + + public void setParameter(String parameter) { + this.parameter = parameter; + } + + @Resource + private IQuartzJobService quartzJobService; + + @Resource + private ISysAnnouncementService sysAnnouncementService; + + @Resource + private ISysQuartzLogService sysQuartzLogService; + + @Resource + private IMdcOverallEquipmentEfficiencyService mdcOverallEquipmentEfficiencyService; + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + SysQuartzLog quartzLog = new SysQuartzLog(); + quartzLog.setCreateTime(new Date()); + List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + quartzLog.setParams(this.parameter); + log.info("瀹氭椂璁$畻璁惧缁煎悎鏁堢巼OEE浠诲姟 RunningOverallEquipmentEfficiencyJob start! 鏃堕棿:" + DateUtils.now(), this.parameter); + long startTime = System.currentTimeMillis(); + try { + mdcOverallEquipmentEfficiencyService.runningOverallEquipmentEfficiency(this.parameter); + quartzLog.setIsSuccess(0); + } catch (Exception e) { + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); + // 鍙戦�佹秷鎭�氱煡 + sysAnnouncementService.jobSendMessage("瀹氭椂缁熻娈垫椂闂翠换鍔�", quartzLog.getExceptionDetail()); + } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); + } + +} diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentAlarmMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentAlarmMapper.java index 629c89b..389bd8f 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentAlarmMapper.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentAlarmMapper.java @@ -11,5 +11,7 @@ * @create: 2023-04-12 16:39 */ public interface EquipmentAlarmMapper extends BaseMapper<EquipmentAlarm> { + List<EquipmentAlarm> equAlarmList(@Param("equipmentIdList") List<String> equipmentIdList); + } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcAlarmInfoMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcAlarmInfoMapper.java index 486151e..bf1e785 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcAlarmInfoMapper.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcAlarmInfoMapper.java @@ -13,4 +13,5 @@ public interface MdcAlarmInfoMapper extends BaseMapper<MdcAlarmInfo> { MdcAlarmInfo findAlarmContent(@Param("alarmNo") String alarmNo, @Param("equipmentId") String equipmentId); + } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java index 0726a92..3aa3fd3 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java @@ -1,8 +1,8 @@ package org.jeecg.modules.mdc.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.jeecg.modules.mdc.vo.EquFaultRecord; import java.util.List; diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java index 38c8714..b9997c0 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java @@ -5,7 +5,6 @@ import org.jeecg.modules.mdc.dto.MdcAlarmListDto; import org.jeecg.modules.mdc.dto.MdcEquipmentWaitSectionDto; import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; -import org.jeecg.modules.mdc.vo.EquFaultRecord; import org.jeecg.modules.mdc.vo.MdcAlarmAnalyzeQueryVo; import java.util.Date; @@ -79,8 +78,6 @@ List<Integer> getDataList(@Param("equipmentId") String equipmentId, @Param("date") Date date); List<MdcEquipmentWaitSectionDto> findWaitList(@Param("date") String date); - - List<EquFaultRecord> findFaultList(@Param("equipmentId") String equipmentId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); MdcEquipmentRunningSection getFirstRecord(); } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcAlarmInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcAlarmInfoMapper.xml index 4e71d72..d7e5038 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcAlarmInfoMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcAlarmInfoMapper.xml @@ -11,4 +11,5 @@ WHERE t2.equipment_id = #{equipmentId} AND t1.alarm_code = #{alarmNo} </select> + </mapper> \ No newline at end of file diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml index 0917a40..85d3ca7 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml @@ -50,11 +50,11 @@ LEFT JOIN mdc_downtime_reason t2 ON t1.reason_id = t2.id WHERE t1.reason_id != '' - AND t1.the_date BETWEEN #{start} AND #{end} - AND t1.equipment_id IN - <foreach collection="equipmentIdList" item="equipmentId" index="index" open="(" close=")" separator=","> - #{ equipmentId } - </foreach> + AND t1.the_date BETWEEN #{start} AND #{end} + AND t1.equipment_id IN + <foreach collection="equipmentIdList" item="equipmentId" index="index" open="(" close=")" separator=","> + #{ equipmentId } + </foreach> GROUP BY t2.downtime_description </select> diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeOperatorMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeOperatorMapper.xml index 581970f..db58e0e 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeOperatorMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeOperatorMapper.xml @@ -9,6 +9,6 @@ t2.downtime_description downtimeDescription FROM mdc_downtime t1 LEFT JOIN mdc_downtime_reason t2 ON t1.reason_id = t2.id ${ew.customSqlSegment} - ORDER BY t1.equipment_id DESC, t1.start_date ASC + ORDER BY t1.create_time DESC </select> </mapper> \ No newline at end of file diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml index d7c9488..74ccdcb 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml @@ -69,10 +69,14 @@ t1.open_long / 86400 openRate, t1.open_long openLong, t1.wait_long waitLong, - t1.close_long closeLong + t1.close_long closeLong, + COALESCE(t3.fault_long, 0) faultLong, + COALESCE(t3.fault_rate, 0) faultRate, + COALESCE(t3.remove_fault_run_long, 0) removeFaultRunLong FROM mdc_equipment t2 LEFT JOIN mdc_equipment_statistical_info t1 ON t1.equipment_id = t2.equipment_id + LEFT JOIN mdc_equipment_fault_info t3 ON t2.equipment_id = t3.equipment_id AND t1.the_date = t3.the_date WHERE t1.the_date <= #{ vo.endTime } AND t1.the_date >= #{ vo.startTime } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml index 964540d..acf92f2 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml @@ -188,28 +188,7 @@ equipment_id, start_time DESC </select> - <select id="findFaultList" resultType="org.jeecg.modules.mdc.vo.EquFaultRecord"> - SELECT - t3.equipment_code equipmentId, - t1.fault_start_time startTime, - t2.actual_end_time endTime - FROM - eam_report_repair t1 - LEFT JOIN eam_repair_order t2 ON t2.report_id = t1.id - LEFT JOIN eam_equipment t3 ON t1.equipment_id = t3.id - WHERE - ( - ( t1.fault_start_time BETWEEN #{startTime} AND #{endTime} ) - OR ( t2.actual_end_time BETWEEN #{startTime} AND #{endTime} ) - OR ( t1.fault_start_time < #{startTime} AND t2.actual_end_time IS NULL ) - ) - AND t3.equipment_code = #{equipmentId} - AND t1.report_status != 'ABOLISH' - </select> - <select id="getFirstRecord" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection"> SELECT TOP 1 * FROM mdc_equipment_running_section ORDER BY start_time </select> - - </mapper> \ No newline at end of file diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml index 62ae98e..273ae3b 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml @@ -33,26 +33,26 @@ <select id="findByEquIdsAndMonth" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> SELECT - AVG(open_long) openLong, - AVG(close_long) closeLong, - AVG(wait_long) waitLong, - AVG(process_long) processLong, - AVG(error_long) errorLong + AVG(open_long) openLong, + AVG(close_long) closeLong, + AVG(wait_long) waitLong, + AVG(process_long) processLong, + AVG(error_long) errorLong FROM - mdc_equipment_statistical_info + mdc_equipment_statistical_info WHERE - equipment_id IN - <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> - #{ id } - </foreach> - AND the_date LIKE CONCAT(#{month}, '%') + equipment_id IN + <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> + #{ id } + </foreach> + AND the_date LIKE CONCAT(#{month}, '%') </select> <select id="findByEquipmentAndDate" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo"> SELECT - * + * FROM - mdc_equipment_statistical_info + mdc_equipment_statistical_info WHERE equipment_id IN <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOeeInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOeeInfoMapper.xml index 3261ab9..ddb66e1 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOeeInfoMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOeeInfoMapper.xml @@ -30,12 +30,12 @@ <select id="findByEquIdAndMonth" resultType="java.math.BigDecimal"> SELECT - AVG(oee) + AVG(oee) FROM - mdc_oee_info + mdc_oee_info WHERE - the_date LIKE CONCAT(#{month}, '%') - AND equipment_id IN + the_date LIKE CONCAT(#{month}, '%') + AND equipment_id IN <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> #{ id } </foreach> diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcWorkshopInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcWorkshopInfoMapper.xml index b3a2f9a..e286929 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcWorkshopInfoMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcWorkshopInfoMapper.xml @@ -9,12 +9,8 @@ a.EquipmentID equipmentId, me.equipment_name equipmentName, me.equipment_type equipmentType, - me.equipment_image equipmentImage, - CASE - - WHEN repair.count > 0 THEN - '5' ELSE a.Oporation - END AS equipmentStatus, + met.equipment_type_pictures equipmentImage, + a.Oporation equipmentStatus, mew.coordinate_left coordinateLeft, mew.coordinate_top coordinateTop, mew.vw vw, @@ -28,17 +24,6 @@ INNER JOIN mdc_equipment_type met ON me.equipment_type = met.equipment_type_name AND a.CollectTime= b.maxgdtime AND mew.workshop_id = #{ workshopId } - LEFT JOIN ( - SELECT - e1.equipment_code, - COUNT(1) COUNT - FROM - eam_report_repair r1 - INNER JOIN eam_equipment e1 ON e1.id = r1.equipment_id - WHERE - r1.report_status NOT IN ('COMPLETE', 'ABOLISH') - GROUP BY - e1.equipment_code) repair ON repair.equipment_code = me.equipment_id </select> <select id="listByUser" resultType="org.jeecg.modules.mdc.entity.MdcWorkshopInfo"> diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java index ce9e4db..d8f63a3 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java @@ -1,7 +1,7 @@ package org.jeecg.modules.mdc.service; -import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; /** * @Description: 鏁呴殰鐜囪〃 diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/AndonOrderServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/AndonOrderServiceImpl.java index 499e343..0abd10a 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/AndonOrderServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/AndonOrderServiceImpl.java @@ -2,18 +2,14 @@ import cn.hutool.core.date.DatePattern; import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.parser.Feature; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.compress.utils.Lists; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.constant.WebsocketConst; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.common.util.TranslateDictTextUtils; import org.jeecg.modules.board.vo.EquAndon; import org.jeecg.modules.mdc.dto.MdcEquProDto; import org.jeecg.modules.mdc.entity.AndonOrder; @@ -25,7 +21,6 @@ import org.jeecg.modules.message.websocket.WebSocket; import org.jeecg.modules.system.service.ISysDictService; import org.jeecg.modules.system.service.ISysUserService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentAlarmServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentAlarmServiceImpl.java index b8a2565..15f3a9c 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentAlarmServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentAlarmServiceImpl.java @@ -7,7 +7,6 @@ import org.jeecg.modules.mdc.service.IEquipmentAlarmService; import org.springframework.stereotype.Service; -import java.util.Collections; import java.util.Date; import java.util.List; diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcAlarmInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcAlarmInfoServiceImpl.java index 12b90a1..a423277 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcAlarmInfoServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcAlarmInfoServiceImpl.java @@ -19,4 +19,5 @@ public MdcAlarmInfo findAlarmContent(String alarmNo, String equipmentId) { return this.baseMapper.findAlarmContent(alarmNo, equipmentId); } + } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java index 83fa48f..fc76c70 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java @@ -1,8 +1,12 @@ package org.jeecg.modules.mdc.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang.StringUtils; -import org.jeecg.modules.mdc.entity.*; +import org.jeecg.modules.mdc.entity.Equipment; +import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; +import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; +import org.jeecg.modules.mdc.entity.MdcSystemParameters; import org.jeecg.modules.mdc.mapper.MdcEquipmentFaultInfoMapper; import org.jeecg.modules.mdc.service.IEquipmentService; import org.jeecg.modules.mdc.service.IMdcEquipmentFaultInfoService; @@ -12,17 +16,12 @@ import org.jeecg.modules.mdc.vo.EquFaultRecord; import org.jeecg.modules.mdc.vo.TimeInterval; import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; -import java.time.Instant; -import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.ZoneId; import java.time.temporal.ChronoUnit; import java.util.*; import java.util.stream.Collectors; @@ -177,6 +176,39 @@ } map.put(key, equFaultRecords); }); + } else { + map.forEach((key, value1) -> { + MdcEquipmentFaultInfo equFaultRecords = value1; + List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); + if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { + // 鏃堕棿淇 + if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { + mdcEquipmentRunningSections.get(0).setStartTime(start); + } + if (mdcEquipmentRunningSections.size() > 1) { + if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { + mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); + } + } else { + if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { + mdcEquipmentRunningSections.get(0).setEndTime(end); + } + } + List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); + + if (!collect.isEmpty()) { + long totalProcessingTime = 0; + for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) { + totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime())); + } + equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime); + // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 + BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP); + equFaultRecords.setRemoveFaultRate(removeFaultRate); + } + } + map.put(key, equFaultRecords); + }); } if (!map.isEmpty()) { this.saveBatch(new ArrayList<>(map.values())); diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java index 5db88df..0a0d678 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java @@ -13,20 +13,15 @@ import org.jeecg.modules.mdc.service.*; import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.util.TimeFieldUtils; -import org.jeecg.modules.mdc.vo.EquFaultRecord; import org.jeecg.modules.mdc.vo.MdcAlarmAnalyzeQueryVo; import org.jeecg.modules.mdc.vo.MdcEquipmentRunningSectionVo; -import org.jeecg.modules.mdc.vo.TimeInterval; import org.jeecg.modules.system.service.ISysDictService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.time.LocalDate; -import java.time.LocalDateTime; import java.util.*; -import java.util.stream.Collectors; /** * @Description: 璁惧杩愯鏃舵鐘舵�佽〃 @@ -69,8 +64,6 @@ List<MdcEquipmentRunningSection> running = loadEquipmentRunningTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr()); //鏌ヨ鎶ヨ鏁版嵁 List<MdcEquipmentRunningSection> errs = loadEquipmentErrorTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr()); - //鏌ヨ鏁呴殰鏁版嵁 - List<MdcEquipmentRunningSection> faults = loadEquipmentFaultTrace(equipmentRunningSectionVo.getEquipmentId(), equipmentRunningSectionVo.getCollectTimeStr()); Equipment equip = equipmentService.getOne(new LambdaQueryWrapper<Equipment>().eq(Equipment::getEquipmentid, equipmentRunningSectionVo.getEquipmentId())); if (!running.isEmpty()) { MdcEquipmentRunningSectionDto dto; @@ -107,12 +100,22 @@ } } } +// Set<TmpEquipmentAlarm> set = entity.getTmpEquipmentAlarmSet(); +// if (entity.getStatus() == 22 && set != null && !set.isEmpty()) { +// Iterator<TmpEquipmentAlarm> iterator = entity.getTmpEquipmentAlarmSet().iterator(); +// //鑾峰彇鎶ヨ缂栧彿鐩稿悓鐨勬姤璀︿俊鎭� +// while (iterator.hasNext()) { +// TmpEquipmentAlarm next = iterator.next(); +// if (StringUtils.isNotBlank(next.getAlarmNo()) && next.getAlarmNo().equals(entity.getStatus())) { +// dto.setAlarmContent(next.getAlarmContent()); +// } +// } +// } dtos.add(dto); } } List<MdcEquipmentRunningSectionDto> result = new ArrayList<>(); - //鍚堝苟鐩稿悓鐘舵�佹暟鎹� for (int i = 0; i < dtos.size() - 1; i++) { MdcEquipmentRunningSectionDto mdcEquipmentRunningSectionDto = dtos.get(i); @@ -138,105 +141,7 @@ result.addAll(dtos); } - if (faults != null && !faults.isEmpty()) { - MdcEquipmentRunningSectionDto dto; - for (MdcEquipmentRunningSection entity : faults) { - dto = new MdcEquipmentRunningSectionDto(); - BeanUtils.copyProperties(entity, dto); - result.add(dto); - } - } - return result; - } - - private List<MdcEquipmentRunningSection> loadEquipmentFaultTrace(String equipmentId, String collectTimeStr) { - List<MdcEquipmentRunningSection> result = new ArrayList<>(); - Date startTime = DateUtils.getShortDate(collectTimeStr); - Date now = DateUtils.removeTime(DateUtils.getNow()); - long second = DateUtils.differentSecond(startTime, now); - Date endTime = DateUtils.plusTime(startTime, 1); - if (collectTimeStr.equals(LocalDate.now().toString())) { - endTime = DateUtils.getNow(); - } - if (second < 0) { - return Collections.emptyList(); - } else { - List<EquFaultRecord> equFaultRecordList = this.baseMapper.findFaultList(equipmentId, startTime, endTime); - if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) { - - // 淇璁板綍鏃堕棿 - List<EquFaultRecord> correctedRecords = correctRecordTimes(equFaultRecordList, DateUtils.convertToLocalDateTime(startTime), DateUtils.convertToLocalDateTime(endTime)); - - // 鎸夊紑濮嬫椂闂存帓搴� - correctedRecords.sort(Comparator.comparing(EquFaultRecord::getStartTime)); - - // 鍚堝苟閲嶅彔鏃堕棿娈� - List<TimeInterval> mergedIntervals = mergeIntervals(correctedRecords); - - for (TimeInterval mergedInterval : mergedIntervals) { - MdcEquipmentRunningSection mdcEquipmentRunningSection = new MdcEquipmentRunningSection(25, equipmentId, DateUtils.convertToDate(mergedInterval.getStart()), DateUtils.convertToDate(mergedInterval.getEnd()), DateUtils.convertToDate(mergedInterval.getStart()).getTime(), DateUtils.convertToDate(mergedInterval.getEnd()).getTime()); - mdcEquipmentRunningSection.setDuration(DateUtils.differentSecond(mdcEquipmentRunningSection.getStartTime(), mdcEquipmentRunningSection.getEndTime())); - result.add(mdcEquipmentRunningSection); - } - } - } - return result; - } - - private static List<EquFaultRecord> correctRecordTimes(List<EquFaultRecord> records, LocalDateTime startTime, LocalDateTime endTime) { - return records.stream() - .map(record -> { - LocalDateTime recordStart = DateUtils.convertToLocalDateTime(record.getStartTime()); - LocalDateTime recordEnd = record.getEndTime() != null ? - DateUtils.convertToLocalDateTime(record.getEndTime()) : null; - - // 淇寮�濮嬫椂闂� - LocalDateTime correctedStart = recordStart.isBefore(startTime) ? - startTime : recordStart; - - // 淇缁撴潫鏃堕棿 - LocalDateTime correctedEnd = recordEnd == null || recordEnd.isAfter(endTime) ? - endTime : recordEnd; - - // 鍒涘缓淇鍚庣殑璁板綍 - return new EquFaultRecord( - record.getEquipmentId(), - DateUtils.convertToDate(correctedStart), - DateUtils.convertToDate(correctedEnd) - ); - }) - .collect(Collectors.toList()); - } - - private static List<TimeInterval> mergeIntervals(List<EquFaultRecord> records) { - List<TimeInterval> intervals = records.stream() - .map(record -> new TimeInterval( - DateUtils.convertToLocalDateTime(record.getStartTime()), - DateUtils.convertToLocalDateTime(record.getEndTime()))) - .collect(Collectors.toList()); - - if (intervals.isEmpty()) { - return Collections.emptyList(); - } - - List<TimeInterval> merged = new ArrayList<>(); - TimeInterval current = intervals.get(0); - - for (int i = 1; i < intervals.size(); i++) { - TimeInterval next = intervals.get(i); - if (next.getStart().isBefore(current.getEnd()) || next.getStart().equals(current.getEnd())) { - // 鏈夐噸鍙狅紝鍚堝苟鍖洪棿 - current.setEnd(current.getEnd().isAfter(next.getEnd()) ? current.getEnd() : next.getEnd()); - } else { - // 鏃犻噸鍙狅紝娣诲姞褰撳墠鍖洪棿骞舵洿鏂板綋鍓嶅尯闂� - merged.add(current); - current = next; - } - } - merged.add(current); // 娣诲姞鏈�鍚庝竴涓尯闂� - - return merged; } /** @@ -615,9 +520,9 @@ //鑾峰彇running杩愯鐨勬棩蹇楄褰� List<MdcEquipmentRunningSection> list = this.equipmentRunningTracesLog(equipment.getEquipmentid()); if (list != null && !list.isEmpty()) { -// List<MdcEquipmentRunningSection> equipList = addSequenceNumber(list); //娣诲姞绋嬪簭鍙� - this.ergodicTrim(list); - super.saveBatch(list); + List<MdcEquipmentRunningSection> equipList = addSequenceNumber(list); //娣诲姞绋嬪簭鍙� + this.ergodicTrim(equipList); + super.saveBatch(equipList); } //鑾峰彇鎶ヨ鐨勬棩蹇楄褰� List<MdcEquipmentRunningSection> errorList = this.equipmentRunningTracesErrorLog(equipment.getEquipmentid()); @@ -850,13 +755,10 @@ Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>(); List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>(); List<MdcEquipmentRunningSectionDto> waring = new ArrayList<>(); - List<MdcEquipmentRunningSectionDto> fault = new ArrayList<>(); //杩愯 List<MdcEquipmentRunningSection> running = loadEquipmentRunningTrace(equipmentRunningSectionVo.getEquipmentId(), date); //鎶ヨ List<MdcEquipmentRunningSection> errs = loadEquipmentErrorTrace(equipmentRunningSectionVo.getEquipmentId(), date); - //鏁呴殰 - List<MdcEquipmentRunningSection> faults = loadEquipmentFaultTrace(equipmentRunningSectionVo.getEquipmentId(), date); if (running != null && !running.isEmpty()) { MdcEquipmentRunningSectionDto dto; @@ -880,20 +782,8 @@ map.put("waring", null); } - if (!faults.isEmpty()) { - MdcEquipmentRunningSectionDto dto; - for (MdcEquipmentRunningSection mdcEquipmentRunningSection : faults) { - dto = new MdcEquipmentRunningSectionDto(); - BeanUtils.copyProperties(mdcEquipmentRunningSection, dto); - fault.add(dto); - } - } else { - map.put("fault", null); - } - map.put("normal", normal); map.put("waring", waring); - map.put("fault", fault); return map; } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java deleted file mode 100644 index 646dc55..0000000 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.jeecg.modules.mdc.util; - -import org.apache.ibatis.jdbc.SqlRunner; -import org.apache.ibatis.session.SqlSession; -import org.apache.ibatis.session.SqlSessionFactory; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * @author Lius - * @date 2025/1/3 13:26 - */ -@Component -public class SqlExecutor { - - @Resource - private SqlSessionFactory sqlSessionFactory; - - public void execute(String sql) { - try (SqlSession sqlSession = sqlSessionFactory.openSession(true)) { - SqlRunner runner = new SqlRunner(sqlSession.getConnection()); - runner.run(sql); - } catch (Exception e) { -// e.printStackTrace(); - throw new RuntimeException("Error executing SQL: " + sql, e); - } - } -} diff --git a/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/controller/MsiWebapiJsonController.java b/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/controller/MsiWebapiJsonController.java index 54c5d15..b3d2a0d 100644 --- a/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/controller/MsiWebapiJsonController.java +++ b/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/controller/MsiWebapiJsonController.java @@ -42,14 +42,14 @@ entity.setModuleType("MDC"); entity.setWebapiInfo(data.toString()); //鍚庣画杩涜鍏朵粬涓氬姟鍏宠仈 - JsonMapper mapper = new JsonMapper(); +// JsonMapper mapper = new JsonMapper(); + service.save(entity); try { service.saveTableAutomationOne(data); } catch (Exception e) { log.error("JSON parsing error: {}", e.getMessage()); return Result.error("鏁版嵁寮傚父", e.getMessage()); } - service.save(entity); return Result.OK("鎺ユ敹鎴愬姛"); } diff --git a/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java b/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java index 5364928..d0f9f2c 100644 --- a/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java +++ b/lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java @@ -3,8 +3,10 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import liquibase.util.JdbcUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.util.DateUtils; +import org.jeecg.common.util.RedisUtil; import org.jeecg.modules.msi.webapi.entity.MsiWebapiJsonEntity; import org.jeecg.modules.msi.webapi.mapper.MsiWebapiJsonMapper; import org.jeecg.modules.msi.webapi.service.IMsiWebapiJsonService; @@ -15,7 +17,9 @@ import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.interceptor.TransactionAspectSupport; +import org.jetbrains.annotations.NotNull; +import javax.annotation.Resource; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; @@ -24,29 +28,33 @@ import java.util.*; @Service +@Slf4j public class MsiWebapiJsonServiceImpl extends ServiceImpl<MsiWebapiJsonMapper, MsiWebapiJsonEntity> implements IMsiWebapiJsonService { @Autowired private JdbcTemplate jdbcTemplate; + @Resource + private RedisUtil redisUtil; + + private final static String ZDHKEY = "ZDHKEY_"; + /** * 瑙f瀽鍗曟潯鏁版嵁淇濆瓨鍒板崟琛� + * * @param data * @return */ @Override public boolean saveTableAutomationOne(List<MachineEquipentInfo> data) { - if (data ==null || data.isEmpty()) { + if (data == null || data.isEmpty()) { return false; } List<String> listStatus = new ArrayList<>(); List<String> listParameter = new ArrayList<>(); - // 鐢ㄤ簬璁板綍鍓嶄竴鏉¤褰曠殑鐘舵�佸�� - String prevRunningStatus = null; - for (MachineEquipentInfo machineInfo : data) { - System.out.println(machineInfo); +// log.info("鎺ユ敹鑷姩鍖栨暟鎹細" + machineInfo); // 鑾峰彇褰撳墠璁板綍鐨剅unningStatus鍊� String currentRunningStatus = null; @@ -57,23 +65,38 @@ } } - // 濡傛灉褰撳墠鐘舵�佷笌鍓嶄竴鏉$浉鍚岋紝鍒欒烦杩� - if (currentRunningStatus != null && currentRunningStatus.equals(prevRunningStatus)) { - continue; - } + // 鑾峰彇鍓嶄竴鏉$姸鎬� + if (redisUtil.hasKey(ZDHKEY + machineInfo.getMachineNo())) { + String prevRunningStatus = (String) redisUtil.get(ZDHKEY + machineInfo.getMachineNo()); - // 鏇存柊鍓嶄竴鏉¤褰曠殑鐘舵�佸�� - prevRunningStatus = currentRunningStatus; + // 濡傛灉褰撳墠鐘舵�佷笌鍓嶄竴鏉$浉鍚岋紝鍒欏彧鍐欏叆鍗曡〃鏁版嵁 + if (currentRunningStatus != null && currentRunningStatus.equals(prevRunningStatus)) { + String parameter = listSqlParameter(machineInfo); + if (parameter != null && !parameter.equals("")) { + listParameter.add(parameter); + } + continue; + } + + // 鏇存柊鍓嶄竴鏉¤褰曠殑鐘舵�佸�� + redisUtil.set(ZDHKEY + machineInfo.getMachineNo(), currentRunningStatus); + } else { + if (currentRunningStatus != null) { + redisUtil.set(ZDHKEY + machineInfo.getMachineNo(), currentRunningStatus); + } + } // 鐢熸垚SQL String stutus = listSqls(machineInfo); if (stutus != null && !stutus.equals("")) { listStatus.add(stutus); } + String parameter = listSqlParameter(machineInfo); if (parameter != null && !parameter.equals("")) { listParameter.add(parameter); } + } // 鎵ц鐘舵�佹暟鎹甋QL try { @@ -91,6 +114,7 @@ /** * 鎵归噺鎵цSQL璇彞 + * * @param sqlList SQL璇彞鍒楄〃 * @throws SQLException */ @@ -126,22 +150,23 @@ /** - * 鎻掑叆鍒癊quipmentLog + * 鎻掑叆鍒拌澶囧崟琛� + * * @param machineInfo * @return */ public String listSqlParameter(MachineEquipentInfo machineInfo) { String listSqls = null; List<DetailedListVo> itemList = machineInfo.getItemList(); - Map<String ,DetailedListVo> itemMap = new HashMap<String ,DetailedListVo>(); - for (DetailedListVo item: itemList) { - itemMap.put(item.getItemName(),item); + Map<String, DetailedListVo> itemMap = new HashMap<String, DetailedListVo>(); + for (DetailedListVo item : itemList) { + itemMap.put(item.getItemName(), item); } String sql = "insert into "; sql = sql + "ZDH_" + machineInfo.getMachineNo() + " "; sql = sql + "(EquipmentID,EquipmentName,CollectTime,runningStatus,spindleSpeed,feedRatio,runDuration,spindleDuration,progName,progStatus,toolNo) values ( "; //EquipmentID - if (machineInfo.getMachineNo() == null || machineInfo.getMachineNo().equals("")) { + if (machineInfo.getMachineNo() == null || machineInfo.getMachineNo().equals("")) { return null; } else { sql = sql + "'" + machineInfo.getMachineNo() + "', "; @@ -151,18 +176,7 @@ //CollectTime // 鍋囪 endTime 鏄� "MM/dd/yyyy HH:mm:ss" 鏍煎紡鐨勫瓧绗︿覆 if (machineInfo.getEndTime() != null && !machineInfo.getEndTime().isEmpty()) { - try { - // 1. 灏嗗瓧绗︿覆瑙f瀽涓� Date 瀵硅薄 - SimpleDateFormat inputFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); - Date endDate = inputFormat.parse(machineInfo.getEndTime()); - - // 2. 灏� Date 鏍煎紡鍖栦负鐩爣 SQL 鏍煎紡锛堝 "yyyy-MM-dd HH:mm:ss"锛� - SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - sql = sql + "'" + outputFormat.format(endDate) + "', "; - } catch (ParseException e) { - // 澶勭悊瑙f瀽澶辫触鐨勬儏鍐碉紙濡傛棩蹇楄褰曟垨鎶涘嚭寮傚父锛� - throw new RuntimeException("Invalid end time format: " + machineInfo.getEndTime(), e); - } + sql = getTime(machineInfo, sql); } else { // 濡傛灉 endTime 涓� null 鎴栫┖锛屼娇鐢ㄥ綋鍓嶆椂闂� sql = sql + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "', "; @@ -182,7 +196,7 @@ //feedRatio if (itemMap.containsKey("feedRatio")) { sql = sql + "'" + itemMap.get("feedRatio").getItemValue() + "', "; - }else { + } else { sql = sql + "NULL, "; } //runDuration @@ -217,7 +231,7 @@ } sql = sql + "); \n"; - if (StringUtils.isBlank(listSqls) ) { + if (StringUtils.isBlank(listSqls)) { listSqls = sql; } else { listSqls += sql; @@ -227,7 +241,8 @@ /** - * 鎻掑叆鍒癊quipmentLog + * 鎻掑叆鍒癊quipmentLog + * * @param machineInfo * @return */ @@ -242,37 +257,72 @@ } sql = sql + null + ", "; if (machineInfo.getEndTime() != null) { - - sql = sql + "'" + DateUtils.formattedDate(machineInfo.getEndTime(),DateUtils.STR_DD_MM_YYYY,DateUtils.STR_DATE_TIME_SMALL) + "', "; + sql = getTime(machineInfo, sql); } else { return null; } - Map<String ,DetailedListVo> itemMap = new HashMap<String ,DetailedListVo>(); - for (DetailedListVo item: itemList) { - itemMap.put(item.getItemName(),item); + Map<String, DetailedListVo> itemMap = new HashMap<String, DetailedListVo>(); + for (DetailedListVo item : itemList) { + itemMap.put(item.getItemName(), item); } if (itemMap.containsKey("runningStatus")) { int oporation = 0; switch (itemMap.get("runningStatus").getItemValue()) { - case "0" : oporation =0;break; - case "1" : oporation =2;break; - case "2" : oporation =3;break; - case "3" : oporation =2;break; - case "4" : oporation =2;break; - case "10" : oporation =2;break; - case "13" : oporation =2;break; - case "14" : oporation =2;break; - case "10001" : oporation =2;break; - default: break; + case "0": + oporation = 0; + break; + case "1": + oporation = 2; + break; + case "2": + oporation = 3; + break; + case "3": + oporation = 2; + break; + case "4": + oporation = 2; + break; + case "10": + oporation = 2; + break; + case "13": + oporation = 2; + break; + case "14": + oporation = 2; + break; + case "10001": + oporation = 2; + break; + default: + break; } - sql = sql + " " + oporation + ", "; + sql = sql + " " + oporation + ", "; } else { return null; } - sql = sql + null + " ); \n"; - if (StringUtils.isBlank(listSqls) ) { + sql = sql + null + " ); \n"; + if (StringUtils.isBlank(listSqls)) { listSqls = sql; } return listSqls; } + + @NotNull + private String getTime(MachineEquipentInfo machineInfo, String sql) { + try { + // 1. 灏嗗瓧绗︿覆瑙f瀽涓� Date 瀵硅薄 + SimpleDateFormat inputFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + Date endDate = inputFormat.parse(machineInfo.getEndTime()); + + // 2. 灏� Date 鏍煎紡鍖栦负鐩爣 SQL 鏍煎紡锛堝 "yyyy-MM-dd HH:mm:ss"锛� + SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + sql = sql + "'" + outputFormat.format(endDate) + "', "; + } catch (ParseException e) { + // 澶勭悊瑙f瀽澶辫触鐨勬儏鍐碉紙濡傛棩蹇楄褰曟垨鎶涘嚭寮傚父锛� + throw new RuntimeException("Invalid end time format: " + machineInfo.getEndTime(), e); + } + return sql; + } } -- Gitblit v1.9.3