备件申领 逻辑修改

master
A0010407 1 year ago
parent afe322e8c9
commit e3c8a23b7b

@ -86,48 +86,44 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService {
@Override
@DS("#header.poolName")
public AjaxResult insertEquSpareApply(EquSpareApply equSpareApply) {
try {
//equSpareApply.getSpareApplyLists().size() 是在维修申领备件的时候进行的操作 批量新增
if(equSpareApply.getSpareApplyLists().size() >= 1){
List<EquSpareApply> list = equSpareApply.getSpareApplyLists();
for(EquSpareApply applyList:list){
applyList.setApplyId(IdUtils.fastSimpleUUID());
//生成领料单code //申领单号
String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber());
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);
if(equSpareApply.getSpareApplyLists() != null){
List<EquSpareApply> list = equSpareApply.getSpareApplyLists();
for(EquSpareApply applyList:list){
applyList.setApplyId(IdUtils.fastSimpleUUID());
String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber());
if(applyList.getWorkCode() != null){
String code = applyList.getWorkCode();
applyList.setApplyCode("AW" + code.substring(2) + serialNum);
}
}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());
String serialNum = String.format("%03d", equSpareApplyMapper.selectSerialNumber());
if(equSpareApply.getWorkCode().length() == 12){
//生成领料单code 十五位单号
equSpareApply.setApplyCode("A" + equSpareApply.getWorkCode() + serialNum);
}else if(equSpareApply.getWorkCode().length() > 12){
equSpareApply.setApplyCode("AW" + equSpareApply.getWorkCode().substring(2) + serialNum);
}else{
if(equSpareApply.getWorkCode() != null){
String code = equSpareApply.getWorkCode();
equSpareApply.setApplyCode("AW" + code.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());
@ -151,9 +147,6 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService {
sparePartsLedgerMapper.updateSparePartsLedger(sparePartsLedger);
}
return success("新增申领记录成功!");
} catch (Exception e) {
return error();
}
}
/**

Loading…
Cancel
Save