Lius
2025-06-28 3d4e5941c728ff1c13d05195299c9c2163060ea4
update
已添加9个文件
已修改12个文件
1116 ■■■■■ 文件已修改
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/util/DateUtils.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentFaultInfo.java 87 ●●●●● 补丁 | 查看 | 原始文档 | 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/mapper/MdcEquipmentFaultInfoMapper.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java 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/MdcEquipmentFaultInfoMapper.xml 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java 380 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquFaultRecord.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/TimeInterval.java 21 ●●●●● 补丁 | 查看 | 原始文档 | 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 112 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/controller/TriggerCreateController.java 204 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/vo/TriggerVo.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-system/lxzn-system-start/src/main/resources/application-prod.yml 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-mdc-common/src/main/java/org/jeecg/modules/mdc/util/DateUtils.java
@@ -6,9 +6,7 @@
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.*;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.util.*;
@@ -1086,4 +1084,32 @@
        return dateString;
    }
    /**
     * Date与LocalDateTime互相转换的工具方法
     *
     * @param date
     * @return
     */
    public static LocalDateTime convertToLocalDateTime(Date date) {
        if (date == null) {
            return null;
        }
        return Instant.ofEpochMilli(date.getTime())
                .atZone(ZoneId.systemDefault())
                .toLocalDateTime();
    }
    /**
     * Date与LocalDateTime互相转换的工具方法
     *
     * @param localDateTime
     * @return
     */
    public static Date convertToDate(LocalDateTime localDateTime) {
        if (localDateTime == null) {
            return null;
        }
        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipmentFaultInfo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,87 @@
package org.jeecg.modules.mdc.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
 * @Description: æ•…障率表
 * @Author: Lius
 * @Date: 2025-06-16
 * @Version: V1.0
 */
@Data
@TableName("mdc_equipment_fault_info")
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "mdc_equipment_fault_info对象", description = "故障率表")
public class MdcEquipmentFaultInfo implements Serializable {
    private static final long serialVersionUID = 7825739575204258911L;
    /**
     * ä¸»é”®
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
    /**
     * è®¾å¤‡id
     */
    @Excel(name = "设备id", width = 15)
    @ApiModelProperty(value = "设备id")
    private String equipmentId;
    /**
     * æ•…障时长
     */
    @Excel(name = "故障时长", width = 15)
    @ApiModelProperty(value = "故障时长")
    private Integer faultLong = 0;
    /**
     * æ•…障率
     */
    @Excel(name = "故障率", width = 15)
    @ApiModelProperty(value = "故障率")
    private BigDecimal faultRate = BigDecimal.ZERO;
    /**
     * åŽ»é™¤æ•…éšœæ—¶é—´çš„è¿è¡Œæ—¶é—´
     */
    @Excel(name = "去除故障时间的运行时间", width = 15)
    @ApiModelProperty(value = "去除故障时间的运行时间")
    private Integer removeFaultRunLong = 0;
    /**
     * åŽ»é™¤æ•…éšœæ—¶é—´åˆ©ç”¨çŽ‡
     */
    @Excel(name = "去除故障时间利用率", width = 15)
    @ApiModelProperty(value = "去除故障时间利用率")
    private BigDecimal removeFaultRate = BigDecimal.ZERO;
    /**
     * æœ‰æ•ˆæ—¥æœŸ
     */
    @Excel(name = "有效日期", width = 15)
    @ApiModelProperty(value = "有效日期")
    private String theDate;
    /**
     * åˆ›å»ºæ—¶é—´
     */
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    public MdcEquipmentFaultInfo() {
    }
    public MdcEquipmentFaultInfo(String equipmentId, String theDate) {
        this.equipmentId = equipmentId;
        this.theDate = theDate;
    }
}
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/mapper/MdcEquipmentFaultInfoMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
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 org.jeecg.modules.mdc.vo.EquFaultRecord;
import java.util.List;
/**
 * @Description: æ•…障率表
 * @Author: jeecg-boot
 * @Date:   2025-06-16
 * @Version: V1.0
 */
