PDA保养设置设备保养运行记录

orign^2
wws 1 year ago
parent aa95f14f67
commit df96944476

@ -3,6 +3,7 @@ package com.op.device.mapper;
import java.util.List;
import com.op.device.domain.EquOperationRecord;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@ -71,4 +72,11 @@ public interface EquOperationRecordMapper {
//设备完好率
EquOperationRecord getEquipmentIntactRate(EquOperationRecord equOperationRecord);
/**
*
* @param equipmentCode
* @return
*/
EquOperationRecord selectLastOperationRecordByEquipmentCode(String equipmentCode);
}

@ -334,6 +334,8 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
// 更新设备状态为开机
equ.setStatus("1");
equOrderMapper.updateEquipmentStatus(equ);
// 更新设备运行记录
updateOperationRecord(equOrder.getEquipmentCode(),"on","");
//上传附件
if (StringUtils.isNotEmpty(equOrder.getPicturePath())) {
String[] ids = equOrder.getPicturePath().split(",");
@ -467,12 +469,19 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
// 创建设备对象用于更新设备状态
Equipment equ = new Equipment();
equ.setEquipmentCode(order.getEquipmentCode());
// 运行记录类型
String operationType;
// 停机保养
if (pdadto.getShutDown().equals("1")){
// 更改设备状态为停机
equ.setStatus("0");
equOrderMapper.updateEquipmentStatus(equ);
operationType = "off";
}else {
operationType = "on";
}
// 更新设备运行记录
updateOperationRecord(order.getEquipmentCode(),operationType,"upkeep");
// 设置开始时间
order.setOrderStart(DateUtils.getNowDate());
@ -824,4 +833,31 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
return equEquipmentMapper.selectEquEquipmentList(equEquipment);
}
/**
*
* @param equipmentCode
* @param operationType /
* @param type /
*/
private void updateOperationRecord(String equipmentCode,String operationType,String type) {
// 设备最后一条运行记录
EquOperationRecord lastRecord = equOperationRecordMapper.selectLastOperationRecordByEquipmentCode(equipmentCode);
lastRecord.setEndTime(DateUtils.getNowDate());
lastRecord.setUpdateBy(SecurityContextHolder.getUserName());
// 更新运行记录
equOperationRecordMapper.updateEquOperationRecord(lastRecord);
// 创建新的运行记录
EquOperationRecord newRecord = new EquOperationRecord();
newRecord.setId(IdUtils.fastSimpleUUID());
newRecord.setEquipmentCode(equipmentCode);
newRecord.setStartTime(DateUtils.getNowDate());
newRecord.setType(operationType);
newRecord.setMaintenanceType(type);// 维护类型
newRecord.setParentId(lastRecord.getId());
newRecord.setFactoryCode(lastRecord.getFactoryCode());
newRecord.setCreateBy(SecurityContextHolder.getUserName());
newRecord.setCreateTime(DateUtils.getNowDate());
equOperationRecordMapper.insertEquOperationRecord(newRecord);
}
}

@ -178,5 +178,28 @@
FROM base_equipment
WHERE del_flag = '0' AND status = '1'
</select>
<select id="selectLastOperationRecordByEquipmentCode" resultType="com.op.device.domain.EquOperationRecord">
select id AS 'id',
equipment_code,
start_time,
end_time,
type,
maintenance_type,
parent_id,
factory_code,
attr1,
attr2,
attr3,
del_flag,
create_by,
create_time,
update_by,
update_time
from equ_operation_record
where id not in ( select parent_id from equ_operation_record where del_flag =
'0' ) and equipment_code =#{equipmentCode}
</select>
</mapper>

@ -359,10 +359,10 @@
</update>
<update id="updateEquipmentStatus">
update base_equipment be
set be.status = #{status}
where be.equipmentCode = #{equipmentCode}
and be.del_flag = '0'
update base_equipment
set status = #{status}
where equipment_code = #{equipmentCode}
and del_flag = '0'
</update>

Loading…
Cancel
Save