package com.consum.base.service.core;
|
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import com.consum.base.core.WhBusinessEnum;
|
import com.consum.base.core.type.TransferStatesType;
|
import com.consum.base.core.utils.IdUtil;
|
import com.consum.base.core.utils.LockManage;
|
import com.consum.base.service.BaseGoodsTemplateService;
|
import com.consum.base.service.GoodsBaseService;
|
import com.consum.base.service.LGoodsUserRecordServiceImpl;
|
import com.consum.base.service.LGoodsWhRecordServiceImpl;
|
import com.consum.base.service.LWarehouseFlowService;
|
import com.consum.base.service.LWhFormTransferService;
|
import com.consum.base.service.LWhGoodsRecordService;
|
import com.consum.base.service.LWhGoodsService;
|
import com.consum.base.service.LWhProcureModelService;
|
import com.consum.base.service.impl.LWhGoodsRecordDetailsService;
|
import com.consum.model.po.LGoodsUserRecord;
|
import com.consum.model.po.LWarehouseFlow;
|
import com.consum.model.po.LWhFormTransfer;
|
import com.consum.model.po.LWhGoodsRecord;
|
import com.consum.model.po.LWhGoodsRecordDetails;
|
import com.consum.model.po.LWhProcureModel;
|
import com.consum.model.po.LWhProcureModelUser;
|
import com.iplatform.model.po.S_user_core;
|
import com.walker.infrastructure.utils.CollectionUtils;
|
import com.walker.infrastructure.utils.DateUtils;
|
import com.walker.infrastructure.utils.NumberGenerator;
|
import com.walker.infrastructure.utils.StringUtils;
|
|
import cn.hutool.core.convert.Convert;
|
import lombok.extern.slf4j.Slf4j;
|
|
/**
|
* @ClassName LWhFormTransferCoreService
|
* @Date 2023/10/26
|
* @Description
|
* @Version 1.0
|
**/
|
@Service
|
@Slf4j
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
public class LWhFormTransferCoreService {
|
|
@Resource
|
private LWhFormTransferService lWhFormTransferService;
|
@Resource
|
private LWhProcureModelService lWhProcureModelService;
|
@Resource
|
private BaseGoodsTemplateService baseGoodsTemplateService;
|
|
@Resource
|
private LWhFormOutputCoreService lWhFormOutputCoreService;
|
@Resource
|
private GoodsBaseService goodsBaseService;
|
@Resource
|
private LWhGoodsRecordService lWhGoodsRecordServiceImpl;
|
@Resource
|
private LWhGoodsService lWhGoodsService;
|
@Resource
|
private LGoodsWhRecordServiceImpl lGoodsWhRecordService;
|
@Resource
|
private LWarehouseFlowService lWarehouseFlowServiceImpl;
|
@Resource
|
private LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService;
|
@Resource
|
private LGoodsUserRecordServiceImpl lGoodsUserRecordService;
|
@Resource
|
private LWhWarningCoreService lWhWarningCoreService;
|
|
/**
|
* 执行调拨出库操作
|
*
|
* @param whFormTransferId 调拨单id
|
*/
|
public void doTransferOutPut(Long whFormTransferId, S_user_core currentUser) {
|
LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(whFormTransferId);
|
lWhFormTransfer = lWhFormTransferService.get(lWhFormTransfer);
|
if (lWhFormTransfer == null || lWhFormTransfer.getStates() != 0) {
|
log.error("调拨失败!请检查调拨单状态");
|
return;
|
}
|
|
Long userId = currentUser.getId();
|
String nickName = currentUser.getNick_name();
|
long dealTime = DateUtils.getDateTimeNumber(System.currentTimeMillis());
|
// 单据类型。0仓库调拨;1部门分发;2部门物品回退
|
Integer businessType = lWhFormTransfer.getBusinessType();
|
WhBusinessEnum businessEnum;
|
if (businessType == 1) {
|
businessEnum = WhBusinessEnum.BUMENFENFA;
|
} else if (businessType == 2) {
|
businessEnum = WhBusinessEnum.BUMENTUIHUI;
|
} else {
|
businessEnum = WhBusinessEnum.DIAOBO;
|
}
|
|
// 出库单ID
|
Long outWarehouseFormId = null;
|
try {
|
// 根据调拨单 生成 出库单 这样就能公用出库
|
lWhFormTransfer.getBusinessType();
|
outWarehouseFormId =
|
lWhFormOutputCoreService.createOutFormByTransId(whFormTransferId, businessEnum, currentUser, dealTime);
|
} catch (Exception e) {
|
log.error(e.getMessage());
|
return;
|
}
|
// 出库单 出库,返回 出库单流水Id
|
Long lWarehouseFlowId = lWhFormOutputCoreService.outFormByTransId(outWarehouseFormId, businessEnum, currentUser,
|
dealTime, whFormTransferId);
|
|
// 更新调拨单
|
lWhFormTransfer = new LWhFormTransfer(whFormTransferId);
|
lWhFormTransfer.setOutWarehouseFormId(outWarehouseFormId);
|
lWhFormTransfer.setStates(1);
|
lWhFormTransfer.setOutOperatorId(userId);
|
lWhFormTransfer.setOutOperatorName(nickName);
|
lWhFormTransfer.setOutputTime(dealTime);
|
lWhFormTransfer.setOutWarehouseFlowId(lWarehouseFlowId);
|
lWhFormTransferService.update(lWhFormTransfer);
|
|
log.info("调拨单:{} 出库完成", whFormTransferId);
|
|
}
|
|
/**
|
* 新调拨出库 ,不再生成出库单
|
*
|
* @param whFormTransferId
|
* @param currentUser
|
*/
|
public Long doTransferOutPutNew(Long whFormTransferId, S_user_core currentUser, WhBusinessEnum whBusinessEnum)
|
throws Exception {
|
LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(whFormTransferId);
|
lWhFormTransfer = lWhFormTransferService.get(lWhFormTransfer);
|
if (lWhFormTransfer == null || lWhFormTransfer.getStates() != 0) {
|
log.error("调拨失败!请检查调拨单状态");
|
throw new Exception("调拨失败!请检查调拨单状态");
|
}
|
|
Long userId = currentUser.getId();
|
String nickName = currentUser.getNick_name();
|
long dealTime = DateUtils.getDateTimeNumber(System.currentTimeMillis());
|
// 申请调拨的物品
|
List<LWhProcureModel> goodsModelNumList =
|
lWhProcureModelService.getModelByForm(whBusinessEnum, whFormTransferId);
|
if (CollectionUtils.isEmpty(goodsModelNumList)) {
|
log.error("没有要出库的物品");
|
throw new Exception("没有要出库的物品");
|
}
|
List<LWhProcureModel> goodsModelNumUpdList = new ArrayList<>(goodsModelNumList.size());
|
|
// 要出物品的仓库id
|
Integer outWarehouseType = lWhFormTransfer.getOutWarehouseType();
|
Long outWarehouseId = lWhFormTransfer.getOutWarehouseId();
|
String warehouseName = lWhFormTransfer.getOutWarehouseName();
|
Integer inWarehouseType = lWhFormTransfer.getInWarehouseType();
|
Long inWarehouseId = lWhFormTransfer.getInWarehouseId();
|
String inWarehouseName = lWhFormTransfer.getInWarehouseName();
|
|
// 流水记录总表ID
|
long lWarehouseFlowId = NumberGenerator.getLongSequenceNumberNano();
|
// 流水记录总表中 业务ID 。调拨单时 保存调拨单id 出库单时 保存出库单id
|
long lWarehouseFlowBusinessId = whFormTransferId;
|
|
// 物品状态(0=在途调拨;1=入库未分发;2=已下发;3=报废)
|
Integer queryModelStatus = 1;
|
// 采购方式(1:集采;2=自采)
|
Integer buyType = 1;
|
if (whBusinessEnum == WhBusinessEnum.BUMENFENFA) {
|
buyType = null;
|
}
|
Integer modGoodsStatus = 0;
|
|
ArrayList<Long> allChangModelList = new ArrayList<>();
|
for (LWhProcureModel itemModelInfo : goodsModelNumList) {
|
// 需要调拨的物品的某个型号
|
Long baseGoodsModelsId = itemModelInfo.getBaseGoodsModelsId();
|
LWhProcureModel updWhProcureModel = new LWhProcureModel(itemModelInfo.getId());
|
// TODO 为空时不加入更新列表
|
if (baseGoodsModelsId != null) {
|
allChangModelList.add(baseGoodsModelsId);
|
}
|
// 需要调拨的物品某个型号的数量
|
Integer counts = itemModelInfo.getCounts();
|
// 查询型号信息
|
Map<String, Object> tempGoodsInfo = baseGoodsTemplateService.queryGoodsInfoByModelId(baseGoodsModelsId);
|
Long tempGoodsId = (Long)tempGoodsInfo.get("goodsid");
|
String goodsName = (String)tempGoodsInfo.get("goodsname");
|
String modelName = (String)tempGoodsInfo.get("modelname");
|
|
// 插入 各规格物品的进出库记录 L_WH_GOODS_RECORD
|
long whGoodsRecordId = NumberGenerator.getLongSequenceNumberNano();
|
LWhGoodsRecord whGoodsRecord = new LWhGoodsRecord();
|
whGoodsRecord.setId(whGoodsRecordId);
|
whGoodsRecord.setWarehouseId(outWarehouseId);
|
whGoodsRecord.setWarehouseFlowId(lWarehouseFlowId);
|
whGoodsRecord.setBaseGoodsTemplateId(tempGoodsId);
|
whGoodsRecord.setGoodsTemplateName(goodsName);
|
whGoodsRecord.setBaseGoodsModelsId(baseGoodsModelsId);
|
whGoodsRecord.setBaseGoodsModelsName(modelName);
|
whGoodsRecord.setDealTime(dealTime);
|
// 本次调整类型 1=调增;2=调减
|
whGoodsRecord.setThisType(2);
|
whGoodsRecord.setThisCount(counts);
|
|
// 通过LockManage获得锁
|
Object warehouseModelLockObj = LockManage.acquireLock(outWarehouseType, outWarehouseId, baseGoodsModelsId);
|
List<Long> outGoodsId = null;
|
synchronized (warehouseModelLockObj) {
|
// 获得锁后查询该型号的期初数量
|
List<Long> warehouseIds = new ArrayList<>(Arrays.asList(outWarehouseId));
|
int goodsModelNum = lWhGoodsService.queryGoodsModelNum(outWarehouseType, warehouseIds,
|
baseGoodsModelsId, queryModelStatus, buyType);
|
if (goodsModelNum < counts) {
|
log.error("出库失败!型号{} 的数量不足,需要调拨{}个,仓库中现存{}个", baseGoodsModelsId, counts, goodsModelNum);
|
// 手动回滚
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
//throw new RuntimeException("出库失败!型号数量不足");
|
return -1L;
|
}
|
whGoodsRecord.setInitialCount(goodsModelNum);
|
whGoodsRecord.setEndCount(goodsModelNum - counts);
|
|
// 出库时候,按 先入库的先出库,同时入库的,按价格高的先出库
|
outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId,
|
queryModelStatus, buyType, counts);
|
lWhGoodsService.modGoodsTransfering(outGoodsId, inWarehouseType, inWarehouseId, inWarehouseName,
|
modGoodsStatus);
|
// 批量插入 进出库流水明细[L_WH_GOODS_RECORD_DETAILS]
|
lWhGoodsRecordDetailsService.sameGoodsInsertMore(outGoodsId, whGoodsRecordId, (short)0);
|
}
|
long totalAmount = lWhGoodsService.queryGoodsPriceById(outGoodsId);
|
LWhProcureModel lWhProcureModel = new LWhProcureModel(itemModelInfo.getId());
|
whGoodsRecord.setTotalPrice(totalAmount);
|
lWhGoodsRecordServiceImpl.insert(whGoodsRecord);
|
lWhProcureModel.setTotalAmount(totalAmount);
|
lWhProcureModelService.update(lWhProcureModel);
|
updWhProcureModel.setTotalAmount(totalAmount);
|
goodsModelNumUpdList.add(updWhProcureModel);
|
}
|
// 更新L_WH_PROCURE_MODEL表内金额
|
lWhProcureModelService.updateBatch(goodsModelNumUpdList);
|
|
LWarehouseFlow warehouseFlow = new LWarehouseFlow();
|
warehouseFlow.setId(lWarehouseFlowId);
|
warehouseFlow.setWarehouseId(outWarehouseId);
|
warehouseFlow.setWarehouseName(warehouseName);
|
warehouseFlow.setThisType(2);
|
warehouseFlow.setBusinessType(whBusinessEnum.getValue());
|
|
warehouseFlow.setBusinessFormId(whFormTransferId == null ? lWarehouseFlowBusinessId : whFormTransferId);
|
warehouseFlow.setOperatorId(userId);
|
warehouseFlow.setOperatorName(nickName);
|
warehouseFlow.setDealTime(dealTime);
|
// 插入流水总表
|
int flowInsertFlag = lWarehouseFlowServiceImpl.insert(warehouseFlow);
|
if (flowInsertFlag == 0) {
|
return null;
|
}
|
|
// 当库存变动时调用该方法
|
if (outWarehouseType == 0) {
|
lWhWarningCoreService.updateKuCun(Convert.toShort(outWarehouseType, (short)0), outWarehouseId,
|
allChangModelList, null, dealTime);
|
}
|
|
// 更新调拨单
|
lWhFormTransfer = new LWhFormTransfer(whFormTransferId);
|
// 调拨单不再关联出入库单
|
// lWhFormTransfer.setOutWarehouseFormId(outWarehouseFormId);
|
lWhFormTransfer.setStates(TransferStatesType.RECEIVE_ING.getValue());
|
lWhFormTransfer.setOutOperatorId(userId);
|
lWhFormTransfer.setOutOperatorName(nickName);
|
lWhFormTransfer.setOutputTime(dealTime);
|
lWhFormTransfer.setOutWarehouseFlowId(lWarehouseFlowId);
|
lWhFormTransferService.update(lWhFormTransfer);
|
|
log.info("调拨单:{} 出库完成", whFormTransferId);
|
return lWarehouseFlowId;
|
|
}
|
|
/**
|
* 调拨单入库
|
*
|
* @param whFormTransferId
|
* @param currentUser
|
*/
|
public void doTransferInPut(Long whFormTransferId, S_user_core currentUser, String inOperatorName)
|
throws Exception {
|
LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(whFormTransferId);
|
lWhFormTransfer = lWhFormTransferService.get(lWhFormTransfer);
|
if (lWhFormTransfer == null || lWhFormTransfer.getStates() != 1) {
|
log.info("调拨失败!请检查调拨单状态");
|
throw new RuntimeException("调拨失败!请检查调拨单状态");
|
}
|
Long userId = currentUser.getId();
|
String nickName = currentUser.getNick_name();
|
// 出库单流水id
|
Long outWarehouseFlowId = lWhFormTransfer.getOutWarehouseFlowId();
|
if (outWarehouseFlowId == null) {
|
log.info("调拨失败!未找到出库单");
|
throw new RuntimeException("调拨失败!未找到出库单");
|
}
|
// 入库仓库类型 0机构1部门
|
Integer inWarehouseType = lWhFormTransfer.getInWarehouseType();
|
Long inWarehouseId = lWhFormTransfer.getInWarehouseId();
|
String inWarehouseName = lWhFormTransfer.getInWarehouseName();
|
|
long dealTime = DateUtils.getDateTimeNumber(System.currentTimeMillis());
|
|
// 流水记录总表ID
|
long inWarehouseFlowId = NumberGenerator.getLongSequenceNumber();
|
// 单据类型。0仓库调拨;1部门分发;2部门物品回退
|
Integer businessType = lWhFormTransfer.getBusinessType();
|
// 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废 4 零星出库)
|
Integer goodsStatus = 1;
|
// 类型0分发使用1 反库
|
Integer recordType = null;
|
if (businessType == 1) {
|
goodsStatus = 2;
|
recordType = 0;
|
|
} else if (businessType == 2) {
|
goodsStatus = 1;
|
recordType = 1;
|
}
|
|
// 插入 进出库流水总表[L_WAREHOUSE_FLOW]
|
LWarehouseFlow inwarehouseFlow = new LWarehouseFlow();
|
inwarehouseFlow.setId(inWarehouseFlowId);
|
inwarehouseFlow.setWarehouseType(inWarehouseType);
|
inwarehouseFlow.setWarehouseId(inWarehouseId);
|
inwarehouseFlow.setWarehouseName(inWarehouseName);
|
inwarehouseFlow.setThisType(1);
|
inwarehouseFlow.setBusinessType(2);
|
inwarehouseFlow.setBusinessFormId(whFormTransferId);
|
inwarehouseFlow.setOperatorId(userId);
|
inwarehouseFlow.setOperatorName(nickName);
|
inwarehouseFlow.setDealTime(dealTime);
|
lWarehouseFlowServiceImpl.insert(inwarehouseFlow);
|
|
ArrayList<Long> allChangModelList = new ArrayList<>();
|
LWhGoodsRecord lWhGoodsRecord = new LWhGoodsRecord();
|
lWhGoodsRecord.setWarehouseFlowId(outWarehouseFlowId);
|
List<LWhGoodsRecord> whGoodsRecordList = lWhGoodsRecordServiceImpl.select(lWhGoodsRecord);
|
for (LWhGoodsRecord whGoodsRecord : whGoodsRecordList) {
|
Long oldRecordId = whGoodsRecord.getId();
|
Long baseGoodsModelsId = whGoodsRecord.getBaseGoodsModelsId();
|
allChangModelList.add(baseGoodsModelsId);
|
whGoodsRecord.setId(IdUtil.generateId());
|
whGoodsRecord.setWarehouseFlowId(inWarehouseFlowId);
|
whGoodsRecord.setWarehouseType(inWarehouseType);
|
whGoodsRecord.setWarehouseId(inWarehouseId);
|
whGoodsRecord.setDealTime(dealTime);
|
// 通过LockManage获得锁
|
Object warehouseModelLockObj = LockManage.acquireLock(inWarehouseType, inWarehouseId, baseGoodsModelsId);
|
List<Long> outGoodsIds = null;
|
synchronized (warehouseModelLockObj) {
|
// 根据出库流水ID 查询 出库的物品ID
|
outGoodsIds = getGoodsidByFlowId(outWarehouseFlowId, oldRecordId);
|
if (CollectionUtils.isEmpty(outGoodsIds)) {
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
throw new RuntimeException("入库单失败,未查询到物品!");
|
}
|
// 获得锁后查询该型号的期初数量
|
List<Long> warehouseIds = new ArrayList<>(Arrays.asList(inWarehouseId));
|
int goodsModelNum =
|
lWhGoodsService.queryGoodsModelNum(inWarehouseType, warehouseIds, baseGoodsModelsId, 1, null);
|
|
// 库存物品详情(L_WH_GOODS)中 状态设置为1
|
lWhGoodsService.modGoodsTransfering(outGoodsIds, inWarehouseType, inWarehouseId, inWarehouseName,
|
goodsStatus);
|
|
whGoodsRecord.setInitialCount(goodsModelNum);
|
whGoodsRecord.setEndCount(goodsModelNum + whGoodsRecord.getThisCount());
|
long totalAmount = lWhGoodsService.queryGoodsPriceById(outGoodsIds);
|
whGoodsRecord.setTotalPrice(totalAmount);
|
}
|
if (businessType == 1) {
|
// List<Map<String, Object>> modelInfo = baseGoodsModelsService.queryGoodsModelInfo(baseGoodsModelsId);
|
// 1部门分发 此时要往 物品使用记录【L_GOODS_USER_RECORD】添加数据
|
// 查询部门分发使用人
|
LWhProcureModelUser lWhProcureModelUser = new LWhProcureModelUser();
|
lWhProcureModelUser.setTransBusinessId(whFormTransferId);
|
lWhProcureModelUser.setBaseGoodsModelsId(baseGoodsModelsId);
|
List<LWhProcureModelUser> goodsUserInfo = goodsBaseService.select(lWhProcureModelUser);
|
// 将物品型号以前的使用记录设置为非最新
|
lGoodsUserRecordService.updSetNotLast(outGoodsIds);
|
if (!CollectionUtils.isEmpty(goodsUserInfo)) {
|
// 认为是A类物品
|
int totalGoodsNum = goodsUserInfo.stream().filter(item -> item.getGoodsNum() != null)
|
.mapToInt(LWhProcureModelUser::getGoodsNum).sum();
|
if (totalGoodsNum != outGoodsIds.size()) {
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
log.info("入库单失败,使用人使用数量与物品数量不一致");
|
throw new RuntimeException("入库单失败,使用人使用数量与物品数量不一致");
|
}
|
|
ArrayList<LGoodsUserRecord> goodsUserRecordList = new ArrayList<>();
|
int startIndex = 0;
|
for (LWhProcureModelUser whProcureModelUser : goodsUserInfo) {
|
Integer goodsNum = whProcureModelUser.getGoodsNum();
|
String nowUserName = whProcureModelUser.getNowUserName();
|
Long nowUserPhone = whProcureModelUser.getNowUserPhone();
|
Long procureModelUserRecordId = whProcureModelUser.getProcureModelUserRecordId();
|
List<Long> goodsIds = outGoodsIds.subList(startIndex, startIndex + goodsNum);
|
for (Long goodsId : goodsIds) {
|
LGoodsUserRecord tmp = new LGoodsUserRecord();
|
tmp.setWhGoodsId(goodsId);
|
tmp.setRecordType(recordType);
|
tmp.setTransBusinessId(whFormTransferId);
|
if (businessType == 1) {
|
tmp.setNowUserName(nowUserName);
|
tmp.setNowUserPhone(nowUserPhone);
|
} else if (businessType == 2) {
|
tmp.setNowUserName(null);
|
tmp.setNowUserPhone(null);
|
}
|
tmp.setProcureModelUserRecordId(procureModelUserRecordId);
|
tmp.setOperatorId(userId);
|
tmp.setOperatorName(nickName);
|
tmp.setDealTime(dealTime);
|
tmp.setLastRecord(1);
|
goodsUserRecordList.add(tmp);
|
}
|
// 更新下标位置
|
startIndex += goodsNum;
|
}
|
// 批量插入使用人记录
|
lGoodsUserRecordService.insertBatch(goodsUserRecordList);
|
}
|
}
|
// 将保管仓库信息更新到 物品仓库保管记录【L_GOODS_WH_RECORD】
|
lGoodsWhRecordService.insertNewRecord(outGoodsIds, inWarehouseFlowId, dealTime);
|
|
LWhGoodsRecordDetails lWhGoodsRecordDetails = new LWhGoodsRecordDetails();
|
lWhGoodsRecordDetails.setWhGoodsRecordId(oldRecordId);
|
List<LWhGoodsRecordDetails> goodsRecordDetailsList =
|
lWhGoodsRecordDetailsService.select(lWhGoodsRecordDetails);
|
for (LWhGoodsRecordDetails whGoodsRecordDetails : goodsRecordDetailsList) {
|
whGoodsRecordDetails.setId(null);
|
whGoodsRecordDetails.setWhGoodsRecordId(whGoodsRecord.getId());
|
whGoodsRecordDetails.setThisType(1);
|
}
|
lWhGoodsRecordDetailsService.insertBatch(goodsRecordDetailsList);
|
}
|
lWhGoodsRecordServiceImpl.insertBatch(whGoodsRecordList);
|
|
// 更新调拨单
|
lWhFormTransfer = new LWhFormTransfer(whFormTransferId);
|
lWhFormTransfer.setInWarehouseFlowId(inWarehouseFlowId);
|
lWhFormTransfer.setInWarehouseFormId(null);
|
lWhFormTransfer.setStates(TransferStatesType.SUCCESS.getValue());
|
if (StringUtils.isEmpty(inOperatorName)) {
|
lWhFormTransfer.setInOperatorId(userId);
|
lWhFormTransfer.setInOperatorName(nickName);
|
} else {
|
lWhFormTransfer.setInOperatorName(inOperatorName);
|
}
|
|
lWhFormTransfer.setInTime(dealTime);
|
lWhFormTransferService.update(lWhFormTransfer);
|
|
// 当库存变动时调用该方法
|
if (inWarehouseType == 0) {
|
lWhWarningCoreService.updateKuCun(Convert.toShort(inWarehouseType, (short)0), inWarehouseId,
|
allChangModelList, null, dealTime);
|
}
|
log.info("调拨单:{} 入库完成", whFormTransferId);
|
}
|
|
private static String GET_GOODSID_BY_FLOWID =
|
"SELECT goods.id FROM L_WH_GOODS_RECORD gr LEFT JOIN L_WH_GOODS_RECORD_DETAILS grd ON gr.id=grd.WH_GOODS_RECORD_ID LEFT JOIN L_WH_GOODS goods ON goods.id=grd.WH_GOODS_ID WHERE 1=1";
|
|
/**
|
* 根据出库流水ID 查询 出库的物品ID
|
*
|
* @param lWarehouseFlowId
|
*/
|
private List<Long> getGoodsidByFlowId(Long lWarehouseFlowId, Long whGoodsRecordId) {
|
StringBuilder sql = new StringBuilder(GET_GOODSID_BY_FLOWID);
|
Map<String, Object> paramts = new HashMap<>();
|
if (lWarehouseFlowId != null) {
|
sql.append(" and gr.WAREHOUSE_FLOW_ID =:lWarehouseFlowId");
|
paramts.put("lWarehouseFlowId", lWarehouseFlowId);
|
}
|
if (whGoodsRecordId != null) {
|
sql.append(" and gr.id =:whGoodsRecordId");
|
paramts.put("whGoodsRecordId", whGoodsRecordId);
|
}
|
List<Map<String, Object>> outGoods = goodsBaseService.select(sql.toString(), paramts);
|
if (CollectionUtils.isEmpty(outGoods)) {
|
return null;
|
}
|
List<Long> whGoodsIds = outGoods.stream().map(map -> (Long)map.get("id")).collect(Collectors.toList());
|
return whGoodsIds;
|
}
|
}
|