public interface MdcEquipmentFaultInfoMapper extends BaseMapper<MdcEquipmentFaultInfo> {
    List<EquFaultRecord> findFaultRecord(@Param("equipmentIdList") List<String> equipmentIdList, @Param("startTime") String startTime, @Param("endTime") String endTime);
    String getMaxStaticsData();
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentRunningSectionMapper.java
@@ -78,4 +78,6 @@
    List<Integer> getDataList(@Param("equipmentId") String equipmentId, @Param("date") Date date);
    List<MdcEquipmentWaitSectionDto> findWaitList(@Param("date") String date);
    MdcEquipmentRunningSection getFirstRecord();
}
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/MdcEquipmentFaultInfoMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mdc.mapper.MdcEquipmentFaultInfoMapper">
    <select id="findFaultRecord" 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 IN
            <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
                #{ id }
            </foreach>
          AND t1.report_status != 'ABOLISH'
    </select>
    <select id="getMaxStaticsData" resultType="java.lang.String">
        SELECT TOP 1 the_date FROM mdc_equipment_fault_info ORDER BY the_date DESC
    </select>
</mapper>
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
@@ -188,5 +188,7 @@
            equipment_id, start_time DESC
    </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/service/IMdcEquipmentFaultInfoService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package org.jeecg.modules.mdc.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo;
/**
 * @Description: æ•…障率表
 * @Author: Lius
 * @Date: 2025-06-16
 * @Version: V1.0
 */
