| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.modules.mdc.entity.MdcDeviceCalendar; |
| | | import org.jeecg.modules.mdc.entity.MdcShiftSub; |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.mapper.MdcDeviceCalendarMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcDeviceCalendarService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcShiftSubService; |
| | | import org.jeecg.modules.mdc.service.IMdcVacationManagementService; |
| | | import org.jeecg.modules.mdc.vo.EquipmentCalendarVo; |
| | | import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo; |
| | | import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: 设备工作日历表 |
| | |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | @Resource |
| | | private IMdcShiftSubService mdcShiftSubService; |
| | | |
| | | @Resource |
| | | private IMdcVacationManagementService mdcVacationManagementService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | public List<MdcDeviceCalendarVo> listByEquipmentAndDate(String equipmentId, List<String> stringDates) { |
| | | List<MdcDeviceCalendarVo> result = new ArrayList<>(); |
| | | try { |
| | | //查询默认班制 |
| | | List<MdcDeviceCalendarVo> acquiesceShift = this.baseMapper.findAcquiesceShift(); |
| | | |
| | | for (String stringDate : stringDates) { |
| | | List<MdcDeviceCalendarVo> mdcDeviceCalendarVos = this.baseMapper.listByEquipmentAndDate(equipmentId, stringDate); |
| | | if (mdcDeviceCalendarVos != null && !mdcDeviceCalendarVos.isEmpty()) { |
| | | result.addAll(mdcDeviceCalendarVos); |
| | | } else { |
| | | acquiesceShift.forEach(mdcDeviceCalendarVo -> { |
| | | mdcDeviceCalendarVo.setEquipmentId(equipmentId); |
| | | mdcDeviceCalendarVo.setEffectiveDate(stringDate); |
| | | }); |
| | | // 设置默认班制 |
| | | result.addAll(acquiesceShift); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 计算实际班产天数 |
| | | * |
| | | * @param equipmentId |
| | | * @param validDate |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BigDecimal computeActualWorkDayCount(String equipmentId, String validDate) { |
| | | validDate = validDate.replaceAll("-", ""); |
| | | List<String> validDateList = this.baseMapper.computeActualWorkDayCount(equipmentId, validDate); |
| | | return new BigDecimal(validDateList.size()); |
| | | } |
| | | |
| | | /** |
| | | * 查询班次分类 |
| | | * |
| | | * @param equipmentId |
| | | * @param validDate |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<String> findShiftSort(String equipmentId, String validDate) { |
| | | validDate = validDate.replaceAll("-", ""); |
| | | return this.baseMapper.findShiftSort(equipmentId, validDate); |
| | | } |
| | | |
| | | /** |
| | | * 计算班次时间 |
| | | * |
| | | * @param equipmentId |
| | | * @param validDate |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BigDecimal computeShiftTimeCount(String equipmentId, String validDate) { |
| | | validDate = validDate.replaceAll("-", ""); |
| | | Integer shiftCount = this.baseMapper.computeShiftTimeCount(equipmentId, validDate); |
| | | return new BigDecimal(shiftCount).multiply(new BigDecimal("8")).multiply(new BigDecimal("60")); |
| | | } |
| | | |
| | | /** |
| | | * 自动生成设备工作日历 |
| | | */ |
| | | @Override |
| | | public void generateDeviceCalendar() { |
| | | // 暂定每天晚上11点执行 |
| | | //查询默认班制 |
| | | List<MdcDeviceCalendarVo> acquiesceShift = this.baseMapper.findAcquiesceShift(); |
| | | // 获取明日日期 |
| | | String localDate = LocalDate.now().plusDays(1).toString(); |
| | | // 获取设备列表 |
| | | List<MdcEquipment> equipmentList = mdcEquipmentService.list(); |
| | | List<MdcDeviceCalendar> result = new ArrayList<>(); |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | List<MdcDeviceCalendar> list = super.list(new LambdaQueryWrapper<MdcDeviceCalendar>().eq(MdcDeviceCalendar::getEquipmentId, mdcEquipment.getEquipmentId()).eq(MdcDeviceCalendar::getEffectiveDate, localDate.replaceAll("-", ""))); |
| | | if (list == null || list.isEmpty()) { |
| | | List<MdcVacationManagement> vacationManagementList = mdcVacationManagementService.list(new LambdaQueryWrapper<MdcVacationManagement>().eq(MdcVacationManagement::getEquipmentId, mdcEquipment.getEquipmentId()).eq(MdcVacationManagement::getVacationDate, localDate)); |
| | | if (vacationManagementList == null || vacationManagementList.isEmpty()) { |
| | | String effectiveDate = localDate.replaceAll("-", ""); |
| | | for (MdcDeviceCalendarVo mdcDeviceCalendarVo : acquiesceShift) { |
| | | MdcDeviceCalendar mdcDeviceCalendar = new MdcDeviceCalendar(); |
| | | mdcDeviceCalendar.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | mdcDeviceCalendar.setEffectiveDate(effectiveDate); |
| | | mdcDeviceCalendar.setShiftId(mdcDeviceCalendarVo.getShiftId()); |
| | | mdcDeviceCalendar.setShiftSubId(mdcDeviceCalendarVo.getShiftSubId()); |
| | | result.add(mdcDeviceCalendar); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!result.isEmpty()) { |
| | | super.saveBatch(result); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public MdcDeviceCalendar getFirstData(String equipmentId) { |
| | | return this.baseMapper.getFirstData(equipmentId); |
| | | } |
| | | |
| | | @Override |
| | | public List<MdcDeviceCalendarVo> listByEquipmentIdAndDate(String equipmentId, String date) { |
| | | return this.baseMapper.listByEquipmentAndDate(equipmentId, date); |
| | | } |
| | | |
| | | } |