|
@@ -345,19 +345,10 @@ public class SparePartUsedServiceImpl extends BaseServiceImpl<SparePartUsedMappe
|
|
|
mapper.updateRecordToOld(updDTO);
|
|
|
}*/
|
|
|
// 待插入更换记录
|
|
|
- /*List<SparePartUsed> saveList = new ArrayList<>();
|
|
|
+ List<SparePartUsed> saveList = new ArrayList<>();
|
|
|
// 区分是否bom关联备件
|
|
|
for(SparePartUsedDTO sparePartUsedDTO : sparePartUsedDTOList){
|
|
|
int isSpecial = sparePartUsedDTO.getIsSpecial() == null ? 0 : sparePartUsedDTO.getIsSpecial();
|
|
|
- // 获取old id
|
|
|
- SparePartUsed oldUsed = new SparePartUsed();
|
|
|
- oldUsed.setSbId(sparePartUsedDTO.getSbId());
|
|
|
- oldUsed.setSpareId(sparePartUsedDTO.getSpareId());
|
|
|
- oldUsed.setStatus(SparePartUsedStatusEnum.IN_USE.getValue());
|
|
|
- oldUsed = mapper.selectOne(oldUsed);
|
|
|
- if(oldUsed != null){
|
|
|
- ids.add(oldUsed.getId());
|
|
|
- }
|
|
|
// 封装新增更换记录
|
|
|
SparePartUsed entity = BeanConverterUtil.copyObjectProperties(sparePartUsedDTO, SparePartUsed.class);
|
|
|
entity.setId(IdGeneratorUtils.getObjectId());
|
|
@@ -368,26 +359,17 @@ public class SparePartUsedServiceImpl extends BaseServiceImpl<SparePartUsedMappe
|
|
|
entity.setCreatedUserId(userInfo.getUserId());
|
|
|
entity.setCreatedUserName(userInfo.getRealName());
|
|
|
}
|
|
|
- LocalDate now = LocalDate.now();
|
|
|
- entity.setStartDate(now);
|
|
|
- entity.setIsSpecial(isSpecial);
|
|
|
- // 计算下次更换时间
|
|
|
- if(sparePartUsedDTO.getSparePeriod() != null && sparePartUsedDTO.getSparePeriod() > 0){
|
|
|
- entity.setChangeDate(now.plusDays(sparePartUsedDTO.getSparePeriod()));
|
|
|
+ entity.setSpareId(sparePartUsedDTO.getNo()); // 备件编码
|
|
|
+ if(entity.getStartDate() == null){
|
|
|
+ entity.setStartDate(LocalDate.now());
|
|
|
}
|
|
|
+ entity.setIsSpecial(isSpecial);
|
|
|
saveList.add(entity);
|
|
|
-
|
|
|
}
|
|
|
// 保存更换记录
|
|
|
if(saveList.size() > 0){
|
|
|
mapper.insertListforComplex(saveList);
|
|
|
}
|
|
|
- // 将之前记录修改为历史和实际更换时间
|
|
|
- if(ids.size() > 0){
|
|
|
- SparePartUsedDTO updDTO = new SparePartUsedDTO();
|
|
|
- updDTO.setTypeIds(ids);
|
|
|
- mapper.updateRecordToOld(updDTO);
|
|
|
- }*/
|
|
|
}
|
|
|
|
|
|
@Override
|