public interface IMdcEquipmentFaultInfoService extends IService<MdcEquipmentFaultInfo> {
    /**
     * ç»Ÿè®¡æ•…障时长,计算故障率
     * @param parameter
     */
    void runningAllEquFaultStatistical(String parameter);
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentRunningSectionService.java
@@ -90,4 +90,7 @@
    List<Integer> getDataList(String equipmentId, Date date);
    List<MdcEquipmentWaitSectionDto> findWaitList(String date);
    MdcEquipmentRunningSection getFirstRecord();
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,380 @@
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.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;
import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService;
import org.jeecg.modules.mdc.service.IMdcSystemParametersService;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.vo.EquFaultRecord;
import org.jeecg.modules.mdc.vo.TimeInterval;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @Description: æ•…障率表
 * @Author: Lius
 * @Date: 2025-06-16
 * @Version: V1.0
 */
@Service
public class MdcEquipmentFaultInfoServiceImpl extends ServiceImpl<MdcEquipmentFaultInfoMapper, MdcEquipmentFaultInfo> implements IMdcEquipmentFaultInfoService {
    @Resource
    private IEquipmentService equipmentService;
    @Resource
    private IMdcSystemParametersService mdcSystemParametersService;
    @Resource
    private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService;
    @Override
    @Transactional(rollbackFor = {Exception.class})
    public void runningAllEquFaultStatistical(String dateTime) {
        Date initDate = null;
        if (StringUtils.isNotBlank(dateTime)) {
            initDate = DateUtils.toDate(dateTime, DateUtils.STRDATE);
        } else {
            // å–最后的统计时间
            String date = this.baseMapper.getMaxStaticsData();
            if (date != null) {
                initDate = DateUtils.toDate(date, DateUtils.STRDATE);
            } else {
                // åˆæ¬¡å–值 å–最早时间记录
                MdcEquipmentRunningSection equipmentRunningSection = mdcEquipmentRunningSectionService.getFirstRecord();
                if (equipmentRunningSection != null) {
                    initDate = equipmentRunningSection.getStartTime();
                }
            }
        }
        Date endDate = DateUtils.addDays(DateUtils.getNow(), -1);
        List<String> dateList = DateUtils.getDatesStringList2(initDate, endDate);
        if (dateList.isEmpty()) {
            return;
        }
        try {
            this.remove(new LambdaQueryWrapper<MdcEquipmentFaultInfo>().in(MdcEquipmentFaultInfo::getTheDate, dateList));
        } catch (Exception e) {
            log.error("参数格式不对", e);
        }
        List<Equipment> equipmentList = equipmentService.list();
        if (equipmentList == null || equipmentList.isEmpty()) {
            return;
        }
        String planTime = "00:00:00";
        MdcSystemParameters mdcSystemParameters = mdcSystemParametersService.getOne(new LambdaQueryWrapper<MdcSystemParameters>().eq(MdcSystemParameters::getCode, "equip_log_statis_time"));
        if (mdcSystemParameters != null) {
            planTime = mdcSystemParameters.getValue();
        }
        List<String> equipmentIdList = equipmentList.stream().map(Equipment::getEquipmentid).collect(Collectors.toList());
        for (String validDate : dateList) {
            Map<String, MdcEquipmentFaultInfo> map = new HashMap<>();
            String finalValidDate = validDate;
            equipmentList.forEach(equipment -> {
                MdcEquipmentFaultInfo mdcEquipmentFaultInfo = new MdcEquipmentFaultInfo(equipment.getEquipmentid(), finalValidDate);
                map.put(equipment.getEquipmentid(), mdcEquipmentFaultInfo);
            });
            String startTime = DateUtils.format(DateUtils.setTimeForDay(DateUtils.toDate(validDate, DateUtils.STRDATE), planTime), DateUtils.STR_DATE_TIME_SMALL);
            Date start = DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL);
            String endTime = DateUtils.format(DateUtils.addDays(DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL), 1), DateUtils.STR_DATE_TIME_SMALL);
            Date end = DateUtils.toDate(endTime, DateUtils.STR_DATE_TIME_SMALL);
            //查询故障记录
            List<EquFaultRecord> equFaultRecordList = this.baseMapper.findFaultRecord(equipmentIdList, startTime, endTime);
            if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) {
                // ä¿®æ•´æ—¶é—´
                Map<String, List<EquFaultRecord>> equFaultRecordMap = equFaultRecordList.stream().collect(Collectors.groupingBy(EquFaultRecord::getEquipmentId));
                map.forEach((key, value1) -> {
                    MdcEquipmentFaultInfo equFaultRecords = value1;
                    if (equFaultRecordMap.containsKey(key)) {
                        List<EquFaultRecord> value = equFaultRecordMap.get(key);
                        long faultLong = calculateTotalFaultDuration(value, start, end);
                        equFaultRecords.setFaultLong((int) faultLong);
                        if (faultLong != 0) {
                            equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP));
                        }
                        // è®¡ç®—去除故障时长的加工时间
                        // step.1 æŸ¥è¯¢åŠ å·¥æ—¶é—´
                        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()) {
                                // step.2 è®¡ç®—去除故障时长的加工时间
                                long processingTime = calculateProcessingTimeWithoutFaults(collect, value, start, end);
                                equFaultRecords.setRemoveFaultRunLong((int) processingTime);
                                if (faultLong != 0 && faultLong != 86400) {
                                    // è®¡ç®—去除故障时长的利用率
                                    BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("864").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP);
                                    equFaultRecords.setRemoveFaultRate(removeFaultRate);
                                }
                            }
                        }
                    } else {
                        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);
                });
            } 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()));
            }
        }
    }
    public static long calculateTotalFaultDuration(List<EquFaultRecord> records, Date startTime, Date endTime) {
        LocalDateTime start = DateUtils.convertToLocalDateTime(startTime);
        LocalDateTime end = DateUtils.convertToLocalDateTime(endTime);
        // ä¿®æ­£è®°å½•æ—¶é—´
        List<EquFaultRecord> correctedRecords = correctRecordTimes(records, start, end);
        // æŒ‰å¼€å§‹æ—¶é—´æŽ’序
        correctedRecords.sort(Comparator.comparing(EquFaultRecord::getStartTime));
        // åˆå¹¶é‡å æ—¶é—´æ®µ
        List<TimeInterval> mergedIntervals = mergeIntervals(correctedRecords);
        // è®¡ç®—总时长(秒)
        return mergedIntervals.stream()
                .mapToLong(interval -> ChronoUnit.SECONDS.between(interval.getStart(), interval.getEnd()))
                .sum();
    }
    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;
    }
    // è®¡ç®—去除故障时长后的加工时间
    private long calculateProcessingTimeWithoutFaults(
            List<MdcEquipmentRunningSection> runningSections,
            List<EquFaultRecord> faultRecords,
            Date startTime,
            Date endTime) {
        // è½¬æ¢ä¸ºLocalDateTime进行处理
        LocalDateTime start = DateUtils.convertToLocalDateTime(startTime);
        LocalDateTime end = DateUtils.convertToLocalDateTime(endTime);
        // ä¿®æ­£è®°å½•æ—¶é—´
        List<EquFaultRecord> correctedRecords = correctRecordTimes(faultRecords, start, end);
        List<TimeInterval> mergedFaultIntervals = mergeIntervals(correctedRecords);
        long totalProcessingTime = 0;
        // éåŽ†æ¯ä¸ªåŠ å·¥åŒºé—´ï¼ŒæŽ’é™¤æ•…éšœæ—¶é—´
        for (MdcEquipmentRunningSection section : runningSections) {
            LocalDateTime sectionStart = DateUtils.convertToLocalDateTime(section.getStartTime());
            LocalDateTime sectionEnd = DateUtils.convertToLocalDateTime(section.getEndTime());
            // æŽ’除故障时间后的有效加工时间
            List<TimeInterval> validIntervals = excludeFaultsFromSection(
                    new TimeInterval(sectionStart, sectionEnd),
                    mergedFaultIntervals);
            // ç´¯åŠ æœ‰æ•ˆåŠ å·¥æ—¶é—´ï¼ˆç§’ï¼‰
            for (TimeInterval interval : validIntervals) {
                totalProcessingTime += ChronoUnit.SECONDS.between(interval.getStart(), interval.getEnd());
            }
        }
        return totalProcessingTime;
    }
    // ä»Žè¿è¡ŒåŒºé—´ä¸­æŽ’除故障时间
    private List<TimeInterval> excludeFaultsFromSection(
            TimeInterval section,
            List<TimeInterval> faultIntervals) {
        List<TimeInterval> validIntervals = new ArrayList<>();
        validIntervals.add(section);
        // éåŽ†æ¯ä¸ªæ•…éšœåŒºé—´ï¼Œä»Žæœ‰æ•ˆåŒºé—´ä¸­æ‰£é™¤
        for (TimeInterval fault : faultIntervals) {
            List<TimeInterval> newValidIntervals = new ArrayList<>();
            for (TimeInterval valid : validIntervals) {
                // è®¡ç®—有效区间与故障区间的交集
                if (isOverlapping(valid, fault)) {
                    // åˆ†å‰²æœ‰æ•ˆåŒºé—´
                    splitInterval(valid, fault, newValidIntervals);
                } else {
                    // æ— äº¤é›†ï¼Œä¿ç•™åŽŸæœ‰æ•ˆåŒºé—´
                    newValidIntervals.add(valid);
                }
            }
            validIntervals = newValidIntervals;
        }
        return validIntervals;
    }
    // åˆ¤æ–­ä¸¤ä¸ªæ—¶é—´åŒºé—´æ˜¯å¦é‡å 
    private boolean isOverlapping(TimeInterval a, TimeInterval b) {
        return a.getStart().isBefore(b.getEnd()) && b.getStart().isBefore(a.getEnd());
    }
    // åˆ†å‰²åŒºé—´ï¼ˆæ‰£é™¤é‡å éƒ¨åˆ†ï¼‰
    private void splitInterval(
            TimeInterval valid,
            TimeInterval fault,
            List<TimeInterval> result) {
        // é‡å å‰çš„部分
        if (valid.getStart().isBefore(fault.getStart())) {
            result.add(new TimeInterval(valid.getStart(), fault.getStart()));
        }
        // é‡å åŽçš„部分
        if (valid.getEnd().isAfter(fault.getEnd())) {
            result.add(new TimeInterval(fault.getEnd(), valid.getEnd()));
        }
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentRunningSectionServiceImpl.java
@@ -746,6 +746,11 @@
        return this.baseMapper.findWaitList(date);
    }
    @Override
    public MdcEquipmentRunningSection getFirstRecord() {
        return this.baseMapper.getFirstRecord();
    }
    private Map<String, List<MdcEquipmentRunningSectionDto>> logCharts(MdcEquipmentRunningSectionVo equipmentRunningSectionVo, String date) {
        Map<String, List<MdcEquipmentRunningSectionDto>> map = new HashMap<>();
        List<MdcEquipmentRunningSectionDto> normal = new ArrayList<>();
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
@@ -37,10 +37,7 @@
    private IMdcSystemParametersService mdcSystemParametersService;
    @Resource
    private ISysDictService sysDictService;
    @Resource
    private IEquipmentStatisticalInfoService equipmentStatisticalInfoService;
    private IMdcEquipmentFaultInfoService mdcEquipmentFaultInfoService;
    /**
     * è®¡ç®—设备单日运行数据
@@ -69,28 +66,8 @@
        }
        if (!result.isEmpty()) {
            this.saveBatch(result);
            List<DictModel> dictList = sysDictService.queryDictItemsByCode("data_synchronization_flag");
            if (dictList != null && !dictList.isEmpty() && "0".equals(dictList.get(0).getValue())) {
                List<EquipmentStatisticalInfo> list = this.dataHandle(result);
                equipmentStatisticalInfoService.saveBatch(list);
            }
        }
    }
    private List<EquipmentStatisticalInfo> dataHandle(List<MdcEquipmentStatisticalInfo> list) {
        List<EquipmentStatisticalInfo> result = new ArrayList<>();
        list.forEach(item -> {
            EquipmentStatisticalInfo equipmentStatisticalInfo = new EquipmentStatisticalInfo();
            equipmentStatisticalInfo.setEquipment(item.getEquipmentId());
            equipmentStatisticalInfo.setTheDate(item.getTheDate());
            equipmentStatisticalInfo.setClosedLong(item.getCloseLong());
            equipmentStatisticalInfo.setOpeningLong(item.getOpenLong());
            equipmentStatisticalInfo.setErroringLong(item.getErrorLong());
            equipmentStatisticalInfo.setProcessingLong(item.getProcessLong());
            equipmentStatisticalInfo.setWaitingLong(item.getWaitLong());
            result.add(equipmentStatisticalInfo);
        });
        return result;
        mdcEquipmentFaultInfoService.runningAllEquFaultStatistical(dateTime);
    }
    private List<MdcEquipmentStatisticalInfo> equipmentStatisticalProcess(Equipment equipment, String dateTime) {
@@ -141,7 +118,6 @@
                List<MdcEquipmentRunningSection> equipmentRunningSectionList = mdcEquipmentRunningSectionService.listForEquipmentStatisticalInfo(equipment.getEquipmentid(), startDate, endDate);
                return this.statisticsData(equipmentRunningSectionList, planTime, startDate, endDate, equipment);
            } else {
                //待验证
                Date end = DateUtils.plusTime(initDate, 1);
                endDate = DateUtils.setTimeForDay(end, planTime);
                List<MdcEquipmentRunningSection> equipmentRunningSectionList = mdcEquipmentRunningSectionService.listForEquipmentStatisticalInfo(equipment.getEquipmentid(), startDate, endDate);
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquFaultRecord.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package org.jeecg.modules.mdc.vo;
import lombok.Data;
import java.util.Date;
/**
 * @Author: Lius
 * @CreateTime: 2025-06-16
 * @Description:
 */
@Data
public class EquFaultRecord {
    /**
     * è®¾å¤‡ç¼–号
     */
    private String equipmentId;
    /**
     * å¼€å§‹æ—¶é—´
     */
    private Date startTime;
    /**
     * ç»“束时间
     */
    private Date endTime;
    public EquFaultRecord(String equipmentId, Date startTime, Date endTime) {
        this.equipmentId = equipmentId;
        this.startTime = startTime;
        this.endTime = endTime;
    }
}
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/TimeInterval.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package org.jeecg.modules.mdc.vo;
import lombok.Data;
import java.time.LocalDateTime;
/**
 * @Author: Lius
 * @CreateTime: 2025-06-17
 * @Description:
 */
@Data
public class TimeInterval {
    LocalDateTime start;
    LocalDateTime end;
    public TimeInterval(LocalDateTime start, LocalDateTime end) {
        this.start = start;
        this.end = end;
    }
}
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,13 +28,20 @@
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
     */
@@ -42,11 +53,8 @@
        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 (redisUtil.hasKey(ZDHKEY + machineInfo.getMachineNo())) {
                String prevRunningStatus = (String) redisUtil.get(ZDHKEY + machineInfo.getMachineNo());
                // å¦‚果当前状态与前一条相同,则只写入单表数据
            if (currentRunningStatus != null && currentRunningStatus.equals(prevRunningStatus)) {
                    String parameter = listSqlParameter(machineInfo);
                    if (parameter != null && !parameter.equals("")) {
                        listParameter.add(parameter);
                    }
                continue;
            }
            // æ›´æ–°å‰ä¸€æ¡è®°å½•的状态值
            prevRunningStatus = currentRunningStatus;
                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,7 +150,8 @@
    /**
     *  æ’入到EquipmentLog
     * æ’入到设备单表
     *
     * @param machineInfo
     * @return
     */
@@ -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()) + "', ";
@@ -228,6 +242,7 @@
    /**
     *  æ’入到EquipmentLog
     *
     * @param machineInfo
     * @return
     */
@@ -242,8 +257,7 @@
        }
        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;
        }
