From e17986e0800584f650b42c6fb632d0244d695a35 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期四, 31 十月 2024 16:13:55 +0800
Subject: [PATCH] update

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/screen/service/impl/MdcLargeScreenServiceImpl.java |   62 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/screen/service/impl/MdcLargeScreenServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/screen/service/impl/MdcLargeScreenServiceImpl.java
index e107ae2..3890456 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/screen/service/impl/MdcLargeScreenServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/screen/service/impl/MdcLargeScreenServiceImpl.java
@@ -1,11 +1,15 @@
 package org.jeecg.modules.screen.service.impl;
 
-import org.jeecg.modules.mdc.service.IMdcEquipmentStatisticalInfoService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.modules.mdc.dto.MdcEfficiencyDto;
 import org.jeecg.modules.mdcJc.entity.MdcProductDayschedule;
 import org.jeecg.modules.mdcJc.service.IMdcProductDayScheduleService;
 import org.jeecg.modules.screen.dto.*;
 import org.jeecg.modules.screen.mapper.MdcLargeScreenMapper;
 import org.jeecg.modules.screen.service.MdcLargeScreenService;
+import org.jeecg.modules.system.entity.MdcProduction;
+import org.jeecg.modules.system.service.IMdcProductionService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -28,9 +32,12 @@
     @Resource
     private MdcLargeScreenMapper mdcLargeScreenMapper;
 
-    private final String yesterday = LocalDate.now().plusDays(-1).toString();
+    private final String yesterday = LocalDate.now().plusDays(-1).toString().replaceAll("-", "");
 
     private final String today = LocalDate.now().toString();
+
+    @Resource
+    private IMdcProductionService mdcProductionService;
 
 
     /**
@@ -83,7 +90,9 @@
             for (MdcProductDayschedule mdcProductDayschedule : list) {
                 TodayProductionPassRateDto todayProductionPassRateDto = new TodayProductionPassRateDto();
                 todayProductionPassRateDto.setProductionName(mdcProductDayschedule.getProductName());
-                todayProductionPassRateDto.setPassRate(new BigDecimal(mdcProductDayschedule.getQualifiedCount()).divide(new BigDecimal(mdcProductDayschedule.getCompletionCount()), 0, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
+                if (mdcProductDayschedule.getCompletionCount() != 0) {
+                    todayProductionPassRateDto.setPassRate(new BigDecimal(mdcProductDayschedule.getQualifiedCount()).divide(new BigDecimal(mdcProductDayschedule.getCompletionCount()), 0, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
+                }
                 result.add(todayProductionPassRateDto);
             }
         }
@@ -107,7 +116,50 @@
      */
     @Override
     public List<EquipmentRateDto> todayEquipmentRate() {
-        return null;
-//        return mdcLargeScreenMapper.todayEquipmentRate();
+        List<EquipmentRateDto> result = new ArrayList<>();
+        List<MdcEfficiencyDto> mdcEfficiencyDtoList = mdcLargeScreenMapper.efficiencyList(yesterday);
+        if (mdcEfficiencyDtoList != null && !mdcEfficiencyDtoList.isEmpty()) {
+            for (MdcEfficiencyDto mdcEfficiencyDto : mdcEfficiencyDtoList) {
+                EquipmentRateDto equipmentRateDto = new EquipmentRateDto();
+                equipmentRateDto.setEquipmentId(mdcEfficiencyDto.getEquipmentId());
+                equipmentRateDto.setEquipmentName(mdcEfficiencyDto.getEquipmentName());
+                equipmentRateDto.setOpenRate(mdcEfficiencyDto.getOpenRate().multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
+                equipmentRateDto.setUtilizationRate(mdcEfficiencyDto.getUtilizationRate().multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
+                if (!equipmentRateDto.getOpenRate().equals(BigDecimal.ZERO) || !equipmentRateDto.getUtilizationRate().equals(BigDecimal.ZERO)) {
+                    result.add(equipmentRateDto);
+                }
+            }
+        }
+        return result;
     }
+
+    /**
+     * 鏈堝埄鐢ㄧ巼
+     *
+     * @return
+     */
+    @Override
+    public List<MonthEquipmentUtilizationRateDto> monthEquipmentUtilizationRate() {
+        List<MonthEquipmentUtilizationRateDto> result = new ArrayList<>();
+        String startDate = LocalDate.now().plusDays(-32).toString().replaceAll("-", "");
+        List<MdcEfficiencyDto> mdcEfficiencyDtoList = mdcLargeScreenMapper.efficiency(startDate, yesterday);
+        if (mdcEfficiencyDtoList != null && !mdcEfficiencyDtoList.isEmpty()) {
+            for (MdcEfficiencyDto mdcEfficiencyDto : mdcEfficiencyDtoList) {
+                MonthEquipmentUtilizationRateDto meu = new MonthEquipmentUtilizationRateDto();
+                meu.setDate(new StringBuilder(mdcEfficiencyDto.getTheDate().substring(4, 8)).insert(2, "-").toString());
+                BigDecimal equipmentCount = mdcLargeScreenMapper.findEquipmentCount(yesterday);
+                meu.setUtilizationRate(mdcEfficiencyDto.getProcessLong().divide(equipmentCount.multiply(new BigDecimal("86400")), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
+                if (!meu.getUtilizationRate().equals(BigDecimal.ZERO)) {
+                    result.add(meu);
+                }
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public List<MdcProduction> productionList() {
+        return mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgType, "3").eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder));
+    }
+
 }

--
Gitblit v1.9.3