lxzn-boot-base-core/src/main/java/org/jeecg/common/system/vo/LoginUser.java
@@ -51,6 +51,10 @@ */ private String orgCode; /** * ç¨æ·ç±»å */ private Integer userType; /** * 头å */ @SensitiveField lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/constant/MdcConstant.java
@@ -75,4 +75,12 @@ public static final String MSG_STATUS_2 = "2"; public static final String MSG_STATUS_3 = "3"; /** * ç¨æ·ç±»å(1 æ®éæå 2 工段 3 è½¦é´ 4 å ¬å¸ï¼ */ public static final Integer USER_TYPE_1 = 1; public static final Integer USER_TYPE_2 = 2; public static final Integer USER_TYPE_3 = 3; public static final Integer USER_TYPE_4 = 4; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcHomeController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,66 @@ 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.service.IMdcEquipmentService; import org.jeecg.modules.mdc.vo.MdcCommonVo; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; /** * @author Lius * @Description: MDCé¦é¡µæ¥å£ * @date 2024/3/13 14:27 */ @Slf4j @Api(tags = "MDCé¦é¡µæ¥å£") @RestController @RequestMapping("/mdc/home") public class MdcHomeController { @Resource private IMdcEquipmentService mdcEquipmentService; @Resource private IMdcProductionService mdcProductionService; @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()); } } List<MdcCommonVo> resultMap = mdcEquipmentService.getEquipmentStatusStatistics(userId, key); return Result.OK(resultMap); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java
@@ -9,6 +9,7 @@ import org.jeecg.modules.mdc.dto.MdcEquDepDto; import org.jeecg.modules.mdc.dto.MdcEquProDto; import org.jeecg.modules.mdc.dto.MdcEquipmentDto; import org.jeecg.modules.mdc.entity.EquipmentLog; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor; import org.jeecg.modules.mdc.vo.MdcEquipmentDepVo; @@ -116,4 +117,6 @@ */ @InterceptorIgnore(tenantLine = "1") MdcEquipmentDto findWorkLineLast(@Param("tableName") String tableName); List<EquipmentLog> getEquipmentStatusList(@Param("equipmentIdList") List<String> equipmentIdList); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml
@@ -286,4 +286,20 @@ select top 1 spindlespeed, actualspindlespeed from [${tableName}] order by CollectTime desc </select> <!--æ¥è¯¢è®¾å¤ææ°ä¸æ¡æ°æ®--> <select id="getEquipmentStatusList" resultType="org.jeecg.modules.mdc.entity.EquipmentLog"> SELECT t1.* FROM EquipmentLog t1 INNER JOIN ( SELECT MAX ( CollectTime ) AS CollectTime, EquipmentID FROM EquipmentLog GROUP BY EquipmentID ) t2 ON t1.CollectTime= t2.CollectTime AND t1.EquipmentID= t2.EquipmentID <if test="equipmentIdList != null and equipmentIdList.size() > 0"> AND t1.EquipmentID IN <foreach collection="equipmentIdList" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> </if> </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java
@@ -9,6 +9,7 @@ import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor; import org.jeecg.modules.mdc.model.MdcEquipmentTree; import org.jeecg.modules.mdc.vo.MdcCommonVo; import org.jeecg.modules.mdc.vo.MdcEquipmentVo; import org.jeecg.modules.mdc.vo.WorkshopEquipmentVo; @@ -202,4 +203,9 @@ * @return */ MdcEquipmentDto getWorkLineLast(String tableName); /** * 设å¤è¿è¡ç¶æç»è®¡ */ List<MdcCommonVo> getEquipmentStatusStatistics(String userId, String key); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -21,10 +21,7 @@ import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.util.FindsEquipmentDepartUtil; import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil; import org.jeecg.modules.mdc.vo.MdcEquipmentDepVo; import org.jeecg.modules.mdc.vo.MdcEquipmentProVo; import org.jeecg.modules.mdc.vo.MdcEquipmentVo; import org.jeecg.modules.mdc.vo.WorkshopEquipmentVo; import org.jeecg.modules.mdc.vo.*; import org.jeecg.modules.system.entity.MdcEquipmentDepart; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.entity.MdcProductionEquipment; @@ -852,4 +849,75 @@ return this.baseMapper.findWorkLineLast(tableName); } /** * 设å¤è¿è¡ç¶æç»è®¡ */ @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(); List<String> equipmentIdList = this.getEquipmentIdsProduction(userId, key); if (equipmentIdList == null || equipmentIdList.isEmpty()) { return result; } List<EquipmentLog> logList = this.baseMapper.getEquipmentStatusList(equipmentIdList); if (logList != null && !logList.isEmpty()) { for (EquipmentLog equipmentLog : logList) { if (equipmentLog.getOporation() != null) { switch (equipmentLog.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()); result.add(mdcCommonVo5); MdcCommonVo mdcCommonVo6 = new MdcCommonVo(); mdcCommonVo6.setName("æ¥è¦"); mdcCommonVo6.setValue(mdcEquipmentStatusVo.getAlarmCount()); result.add(mdcCommonVo6); MdcCommonVo mdcCommonVo7 = new MdcCommonVo(); mdcCommonVo7.setName("å¾ æº"); mdcCommonVo7.setValue(mdcEquipmentStatusVo.getWaitCount()); result.add(mdcCommonVo7); MdcCommonVo mdcCommonVo8 = new MdcCommonVo(); mdcCommonVo8.setName("è¿è¡"); mdcCommonVo8.setValue(mdcEquipmentStatusVo.getRunCount()); result.add(mdcCommonVo8); return result; } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcCommonVo.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,13 @@ package org.jeecg.modules.mdc.vo; import lombok.Data; /** * @author Lius * @date 2024/3/13 18:02 */ @Data public class MdcCommonVo { private Integer value; private String name; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/MdcEquipmentStatusVo.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,27 @@ package org.jeecg.modules.mdc.vo; import lombok.Data; /** * @author Lius * @date 2024/3/13 15:43 */ @Data public class MdcEquipmentStatusVo { /** * è¿è¡ */ private Integer runCount = 0; /** * å ³æº */ private Integer closeCount = 0; /** * æ¥è¦ */ private Integer alarmCount = 0; /** * å¾ æº */ private Integer waitCount = 0; } lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/MdcProductionMapper.java
@@ -26,4 +26,12 @@ * é彿¥è¯¢ææåèç¹ */ List<String> recursionChildren(@Param("productionId") String productionId); /** * æ ¹æ®ç¨æ·idå车é´idè·åç¨æ·æ¥æç车é´id * @param userId * @param productionId * @return */ String findFirstProduction(@Param("userId") String userId, @Param("productionId") String productionId); } lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/MdcProductionMapper.xml
@@ -21,4 +21,9 @@ FROM temp </select> <!--æ ¹æ®ç¨æ·idå车é´idè·åç¨æ·æ¥æç车é´id--> <select id="findFirstProduction" resultType="java.lang.String"> SELECT TOP 1 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> </mapper> lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/IMdcProductionService.java
@@ -70,4 +70,12 @@ */ List<String> recursionChildren(String productionId); /** * æ ¹æ®ç¨æ·idå车é´idè·åç¨æ·æ¥æç车é´id * @param userId * @param productionId * @return */ String findFirstProduction(String userId, String productionId); } lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/MdcProductionServiceImpl.java
@@ -225,6 +225,17 @@ } /** * æ ¹æ®ç¨æ·idå车é´idè·åç¨æ·æ¥æç车é´id * @param userId * @param productionId * @return */ @Override public String findFirstProduction(String userId, String productionId) { return this.baseMapper.findFirstProduction(userId, productionId); } /** * delete æ¹æ³è°ç¨ é彿¥æ¾åéid */ private void checkChildrenExists(String id, List<String> idList) {