|
|
@ -32,6 +32,8 @@ public class DeviceInterfaceServiceImpl implements IDeviceInterfaceService {
|
|
|
|
private DeviceInterfaceMapper deviceInterfaceMapper;
|
|
|
|
private DeviceInterfaceMapper deviceInterfaceMapper;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private EquOperationRecordMapper equOperationRecordMapper;
|
|
|
|
private EquOperationRecordMapper equOperationRecordMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private EquOperationMapper equOperationMapper;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取待维修的维修工单
|
|
|
|
* 获取待维修的维修工单
|
|
|
@ -64,64 +66,6 @@ public class DeviceInterfaceServiceImpl implements IDeviceInterfaceService {
|
|
|
|
public AjaxResult getEquipmentInfo() {
|
|
|
|
public AjaxResult getEquipmentInfo() {
|
|
|
|
// 获取所有设备信息
|
|
|
|
// 获取所有设备信息
|
|
|
|
List<IEquipmentVO> equipmentVOList = deviceInterfaceMapper.selectEquipmentList();
|
|
|
|
List<IEquipmentVO> 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<EquOperationRecord> 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);
|
|
|
|
return success(equipmentVOList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|