Lius
2025-08-25 2b9ff0c274a847af41b2f5a04de1b23ed6fbb9bb
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcNoplanCloseServiceImpl.java
@@ -23,10 +23,6 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -320,29 +316,4 @@
        return mv;
    }
    @Override
    public BigDecimal findNoplanTimeDuration(String equipmentId, String validDate, String noplanType) {
        BigDecimal result = new BigDecimal("0");
        String startDate = DateUtils.format(DateUtils.toDate(validDate + "-01", DateUtils.STR_DATE), DateUtils.STR_DATE) + " 00:00:00";
        Date startTime = DateUtils.toDate(startDate, DateUtils.STR_DATE_TIME_SMALL);
        String endDate = DateUtils.format(DateUtils.addMonth(1, DateUtils.toDate(startDate, DateUtils.STR_DATE_TIME_SMALL)), DateUtils.STR_DATE_TIME_SMALL);
        Date endTime = DateUtils.toDate(endDate, DateUtils.STR_DATE_TIME_SMALL);
        List<MdcNoplanClose> mdcNoplanCloseList = this.baseMapper.findNoplanTimeDuration(equipmentId, noplanType, startDate, endDate);
        // 时间修正 并计算
        if (mdcNoplanCloseList != null && !mdcNoplanCloseList.isEmpty()) {
            for (MdcNoplanClose mdcNoplanClose : mdcNoplanCloseList) {
                if (mdcNoplanClose.getStartTime().before(startTime)) {
                    mdcNoplanClose.setStartTime(startTime);
                }
                if (mdcNoplanClose.getEndTime().after(endTime)) {
                    mdcNoplanClose.setEndTime(endTime);
                }
                LocalDateTime localStartDate = LocalDateTime.ofInstant(mdcNoplanClose.getStartTime().toInstant(), ZoneId.systemDefault());
                LocalDateTime localEndDate = LocalDateTime.ofInstant(mdcNoplanClose.getEndTime().toInstant(), ZoneId.systemDefault());
                int minutes = Math.toIntExact(Duration.between(localStartDate, localEndDate).toMinutes());
                result = result.add(new BigDecimal(minutes));
            }
        }
        return result;
    }
}