@@ -254,16 +268,35 @@
        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  + ", ";
        } else {
@@ -275,4 +308,21 @@
        }
        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;
    }
}
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/controller/TriggerCreateController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,204 @@
package org.jeecg.modules.system.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.system.vo.TriggerVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
/**
 * @Author: Lius
 * @CreateTime: 2025-06-26
 * @Description:
 */
@Api(tags = "触发器")
@RestController
@RequestMapping("/sys/trigger")
@Slf4j
public class TriggerCreateController {
    @AutoLog(value = "触发器-生成触发器")
    @ApiOperation(value = "触发器-生成触发器", notes = "触发器-生成触发器")
    @GetMapping(value = "/list")
    public Result create(@RequestBody TriggerVo triggerVo) {
        String schemaName = "dbo"; // SQL Server é»˜è®¤æž¶æž„
        String logTableName = "log_table"; // æ—¥å¿—表名
        try (Connection connection = DriverManager.getConnection(triggerVo.getJdbcUrl(), triggerVo.getUsername(), triggerVo.getPassword())) {
            // èŽ·å–æŒ‡å®šæž¶æž„ä¸‹çš„æ‰€æœ‰è¡¨
            List<String> tables = getTables(connection, schemaName);
            // ç”Ÿæˆè§¦å‘器 SQL å¹¶ä¿å­˜åˆ°æ–‡ä»¶
            generateTriggersForTables(connection, schemaName, logTableName, tables);
        } catch (SQLException | IOException e) {
            e.printStackTrace();
        }
        return Result.ok();
    }
    /**
     * èŽ·å–æŒ‡å®šæž¶æž„ä¸‹çš„æ‰€æœ‰è¡¨
     */
    private static List<String> getTables(Connection connection, String schemaName) throws SQLException {
        List<String> tables = new ArrayList<>();
        DatabaseMetaData metaData = connection.getMetaData();
        try (ResultSet resultSet = metaData.getTables(null, schemaName, null, new String[]{"TABLE"})) {
            while (resultSet.next()) {
                String tableName = resultSet.getString("TABLE_NAME");
                tables.add(tableName);
            }
        }
        return tables;
    }
    /**
     * èŽ·å–è¡¨çš„å­—æ®µåˆ—è¡¨
     */
    private static List<String> getTableColumns(Connection connection, String schemaName, String tableName) throws SQLException {
        List<String> columns = new ArrayList<>();
        DatabaseMetaData metaData = connection.getMetaData();
        try (ResultSet resultSet = metaData.getColumns(null, schemaName, tableName, null)) {
            while (resultSet.next()) {
                String columnName = resultSet.getString("COLUMN_NAME");
                columns.add(columnName);
            }
        }
        return columns;
    }
    /**
     * èŽ·å–è¡¨çš„ä¸»é”®åˆ—
     */
    private static String getPrimaryKeyColumn(Connection connection, String schemaName, String tableName) throws SQLException {
        DatabaseMetaData metaData = connection.getMetaData();
        try (ResultSet resultSet = metaData.getPrimaryKeys(null, schemaName, tableName)) {
            if (resultSet.next()) {
                return resultSet.getString("COLUMN_NAME");
            }
        }
        return "id"; // é»˜è®¤ä½¿ç”¨id作为主键,如果没有找到主键
    }
    /**
     * ä¸ºæ‰€æœ‰è¡¨ç”Ÿæˆè§¦å‘器
     */
    private static void generateTriggersForTables(Connection connection, String schemaName, String logTableName, List<String> tables) throws SQLException, IOException {
        try (FileWriter writer = new FileWriter("triggers.sql")) {
            for (String tableName : tables) {
                // èŽ·å–è¡¨ç»“æž„ä¿¡æ¯
                List<String> columns = getTableColumns(connection, schemaName, tableName);
                String primaryKey = getPrimaryKeyColumn(connection, schemaName, tableName);
                // ç”Ÿæˆè§¦å‘器 SQL
                String triggerSQL = generateTriggerSQL(schemaName, tableName, logTableName, columns, primaryKey);
                // å°†ç”Ÿæˆçš„触发器 SQL å†™å…¥æ–‡ä»¶
                writer.write("-- è§¦å‘器表: " + tableName + "\n");
                writer.write(triggerSQL);
                writer.write("\n\n");
                // å¦‚果需要,可以直接在数据库中创建触发器
                // createTrigger(connection, triggerSQL);
            }
            System.out.println("成功生成触发器并保存到Triggers.sql中!");
        }
    }
    /**
     * ç”Ÿæˆ SQL Server è§¦å‘器 SQL
     */
    private static String generateTriggerSQL(String schemaName, String tableName, String logTableName, List<String> columns, String primaryKey) {
        StringBuilder triggerSQL = new StringBuilder();
        // è§¦å‘器头部
        triggerSQL.append("CREATE TRIGGER [")
                .append(tableName)
                .append("_trigger]\n")
                .append("ON [")
                .append(schemaName)
                .append("].[").append(tableName).append("]\n")
                .append("AFTER INSERT, UPDATE, DELETE\n")
                .append("AS\n")
                .append("BEGIN\n")
                .append("    SET NOCOUNT ON;\n\n");
        // æ’入操作
        triggerSQL.append("    -- æ’入操作\n")
                .append("    IF EXISTS (SELECT * FROM inserted) AND NOT EXISTS (SELECT * FROM deleted)\n")
                .append("    BEGIN\n")
                .append("        INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n")
                .append("        SELECT 'INSERT', GETDATE(), 'INSERT INTO [").append(tableName).append("] (");
        // æ‹¼æŽ¥å­—段名
        for (int i = 0; i < columns.size(); i++) {
            triggerSQL.append("[").append(columns.get(i)).append("]");
            if (i < columns.size() - 1) {
                triggerSQL.append(", ");
            }
        }
        triggerSQL.append(") VALUES (''' + ");
        // æ‹¼æŽ¥å­—段值
        for (int i = 0; i < columns.size(); i++) {
            triggerSQL.append("ISNULL(CAST(i.").append(columns.get(i)).append(" AS NVARCHAR(MAX)), '') + '''");
            if (i < columns.size() - 1) {
                triggerSQL.append(", ''' + ");
            }
        }
        triggerSQL.append(");'\n")
                .append("        FROM inserted i;\n")
                .append("    END\n\n");
        // æ›´æ–°æ“ä½œ
        triggerSQL.append("    -- æ›´æ–°æ“ä½œ\n")
                .append("    IF EXISTS (SELECT * FROM inserted) AND EXISTS (SELECT * FROM deleted)\n")
                .append("    BEGIN\n")
                .append("        INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n")
                .append("        SELECT 'UPDATE', GETDATE(), 'UPDATE [").append(tableName).append("] SET ");
        // æ‹¼æŽ¥æ›´æ–°å­—段
        for (int i = 0; i < columns.size(); i++) {
            triggerSQL.append("[").append(columns.get(i)).append("] = ''' + ISNULL(CAST(i.").append(columns.get(i)).append(" AS NVARCHAR(MAX)), '') + '''");
            if (i < columns.size() - 1) {
                triggerSQL.append(", ");
            }
        }
        triggerSQL.append(" WHERE [").append(primaryKey).append("] = ''' + ISNULL(CAST(d.").append(primaryKey).append(" AS NVARCHAR(MAX)), '') + ''';'\n")
                .append("        FROM inserted i\n")
                .append("        INNER JOIN deleted d ON i.").append(primaryKey).append(" = d.").append(primaryKey).append(";\n")
                .append("    END\n\n");
        // åˆ é™¤æ“ä½œ
        triggerSQL.append("    -- åˆ é™¤æ“ä½œ\n")
                .append("    IF NOT EXISTS (SELECT * FROM inserted) AND EXISTS (SELECT * FROM deleted)\n")
                .append("    BEGIN\n")
                .append("        INSERT INTO [").append(logTableName).append("] (action, create_time, sql_log)\n")
                .append("        SELECT 'DELETE', GETDATE(), 'DELETE FROM [").append(tableName).append("] WHERE [").append(primaryKey).append("] = ''' + ISNULL(CAST(d.").append(primaryKey).append(" AS NVARCHAR(MAX)), '') + ''';'\n")
                .append("        FROM deleted d;\n")
                .append("    END\n\n");
        triggerSQL.append("END;\n");
        return triggerSQL.toString();
    }
}
lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/vo/TriggerVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
package org.jeecg.modules.system.vo;
import lombok.Data;
/**
 * @Author: Lius
 * @CreateTime: 2025-06-26
 * @Description:
 */
