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 |  131 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 104 insertions(+), 27 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 7ae9603..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
@@ -775,19 +775,33 @@
                 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));
-                    list = calibrationOrderService.getEquipmentTechnologyStatusList(area.getId(),"");
+                    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));
-                    list = calibrationOrderService.getEquipmentTechnologyStatusList("",area.getId());
+                    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));
-                list = calibrationOrderService.getEquipmentTechnologyStatusList(area.getId(),"");
+                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());
             }
         }
@@ -810,19 +824,33 @@
                 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));
-                    list = calibrationOrderService.getReportRepairEquipmentList(area.getId(),"");
+                    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));
-                    list = calibrationOrderService.getReportRepairEquipmentList("",area.getId());
+                    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));
-                list = calibrationOrderService.getReportRepairEquipmentList(area.getId(),"");
+                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());
             }
         }
@@ -835,13 +863,6 @@
      */
     @GetMapping("getThisMonthMaintenanceList")
     public Result<?> getThisMonthMaintenanceList(String productionCode) {
-//        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;
-//        }
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         Integer userType = user.getUserType();
         List<Map<String, Object>> list = null;
@@ -852,19 +873,33 @@
                 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));
-                    list = calibrationOrderService.getThisMonthMaintenanceList(area.getId(),"");
+                    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));
-                    list = calibrationOrderService.getThisMonthMaintenanceList("",area.getId());
+                    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));
-                list = calibrationOrderService.getThisMonthMaintenanceList(area.getId(),"");
+                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());
             }
         }
@@ -887,19 +922,33 @@
                 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));
-                    list = calibrationOrderService.getNextMonthMaintenanceList(area.getId(),"");
+                    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));
-                    list = calibrationOrderService.getNextMonthMaintenanceList("",area.getId());
+                    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));
-                list = calibrationOrderService.getNextMonthMaintenanceList(area.getId(),"");
+                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());
             }
         }
@@ -917,25 +966,39 @@
         List<Map<String, Object>> list = null;
         if(USER_TYPE_4.equals(userType)){
             if(StringUtils.isBlank(productionCode)){
-                list = calibrationOrderService.getFactoryNextMonthMaintenanceList();
+                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));
-                    list = calibrationOrderService.getNextMonthMaintenanceList(area.getId(),"");
+                    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));
-                    list = calibrationOrderService.getNextMonthMaintenanceList("",area.getId());
+                    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));
-                list = calibrationOrderService.getNextMonthMaintenanceList(area.getId(),"");
+                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));
-                list = calibrationOrderService.getNextMonthMaintenanceList("",area.getId());
+                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);
@@ -957,19 +1020,33 @@
                 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));
-                    list = calibrationOrderService.getThisMonthMaintenanceFinishList(area.getId(),"");
+                    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));
-                    list = calibrationOrderService.getThisMonthMaintenanceFinishList("",area.getId());
+                    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));
-                list = calibrationOrderService.getThisMonthMaintenanceFinishList(area.getId(),"");
+                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());
             }
         }

--
Gitblit v1.9.3