|
|
@ -15,6 +15,7 @@ import com.op.device.service.IDevicePDAService;
|
|
|
|
import com.op.system.api.domain.SysUser;
|
|
|
|
import com.op.system.api.domain.SysUser;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
@ -537,14 +538,23 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
|
|
|
|
equRepairWorkOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
equRepairWorkOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
//维修中
|
|
|
|
//维修中
|
|
|
|
equRepairWorkOrder.setWorkStatus("2");
|
|
|
|
equRepairWorkOrder.setWorkStatus("2");
|
|
|
|
|
|
|
|
//维修工单里面的设备名 简化TODO
|
|
|
|
|
|
|
|
EquRepairWorkOrder list = equRepairWorkOrderMapper.selectEquRepairWorkOrderByWorkId(equRepairWorkOrder.getWorkId());
|
|
|
|
|
|
|
|
//修改设备状态 改为维修中
|
|
|
|
|
|
|
|
EquEquipment equEquipment = new EquEquipment();
|
|
|
|
|
|
|
|
equEquipment.setEquipmentCode(list.getEquipmentCode());
|
|
|
|
|
|
|
|
equEquipment.setEquipmentStatus("2");
|
|
|
|
|
|
|
|
equRepairWorkOrderMapper.updateEquipmentStatus(equEquipment);
|
|
|
|
|
|
|
|
|
|
|
|
equRepairWorkOrderMapper.updateEquRepairWorkOrder(equRepairWorkOrder);
|
|
|
|
equRepairWorkOrderMapper.updateEquRepairWorkOrder(equRepairWorkOrder);
|
|
|
|
return success("提交成功,开始维修!");
|
|
|
|
return success("提交成功,设备开始维修!");
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
return error();
|
|
|
|
return error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 查询设备
|
|
|
|
* @param equipmentId
|
|
|
|
* @param equipmentId
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -617,117 +627,148 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
|
|
|
|
* @param equRepairWorkOrder
|
|
|
|
* @param equRepairWorkOrder
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Transactional//增加事务注解,出错时自动回滚
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@DS("#header.poolName")
|
|
|
|
@DS("#header.poolName")
|
|
|
|
public AjaxResult updateMaintenanceRecords(EquRepairWorkOrder equRepairWorkOrder) {
|
|
|
|
public AjaxResult updateMaintenanceRecords(EquRepairWorkOrder equRepairWorkOrder) {
|
|
|
|
//判断是否停机
|
|
|
|
try {
|
|
|
|
EquRepairWorkOrder list = equRepairWorkOrderMapper.selectEquRepairWorkOrderByWorkId(equRepairWorkOrder.getWorkId());
|
|
|
|
//判断是否停机
|
|
|
|
if (list.getWorkDownMachine().equals("1")) {
|
|
|
|
EquRepairWorkOrder list = equRepairWorkOrderMapper.selectEquRepairWorkOrderByWorkId(equRepairWorkOrder.getWorkId());
|
|
|
|
//维修结束时间、维修真正停机时间
|
|
|
|
if (list.getWorkDownMachine().equals("1")) {
|
|
|
|
equRepairWorkOrder.setActualDownEndTime(DateUtils.getNowDate());
|
|
|
|
//维修真正停机时间
|
|
|
|
}
|
|
|
|
equRepairWorkOrder.setActualDownEndTime(DateUtils.getNowDate());
|
|
|
|
equRepairWorkOrder.setWorkEndTime(DateUtils.getNowDate());
|
|
|
|
}
|
|
|
|
//更新每一项点检/巡检检查项信息
|
|
|
|
//维修工单结束时间
|
|
|
|
List<EquOrder> checkLists = equRepairWorkOrder.getDetailList();
|
|
|
|
equRepairWorkOrder.setWorkEndTime(DateUtils.getNowDate());
|
|
|
|
for (EquOrder checkList : checkLists) {
|
|
|
|
|
|
|
|
checkList.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
////更新每一项点检/巡检检查项信息
|
|
|
|
checkList.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
//判空
|
|
|
|
List<EquOrderStandard> standardLists = checkList.getStandardList();
|
|
|
|
if(StringUtils.isNotEmpty(equRepairWorkOrder.getDetailList())){
|
|
|
|
for (EquOrderStandard standardList : standardLists) {
|
|
|
|
List<EquOrder> checkLists = equRepairWorkOrder.getDetailList();
|
|
|
|
//先删除每个检查项标准图片
|
|
|
|
for (EquOrder checkList : checkLists) {
|
|
|
|
equOrderStandardMapper.deleteBaseFileBySourceId(standardList.getId());
|
|
|
|
checkList.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
//图片
|
|
|
|
checkList.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
if (StringUtils.isNotEmpty(standardList.getPicturePath())) {
|
|
|
|
List<EquOrderStandard> standardLists = checkList.getStandardList();
|
|
|
|
String[] ids = standardList.getPicturePath().split(",");
|
|
|
|
for (EquOrderStandard standardList : standardLists) {
|
|
|
|
List<BaseFileData> files = new ArrayList<>();
|
|
|
|
//先删除每个检查项标准图片
|
|
|
|
BaseFileData file = null;
|
|
|
|
equOrderStandardMapper.deleteBaseFileBySourceId(standardList.getId());
|
|
|
|
for (String id : ids) {
|
|
|
|
//图片批量新增
|
|
|
|
file = new BaseFileData();
|
|
|
|
if (StringUtils.isNotEmpty(standardList.getPicturePath())) {
|
|
|
|
file.setFileId(IdUtils.fastSimpleUUID());
|
|
|
|
String[] ids = standardList.getPicturePath().split(",");
|
|
|
|
file.setFileName(id.split("&fileName=")[1]);
|
|
|
|
List<BaseFileData> files = new ArrayList<>();
|
|
|
|
file.setFileAddress(id);
|
|
|
|
BaseFileData file = null;
|
|
|
|
file.setSourceId(standardList.getId());
|
|
|
|
for (String id : ids) {
|
|
|
|
file.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
file = new BaseFileData();
|
|
|
|
file.setCreateTime(new Date());
|
|
|
|
file.setFileId(IdUtils.fastSimpleUUID());
|
|
|
|
//维修后
|
|
|
|
file.setFileName(id.split("&fileName=")[1]);
|
|
|
|
file.setImageType("4");
|
|
|
|
file.setFileAddress(id);
|
|
|
|
files.add(file);
|
|
|
|
file.setSourceId(standardList.getId());
|
|
|
|
|
|
|
|
file.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
file.setCreateTime(new Date());
|
|
|
|
|
|
|
|
//图片类型 维修后
|
|
|
|
|
|
|
|
file.setImageType("4");
|
|
|
|
|
|
|
|
files.add(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
equOrderStandardMapper.insertBaseFileBatch(files);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
standardList.setRepairReach(standardList.getDetailReach());
|
|
|
|
|
|
|
|
standardList.setRepairValue(standardList.getActualValue());
|
|
|
|
|
|
|
|
standardList.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
standardList.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
equOrderStandardMapper.updateActualValues(standardList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
equOrderStandardMapper.insertBaseFileBatch(files);
|
|
|
|
equOrderMapper.updateEquOrder(checkList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
standardList.setRepairReach(standardList.getDetailReach());
|
|
|
|
|
|
|
|
standardList.setRepairValue(standardList.getActualValue());
|
|
|
|
|
|
|
|
standardList.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
standardList.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
equOrderStandardMapper.updateActualValues(standardList);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
equOrderMapper.updateEquOrder(checkList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//新建申领单
|
|
|
|
////新建申领单
|
|
|
|
List<EquSpareApply> equSpareApplies = equRepairWorkOrder.getApplyList();
|
|
|
|
//判空
|
|
|
|
for (EquSpareApply equSpareApply : equSpareApplies) {
|
|
|
|
if(StringUtils.isNotEmpty(equRepairWorkOrder.getApplyList())){
|
|
|
|
//生成领料单code
|
|
|
|
List<EquSpareApply> equSpareApplies = equRepairWorkOrder.getApplyList();
|
|
|
|
String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber());
|
|
|
|
for (EquSpareApply equSpareApply : equSpareApplies) {
|
|
|
|
String code = DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + equRepairWorkOrder.getWorkCode().substring(10);
|
|
|
|
//生成领料单code
|
|
|
|
//十五位单号
|
|
|
|
String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber());
|
|
|
|
equSpareApply.setApplyCode("AW" + code + serialNum);
|
|
|
|
String code = DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + equRepairWorkOrder.getWorkCode().substring(10);
|
|
|
|
equSpareApply.setApplyId(IdUtils.fastSimpleUUID());
|
|
|
|
//十五位单号
|
|
|
|
//备品备件规格型号!!!!!
|
|
|
|
equSpareApply.setApplyCode("AW" + code + serialNum);
|
|
|
|
// equSpareApply.setSpareModel(equSpareApply.getS);
|
|
|
|
equSpareApply.setApplyId(IdUtils.fastSimpleUUID());
|
|
|
|
equSpareApply.setSpareCode(equSpareApply.getMaterialCode());
|
|
|
|
//备品备件规格型号!!!!!
|
|
|
|
equSpareApply.setSpareName(equSpareApply.getMaterialDesc());
|
|
|
|
//equSpareApply.setSpareModel(equSpareApply.getSpareMode());
|
|
|
|
equSpareApply.setApplyPeople(SecurityUtils.getUsername());
|
|
|
|
//备件编码
|
|
|
|
equSpareApply.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
equSpareApply.setSpareCode(equSpareApply.getMaterialCode());
|
|
|
|
equSpareApply.setCreateTime(DateUtils.getNowDate());
|
|
|
|
//备件名称
|
|
|
|
equSpareApply.setApplyTime(DateUtils.getNowDate());
|
|
|
|
equSpareApply.setSpareName(equSpareApply.getMaterialDesc());
|
|
|
|
equSpareApply.setSpareUseEquipment(equRepairWorkOrder.getEquipmentCode());
|
|
|
|
//申领人
|
|
|
|
equSpareApply.setWorkCode(equRepairWorkOrder.getWorkCode());
|
|
|
|
equSpareApply.setApplyPeople(SecurityUtils.getUsername());
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
equSpareApply.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
String key = "#header.poolName";
|
|
|
|
equSpareApply.setCreateTime(DateUtils.getNowDate());
|
|
|
|
equSpareApply.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_", ""));
|
|
|
|
//申领时间
|
|
|
|
equSpareApplyMapper.insertEquSpareApply(equSpareApply);
|
|
|
|
equSpareApply.setApplyTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
//使用设备
|
|
|
|
//更新完备品申领单后,更新库存
|
|
|
|
equSpareApply.setSpareUseEquipment(equRepairWorkOrder.getEquipmentCode());
|
|
|
|
SparePartsLedger sparePartsLedger = new SparePartsLedger();
|
|
|
|
//关联维修工单号
|
|
|
|
sparePartsLedger.setStorageId(equSpareApply.getStorageId());
|
|
|
|
equSpareApply.setWorkCode(equRepairWorkOrder.getWorkCode());
|
|
|
|
BigDecimal applyNum = equSpareApply.getSpareQuantity();
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
|
BigDecimal amount = equSpareApply.getAmount();
|
|
|
|
String key = "#header.poolName";
|
|
|
|
sparePartsLedger.setAmount(amount.subtract(applyNum));
|
|
|
|
//工厂号
|
|
|
|
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
|
|
|
|
equSpareApply.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_", ""));
|
|
|
|
}
|
|
|
|
equSpareApplyMapper.insertEquSpareApply(equSpareApply);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////更新完备品申领单后,更新库存
|
|
|
|
|
|
|
|
SparePartsLedger sparePartsLedger = new SparePartsLedger();
|
|
|
|
|
|
|
|
sparePartsLedger.setStorageId(equSpareApply.getStorageId());
|
|
|
|
|
|
|
|
BigDecimal applyNum = equSpareApply.getSpareQuantity();
|
|
|
|
|
|
|
|
BigDecimal amount = equSpareApply.getAmount();
|
|
|
|
|
|
|
|
//减去库存
|
|
|
|
|
|
|
|
sparePartsLedger.setAmount(amount.subtract(applyNum));
|
|
|
|
|
|
|
|
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//图片
|
|
|
|
////增加多个维修后照片
|
|
|
|
//先删除每个维修工单对应图片
|
|
|
|
//先删除每个维修工单对应图片
|
|
|
|
equRepairWorkOrderMapper.deleteBaseFileBySourceId(equRepairWorkOrder.getWorkId());
|
|
|
|
equRepairWorkOrderMapper.deleteBaseFileBySourceId(equRepairWorkOrder.getWorkId());
|
|
|
|
if (StringUtils.isNotEmpty(equRepairWorkOrder.getFileList())) {
|
|
|
|
if (StringUtils.isNotEmpty(equRepairWorkOrder.getFileList())) {
|
|
|
|
String[] ids = equRepairWorkOrder.getFileList().split(",");
|
|
|
|
String[] ids = equRepairWorkOrder.getFileList().split(",");
|
|
|
|
List<BaseFileData> files = new ArrayList<>();
|
|
|
|
List<BaseFileData> files = new ArrayList<>();
|
|
|
|
BaseFileData file = null;
|
|
|
|
BaseFileData file = null;
|
|
|
|
for (String id : ids) {
|
|
|
|
for (String id : ids) {
|
|
|
|
file = new BaseFileData();
|
|
|
|
file = new BaseFileData();
|
|
|
|
file.setFileId(IdUtils.fastSimpleUUID());
|
|
|
|
file.setFileId(IdUtils.fastSimpleUUID());
|
|
|
|
file.setFileName(id.split("&fileName=")[1]);
|
|
|
|
file.setFileName(id.split("&fileName=")[1]);
|
|
|
|
file.setFileAddress(id);
|
|
|
|
file.setFileAddress(id);
|
|
|
|
file.setSourceId(equRepairWorkOrder.getWorkId());
|
|
|
|
file.setSourceId(equRepairWorkOrder.getWorkId());
|
|
|
|
file.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
file.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
file.setCreateTime(new Date());
|
|
|
|
file.setCreateTime(new Date());
|
|
|
|
//维修后
|
|
|
|
//维修后
|
|
|
|
file.setImageType("4");
|
|
|
|
file.setImageType("4");
|
|
|
|
files.add(file);
|
|
|
|
files.add(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
equRepairWorkOrderMapper.insertBaseFileBatch(files);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
equRepairWorkOrderMapper.insertBaseFileBatch(files);
|
|
|
|
|
|
|
|
|
|
|
|
////更新维修工单
|
|
|
|
|
|
|
|
//维修状态
|
|
|
|
|
|
|
|
equRepairWorkOrder.setWorkStatus("1");
|
|
|
|
|
|
|
|
//维修人
|
|
|
|
|
|
|
|
equRepairWorkOrder.setWorkPerson(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
//维修人员联系方式TODO!!!!
|
|
|
|
|
|
|
|
equRepairWorkOrder.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
equRepairWorkOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
equRepairWorkOrderMapper.updateEquRepairWorkOrder(equRepairWorkOrder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//维修工单里面的设备名 简化TODO
|
|
|
|
|
|
|
|
EquRepairWorkOrder example = equRepairWorkOrderMapper.selectEquRepairWorkOrderByWorkId(equRepairWorkOrder.getWorkId());
|
|
|
|
|
|
|
|
//修改设备状态 由维修中改为正常运行
|
|
|
|
|
|
|
|
EquEquipment equEquipment = new EquEquipment();
|
|
|
|
|
|
|
|
equEquipment.setEquipmentCode(example.getEquipmentCode());
|
|
|
|
|
|
|
|
equEquipment.setEquipmentStatus("1");
|
|
|
|
|
|
|
|
equRepairWorkOrderMapper.updateEquipmentStatus(equEquipment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return success("提交成功,维修完成!");
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
return error("提交失败!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//维修人:当前登录人
|
|
|
|
|
|
|
|
//维修状态
|
|
|
|
|
|
|
|
equRepairWorkOrder.setWorkStatus("1");
|
|
|
|
|
|
|
|
//维修结束时间
|
|
|
|
|
|
|
|
equRepairWorkOrder.setWorkPerson(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
equRepairWorkOrder.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
|
|
|
equRepairWorkOrder.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
equRepairWorkOrderMapper.updateEquRepairWorkOrder(equRepairWorkOrder);
|
|
|
|
|
|
|
|
//需要更新设备状态????这里没做
|
|
|
|
|
|
|
|
return success("提交成功,维修完成!");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|