From cdeec053dbbc842c03dd1a0b961b3b3321c5ac20 Mon Sep 17 00:00:00 2001
From: qushaowei <qushaowei@163.com>
Date: 星期二, 19 三月 2024 16:32:39 +0800
Subject: [PATCH] 首页接口优化

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/CalibrationOrderController.java |  315 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 273 insertions(+), 42 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/CalibrationOrderController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/CalibrationOrderController.java
index ce24a6a..dd18a9c 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/CalibrationOrderController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/CalibrationOrderController.java
@@ -26,6 +26,7 @@
 import org.jeecg.modules.eam.service.*;
 import org.jeecg.modules.eam.vo.CalibrationOrderPage;
 import org.jeecg.modules.eam.vo.SysFileNameVo;
+import org.jeecg.modules.system.entity.MdcProduction;
 import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.service.ISysDepartService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -61,6 +62,25 @@
 @RequestMapping("/eam/calibrationOrder")
 @Slf4j
 public class CalibrationOrderController {
+
+    /**
+     * 鐢ㄦ埛绫诲瀷(1 鏅�氭垚鍛� 2 宸ユ 3 鍒嗗巶/涓績 4 鍏徃锛�
+     */
+    private static final Integer USER_TYPE_1 = 1;
+    private static final Integer USER_TYPE_2 = 2;
+    private static final Integer USER_TYPE_3 = 3;
+    private static final Integer USER_TYPE_4 = 4;
+
+    /**
+     * 杞﹂棿灞傜骇绫诲瀷(1 鍏徃 2 鍒嗗巶銆佷腑蹇� 3 宸ユ锛�
+     */
+    private static final String ORG_TYPE_1 = "1";
+    private static final String ORG_TYPE_2 = "2";
+    private static final String ORG_TYPE_3 = "3";
+
+
+
+
     @Autowired
     private ICalibrationOrderService calibrationOrderService;
     @Autowired
@@ -736,18 +756,54 @@
     }
 
 
+
+
     /**
      *棣栭〉锛堜簩绾ч〉闈級鎶�鏈姸鎬佹暟閲忕粺璁�
      * qsw 2024-3-13
      */
     @GetMapping("getEquipmentTechnologyStatusList")
-    public Result<?> getEquipmentTechnologyStatusList(@Param("factoryNum") String factoryNum) {
-        List<Area> areaList = areaService.lambdaQuery().eq(Area::getNum, factoryNum).eq(Area::getDelFlag, 0).list();
-        List<Map<String, Object>> list;
-        if(areaList.size()>0){
-            list = calibrationOrderService.getEquipmentTechnologyStatusList(areaList.get(0).getId());
-        }else{
-            list = null;
+    public Result<?> getEquipmentTechnologyStatusList(String productionCode) {
+
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        List<Map<String, Object>> list = null;
+        if(USER_TYPE_4.equals(userType)){
+            if(StringUtils.isBlank(productionCode)){
+                list = calibrationOrderService.getFactoryEquipmentTechnologyStatusList();
+            }else{
+                String orgType = calibrationOrderService.findOrgType(productionCode);
+                if(ORG_TYPE_2.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getEquipmentTechnologyStatusList(area.getId(),"");
+                    }
+                }else if(ORG_TYPE_3.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getEquipmentTechnologyStatusList("",area.getId());
+                    }
+                }
+            }
+        }else if(USER_TYPE_3.equals(userType)){
+            String code = calibrationOrderService.findProductionCode(user.getId());
+            if(StringUtils.isBlank(productionCode)){
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, code).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getEquipmentTechnologyStatusList(area.getId(),"");
+                }
+            }else{
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getEquipmentTechnologyStatusList("",area.getId());
+                }
+            }
+        }else if(USER_TYPE_2.equals(userType)){
+            String areaProductionCode = calibrationOrderService.findAreaProductionCode(user.getId());
+            Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, areaProductionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+            if(area != null){
+                list = calibrationOrderService.getEquipmentTechnologyStatusList("",area.getId());
+            }
         }
         return Result.ok(list);
     }
@@ -757,13 +813,46 @@
      * qsw 2024-3-13
      */
     @GetMapping("getReportRepairEquipmentList")