@Data
public class TriggerVo {
    private String jdbcUrl;
    private String username;
    private String password;
}
lxzn-module-system/lxzn-system-start/src/main/resources/application-dev.yml
@@ -126,7 +126,7 @@
        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
      datasource:
        master:
          url: jdbc:sqlserver://192.168.1.118:1433;databasename=LXZN_TEST_HANGYU_GK;nullCatalogMeansCurrent=true
          url: jdbc:sqlserver://localhost:1433;databasename=LXZN_TEST_HANGYU_GK;nullCatalogMeansCurrent=true
          username: sa
          password: 123
          driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
lxzn-module-system/lxzn-system-start/src/main/resources/application-prod.yml
@@ -7,7 +7,7 @@
    include-stacktrace: ALWAYS
    include-message: ALWAYS
  servlet:
    context-path:
    context-path: /jeecg-boot
  compression:
    enabled: true
    min-response-size: 1024
@@ -132,9 +132,9 @@
        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
      datasource:
        master:
          url: jdbc:sqlserver://localhost:1433;databasename=LXZN_TEST_COMMON
          url: jdbc:sqlserver://DNC2\LXZN:1444;databasename=LXZN_TEST_COMMON;nullCatalogMeansCurrent=true
          username: sa
          password: 123
          password: sa123
          driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
  #redis é…ç½®
  redis:
