From e3c8a23b7b2cc472336d94132fdf64bb92d01875 Mon Sep 17 00:00:00 2001 From: A0010407 Date: Wed, 13 Dec 2023 22:01:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=B6=E7=94=B3=E9=A2=86=20?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/EquSpareApplyServiceImpl.java | 75 +++++++++---------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquSpareApplyServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquSpareApplyServiceImpl.java index f9a85cd9..8e17be26 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquSpareApplyServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquSpareApplyServiceImpl.java @@ -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 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 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(); - } } /**