| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | |
| | | /** |
| | | * @ClassName LWhFormInventoryCoreService |
| | | |
| | | * @Date 2023/11/1 |
| | | * @Description |
| | | * @Version 1.0 |
| | | **/ |
| | | @Slf4j |
| | | @Service |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public class LWhFormInventoryCoreService { |
| | | |
| | | private LWhFormInventoryGoodsServiceImpl lWhFormInventoryGoods; |
| | | private LWhFormOutputCoreService lWhFormOutputCoreService; |
| | | private CodeGeneratorService codeGeneratorService; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据 盘点单 生成 出库单 和 入库单 |
| | | * 盘点单中 盘盈物品生成入库单,盘亏生成出库单 |
| | | * 根据 盘点单 生成 出库单 和 入库单 盘点单中 盘盈物品生成入库单,盘亏生成出库单 |
| | | * |
| | | * @param whformInventoryId 盘点单id |
| | | * @return status true/false |
| | | * errMsg 错误消息 |
| | | * @return status true/false errMsg 错误消息 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String createInOutFormByInventoryId(Long whformInventoryId, S_user_core currentUser, FinSysTenantUser sysInfo) { |
| | |
| | | // rtnMap.put("errMsg", "创建入库单失败"); |
| | | return "创建入库单失败"; |
| | | } |
| | | Long inFormByInventoryId = (Long) inOutMap.get("inId"); |
| | | inOutMap.putAll(rkMap); |
| | | Long inFormByInventoryId = (Long) inOutMap.get("inId"); |
| | | String errMsg = lWhFormProcureCoreService.doProcure(inFormByInventoryId, currentUser); |
| | | if (errMsg != null) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | |
| | | inOutMap.putAll(ckMap); |
| | | Long lWhFormOutputId = (Long) inOutMap.get("outId"); |
| | | //2.根据出库单出库 |
| | | Long lWarehouseFlowId = lWhFormOutputCoreService.outFormByTransId(lWhFormOutputId, currentUser, stopTime); |
| | | Long lWarehouseFlowId = lWhFormOutputCoreService.outFormByTransId(lWhFormOutputId, WhBusinessEnum.PANDIAN, currentUser, stopTime); |
| | | if (lWarehouseFlowId == null) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | // throw new RuntimeException("创建出库单失败"); |
| | |
| | | continue; |
| | | } |
| | | // 查询型号库存 |
| | | int goodsModelNum = lWhGoodsService.queryGoodsModelNum(0, warehouseId, baseGoodsModelsId, (short) 1, null); |
| | | int goodsModelNum = lWhGoodsService.queryGoodsModelNum(0, warehouseId, baseGoodsModelsId, 1, null); |
| | | LWhProcureModel model = new LWhProcureModel(); |
| | | model.setId(NumberGenerator.getLongSequenceNumber()); |
| | | model.setFromProcureGoodsId(fromProcureGoodsId); |
| | |
| | | //出入库id |
| | | long lWhFormOutputId = IdUtil.generateId(); |
| | | lWhFormOutput.setId(lWhFormOutputId); |
| | | lWhFormOutput.setOutWarehouseType(0); |
| | | lWhFormOutput.setWarehouseId(warehouseId); |
| | | //根据仓库id查询仓库 |
| | | BaseWarehouse warehouse = this.baseWarehouseService.getById(warehouseId); |
| | |
| | | if (flag1 != 1) { |
| | | return null; |
| | | } |
| | | ArrayList<LWhProcureModel> lWhProcureModels = new ArrayList<>(); |
| | | for (LWhFormInventoryGoods inventoryGoods : inventoryGoodsList) { |
| | | Long baseGoodsModelsId = inventoryGoods.getBaseGoodsModelsId(); |
| | | Integer counts = inventoryGoods.getErrorCounts(); |
| | |
| | | continue; |
| | | } |
| | | //根据物品型号查询物品库存 |
| | | int goodsNum = lWhGoodsService.queryGoodsModelNum(0, warehouseId, baseGoodsModelsId, (short) 1, null); |
| | | int goodsNum = lWhGoodsService.queryGoodsModelNum(0, warehouseId, baseGoodsModelsId, 1, null); |
| | | //新增L_WH_PROCURE_MODEL记录 |
| | | LWhProcureModel lWhProcureModel = new LWhProcureModel(); |
| | | lWhProcureModel.setId(IdUtil.generateId()); |
| | | lWhProcureModel.setBusinessType(3); |
| | | lWhProcureModel.setBusinessType(WhBusinessEnum.CHUKU.getValue() + 0); |
| | | lWhProcureModel.setBusinessId(lWhFormOutputId); |
| | | lWhProcureModel.setBaseGoodsModelsId(baseGoodsModelsId); |
| | | lWhProcureModel.setCounts(counts); |
| | | lWhProcureModel.setWorehouseCount(goodsNum); |
| | | lWhProcureModelService.insert(lWhProcureModel); |
| | | // lWhProcureModelService.insert(lWhProcureModel); |
| | | lWhProcureModels.add(lWhProcureModel); |
| | | } |
| | | if (!CollectionUtils.isEmpty(lWhProcureModels)) { |
| | | lWhProcureModelService.insertBatch(lWhProcureModels); |
| | | } |
| | | HashMap<String, Object> rtnMap = new HashMap<>(); |
| | | rtnMap.put("outId", lWhFormOutputId); |