Lius
2025-06-28 39f62fa03a2463652e971edfabab56313db6af10
涉密->工控
已添加1个文件
已修改24个文件
已删除2个文件
749 ■■■■■ 文件已修改
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/AndonOrderController.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/AndonOrder.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentRunningSection.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/CollectEquipmentDataMonthJob.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ImportXmlToDataJob.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningOverallEquipmentEfficiencyJob.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentAlarmMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcAlarmInfoMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcAlarmInfoMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeOperatorMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcOeeInfoMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcWorkshopInfoMapper.xml 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/AndonOrderServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/EquipmentAlarmServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcAlarmInfoServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java 138 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/controller/MsiWebapiJsonController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/service/impl/MsiWebapiJsonServiceImpl.java 148 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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("呼叫成功!");
    }
}
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
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;
    }
}
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);
                        }
                    }
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/ImportXmlToDataJob.java
ÎļþÒÑɾ³ý
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);
    }
}
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);
}
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);
}
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;
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();
}
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>
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>
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>
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 &lt;= #{ vo.endTime }
            AND t1.the_date &gt;= #{ vo.startTime }
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 &lt; #{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>
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=",">
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>
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">
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: æ•…障率表
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;
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;
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);
    }
}
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()));
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;
    }
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/util/SqlExecutor.java
ÎļþÒÑɾ³ý
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("接收成功");
    }
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_";
    /**
     * è§£æžå•条数据保存到单表
     *
     * @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);
            // èŽ·å–å½“å‰è®°å½•çš„runningStatus值
            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);
            }
        }
        // æ‰§è¡ŒçŠ¶æ€æ•°æ®SQL
        try {
@@ -91,6 +114,7 @@
    /**
     * æ‰¹é‡æ‰§è¡ŒSQL语句
     *
     * @param sqlList SQL语句列表
     * @throws SQLException
     */
@@ -126,22 +150,23 @@
    /**
     *  æ’入到EquipmentLog
     * æ’入到设备单表
     *
     * @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. å°†å­—符串解析为 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) {
                // å¤„理解析失败的情况(如日志记录或抛出异常)
                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 @@
    /**
     *  æ’入到EquipmentLog
     * æ’入到EquipmentLog
     *
     * @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. å°†å­—符串解析为 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) {
            // å¤„理解析失败的情况(如日志记录或抛出异常)
            throw new RuntimeException("Invalid end time format: " + machineInfo.getEndTime(), e);
        }
        return sql;
    }
}