From 2dcd7f3634f2e636e10ea758441ded77e1d2c845 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期一, 02 十二月 2024 17:15:16 +0800
Subject: [PATCH] update

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java |  182 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 162 insertions(+), 20 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java
index eaa6d9a..b1a67b4 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPlanCloseServiceImpl.java
@@ -2,15 +2,29 @@
 
 
 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;
-import org.jeecg.modules.mdc.constant.MdcConstant;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.mdc.entity.MdcPassRate;
 import org.jeecg.modules.mdc.entity.MdcPlanClose;
 import org.jeecg.modules.mdc.mapper.MdcPlanCloseMapper;
+import org.jeecg.modules.mdc.service.IMdcEquipmentService;
 import org.jeecg.modules.mdc.service.IMdcPlanCloseService;
+import org.jeecg.modules.mdc.vo.MdcPlanCloseVo;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.ModelAndView;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 
@@ -23,27 +37,155 @@
 @Service
 public class MdcPlanCloseServiceImpl extends ServiceImpl<MdcPlanCloseMapper, MdcPlanClose> implements IMdcPlanCloseService {
 
+    @Resource
+    private IMdcEquipmentService mdcEquipmentService;
+
+    /**
+     * 鍒嗛〉鏌ヨ
+     *
+     * @param userId
+     * @param page
+     * @param mdcPlanClose
+     * @param req
+     * @return
+     */
+    @Override
+    public IPage<MdcPlanClose> pageList(String userId, Page<MdcPlanClose> page, MdcPlanCloseVo mdcPlanClose, HttpServletRequest req) {
+        List<String> equipmentIds = new ArrayList<>();
+        if (StringUtils.isNotEmpty(mdcPlanClose.getParentId()) && StringUtils.isEmpty(mdcPlanClose.getEquipmentId())) {
+            if ("2".equals(mdcPlanClose.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcPlanClose.getParentId());
+            } else {
+                //浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcPlanClose.getParentId());
+            }
+        } else if (StringUtils.isNotEmpty(mdcPlanClose.getEquipmentId())) {
+            //鍗曞彴璁惧淇℃伅
+            mdcPlanClose.setEquipmentIdList(Collections.singletonList(mdcPlanClose.getEquipmentId()));
+        } else {
+            //鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
+            if ("2".equals(mdcPlanClose.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
+            } else {
+                //浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
+            }
+        }
+
+        if (mdcPlanClose.getEquipmentIdList() == null || mdcPlanClose.getEquipmentIdList().isEmpty()) {
+            mdcPlanClose.setEquipmentIdList(equipmentIds);
+        }
+
+        if (mdcPlanClose.getEquipmentIdList() == null || mdcPlanClose.getEquipmentIdList().isEmpty()) {
+            return null;
+        }
+        return this.baseMapper.pageList(page, mdcPlanClose);
+    }
+
+    /**
+     * 娣诲姞
+     *
+     * @param mdcPlanCloseVo
+     * @return
+     */
+    @Override
+    public boolean addPlanClose(MdcPlanCloseVo mdcPlanCloseVo) {
+        String[] equipmentIdList = mdcPlanCloseVo.getEquipmentIds().split(",");
+        List<MdcPlanClose> planCloseList = new ArrayList<>();
+        for (String equipmentId : equipmentIdList) {
+            MdcPlanClose mdcPlanClose = new MdcPlanClose();
+            mdcPlanClose.setEquipmentId(equipmentId);
+            mdcPlanClose.setPlanCloseType(mdcPlanCloseVo.getPlanCloseType());
+            mdcPlanClose.setPlanCloseTimeLong(mdcPlanCloseVo.getPlanCloseTimeLong());
+            mdcPlanClose.setTheDate(mdcPlanCloseVo.getTheDate());
+            mdcPlanClose.setCloseType(mdcPlanCloseVo.getCloseType());
+            mdcPlanClose.setRemark(mdcPlanClose.getRemark());
+            planCloseList.add(mdcPlanClose);
+        }
+        this.saveBatch(planCloseList);
+        return true;
+    }
+
+    @Override
+    public ModelAndView exportXls(String userId, MdcPlanCloseVo mdcPlanClose, String title) {
+        LambdaQueryWrapper<MdcPlanClose> queryWrapper = new LambdaQueryWrapper<>();
+        List<String> equipmentIds = new ArrayList<>();
+        if (StringUtils.isNotEmpty(mdcPlanClose.getParentId()) && StringUtils.isEmpty(mdcPlanClose.getEquipmentId())) {
+            if ("2".equals(mdcPlanClose.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcPlanClose.getParentId());
+            } else {
+                //浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcPlanClose.getParentId());
+            }
+        } else if (StringUtils.isNotEmpty(mdcPlanClose.getEquipmentId())) {
+            //鍗曞彴璁惧淇℃伅
+            mdcPlanClose.setEquipmentIdList(Collections.singletonList(mdcPlanClose.getEquipmentId()));
+        } else {
+            //鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
+            if ("2".equals(mdcPlanClose.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
+            } else {
+                //浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
+            }
+        }
+        if (mdcPlanClose.getEquipmentIdList() == null || mdcPlanClose.getEquipmentIdList().isEmpty()) {
+            mdcPlanClose.setEquipmentIdList(equipmentIds);
+        }
+
+        if (mdcPlanClose.getEquipmentIdList() == null || mdcPlanClose.getEquipmentIdList().isEmpty()) {
+            return null;
+        } else {
+            queryWrapper.in(MdcPlanClose::getEquipmentId, mdcPlanClose.getEquipmentIdList());
+        }
+        if (StringUtils.isNotEmpty(mdcPlanClose.getEquipmentId())) {
+            queryWrapper.eq(MdcPlanClose::getEquipmentId, mdcPlanClose.getEquipmentId());
+        }
+        if (StringUtils.isNotEmpty(mdcPlanClose.getPlanCloseType())) {
+            queryWrapper.eq(MdcPlanClose::getPlanCloseType, mdcPlanClose.getPlanCloseType());
+        }
+        if (StringUtils.isNotEmpty(mdcPlanClose.getStartTime()) && StringUtils.isNotEmpty(mdcPlanClose.getEndTime())) {
+            queryWrapper.between(MdcPlanClose::getTheDate, mdcPlanClose.getStartTime(), mdcPlanClose.getEndTime());
+        }
+        queryWrapper.orderByDesc(MdcPlanClose::getTheDate).orderByDesc(MdcPlanClose::getEquipmentId);
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<MdcPlanClose> mdcPlanCloses = this.baseMapper.selectList(queryWrapper);
+        // 瀵煎嚭鏂囦欢鍚嶇О
+        mv.addObject(NormalExcelConstants.FILE_NAME, title + "鍒楄〃");
+        mv.addObject(NormalExcelConstants.CLASS, MdcPlanClose.class);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams(title + "鍒楄〃鏁版嵁", "瀵煎嚭浜�:" + user.getRealname(), title));
+        //update-end---author:wangshuai ---date:20211227  for锛歔JTC-116]瀵煎嚭浜哄啓姝讳簡------------
+        mv.addObject(NormalExcelConstants.DATA_LIST, mdcPlanCloses);
+        return mv;
+    }
+
     @Override
     public BigDecimal findPlanTimeDuration(BigDecimal actualWorkDayCount, String planCloseType) {
         BigDecimal result = new BigDecimal("0");
-        List<MdcPlanClose> mdcPlanCloses = this.baseMapper.selectList(new LambdaQueryWrapper<MdcPlanClose>().in(MdcPlanClose::getPlanCloseType, Arrays.asList(planCloseType.split(","))));
-        if (mdcPlanCloses != null && !mdcPlanCloses.isEmpty()) {
-            for (MdcPlanClose mdcPlanClose : mdcPlanCloses) {
-                switch (mdcPlanClose.getPlanCloseTimeType()) {
-                    case MdcConstant.DAY:
-                        result = result.add(actualWorkDayCount.multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())));
-                        break;
-                    case MdcConstant.WEEK:
-                        result = result.add(new BigDecimal("4").multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())));
-                        break;
-                    case MdcConstant.MONTH:
-                        result = result.add(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()));
-                        break;
-                    default:
-                        break;
-                }
-            }
-        }
+//        List<MdcPlanClose> mdcPlanCloses = this.baseMapper.selectList(new LambdaQueryWrapper<MdcPlanClose>().in(MdcPlanClose::getPlanCloseType, Arrays.asList(planCloseType.split(","))));
+//        if (mdcPlanCloses != null && !mdcPlanCloses.isEmpty()) {
+//            for (MdcPlanClose mdcPlanClose : mdcPlanCloses) {
+//                switch (mdcPlanClose.getPlanCloseTimeType()) {
+//                    case MdcConstant.DAY:
+//                        result = result.add(actualWorkDayCount.multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())));
+//                        break;
+//                    case MdcConstant.WEEK:
+//                        result = result.add(new BigDecimal("4").multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())));
+//                        break;
+//                    case MdcConstant.MONTH:
+//                        result = result.add(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()));
+//                        break;
+//                    default:
+//                        break;
+//                }
+//            }
+//        }
         return result;
     }
+
 }

--
Gitblit v1.9.3