-    public Result<?> getReportRepairEquipmentList(@Param("factoryNum") String factoryNum) {
-        List<Area> areaList = areaService.lambdaQuery().eq(Area::getNum, factoryNum).eq(Area::getDelFlag, 0).list();
-        List<Map<String, Object>> list;
-        if(areaList.size()>0){
-            list = calibrationOrderService.getReportRepairEquipmentList(areaList.get(0).getId());
-        }else{
-            list = null;
+    public Result<?> getReportRepairEquipmentList(String productionCode) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        List<Map<String, Object>> list = null;
+        if(USER_TYPE_4.equals(userType)){
+            if(StringUtils.isBlank(productionCode)){
+                list = calibrationOrderService.getFactoryReportRepairEquipmentList();
+            }else{
+                String orgType = calibrationOrderService.findOrgType(productionCode);
+                if(ORG_TYPE_2.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getReportRepairEquipmentList(area.getId(),"");
+                    }
+                }else if(ORG_TYPE_3.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getReportRepairEquipmentList("",area.getId());
+                    }
+                }
+            }
+        }else if(USER_TYPE_3.equals(userType)){
+            String code = calibrationOrderService.findProductionCode(user.getId());
+            if(StringUtils.isBlank(productionCode)){
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, code).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getReportRepairEquipmentList(area.getId(),"");
+                }
+            }else{
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getReportRepairEquipmentList("",area.getId());
+                }
+            }
+        }else if(USER_TYPE_2.equals(userType)){
+            String areaProductionCode = calibrationOrderService.findAreaProductionCode(user.getId());
+            Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, areaProductionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+            if(area != null){
+                list = calibrationOrderService.getReportRepairEquipmentList("",area.getId());
+            }
         }
         return Result.ok(list);
     }
@@ -773,13 +862,46 @@
      * qsw 2024-3-14
      */
     @GetMapping("getThisMonthMaintenanceList")
-    public Result<?> getThisMonthMaintenanceList(@Param("factoryNum") String factoryNum) {
-        List<Area> areaList = areaService.lambdaQuery().eq(Area::getNum, factoryNum).eq(Area::getDelFlag, 0).list();
-        List<Map<String, Object>> list;
-        if(areaList.size()>0){
-            list = calibrationOrderService.getThisMonthMaintenanceList(areaList.get(0).getId());
-        }else{
-            list = null;
+    public Result<?> getThisMonthMaintenanceList(String productionCode) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        List<Map<String, Object>> list = null;
+        if(USER_TYPE_4.equals(userType)){
+            if(StringUtils.isBlank(productionCode)){
+                list = calibrationOrderService.getFactoryThisMonthMaintenanceList();
+            }else{
+                String orgType = calibrationOrderService.findOrgType(productionCode);
+                if(ORG_TYPE_2.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getThisMonthMaintenanceList(area.getId(),"");
+                    }
+                }else if(ORG_TYPE_3.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getThisMonthMaintenanceList("",area.getId());
+                    }
+                }
+            }
+        }else if(USER_TYPE_3.equals(userType)){
+            String code = calibrationOrderService.findProductionCode(user.getId());
+            if(StringUtils.isBlank(productionCode)){
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, code).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getThisMonthMaintenanceList(area.getId(),"");
+                }
+            }else{
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getThisMonthMaintenanceList("",area.getId());
+                }
+            }
+        }else if(USER_TYPE_2.equals(userType)){
+            String areaProductionCode = calibrationOrderService.findAreaProductionCode(user.getId());
+            Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, areaProductionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+            if(area != null){
+                list = calibrationOrderService.getThisMonthMaintenanceList("",area.getId());
+            }
         }
         return Result.ok(list);
     }
@@ -789,13 +911,46 @@
      * qsw 2024-3-14
      */
     @GetMapping("getNextMonthMaintenanceList")
-    public Result<?> getNextMonthMaintenanceList(@Param("factoryNum") String factoryNum) {
-        List<Area> areaList = areaService.lambdaQuery().eq(Area::getNum, factoryNum).eq(Area::getDelFlag, 0).list();
-        List<Map<String, Object>> list;
-        if(areaList.size()>0){
-            list = calibrationOrderService.getNextMonthMaintenanceList(areaList.get(0).getId());
-        }else{
-            list = null;
+    public Result<?> getNextMonthMaintenanceList(String productionCode) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        List<Map<String, Object>> list = null;
+        if(USER_TYPE_4.equals(userType)){
+            if(StringUtils.isBlank(productionCode)){
+                list = calibrationOrderService.getFactoryNextMonthMaintenanceList();
+            }else{
+                String orgType = calibrationOrderService.findOrgType(productionCode);
+                if(ORG_TYPE_2.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getNextMonthMaintenanceList(area.getId(),"");
+                    }
+                }else if(ORG_TYPE_3.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getNextMonthMaintenanceList("",area.getId());
+                    }
+                }
+            }
+        }else if(USER_TYPE_3.equals(userType)){
+            String code = calibrationOrderService.findProductionCode(user.getId());
+            if(StringUtils.isBlank(productionCode)){
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, code).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getNextMonthMaintenanceList(area.getId(),"");
+                }
+            }else{
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getNextMonthMaintenanceList("",area.getId());
+                }
+            }
+        }else if(USER_TYPE_2.equals(userType)){
+            String areaProductionCode = calibrationOrderService.findAreaProductionCode(user.getId());
+            Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, areaProductionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+            if(area != null){
+                list = calibrationOrderService.getNextMonthMaintenanceList("",area.getId());
+            }
         }
         return Result.ok(list);
     }
