Lius
2025-04-25 c9eea9f24aa52ea59dbb8dcf1cb6cf513ddc74a9
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDowntimeServiceImpl.java
@@ -6,17 +6,21 @@
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.mdc.dto.MdcDowntimeDto;
import org.jeecg.modules.mdc.entity.MdcDowntime;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcStandardProcessDuration;
import org.jeecg.modules.mdc.mapper.MdcDowntimeMapper;
import org.jeecg.modules.mdc.service.IMdcDowntimeService;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.vo.MdcDowntimeVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
@@ -62,12 +66,38 @@
        List<MdcDowntime> mdcDowntimeList = this.baseMapper.findPlanTimeDuration(equipmentId, validDate, closeType);
        if (mdcDowntimeList != null && !mdcDowntimeList.isEmpty()) {
            for (MdcDowntime mdcDowntime : mdcDowntimeList) {
                result = DateUtils.differentMinutes(mdcDowntime.getStartDate(), mdcDowntime.getEndDate()) + result;
//                Date startDate = DateUtils.toDate(mdcDowntime.getTheDate() + " " + mdcDowntime.getStartTime(), DateUtils.STR_DATE_TIME_SMALL);
//                Date endDate = DateUtils.toDate(mdcDowntime.getTheDate() + " " + mdcDowntime.getEndTime(), DateUtils.STR_DATE_TIME_SMALL);
                result = mdcDowntime.getDownLong() + result;
            }
        }
        return result;
    }
    /**
     * 添加
     * @param mdcDowntime
     * @return
     */
    @Override
    public boolean saveDowntime(MdcDowntime mdcDowntime) {
        boolean result = false;
        String[] equipmentIds = mdcDowntime.getEquipmentIds().split(",");
        for (String equipmentId : equipmentIds) {
            MdcEquipment mdcEquipment = mdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId);
            MdcDowntime downtime = new MdcDowntime();
            BeanUtils.copyProperties(mdcDowntime, downtime);
            downtime.setEquipmentId(mdcEquipment.getEquipmentId());
            downtime.setEquipmentName(mdcEquipment.getEquipmentName());
            boolean b = super.save(downtime);
            if (b) {
                result = true;
            }
        }
        return result;
    }
    private List<String> getEquipmentIds(String userId, MdcDowntimeVo mdcDowntimeVo) {
        if (StringUtils.isNotEmpty(mdcDowntimeVo.getEquipmentId())) {
            return Collections.singletonList(mdcDowntimeVo.getEquipmentId());