From 9363b7a09744b3003ad6163ac42591fe40c59c5e Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期四, 14 三月 2024 15:50:06 +0800
Subject: [PATCH] 首页设备利用率和oee接口

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java |   85 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 84 insertions(+), 1 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java
index 901b846..970da2f 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java
@@ -11,6 +11,7 @@
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.mdc.constant.MdcConstant;
 import org.jeecg.modules.mdc.service.IMdcEquipmentService;
+import org.jeecg.modules.mdc.service.IMdcHomeService;
 import org.jeecg.modules.mdc.vo.MdcCommonVo;
 import org.jeecg.modules.system.entity.MdcProduction;
 import org.jeecg.modules.system.service.IMdcProductionService;
@@ -20,6 +21,7 @@
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author Lius
@@ -37,6 +39,9 @@
 
     @Resource
     private IMdcProductionService mdcProductionService;
+
+    @Resource
+    private IMdcHomeService mdcHomeService;
 
     @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧杩愯鐘舵�佺粺璁�", notes = "MDC棣栭〉鎺ュ彛-璁惧杩愯鐘舵�佺粺璁�")
     @GetMapping("/equipmentStatusStatistics")
@@ -60,7 +65,85 @@
                 key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId());
             }
         }
-        List<MdcCommonVo> resultMap = mdcEquipmentService.getEquipmentStatusStatistics(userId, key);
+        List<MdcCommonVo> resultMap = mdcHomeService.getEquipmentStatusStatistics(userId, key);
         return Result.OK(resultMap);
     }
+
+    @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧鍒╃敤鐜囩粺璁�(鏄ㄦ棩)", notes = "MDC棣栭〉鎺ュ彛-璁惧杩愯鐘舵�佺粺璁�(鏄ㄦ棩)")
+    @GetMapping("/equipmentUtilizationStatistics")
+    public Result<?> equipmentUtilizationStatistics(String productionCode) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        String userId = user.getId();
+        String key = "";
+        if (StringUtils.isNotBlank(productionCode)) {
+            //鍘傚尯
+            MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()));
+            key = mdcProduction.getId();
+        } else {
+            //鍒ゆ柇鏄叕鍙哥骇杩樻槸鍘傚尯
+            MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, ""));
+            if (userType.equals(MdcConstant.USER_TYPE_4)) {
+                //鍏徃
+                key = mdcProduction.getId();
+            } else if (userType.equals(MdcConstant.USER_TYPE_3)) {
+                //鍘傚尯
+                key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId());
+            }
+        }
+        List<MdcCommonVo> result = mdcHomeService.getEquipmentUtilizationStatistics(userId, key);
+        return Result.OK(result);
+    }
+
+    @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧OEE缁熻(涓婃湀)", notes = "MDC棣栭〉鎺ュ彛-璁惧OEE缁熻(涓婃湀)")
+    @GetMapping("/equipmentOEEStatistics")
+    public Result<?> equipmentOEEStatistics(String productionCode) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        String userId = user.getId();
+        String key = "";
+        if (StringUtils.isNotBlank(productionCode)) {
+            //鍘傚尯
+            MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()));
+            key = mdcProduction.getId();
+        } else {
+            //鍒ゆ柇鏄叕鍙哥骇杩樻槸鍘傚尯
+            MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, ""));
+            if (userType.equals(MdcConstant.USER_TYPE_4)) {
+                //鍏徃
+                key = mdcProduction.getId();
+            } else if (userType.equals(MdcConstant.USER_TYPE_3)) {
+                //鍘傚尯
+                key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId());
+            }
+        }
+        List<MdcCommonVo> result = mdcHomeService.getEquipmentOeeStatistics(userId, key);
+        return Result.OK(result);
+    }
+
+    @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧OEE鍜屽埄鐢ㄧ巼缁熻鏌辩姸鍥�", notes = "MDC棣栭〉鎺ュ彛-璁惧OEE鍜屽埄鐢ㄧ巼缁熻鏌辩姸鍥�")
+    @GetMapping("/equipmentMonthStatistics")
+    public Result<?> equipmentMonthStatistics(String productionCode) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        Integer userType = user.getUserType();
+        String userId = user.getId();
+        String key = "";
+        if (StringUtils.isNotBlank(productionCode)) {
+            //鍘傚尯
+            MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getProductionCode, productionCode).eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()));
+            key = mdcProduction.getId();
+        } else {
+            //鍒ゆ柇鏄叕鍙哥骇杩樻槸鍘傚尯
+            MdcProduction mdcProduction = mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getParentId, ""));
+            if (userType.equals(MdcConstant.USER_TYPE_4)) {
+                //鍏徃
+                key = mdcProduction.getId();
+            } else if (userType.equals(MdcConstant.USER_TYPE_3)) {
+                //鍘傚尯
+                key = mdcProductionService.findFirstProduction(userId, mdcProduction.getId());
+            }
+        }
+        Map<String, Object> result = mdcHomeService.getEquipmentMonthStatistics(userId, key);
+        return Result.OK(result);
+    }
 }

--
Gitblit v1.9.3