From 3f7774efde865b52797089fcdde621d7ae1e1a4a Mon Sep 17 00:00:00 2001 From: lius <Lius2225@163.com> Date: 星期二, 08 八月 2023 14:12:32 +0800 Subject: [PATCH] 设备工作日历配置接口更新 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcDeviceCalendarVo.java | 2 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentCalendarVo.java | 24 +------- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java | 4 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDeviceCalendar.java | 10 -- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml | 11 +-- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java | 104 +++++----------------------------- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java | 2 7 files changed, 32 insertions(+), 125 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java index b3f55be..a55e9bb 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java @@ -70,8 +70,8 @@ @ApiOperation(value = "璁惧宸ヤ綔鏃ュ巻琛�-閰嶇疆", notes = "璁惧宸ヤ綔鏃ュ巻琛�-閰嶇疆") @PostMapping(value = "/add") public Result add(@RequestBody EquipmentCalendarVo calendarVo) { - if (StringUtils.isBlank(calendarVo.getEquipmentId())) { - return Result.error("鏈�夋嫨璁惧"); + if (StringUtils.isBlank(calendarVo.getEquipmentId()) || calendarVo.getDateList().isEmpty()) { + return Result.error("璇烽�夋嫨鏈夋晥鍙傛暟锛�"); } boolean result = mdcDeviceCalendarService.saveCalendar(calendarVo); if(result){ diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDeviceCalendar.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDeviceCalendar.java index a158b6f..dbb45dd 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDeviceCalendar.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcDeviceCalendar.java @@ -42,7 +42,7 @@ */ @Excel(name = "璁惧缂栧彿", width = 15) @ApiModelProperty(value = "璁惧缂栧彿") - private String equmentId; + private String equipmentId; /** * 鐝ID @@ -50,11 +50,5 @@ @Excel(name = "鐝ID", width = 15) @ApiModelProperty(value = "鐝ID") private String shiftSubId; - /** - * 鏄熸湡鏍囪瘑 - */ - @Excel(name = "鏄熸湡鏍囪瘑", width = 15) - @ApiModelProperty(value = "鏄熸湡鏍囪瘑") - @Dict(dicCode = "week_number_type") - private String weekNumber; + } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml index 5bd9aa1..39b812f 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDeviceCalendarMapper.xml @@ -13,19 +13,18 @@ t3.sleep_start_date, t3.sleep_end_date, t3.is_day_span, - t4.equipment_name, - t4.equipment_id + t4.equipment_name FROM mdc_device_calendar t1 LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id LEFT JOIN mdc_shift_sub t3 ON t1.shift_sub_id = t3.id - LEFT JOIN mdc_equipment t4 ON t1.equment_id = t4.equipment_id + LEFT JOIN mdc_equipment t4 ON t1.equipment_id = t4.equipment_id WHERE 1=1 <if test="deviceCalendar.effectiveDate != null and deviceCalendar.effectiveDate != ''"> AND t1.effective_date LIKE CONCAT('%',#{ deviceCalendar.effectiveDate },'%') </if> <if test="deviceCalendar.equipmentId != null and deviceCalendar.equipmentId != ''"> - AND t1.equment_id = #{ deviceCalendar.equipmentId } + AND t1.equipment_id = #{ deviceCalendar.equipmentId } </if> <if test="deviceCalendar.startTime != null and deviceCalendar.startTime != ''"> AND t1.effective_date >= #{ deviceCalendar.startTime } @@ -34,7 +33,7 @@ AND t1.effective_date <= #{ deviceCalendar.endTime } </if> <if test="deviceCalendar.equipmentIdList != null and deviceCalendar.equipmentIdList.size() > 0 "> - AND t1.equment_id IN + AND t1.equipment_id IN <foreach collection="deviceCalendar.equipmentIdList" item="id" index="index" open="(" close=")" separator=","> #{ id } </foreach> @@ -59,7 +58,7 @@ mdc_device_calendar t1 LEFT JOIN mdc_shift t2 ON t1.shift_id = t2.id LEFT JOIN mdc_shift_sub t3 ON t1.shift_sub_id = t3.id - LEFT JOIN mdc_equipment t4 ON t1.equment_id = t4.equipment_id + LEFT JOIN mdc_equipment t4 ON t1.equipment_id = t4.equipment_id <where> <if test="equipmentid != null and equipmentid != ''"> AND t4.equipment_id = #{ equipmentid } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java index 57dce4e..a469d00 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcDeviceCalendarServiceImpl.java @@ -83,50 +83,21 @@ @Override public boolean saveCalendar(EquipmentCalendarVo calendarVo) { String[] equipmentIdList = calendarVo.getEquipmentId().split(","); - //鐢熸晥鏃堕棿 - LocalDate takeEffectDate = calendarVo.getTakeEffectDate(); - //澶辨晥鏃堕棿 - LocalDate invalidDate = calendarVo.getInvalidDate(); - //澶勭悊鏄熸湡 - Map<String, String> map = new HashMap<>(); - if (org.apache.commons.lang.StringUtils.isNotBlank(calendarVo.getMonShiftId())) { - map.put("1", calendarVo.getMonShiftId()); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(calendarVo.getTueShiftId())) { - map.put("2", calendarVo.getTueShiftId()); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(calendarVo.getWedShiftId())) { - map.put("3", calendarVo.getWedShiftId()); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(calendarVo.getThuShiftId())) { - map.put("4", calendarVo.getThuShiftId()); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(calendarVo.getFriShiftId())) { - map.put("5", calendarVo.getFriShiftId()); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(calendarVo.getSatShiftId())) { - map.put("6", calendarVo.getSatShiftId()); - } - if (org.apache.commons.lang.StringUtils.isNotBlank(calendarVo.getSunShiftId())) { - map.put("7", calendarVo.getSunShiftId()); - } - if (map.isEmpty()) { - return false; - } + List<String> dateList = calendarVo.getDateList(); + List<MdcShiftSub> mdcShiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, calendarVo.getShiftId()).eq(MdcShiftSub::getShiftSubStatus, "1")); List<MdcDeviceCalendar> calendarList = new ArrayList<>(); - map.forEach((key, value) -> { - List<MdcShiftSub> mdcShiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper - <MdcShiftSub>().eq(MdcShiftSub::getShiftId, value).eq(MdcShiftSub::getShiftSubStatus, "1")); - List<LocalDate> meetDayOfWeekLocalDates = getMeetDayOfWeekLocalDates(takeEffectDate, invalidDate, key); - if (!meetDayOfWeekLocalDates.isEmpty()) { - List<String> dates = meetDayOfWeekLocalDates.stream().map(localDate -> localDate.format(DateTimeFormatter.BASIC_ISO_DATE)).collect(Collectors.toList()); - LambdaUpdateChainWrapper<MdcDeviceCalendar> lambdaUpdate = this.lambdaUpdate(); - lambdaUpdate.in(MdcDeviceCalendar::getEffectiveDate, dates).in(MdcDeviceCalendar::getEqumentId, Arrays.asList(equipmentIdList)); - lambdaUpdate.remove(); - List<MdcDeviceCalendar> calendars = handleMdcDeviceCalendar(dates, equipmentIdList, mdcShiftSubList, key); - calendarList.addAll(calendars); + for (String equipmentId : equipmentIdList) { + for (String date : dateList) { + for (MdcShiftSub mdcShiftSub : mdcShiftSubList) { + MdcDeviceCalendar mdcDeviceCalendar = new MdcDeviceCalendar(); + mdcDeviceCalendar.setEffectiveDate(date); + mdcDeviceCalendar.setEquipmentId(equipmentId); + mdcDeviceCalendar.setShiftId(mdcShiftSub.getShiftId()); + mdcDeviceCalendar.setShiftSubId(mdcShiftSub.getId()); + calendarList.add(mdcDeviceCalendar); + } } - }); + } this.saveBatch(calendarList); return true; } @@ -134,24 +105,24 @@ /** * 鏌ヨ鐝埗鏁版嵁 * - * @param equipmentid + * @param equipmentId * @param stringDates * @return */ @Override - public List<MdcDeviceCalendarVo> listByEquipmentAndDate(String equipmentid, List<String> stringDates) { + 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); + List<MdcDeviceCalendarVo> mdcDeviceCalendarVos = this.baseMapper.listByEquipmentAndDate(equipmentId, stringDate); if (mdcDeviceCalendarVos != null && !mdcDeviceCalendarVos.isEmpty()) { result.addAll(mdcDeviceCalendarVos); } else { acquiesceShift.forEach(mdcDeviceCalendarVo -> { - mdcDeviceCalendarVo.setEquipmentId(equipmentid); + mdcDeviceCalendarVo.setEquipmentId(equipmentId); mdcDeviceCalendarVo.setEffectiveDate(stringDate); }); // 璁剧疆榛樿鐝埗 @@ -165,45 +136,4 @@ return result; } - /** - * 鑾峰彇涓�娈垫椂闂磋寖鍥村唴绗﹀悎鏄熸湡鍑犵殑鏃ユ湡闆嗗悎 - * - * @param startDate 寮�濮嬫椂闂� - * @param endDate 缁撴潫鏃堕棿 - * @param workDate 鍛ㄥ嚑 1,2,3,4 - */ - public static List<LocalDate> getMeetDayOfWeekLocalDates(LocalDate startDate, LocalDate endDate, String workDate) { - - List<DayOfWeek> dayOfWeeks = Stream.of(workDate.split(",")) - .map(Integer::valueOf) - .map(DayOfWeek::of) - .collect(Collectors.toList()); - - long distance = ChronoUnit.DAYS.between(startDate, endDate); - - return Stream.iterate(startDate, d -> d.plusDays(1)) - .limit(distance + 1) - .filter(localDate -> dayOfWeeks.contains(localDate.getDayOfWeek())) - .collect(Collectors.toList()); - } - - public List<MdcDeviceCalendar> handleMdcDeviceCalendar(List<String> dates, String[] equipment, List<MdcShiftSub> mdcShiftSubList, String weekNumber) { - List<MdcDeviceCalendar> ds = new ArrayList<>(); - for (String date : dates) { - for (String equipmentId : equipment) { - for (MdcShiftSub temp : mdcShiftSubList) { - MdcDeviceCalendar mdcDeviceCalendar = new MdcDeviceCalendar(); - if (org.apache.commons.lang.StringUtils.isNotEmpty(equipmentId)) { - mdcDeviceCalendar.setEqumentId(equipmentId); - } - mdcDeviceCalendar.setShiftId(temp.getShiftId()); - mdcDeviceCalendar.setShiftSubId(temp.getId()); - mdcDeviceCalendar.setEffectiveDate(date); - mdcDeviceCalendar.setWeekNumber(weekNumber); - ds.add(mdcDeviceCalendar); - } - } - } - return ds; - } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java index 32aa32b..a9c8fb7 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java @@ -112,6 +112,8 @@ */ @Override public void generateWeekDays() { + List<String> alist = new ArrayList<>(); + String s = alist.get(10); MdcVacationManagement mdcVacationManagement = this.baseMapper.selectLastWeekDays(); // 鑾峰彇鐢熸垚寮�濮嬫椂闂村拰缁撴潫鏃堕棿 LocalDate startDate; diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentCalendarVo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentCalendarVo.java index cd9e110..1a4fef1 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentCalendarVo.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentCalendarVo.java @@ -4,6 +4,7 @@ import lombok.Data; import java.time.LocalDate; +import java.util.List; /** * @author: LiuS @@ -13,28 +14,9 @@ public class EquipmentCalendarVo { private String equipmentId; - /** - * 寮�濮嬫椂闂� - */ - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - private LocalDate takeEffectDate; - /** - * 缁撴潫鏃堕棿 - */ - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - private LocalDate invalidDate; - private String monShiftId; + private List<String> dateList; - private String tueShiftId; + private String shiftId; - private String wedShiftId; - - private String thuShiftId; - - private String friShiftId; - - private String satShiftId; - - private String sunShiftId; } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcDeviceCalendarVo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcDeviceCalendarVo.java index e52b641..e6f60d0 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcDeviceCalendarVo.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcDeviceCalendarVo.java @@ -17,5 +17,5 @@ private String sleepEndDate; private String isDaySpan; private String equipmentName; - private String equipmentId; +// private String equipmentId; } -- Gitblit v1.9.3