diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/DeviceInterfaceMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/DeviceInterfaceMapper.java index 2b61c79d..a21f1edf 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/DeviceInterfaceMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/DeviceInterfaceMapper.java @@ -66,4 +66,7 @@ public interface DeviceInterfaceMapper { * @return */ List> selectEquipmentFaultNumForMonth(String groupCode); + + // 通过设备编码获取设备运行记录 + Map selectSumEquipmentOperation(String equipmentCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceInterfaceServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceInterfaceServiceImpl.java index 5788fdbe..0b9b43d8 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceInterfaceServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/DeviceInterfaceServiceImpl.java @@ -32,6 +32,8 @@ public class DeviceInterfaceServiceImpl implements IDeviceInterfaceService { private DeviceInterfaceMapper deviceInterfaceMapper; @Autowired private EquOperationRecordMapper equOperationRecordMapper; + @Autowired + private EquOperationMapper equOperationMapper; /** * 获取待维修的维修工单 @@ -64,64 +66,6 @@ public class DeviceInterfaceServiceImpl implements IDeviceInterfaceService { public AjaxResult getEquipmentInfo() { // 获取所有设备信息 List equipmentVOList = deviceInterfaceMapper.selectEquipmentList(); - for (IEquipmentVO equipmentVO : equipmentVOList) { - // 设备状态 - if (equipmentVO.getEquipmentStatus().equals("1")) { - equipmentVO.setEquipmentStatus("正常"); - } else { - equipmentVO.setEquipmentStatus("停用"); - } - - - /* 停机故障率逻辑 */ - double totalTime = 0;// 运行总时间 - double downTime = 0;// 停机时间 - // 通过设备编码获取运行记录中的运行记录List - List operationRecordList = equOperationRecordMapper.selectEquOperationRecordByEquipmentCode(equipmentVO.getEquipmentCode()); - if (operationRecordList.size() != 0) { - for (EquOperationRecord operationRecord : operationRecordList) { - // 运行时间差值 - double diffTime = operationRecord.getEndTime().getTime() - operationRecord.getStartTime().getTime(); - // 开机运行时间运行总时间累加 - if (operationRecord.getType().equals("on")) { - totalTime += diffTime; - } - // 维修停机时间累加(故障) - if (operationRecord.getMaintenanceType().equals("repair")) { - downTime += diffTime; - } - } - - // 设置停机故障率 - if (downTime == 0L) { - // 如果未查到该设备停机故障时间 - equipmentVO.setFailureRate(0D); - } else { - // 计算故障停机率(设备停机时间总和/一定时间内运行总时间(年)) - double failureRate = downTime / totalTime; - System.out.println(failureRate); - equipmentVO.setFailureRate(failureRate); - } - - } - - /* 设备有效利用率逻辑(每月) */ - // 查询该设备下报工单信息(年月日可在该sql中修改) - MesReportWork reportWork = deviceInterfaceMapper.selectReportWorkByEquipmentCode(equipmentVO.getEquipmentCode()); - if (reportWork != null) { - BigDecimal theoryQuantity = reportWork.getQuantity();// 理论产量 - BigDecimal actualQuantity = reportWork.getQuantityFeedback();// 实际产量 - - // 计算该设备有效利用率(实际产量/理论产量) - BigDecimal utilizationRatio = actualQuantity.divide(theoryQuantity, 2, BigDecimal.ROUND_HALF_UP); - equipmentVO.setUtilizationRatio(utilizationRatio.doubleValue()); - - } else { - // 如果未查到该信息,则默认设置为0 - equipmentVO.setUtilizationRatio(0D); - } - - } return success(equipmentVOList); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/DevicePDAServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/DevicePDAServiceImpl.java index 2ba20b72..b3125214 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/DevicePDAServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/DevicePDAServiceImpl.java @@ -366,7 +366,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService { equ.setStatus("1"); equOrderMapper.updateEquipmentStatus(equ); // 更新设备运行记录 - updateOperationRecord(equOrder.getEquipmentCode(),"on",""); +// updateOperationRecord(equOrder.getEquipmentCode(),"on",""); //上传附件 if (StringUtils.isNotEmpty(equOrder.getPicturePath())) { String[] ids = equOrder.getPicturePath().split(","); @@ -501,20 +501,20 @@ public class DevicePDAServiceImpl implements IDevicePDAService { Equipment equ = new Equipment(); equ.setEquipmentCode(order.getEquipmentCode()); // 运行记录类型 - String operationType; - // 停机保养 - if (pdadto.getShutDown().equals("1")){ - operationType = "off"; - }else { - operationType = "on"; - } +// String operationType; +// // 停机保养 +// if (pdadto.getShutDown().equals("1")){ +// operationType = "off"; +// }else { +// operationType = "on"; +// } // 更改设备状态为保养中 equ.setStatus("3"); equOrderMapper.updateEquipmentStatus(equ); // 更新设备运行记录 - updateOperationRecord(order.getEquipmentCode(),operationType,"upkeep"); +// updateOperationRecord(order.getEquipmentCode(),operationType,"upkeep"); // 设置开始时间 order.setOrderStart(DateUtils.getNowDate()); diff --git a/op-modules/op-device/src/main/resources/mapper/device/DeviceInterfaceMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/DeviceInterfaceMapper.xml index 1ce66128..48089a27 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/DeviceInterfaceMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/DeviceInterfaceMapper.xml @@ -21,13 +21,22 @@ + + \ No newline at end of file