看板接口便变更

master
wws 1 year ago
parent 4edeb71b91
commit c0614e3cf8

@ -66,4 +66,7 @@ public interface DeviceInterfaceMapper {
* @return
*/
List<Map<String, Integer>> selectEquipmentFaultNumForMonth(String groupCode);
// 通过设备编码获取设备运行记录
Map<String, Double> selectSumEquipmentOperation(String equipmentCode);
}

@ -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<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);
}

@ -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());

@ -21,13 +21,22 @@
</select>
<select id="selectEquipmentList" resultType="com.op.device.domain.vo.IEquipmentVO">
select be.equipment_code AS 'equipmentCode', be.equipment_name AS 'equipmentName',be.equipment_status AS 'equipmentStatus'
select be.equipment_code AS 'equipmentCode', be.equipment_name AS 'equipmentName',be.equipment_status AS 'equipmentStatus', (SELECT ROUND(
SUM(CAST(fault_time AS FLOAT)) /
SUM(CAST(actual_operation_time AS FLOAT)),
2)
FROM equ_operation
WHERE equipment_code = be.equipment_code) AS 'failureRate', (
SELECT ROUND(SUM(mrw.quantity_feedback) / SUM(mrw.quantity), 2)
FROM mes_report_work mrw
WHERE mrw.del_flag = '0'
AND mrw.status = 'PREPARE'
AND mrw.machine_code = be.equipment_code
AND mrw.feedback_time >= DATEADD(MONTH, -1, GETDATE())
) AS 'utilizationRatio'
from base_equipment be
where be.equipment_code in (select wo.equipment_code
from equ_repair_work_order wo
where wo.del_flag = '0'
and wo.work_status = '1'
GROUP BY wo.equipment_code)
where be.del_flag = '0'
and be.equipment_category = '0'
</select>
<select id="selectRepairEquipmentList" resultType="com.op.device.domain.vo.IEquipmentVO">
@ -114,4 +123,12 @@
ORDER BY MONTH (eo.create_time)
</select>
<select id="selectSumEquipmentOperation" resultType="java.util.Map">
SELECT
SUM(CAST(actual_operation_time AS FLOAT)) AS actualOperationTime,
SUM(CAST(fault_time AS FLOAT)) AS faultTime
FROM equ_operation
WHERE equipment_code = #{equipmentCode};
</select>
</mapper>
Loading…
Cancel
Save