From 368e938e3ced045d6b8499cdaed7d61a84180a1c Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期三, 06 八月 2025 11:12:35 +0800 Subject: [PATCH] 删除原MDC设备车间管理代码 --- src/main/java/org/jeecg/modules/base/service/IFactoryService.java | 2 src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java | 14 src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java | 32 src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml | 18 src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java | 5 src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java | 6 /dev/null | 152 ------ src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java | 2 src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml | 24 src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java | 7 src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java | 82 +- src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml | 12 src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java | 70 +- src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java | 12 src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java | 8 src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java | 30 src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java | 782 ++++++++++++++++---------------- src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java | 126 ++-- src/main/java/org/jeecg/modules/system/controller/SysUserController.java | 7 19 files changed, 617 insertions(+), 774 deletions(-) diff --git a/src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java b/src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java index 840fc19..36d7a59 100644 --- a/src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java +++ b/src/main/java/org/jeecg/modules/base/mapper/FactoryMapper.java @@ -20,4 +20,9 @@ */ @Select("SELECT * FROM base_factory where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}") List<Factory> queryFacByPid(@Param("parentId") String parentId); + + /** + * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 + */ + List<String> recursionChildren(@Param("factoryId") String factoryId); } diff --git a/src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml b/src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml index 0832f10..b818615 100644 --- a/src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml +++ b/src/main/java/org/jeecg/modules/base/mapper/xml/FactoryMapper.xml @@ -2,4 +2,22 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.base.mapper.FactoryMapper"> + <select id="recursionChildren" resultType="java.lang.String"> + WITH temp ( id ) AS ( + SELECT + id + FROM + base_factory + WHERE + id = #{ factoryId } UNION ALL + SELECT + a.id + FROM + base_factory a + INNER JOIN temp ON a.parent_id = temp.id + ) SELECT + * + FROM + temp + </select> </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/base/service/IFactoryService.java b/src/main/java/org/jeecg/modules/base/service/IFactoryService.java index 0cd42ea..e89a234 100644 --- a/src/main/java/org/jeecg/modules/base/service/IFactoryService.java +++ b/src/main/java/org/jeecg/modules/base/service/IFactoryService.java @@ -43,4 +43,6 @@ * 鑾峰彇涓嬬骇浜х嚎 */ List<Factory> queryFacByPid(String pid); + + List<String> recursionChildren(String factoryId); } diff --git a/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java b/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java index c34c7c9..1464018 100644 --- a/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java +++ b/src/main/java/org/jeecg/modules/base/service/impl/FactoryServiceImpl.java @@ -168,6 +168,14 @@ } /** + * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣id + */ + @Override + public List<String> recursionChildren(String factoryId) { + return this.baseMapper.recursionChildren(factoryId); + } + + /** * 鎵撳紑 鐖惰妭鐐� 鍙� 浠ヤ笂鐨刴dc鏍囪 * @param parentId */ diff --git a/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java b/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java index 732f2f3..e156aea 100644 --- a/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java +++ b/src/main/java/org/jeecg/modules/mdc/controller/MdcEfficiencyReportController.java @@ -112,40 +112,40 @@ return Result.OK(result); } - @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�", notes = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�") - @GetMapping("/comprehensiveRateAnalyze") - public Result<?> comprehensiveRateAnalyze(EquEffVo vo) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - Map<String, Object> result = mdcEfficiencyReportService.comprehensiveRateAnalyze(userId, vo); - return Result.OK(result); - } - - @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-鐝粍缁煎悎鍒╃敤鐜囩粺璁″垎鏋�", notes = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�") - @GetMapping("/teamEfficiencyAnalyzeByMonth") - public Result<?> teamEfficiencyAnalyzeByMonth(EquEffVo equEffVo) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - Map<String, Object> result = mdcEfficiencyReportService.teamEfficiencyAnalyzeByMonth(userId, equEffVo); - return Result.OK(result); - } - - @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�", notes = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�") - @GetMapping("/teamEquipmentEfficiencyAnalyze") - public Result<?> teamEquipmentEfficiencyAnalyze(EquEffVo equEffVo) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - Map<String, Object> result = mdcEfficiencyReportService.teamEquipmentEfficiencyAnalyze(userId, equEffVo); - return Result.OK(result); - } - - @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷", notes = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷") - @GetMapping("/equipmentEfficiencyAnalyze") - public Result<?> equipmentEfficiencyAnalyze(EquEffVo equEffVo) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - Map<String, Object> result = mdcEfficiencyReportService.equipmentEfficiencyAnalyze(userId, equEffVo); - return Result.OK(result); - } +// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�", notes = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�") +// @GetMapping("/comprehensiveRateAnalyze") +// public Result<?> comprehensiveRateAnalyze(EquEffVo vo) { +// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); +// String userId = user.getId(); +// Map<String, Object> result = mdcEfficiencyReportService.comprehensiveRateAnalyze(userId, vo); +// return Result.OK(result); +// } +// +// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-鐝粍缁煎悎鍒╃敤鐜囩粺璁″垎鏋�", notes = "璁惧鏁堢巼鎶ヨ〃-缁煎悎鍒╃敤鐜囩粺璁″垎鏋�") +// @GetMapping("/teamEfficiencyAnalyzeByMonth") +// public Result<?> teamEfficiencyAnalyzeByMonth(EquEffVo equEffVo) { +// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); +// String userId = user.getId(); +// Map<String, Object> result = mdcEfficiencyReportService.teamEfficiencyAnalyzeByMonth(userId, equEffVo); +// return Result.OK(result); +// } +// +// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�", notes = "璁惧鏁堢巼鎶ヨ〃-閰嶉�佸皬缁勭淮搴﹀悇鐝粍鏈堣澶囧埄鐢ㄥ垎甯�") +// @GetMapping("/teamEquipmentEfficiencyAnalyze") +// public Result<?> teamEquipmentEfficiencyAnalyze(EquEffVo equEffVo) { +// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); +// String userId = user.getId(); +// Map<String, Object> result = mdcEfficiencyReportService.teamEquipmentEfficiencyAnalyze(userId, equEffVo); +// return Result.OK(result); +// } +// +// @ApiOperation(value = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷", notes = "璁惧鏁堢巼鎶ヨ〃-璁惧缁村害鍚勭彮缁勬湀璁惧鍒╃敤鍒嗗竷") +// @GetMapping("/equipmentEfficiencyAnalyze") +// public Result<?> equipmentEfficiencyAnalyze(EquEffVo equEffVo) { +// LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); +// String userId = user.getId(); +// Map<String, Object> result = mdcEfficiencyReportService.equipmentEfficiencyAnalyze(userId, equEffVo); +// return Result.OK(result); +// } } diff --git a/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java b/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java index ec495da..7b72e9e 100644 --- a/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java +++ b/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java @@ -208,34 +208,34 @@ return Result.OK("鎵归噺绉婚櫎鎴愬姛锛�"); } - /** - * 鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯� - */ - @AutoLog(value = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�") - @ApiOperation(value = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�", notes = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�") - @PostMapping(value = "/removeEquipmentsForProduction") - public Result<?> removeEquipmentsForProduction(@RequestParam(name = "productionId", required = true) String productionId, - @RequestParam(name = "equipmentIds", required = true) String equipmentIds) { - if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentIds)) { - List<String> equipmentIdList = Arrays.asList(equipmentIds.split(",")); - mdcEquipmentService.removeEquipmentsForProduction(productionId, equipmentIdList); - } - return Result.OK("鎵归噺绉婚櫎鎴愬姛锛�"); - } +// /** +// * 鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯� +// */ +// @AutoLog(value = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�") +// @ApiOperation(value = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�", notes = "璁惧浜х嚎琛�-鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯�") +// @PostMapping(value = "/removeEquipmentsForProduction") +// public Result<?> removeEquipmentsForProduction(@RequestParam(name = "productionId", required = true) String productionId, +// @RequestParam(name = "equipmentIds", required = true) String equipmentIds) { +// if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentIds)) { +// List<String> equipmentIdList = Arrays.asList(equipmentIds.split(",")); +// mdcEquipmentService.removeEquipmentsForProduction(productionId, equipmentIdList); +// } +// return Result.OK("鎵归噺绉婚櫎鎴愬姛锛�"); +// } - /** - * 绉婚櫎浜х嚎鍜岃澶囧叧绯� - */ - @AutoLog(value = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�") - @ApiOperation(value = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�", notes = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�") - @PostMapping(value = "/removeEquipmentForProduction") - public Result<?> removeEquipmentForProduction(@RequestParam(name = "productionId", required = true) String productionId, - @RequestParam(name = "equipmentId", required = true) String equipmentId) { - if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentId)) { - mdcEquipmentService.removeEquipmentForProduction(productionId, equipmentId); - } - return Result.OK("绉婚櫎鎴愬姛锛�"); - } +// /** +// * 绉婚櫎浜х嚎鍜岃澶囧叧绯� +// */ +// @AutoLog(value = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�") +// @ApiOperation(value = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�", notes = "璁惧浜х嚎琛�-绉婚櫎浜х嚎鍜岃澶囧叧绯�") +// @PostMapping(value = "/removeEquipmentForProduction") +// public Result<?> removeEquipmentForProduction(@RequestParam(name = "productionId", required = true) String productionId, +// @RequestParam(name = "equipmentId", required = true) String equipmentId) { +// if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentId)) { +// mdcEquipmentService.removeEquipmentForProduction(productionId, equipmentId); +// } +// return Result.OK("绉婚櫎鎴愬姛锛�"); +// } /** * 娣诲姞 @@ -589,18 +589,18 @@ } - @AutoLog(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") - @ApiOperation(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�", notes = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") - @GetMapping(value = "/loadTreeListByProductionIds") - public Result<?> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) { - Result<List<MdcEquipmentTree>> result = new Result<>(); - try { - List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProductionIds(ids); - result.setSuccess(true); - result.setResult(mdcEquipmentTreeList); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } +// @AutoLog(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") +// @ApiOperation(value = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�", notes = "璁惧琛�-閫氳繃杞﹂棿ids鑾峰彇璁惧鏍�") +// @GetMapping(value = "/loadTreeListByProductionIds") +// public Result<?> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) { +// Result<List<MdcEquipmentTree>> result = new Result<>(); +// try { +// List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProductionIds(ids); +// result.setSuccess(true); +// result.setResult(mdcEquipmentTreeList); +// } catch (Exception e) { +// log.error(e.getMessage(), e); +// } +// return result; +// } } diff --git a/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java b/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java deleted file mode 100644 index a12f3d8..0000000 --- a/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java +++ /dev/null @@ -1,278 +0,0 @@ -package org.jeecg.modules.mdc.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.apache.shiro.SecurityUtils; -import org.jeecg.common.api.vo.Result; -import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.modules.mdc.constant.MdcConstant; -import org.jeecg.modules.mdc.dto.MdcEquipmentDto; -import org.jeecg.modules.mdc.entity.MdcEquipment; -import org.jeecg.modules.mdc.entity.MdcFeedback; -import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; -import org.jeecg.modules.mdc.service.IMdcHomeService; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.jeecg.modules.mdc.vo.MdcCommonVo; -import org.jeecg.modules.mdc.vo.MdcHomeEfficiencyVo; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Lius - * @Description: MDC棣栭〉鎺ュ彛 - * @date 2024/3/13 14:27 - */ -@Slf4j -@Api(tags = "MDC棣栭〉鎺ュ彛") -@RestController -@RequestMapping("/mdc/home") -public class MdcHomeController { - - @Resource - private IMdcProductionService mdcProductionService; - - @Resource - private IMdcHomeService mdcHomeService; - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧杩愯鐘舵�佺粺璁�", notes = "MDC棣栭〉鎺ュ彛-璁惧杩愯鐘舵�佺粺璁�") - @GetMapping("/equipmentStatusStatistics") - public Result<?> equipmentStatusStatistics(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()); - } else if (userType.equals(MdcConstant.USER_TYPE_2)) { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - } - List<MdcCommonVo> resultMap = mdcHomeService.getEquipmentStatusStatistics(userId, key); - Map<String, Object> map = new HashMap<>(); - map.put("list", resultMap); - map.put("productionId", key); - return Result.OK(map); - } - - @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); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-宸ユ绾у墠涓冨ぉ鍒╃敤鐜囨姌绾垮浘", notes = "MDC棣栭〉鎺ュ彛-宸ユ绾у墠涓冨ぉ鍒╃敤鐜囨姌绾垮浘") - @GetMapping("/equipmentDayUtilizationStatistics") - public Result<?> equipmentDayUtilizationStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - 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 { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - Map<String, Object> result = mdcHomeService.getEquipmentDayUtilizationStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-涓婃湀鍚勮澶嘜EE缁熻", notes = "MDC棣栭〉鎺ュ彛-涓婃湀鍚勮澶嘜EE缁熻") - @GetMapping("/equipmentOEEMonthStatistics") - public Result<?> equipmentOEEMonthStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - 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 { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - List<MdcOverallEquipmentEfficiency> result = mdcHomeService.getEquipmentOEEMonthStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-宸ユ绾ц澶囨晥鐜囩粺璁�", notes = "MDC棣栭〉鎺ュ彛-宸ユ绾ц澶囨晥鐜囩粺璁�") - @GetMapping("/equipmentEfficiencyStatistics") - public Result<?> equipmentEfficiencyStatistics(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - 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 { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - MdcHomeEfficiencyVo result = mdcHomeService.getEquipmentEfficiencyStatistics(userId, key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囨晥鐜囩粺璁�", notes = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囨晥鐜囩粺璁�") - @GetMapping("/equipmentLevelEfficiencyStatistics") - public Result<?> equipmentLevelEfficiencyStatistics(@RequestParam(name = "equipmentId", required = true) String equipmentId) { - MdcHomeEfficiencyVo result = mdcHomeService.getEquipmentLevelEfficiencyStatistics(equipmentId); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧绾ф暣骞村害鍒╃敤鐜�", notes = "MDC棣栭〉鎺ュ彛-璁惧绾ф暣骞村害鍒╃敤鐜�") - @GetMapping("/equipmentAnnualEfficiencyStatistics") - public Result<?> equipmentAnnualEfficiencyStatistics(@RequestParam(name = "equipmentId", required = true) String equipmentId) { - Map<String, Object> result = mdcHomeService.getEquipmentAnnualEfficiencyStatistics(equipmentId); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囪缁嗕俊鎭�", notes = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囪缁嗕俊鎭�") - @GetMapping("/equipmentDetails") - public Result<?> equipmentDetails(@RequestParam(name = "equipmentId", required = true) String equipmentId) { - MdcEquipmentDto result = mdcHomeService.getEquipmentDetails(equipmentId); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囧垪琛�", notes = "MDC棣栭〉鎺ュ彛-璁惧绾ц澶囧垪琛�") - @GetMapping("/equipmentList") - public Result<?> equipmentList(String productionCode) { - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - 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 { - //宸ユ 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勫伐娈垫潈闄� - key = mdcProductionService.findThreeProductionId(userId); - } - List<MdcEquipment> result = mdcHomeService.getEquipmentList(key); - return Result.OK(result); - } - - @ApiOperation(value = "MDC棣栭〉鎺ュ彛-闂鍒楄〃", notes = "MDC棣栭〉鎺ュ彛-闂鍒楄〃") - @GetMapping("/feedbackList") - public Result<?> feedbackList(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<MdcFeedback> result = mdcHomeService.getFeedbackList(key); - return Result.OK(result); - } - -} diff --git a/src/main/java/org/jeecg/modules/mdc/controller/MdcProductionController.java b/src/main/java/org/jeecg/modules/mdc/controller/MdcProductionController.java deleted file mode 100644 index fdf674b..0000000 --- a/src/main/java/org/jeecg/modules/mdc/controller/MdcProductionController.java +++ /dev/null @@ -1,357 +0,0 @@ -package org.jeecg.modules.mdc.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.apache.shiro.SecurityUtils; -import org.jeecg.common.api.vo.Result; -import org.jeecg.common.aspect.annotation.AutoLog; -import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.system.base.controller.JeecgController; -import org.jeecg.common.system.query.QueryGenerator; -import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.common.util.oConvertUtils; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.model.MdcProductionTreeModel; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.jeecg.modules.mdc.vo.MdcProOptionsVo; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @Description: 浜х嚎琛� - * @Author: liuS - * @Date: 2023-03-23 - * @Version: V1.0 - */ -@Slf4j -@Api(tags = "浜х嚎琛�") -@RestController -@RequestMapping("/mdc/mdcProduction") -public class MdcProductionController extends JeecgController<MdcProduction, IMdcProductionService> { - @Resource - private IMdcProductionService mdcProductionService; - - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param mdcProduction - * @param pageNo - * @param pageSize - * @param req - * @return - */ - @AutoLog(value = "浜х嚎琛�-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value = "浜х嚎琛�-鍒嗛〉鍒楄〃鏌ヨ", notes = "浜х嚎琛�-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<?> queryPageList(MdcProduction mdcProduction, - @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper<MdcProduction> queryWrapper = QueryGenerator.initQueryWrapper(mdcProduction, req.getParameterMap()); - Page<MdcProduction> page = new Page<MdcProduction>(pageNo, pageSize); - IPage<MdcProduction> pageList = mdcProductionService.page(page, queryWrapper); - return Result.OK(pageList); - } - - @AutoLog(value = "浜х嚎琛�-鏍戝舰鍒楄〃") - @ApiOperation(value = "浜х嚎琛�-鏍戝舰鍒楄〃", notes = "浜х嚎琛�-鏍戝舰鍒楄〃") - @GetMapping(value = "/queryTreeList") - public Result<List<MdcProductionTreeModel>> queryTreeList(@RequestParam(name = "ids", required = false) String ids) { - Result<List<MdcProductionTreeModel>> result = new Result<>(); - try { - if (oConvertUtils.isNotEmpty(ids)) { - List<MdcProductionTreeModel> productionList = mdcProductionService.queryTreeList(ids); - result.setResult(productionList); - } else { - List<MdcProductionTreeModel> list = mdcProductionService.queryTreeList(); - result.setResult(list); - } - result.setSuccess(true); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-鏍戝舰鍒楄〃(MDC)") - @ApiOperation(value = "浜х嚎琛�-鏍戝舰鍒楄〃(MDC)", notes = "浜х嚎琛�-鏍戝舰鍒楄〃(MDC)") - @GetMapping(value = "/queryTreeListByMdc") - public Result<List<MdcProductionTreeModel>> queryTreeListByMdc(@RequestParam(name = "ids", required = false) String ids) { - Result<List<MdcProductionTreeModel>> result = new Result<>(); - try { - if (oConvertUtils.isNotEmpty(ids)) { - List<MdcProductionTreeModel> productionList = mdcProductionService.queryTreeListByMdc(ids); - result.setResult(productionList); - } else { - List<MdcProductionTreeModel> list = mdcProductionService.queryTreeListByMdc(); - result.setResult(list); - } - result.setSuccess(true); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-鏍戝舰鍒楄〃(娣诲姞绯荤粺閰嶇疆)") - @ApiOperation(value = "浜х嚎琛�-鏍戝舰鍒楄〃(娣诲姞绯荤粺閰嶇疆)", notes = "浜х嚎琛�-鏍戝舰鍒楄〃(娣诲姞绯荤粺閰嶇疆)") - @GetMapping(value = "/queryTreeListByConfig") - public Result<List<MdcProductionTreeModel>> queryTreeListByConfig(@RequestParam(name = "ids", required = false) String ids) { - Result<List<MdcProductionTreeModel>> result = new Result<>(); - try { - if (oConvertUtils.isNotEmpty(ids)) { - List<MdcProductionTreeModel> productionList = mdcProductionService.queryTreeList(ids); - result.setResult(productionList); - } else { - List<MdcProductionTreeModel> list = mdcProductionService.queryTreeListByConfig(); - result.setResult(list); - } - result.setSuccess(true); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @ApiOperation(value = "浜х嚎琛�-鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎涓嬫媺鏍戦�夐」", notes = "浜х嚎琛�-鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎涓嬫媺鏍戦�夐」") - @GetMapping(value = "/loadProductionTreeOptions") - public Result<List<ProductionIdModel>> loadProductionTreeOptions() { - Result<List<ProductionIdModel>> result = new Result<>(); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - try { - List<ProductionIdModel> list = mdcProductionService.loadProductionTreeOptions(userId); - result.setSuccess(true); - result.setResult(list); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-id闆嗗悎") - @ApiOperation(value = "浜х嚎琛�-id闆嗗悎", notes = "浜х嚎琛�-id闆嗗悎") - @GetMapping(value = "/queryTreeIdList") - public Result<List<String>> queryTreeIdList() { - Result<List<String>> result = new Result<>(); - try { - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0).orderByAsc(MdcProduction::getProductionOrder)); - List<String> ids = productionList.stream().map(MdcProduction::getId).collect(Collectors.toList()); - result.setSuccess(true); - result.setResult(ids); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - /** - * 娣诲姞 - * - * @param mdcProduction - * @return - */ - @AutoLog(value = "浜х嚎琛�-娣诲姞") - @ApiOperation(value = "浜х嚎琛�-娣诲姞", notes = "浜х嚎琛�-娣诲姞") - @PostMapping(value = "/add") - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<MdcProduction> add(@RequestBody MdcProduction mdcProduction) { - Result<MdcProduction> result = new Result<>(); - try { - mdcProductionService.saveProductionData(mdcProduction); - result.success("娣诲姞鎴愬姛锛�"); - } catch (Exception e) { - log.error(e.getMessage(), e); - result.error500("鎿嶄綔澶辫触"); - } - return result; - } - - /** - * 缂栬緫 - * - * @param mdcProduction - * @return - */ - @AutoLog(value = "浜х嚎琛�-缂栬緫") - @ApiOperation(value = "浜х嚎琛�-缂栬緫", notes = "浜х嚎琛�-缂栬緫") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<MdcProduction> edit(@RequestBody MdcProduction mdcProduction) { - Result<MdcProduction> result = new Result<>(); - MdcProduction mdcProductionEntity = mdcProductionService.getById(mdcProduction.getId()); - if (mdcProductionEntity == null) { - result.error500("鏈壘鍒板搴斿疄浣�"); - } else { - boolean ok = mdcProductionService.updateProductionDataById(mdcProduction); - if (ok) { - result.success("淇敼鎴愬姛!"); - } - } - return result; - } - - /** - * 閫氳繃id鍒犻櫎 - * - * @param id - * @return - */ - @AutoLog(value = "浜х嚎琛�-閫氳繃id鍒犻櫎") - @ApiOperation(value = "浜х嚎琛�-閫氳繃id鍒犻櫎", notes = "浜х嚎琛�-閫氳繃id鍒犻櫎") - @DeleteMapping(value = "/delete") - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<MdcProduction> delete(@RequestParam(name = "id", required = true) String id) { - Result<MdcProduction> result = new Result<>(); - MdcProduction mdcProduction = mdcProductionService.getById(id); - if (mdcProduction == null) { - result.error500("鏈壘鍒板搴斿疄浣�"); - } else { - boolean ok = mdcProductionService.delete(id); - if (ok) { - result.success("鍒犻櫎鎴愬姛!"); - } - } - return result; - } - - /** - * 鎵归噺鍒犻櫎 - * - * @param ids - * @return - */ - @AutoLog(value = "浜х嚎琛�-鎵归噺鍒犻櫎") - @ApiOperation(value = "浜х嚎琛�-鎵归噺鍒犻櫎", notes = "浜х嚎琛�-鎵归噺鍒犻櫎") - @DeleteMapping(value = "/deleteBatch") - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<MdcProduction> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { - Result<MdcProduction> result = new Result<>(); - if (ids == null || "".equals(ids.trim())) { - result.error500("鍙傛暟涓嶈瘑鍒紒"); - } else { - this.mdcProductionService.deleteBatchWithChildren(Arrays.asList(ids.split(","))); - result.success("鍒犻櫎鎴愬姛!"); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-鏌ヨ鏍戝舰缁撴瀯鎵�鏈変骇绾垮悕绉�") - @ApiOperation(value = "浜х嚎琛�-鏌ヨ鏍戝舰缁撴瀯鎵�鏈変骇绾垮悕绉�", notes = "浜х嚎琛�-鏌ヨ鏍戝舰缁撴瀯鎵�鏈変骇绾垮悕绉�") - @GetMapping(value = "/queryIdTree") - public Result<List<ProductionIdModel>> queryIdTree() { - Result<List<ProductionIdModel>> result = new Result<>(); - try { - List<ProductionIdModel> list = mdcProductionService.queryProductionIdTreeList(); - result.setResult(list); - result.setSuccess(true); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @AutoLog(value = "浜х嚎琛�-鏍规嵁鍏抽敭瀛楁ā绯婃悳绱㈢浉鍏充骇绾�") - @ApiOperation(value = "浜х嚎琛�-鏍规嵁鍏抽敭瀛楁ā绯婃悳绱㈢浉鍏充骇绾�", notes = "浜х嚎琛�-鏍规嵁鍏抽敭瀛楁ā绯婃悳绱㈢浉鍏充骇绾�") - @GetMapping(value = "/searchBy") - public Result<List<MdcProductionTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) { - Result<List<MdcProductionTreeModel>> result = new Result<>(); - List<MdcProductionTreeModel> treeList = mdcProductionService.searchByKeyWord(keyWord); - if (treeList == null || treeList.isEmpty()) { - result.setSuccess(false); - result.setMessage("鏈煡璇㈠尮閰嶆暟鎹紒"); - return result; - } - result.setResult(treeList); - return result; - } - - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - @AutoLog(value = "浜х嚎琛�-閫氳繃id鏌ヨ") - @ApiOperation(value = "浜х嚎琛�-閫氳繃id鏌ヨ", notes = "浜х嚎琛�-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { - MdcProduction mdcProduction = mdcProductionService.getById(id); - return Result.OK(mdcProduction); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param mdcProduction - */ - @AutoLog(value = "浜х嚎琛�-瀵煎嚭excel") - @ApiOperation(value = "浜х嚎琛�-瀵煎嚭excel", notes = "浜х嚎琛�-瀵煎嚭excel") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, MdcProduction mdcProduction) { - return super.exportXls(request, mdcProduction, MdcProduction.class, "浜х嚎琛�"); - } - - /** - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - @AutoLog(value = "浜х嚎琛�-閫氳繃excel瀵煎叆鏁版嵁") - @ApiOperation(value = "浜х嚎琛�-閫氳繃excel瀵煎叆鏁版嵁", notes = "浜х嚎琛�-閫氳繃excel瀵煎叆鏁版嵁") - @PostMapping(value = "/importExcel") - @CacheEvict(value = {"mdc:cache:production:alldata", "mdc:cache:production:allids"}, allEntries = true) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, MdcProduction.class); - } - - @ApiOperation(value = "浜х嚎琛�-鏍规嵁鐢ㄦ埛id鑾峰彇MDC浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」", notes = "浜х嚎琛�-鏍规嵁鐢ㄦ埛id鑾峰彇MDC浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」") - @GetMapping(value = "/loadProductionOptions") - public Result<?> loadProductionOptions(String productionId) { - Result<List<MdcProOptionsVo>> result = new Result<>(); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - try { - List<MdcProOptionsVo> list = mdcProductionService.loadProductionOptions(userId, productionId); - result.setSuccess(true); - result.setResult(list); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - - @ApiOperation(value = "浜х嚎琛�-鏍规嵁鐝粍id鑾峰彇閰嶉�佺粍涓嬫媺閫夐」", notes = "浜х嚎琛�-鏍规嵁鐝粍id鑾峰彇閰嶉�佺粍涓嬫媺閫夐」") - @GetMapping(value = "/loadTeamOptions") - public Result<?> loadTeamOptions(@RequestParam(name = "productionId", required = true) String productionId) { - Result<List<MdcProOptionsVo>> result = new Result<>(); - LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String userId = user.getId(); - try { - List<MdcProOptionsVo> list = mdcProductionService.loadTeamOptions(userId, productionId); - result.setSuccess(true); - result.setResult(list); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return result; - } - -} diff --git a/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java b/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java index 1e6d764..e9afd9b 100644 --- a/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java +++ b/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyDto.java @@ -55,17 +55,5 @@ * 鍏虫満鏃堕暱 */ private BigDecimal closeLong; - /** - * 鏁呴殰鏃堕暱 - */ - private BigDecimal faultLong; - /** - * 鏁呴殰鐜� - */ - private BigDecimal faultRate; - /** - * 杩愯鏃堕暱(鍘婚櫎鏁呴殰鏃堕棿) - */ - private BigDecimal removeFaultRunLong; } diff --git a/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java b/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java index 2086182..0056c06 100644 --- a/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java +++ b/src/main/java/org/jeecg/modules/mdc/dto/MdcEfficiencyResultDto.java @@ -42,24 +42,24 @@ * 鍏虫満鏃堕暱 */ private BigDecimal closeLong = BigDecimal.ZERO; - /** - * 鏁呴殰鏃堕暱 - */ - private BigDecimal faultLong = BigDecimal.ZERO; - /** - * 鏁呴殰鐜� - */ - private BigDecimal faultRate = BigDecimal.ZERO; - /** - * 杩愯鏃堕暱(鍘婚櫎鏁呴殰鏃堕棿) - */ - private BigDecimal removeFaultRunLong = BigDecimal.ZERO; +// /** +// * 鏁呴殰鏃堕暱 +// */ +// private BigDecimal faultLong = BigDecimal.ZERO; +// /** +// * 鏁呴殰鐜� +// */ +// private BigDecimal faultRate = BigDecimal.ZERO; +// /** +// * 杩愯鏃堕暱(鍘婚櫎鏁呴殰鏃堕棿) +// */ +// private BigDecimal removeFaultRunLong = BigDecimal.ZERO; /** * 棰滆壊 */ private String color; - public MdcEfficiencyResultDto(String theDate, BigDecimal processLong, BigDecimal utilizationRate, BigDecimal startRate, BigDecimal openRate, BigDecimal openLong, BigDecimal waitLong, BigDecimal closeLong, BigDecimal faultLong, BigDecimal faultRate, BigDecimal removeFaultRunLong) { + public MdcEfficiencyResultDto(String theDate, BigDecimal processLong, BigDecimal utilizationRate, BigDecimal startRate, BigDecimal openRate, BigDecimal openLong, BigDecimal waitLong, BigDecimal closeLong) { this.theDate = theDate; this.processLong = processLong; this.utilizationRate = utilizationRate; @@ -68,9 +68,9 @@ this.openLong = openLong; this.waitLong = waitLong; this.closeLong = closeLong; - this.faultLong = faultLong; - this.faultRate = faultRate; - this.removeFaultRunLong = removeFaultRunLong; +// this.faultLong = faultLong; +// this.faultRate = faultRate; +// this.removeFaultRunLong = removeFaultRunLong; } public MdcEfficiencyResultDto() { diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java deleted file mode 100644 index 3aa3fd3..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentFaultInfoMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.jeecg.modules.mdc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Param; -import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; -import org.jeecg.modules.mdc.vo.EquFaultRecord; - -import java.util.List; - -/** - * @Description: 鏁呴殰鐜囪〃 - * @Author: jeecg-boot - * @Date: 2025-06-16 - * @Version: V1.0 - */ -public interface MdcEquipmentFaultInfoMapper extends BaseMapper<MdcEquipmentFaultInfo> { - - List<EquFaultRecord> findFaultRecord(@Param("equipmentIdList") List<String> equipmentIdList, @Param("startTime") String startTime, @Param("endTime") String endTime); - - String getMaxStaticsData(); - -} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java index f5b6fba..dbc09ca 100644 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java +++ b/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java @@ -143,7 +143,7 @@ List<String> getEquIdsByProIds(@Param("proIds") List<String> proIds); - List<MdcEquipment> getEquipmentList(@Param("allProductionIds") List<String> allProductionIds); + List<MdcEquipment> getEquipmentList(@Param("allFactoryIds") List<String> allFactoryIds); List<MdcEquipment> queryByFactoryId(@Param("factoryId") String factoryId); diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionEquipmentMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionEquipmentMapper.java deleted file mode 100644 index f365f1a..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionEquipmentMapper.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.jeecg.modules.mdc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.jeecg.modules.mdc.entity.MdcProductionEquipment; - -/** - * 浜х嚎璁惧mapper鎺ュ彛 - * - * @author: LiuS - * @create: 2023-03-24 16:00 - */ -public interface MdcProductionEquipmentMapper extends BaseMapper<MdcProductionEquipment> { -} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionMapper.java deleted file mode 100644 index 5b059de..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcProductionMapper.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.jeecg.modules.mdc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; -import org.jeecg.modules.mdc.entity.MdcProduction; - -import java.util.List; - - -/** - * @Description: 浜х嚎琛� - * @Author: liuS - * @Date: 2023-03-23 - * @Version: V1.0 - */ -public interface MdcProductionMapper extends BaseMapper<MdcProduction> { - - /** - * 鏍规嵁id涓嬬骇浜х嚎 - */ - @Select("SELECT * FROM mdc_production where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}") - List<MdcProduction> queryProdByPid(@Param("parentId") String parentId); - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - */ - List<String> recursionChildren(@Param("productionId") String productionId); - - /** - * 涓�缁刬d閫掑綊鎵�鏈夊瓙鑺傜偣 - */ - List<String> recursionChildrenByList(@Param("productionIds") List<String> productionIds); - - /** - * 鏍规嵁鐢ㄦ埛id鍜岃溅闂磇d鑾峰彇鐢ㄦ埛鎷ユ湁鐨勮溅闂磇d - * @param userId - * @param productionId - * @return - */ - String findFirstProduction(@Param("userId") String userId, @Param("productionId") String productionId); - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛宸ユ鏉冮檺 - * @param userId - * @return - */ - String findThreeProductionId(@Param("userId") String userId); - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛鍏ㄩ儴杞﹂棿鏉冮檺 - * @param userId - * @return - */ - List<MdcProduction> findAllProductionId(@Param("userId") String userId); - - List<String> findChildren(@Param("mdcProductionIds") List<String> mdcProductionIds); - - List<MdcProduction> loadProductionOptions(@Param("userId") String userId, @Param("productionId") String productionId); - - List<String> findTeamValue(@Param("userId") String userId, @Param("productionList") List<String> productionList); - - List<String> findProIdsByUId(@Param("userId") String userId, @Param("allProductionIds") List<String> allProductionIds); - - List<String> findChildByProId(@Param("productionId") String productionId); - - String findProName(@Param("equipmentId") String equipmentId); -} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/MdcUserProductionMapper.java b/src/main/java/org/jeecg/modules/mdc/mapper/MdcUserProductionMapper.java deleted file mode 100644 index d7ca1c1..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/MdcUserProductionMapper.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.jeecg.modules.mdc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Param; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.system.entity.SysUser; - -import java.util.List; - -/** - * 鐢ㄦ埛浜х嚎Mapper鎺ュ彛 - * - * @author: LiuS - * @create: 2023-03-24 15:43 - */ -public interface MdcUserProductionMapper extends BaseMapper<MdcUserProduction> { - - /** - * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 - */ - List<String> queryProductionIdsByUserId(@Param("userId") String userId); - - /** - * 鑾峰彇宸插垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - List<SysUser> getUserPermsByGroupId(@Param("proId") String proId); - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - List<SysUser> getUserNonPermsByGroupId(@Param("proId") String proId); - - /** - * 鑾峰彇璁惧鏈垎閰嶇殑鐢ㄦ埛 - * @param proId - * @return - */ - List<SysUser> getUserNonPermsByDeviceId(String proId); - - - /** - * 鑾峰彇璁惧宸插垎閰嶇殑鐢ㄦ埛 - * @param deviceId - * @return - */ - List<SysUser> getUserPermsByDeviceId(String deviceId); - - /** - * 閫氳繃杞﹂棿id涓庡矖浣峣d绛涢�夌敤鎴� - * @param post - * @param proId - * @return - */ - List<SysUser> queryByPostAndProId(@Param("post") String post, @Param("proId") String proId); -} diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml index d611c14..d5a3d75 100644 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml +++ b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEfficiencyReportMapper.xml @@ -18,14 +18,10 @@ t1.open_long / 86400 openRate, t1.open_long openLong, t1.wait_long waitLong, - t1.close_long closeLong, - COALESCE(t3.fault_long, 0) faultLong, - COALESCE(t3.fault_rate, 0) faultRate, - COALESCE(t3.remove_fault_run_long, 0) removeFaultRunLong + t1.close_long closeLong FROM mdc_equipment t2 LEFT JOIN mdc_equipment_statistical_info t1 ON t1.equipment_id = t2.equipment_id - LEFT JOIN mdc_equipment_fault_info t3 ON t2.equipment_id = t3.equipment_id AND t1.the_date = t3.the_date WHERE t1.the_date <= #{ vo.endTime } AND t1.the_date >= #{ vo.startTime } @@ -69,14 +65,10 @@ t1.open_long / 86400 openRate, t1.open_long openLong, t1.wait_long waitLong, - t1.close_long closeLong, - COALESCE(t3.fault_long, 0) faultLong, - COALESCE(t3.fault_rate, 0) faultRate, - COALESCE(t3.remove_fault_run_long, 0) removeFaultRunLong + t1.close_long closeLong FROM mdc_equipment t2 LEFT JOIN mdc_equipment_statistical_info t1 ON t1.equipment_id = t2.equipment_id - LEFT JOIN mdc_equipment_fault_info t3 ON t2.equipment_id = t3.equipment_id AND t1.the_date = t3.the_date WHERE t1.the_date <= #{ vo.endTime } AND t1.the_date >= #{ vo.startTime } diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml deleted file mode 100644 index 3136e97..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentFaultInfoMapper.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcEquipmentFaultInfoMapper"> - - <select id="findFaultRecord" resultType="org.jeecg.modules.mdc.vo.EquFaultRecord"> - SELECT - t3.equipment_code equipmentId, - t1.fault_start_time startTime, - t2.actual_end_time endTime - FROM - eam_report_repair t1 - LEFT JOIN eam_repair_order t2 ON t2.report_id = t1.id - LEFT JOIN eam_equipment t3 ON t1.equipment_id = t3.id - WHERE - ( - ( t1.fault_start_time BETWEEN #{startTime} AND #{endTime} ) - OR ( t2.actual_end_time BETWEEN #{startTime} AND #{endTime} ) - OR ( t1.fault_start_time < #{startTime} AND t2.actual_end_time IS NULL ) - ) - AND t3.equipment_code IN - <foreach collection="equipmentIdList" item="id" index="index" open="(" close=")" separator=","> - #{ id } - </foreach> - AND t1.report_status != 'ABOLISH' - </select> - - <select id="getMaxStaticsData" resultType="java.lang.String"> - SELECT TOP 1 the_date FROM mdc_equipment_fault_info ORDER BY the_date DESC - </select> -</mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml index 3087928..f4dcaf8 100644 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml +++ b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml @@ -95,10 +95,10 @@ me.* FROM mdc_equipment me - LEFT JOIN mdc_production_equipment mpe ON me.id = mpe.equipment_id + LEFT JOIN base_equipment_factory mpe ON me.id = mpe.equipment_id WHERE - mpe.production_id IN - <foreach collection="allProductionIds" index="index" item="id" open="(" separator="," close=")"> + mpe.factory_id IN + <foreach collection="allFactoryIds" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> </select> @@ -181,14 +181,14 @@ SELECT mp.id, mp.parent_id, - mp.production_name, - mp.org_type, + mp.factory_name AS productionName, + mp.factory_category AS orgtype, me.equipment_id, me.equipment_name, me.equipment_type FROM - mdc_production_equipment mpe - LEFT JOIN mdc_production mp ON mpe.production_id = mp.id + base_equipment_factory mpe + LEFT JOIN base_factory mp ON mpe.factory_id = mp.id LEFT JOIN mdc_equipment me ON me.id = mpe.equipment_id <where> me.equipment_id IN @@ -196,7 +196,7 @@ #{id} </foreach> </where> - ORDER BY mp.production_order + ORDER BY mp.sorter </select> <!--鏍规嵁澶у睆杞﹂棿id鏌ヨ璁惧鍒楄〃--> @@ -221,8 +221,8 @@ t1.* FROM mdc_equipment t1 - LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id - LEFT JOIN mdc_production t3 ON t2.production_id = t3.id + LEFT JOIN base_equipment_factory t2 ON t1.id = t2.equipment_id + LEFT JOIN base_factory t3 ON t2.factory_id = t3.id <where> <if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' "> AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%') @@ -260,8 +260,8 @@ t1.* FROM mdc_equipment t1 - LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id - LEFT JOIN mdc_production t3 ON t2.production_id = t3.id + LEFT JOIN base_equipment_factory t2 ON t1.id = t2.equipment_id + LEFT JOIN base_factory t3 ON t2.production_id = t3.id <where> <if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' "> AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%') diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml deleted file mode 100644 index 23c95bf..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionEquipmentMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper"> - -</mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionMapper.xml deleted file mode 100644 index 662a7d9..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcProductionMapper.xml +++ /dev/null @@ -1,204 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcProductionMapper"> - - <!--閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣--> - <select id="recursionChildren" resultType="java.lang.String"> - WITH temp ( id ) AS ( - SELECT - id - FROM - mdc_production - WHERE - id = #{ productionId } UNION ALL - SELECT - a.id - FROM - mdc_production a - INNER JOIN temp ON a.parent_id = temp.id - ) SELECT - * - FROM - temp - </select> - - <!--鏍规嵁鐢ㄦ埛id鍜岃溅闂磇d鑾峰彇鐢ㄦ埛鎷ユ湁鐨勮溅闂磇d--> - <select id="findFirstProduction" resultType="java.lang.String"> - SELECT TOP 1 t2.id FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id WHERE t1.user_id = #{ userId } AND t2.parent_id = #{productionId} - </select> - - <!--鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛宸ユ鏉冮檺--> - <select id="findThreeProductionId" resultType="java.lang.String"> - SELECT TOP 1 t2.id id FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id WHERE t1.user_id = #{userId} AND t2.org_type = '3' - </select> - <select id="findAllProductionId" resultType="org.jeecg.modules.mdc.entity.MdcProduction"> - SELECT - t1.* - FROM - mdc_production t1 - LEFT JOIN mdc_user_production t2 ON t1.id = t2.pro_id - LEFT JOIN sys_user t3 on t3.ID=t2.user_id - WHERE - t3.id = #{userId} - AND t1.org_type = '3' - </select> - - <select id="recursionChildrenByList" resultType="java.lang.String"> - WITH temp (id) AS ( - -- 鍒濆鏌ヨ锛岃幏鍙栨寚瀹� id 鐨勮褰� - SELECT - id - FROM - mdc_production - WHERE - id IN - <foreach collection = "productionIds" item = "id" index = "index" open = "(" close = ")" separator = ","> - #{id} - </foreach> - UNION ALL - -- 閫掑綊鏌ヨ锛屾煡鎵惧瓙鑺傜偣 - SELECT - a.id - FROM - mdc_production a - INNER JOIN temp ON a.parent_id = temp.id - ) --- 鏈�缁堟煡璇紝浣跨敤 DISTINCT 鍘婚噸 - SELECT DISTINCT - id - FROM - temp; - </select> - - <select id="findChildren" resultType="java.lang.String"> - WITH temp ( id ) AS ( - SELECT - id - FROM - mdc_production - WHERE - id IN - <foreach collection="mdcProductionIds" item = "id" index = "index" open = "(" close = ")" separator = ","> - #{id} - </foreach> - AND mdc_flag = '1' UNION ALL - SELECT - a.id - FROM - mdc_production a - INNER JOIN temp ON a.parent_id = temp.id - WHERE - a.mdc_flag = '1' - ) SELECT - * - FROM - temp - </select> - - <select id="loadProductionOptions" resultType="org.jeecg.modules.mdc.entity.MdcProduction"> - SELECT - t1.* - FROM - mdc_production t1 - LEFT JOIN mdc_user_production t2 ON t1.id = t2.pro_id - WHERE - t2.user_id = #{userId} AND t1.mdc_flag = '1' - <choose> - <when test="productionId != null and productionId != ''"> - AND t1.org_type = '3' AND t1.parent_id = #{productionId} - </when> - <otherwise> - AND t1.org_type = '2' - </otherwise> - </choose> - ORDER BY t1.production_order - </select> - - <select id="findTeamValue" resultType="java.lang.String"> - SELECT DISTINCT - t1.team_code deamCode - FROM - mdc_equipment t1 - LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id - WHERE t2.production_id IN - <foreach collection="productionList" item = "productionId" index = "index" open = "(" close= ")" separator = ","> - #{productionId} - </foreach> - </select> - - <select id="findProIdsByUId" resultType="java.lang.String"> - SELECT - pro_id - FROM - mdc_user_production - WHERE - pro_id IN - <foreach collection="allProductionIds" item = "productionId" index = "index" open = "(" close= ")" separator = ","> - #{productionId} - </foreach> - AND user_id = #{userId} - </select> - - <select id="findChildByProId" resultType="java.lang.String"> - WITH temp ( id ) AS ( - SELECT - id - FROM - mdc_production - WHERE - id = #{ productionId } - AND mdc_flag = '1' UNION ALL - SELECT - a.id - FROM - mdc_production a - INNER JOIN temp ON a.parent_id = temp.id - WHERE - a.mdc_flag = '1' - ) SELECT - * - FROM - temp - </select> - - <select id="findProName" resultType="java.lang.String"> - WITH production_hierarchy AS ( - SELECT - t3.id, - t3.parent_id, - t3.production_name, - t3.org_type, - 0 AS level - FROM - mdc_equipment t1 - JOIN - mdc_production_equipment t2 ON t1.id = t2.equipment_id - JOIN - mdc_production t3 ON t2.production_id = t3.id - WHERE - t1.equipment_id = #{equipmentId} - - UNION ALL - SELECT - t4.id, - t4.parent_id, - t4.production_name, - t4.org_type, - ph.level + 1 - FROM - production_hierarchy ph - JOIN - mdc_production t4 ON ph.parent_id = t4.id - WHERE - ph.parent_id IS NOT NULL - ) - SELECT TOP 1 - production_name - FROM - production_hierarchy - WHERE - org_type = 2 - ORDER BY - level ASC - </select> -</mapper> diff --git a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcUserProductionMapper.xml b/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcUserProductionMapper.xml deleted file mode 100644 index 750baa2..0000000 --- a/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcUserProductionMapper.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.jeecg.modules.mdc.mapper.MdcUserProductionMapper"> - - <!--鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎--> - <select id="queryProductionIdsByUserId" resultType="java.lang.String"> - SELECT pro_id FROM mdc_user_production WHERE user_id = #{userId} - </select> - <select id="getUserPermsByGroupId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.id - , u.username - , u.realname - , u.avatar - , u.phone - , u.email - from sys_user u - inner join - (select user_id from mdc_user_production where pro_id=#{proId}) p - on u.id=p.user_id - </select> - <select id="getUserNonPermsByGroupId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.id - , u.username - , u.realname - , u.avatar - , u.phone - , u.email - from sys_user u - where u.id not in (select user_id from mdc_user_production where pro_id=#{proId}) - </select> - <select id="getUserNonPermsByDeviceId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.id - , u.username - , u.realname - , u.avatar - , u.phone - , u.email - from sys_user u - where u.id not in (select user_id from nc_device_permission where device_id=#{deviceId}) - </select> - <select id="getUserPermsByDeviceId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.id - , u.username - , u.realname - , u.avatar - , u.phone - , u.email - from sys_user u - inner join - (select user_id from nc_device_permission where device_id=#{deviceId}) p - on u.id=p.user_id - </select> - <select id="queryByPostAndProId" resultType="org.jeecg.modules.system.entity.SysUser"> - select u.* - from sys_user u - inner join - (select user_id from mdc_user_production where pro_id=#{proId}) p - on u.id=p.user_id - where u.post = #{post} - </select> -</mapper> diff --git a/src/main/java/org/jeecg/modules/mdc/rule/OrgCodeProRule.java b/src/main/java/org/jeecg/modules/mdc/rule/OrgCodeProRule.java deleted file mode 100644 index b8cf69a..0000000 --- a/src/main/java/org/jeecg/modules/mdc/rule/OrgCodeProRule.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.jeecg.modules.mdc.rule; - -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import io.netty.util.internal.StringUtil; -import org.jeecg.common.handler.IFillRuleHandler; -import org.jeecg.common.util.SpringContextUtils; -import org.jeecg.common.util.YouBianCodeUtil; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.service.IMdcProductionService; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author: LiuS - * @create: 2023-07-04 16:15 - * @Description: 杞﹂棿鏈烘瀯缂栫爜鐢熸垚瑙勫垯 - */ -public class OrgCodeProRule implements IFillRuleHandler { - - @Override - public Object execute(JSONObject params, JSONObject formData) { - IMdcProductionService mdcProductionService = (IMdcProductionService) SpringContextUtils.getBean("mdcProductionServiceImpl"); - - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - LambdaQueryWrapper<MdcProduction> query1 = new LambdaQueryWrapper<MdcProduction>(); - // 鍒涘缓涓�涓狶ist闆嗗悎,瀛樺偍鏌ヨ杩斿洖鐨勬墍鏈塎dcProduction瀵硅薄 - List<MdcProduction> mdcProductionList = new ArrayList<>(); - String[] strArray = new String[2]; - //瀹氫箟杞﹂棿绫诲瀷 - String orgType = ""; - // 瀹氫箟鏂扮紪鐮佸瓧绗︿覆 - String newOrgCode = ""; - // 瀹氫箟鏃х紪鐮佸瓧绗︿覆 - String oldOrgCode = ""; - - String parentId = null; - if (formData != null && formData.size() > 0) { - Object obj = formData.get("parentId"); - if (obj != null) { - parentId = obj.toString(); - } - } else { - if (params != null) { - Object obj = params.get("parentId"); - if (obj != null) { - parentId = obj.toString(); - } - } - } - - //濡傛灉鏄渶楂樼骇,鍒欐煡璇㈠嚭鍚岀骇鐨刼rg_code, 璋冪敤宸ュ叿绫荤敓鎴愮紪鐮佸苟杩斿洖 - if (StringUtil.isNullOrEmpty(parentId)) { - // 绾垮垽鏂暟鎹簱涓殑琛ㄦ槸鍚︿负绌�,绌哄垯鐩存帴杩斿洖鍒濆缂栫爜 - query1.eq(MdcProduction::getParentId, "").or().isNull(MdcProduction::getParentId); - query1.orderByDesc(MdcProduction::getOrgCode); - mdcProductionList = mdcProductionService.list(query1); - if (mdcProductionList == null || mdcProductionList.size() == 0) { - strArray[0] = YouBianCodeUtil.getNextYouBianCode(null); - strArray[1] = "1"; - return strArray; - } else { - MdcProduction mdcProduction = mdcProductionList.get(0); - oldOrgCode = mdcProduction.getOrgCode(); - orgType = mdcProduction.getOrgType(); - newOrgCode = YouBianCodeUtil.getNextYouBianCode(oldOrgCode); - } - } else {//鍙嶄箣鍒欐煡璇㈠嚭鎵�鏈夊悓绾х殑杞﹂棿,鑾峰彇缁撴灉鍚庢湁涓ょ鎯呭喌,鏈夊悓绾у拰娌℃湁鍚岀骇 - // 灏佽鏌ヨ鍚岀骇鐨勬潯浠� - query.eq(MdcProduction::getParentId, parentId); - // 闄嶅簭鎺掑簭 - query.orderByDesc(MdcProduction::getOrgCode); - // 鏌ヨ鍑哄悓绾т骇绾跨殑闆嗗悎 - List<MdcProduction> parentList = mdcProductionService.list(query); - // 鏌ヨ鍑虹埗绾т骇绾� - MdcProduction production = mdcProductionService.getById(parentId); - // 鑾峰彇鐖剁骇浜х嚎鐨刢ode - String parentCode = production.getOrgCode(); - // 鏍规嵁鐖剁骇浜х嚎绫诲瀷绠楀嚭褰撳墠浜х嚎鐨勭被鍨� - orgType = String.valueOf(Integer.valueOf(production.getOrgType()) + 1); - // 澶勭悊鍚岀骇浜х嚎涓簄ull鐨勬儏鍐� - if (parentList == null || parentList.size() == 0) { - // 鐩存帴鐢熸垚褰撳墠鐨勪骇绾跨紪鐮佸苟杩斿洖 - newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, null); - } else { //澶勭悊鏈夊悓绾т骇绾跨殑鎯呭喌 - // 鑾峰彇鍚岀骇浜х嚎鐨勭紪鐮�,鍒╃敤宸ュ叿绫� - String subCode = parentList.get(0).getOrgCode(); - // 杩斿洖鐢熸垚鐨勫綋鍓嶄骇绾跨紪鐮� - newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, subCode); - } - } - // 杩斿洖鏈�缁堝皝瑁呬簡浜х嚎缂栫爜鍜屼骇绾跨被鍨嬬殑鏁扮粍 - strArray[0] = newOrgCode; - strArray[1] = orgType; - return strArray; - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java deleted file mode 100644 index d8f63a3..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentFaultInfoService.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.jeecg.modules.mdc.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; - -/** - * @Description: 鏁呴殰鐜囪〃 - * @Author: Lius - * @Date: 2025-06-16 - * @Version: V1.0 - */ -public interface IMdcEquipmentFaultInfoService extends IService<MdcEquipmentFaultInfo> { - - /** - * 缁熻鏁呴殰鏃堕暱锛岃绠楁晠闅滅巼 - * @param parameter - */ - void runningAllEquFaultStatistical(String parameter); -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java index f3493f9..51f4341 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java +++ b/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java @@ -88,15 +88,15 @@ */ void removeEquipmentsForDepart(String departId, List<String> equipmentIdList); - /** - * 绉婚櫎璁惧鍜屼骇绾垮叧绯� - */ - void removeEquipmentForProduction(String productionId, String equipmentId); +// /** +// * 绉婚櫎璁惧鍜屼骇绾垮叧绯� +// */ +// void removeEquipmentForProduction(String productionId, String equipmentId); - /** - * 鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯� - */ - void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList); +// /** +// * 鎵归噺绉婚櫎浜х嚎鍜岃澶囧叧绯� +// */ +// void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList); /** * 鍔犺浇閮ㄩ棬璁惧鏍� @@ -192,13 +192,13 @@ */ List<MdcEquipment> exportXlsList(MdcEquipmentVo mdcEquipment); - /** - * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� - * - * @param ids - * @return - */ - List<MdcEquipmentTree> loadTreeListByProductionIds(String ids); +// /** +// * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� +// * +// * @param ids +// * @return +// */ +// List<MdcEquipmentTree> loadTreeListByProductionIds(String ids); /** * 鏌ヨ鍗曡〃鏁版嵁 diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcHomeService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcHomeService.java deleted file mode 100644 index cadcb5a..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcHomeService.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.jeecg.modules.mdc.service; - -import org.jeecg.modules.mdc.dto.MdcEquipmentDto; -import org.jeecg.modules.mdc.entity.MdcEquipment; -import org.jeecg.modules.mdc.entity.MdcFeedback; -import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency; -import org.jeecg.modules.mdc.vo.MdcCommonVo; -import org.jeecg.modules.mdc.vo.MdcHomeEfficiencyVo; - -import java.util.List; -import java.util.Map; - -/** - * @author Lius - * @date 2024/3/14 9:51 - */ -public interface IMdcHomeService { - - /** - * 璁惧杩愯鐘舵�佺粺璁� - */ - List<MdcCommonVo> getEquipmentStatusStatistics(String userId, String key); - - /** - * 璁惧鍒╃敤鐜囩粺璁� - */ - List<MdcCommonVo> getEquipmentUtilizationStatistics(String userId, String key); - - /** - * 璁惧OEE缁熻 - */ - List<MdcCommonVo> getEquipmentOeeStatistics(String userId, String key); - - /** - * 璁惧OEE鍜屽埄鐢ㄧ巼缁熻鏌辩姸鍥� - */ - Map<String, Object> getEquipmentMonthStatistics(String userId, String key); - - /** - * 宸ユ绾у墠涓冨ぉ鍒╃敤鐜囨姌绾垮浘 - */ - Map<String, Object> getEquipmentDayUtilizationStatistics(String userId, String key); - - /** - * 鏌ヨ璁惧涓婃湀OEE - */ - List<MdcOverallEquipmentEfficiency> getEquipmentOEEMonthStatistics(String userId, String key); - - /** - * 宸ユ绾ц澶囨晥鐜� - */ - MdcHomeEfficiencyVo getEquipmentEfficiencyStatistics(String userId, String key); - - /** - * 璁惧绾ф晥鐜囩粺璁� - */ - MdcHomeEfficiencyVo getEquipmentLevelEfficiencyStatistics(String equipmentId); - - /** - * 璁惧绾ф暣骞村害鍒╃敤鐜囧拰OEE - */ - Map<String, Object> getEquipmentAnnualEfficiencyStatistics(String equipmentId); - - /** - * 鏍规嵁杞﹂棿id鑾峰彇璁惧鍒楄〃 - */ - List<MdcEquipment> getEquipmentList(String key); - - /** - * 鏌ヨ璁惧杩愯淇℃伅 - */ - MdcEquipmentDto getEquipmentDetails(String equipmentId); - - List<MdcFeedback> getFeedbackList(String key); -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcProductionService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcProductionService.java deleted file mode 100644 index c89ed56..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcProductionService.java +++ /dev/null @@ -1,195 +0,0 @@ -package org.jeecg.modules.mdc.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.model.MdcProductionTreeModel; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.vo.MdcProOptionsVo; - -import java.util.List; -import java.util.Map; - -/** - * @Description: 浜х嚎琛� - * @Author: liuS - * @Date: 2023-03-23 - * @Version: V1.0 - */ -public interface IMdcProductionService extends IService<MdcProduction> { - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<MdcProductionTreeModel> queryTreeList(); - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず(娣诲姞绯荤粺閰嶇疆) - */ - List<MdcProductionTreeModel> queryTreeListByConfig(); - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<MdcProductionTreeModel> queryTreeList(String ids); - - /** - * 鏌ヨ鎵�鏈夐儴闂―epartId淇℃伅,骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<ProductionIdModel> queryProductionIdTreeList(); - - /** - * 鏍规嵁鍏抽敭瀛楁悳绱㈢浉鍏崇殑浜х嚎鏁版嵁 - */ - List<MdcProductionTreeModel> searchByKeyWord(String keyWord); - - /** - * 淇濆瓨浜х嚎鏁版嵁 - */ - void saveProductionData(MdcProduction mdcProduction); - - /** - * 鏇存柊浜х嚎鏁版嵁 - */ - boolean updateProductionDataById(MdcProduction mdcProduction); - - /** - * 鏍规嵁浜х嚎id鍒犻櫎骞跺垹闄ゅ叾鍙兘瀛樺湪鐨勫瓙绾т骇绾� - */ - boolean delete(String id); - - /** - * 鏍规嵁浜х嚎id鎵归噺鍒犻櫎骞跺垹闄ゅ叾鍙兘瀛樺湪鐨勫瓙绾т骇绾� - */ - void deleteBatchWithChildren(List<String> ids); - - /** - * 鑾峰彇涓嬬骇浜х嚎 - */ - List<MdcProduction> queryProdByPid(String pid); - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - */ - List<MdcProduction> recursionChildrenByPid(String pid); - - /** - * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎涓嬫媺鏍戦�夐」 - */ - List<ProductionIdModel> loadProductionTreeOptions(String userId); - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - */ - List<String> recursionChildren(String productionId); - - /** - * 鏍规嵁鐢ㄦ埛id鍜岃溅闂磇d鑾峰彇鐢ㄦ埛鎷ユ湁鐨勮溅闂磇d - * - * @param userId - * @param productionId - * @return - */ - String findFirstProduction(String userId, String productionId); - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛宸ユ鏉冮檺 - */ - String findThreeProductionId(String userId); - - /** - * 鏌ヨ鎵�鏈夌埗鑺傜偣鍜屾湰鑺傜偣鍚嶇О - * @param id - * @return - */ - List<String> findListParentTreeAll(String id); - - /** - * 鏌ヨ鎵�鏈夌埗鑺傜偣鍚嶇О - * @param parentId - * @param stringList - * @return - */ - List<String> findListParentTree(String parentId,List<String> stringList); - - /** - * 鑾峰彇鐢ㄦ埛鎵�鍦ㄧ殑閮ㄩ棬 - * @param userId - * @return - */ - Map<String, MdcProduction> getUserAssignedDepart(String userId); - - /** - * 閫氳繃涓�缁刬d鑾峰彇閮ㄩ棬 - * @param ids - * @return - */ - List<String> findAllProductionIds(List<String> ids); - - /** - * 鑾峰彇鏌愪釜鑺傜偣鎵�鏈変笂绾ц妭鐐圭殑id - * @param parentId 鐖惰妭鐐� id - * @param idList 鎺ユ敹缁撴灉闆� - * @return - */ - List<String> findParentIdsForProduction(String parentId, List<String> idList); - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<MdcProductionTreeModel> queryTreeListByMdc(String ids); - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず - */ - List<MdcProductionTreeModel> queryTreeListByMdc(); - - /** - * 鏌ヨ瀛愯妭鐐� - * @param mdcProductionIds - * @return - */ - List<String> findChildren(List<String> mdcProductionIds); - - /** - * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」 - * @param userId - * @param productionId - * @return - */ - List<MdcProOptionsVo> loadProductionOptions(String userId, String productionId); - - List<MdcProduction> findMdcPros(String userId, String productionId); - - /** - * - * @param userId - * @param productionId - * @return - */ - List<MdcProOptionsVo> loadTeamOptions(String userId, String productionId); - - /** - * - * @param userId - * @param allProductionIds - * @return - */ - List<String> findProIdsByUId(String userId, List<String> allProductionIds); - - /** - * - * @param productionId - * @return - */ - List<String> findChildByProId(String productionId); - - - String findProName(String equipmentId); - - /** - * 鏍规嵁浜х嚎orgCode鏌ヨ浜х嚎 - * @param orgCode - * @return - */ - MdcProduction findByOrgCode(String orgCode); -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/IMdcUserProductionService.java b/src/main/java/org/jeecg/modules/mdc/service/IMdcUserProductionService.java deleted file mode 100644 index 1d08264..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/IMdcUserProductionService.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.jeecg.modules.mdc.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.system.entity.SysUser; - -import java.util.List; - -/** - * @Description: 鐢ㄦ埛浜х嚎琛� - * @author: LiuS - * @create: 2023-03-27 11:56 - */ -public interface IMdcUserProductionService extends IService<MdcUserProduction> { - - /** - * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎淇℃伅 - */ - List<ProductionIdModel> queryProductionIdsOfUser(String userId); - - /** - * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 - */ - List<String> queryProductionIdsByUserId(String userId); - - /** - * 鏍规嵁涓�缁勮溅闂磇d鏌ヨ鐢ㄦ埛浜х嚎淇℃伅 - * @param productionIds - */ - List<MdcUserProduction> queryByProductionIds(List<String> productionIds); - - /** - * 鍒犻櫎涓�缁勫璞� - * @param mdcUserProductions - * @return - */ - boolean removeByCollection(List<MdcUserProduction> mdcUserProductions); - - /** - * 鑾峰彇宸插垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - List<SysUser> getUserPermsByGroupId(String proId); - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - List<SysUser> getUserNonPermsByGroupId(String proId); - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛 - * @param proId - * @return - */ - List<SysUser> getUserNonPermsByDeviceId(String proId); - - /** - * 鑾峰彇宸插垎閰嶇殑鐢ㄦ埛 - * @param proId - * @return - */ - List<SysUser> getUserPermsByDeviceId(String proId); - - /** - * 閫氳繃杞﹂棿id涓庡矖浣峣d绛涢�夌敤鎴� - * @param post - * @param proId - * @return - */ - List<SysUser> queryByPostAndProId(String post, String proId); - - - MdcUserProduction getByUserIdAndGroupId(String userId, String proId); -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java b/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java index 8d05858..c0a7294 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java +++ b/src/main/java/org/jeecg/modules/mdc/service/MdcEfficiencyReportService.java @@ -105,11 +105,11 @@ */ List<BigDecimal> getEfficiencyRate(String equipmentId, String date); - Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo); - - Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo); - - Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo); - - Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo); +// Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo); +// +// Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo); +// +// Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo); +// +// Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo); } diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java deleted file mode 100644 index eec242f..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java +++ /dev/null @@ -1,506 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import org.jeecg.common.system.vo.DictModel; -import org.jeecg.modules.mdc.constant.MdcConstant; -import org.jeecg.modules.mdc.dto.MdcEquipmentDto; -import org.jeecg.modules.mdc.entity.*; -import org.jeecg.modules.mdc.mapper.MdcHomeMapper; -import org.jeecg.modules.mdc.service.*; -import org.jeecg.modules.mdc.util.DateUtils; -import org.jeecg.modules.mdc.vo.*; -import org.jeecg.modules.system.service.ISysDictService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.time.LocalDate; -import java.util.*; - -/** - * @author Lius - * @date 2024/3/14 9:52 - */ -@Service -public class IMdcHomeServiceImpl implements IMdcHomeService { - - @Resource - private IMdcEquipmentService mdcEquipmentService; - - @Resource - private IEquipmentService equipmentService; - - @Resource - private ISysDictService sysDictService; - - @Resource - private IEquipmentWorkLineService equipmentWorkLineService; - - @Resource - private MdcHomeMapper mdcHomeMapper; - - @Resource - private IMdcProductionService mdcProductionService; - - @Resource - private IEquipmentLogService equipmentLogService; - - @Resource - private IMdcFeedbackService mdcFeedbackService; - - /** - * 璁惧杩愯鐘舵�佺粺璁� - */ - @Override - public List<MdcCommonVo> getEquipmentStatusStatistics(String userId, String key) { - List<MdcCommonVo> result = new ArrayList<>(); - MdcCommonVo mdcCommonVo1 = new MdcCommonVo(); - mdcCommonVo1.setName("鍏虫満"); - mdcCommonVo1.setValue("0"); - result.add(mdcCommonVo1); - MdcCommonVo mdcCommonVo2 = new MdcCommonVo(); - mdcCommonVo2.setName("鎶ヨ"); - mdcCommonVo2.setValue("0"); - result.add(mdcCommonVo2); - MdcCommonVo mdcCommonVo3 = new MdcCommonVo(); - mdcCommonVo3.setName("寰呮満"); - mdcCommonVo3.setValue("0"); - result.add(mdcCommonVo3); - MdcCommonVo mdcCommonVo4 = new MdcCommonVo(); - mdcCommonVo4.setName("杩愯"); - mdcCommonVo4.setValue("0"); - result.add(mdcCommonVo4); - MdcEquipmentStatusVo mdcEquipmentStatusVo = new MdcEquipmentStatusVo(); - if (StringUtils.isBlank(key)) { - return result; - } - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - if (equipmentIdList == null || equipmentIdList.isEmpty()) { - return result; - } -// List<EquipmentLog> logList = equipmentLogService.getEquipmentStatusList(equipmentIdList); - List<Equipment> equipmentList = equipmentService.list(new LambdaQueryWrapper<Equipment>().in(Equipment::getEquipmentid, equipmentIdList)); - if (equipmentList != null && !equipmentList.isEmpty()) { - for (Equipment equipment : equipmentList) { - if (equipment.getOporation() != null) { - switch (equipment.getOporation()) { - case 1: - case 2: - mdcEquipmentStatusVo.setWaitCount(mdcEquipmentStatusVo.getWaitCount() + 1); - break; - case 3: - mdcEquipmentStatusVo.setRunCount(mdcEquipmentStatusVo.getRunCount() + 1); - break; - case 22: - mdcEquipmentStatusVo.setAlarmCount(mdcEquipmentStatusVo.getAlarmCount() + 1); - break; - default: - mdcEquipmentStatusVo.setCloseCount(mdcEquipmentStatusVo.getCloseCount() + 1); - break; - } - } else { - mdcEquipmentStatusVo.setCloseCount(mdcEquipmentStatusVo.getCloseCount() + 1); - } - } - } - result.clear(); - MdcCommonVo mdcCommonVo5 = new MdcCommonVo(); - mdcCommonVo5.setName("鍏虫満"); - mdcCommonVo5.setValue(mdcEquipmentStatusVo.getCloseCount().toString()); - result.add(mdcCommonVo5); - MdcCommonVo mdcCommonVo6 = new MdcCommonVo(); - mdcCommonVo6.setName("鎶ヨ"); - mdcCommonVo6.setValue(mdcEquipmentStatusVo.getAlarmCount().toString()); - result.add(mdcCommonVo6); - MdcCommonVo mdcCommonVo7 = new MdcCommonVo(); - mdcCommonVo7.setName("寰呮満"); - mdcCommonVo7.setValue(mdcEquipmentStatusVo.getWaitCount().toString()); - result.add(mdcCommonVo7); - MdcCommonVo mdcCommonVo8 = new MdcCommonVo(); - mdcCommonVo8.setName("杩愯"); - mdcCommonVo8.setValue(mdcEquipmentStatusVo.getRunCount().toString()); - result.add(mdcCommonVo8); - return result; - } - - /** - * 璁惧鍒╃敤鐜囩粺璁� - */ - @Override - public List<MdcCommonVo> getEquipmentUtilizationStatistics(String userId, String key) { - List<MdcCommonVo> result = new ArrayList<>(); - //鑾峰彇鍏徃鎴栧巶鍖轰簩绾т俊鎭� - List<MdcProduction> mdcProductionList = mdcHomeMapper.getProductionByPid(userId, key); - if (mdcProductionList != null && !mdcProductionList.isEmpty()) { - for (MdcProduction mdcProduction : mdcProductionList) { - MdcCommonVo mdcCommonVo = new MdcCommonVo(); - mdcCommonVo.setName(mdcProduction.getProductionName()); - mdcCommonVo.setProductionCode(mdcProduction.getProductionCode()); - mdcCommonVo.setProductionId(mdcProduction.getId()); - //鑾峰彇姝ゅ眰绾т笅璁惧 - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcProduction.getId()); - if (equipmentIdList == null || equipmentIdList.isEmpty()) { - mdcCommonVo.setValue("0"); - } else { - String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - BigDecimal processCount = mdcHomeMapper.getProcessCount(equipmentIdList, date); - if (processCount == null || processCount.compareTo(BigDecimal.ZERO) == 0) { - mdcCommonVo.setValue("0"); - } else { - mdcCommonVo.setValue(processCount.divide(new BigDecimal("86400").multiply(new BigDecimal(equipmentIdList.size())), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString()); - } - } - result.add(mdcCommonVo); - } - } - if (!result.isEmpty()) { - result.sort(Comparator.comparing(MdcCommonVo::getValue).reversed()); - } - return result; - } - - /** - * 璁惧OEE缁熻 - */ - @Override - public List<MdcCommonVo> getEquipmentOeeStatistics(String userId, String key) { - List<MdcCommonVo> result = new ArrayList<>(); - //鑾峰彇鍏徃鎴栧巶鍖轰簩绾т俊鎭� - List<MdcProduction> mdcProductionList = mdcHomeMapper.getProductionByPid(userId, key); - if (mdcProductionList != null && !mdcProductionList.isEmpty()) { - for (MdcProduction mdcProduction : mdcProductionList) { - MdcCommonVo mdcCommonVo = new MdcCommonVo(); - mdcCommonVo.setName(mdcProduction.getProductionName()); - mdcCommonVo.setProductionCode(mdcProduction.getProductionCode()); - mdcCommonVo.setProductionId(mdcProduction.getId()); - //鑾峰彇姝ゅ眰绾т笅璁惧 - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcProduction.getId()); - if (equipmentIdList == null || equipmentIdList.isEmpty()) { - mdcCommonVo.setValue("0"); - } else { - String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); - BigDecimal oee = mdcHomeMapper.getOeeByDate(equipmentIdList, date); - if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { - mdcCommonVo.setValue("0"); - } else { - mdcCommonVo.setValue(oee.divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString()); - } - } - result.add(mdcCommonVo); - } - } - return result; - } - - /** - * 璁惧OEE鍜屽埄鐢ㄧ巼缁熻鏌辩姸鍥� - */ - @Override - public Map<String, Object> getEquipmentMonthStatistics(String userId, String key) { - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - Map<String, Object> result = new HashMap<>(); - Date end = DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE); - Date start = DateUtils.toDate(LocalDate.now().plusMonths(-12).toString(), DateUtils.STR_DATE); - List<String> monthBetween = DateUtils.getMonthBetween(start, end); - List<String> dateList = new ArrayList<>(); - List<MdcCommonVo> utilizationList = new ArrayList<>(); - List<MdcCommonVo> oeeList = new ArrayList<>(); - for (String month : monthBetween) { - //鏃ユ湡闆嗗悎 - String name = month.substring(month.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - dateList.add(name); - //鍒╃敤鐜囧拰oee - MdcCommonVo mdcCommonUtilizationVo = new MdcCommonVo(); - mdcCommonUtilizationVo.setName(name); - MdcCommonVo mdcCommonOeeVo = new MdcCommonVo(); - mdcCommonOeeVo.setName(name); - if (equipmentIdList == null || equipmentIdList.isEmpty()) { - mdcCommonUtilizationVo.setValue("0"); - mdcCommonOeeVo.setValue("0"); - } else { - //鍒╃敤鐜� - Map<String, Object> resultMap = mdcHomeMapper.getUtilizationByMonth(equipmentIdList, month.replace("-", "")); - if (resultMap != null && resultMap.get("processLong") != null) { - BigDecimal processLong = BigDecimal.valueOf((Double) resultMap.get("processLong")); - BigDecimal processDay = new BigDecimal((Integer) resultMap.get("processDay")); - if (processLong.compareTo(BigDecimal.ZERO) == 0) { - mdcCommonUtilizationVo.setValue("0"); - } else { - mdcCommonUtilizationVo.setValue(processLong.divide(processDay.multiply(new BigDecimal("86400")), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString()); - } - } else { - mdcCommonUtilizationVo.setValue("0"); - } - - //OEE - BigDecimal oee = mdcHomeMapper.getOeeByDate(equipmentIdList, month); - if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { - mdcCommonOeeVo.setValue("0"); - } else { - mdcCommonOeeVo.setValue(oee.divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString()); - } - } - utilizationList.add(mdcCommonUtilizationVo); - oeeList.add(mdcCommonOeeVo); - } - result.put("dateList", dateList); - result.put("utilizationList", utilizationList); - result.put("oeeList", oeeList); - return result; - } - - /** - * 宸ユ绾у墠涓冨ぉ鍒╃敤鐜囨姌绾垮浘 - */ - @Override - public Map<String, Object> getEquipmentDayUtilizationStatistics(String userId, String key) { - Map<String, Object> result = new HashMap<>(); - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - //鑾峰彇鍓嶄竷澶╂棩鏈熼泦鍚� - String start = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-7).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - String end = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - List<MdcEquipment> mdcEquipmentList = mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getEquipmentId, equipmentIdList)); - result.put("mdcEquipmentList", mdcEquipmentList); - List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfoList = mdcHomeMapper.getEquipmentSevenUtilizationStatistics(equipmentIdList, start, end); - List<EquipmentDayUtilizationVo> dataList = new ArrayList<>(); - if (mdcEquipmentStatisticalInfoList != null && !mdcEquipmentStatisticalInfoList.isEmpty()) { - for (MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo : mdcEquipmentStatisticalInfoList) { - EquipmentDayUtilizationVo equipmentDayUtilizationVo = new EquipmentDayUtilizationVo(); - equipmentDayUtilizationVo.setEquipmentId(mdcEquipmentStatisticalInfo.getEquipmentId()); - equipmentDayUtilizationVo.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(mdcEquipmentStatisticalInfoList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { - equipmentDayUtilizationVo.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - equipmentDayUtilizationVo.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(mdcEquipmentStatisticalInfoList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - } - dataList.add(equipmentDayUtilizationVo); - } - } - result.put("dataList", dataList); - } - /*List<String> dayBetween = DateUtils.getDatesStringList2(start, end); - List<String> dateList = new ArrayList<>(); - List<EquipmentDayUtilizationVo> dataList = new ArrayList<>(); - for (String date : dayBetween) { - EquipmentDayUtilizationVo equipmentDayUtilizationVo = new EquipmentDayUtilizationVo(); - String item = date.substring(4); - if (item.startsWith("0")) { - item = item.substring(1); - String sub = item.substring(1); - if (sub.startsWith("0")) { - item = item.substring(0, 1) + "鏈�" + sub.substring(1) + "鏃�"; - } else { - item = item.substring(0, 1) + "鏈�" + item.substring(1) + "鏃�"; - } - } else { - String sub = item.substring(2); - if (sub.startsWith("0")) { - item = item.substring(0, 2) + "鏈�" + sub.substring(2) + "鏃�"; - } else { - item = item.substring(0, 2) + "鏈�" + item.substring(2) + "鏃�"; - } - } - dateList.add(item); - equipmentDayUtilizationVo.setDate(item); - if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - //鑾峰彇鍓嶄竷澶╁埄鐢ㄧ巼鏁版嵁 - List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfos = mdcHomeMapper.getEquipmentDayUtilizationStatistics(equipmentIdList, dayBetween); - if (mdcEquipmentStatisticalInfos != null && !mdcEquipmentStatisticalInfos.isEmpty()) { - for (MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo : mdcEquipmentStatisticalInfos) { - if (mdcEquipmentStatisticalInfo.getTheDate().equals(date)) { - equipmentDayUtilizationVo.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { - equipmentDayUtilizationVo.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - equipmentDayUtilizationVo.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - } - } - } - } else { - dataList.add(equipmentDayUtilizationVo); - } - } else { - dataList.add(equipmentDayUtilizationVo); - } - } - result.put("dateList", dateList); - result.put("dataList", dataList);*/ - return result; - } - - /** - * 鏌ヨ璁惧涓婃湀OEE - */ - @Override - public List<MdcOverallEquipmentEfficiency> getEquipmentOEEMonthStatistics(String userId, String key) { - List<MdcOverallEquipmentEfficiency> result = new ArrayList<>(); - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - String validDate = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); - result = mdcHomeMapper.getEquipmentOEEMonthStatistics(validDate, equipmentIdList); - } - return result; - } - - /** - * 宸ユ绾ц澶囨晥鐜� - */ - @Override - public MdcHomeEfficiencyVo getEquipmentEfficiencyStatistics(String userId, String key) { - MdcHomeEfficiencyVo result = new MdcHomeEfficiencyVo(); - result.setProductionId(key); - MdcProduction mdcProduction = mdcProductionService.getById(key); - result.setProductionName(mdcProduction.getProductionName()); - List<String> equipmentIdList = mdcEquipmentService.getEquipmentIdsProduction(userId, key); - if (equipmentIdList != null && !equipmentIdList.isEmpty()) { - // 鑾峰彇鍒╃敤鐜囨暟鎹� - String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcHomeMapper.getUtilizationByDay(equipmentIdList, date); - if (mdcEquipmentStatisticalInfo != null) { - result.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { - result.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - result.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - } - } - //鑾峰彇OEE鏁版嵁 - String month = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); - BigDecimal oee = mdcHomeMapper.getOeeByDate(equipmentIdList, month); - if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { - result.setOverallEquipmentEfficiency(BigDecimal.ZERO); - } else { - result.setOverallEquipmentEfficiency(oee.divide(new BigDecimal(equipmentIdList.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - } - } - return result; - } - - /** - * 璁惧绾ф晥鐜囩粺璁� - */ - @Override - public MdcHomeEfficiencyVo getEquipmentLevelEfficiencyStatistics(String equipmentId) { - MdcEquipment mdcEquipment = mdcEquipmentService.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, equipmentId)); - if (mdcEquipment == null) { - return null; - } - MdcHomeEfficiencyVo result = new MdcHomeEfficiencyVo(); - String date = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE); - MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcHomeMapper.getUtilizationByDay(Arrays.asList(equipmentId.split(",")), date); - if (mdcEquipmentStatisticalInfo != null) { - result.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) { - result.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - result.setStartRate(mdcEquipmentStatisticalInfo.getOpenLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - } - } - //鑾峰彇OEE鏁版嵁 - String month = DateUtils.format(DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE), DateUtils.STR_YEAR_MONTH); - BigDecimal oee = mdcHomeMapper.getOeeByDate(Arrays.asList(equipmentId.split(",")), month); - if (oee == null || oee.compareTo(BigDecimal.ZERO) == 0) { - result.setOverallEquipmentEfficiency(BigDecimal.ZERO); - } else { - result.setOverallEquipmentEfficiency(oee.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - } - return result; - } - - /** - * 璁惧绾ф暣骞村害鍒╃敤鐜� - */ - @Override - public Map<String, Object> getEquipmentAnnualEfficiencyStatistics(String equipmentId) { - MdcEquipment mdcEquipment = mdcEquipmentService.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, equipmentId)); - if (mdcEquipment == null) { - return null; - } - Map<String, Object> result = new HashMap<>(); - Date end = DateUtils.toDate(LocalDate.now().plusMonths(-1).toString(), DateUtils.STR_DATE); - Date start = DateUtils.toDate(LocalDate.now().plusMonths(-12).toString(), DateUtils.STR_DATE); - List<String> monthBetween = DateUtils.getMonthBetween(start, end); - List<String> dateList = new ArrayList<>(); - List<MdcHomeEquipmentVo> dataList = new ArrayList<>(); - for (String month : monthBetween) { - String name = month.substring(month.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - dateList.add(name); - //鍒╃敤鐜囧拰oee - MdcHomeEquipmentVo mdcHomeEquipmentVo = new MdcHomeEquipmentVo(); - mdcHomeEquipmentVo.setMonth(name); - //鍒╃敤鐜� - Map<String, Object> resultMap = mdcHomeMapper.getUtilizationByMonth(Arrays.asList(equipmentId.split(",")), month.replace("-", "")); - if (resultMap != null && resultMap.get("processLong") != null) { - BigDecimal processLong = BigDecimal.valueOf((Double) resultMap.get("processLong")); - BigDecimal openLong = BigDecimal.valueOf((Double) resultMap.get("openLong")); - BigDecimal processDay = new BigDecimal((Integer) resultMap.get("processDay")); - if (BigDecimal.ZERO.compareTo(processLong) == -1) { - mdcHomeEquipmentVo.setUtilizationRate(processLong.divide(processDay.multiply(new BigDecimal("86400")), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - if (BigDecimal.ZERO.compareTo(openLong) == -1) { - mdcHomeEquipmentVo.setStartRate(openLong.divide(new BigDecimal("86400"), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP)); - mdcHomeEquipmentVo.setOpenRate(processDay.divide(openLong, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - } - } - } - - //OEE - BigDecimal oee = mdcHomeMapper.getOeeByDate(Arrays.asList(equipmentId.split(",")), month); - if (oee != null && !(oee.compareTo(BigDecimal.ZERO) == 0)) { - mdcHomeEquipmentVo.setOverallEquipmentEfficiency(oee.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP)); - } - dataList.add(mdcHomeEquipmentVo); - } - result.put("dateList", dateList); - result.put("dataList", dataList); - return result; - } - - /** - * 璁惧绾ц澶囧垪琛� - */ - @Override - public List<MdcEquipment> getEquipmentList(String key) { - return mdcHomeMapper.getEquipmentList(key); - } - - @Override - public MdcEquipmentDto getEquipmentDetails(String equipmentId) { - MdcEquipment mdcEquipment = mdcEquipmentService.getOne(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, equipmentId)); - List<DictModel> dictModelList = sysDictService.queryEnableDictItemsByCode(MdcConstant.SERIA_TYPE); - if (dictModelList != null && !dictModelList.isEmpty()) { - for (DictModel dictModel : dictModelList) { - if (dictModel.getValue().equals(mdcEquipment.getDriveType())) { - return null; - } - } - } - String saveTableName = mdcEquipment.getSaveTableName(); - MdcEquipmentDto dto = equipmentWorkLineService.getMacingDataList(saveTableName); - if (dto != null) { - if ("LSV2".equals(mdcEquipment.getDriveType())) { - dto.setSpindlebeilv(dto.getSFeed()); - dto.setFeedbeilv(dto.getFFeed()); - dto.setRapidfeed(dto.getRapidfeed()); - dto.setNCVersion(dto.getNCVersion()); - dto.setTNCVersion(dto.getTNCVersion()); - dto.setOPTVersion(dto.getOPTVersion()); - dto.setPLCVersion(dto.getPLCVersion()); - } - // 鏌ヨ璁惧鐘舵�� - EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipment.getEquipmentId()); - Integer oporation = equipmentLog.getOporation(); - if (oporation == 22) { - dto.setALRMstate(equipmentLog.getAlarm()); - } else { - dto.setALRMstate("鏃�"); - } - } else { - return null; - } - return dto; - } - - @Override - public List<MdcFeedback> getFeedbackList(String key) { - return mdcFeedbackService.getFeedbackList(key); - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java index 2a15529..5faa6b6 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java @@ -1,10 +1,13 @@ package org.jeecg.modules.mdc.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import liquibase.pro.packaged.I; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.DictModel; +import org.jeecg.modules.base.entity.Factory; +import org.jeecg.modules.base.service.IFactoryService; import org.jeecg.modules.mdc.dto.*; import org.jeecg.modules.mdc.entity.*; import org.jeecg.modules.mdc.mapper.MdcEfficiencyReportMapper; @@ -46,7 +49,10 @@ private ISysDepartService sysDepartService; @Resource - private IMdcProductionService mdcProductionService; + private IFactoryService factoryService; + +// @Resource +// private IMdcProductionService mdcProductionService; @Resource private IMdcShiftSubService mdcShiftSubService; @@ -192,12 +198,12 @@ mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); mdcEfficiencyResultDto1.setCloseLong(mdcEfficiencyResultDto.getCloseLong()); mdcEfficiencyResultDto.setCloseLong(mdcEfficiencyResultDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong()); - mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate()); - mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong()); - mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong()); +// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate()); +// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong()); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); long rate = mdcEfficiencyResultDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -214,7 +220,7 @@ // 浜х嚎灞傜骇 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); // 鏌ヨ鎵�鏈変骇绾夸俊鎭� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter)); for (MdcEquProDto mdcEquProDto : equipmentList) { MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto(); @@ -233,31 +239,31 @@ break; default: } - MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); - if (mdcProduction != null) { - switch (mdcProduction.getOrgType()) { + Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); + if (baseFactory != null) { + switch (baseFactory.getFactoryCategory()) { case "1": - mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel1(baseFactory.getFactoryName()); break; case "2": - mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel2(baseFactory.getFactoryName()); break; case "3": - mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel3(baseFactory.getFactoryName()); break; default: } - if (StringUtils.isNotEmpty(mdcProduction.getParentId())) { - productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> { - switch (production1.getOrgType()) { + if (StringUtils.isNotEmpty(baseFactory.getParentId())) { + factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> { + switch (factory1.getFactoryCategory()) { case "1": - mdcEfficiencyListDto.setLevel1(production1.getProductionName()); + mdcEfficiencyListDto.setLevel1(factory1.getFactoryName()); break; case "2": - mdcEfficiencyListDto.setLevel2(production1.getProductionName()); + mdcEfficiencyListDto.setLevel2(factory1.getFactoryName()); break; case "3": - mdcEfficiencyListDto.setLevel3(production1.getProductionName()); + mdcEfficiencyListDto.setLevel3(factory1.getFactoryName()); break; default: } @@ -286,12 +292,12 @@ mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); mdcEfficiencyResultDto1.setCloseLong(mdcEfficiencyResultDto.getCloseLong()); mdcEfficiencyResultDto.setCloseLong(mdcEfficiencyResultDto.getCloseLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong()); - mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate()); - mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong()); - mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setFaultLong(mdcEfficiencyResultDto.getFaultLong()); +// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setFaultRate(mdcEfficiencyResultDto.getFaultRate()); +// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(dates.size()), 4, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto1.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong()); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(dates.size()), 0, RoundingMode.HALF_UP)); long rate = mdcEfficiencyResultDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -357,10 +363,7 @@ a.getOpenRate().add(b.getOpenRate()), a.getOpenLong().add(b.getOpenLong()), a.getWaitLong().add(b.getWaitLong()), - a.getCloseLong().add(b.getCloseLong()), - a.getFaultLong().add(b.getFaultLong()), - a.getFaultRate().add(b.getFaultRate()), - a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add); + a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add); }); for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) { mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); @@ -403,10 +406,7 @@ a.getOpenRate().add(b.getOpenRate()), a.getOpenLong().add(b.getOpenLong()), a.getWaitLong().add(b.getWaitLong()), - a.getCloseLong().add(b.getCloseLong()), - a.getFaultLong().add(b.getFaultLong()), - a.getFaultRate().add(b.getFaultRate()), - a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add); + a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add); }); for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) { mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); @@ -574,7 +574,7 @@ // 浜х嚎灞傜骇 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); // 鏌ヨ鎵�鏈変骇绾夸俊鎭� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter)); for (MdcEquProDto mdcEquProDto : equipmentList) { MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto(); @@ -593,31 +593,31 @@ break; default: } - MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); - if (mdcProduction != null) { - switch (mdcProduction.getOrgType()) { + Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); + if (baseFactory != null) { + switch (baseFactory.getFactoryCategory()) { case "1": - mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel1(baseFactory.getFactoryName()); break; case "2": - mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel2(baseFactory.getFactoryName()); break; case "3": - mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName()); + mdcEfficiencyListDto.setLevel3(baseFactory.getFactoryName()); break; default: } - if (StringUtils.isNotEmpty(mdcProduction.getParentId())) { - productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> { - switch (production1.getOrgType()) { + if (StringUtils.isNotEmpty(baseFactory.getParentId())) { + factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> { + switch (factory1.getFactoryCategory()) { case "1": - mdcEfficiencyListDto.setLevel1(production1.getProductionName()); + mdcEfficiencyListDto.setLevel1(factory1.getFactoryName()); break; case "2": - mdcEfficiencyListDto.setLevel2(production1.getProductionName()); + mdcEfficiencyListDto.setLevel2(factory1.getFactoryName()); break; case "3": - mdcEfficiencyListDto.setLevel3(production1.getProductionName()); + mdcEfficiencyListDto.setLevel3(factory1.getFactoryName()); break; default: } @@ -710,10 +710,7 @@ a.getOpenRate().add(b.getOpenRate()), a.getOpenLong().add(b.getOpenLong()), a.getWaitLong().add(b.getWaitLong()), - a.getCloseLong().add(b.getCloseLong()), - a.getFaultLong().add(b.getFaultLong()), - a.getFaultRate().add(b.getFaultRate()), - a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add); + a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add); }); for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) { mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); @@ -723,9 +720,9 @@ mdcEfficiencyResultDto.setWaitLong(mdcEfficiencyResultDto.getWaitLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); mdcEfficiencyResultDto.setOpenLong(mdcEfficiencyResultDto.getOpenLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); mdcEfficiencyResultDto.setProcessLong(mdcEfficiencyResultDto.getProcessLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto.setFaultLong(mdcEfficiencyResultDto.getFaultLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(mdcEfficiencyResultDto.getRemoveFaultRunLong().divide(new BigDecimal(mdcEfficiencyList.size()), 0, RoundingMode.HALF_UP)); long rate = mdcEfficiencyResultDto.getStartRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -760,16 +757,13 @@ a.getOpenRate().add(b.getOpenRate()), a.getOpenLong().add(b.getOpenLong()), a.getWaitLong().add(b.getWaitLong()), - a.getCloseLong().add(b.getCloseLong()), - a.getFaultLong().add(b.getFaultLong()), - a.getFaultRate().add(b.getFaultRate()), - a.getRemoveFaultRunLong().add(b.getRemoveFaultRunLong()))).ifPresent(result::add); + a.getCloseLong().add(b.getCloseLong()))).ifPresent(result::add); }); for (MdcEfficiencyResultDto mdcEfficiencyResultDto : result) { mdcEfficiencyResultDto.setUtilizationRate(mdcEfficiencyResultDto.getUtilizationRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); mdcEfficiencyResultDto.setOpenRate(mdcEfficiencyResultDto.getOpenRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); mdcEfficiencyResultDto.setStartRate(mdcEfficiencyResultDto.getStartRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); - mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); +// mdcEfficiencyResultDto.setFaultRate(mdcEfficiencyResultDto.getFaultRate().divide(new BigDecimal(mdcEfficiencyList.size()), 4, RoundingMode.HALF_UP)); long rate = mdcEfficiencyResultDto.getStartRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -955,7 +949,7 @@ // 浜х嚎灞傜骇 List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList()); // 鏌ヨ鎵�鏈変骇绾夸俊鎭� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().ne(Factory::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(Factory::getSorter)); // 鐝鍚嶇О鏄剧ず澶勭悊 String shiftSubName = ""; @@ -996,31 +990,31 @@ break; default: } - MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); - if (mdcProduction != null) { - switch (mdcProduction.getOrgType()) { + Factory baseFactory = factoryList.stream().filter(factory -> factory.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null); + if (baseFactory != null) { + switch (baseFactory.getFactoryCategory()) { case "1": - mdcEfficiencyShiftListDto.setLevel1(mdcProduction.getProductionName()); + mdcEfficiencyShiftListDto.setLevel1(baseFactory.getFactoryName()); break; case "2": - mdcEfficiencyShiftListDto.setLevel2(mdcProduction.getProductionName()); + mdcEfficiencyShiftListDto.setLevel2(baseFactory.getFactoryName()); break; case "3": - mdcEfficiencyShiftListDto.setLevel3(mdcProduction.getProductionName()); + mdcEfficiencyShiftListDto.setLevel3(baseFactory.getFactoryName()); break; default: } - if (StringUtils.isNotEmpty(mdcProduction.getParentId())) { - productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> { - switch (production1.getOrgType()) { + if (StringUtils.isNotEmpty(baseFactory.getParentId())) { + factoryList.stream().filter(factory -> factory.getId().equals(baseFactory.getParentId())).findAny().ifPresent(factory1 -> { + switch (factory1.getFactoryCategory()) { case "1": - mdcEfficiencyShiftListDto.setLevel1(production1.getProductionName()); + mdcEfficiencyShiftListDto.setLevel1(factory1.getFactoryName()); break; case "2": - mdcEfficiencyShiftListDto.setLevel2(production1.getProductionName()); + mdcEfficiencyShiftListDto.setLevel2(factory1.getFactoryName()); break; case "3": - mdcEfficiencyShiftListDto.setLevel3(production1.getProductionName()); + mdcEfficiencyShiftListDto.setLevel3(factory1.getFactoryName()); break; default: } @@ -1767,316 +1761,316 @@ return mdcEfficiencyReportMapper.getEfficiencyRate(equipmentId, date); } - /** - * 鐝粍鍚勮澶囩患鍚堝埄鐢ㄧ巼 - * - * @param equEffVo - * @return - */ - @Override - public Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) { - Map<String, Object> result = new HashMap<>(); - List<String> mdcProductionIds = new ArrayList<>(); - if (StringUtils.isBlank(equEffVo.getProductionIds())) { - mdcProductionIds.add(equEffVo.getProductionId()); - } else { - mdcProductionIds.addAll(Arrays.asList(equEffVo.getProductionIds().split(","))); - } - List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); - //鏁版嵁鏉冮檺杩囨护 - allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); - List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); - if (equipmentList != null && !equipmentList.isEmpty()) { - List<String> equipmentIdList = equipmentList.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); - List<EquipmentEfficiencyAnalyzeDto> dataList = mdcEfficiencyReportMapper.equipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); - result.put("dataList", dataList); - List<String> equipmentNameList = dataList.stream().map(EquipmentEfficiencyAnalyzeDto::getEquipmentId).collect(Collectors.toList()); - result.put("equipmentNameList", equipmentNameList); - } - return result; - } - - @Override - public Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) { - Map<String, Object> result = new HashMap<>(); - // 1. 澶勭悊鐢熶骇ID - List<String> mdcProductionIds = StringUtils.isBlank(equEffVo.getProductionIds()) - ? Collections.singletonList(equEffVo.getProductionId()) - : Arrays.asList(equEffVo.getProductionIds().split(",")); - - List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); - if (allProductionIds.isEmpty()) { - return result; // 鎻愬墠杩斿洖绌虹粨鏋� - } - //鏁版嵁鏉冮檺杩囨护 - allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); - // 2. 鑾峰彇璁惧鍒楄〃 - List<MdcEquipment> equipmentList = StringUtils.isNotBlank(equEffVo.getTeamCodes()) - ? mdcEquipmentService.findByProIdsAndTeamCode(allProductionIds, Arrays.asList(equEffVo.getTeamCodes().split(","))) - : mdcEquipmentService.findByProductionIds(allProductionIds); - - if (equipmentList.isEmpty()) { - return result; - } - - // 3. 鏁版嵁澶勭悊 - List<String> equipmentIdList = equipmentList.stream() - .map(MdcEquipment::getEquipmentId) - .collect(Collectors.toList()); - - List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper - .teamEquipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); - - if (dataList.isEmpty()) { - return result; - } - - // 4. 鍒嗙粍璁$畻骞冲潎鍊� - Map<String, TeamEquEffDto> grouped = dataList.stream() - .collect(Collectors.groupingBy( - TeamEquEffDto::getTeamCode, - Collectors.collectingAndThen( - Collectors.toList(), - this::calculateAverages // 鎻愬彇璁$畻鏂规硶 - ))); - - // 5. 瀛楀吀杞崲 - Map<String, String> dictMap = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM) - .stream() - .collect(Collectors.toMap(DictModel::getValue, DictModel::getText)); - - List<TeamEquEffDto> resultList = grouped.entrySet().stream() - .map(entry -> buildResultDto(entry, dictMap))// 鎻愬彇鏋勫缓鏂规硶 - .sorted(Comparator.comparing(TeamEquEffDto::getUtilizationRate).reversed()) - .collect(Collectors.toList()); - - result.put("dataList", resultList); - result.put("teamCodeList", resultList.stream() - .map(TeamEquEffDto::getTeamCode) - .collect(Collectors.toList())); - - return result; - - } - - @Override - public Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo) { - Map<String, Object> result = new HashMap<>(); - - // 1. 鏃ユ湡澶勭悊 - LocalDate now = LocalDate.now(); - Date start = DateUtils.toDate(now.plusMonths(-6).toString(), DateUtils.STR_DATE); - Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); - - List<String> monthBetween = DateUtils.getMonthBetween(start, end); - List<String> dateList = monthBetween.stream() - .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�") - .collect(Collectors.toList()); - result.put("dateList", dateList); - - // 2. 鑾峰彇浜х嚎鏁版嵁 - List<MdcProduction> mdcProductions = mdcProductionService.findMdcPros(userId, equEffVo.getProductionId()); - - // 3. 鍒濆鍖栫粨鏋滈泦 - List<TeamEquEffMonthDto> utilizationRateList = new ArrayList<>(); - List<TeamEquEffMonthDto> shiftUtilizationRateList = new ArrayList<>(); - List<TeamEquEffMonthDto> amendUtilizationRateList = new ArrayList<>(); - - // 4. 澶勭悊姣忎釜浜х嚎 - mdcProductions.forEach(mdcProduction -> { - // 4.1 鑾峰彇涓嬬骇浜х嚎骞惰繃婊� - List<String> allProductionIds = mdcProductionService.recursionChildren(mdcProduction.getId()); - // 鏁版嵁鏉冮檺杩囨护 - allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); - // 4.2 鑾峰彇璁惧鍒楄〃 - List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); - if (equipmentList == null || equipmentList.isEmpty()) { - return; - } - //鎻愬彇id闆嗗悎 - List<String> equipmentIdList = equipmentList.stream() - .map(MdcEquipment::getEquipmentId) - .collect(Collectors.toList()); - - TeamEquEffMonthDto urDto = new TeamEquEffMonthDto(); - TeamEquEffMonthDto surDto = new TeamEquEffMonthDto(); - TeamEquEffMonthDto aurDto = new TeamEquEffMonthDto(); - urDto.setProductionName(mdcProduction.getProductionName()); - surDto.setProductionName(mdcProduction.getProductionName()); - aurDto.setProductionName(mdcProduction.getProductionName()); - List<TeamEquEffMonthChildDto> urDataList = new ArrayList<>(); - List<TeamEquEffMonthChildDto> surDataList = new ArrayList<>(); - List<TeamEquEffMonthChildDto> aurDataList = new ArrayList<>(); - - monthBetween.forEach(date -> { - TeamEquEffMonthChildDto urCDto = new TeamEquEffMonthChildDto(); - TeamEquEffMonthChildDto surCDto = new TeamEquEffMonthChildDto(); - TeamEquEffMonthChildDto aurCDto = new TeamEquEffMonthChildDto(); - String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - urCDto.setMonth(month); - surCDto.setMonth(month); - aurCDto.setMonth(month); - List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper.teamEquipmentEfficiencyAnalyze(equipmentIdList, date.replaceAll("-", "")); - if (dataList != null && !dataList.isEmpty()) { - // 璁$畻骞冲潎鍊� - BigDecimal ur = dataList.stream() - .map(TeamEquEffDto::getUtilizationRate) - .reduce(BigDecimal.ZERO, BigDecimal::add) - .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); - //鍒╃敤鐜� - urCDto.setUtilizationRate(ur); - //鐝鍒╃敤鐜� - BigDecimal sur = dataList.stream() - .map(TeamEquEffDto::getShiftUtilizationRate) - .reduce(BigDecimal.ZERO, BigDecimal::add) - .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); - surCDto.setUtilizationRate(sur); - //鍘婚櫎鏁呴殰24灏忔椂鍒╃敤鐜� - BigDecimal aur = dataList.stream() - .map(TeamEquEffDto::getAmendUtilizationRate) - .reduce(BigDecimal.ZERO, BigDecimal::add) - .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); - aurCDto.setUtilizationRate(aur); - } - urDataList.add(urCDto); - surDataList.add(surCDto); - aurDataList.add(aurCDto); - }); - urDto.setDataList(urDataList); - surDto.setDataList(surDataList); - aurDto.setDataList(aurDataList); - utilizationRateList.add(urDto); - shiftUtilizationRateList.add(surDto); - amendUtilizationRateList.add(aurDto); - }); - result.put("utilizationRateList", utilizationRateList); - result.put("shiftUtilizationRateList", shiftUtilizationRateList); - result.put("amendUtilizationRateList", amendUtilizationRateList); - return result; - } - - @Override - public Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo) { - Map<String, Object> result = new HashMap<>(); - // 1. 鏃ユ湡澶勭悊 - LocalDate now = LocalDate.now(); - Date start = DateUtils.toDate(now.plusMonths(-12).toString(), DateUtils.STR_DATE); - Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); - - List<String> monthBetween = DateUtils.getMonthBetween(start, end); - List<String> dateList = monthBetween.stream() - .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�") - .collect(Collectors.toList()); - result.put("dateList", dateList); - - // 1. 澶勭悊鐢熶骇ID - List<String> mdcProductionIds = StringUtils.isBlank(vo.getProductionIds()) - ? Collections.singletonList(vo.getProductionId()) - : Arrays.asList(vo.getProductionIds().split(",")); - - List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); - if (allProductionIds.isEmpty()) { - return result; // 鎻愬墠杩斿洖绌虹粨鏋� - } - //鏁版嵁鏉冮檺杩囨护 - allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); - // 2. 鑾峰彇璁惧鍒楄〃 - List<MdcEquipment> equipmentList = StringUtils.isNotBlank(vo.getEquipmentType()) - ? mdcEquipmentService.findByProIdsAndType(allProductionIds, Arrays.asList(vo.getEquipmentType().split(","))) - : mdcEquipmentService.findByProductionIds(allProductionIds); - - if (equipmentList.isEmpty()) { - return result; - } - - // 3. 鏁版嵁澶勭悊 - List<String> equipmentIdList = equipmentList.stream() - .map(MdcEquipment::getEquipmentId) - .collect(Collectors.toList()); - String startStr = monthBetween.get(0).replaceAll("-", ""); - String endStr = monthBetween.get(monthBetween.size() - 1).replaceAll("-", ""); - List<ComRateDto> comRateDtoList = mdcEfficiencyReportMapper.comprehensiveRateAnalyze(equipmentIdList, startStr, endStr); - if (comRateDtoList.isEmpty()) { - return result; // 鎻愬墠杩斿洖绌虹粨鏋� - } - List<ComRateDto> dataList = new ArrayList<>(); - Map<String, ComRateDto> map = comRateDtoList.stream().collect(Collectors.toMap(ComRateDto::getTheMonth, comRateDto -> comRateDto)); - monthBetween.forEach(date -> { - String d = date.replaceAll("-", ""); - String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - if (map.containsKey(d)) { - ComRateDto comRateDto = map.get(d); - comRateDto.setTheMonth(month); - comRateDto.setUtilizationRate(comRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP)); - comRateDto.setShiftUtilizationRate(comRateDto.getShiftUtilizationRate() != null ? comRateDto.getShiftUtilizationRate().setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); - comRateDto.setAmendUtilizationRate(comRateDto.getAmendUtilizationRate().setScale(2, RoundingMode.HALF_UP)); - comRateDto.setProcessLong(comRateDto.getProcessLong().divide(new BigDecimal("3600"), 2, RoundingMode.HALF_UP)); - dataList.add(comRateDto); - } else { - ComRateDto comRateDto = new ComRateDto(); - comRateDto.setTheMonth(month); - dataList.add(comRateDto); - } - }); - result.put("dataList", dataList); - - if (StringUtils.isNotBlank(vo.getShiftId())) { - List<MdcShiftSub> shiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, vo.getShiftId())); - if (shiftSubList == null || shiftSubList.isEmpty()) { - return result; - } - List<String> shiftSubNameList = shiftSubList.stream().map(MdcShiftSub::getShiftSubName).collect(Collectors.toList()); - result.put("shiftSubList", shiftSubNameList); - - List<ComShiftRateDto> comShiftRateDtoList = mdcEfficiencyReportMapper.comprehensiveShiftRateAnalyze(equipmentIdList, startStr, endStr, vo.getShiftId()); - Map<String, List<ComShiftRateDto>> groupMap; - if (comShiftRateDtoList != null && !comShiftRateDtoList.isEmpty()) { - groupMap = comShiftRateDtoList.stream().collect(Collectors.groupingBy(ComShiftRateDto::getShiftSub)); - } else { - groupMap = new HashMap<>(); - } - List<ComShiftDto> shiftDataList = new ArrayList<>(); - shiftSubList.forEach(mdcShiftSub -> { - ComShiftDto comShiftDto = new ComShiftDto(); - comShiftDto.setShiftSubName(mdcShiftSub.getShiftSubName()); - if (groupMap.containsKey(mdcShiftSub.getId())) { - List<ComShiftRateDto> csrd = groupMap.get(mdcShiftSub.getId()); - Map<String, ComShiftRateDto> collect = csrd.stream().collect(Collectors.toMap(ComShiftRateDto::getTheMonth, comShiftRateDto -> comShiftRateDto)); - List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>(); - monthBetween.forEach(date -> { - String d = date.replaceAll("-", ""); - String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - if (collect.containsKey(d)) { - ComShiftRateDto comShiftRateDto = collect.get(d); - ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); - comShiftChildDto.setMonth(month); - comShiftChildDto.setUtilizationRate(comShiftRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP)); - comShiftChildDtoList.add(comShiftChildDto); - } else { - ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); - comShiftChildDto.setMonth(month); - comShiftChildDtoList.add(comShiftChildDto); - } - }); - comShiftDto.setDataList(comShiftChildDtoList); - } else { - List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>(); - monthBetween.forEach(date -> { - String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; - ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); - comShiftChildDto.setMonth(month); - comShiftChildDtoList.add(comShiftChildDto); - }); - comShiftDto.setDataList(comShiftChildDtoList); - } - shiftDataList.add(comShiftDto); - }); - - result.put("shiftDataList", shiftDataList); - } - - return result; - } +// /** +// * 鐝粍鍚勮澶囩患鍚堝埄鐢ㄧ巼 +// * +// * @param equEffVo +// * @return +// */ +// @Override +// public Map<String, Object> equipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) { +// Map<String, Object> result = new HashMap<>(); +// List<String> mdcProductionIds = new ArrayList<>(); +// if (StringUtils.isBlank(equEffVo.getProductionIds())) { +// mdcProductionIds.add(equEffVo.getProductionId()); +// } else { +// mdcProductionIds.addAll(Arrays.asList(equEffVo.getProductionIds().split(","))); +// } +// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); +// //鏁版嵁鏉冮檺杩囨护 +// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); +// List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); +// if (equipmentList != null && !equipmentList.isEmpty()) { +// List<String> equipmentIdList = equipmentList.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); +// List<EquipmentEfficiencyAnalyzeDto> dataList = mdcEfficiencyReportMapper.equipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); +// result.put("dataList", dataList); +// List<String> equipmentNameList = dataList.stream().map(EquipmentEfficiencyAnalyzeDto::getEquipmentId).collect(Collectors.toList()); +// result.put("equipmentNameList", equipmentNameList); +// } +// return result; +// } +// +// @Override +// public Map<String, Object> teamEquipmentEfficiencyAnalyze(String userId, EquEffVo equEffVo) { +// Map<String, Object> result = new HashMap<>(); +// // 1. 澶勭悊鐢熶骇ID +// List<String> mdcProductionIds = StringUtils.isBlank(equEffVo.getProductionIds()) +// ? Collections.singletonList(equEffVo.getProductionId()) +// : Arrays.asList(equEffVo.getProductionIds().split(",")); +// +// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); +// if (allProductionIds.isEmpty()) { +// return result; // 鎻愬墠杩斿洖绌虹粨鏋� +// } +// //鏁版嵁鏉冮檺杩囨护 +// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); +// // 2. 鑾峰彇璁惧鍒楄〃 +// List<MdcEquipment> equipmentList = StringUtils.isNotBlank(equEffVo.getTeamCodes()) +// ? mdcEquipmentService.findByProIdsAndTeamCode(allProductionIds, Arrays.asList(equEffVo.getTeamCodes().split(","))) +// : mdcEquipmentService.findByProductionIds(allProductionIds); +// +// if (equipmentList.isEmpty()) { +// return result; +// } +// +// // 3. 鏁版嵁澶勭悊 +// List<String> equipmentIdList = equipmentList.stream() +// .map(MdcEquipment::getEquipmentId) +// .collect(Collectors.toList()); +// +// List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper +// .teamEquipmentEfficiencyAnalyze(equipmentIdList, equEffVo.getMonth()); +// +// if (dataList.isEmpty()) { +// return result; +// } +// +// // 4. 鍒嗙粍璁$畻骞冲潎鍊� +// Map<String, TeamEquEffDto> grouped = dataList.stream() +// .collect(Collectors.groupingBy( +// TeamEquEffDto::getTeamCode, +// Collectors.collectingAndThen( +// Collectors.toList(), +// this::calculateAverages // 鎻愬彇璁$畻鏂规硶 +// ))); +// +// // 5. 瀛楀吀杞崲 +// Map<String, String> dictMap = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM) +// .stream() +// .collect(Collectors.toMap(DictModel::getValue, DictModel::getText)); +// +// List<TeamEquEffDto> resultList = grouped.entrySet().stream() +// .map(entry -> buildResultDto(entry, dictMap))// 鎻愬彇鏋勫缓鏂规硶 +// .sorted(Comparator.comparing(TeamEquEffDto::getUtilizationRate).reversed()) +// .collect(Collectors.toList()); +// +// result.put("dataList", resultList); +// result.put("teamCodeList", resultList.stream() +// .map(TeamEquEffDto::getTeamCode) +// .collect(Collectors.toList())); +// +// return result; +// +// } +// +// @Override +// public Map<String, Object> teamEfficiencyAnalyzeByMonth(String userId, EquEffVo equEffVo) { +// Map<String, Object> result = new HashMap<>(); +// +// // 1. 鏃ユ湡澶勭悊 +// LocalDate now = LocalDate.now(); +// Date start = DateUtils.toDate(now.plusMonths(-6).toString(), DateUtils.STR_DATE); +// Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); +// +// List<String> monthBetween = DateUtils.getMonthBetween(start, end); +// List<String> dateList = monthBetween.stream() +// .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�") +// .collect(Collectors.toList()); +// result.put("dateList", dateList); +// +// // 2. 鑾峰彇浜х嚎鏁版嵁 +// List<MdcProduction> mdcProductions = mdcProductionService.findMdcPros(userId, equEffVo.getProductionId()); +// +// // 3. 鍒濆鍖栫粨鏋滈泦 +// List<TeamEquEffMonthDto> utilizationRateList = new ArrayList<>(); +// List<TeamEquEffMonthDto> shiftUtilizationRateList = new ArrayList<>(); +// List<TeamEquEffMonthDto> amendUtilizationRateList = new ArrayList<>(); +// +// // 4. 澶勭悊姣忎釜浜х嚎 +// mdcProductions.forEach(mdcProduction -> { +// // 4.1 鑾峰彇涓嬬骇浜х嚎骞惰繃婊� +// List<String> allProductionIds = mdcProductionService.recursionChildren(mdcProduction.getId()); +// // 鏁版嵁鏉冮檺杩囨护 +// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); +// // 4.2 鑾峰彇璁惧鍒楄〃 +// List<MdcEquipment> equipmentList = mdcEquipmentService.findByProductionIds(allProductionIds); +// if (equipmentList == null || equipmentList.isEmpty()) { +// return; +// } +// //鎻愬彇id闆嗗悎 +// List<String> equipmentIdList = equipmentList.stream() +// .map(MdcEquipment::getEquipmentId) +// .collect(Collectors.toList()); +// +// TeamEquEffMonthDto urDto = new TeamEquEffMonthDto(); +// TeamEquEffMonthDto surDto = new TeamEquEffMonthDto(); +// TeamEquEffMonthDto aurDto = new TeamEquEffMonthDto(); +// urDto.setProductionName(mdcProduction.getProductionName()); +// surDto.setProductionName(mdcProduction.getProductionName()); +// aurDto.setProductionName(mdcProduction.getProductionName()); +// List<TeamEquEffMonthChildDto> urDataList = new ArrayList<>(); +// List<TeamEquEffMonthChildDto> surDataList = new ArrayList<>(); +// List<TeamEquEffMonthChildDto> aurDataList = new ArrayList<>(); +// +// monthBetween.forEach(date -> { +// TeamEquEffMonthChildDto urCDto = new TeamEquEffMonthChildDto(); +// TeamEquEffMonthChildDto surCDto = new TeamEquEffMonthChildDto(); +// TeamEquEffMonthChildDto aurCDto = new TeamEquEffMonthChildDto(); +// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; +// urCDto.setMonth(month); +// surCDto.setMonth(month); +// aurCDto.setMonth(month); +// List<TeamEquEffDto> dataList = mdcEfficiencyReportMapper.teamEquipmentEfficiencyAnalyze(equipmentIdList, date.replaceAll("-", "")); +// if (dataList != null && !dataList.isEmpty()) { +// // 璁$畻骞冲潎鍊� +// BigDecimal ur = dataList.stream() +// .map(TeamEquEffDto::getUtilizationRate) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); +// //鍒╃敤鐜� +// urCDto.setUtilizationRate(ur); +// //鐝鍒╃敤鐜� +// BigDecimal sur = dataList.stream() +// .map(TeamEquEffDto::getShiftUtilizationRate) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); +// surCDto.setUtilizationRate(sur); +// //鍘婚櫎鏁呴殰24灏忔椂鍒╃敤鐜� +// BigDecimal aur = dataList.stream() +// .map(TeamEquEffDto::getAmendUtilizationRate) +// .reduce(BigDecimal.ZERO, BigDecimal::add) +// .divide(BigDecimal.valueOf(dataList.size()), 2, RoundingMode.HALF_UP); +// aurCDto.setUtilizationRate(aur); +// } +// urDataList.add(urCDto); +// surDataList.add(surCDto); +// aurDataList.add(aurCDto); +// }); +// urDto.setDataList(urDataList); +// surDto.setDataList(surDataList); +// aurDto.setDataList(aurDataList); +// utilizationRateList.add(urDto); +// shiftUtilizationRateList.add(surDto); +// amendUtilizationRateList.add(aurDto); +// }); +// result.put("utilizationRateList", utilizationRateList); +// result.put("shiftUtilizationRateList", shiftUtilizationRateList); +// result.put("amendUtilizationRateList", amendUtilizationRateList); +// return result; +// } +// +// @Override +// public Map<String, Object> comprehensiveRateAnalyze(String userId, EquEffVo vo) { +// Map<String, Object> result = new HashMap<>(); +// // 1. 鏃ユ湡澶勭悊 +// LocalDate now = LocalDate.now(); +// Date start = DateUtils.toDate(now.plusMonths(-12).toString(), DateUtils.STR_DATE); +// Date end = DateUtils.toDate(now.plusMonths(-1).toString(), DateUtils.STR_DATE); +// +// List<String> monthBetween = DateUtils.getMonthBetween(start, end); +// List<String> dateList = monthBetween.stream() +// .map(date -> date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�") +// .collect(Collectors.toList()); +// result.put("dateList", dateList); +// +// // 1. 澶勭悊鐢熶骇ID +// List<String> mdcProductionIds = StringUtils.isBlank(vo.getProductionIds()) +// ? Collections.singletonList(vo.getProductionId()) +// : Arrays.asList(vo.getProductionIds().split(",")); +// +// List<String> allProductionIds = mdcProductionService.findChildren(mdcProductionIds); +// if (allProductionIds.isEmpty()) { +// return result; // 鎻愬墠杩斿洖绌虹粨鏋� +// } +// //鏁版嵁鏉冮檺杩囨护 +// allProductionIds = mdcProductionService.findProIdsByUId(userId, allProductionIds); +// // 2. 鑾峰彇璁惧鍒楄〃 +// List<MdcEquipment> equipmentList = StringUtils.isNotBlank(vo.getEquipmentType()) +// ? mdcEquipmentService.findByProIdsAndType(allProductionIds, Arrays.asList(vo.getEquipmentType().split(","))) +// : mdcEquipmentService.findByProductionIds(allProductionIds); +// +// if (equipmentList.isEmpty()) { +// return result; +// } +// +// // 3. 鏁版嵁澶勭悊 +// List<String> equipmentIdList = equipmentList.stream() +// .map(MdcEquipment::getEquipmentId) +// .collect(Collectors.toList()); +// String startStr = monthBetween.get(0).replaceAll("-", ""); +// String endStr = monthBetween.get(monthBetween.size() - 1).replaceAll("-", ""); +// List<ComRateDto> comRateDtoList = mdcEfficiencyReportMapper.comprehensiveRateAnalyze(equipmentIdList, startStr, endStr); +// if (comRateDtoList.isEmpty()) { +// return result; // 鎻愬墠杩斿洖绌虹粨鏋� +// } +// List<ComRateDto> dataList = new ArrayList<>(); +// Map<String, ComRateDto> map = comRateDtoList.stream().collect(Collectors.toMap(ComRateDto::getTheMonth, comRateDto -> comRateDto)); +// monthBetween.forEach(date -> { +// String d = date.replaceAll("-", ""); +// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; +// if (map.containsKey(d)) { +// ComRateDto comRateDto = map.get(d); +// comRateDto.setTheMonth(month); +// comRateDto.setUtilizationRate(comRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP)); +// comRateDto.setShiftUtilizationRate(comRateDto.getShiftUtilizationRate() != null ? comRateDto.getShiftUtilizationRate().setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO); +// comRateDto.setAmendUtilizationRate(comRateDto.getAmendUtilizationRate().setScale(2, RoundingMode.HALF_UP)); +// comRateDto.setProcessLong(comRateDto.getProcessLong().divide(new BigDecimal("3600"), 2, RoundingMode.HALF_UP)); +// dataList.add(comRateDto); +// } else { +// ComRateDto comRateDto = new ComRateDto(); +// comRateDto.setTheMonth(month); +// dataList.add(comRateDto); +// } +// }); +// result.put("dataList", dataList); +// +// if (StringUtils.isNotBlank(vo.getShiftId())) { +// List<MdcShiftSub> shiftSubList = mdcShiftSubService.list(new LambdaQueryWrapper<MdcShiftSub>().eq(MdcShiftSub::getShiftId, vo.getShiftId())); +// if (shiftSubList == null || shiftSubList.isEmpty()) { +// return result; +// } +// List<String> shiftSubNameList = shiftSubList.stream().map(MdcShiftSub::getShiftSubName).collect(Collectors.toList()); +// result.put("shiftSubList", shiftSubNameList); +// +// List<ComShiftRateDto> comShiftRateDtoList = mdcEfficiencyReportMapper.comprehensiveShiftRateAnalyze(equipmentIdList, startStr, endStr, vo.getShiftId()); +// Map<String, List<ComShiftRateDto>> groupMap; +// if (comShiftRateDtoList != null && !comShiftRateDtoList.isEmpty()) { +// groupMap = comShiftRateDtoList.stream().collect(Collectors.groupingBy(ComShiftRateDto::getShiftSub)); +// } else { +// groupMap = new HashMap<>(); +// } +// List<ComShiftDto> shiftDataList = new ArrayList<>(); +// shiftSubList.forEach(mdcShiftSub -> { +// ComShiftDto comShiftDto = new ComShiftDto(); +// comShiftDto.setShiftSubName(mdcShiftSub.getShiftSubName()); +// if (groupMap.containsKey(mdcShiftSub.getId())) { +// List<ComShiftRateDto> csrd = groupMap.get(mdcShiftSub.getId()); +// Map<String, ComShiftRateDto> collect = csrd.stream().collect(Collectors.toMap(ComShiftRateDto::getTheMonth, comShiftRateDto -> comShiftRateDto)); +// List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>(); +// monthBetween.forEach(date -> { +// String d = date.replaceAll("-", ""); +// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; +// if (collect.containsKey(d)) { +// ComShiftRateDto comShiftRateDto = collect.get(d); +// ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); +// comShiftChildDto.setMonth(month); +// comShiftChildDto.setUtilizationRate(comShiftRateDto.getUtilizationRate().setScale(2, RoundingMode.HALF_UP)); +// comShiftChildDtoList.add(comShiftChildDto); +// } else { +// ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); +// comShiftChildDto.setMonth(month); +// comShiftChildDtoList.add(comShiftChildDto); +// } +// }); +// comShiftDto.setDataList(comShiftChildDtoList); +// } else { +// List<ComShiftChildDto> comShiftChildDtoList = new ArrayList<>(); +// monthBetween.forEach(date -> { +// String month = date.substring(date.lastIndexOf("-") + 1).replaceFirst("^0*", "") + "鏈�"; +// ComShiftChildDto comShiftChildDto = new ComShiftChildDto(); +// comShiftChildDto.setMonth(month); +// comShiftChildDtoList.add(comShiftChildDto); +// }); +// comShiftDto.setDataList(comShiftChildDtoList); +// } +// shiftDataList.add(comShiftDto); +// }); +// +// result.put("shiftDataList", shiftDataList); +// } +// +// return result; +// } // 鎻愬彇鐨勫钩鍧囧�艰绠楁柟娉� private TeamEquEffDto calculateAverages(List<TeamEquEffDto> items) { @@ -2170,9 +2164,9 @@ mdcEfficiencyResultDto.setOpenLong(efficiencyDto.getOpenLong()); mdcEfficiencyResultDto.setWaitLong(efficiencyDto.getWaitLong()); mdcEfficiencyResultDto.setCloseLong(efficiencyDto.getCloseLong()); - mdcEfficiencyResultDto.setFaultLong(efficiencyDto.getFaultLong()); - mdcEfficiencyResultDto.setFaultRate(efficiencyDto.getFaultRate()); - mdcEfficiencyResultDto.setRemoveFaultRunLong(efficiencyDto.getRemoveFaultRunLong()); +// mdcEfficiencyResultDto.setFaultLong(efficiencyDto.getFaultLong()); +// mdcEfficiencyResultDto.setFaultRate(efficiencyDto.getFaultRate()); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(efficiencyDto.getRemoveFaultRunLong()); long rate = efficiencyDto.getUtilizationRate().multiply(new BigDecimal("100")).longValue(); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) { @@ -2190,9 +2184,9 @@ mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0")); mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0")); mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0")); - mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0")); - mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0")); - mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0")); +// mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0")); +// mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0")); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0")); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) { mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); @@ -2208,9 +2202,9 @@ mdcEfficiencyResultDto.setOpenLong(new BigDecimal("0")); mdcEfficiencyResultDto.setWaitLong(new BigDecimal("0")); mdcEfficiencyResultDto.setCloseLong(new BigDecimal("0")); - mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0")); - mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0")); - mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0")); +// mdcEfficiencyResultDto.setFaultLong(new BigDecimal("0")); +// mdcEfficiencyResultDto.setFaultRate(new BigDecimal("0")); +// mdcEfficiencyResultDto.setRemoveFaultRunLong(new BigDecimal("0")); for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) { if (0 >= mdcUtilizationRate.getMinimumRange() && 0 < mdcUtilizationRate.getMaximumRange()) { mdcEfficiencyResultDto.setColor(mdcUtilizationRate.getRateParameterColor()); @@ -2224,9 +2218,9 @@ efficiencyResultDto.setOpenLong(efficiencyResultDto.getOpenLong().add(mdcEfficiencyResultDto.getOpenLong())); efficiencyResultDto.setWaitLong(efficiencyResultDto.getWaitLong().add(mdcEfficiencyResultDto.getWaitLong())); efficiencyResultDto.setCloseLong(efficiencyResultDto.getCloseLong().add(mdcEfficiencyResultDto.getCloseLong())); - efficiencyResultDto.setFaultLong(efficiencyResultDto.getFaultLong().add(mdcEfficiencyResultDto.getFaultLong())); - efficiencyResultDto.setFaultRate(efficiencyResultDto.getFaultRate().add(mdcEfficiencyResultDto.getFaultRate())); - efficiencyResultDto.setRemoveFaultRunLong(efficiencyResultDto.getRemoveFaultRunLong().add(mdcEfficiencyResultDto.getRemoveFaultRunLong())); +// efficiencyResultDto.setFaultLong(efficiencyResultDto.getFaultLong().add(mdcEfficiencyResultDto.getFaultLong())); +// efficiencyResultDto.setFaultRate(efficiencyResultDto.getFaultRate().add(mdcEfficiencyResultDto.getFaultRate())); +// efficiencyResultDto.setRemoveFaultRunLong(efficiencyResultDto.getRemoveFaultRunLong().add(mdcEfficiencyResultDto.getRemoveFaultRunLong())); return mdcEfficiencyResultDto; } diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java deleted file mode 100644 index fc76c70..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentFaultInfoServiceImpl.java +++ /dev/null @@ -1,380 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang.StringUtils; -import org.jeecg.modules.mdc.entity.Equipment; -import org.jeecg.modules.mdc.entity.MdcEquipmentFaultInfo; -import org.jeecg.modules.mdc.entity.MdcEquipmentRunningSection; -import org.jeecg.modules.mdc.entity.MdcSystemParameters; -import org.jeecg.modules.mdc.mapper.MdcEquipmentFaultInfoMapper; -import org.jeecg.modules.mdc.service.IEquipmentService; -import org.jeecg.modules.mdc.service.IMdcEquipmentFaultInfoService; -import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService; -import org.jeecg.modules.mdc.service.IMdcSystemParametersService; -import org.jeecg.modules.mdc.util.DateUtils; -import org.jeecg.modules.mdc.vo.EquFaultRecord; -import org.jeecg.modules.mdc.vo.TimeInterval; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @Description: 鏁呴殰鐜囪〃 - * @Author: Lius - * @Date: 2025-06-16 - * @Version: V1.0 - */ -@Service -public class MdcEquipmentFaultInfoServiceImpl extends ServiceImpl<MdcEquipmentFaultInfoMapper, MdcEquipmentFaultInfo> implements IMdcEquipmentFaultInfoService { - - @Resource - private IEquipmentService equipmentService; - - @Resource - private IMdcSystemParametersService mdcSystemParametersService; - - @Resource - private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService; - - @Override - @Transactional(rollbackFor = {Exception.class}) - public void runningAllEquFaultStatistical(String dateTime) { - Date initDate = null; - - if (StringUtils.isNotBlank(dateTime)) { - initDate = DateUtils.toDate(dateTime, DateUtils.STRDATE); - } else { - // 鍙栨渶鍚庣殑缁熻鏃堕棿 - String date = this.baseMapper.getMaxStaticsData(); - if (date != null) { - initDate = DateUtils.toDate(date, DateUtils.STRDATE); - } else { - // 鍒濇鍙栧�� 鍙栨渶鏃╂椂闂磋褰� - MdcEquipmentRunningSection equipmentRunningSection = mdcEquipmentRunningSectionService.getFirstRecord(); - if (equipmentRunningSection != null) { - initDate = equipmentRunningSection.getStartTime(); - } - } - } - Date endDate = DateUtils.addDays(DateUtils.getNow(), -1); - List<String> dateList = DateUtils.getDatesStringList2(initDate, endDate); - - if (dateList.isEmpty()) { - return; - } - try { - this.remove(new LambdaQueryWrapper<MdcEquipmentFaultInfo>().in(MdcEquipmentFaultInfo::getTheDate, dateList)); - } catch (Exception e) { - log.error("鍙傛暟鏍煎紡涓嶅", e); - } - - List<Equipment> equipmentList = equipmentService.list(); - if (equipmentList == null || equipmentList.isEmpty()) { - return; - } - - String planTime = "00:00:00"; - MdcSystemParameters mdcSystemParameters = mdcSystemParametersService.getOne(new LambdaQueryWrapper<MdcSystemParameters>().eq(MdcSystemParameters::getCode, "equip_log_statis_time")); - if (mdcSystemParameters != null) { - planTime = mdcSystemParameters.getValue(); - } - - List<String> equipmentIdList = equipmentList.stream().map(Equipment::getEquipmentid).collect(Collectors.toList()); - - for (String validDate : dateList) { - Map<String, MdcEquipmentFaultInfo> map = new HashMap<>(); - String finalValidDate = validDate; - equipmentList.forEach(equipment -> { - MdcEquipmentFaultInfo mdcEquipmentFaultInfo = new MdcEquipmentFaultInfo(equipment.getEquipmentid(), finalValidDate); - map.put(equipment.getEquipmentid(), mdcEquipmentFaultInfo); - }); - - String startTime = DateUtils.format(DateUtils.setTimeForDay(DateUtils.toDate(validDate, DateUtils.STRDATE), planTime), DateUtils.STR_DATE_TIME_SMALL); - Date start = DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL); - String endTime = DateUtils.format(DateUtils.addDays(DateUtils.toDate(startTime, DateUtils.STR_DATE_TIME_SMALL), 1), DateUtils.STR_DATE_TIME_SMALL); - Date end = DateUtils.toDate(endTime, DateUtils.STR_DATE_TIME_SMALL); - //鏌ヨ鏁呴殰璁板綍 - List<EquFaultRecord> equFaultRecordList = this.baseMapper.findFaultRecord(equipmentIdList, startTime, endTime); - if (equFaultRecordList != null && !equFaultRecordList.isEmpty()) { - // 淇暣鏃堕棿 - Map<String, List<EquFaultRecord>> equFaultRecordMap = equFaultRecordList.stream().collect(Collectors.groupingBy(EquFaultRecord::getEquipmentId)); - map.forEach((key, value1) -> { - MdcEquipmentFaultInfo equFaultRecords = value1; - if (equFaultRecordMap.containsKey(key)) { - List<EquFaultRecord> value = equFaultRecordMap.get(key); - long faultLong = calculateTotalFaultDuration(value, start, end); - equFaultRecords.setFaultLong((int) faultLong); - if (faultLong != 0) { - equFaultRecords.setFaultRate(new BigDecimal(faultLong).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP)); - } - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂� - // step.1 鏌ヨ鍔犲伐鏃堕棿 - List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); - if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { - // 鏃堕棿淇 - if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { - mdcEquipmentRunningSections.get(0).setStartTime(start); - } - if (mdcEquipmentRunningSections.size() > 1) { - if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); - } - } else { - if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(0).setEndTime(end); - } - } - List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); - if (!collect.isEmpty()) { - // step.2 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫姞宸ユ椂闂� - long processingTime = calculateProcessingTimeWithoutFaults(collect, value, start, end); - equFaultRecords.setRemoveFaultRunLong((int) processingTime); - if (faultLong != 0 && faultLong != 86400) { - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 - BigDecimal removeFaultRate = new BigDecimal(processingTime).divide(new BigDecimal("864").subtract(new BigDecimal(faultLong)), 2, RoundingMode.HALF_UP); - equFaultRecords.setRemoveFaultRate(removeFaultRate); - } - } - } - } else { - List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); - if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { - // 鏃堕棿淇 - if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { - mdcEquipmentRunningSections.get(0).setStartTime(start); - } - if (mdcEquipmentRunningSections.size() > 1) { - if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); - } - } else { - if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(0).setEndTime(end); - } - } - List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); - - if (!collect.isEmpty()) { - long totalProcessingTime = 0; - for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) { - totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime())); - } - equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime); - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 - BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP); - equFaultRecords.setRemoveFaultRate(removeFaultRate); - } - } - } - map.put(key, equFaultRecords); - }); - } else { - map.forEach((key, value1) -> { - MdcEquipmentFaultInfo equFaultRecords = value1; - List<MdcEquipmentRunningSection> mdcEquipmentRunningSections = mdcEquipmentRunningSectionService.listEquipmentRunningSectionRun(key, start.getTime(), end.getTime()); - if (mdcEquipmentRunningSections != null && !mdcEquipmentRunningSections.isEmpty()) { - // 鏃堕棿淇 - if (mdcEquipmentRunningSections.get(0).getStartTime().before(start)) { - mdcEquipmentRunningSections.get(0).setStartTime(start); - } - if (mdcEquipmentRunningSections.size() > 1) { - if (mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(mdcEquipmentRunningSections.size() - 1).setEndTime(end); - } - } else { - if (mdcEquipmentRunningSections.get(0).getEndTime().after(end)) { - mdcEquipmentRunningSections.get(0).setEndTime(end); - } - } - List<MdcEquipmentRunningSection> collect = mdcEquipmentRunningSections.stream().filter(mdcEquipmentRunningSection -> mdcEquipmentRunningSection.getStatus() == 3).collect(Collectors.toList()); - - if (!collect.isEmpty()) { - long totalProcessingTime = 0; - for (MdcEquipmentRunningSection mdcEquipmentRunningSection : collect) { - totalProcessingTime += ChronoUnit.SECONDS.between(DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getStartTime()), DateUtils.convertToLocalDateTime(mdcEquipmentRunningSection.getEndTime())); - } - equFaultRecords.setRemoveFaultRunLong((int) totalProcessingTime); - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鐨勫埄鐢ㄧ巼 - BigDecimal removeFaultRate = new BigDecimal(totalProcessingTime).divide(new BigDecimal("864"), 2, RoundingMode.HALF_UP); - equFaultRecords.setRemoveFaultRate(removeFaultRate); - } - } - map.put(key, equFaultRecords); - }); - } - if (!map.isEmpty()) { - this.saveBatch(new ArrayList<>(map.values())); - } - } - } - - public static long calculateTotalFaultDuration(List<EquFaultRecord> records, Date startTime, Date endTime) { - LocalDateTime start = DateUtils.convertToLocalDateTime(startTime); - LocalDateTime end = DateUtils.convertToLocalDateTime(endTime); - - // 淇璁板綍鏃堕棿 - List<EquFaultRecord> correctedRecords = correctRecordTimes(records, start, end); - - // 鎸夊紑濮嬫椂闂存帓搴� - correctedRecords.sort(Comparator.comparing(EquFaultRecord::getStartTime)); - - // 鍚堝苟閲嶅彔鏃堕棿娈� - List<TimeInterval> mergedIntervals = mergeIntervals(correctedRecords); - - // 璁$畻鎬绘椂闀匡紙绉掞級 - return mergedIntervals.stream() - .mapToLong(interval -> ChronoUnit.SECONDS.between(interval.getStart(), interval.getEnd())) - .sum(); - } - - private static List<EquFaultRecord> correctRecordTimes(List<EquFaultRecord> records, LocalDateTime startTime, LocalDateTime endTime) { - return records.stream() - .map(record -> { - LocalDateTime recordStart = DateUtils.convertToLocalDateTime(record.getStartTime()); - LocalDateTime recordEnd = record.getEndTime() != null ? - DateUtils.convertToLocalDateTime(record.getEndTime()) : null; - - // 淇寮�濮嬫椂闂� - LocalDateTime correctedStart = recordStart.isBefore(startTime) ? - startTime : recordStart; - - // 淇缁撴潫鏃堕棿 - LocalDateTime correctedEnd = recordEnd == null || recordEnd.isAfter(endTime) ? - endTime : recordEnd; - - // 鍒涘缓淇鍚庣殑璁板綍 - return new EquFaultRecord( - record.getEquipmentId(), - DateUtils.convertToDate(correctedStart), - DateUtils.convertToDate(correctedEnd) - ); - }) - .collect(Collectors.toList()); - } - - private static List<TimeInterval> mergeIntervals(List<EquFaultRecord> records) { - List<TimeInterval> intervals = records.stream() - .map(record -> new TimeInterval( - DateUtils.convertToLocalDateTime(record.getStartTime()), - DateUtils.convertToLocalDateTime(record.getEndTime()))) - .collect(Collectors.toList()); - - if (intervals.isEmpty()) { - return Collections.emptyList(); - } - - List<TimeInterval> merged = new ArrayList<>(); - TimeInterval current = intervals.get(0); - - for (int i = 1; i < intervals.size(); i++) { - TimeInterval next = intervals.get(i); - if (next.getStart().isBefore(current.getEnd()) || next.getStart().equals(current.getEnd())) { - // 鏈夐噸鍙狅紝鍚堝苟鍖洪棿 - current.setEnd(current.getEnd().isAfter(next.getEnd()) ? current.getEnd() : next.getEnd()); - } else { - // 鏃犻噸鍙狅紝娣诲姞褰撳墠鍖洪棿骞舵洿鏂板綋鍓嶅尯闂� - merged.add(current); - current = next; - } - } - merged.add(current); // 娣诲姞鏈�鍚庝竴涓尯闂� - - return merged; - } - - // 璁$畻鍘婚櫎鏁呴殰鏃堕暱鍚庣殑鍔犲伐鏃堕棿 - private long calculateProcessingTimeWithoutFaults( - List<MdcEquipmentRunningSection> runningSections, - List<EquFaultRecord> faultRecords, - Date startTime, - Date endTime) { - - // 杞崲涓篖ocalDateTime杩涜澶勭悊 - LocalDateTime start = DateUtils.convertToLocalDateTime(startTime); - LocalDateTime end = DateUtils.convertToLocalDateTime(endTime); - - // 淇璁板綍鏃堕棿 - List<EquFaultRecord> correctedRecords = correctRecordTimes(faultRecords, start, end); - List<TimeInterval> mergedFaultIntervals = mergeIntervals(correctedRecords); - - long totalProcessingTime = 0; - - // 閬嶅巻姣忎釜鍔犲伐鍖洪棿锛屾帓闄ゆ晠闅滄椂闂� - for (MdcEquipmentRunningSection section : runningSections) { - LocalDateTime sectionStart = DateUtils.convertToLocalDateTime(section.getStartTime()); - LocalDateTime sectionEnd = DateUtils.convertToLocalDateTime(section.getEndTime()); - - // 鎺掗櫎鏁呴殰鏃堕棿鍚庣殑鏈夋晥鍔犲伐鏃堕棿 - List<TimeInterval> validIntervals = excludeFaultsFromSection( - new TimeInterval(sectionStart, sectionEnd), - mergedFaultIntervals); - - // 绱姞鏈夋晥鍔犲伐鏃堕棿锛堢锛� - for (TimeInterval interval : validIntervals) { - totalProcessingTime += ChronoUnit.SECONDS.between(interval.getStart(), interval.getEnd()); - } - } - - return totalProcessingTime; - } - - // 浠庤繍琛屽尯闂翠腑鎺掗櫎鏁呴殰鏃堕棿 - private List<TimeInterval> excludeFaultsFromSection( - TimeInterval section, - List<TimeInterval> faultIntervals) { - - List<TimeInterval> validIntervals = new ArrayList<>(); - validIntervals.add(section); - - // 閬嶅巻姣忎釜鏁呴殰鍖洪棿锛屼粠鏈夋晥鍖洪棿涓墸闄� - for (TimeInterval fault : faultIntervals) { - List<TimeInterval> newValidIntervals = new ArrayList<>(); - - for (TimeInterval valid : validIntervals) { - // 璁$畻鏈夋晥鍖洪棿涓庢晠闅滃尯闂寸殑浜ら泦 - if (isOverlapping(valid, fault)) { - // 鍒嗗壊鏈夋晥鍖洪棿 - splitInterval(valid, fault, newValidIntervals); - } else { - // 鏃犱氦闆嗭紝淇濈暀鍘熸湁鏁堝尯闂� - newValidIntervals.add(valid); - } - } - - validIntervals = newValidIntervals; - } - - return validIntervals; - } - - // 鍒ゆ柇涓や釜鏃堕棿鍖洪棿鏄惁閲嶅彔 - private boolean isOverlapping(TimeInterval a, TimeInterval b) { - return a.getStart().isBefore(b.getEnd()) && b.getStart().isBefore(a.getEnd()); - } - - // 鍒嗗壊鍖洪棿锛堟墸闄ら噸鍙犻儴鍒嗭級 - private void splitInterval( - TimeInterval valid, - TimeInterval fault, - List<TimeInterval> result) { - - // 閲嶅彔鍓嶇殑閮ㄥ垎 - if (valid.getStart().isBefore(fault.getStart())) { - result.add(new TimeInterval(valid.getStart(), fault.getStart())); - } - - // 閲嶅彔鍚庣殑閮ㄥ垎 - if (valid.getEnd().isAfter(fault.getEnd())) { - result.add(new TimeInterval(fault.getEnd(), valid.getEnd())); - } - } - -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java index 05d9f78..753837f 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java @@ -59,15 +59,9 @@ @Resource private MdcEquipmentDepartMapper mdcEquipmentDepartMapper; @Resource - private MdcProductionEquipmentMapper mdcProductionEquipmentMapper; - @Resource private ISysUserDepartService sysUserDepartService; @Resource - private IMdcUserProductionService mdcUserProductionService; - @Resource private ISysDepartService sysDepartService; - @Resource - private IMdcProductionService mdcProductionService; @Resource private IEquipmentWorkLineService equipmentWorkLineService; @Resource @@ -222,15 +216,15 @@ mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getDepId, departId).in(MdcEquipmentDepart::getEquipmentId, equipmentIdList)); } - @Override - public void removeEquipmentForProduction(String productionId, String equipmentId) { - mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).eq(MdcProductionEquipment::getEquipmentId, equipmentId)); - } +// @Override +// public void removeEquipmentForProduction(String productionId, String equipmentId) { +// mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).eq(MdcProductionEquipment::getEquipmentId, equipmentId)); +// } - @Override - public void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList) { - mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).in(MdcProductionEquipment::getEquipmentId, equipmentIdList)); - } +// @Override +// public void removeEquipmentsForProduction(String productionId, List<String> equipmentIdList) { +// mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).in(MdcProductionEquipment::getEquipmentId, equipmentIdList)); +// } @Override public List<MdcEquipmentTree> loadTreeListByDepart(String userId) { @@ -703,22 +697,22 @@ return this.baseMapper.selectPage(page, queryWrapper); } - /** - * 鏍规嵁鐖剁骇id閫掑綊鏌ヨ鎵�鏈変笅绾d闆嗗悎 - */ - private List<String> findAllProductions(String key) { - List<String> productions = new ArrayList<>(); - List<MdcProduction> mdcProductions = mdcProductionService.queryProdByPid(key); - if (mdcProductions != null && !mdcProductions.isEmpty()) { - List<String> ids = mdcProductions.stream().map(MdcProduction::getId).collect(Collectors.toList()); - productions.addAll(ids); - for (MdcProduction mdcProduction : mdcProductions) { - List<String> allProductions = findAllProductions(mdcProduction.getId()); - productions.addAll(allProductions); - } - } - return productions; - } +// /** +// * 鏍规嵁鐖剁骇id閫掑綊鏌ヨ鎵�鏈変笅绾d闆嗗悎 +// */ +// private List<String> findAllProductions(String key) { +// List<String> productions = new ArrayList<>(); +// List<MdcProduction> mdcProductions = mdcProductionService.queryProdByPid(key); +// if (mdcProductions != null && !mdcProductions.isEmpty()) { +// List<String> ids = mdcProductions.stream().map(MdcProduction::getId).collect(Collectors.toList()); +// productions.addAll(ids); +// for (MdcProduction mdcProduction : mdcProductions) { +// List<String> allProductions = findAllProductions(mdcProduction.getId()); +// productions.addAll(allProductions); +// } +// } +// return productions; +// } /** * 浜х嚎璁惧鏍戝~鍏呰澶囨暟鎹� @@ -843,7 +837,7 @@ public IPage<MdcEquipment> pageList(Page<MdcEquipment> page, MdcEquipmentVo mdcEquipment, HttpServletRequest req) { if (StringUtils.isNotBlank(mdcEquipment.getProductionName())) { // 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); + List<String> productionIds = factoryService.recursionChildren(mdcEquipment.getProductionName()); mdcEquipment.setProductionIds(productionIds); } return this.baseMapper.pageList(page, mdcEquipment); @@ -919,38 +913,38 @@ public List<MdcEquipment> exportXlsList(MdcEquipmentVo mdcEquipment) { if (StringUtils.isNotBlank(mdcEquipment.getProductionName())) { // 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); + List<String> productionIds = factoryService.recursionChildren(mdcEquipment.getProductionName()); mdcEquipment.setProductionIds(productionIds); } return this.baseMapper.exportXlsList(mdcEquipment); } - /** - * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� - * - * @param ids - * @return - */ - @Override - public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids) { - List<String> productionIds = Arrays.asList(ids.split(",")); - //鑾峰彇鎵�鏈変骇绾挎暟鎹� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); - List<String> allProductionIds = new ArrayList<>(); - //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d - if (!productionIds.isEmpty()) { - for (String productionId : productionIds) { - this.getAllProductionIds(productionList, productionId, allProductionIds); - } - } - //杩囨护浜х嚎鏁版嵁 - List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); - //缁勮浜х嚎璁惧鏍� - List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); - //濉厖璁惧鏁版嵁 - FillEquipmentByProduction(treeList); - return treeList; - } +// /** +// * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� +// * +// * @param ids +// * @return +// */ +// @Override +// public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids) { +// List<String> productionIds = Arrays.asList(ids.split(",")); +// //鑾峰彇鎵�鏈変骇绾挎暟鎹� +// List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); +// List<String> allProductionIds = new ArrayList<>(); +// //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d +// if (!productionIds.isEmpty()) { +// for (String productionId : productionIds) { +// this.getAllProductionIds(productionList, productionId, allProductionIds); +// } +// } +// //杩囨护浜х嚎鏁版嵁 +// List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); +// //缁勮浜х嚎璁惧鏍� +// List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); +// //濉厖璁惧鏁版嵁 +// FillEquipmentByProduction(treeList); +// return treeList; +// } /** * 鏌ヨ鍗曡〃鏁版嵁 @@ -1061,21 +1055,21 @@ return this.baseMapper.selectList(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getEquipmentId, Arrays.asList(user.getEquipmentIds().split(StringPool.COMMA)))); } //鑾峰彇鎵�鏈変骇绾挎暟鎹� - List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<Factory> factoryList = factoryService.list(new LambdaQueryWrapper<Factory>().eq(Factory::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(Factory::getSorter)); //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� - List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); - List<String> allProductionIds = new ArrayList<>(); + List<String> factoryIds = userFactoryService.queryFactoryIdsByUserId(userId); + List<String> allFactoryIds = new ArrayList<>(); //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d - if (productionIds != null && !productionIds.isEmpty()) { - for (String productionId : productionIds) { - this.getAllProductionIds(productionList, productionId, allProductionIds); + if (factoryIds != null && !factoryIds.isEmpty()) { + for (String factoryId : factoryIds) { + this.getAllFactoryIds(factoryList, factoryId, allFactoryIds); } } //鏍规嵁浜х嚎闆嗗悎鏌ユ壘鎵�鏈夎澶噄d - if (allProductionIds.isEmpty()) { + if (allFactoryIds.isEmpty()) { return null; } - List<MdcEquipment> equipmentIds = this.baseMapper.getEquipmentList(allProductionIds); + List<MdcEquipment> equipmentIds = this.baseMapper.getEquipmentList(allFactoryIds); return equipmentIds; } diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java index bd38a45..b38b863 100644 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java @@ -37,8 +37,8 @@ @Resource private IMdcSystemParametersService mdcSystemParametersService; - @Resource - private IMdcEquipmentFaultInfoService mdcEquipmentFaultInfoService; +// @Resource +// private IMdcEquipmentFaultInfoService mdcEquipmentFaultInfoService; /** * 璁$畻璁惧鍗曟棩杩愯鏁版嵁 @@ -68,7 +68,7 @@ if (!result.isEmpty()) { this.saveBatch(result); } - mdcEquipmentFaultInfoService.runningAllEquFaultStatistical(dateTime); +// mdcEquipmentFaultInfoService.runningAllEquFaultStatistical(dateTime); } private List<MdcEquipmentStatisticalInfo> equipmentStatisticalProcess(Equipment equipment, String dateTime) { diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionEquipmentServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionEquipmentServiceImpl.java deleted file mode 100644 index a4aa655..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionEquipmentServiceImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.jeecg.modules.mdc.entity.MdcEquipment; -import org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper; -import org.jeecg.modules.mdc.service.IMdcEquipmentService; -import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.entity.MdcProductionEquipment; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * @author: LiuS - * @create: 2023-03-28 10:31 - */ -@Service -public class MdcProductionEquipmentServiceImpl extends ServiceImpl<MdcProductionEquipmentMapper, MdcProductionEquipment> implements IMdcProductionEquipmentService { - - @Resource - private IMdcProductionService mdcProductionService; - @Resource - private IMdcEquipmentService mdcEquipmentService; - - /** - * 鏍规嵁璁惧id鏌ヨ浜х嚎淇℃伅 - */ - @Override - public List<ProductionIdModel> queryProductionIdsOfEquipment(String equipmentId) { - LambdaQueryWrapper<MdcProductionEquipment> queryEquipmentPro = new LambdaQueryWrapper<>(); - LambdaQueryWrapper<MdcProduction> queryPro = new LambdaQueryWrapper<>(); - try { - queryEquipmentPro.eq(MdcProductionEquipment::getEquipmentId, equipmentId); - List<String> proIdList = new ArrayList<>(); - List<ProductionIdModel> proIdModelList = new ArrayList<>(); - List<MdcProductionEquipment> equipmentProList = this.list(queryEquipmentPro); - if (equipmentProList != null && !equipmentProList.isEmpty()) { - for (MdcProductionEquipment productionEquipment : equipmentProList) { - proIdList.add(productionEquipment.getProductionId()); - } - queryPro.in(MdcProduction::getId, proIdList); - List<MdcProduction> proList = mdcProductionService.list(queryPro); - if (proList != null && !proList.isEmpty()) { - for (MdcProduction mdcProduction : proList) { - proIdModelList.add(new ProductionIdModel().convertByUserProduction(mdcProduction)); - } - } - return proIdModelList; - } - } catch (Exception e) { - e.fillInStackTrace(); - } - return null; - } - /** - * 鏍规嵁鎸囧畾浜х嚎id鏌ヨ璁惧淇℃伅 - */ - @Override - public List<MdcEquipment> queryEquipmentsOfProduction(String productionId){ - List<String> equipmentIds = this.list(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId)) - .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); - if (!equipmentIds.isEmpty()) { - return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); - } - return null; - } - - /** - * 鏍规嵁鎸囧畾浜х嚎ids鏌ヨ璁惧淇℃伅 - */ - @Override - public List<MdcEquipment> queryEquipmentsOfProductions(List<String> productionIds){ - List<String> equipmentIds = this.list(new LambdaQueryWrapper<MdcProductionEquipment>() - .in(MdcProductionEquipment::getProductionId, productionIds)).stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); - if (!equipmentIds.isEmpty()) { - return mdcEquipmentService.list(new LambdaQueryWrapper<MdcEquipment>().in(MdcEquipment::getId, equipmentIds)); - } - return null; - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionServiceImpl.java deleted file mode 100644 index 3ba9d7c..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProductionServiceImpl.java +++ /dev/null @@ -1,649 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.IdWorker; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.SecurityUtils; -import org.jeecg.common.constant.CommonConstant; -import org.jeecg.common.constant.FillRuleConstant; -import org.jeecg.common.system.vo.DictModel; -import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.common.util.FillRuleUtil; -import org.jeecg.common.util.oConvertUtils; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.entity.MdcProductionEquipment; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.mdc.mapper.MdcProductionEquipmentMapper; -import org.jeecg.modules.mdc.mapper.MdcProductionMapper; -import org.jeecg.modules.mdc.mapper.MdcUserProductionMapper; -import org.jeecg.modules.mdc.model.MdcProductionTreeModel; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.jeecg.modules.mdc.util.FindsProductionsChildrenUtil; -import org.jeecg.modules.mdc.vo.MdcProOptionsVo; -import org.jeecg.modules.system.entity.SysParams; -import org.jeecg.modules.system.entity.SysUser; -import org.jeecg.modules.system.mapper.SysUserMapper; -import org.jeecg.modules.system.service.ISysDictService; -import org.jeecg.modules.system.service.ISysParamsService; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @Description: 浜х嚎琛� - * @Author: liuS - * @Date: 2023-03-23 - * @Version: V1.0 - */ -@Service -public class MdcProductionServiceImpl extends ServiceImpl<MdcProductionMapper, MdcProduction> implements IMdcProductionService { - - @Resource - private SysUserMapper sysUserMapper; - - @Resource - private MdcUserProductionMapper userProductionMapper; - - @Resource - private MdcProductionEquipmentMapper productionEquipmentMapper; - - @Resource - private ISysParamsService sysParamsService; - - @Resource - private ISysDictService sysDictService; - /** - * queryTreeList 瀵瑰簲 queryTreeList 鏌ヨ鎵�鏈夌殑浜х嚎鏁版嵁,浠ユ爲缁撴瀯褰㈠紡鍝嶅簲缁欏墠绔� - */ - @Override - @Cacheable(value = "mdc:cache:production:alldata") - public List<MdcProductionTreeModel> queryTreeList() { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず - this.setUserIdsByProList(list); - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); - } - - /** - * 鏌ヨ鎵�鏈変骇绾夸俊鎭紝骞跺垎鑺傜偣杩涜鏄剧ず(娣诲姞绯荤粺閰嶇疆) - */ - @Override - public List<MdcProductionTreeModel> queryTreeListByConfig(){ - SysParams sysParams = sysParamsService.getSysPramBySettingKey("dnc_production"); - LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - if (sysParams == null) { - return null; - }else { - List<String> productionIds = new ArrayList<>(); - if (!("admin").equals(loginUser.getUsername())) { - //涓嶆槸瓒呯骇绠$悊鍛橈紝鑾峰彇鐢ㄦ埛鎷ユ湁鐨勪骇绾� - if (loginUser.getProductionIds() != null) { - if (loginUser.getProductionIds().contains(",")) { - productionIds = Arrays.asList(loginUser.getProductionIds().split(",")); - } else { - productionIds = Collections.singletonList(loginUser.getProductionIds()); - } - } - } - if (("0").equals(sysParams.getSettingValue())){ - query.eq(MdcProduction::getOrgType,"2"); - query.in(!productionIds.isEmpty(), MdcProduction::getId, productionIds); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず - this.setUserIdsByProList(list); - //灏佽涓�绾ф爲 - List<MdcProductionTreeModel> listResult = new ArrayList<>(); - for (MdcProduction production : list) { - if (production.getDescription().isEmpty()){ - production.setDescription(""); - } - listResult.add(new MdcProductionTreeModel(production)); - } - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return listResult; - }else { - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず - this.setUserIdsByProList(list); - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); - } - } - } - - /** - * queryTreeList 鏍规嵁浜х嚎id鏌ヨ,鍓嶇鍥炴樉璋冪敤 - */ - @Override - public List<MdcProductionTreeModel> queryTreeList(String ids) { - List<MdcProductionTreeModel> listResult = new ArrayList<>(); - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - if (oConvertUtils.isNotEmpty(ids)) { - query.in(true, MdcProduction::getId, ids.split(",")); - } - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - for (MdcProduction production : list) { - if (production.getDescription().isEmpty()){ - production.setDescription(""); - } - listResult.add(new MdcProductionTreeModel(production)); - } - return listResult; - } - - @Override - @Cacheable(value = "mdc:cache:production:allids") - public List<ProductionIdModel> queryProductionIdTreeList() { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return FindsProductionsChildrenUtil.wrapTreeDataToProductionIdTreeList(list); - } - - /** - * 鏍规嵁鍏抽敭瀛楁悳绱㈢浉鍏崇殑閮ㄩ棬鏁版嵁 - */ - @Override - public List<MdcProductionTreeModel> searchByKeyWord(String keyWord) { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); - List<MdcProductionTreeModel> newList = new ArrayList<>(); - query.like(MdcProduction::getProductionName, keyWord); - MdcProductionTreeModel model = new MdcProductionTreeModel(); - List<MdcProduction> productionList = this.list(query); - if (!productionList.isEmpty()) { - for (MdcProduction mdcProduction : productionList) { - model = new MdcProductionTreeModel(mdcProduction); - model.setChildren(null); - newList.add(model); - } - return newList; - } - return Collections.emptyList(); - } - - /** - * saveProductionData 瀵瑰簲 add 淇濆瓨鐢ㄦ埛鍦ㄩ〉闈㈡坊鍔犵殑鏂扮殑浜х嚎瀵硅薄鏁版嵁 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void saveProductionData(MdcProduction mdcProduction) { - if (mdcProduction != null) { - if (mdcProduction.getParentId() == null) { - mdcProduction.setParentId(""); - } - mdcProduction.setId(IdWorker.getIdStr(mdcProduction)); - // 鍏堝垽鏂瀵硅薄鏈夋棤鐖剁骇ID,鏈夊垯鎰忓懗鐫�涓嶆槸鏈�楂樼骇,鍚﹀垯鎰忓懗鐫�鏄渶楂樼骇 - // 鑾峰彇鐖剁骇ID - String parentId = mdcProduction.getParentId(); - JSONObject formData = new JSONObject(); - formData.put("parentId",parentId); - String[] codeArray = (String[]) FillRuleUtil.executeRule(FillRuleConstant.PRODUCTION,formData); - mdcProduction.setOrgCode(codeArray[0]); - String orgType = codeArray[1]; - mdcProduction.setOrgType(String.valueOf(orgType)); - mdcProduction.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); - this.save(mdcProduction); - - //澶勭悊瀛樺湪鐖跺瓙鍏崇郴 mdc鏍囪缁熶竴鐨勯棶棰� - //1.mdc鏍囪 涓� 1 寮�鍚� 鐖剁骇鑺傜偣瑕佺粺涓�寮�鍚� - //2.mdc鏍囪 涓� 0 鍏抽棴 瀛愮骇鑺傜偣瑕佺粺涓�鍏抽棴 鏂板鎿嶄綔 涓嶅瓨鍦ㄦ鎯呭喌 - if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ - openParentMdcFlag(parentId); - } - } - } - - /** - * updateProductionDataById 瀵瑰簲 edit 鏍规嵁浜х嚎涓婚敭鏉ユ洿鏂板搴旂殑浜х嚎鏁版嵁 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean updateProductionDataById(MdcProduction mdcProduction) { - if (mdcProduction != null) { - this.updateById(mdcProduction); - - //澶勭悊瀛樺湪鐖跺瓙鍏崇郴 mdc鏍囪缁熶竴鐨勯棶棰� - //1.mdc鏍囪 涓� 1 寮�鍚� 鐖剁骇鑺傜偣瑕佺粺涓�寮�鍚� - //2.mdc鏍囪 涓� 0 鍏抽棴 瀛愮骇鑺傜偣瑕佺粺涓�鍏抽棴 - String parentId = mdcProduction.getParentId(); - if(StringUtils.isNotBlank(parentId) && CommonConstant.DEFAULT_1.equals(mdcProduction.getMdcFlag())){ - openParentMdcFlag(parentId); - } - if(CommonConstant.DEFAULT_0.equals(mdcProduction.getMdcFlag())){ - //鍏抽棴 - closeChildrenMdcFlag(mdcProduction.getId()); - } - return true; - } - return false; - } - - /** - * 鏍规嵁浜х嚎id鍒犻櫎骞跺垹闄ゅ叾鍙兘瀛樺湪鐨勫瓙绾т骇绾� - */ - @Override - @Transactional(rollbackFor = Exception.class) - public boolean delete(String id) { - List<String> idList = new ArrayList<>(); - idList.add(id); - this.checkChildrenExists(id, idList); - boolean result = this.removeByIds(idList); - //鏍规嵁浜х嚎id鍒犻櫎鐢ㄦ埛涓庝骇绾垮叧绯� - userProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, idList)); - //鏍规嵁浜х嚎id鍒犻櫎浜х嚎涓庤澶囧叧绯� - productionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getProductionId, idList)); - return result; - } - - /** - * 鏍规嵁浜х嚎id鎵归噺鍒犻櫎骞跺垹闄ゅ叾鍙兘瀛樺湪鐨勫瓙绾т骇绾� - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteBatchWithChildren(List<String> ids) { - List<String> idList = new ArrayList<>(); - for (String id : ids) { - idList.add(id); - this.checkChildrenExists(id, idList); - } - this.removeByIds(idList); - //鏍规嵁浜х嚎id鍒犻櫎鐢ㄦ埛涓庝骇绾垮叧绯� - userProductionMapper.delete(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, idList)); - //鏍规嵁浜х嚎id鍒犻櫎浜х嚎涓庤澶囧叧绯� - productionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().in(MdcProductionEquipment::getProductionId, idList)); - } - - /** - * 鏍规嵁id鏌ヨ涓嬬骇浜х嚎 - */ - @Override - public List<MdcProduction> queryProdByPid(String pid) { - return this.baseMapper.queryProdByPid(pid); - } - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣 - */ - @Override - public List<MdcProduction> recursionChildrenByPid(String pid){ - List<String> ids=this.recursionChildren(pid); - return super.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).in(MdcProduction::getId, ids)); - } - - /** - * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎涓嬫媺鏍戦�夐」 - */ - @Override - public List<ProductionIdModel> loadProductionTreeOptions(String userId) { - //鑾峰彇鎵�鏈変骇绾挎暟鎹� - List<MdcProduction> productionList = this.baseMapper.selectList(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); - //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� - List<String> productionIds = userProductionMapper.queryProductionIdsByUserId(userId); - List<String> allProductionIds = new ArrayList<>(); - //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d - if (productionIds != null && !productionIds.isEmpty()) { - for (String productionId : productionIds) { - this.getAllProductionIds(productionList, productionId, allProductionIds); - } - } - //杩囨护浜х嚎鏁版嵁 - List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); - return FindsProductionsChildrenUtil.wrapTreeDataToProductionIdTreeList(list); - } - - /** - * 閫掑綊鏌ヨ鎵�鏈夊瓙鑺傜偣id - */ - @Override - public List<String> recursionChildren(String productionId) { - return this.baseMapper.recursionChildren(productionId); - } - - /** - * 鏍规嵁鐢ㄦ埛id鍜岃溅闂磇d鑾峰彇鐢ㄦ埛鎷ユ湁鐨勮溅闂磇d - * @param userId - * @param productionId - * @return - */ - @Override - public String findFirstProduction(String userId, String productionId) { - return this.baseMapper.findFirstProduction(userId, productionId); - } - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ鐢ㄦ埛宸ユ鏉冮檺 - */ - @Override - public String findThreeProductionId(String userId) { - return this.baseMapper.findThreeProductionId(userId); - } - - /** - * delete 鏂规硶璋冪敤 閫掑綊鏌ユ壘瀛愰泦id - */ - private void checkChildrenExists(String id, List<String> idList) { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<>(); - query.eq(MdcProduction::getParentId, id); - List<MdcProduction> productionList = this.list(query); - if (productionList != null && !productionList.isEmpty()) { - for (MdcProduction production : productionList) { - idList.add(production.getId()); - this.checkChildrenExists(production.getId(), idList); - } - } - } - - /** - * 鑾峰彇鎵�鏈夌殑浜х嚎id锛堝寘鍚墍鏈変笂绾э級 - */ - private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) { - if (!allProductionIds.contains(productionId)) { - allProductionIds.add(productionId); - } - for (MdcProduction mdcProduction : productionList) { - if (StringUtils.isEmpty(mdcProduction.getParentId())) { - continue; - } - if (productionId.equals(mdcProduction.getId())) { - if (!allProductionIds.contains(mdcProduction.getParentId())) { - allProductionIds.add(mdcProduction.getParentId()); - getAllProductionIds(productionList, mdcProduction.getParentId(), allProductionIds); - } - } - } - } - - /** - * 閫氳繃浜х嚎闆嗗悎涓轰骇绾胯缃敤鎴穒d锛岀敤浜庡墠鍙板睍绀� - */ - private void setUserIdsByProList(List<MdcProduction> productionList) { - //鏌ヨ璐熻矗閮ㄩ棬涓嶄负绌虹殑鎯呭喌 - LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>(); - query.isNotNull(SysUser::getDepartIds); - List<SysUser> users = sysUserMapper.selectList(query); - Map<String, Object> map = new HashMap(5); - //鍏堝惊鐜竴閬嶆壘鍒颁笉鍚岀殑璐熻矗浜х嚎id - for (SysUser user : users) { - String productionIds = user.getProductionIds(); - if (StringUtils.isNotBlank(productionIds)) { - String[] productionIdArray = productionIds.split(","); - for (String productionId : productionIdArray) { - if (map.containsKey(productionId)) { - String userIds = map.get(productionId) + "," + user.getId(); - map.put(productionId, userIds); - } else { - map.put(productionId, user.getId()); - } - } - } - } - //寰幆浜х嚎闆嗗悎鎵惧埌浜х嚎id瀵瑰簲鐨勮礋璐g敤鎴� - for (MdcProduction mdcProduction : productionList) { - if (map.containsKey(mdcProduction.getId())) { - mdcProduction.setDirectorUserIds(map.get(mdcProduction.getId()).toString()); - } - } - } - - /** - * 鏌ヨ鎵�鏈夌埗鑺傜偣鍜屾湰鑺傜偣鍚嶇О - * @param id - * @return - */ - @Override - public List<String> findListParentTreeAll(String id){ - MdcProductionEquipment mdcProductionEquipment=productionEquipmentMapper.selectOne(new QueryWrapper<MdcProductionEquipment>().eq("equipment_id",id)); - if (mdcProductionEquipment==null) { - return null; - } - List<String> strings = new ArrayList<>(); - MdcProduction en=super.getById(mdcProductionEquipment.getProductionId()); - if (en == null) { - return null; - } - strings.add(en.getProductionName()); - if (StringUtils.isEmpty(en.getParentId())) { - return strings; - } else { - return findListParentTree(en.getParentId(),strings); - } - } - - // 鏌ヨ鎵�浠ョ埗鑺傜偣 - @Override - public List<String> findListParentTree(String parentId,List<String> stringList){ - if (StringUtils.isEmpty(parentId)) { - return null; - } - if (stringList == null || stringList.isEmpty()) { - stringList = new ArrayList<>(); - } - boolean p = true; - if (p) { - MdcProduction en = super.getById(parentId); - if (en != null) { - stringList.add(0,en.getProductionName()); - } - if (StringUtils.isNotBlank(en.getParentId())) { - parentId = en.getParentId(); - findListParentTree(parentId,stringList); - } else { - p = false; - return stringList; - } - } - return stringList; - } - - /** - * 鑾峰彇鐢ㄦ埛宸插垎閰嶇殑閮ㄩ棬鍒楄〃 - * @param userId - * @return - */ - @Override - public Map<String, MdcProduction> getUserAssignedDepart(String userId){ - if(StrUtil.isEmpty(userId)) - return null; - List<MdcProduction> userPermDepart = this.baseMapper.findAllProductionId(userId); - if(userPermDepart == null || userPermDepart.isEmpty()) - return null; - Map<String, MdcProduction> map = new HashMap<>(); - userPermDepart.forEach(item -> { - map.put(item.getId(), item); - }); - return map; - } - - /** - * 閫氳繃涓�缁刬d鑾峰彇閮ㄩ棬 - * @param ids - * @return - */ - @Override - public List<String> findAllProductionIds(List<String> ids){ - return this.baseMapper.recursionChildrenByList(ids); - } - - @Override - public List<String> findParentIdsForProduction(String parentId, List<String> idList) { - if (StringUtils.isEmpty(parentId)) { - return null; - } - if (idList == null || idList.isEmpty()) { - idList = new ArrayList<>(); - } - boolean p = true; - if (p) { - MdcProduction en = super.getById(parentId); - if (en != null) { - idList.add(0, en.getId()); - } - if (StringUtils.isNotBlank(en.getParentId())) { - parentId = en.getParentId(); - findParentIdsForProduction(parentId, idList); - } else { - p = false; - return idList; - } - } - return idList; - } - - @Override - public List<MdcProductionTreeModel> queryTreeListByMdc(String ids) { - List<MdcProductionTreeModel> listResult = new ArrayList<>(); - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1); - if (oConvertUtils.isNotEmpty(ids)) { - query.in(true, MdcProduction::getId, ids.split(",")); - } - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - for (MdcProduction production : list) { - if (production.getDescription().isEmpty()){ - production.setDescription(""); - } - listResult.add(new MdcProductionTreeModel(production)); - } - return listResult; - } - - @Override - public List<MdcProductionTreeModel> queryTreeListByMdc() { - LambdaQueryWrapper<MdcProduction> query = new LambdaQueryWrapper<MdcProduction>(); - query.eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); - query.eq(MdcProduction::getMdcFlag, CommonConstant.DEFAULT_1); - query.orderByAsc(MdcProduction::getProductionOrder); - List<MdcProduction> list = this.list(query); - //璁剧疆鐢ㄦ埛id锛岃鍓嶅彴鏄剧ず - this.setUserIdsByProList(list); - //璋冪敤wrapTreeDataToTreeList鏂规硶鐢熸垚鏍戠姸鏁版嵁 - return FindsProductionsChildrenUtil.wrapTreeDataToTreeList(list); - } - - @Override - public List<String> findChildren(List<String> mdcProductionIds) { - return this.baseMapper.findChildren(mdcProductionIds); - } - - /** - * 鏍规嵁鐢ㄦ埛id鑾峰彇浜х嚎(涓績)鎴栫彮缁勪笅鎷夐�夐」 - * @param userId - * @param productionId - * @return - */ - @Override - public List<MdcProOptionsVo> loadProductionOptions(String userId, String productionId) { - List<MdcProOptionsVo> result = new ArrayList<>(); - List<MdcProduction> mdcProductionList = this.baseMapper.loadProductionOptions(userId, productionId); - if (mdcProductionList != null && !mdcProductionList.isEmpty()) { - for (MdcProduction mdcProduction : mdcProductionList) { - MdcProOptionsVo vo = new MdcProOptionsVo().convert(mdcProduction); - result.add(vo); - } - } - return result; - } - - @Override - public List<MdcProduction> findMdcPros(String userId, String productionId) { - return this.baseMapper.loadProductionOptions(userId, productionId); - } - - @Override - public List<MdcProOptionsVo> loadTeamOptions(String userId, String productionId) { - List<MdcProOptionsVo> result = new ArrayList<>(); - List<String> productionList = this.findChildren(Arrays.asList(productionId.split(","))); - if (productionList != null && !productionList.isEmpty()) { - List<String> dictValues = this.baseMapper.findTeamValue(userId, productionList); - if (dictValues != null && !dictValues.isEmpty()) { - List<DictModel> dictModels = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_MDC_STAFF_TEAM); - if (dictModels != null && !dictModels.isEmpty()) { - for (DictModel dictModel : dictModels) { - if (dictValues.contains(dictModel.getValue())) { - MdcProOptionsVo vo = new MdcProOptionsVo(); - vo.setKey(dictModel.getValue()); - vo.setValue(dictModel.getValue()); - vo.setTitle(dictModel.getText()); - result.add(vo); - } - } - } - } - } - return result; - } - - @Override - public List<String> findProIdsByUId(String userId, List<String> allProductionIds) { - return this.baseMapper.findProIdsByUId(userId, allProductionIds); - } - - /** - * 鎵撳紑 鐖惰妭鐐� 鍙� 浠ヤ笂鐨刴dc鏍囪 - * @param parentId - */ - private void openParentMdcFlag(String parentId) { - List<String> listParentTree = findParentIdsForProduction(parentId, new ArrayList<>()); - if (!CollectionUtil.isEmpty(listParentTree)) { - UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>(); - updateWrapper.in("id", listParentTree); - updateWrapper.set("mdc_flag", "1"); - super.update(updateWrapper); - } - } - - /** - * 鍏抽棴鎵�鏈夊瓙鑺傜偣鐨刴dc鏍囪 - * @param productionId - */ - private void closeChildrenMdcFlag(String productionId) { - List<String> childrenList = recursionChildren(productionId); - if (!CollectionUtil.isEmpty(childrenList)) { - UpdateWrapper<MdcProduction> updateWrapper = new UpdateWrapper<>(); - updateWrapper.in("id", childrenList); - updateWrapper.set("mdc_flag", "0"); - super.update(updateWrapper); - } - } - - @Override - public List<String> findChildByProId(String productionId) { - return this.baseMapper.findChildByProId(productionId); - } - - @Override - public String findProName(String equipmentId) { - return this.baseMapper.findProName(equipmentId); - } - - @Override - public MdcProduction findByOrgCode(String orgCode){ - return this.baseMapper.selectOne(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getOrgCode, orgCode)); - } -} diff --git a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcUserProductionServiceImpl.java b/src/main/java/org/jeecg/modules/mdc/service/impl/MdcUserProductionServiceImpl.java deleted file mode 100644 index 455999c..0000000 --- a/src/main/java/org/jeecg/modules/mdc/service/impl/MdcUserProductionServiceImpl.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.jeecg.modules.mdc.service.impl; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.jeecg.modules.mdc.entity.MdcProduction; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.mdc.mapper.MdcUserProductionMapper; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcProductionService; -import org.jeecg.modules.mdc.service.IMdcUserProductionService; -import org.jeecg.modules.system.entity.SysUser; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; - -/** - * @Description: 鐢ㄦ埛浜х嚎琛� - * @author: LiuS - * @create: 2023-03-27 11:58 - */ -@Service -public class MdcUserProductionServiceImpl extends ServiceImpl<MdcUserProductionMapper, MdcUserProduction> implements IMdcUserProductionService { - - @Resource - private IMdcProductionService mdcProductionService; - - /** - * 鏍规嵁鐢ㄦ埛id鏌ヨ浜х嚎淇℃伅 - */ - @Override - public List<ProductionIdModel> queryProductionIdsOfUser(String userId) { - LambdaQueryWrapper<MdcUserProduction> queryUserPro = new LambdaQueryWrapper<>(); - LambdaQueryWrapper<MdcProduction> queryPro = new LambdaQueryWrapper<>(); - try { - queryUserPro.eq(MdcUserProduction::getUserId, userId); - List<String> proIdList = new ArrayList<>(); - List<ProductionIdModel> proIdModelList = new ArrayList<>(); - List<MdcUserProduction> userProList = this.list(queryUserPro); - if (userProList != null && !userProList.isEmpty()) { - for (MdcUserProduction userProduction : userProList) { - proIdList.add(userProduction.getProId()); - } - queryPro.in(MdcProduction::getId, proIdList); - List<MdcProduction> proList = mdcProductionService.list(queryPro); - if (proList != null && !proList.isEmpty()) { - for (MdcProduction mdcProduction : proList) { - proIdModelList.add(new ProductionIdModel().convertByUserProduction(mdcProduction)); - } - } - return proIdModelList; - } - } catch (Exception e) { - e.fillInStackTrace(); - } - return null; - } - - /** - * 鏍规嵁鎸囧畾鐢ㄦ埛id鏌ヨ浜х嚎id闆嗗悎 - */ - @Override - public List<String> queryProductionIdsByUserId(String userId) { - return this.baseMapper.queryProductionIdsByUserId(userId); - } - - /** - * 鏍规嵁涓�缁勮溅闂磇d鏌ヨ鐢ㄦ埛浜х嚎淇℃伅 - * @param productionIds - */ - @Override - public List<MdcUserProduction> queryByProductionIds(List<String> productionIds){ - if (!productionIds.isEmpty()){ - return super.list(new LambdaQueryWrapper<MdcUserProduction>().in(MdcUserProduction::getProId, productionIds)); - } - return null; - } - - @Override - @Transactional(rollbackFor = {Exception.class}) - public boolean removeByCollection(List<MdcUserProduction> mdcUserProductions) { - if(mdcUserProductions == null || mdcUserProductions.isEmpty()) - return false; - if(mdcUserProductions.size() == 1){ - return super.removeById(mdcUserProductions.get(0).getId()); - } - List<String> ids = new ArrayList<>(); - mdcUserProductions.forEach(item -> { - ids.add(item.getId()); - }); - return super.removeByIds(ids); - } - - /** - * 鑾峰彇宸插垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - @Override - public List<SysUser> getUserPermsByGroupId(String proId){ - return super.getBaseMapper().getUserPermsByGroupId(proId); - } - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛鍒楄〃 - * @param proId - * @return - */ - @Override - public List<SysUser> getUserNonPermsByGroupId(String proId){ - return super.getBaseMapper().getUserNonPermsByGroupId(proId); - } - - /** - * 鑾峰彇鏈垎閰嶇殑鐢ㄦ埛 - * @param proId - * @return - */ - @Override - public List<SysUser> getUserNonPermsByDeviceId(String proId){ - return super.getBaseMapper().getUserNonPermsByDeviceId(proId); - } - - @Override - public List<SysUser> getUserPermsByDeviceId(String proId) { - return super.getBaseMapper().getUserPermsByDeviceId(proId); - } - - /** - * 閫氳繃杞﹂棿id涓庡矖浣峣d绛涢�夌敤鎴� - * @param post - * @param proId - * @return - */ - @Override - public List<SysUser> queryByPostAndProId(String post, String proId){ - return super.getBaseMapper().queryByPostAndProId(post, proId); - } - - @Override - public MdcUserProduction getByUserIdAndGroupId(String userId, String proId){ - if(StrUtil.isEmpty(userId) || StrUtil.isEmpty(proId)) - return null; - List<MdcUserProduction> list = super.lambdaQuery().eq(MdcUserProduction::getUserId, userId).eq(MdcUserProduction::getProId, proId).list(); - if(list == null || list.isEmpty()) - return null; - return list.get(0); - } -} diff --git a/src/main/java/org/jeecg/modules/system/controller/SysUserController.java b/src/main/java/org/jeecg/modules/system/controller/SysUserController.java index 9cc6fdd..d0ff657 100644 --- a/src/main/java/org/jeecg/modules/system/controller/SysUserController.java +++ b/src/main/java/org/jeecg/modules/system/controller/SysUserController.java @@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import liquibase.pro.packaged.I; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.shiro.SecurityUtils; @@ -31,8 +30,6 @@ import org.jeecg.modules.base.service.BaseCommonService; import org.jeecg.modules.base.service.IUserFactoryService; import org.jeecg.modules.base.service.IUserGroupService; -import org.jeecg.modules.mdc.model.ProductionIdModel; -import org.jeecg.modules.mdc.service.IMdcUserProductionService; import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.model.DepartIdModel; import org.jeecg.modules.base.model.FactoryIdModel; @@ -108,8 +105,8 @@ @Resource private IUserFactoryService userFactoryService; - @Resource - private IMdcUserProductionService userProductionService; +// @Resource +// private IMdcUserProductionService userProductionService; @Resource private IUserGroupService userGroupService; diff --git a/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java b/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java index b38d527..1fd0c21 100644 --- a/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java +++ b/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; -import org.apache.catalina.User; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CacheConstant; @@ -24,8 +23,6 @@ import org.jeecg.modules.base.entity.UserFactory; import org.jeecg.modules.base.mapper.UserFactoryMapper; import org.jeecg.modules.base.service.BaseCommonService; -import org.jeecg.modules.mdc.entity.MdcUserProduction; -import org.jeecg.modules.mdc.mapper.MdcUserProductionMapper; import org.jeecg.modules.system.entity.*; import org.jeecg.modules.system.mapper.*; import org.jeecg.modules.system.model.SysUserSysDepartModel; @@ -85,8 +82,8 @@ SysRoleIndexMapper sysRoleIndexMapper; @Resource UserFactoryMapper userFactoryMapper; - @Resource - MdcUserProductionMapper mdcUserProductionMapper; +// @Resource +// MdcUserProductionMapper mdcUserProductionMapper; @Resource private ISysDictService sysDictService; -- Gitblit v1.9.3