@@ -247,8 +247,8 @@
  production: false
  basic:
    enable: true
    username: jeecg
    password: jeecg1314
    username: lxzn
    password: lxzn1688
#第三方登录
justauth:
  enabled: true
@@ -297,8 +297,34 @@
      # appSecret
      client-secret: ??
      agent-id: ??
#staticAccessPath: /api/ffile/** # å½“前项目的静态资源访问配置在nginx中
#文件上传目录(注意Linux和Windows上的目录结构不同)
fileHomePath: ${UPLOAD_FOLDER:d://lxzn_storage}
fileNCPath: ${NC_FOLDER:D://NC} # NC文件位置
ncSend:
  addOrDelete: false  #//是否删除seed ä¸­çš„之前文件
#staticAccessPath: /api/ffile/** # å½“前项目的静态资源访问配置在nginx中
#工控网/涉密网部署相关配置------------通过光盘摆渡
deploy:
  #工控网/涉密网部署 0为涉密网 1为工控网
  deployType: 0
  #涉密网传输工控网nc文件夹(指派设备nc文件)    å·¥æŽ§ç½‘传输涉密网nc文件夹(解析回传后的nc文件)
  secretFolder: D:\\test\\a
file:
  monitor:
    # ä¸‰ä¸ªç›‘控目录配置
    paths:
      - D:\\hy_test\\ncFile #工控负责解析里面的文件;涉密网进行解析回传的操作
      - D:\\hy_test\\b
      - D:\\hy_test\\c
    interval: 10000  # ç›‘控间隔(ms)
ferry:
  file:
    path: /data/ferry
    max-file-size: 10MB
security:
  encryption-key: 1234567890abcdef
#mdc文件路径配置
fileService:
  localFilePath: D:/data/sql/     #本地文件路径