From dcffd347f5ab47d3d158afddb86249fe8bc7e3e7 Mon Sep 17 00:00:00 2001
From: lius <Lius2225@163.com>
Date: 星期三, 12 七月 2023 13:56:56 +0800
Subject: [PATCH] 扭矩配置导入导出分页列表接口bug修复

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcVacationManagementServiceImpl.java |   68 +++++++++++++++++++++-------------
 1 files changed, 42 insertions(+), 26 deletions(-)

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 75df63e..f064d96 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
@@ -1,5 +1,6 @@
 package org.jeecg.modules.mdc.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -8,12 +9,17 @@
 import org.jeecg.modules.mdc.mapper.MdcVacationManagementMappper;
 import org.jeecg.modules.mdc.service.IMdcEquipmentService;
 import org.jeecg.modules.mdc.service.IMdcVacationManagementService;
+import org.jeecg.modules.mdc.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 
 /**
@@ -54,45 +60,55 @@
 
     @Override
     public IPage<MdcVacationManagement> pageList(String userId, Page page, HttpServletRequest req, MdcVacationManagement mdcVacationManagement) {
-        //鏄剧ず鍙屼紤鏃�
-        Date vacationDate=mdcVacationManagement.getVacationDate();
-        String type= mdcVacationManagement.getType();
-        Calendar c=Calendar.getInstance();
-        c.setTime(vacationDate);
-        int day=c.get(Calendar.DAY_OF_WEEK)-1;
-        System.out.println(day);
-        if (day==6||day==7){
-            System.out.println("鍙屼紤鏃�");
-            mdcVacationManagement.setType("鍙屼紤鏃�");
-        }
         //鏌ヨ鐢ㄦ埛鎵�鎷ユ湁鐨勮澶囦俊鎭�
-        List<String> equipmentIds=new ArrayList<>();
-        if (StringUtils.isNotEmpty(mdcVacationManagement.getParentId()) && StringUtils.isEmpty(mdcVacationManagement.getEquipmentId())){
-            if ("2".equals(mdcVacationManagement.getTypeTree())){
+        List<String> equipmentIds = new ArrayList<>();
+        if (StringUtils.isNotEmpty(mdcVacationManagement.getParentId()) && StringUtils.isEmpty(mdcVacationManagement.getEquipmentId())) {
+            if ("2".equals(mdcVacationManagement.getTypeTree())) {
                 //閮ㄩ棬灞傜骇
-                equipmentIds=equipmentService.getEquipmentIdsByDepart(userId,mdcVacationManagement.getParentId());
-            }else {
+                equipmentIds = equipmentService.getEquipmentIdsByDepart(userId, mdcVacationManagement.getParentId());
+            } else {
                 //浜х嚎灞傜骇
-                equipmentIds=equipmentService.getEquipmentIdsProduction(userId,mdcVacationManagement.getParentId());
+                equipmentIds = equipmentService.getEquipmentIdsProduction(userId, mdcVacationManagement.getParentId());
             }
-        }else if (StringUtils.isNotEmpty(mdcVacationManagement.getEquipmentId())){
+        } else if (StringUtils.isNotEmpty(mdcVacationManagement.getEquipmentId())) {
             //鍗曞彴璁惧淇℃伅
             mdcVacationManagement.setMdcSectionIds(Collections.singletonList(mdcVacationManagement.getEquipmentId()));
-        }else {
+        } else {
             //鏌ヨ鐢ㄦ埛鎵�鎷ユ湁鐨勮澶囦俊鎭�
-            if ("2".equals(mdcVacationManagement.getTypeTree())){
+            if ("2".equals(mdcVacationManagement.getTypeTree())) {
                 //閮ㄩ棬灞傜骇
-                equipmentIds=equipmentService.getEquipmentIdsByDepart(userId,null);
-            }else {
-                equipmentIds=equipmentService.getEquipmentIdsProduction(userId,null);
+                equipmentIds = equipmentService.getEquipmentIdsByDepart(userId, null);
+            } else {
+                equipmentIds = equipmentService.getEquipmentIdsProduction(userId, null);
             }
         }
-        if (mdcVacationManagement.getMdcSectionIds() == null || mdcVacationManagement.getMdcSectionIds().isEmpty()){
+        if (mdcVacationManagement.getMdcSectionIds() == null || mdcVacationManagement.getMdcSectionIds().isEmpty()) {
             mdcVacationManagement.setMdcSectionIds(equipmentIds);
         }
-        if (mdcVacationManagement.getMdcSectionIds() == null || mdcVacationManagement.getMdcSectionIds().isEmpty()){
+        if (mdcVacationManagement.getMdcSectionIds() == null || mdcVacationManagement.getMdcSectionIds().isEmpty()) {
             return null;
         }
-        return this.baseMapper.pageList(page,mdcVacationManagement);
+        return this.baseMapper.pageList(page, mdcVacationManagement);
+    }
+
+    /**
+     * 鐢熸垚鍙屼紤鏃�
+     */
+    @Override
+    public void generateWeekDays() {
+        MdcVacationManagement mdcVacationManagement = this.baseMapper.selectOne(new LambdaQueryWrapper<MdcVacationManagement>().eq(MdcVacationManagement::getType, "鍙屼紤鏃�").orderByDesc(MdcVacationManagement::getVacationDate).last("limit 1"));
+        // 鑾峰彇鐢熸垚寮�濮嬫椂闂村拰缁撴潫鏃堕棿
+        LocalDate startDate;
+        LocalDate endDate;
+        if (mdcVacationManagement == null) {
+            startDate = LocalDate.now();
+            endDate = LocalDate.of(DateUtils.getYear(), DateUtils.getMonth(), DateUtils.getDayOfMonth());
+        } else {
+            LocalDate vacationDate = mdcVacationManagement.getVacationDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusMonths(1);
+            startDate = vacationDate.with(TemporalAdjusters.firstDayOfMonth());
+            endDate = vacationDate.with(TemporalAdjusters.lastDayOfMonth());
+        }
+        // 鑾峰彇寮�濮嬫椂闂村拰缁撴潫鏃堕棿鐨勪腑闂村弻浼戞棩闆嗗悎
+        List<Date> dateList = DateUtils.getWeekDays(startDate, endDate);
     }
 }

--
Gitblit v1.9.3