备件申领 逻辑修改

master
A0010407 1 year ago
parent afe322e8c9
commit e3c8a23b7b

@ -86,48 +86,44 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService {
@Override @Override
@DS("#header.poolName") @DS("#header.poolName")
public AjaxResult insertEquSpareApply(EquSpareApply equSpareApply) { public AjaxResult insertEquSpareApply(EquSpareApply equSpareApply) {
try { if(equSpareApply.getSpareApplyLists() != null){
//equSpareApply.getSpareApplyLists().size() 是在维修申领备件的时候进行的操作 批量新增 List<EquSpareApply> list = equSpareApply.getSpareApplyLists();
if(equSpareApply.getSpareApplyLists().size() >= 1){ for(EquSpareApply applyList:list){
List<EquSpareApply> list = equSpareApply.getSpareApplyLists(); applyList.setApplyId(IdUtils.fastSimpleUUID());
for(EquSpareApply applyList:list){ String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber());
applyList.setApplyId(IdUtils.fastSimpleUUID()); if(applyList.getWorkCode() != null){
//生成领料单code //申领单号 String code = applyList.getWorkCode();
String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber()); applyList.setApplyCode("AW" + code.substring(2) + serialNum);
String code = DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + applyList.getWorkCode().substring(2);
//申领单号
equSpareApply.setApplyCode("AW" + code + serialNum);
//领用时间
applyList.setApplyTime(DateUtils.getNowDate());
//申领人
applyList.setApplyPeople(SecurityUtils.getUsername());
//工厂号
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
applyList.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
//创建人、创建时间
applyList.setCreateTime(DateUtils.getNowDate());
applyList.setCreateBy(SecurityUtils.getUsername());
equSpareApplyMapper.insertEquSpareApply(applyList);
//更新完备品申领单后,更新库存
SparePartsLedger sparePartsLedger = new SparePartsLedger();
sparePartsLedger.setStorageId(applyList.getStorageId());
BigDecimal applyNum = applyList.getSpareQuantity();
BigDecimal amount = applyList.getAmount();
sparePartsLedger.setAmount(amount.subtract(applyNum));
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
} }
}else{ //领用时间
applyList.setApplyTime(DateUtils.getNowDate());
//申领人
applyList.setApplyPeople(SecurityUtils.getUsername());
//工厂号
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
applyList.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
//创建人、创建时间
applyList.setCreateTime(DateUtils.getNowDate());
applyList.setCreateBy(SecurityUtils.getUsername());
equSpareApplyMapper.insertEquSpareApply(applyList);
//更新完备品申领单后,更新库存
SparePartsLedger sparePartsLedger = new SparePartsLedger();
sparePartsLedger.setStorageId(applyList.getStorageId());
BigDecimal applyNum = applyList.getSpareQuantity();
BigDecimal amount = applyList.getAmount();
sparePartsLedger.setAmount(amount.subtract(applyNum));
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}
}else if(equSpareApply.getSpareApplyLists() == null){
equSpareApply.setApplyId(IdUtils.fastSimpleUUID()); equSpareApply.setApplyId(IdUtils.fastSimpleUUID());
String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber()); String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber());
if(equSpareApply.getWorkCode().length() == 12){ if(equSpareApply.getWorkCode() != null){
//生成领料单code 十五位单号 String code = equSpareApply.getWorkCode();
equSpareApply.setApplyCode("A" + equSpareApply.getWorkCode() + serialNum); equSpareApply.setApplyCode("AW" + code.substring(2) + serialNum);
}else if(equSpareApply.getWorkCode().length() > 12){ } else{
equSpareApply.setApplyCode("AW" + equSpareApply.getWorkCode().substring(2) + serialNum);
}else{
//普通申领单 //普通申领单
equSpareApply.setApplyCode("AN" + DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + equSpareApply.getSpareUseEquipment() + serialNum); equSpareApply.setApplyCode("AW" + DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + equSpareApply.getSpareUseEquipment() + serialNum);
} }
//领用时间 //领用时间
equSpareApply.setApplyTime(DateUtils.getNowDate()); equSpareApply.setApplyTime(DateUtils.getNowDate());
@ -151,9 +147,6 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService {
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger); sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
} }
return success("新增申领记录成功!"); return success("新增申领记录成功!");
} catch (Exception e) {
return error();
}
} }
/** /**

Loading…
Cancel
Save