@@ -805,13 +960,46 @@
      * qsw 2024-3-14
      */
     @GetMapping("getNextNextMonthMaintenanceList")
-    public Result<?> getNextNextMonthMaintenanceList(@Param("factoryNum") String factoryNum) {
-        List<Area> areaList = areaService.lambdaQuery().eq(Area::getNum, factoryNum).eq(Area::getDelFlag, 0).list();
-        List<Map<String, Object>> list;
-        if(areaList.size()>0){
-            list = calibrationOrderService.getNextNextMonthMaintenanceList(areaList.get(0).getId());
-        }else{
-            list = null;
+    public Result<?> getNextNextMonthMaintenanceList(String productionCode) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        List<Map<String, Object>> list = null;
+        if(USER_TYPE_4.equals(userType)){
+            if(StringUtils.isBlank(productionCode)){
+                list = calibrationOrderService.getFactoryNextNextMonthMaintenanceList();
+            }else{
+                String orgType = calibrationOrderService.findOrgType(productionCode);
+                if(ORG_TYPE_2.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getNextNextMonthMaintenanceList(area.getId(),"");
+                    }
+                }else if(ORG_TYPE_3.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getNextNextMonthMaintenanceList("",area.getId());
+                    }
+                }
+            }
+        }else if(USER_TYPE_3.equals(userType)){
+            String code = calibrationOrderService.findProductionCode(user.getId());
+            if(StringUtils.isBlank(productionCode)){
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, code).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getNextNextMonthMaintenanceList(area.getId(),"");
+                }
+            }else{
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getNextNextMonthMaintenanceList("",area.getId());
+                }
+            }
+        }else if(USER_TYPE_2.equals(userType)){
+            String areaProductionCode = calibrationOrderService.findAreaProductionCode(user.getId());
+            Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, areaProductionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+            if(area != null){
+                list = calibrationOrderService.getNextNextMonthMaintenanceList("",area.getId());
+            }
         }
         return Result.ok(list);
     }
@@ -821,15 +1009,58 @@
      * qsw 2024-3-14
      */
     @GetMapping("getThisMonthMaintenanceFinishList")
-    public Result<?> getThisMonthMaintenanceFinishList(@Param("factoryNum") String factoryNum) {
-        List<Area> areaList = areaService.lambdaQuery().eq(Area::getNum, factoryNum).eq(Area::getDelFlag, 0).list();
-        List<Map<String, Object>> list;
-        if(areaList.size()>0){
-            list = calibrationOrderService.getThisMonthMaintenanceFinishList(areaList.get(0).getId());
-        }else{
-            list = null;
+    public Result<?> getThisMonthMaintenanceFinishList(String productionCode) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        List<Map<String, Object>> list = null;
+        if(USER_TYPE_4.equals(userType)){
+            if(StringUtils.isBlank(productionCode)){
+                list = calibrationOrderService.getFactoryThisMonthMaintenanceFinishList();
+            }else{
+                String orgType = calibrationOrderService.findOrgType(productionCode);
+                if(ORG_TYPE_2.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getThisMonthMaintenanceFinishList(area.getId(),"");
+                    }
+                }else if(ORG_TYPE_3.equals(orgType)){
+                    Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                    if(area != null){
+                        list = calibrationOrderService.getThisMonthMaintenanceFinishList("",area.getId());
+                    }
+                }
+            }
+        }else if(USER_TYPE_3.equals(userType)){
+            String code = calibrationOrderService.findProductionCode(user.getId());
+            if(StringUtils.isBlank(productionCode)){
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, code).eq(Area::getType, "1").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getThisMonthMaintenanceFinishList(area.getId(),"");
+                }
+            }else{
+                Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, productionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+                if(area != null){
+                    list = calibrationOrderService.getThisMonthMaintenanceFinishList("",area.getId());
+                }
+            }
+        }else if(USER_TYPE_2.equals(userType)){
+            String areaProductionCode = calibrationOrderService.findAreaProductionCode(user.getId());
+            Area area = areaService.getOne(new LambdaQueryWrapper<Area>().eq(Area::getNum, areaProductionCode).eq(Area::getType, "3").eq(Area::getDelFlag, 0));
+            if(area != null){
+                list = calibrationOrderService.getThisMonthMaintenanceFinishList("",area.getId());
+            }
         }
         return Result.ok(list);
     }
 
+    /**
+     *棣栭〉浜屼繚璁″垝灞曠ず
+     * qsw 2024-3-15
+     */
+    @GetMapping("getTwoMaintenancePlanList")
+    public Result<?> getTwoMaintenancePlanList(String productionCode) {
+        List<Map<String, Object>> twoMaintenancePlanList = calibrationOrderService.getTwoMaintenancePlanList(productionCode);
+        return Result.ok(twoMaintenancePlanList);
+    }
+
 }

--
Gitblit v1.9.3