lxzn-module-mdc/src/main/java/org/jeecg/modules/board/controller/DtBoardController.java
@@ -7,6 +7,7 @@ import org.jeecg.common.api.vo.Result; import org.jeecg.modules.board.service.IDtBoardService; import org.jeecg.modules.board.vo.*; import org.jeecg.modules.mdc.vo.AndonOrderWebSocketVo; import org.jeecg.modules.system.entity.MdcProduction; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -99,5 +100,19 @@ return Result.OK(result); } @ApiOperation(value = "数字孪生看板-获取设备未处理的安灯信息", notes = "数字孪生看板-获取设备未处理的安灯信息") @GetMapping("/untreatedAndonList") public Result<?> untreatedAndonList() { List<AndonOrderWebSocketVo> result = dtBoardService.untreatedAndonList(); return Result.OK(result); } @ApiOperation(value = "数字孪生看板-获取设备状态信息", notes = "数字孪生看板-获取设备状态信息") @GetMapping("/getAllEquipmentStatus") public Result<?> getAllEquipmentStatus() { List<EquStatus> result = dtBoardService.getAllEquipmentStatus(); return Result.OK(result); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/board/service/IDtBoardService.java
@@ -1,6 +1,7 @@ package org.jeecg.modules.board.service; import org.jeecg.modules.board.vo.*; import org.jeecg.modules.mdc.vo.AndonOrderWebSocketVo; import org.jeecg.modules.system.entity.MdcProduction; import java.util.List; @@ -32,4 +33,7 @@ List<EquAndon> equAndonList(String productionId); List<AndonOrderWebSocketVo> untreatedAndonList(); List<EquStatus> getAllEquipmentStatus(); } lxzn-module-mdc/src/main/java/org/jeecg/modules/board/service/impl/DtBoardServiceImpl.java
@@ -1,7 +1,11 @@ package org.jeecg.modules.board.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringPool; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.WebsocketConst; import org.jeecg.common.system.vo.DictModel; import org.jeecg.modules.board.mapper.DtBoardMapper; import org.jeecg.modules.board.service.IDtBoardService; @@ -9,6 +13,7 @@ import org.jeecg.modules.mdc.entity.*; import org.jeecg.modules.mdc.service.*; import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.vo.AndonOrderWebSocketVo; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.jeecg.modules.system.service.ISysDictService; @@ -379,4 +384,30 @@ return result; } @Override public List<AndonOrderWebSocketVo> untreatedAndonList() { List<AndonOrderWebSocketVo> result = andonOrderService.untreatedAndonList(); return result; } @Override public List<EquStatus> getAllEquipmentStatus() { List<Equipment> equipmentList = equipmentService.list(); List<EquStatus> equStatusList = new ArrayList<>(); if (equipmentList != null && !equipmentList.isEmpty()) { for (Equipment equipment : equipmentList) { if (equipment.getOporation() == null) { equipment.setOporation(0); } EquStatus equStatus = new EquStatus(); equStatus.setEquipmentId(equipment.getEquipmentid()); equStatus.setState(equipment.getOporation()); // 通过equipmentId获取设备车间名称 String productionName = mdcProductionService.findProName(equipment.getEquipmentid()); equStatus.setPlantName(StringUtils.isNotBlank(productionName) ? productionName : StringPool.EMPTY); equStatusList.add(equStatus); } } return equStatusList; } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/AndonOrderMapper.java
@@ -15,4 +15,6 @@ public interface AndonOrderMapper extends BaseMapper<AndonOrder> { List<AndonOrder> equAndonList(@Param("equipmentIdList") List<String> equipmentIdList); List<AndonOrder> untreatedAndonList(); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/AndonOrderMapper.xml
@@ -16,4 +16,23 @@ ORDER BY create_time </select> <select id="untreatedAndonList" resultType="org.jeecg.modules.mdc.entity.AndonOrder"> SELECT ao.* FROM andon_order ao INNER JOIN ( SELECT equipment_id, MAX(create_time) AS max_create_time FROM andon_order WHERE order_status = 1 GROUP BY equipment_id) AS latest ON ao.equipment_id = latest.equipment_id AND ao.create_time = latest.max_create_time WHERE order_status = 1 ORDER BY ao.create_time </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IAndonOrderService.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.board.vo.EquAndon; import org.jeecg.modules.mdc.entity.AndonOrder; import org.jeecg.modules.mdc.vo.AndonOrderWebSocketVo; import java.util.List; @@ -17,4 +18,6 @@ void procedureCall(AndonOrder andonOrder); List<EquAndon> equAndonList(List<String> equipmentIdList); List<AndonOrderWebSocketVo> untreatedAndonList(); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/AndonOrderServiceImpl.java
@@ -2,6 +2,8 @@ import cn.hutool.core.date.DatePattern; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.compress.utils.Lists; @@ -19,6 +21,7 @@ import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.vo.AndonOrderWebSocketVo; import org.jeecg.modules.message.websocket.WebSocket; import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.service.ISysDictService; import org.jeecg.modules.system.service.ISysUserService; import org.springframework.stereotype.Service; @@ -118,4 +121,33 @@ } return result; } @Override public List<AndonOrderWebSocketVo> untreatedAndonList() { List<AndonOrderWebSocketVo> result = new ArrayList<>(); List<AndonOrder> andonOrderList = this.baseMapper.untreatedAndonList(); if (andonOrderList != null && !andonOrderList.isEmpty()) { List<String> equipmentIds = andonOrderList.stream().map(AndonOrder::getEquipmentId).collect(Collectors.toList()); List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(equipmentIds); Map<String, MdcEquProDto> equipmentIdToProductionIdMap = CollectionUtils.isNotEmpty(equipmentList) ? equipmentList.stream().collect(Collectors.toMap(MdcEquProDto::getEquipmentId, comRateDto -> comRateDto)) : new HashMap<>(); andonOrderList.forEach(andonOrder -> { AndonOrderWebSocketVo andonOrderWebSocketVo = new AndonOrderWebSocketVo(); andonOrderWebSocketVo.setEquipmentId(andonOrder.getEquipmentId()); andonOrderWebSocketVo.setCallPersonnel(userService.getById(andonOrder.getOperator()).getRealname()); andonOrderWebSocketVo.setCallTime(DateUtils.format(andonOrder.getOperateTime(), DatePattern.NORM_DATE_PATTERN)); andonOrderWebSocketVo.setCallReason(andonOrder.getCallReason()); andonOrderWebSocketVo.setAndonType("程序呼叫"); andonOrderWebSocketVo.setPersonResponsible(userService.getById(andonOrder.getResponder()).getRealname()); andonOrderWebSocketVo.setRepairTime(StringPool.EMPTY); andonOrderWebSocketVo.setFaultInfo(StringPool.EMPTY); andonOrderWebSocketVo.setType("open"); andonOrderWebSocketVo.setPlantName(equipmentIdToProductionIdMap != null && equipmentIdToProductionIdMap.containsKey(andonOrder.getEquipmentId()) ? equipmentIdToProductionIdMap.get(andonOrder.getEquipmentId()).getProductionName() : null); result.add(andonOrderWebSocketVo); }); } return result; } }