| | |
| | | |
| | | @Autowired |
| | | public LWhFormOutputCoreService(BaseGoodsTemplateServiceImpl baseGoodsTemplateService, |
| | | LWhGoodsService lWhGoodsService, |
| | | CodeGeneratorService codeGeneratorService, |
| | | LWhProcureModelService lWhProcureModelService, |
| | | LWhFormOutputService lWhFormOutputService, |
| | | LWarehouseFlowService lWarehouseFlowService, |
| | | LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, |
| | | LWhGoodsRecordService lWhGoodsRecordService) { |
| | | LWhGoodsService lWhGoodsService, |
| | | CodeGeneratorService codeGeneratorService, |
| | | LWhProcureModelService lWhProcureModelService, |
| | | LWhFormOutputService lWhFormOutputService, |
| | | LWarehouseFlowService lWarehouseFlowService, |
| | | LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, |
| | | LWhGoodsRecordService lWhGoodsRecordService) { |
| | | this.baseGoodsTemplateService = baseGoodsTemplateService; |
| | | this.lWhGoodsService = lWhGoodsService; |
| | | this.codeGeneratorService = codeGeneratorService; |
| | |
| | | |
| | | //通过LockManage获得锁 |
| | | Object warehouseModelLockObj = LockManage.acquireLock(outWarehouseType, outWarehouseId, baseGoodsModelsId); |
| | | List<Long> outGoodsId = null; |
| | | synchronized (warehouseModelLockObj) { |
| | | // 获得锁后查询该型号的期初数量 |
| | | int goodsModelNum = lWhGoodsService.queryGoodsModelNum(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType); |
| | |
| | | whGoodsRecord.setEndCount(goodsModelNum - counts); |
| | | |
| | | //出库时候,按 先入库的先出库,同时入库的,按价格高的先出库 |
| | | List<Long> outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType, |
| | | outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType, |
| | | counts); |
| | | lWhGoodsService.modGoodsTransfering(outGoodsId, inWarehouseType, inWarehouseId, inWarehouseName, modGoodsTransferingStatus); |
| | | // 批量插入 进出库流水明细[L_WH_GOODS_RECORD_DETAILS] |
| | | lWhGoodsRecordDetailsService.sameGoodsInsertMore(outGoodsId, whGoodsRecordId, (short) 0); |
| | | lWhGoodsRecordService.insert(whGoodsRecord); |
| | | } |
| | | long totalAmount = lWhGoodsService.queryGoodsPriceById(outGoodsId); |
| | | LWhProcureModel lWhProcureModel = new LWhProcureModel(itemModelInfo.getId()); |
| | | lWhProcureModel.setTotalAmount(totalAmount); |
| | | lWhProcureModelService.update(lWhProcureModel); |
| | | }); |
| | | LWarehouseFlow warehouseFlow = new LWarehouseFlow(); |
| | | warehouseFlow.setId(lWarehouseFlowId); |
| | |
| | | import com.consum.model.po.LWhGoods; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @ClassName LWhGoodsService |
| | |
| | | private static String QUERY_OUT_GOODS_ID = "SELECT * FROM L_WH_GOODS WHERE 1=1"; |
| | | |
| | | public List<Map<String, Object>> queryOutGoods(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, Short states, Short buyType, |
| | | Integer goodsModelNum) { |
| | | Integer goodsModelNum) { |
| | | StringBuilder sql = new StringBuilder(QUERY_OUT_GOODS_ID); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | if (warehouseType != null) { |
| | |
| | | return whGoodsIds; |
| | | } |
| | | |
| | | private static String QUERY_GOODS_PRICE_BY_ID = "SELECT sum(PRICE)totalPrice from L_WH_GOODS goods where 1=1"; |
| | | |
| | | public long queryGoodsPriceById(List<Long> goodsIds) { |
| | | StringBuilder sql = new StringBuilder(QUERY_GOODS_PRICE_BY_ID); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(goodsIds)) { |
| | | sql.append(" and id in(:goodsIds)"); |
| | | paramts.put("goodsIds", goodsIds); |
| | | } |
| | | List<Map<String, Object>> map = this.select(sql.toString(), paramts); |
| | | if (CollectionUtils.isEmpty(map)) { |
| | | return 0; |
| | | } |
| | | BigDecimal totalPrice = (BigDecimal) map.get(0).get("totalPrice"); |
| | | return totalPrice.longValue(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询报废物品 默认优先报废最高价的物品 |
| | |
| | | private static String QUERY_SCRAPPED_GOODS_END = " ORDER BY goods.PRICE DESC,goods.PROCURE_DATE ASC,goods.id"; |
| | | |
| | | public List<Map<String, Object>> queryScrappedGoods(Integer warehouseType, |
| | | Long warehouseId, |
| | | Long transBusinessId, |
| | | String nowUserName, |
| | | Long baseGoodsModelsId, |
| | | Short states, |
| | | Integer goodsModelNum) { |
| | | Long warehouseId, |
| | | Long transBusinessId, |
| | | String nowUserName, |
| | | Long baseGoodsModelsId, |
| | | Short states, |
| | | Integer goodsModelNum) { |
| | | if (warehouseType == null) { |
| | | warehouseType = 0; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public List<Long> queryScrappedGoodsIds(Integer warehouseType, |
| | | Long warehouseId, |
| | | Long transBusinessId, |
| | | String nowUserName, |
| | | Long baseGoodsModelsId, |
| | | Short states, |
| | | Integer goodsModelNum) { |
| | | Long warehouseId, |
| | | Long transBusinessId, |
| | | String nowUserName, |
| | | Long baseGoodsModelsId, |
| | | Short states, |
| | | Integer goodsModelNum) { |
| | | List<Map<String, Object>> outGoods = queryScrappedGoods(warehouseType, warehouseId, transBusinessId, nowUserName, baseGoodsModelsId, states, |
| | | goodsModelNum); |
| | | goodsModelNum); |
| | | if (CollectionUtils.isEmpty(outGoods)) { |
| | | return null; |
| | | } |