|
|
|
|
package com.glxp.api.service.inout;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
|
|
import com.glxp.api.res.basic.BasicSkPrescribeDiResponse;
|
|
|
|
|
import com.glxp.api.service.BasicSkPrescribeDiService;
|
|
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
|
|
import com.glxp.api.service.inout.impl.IoCodeService;
|
|
|
|
|
import com.glxp.api.service.inv.impl.InvProductDetailService;
|
|
|
|
|
import com.glxp.api.service.inv.impl.InvProductService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.constant.ConstantType;
|
|
|
|
|
import com.glxp.api.dao.inout.IoOrderDetailCodeDao;
|
|
|
|
|
import com.glxp.api.entity.auth.InvWarehouseEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
|
import com.glxp.api.entity.inv.InvProductDetailEntity;
|
|
|
|
|
import com.glxp.api.entity.system.SystemParamConfigEntity;
|
|
|
|
|
import com.glxp.api.req.basic.FilterCompanyProductRelevanceRequest;
|
|
|
|
|
import com.glxp.api.req.inout.PdaPostOrderRequest;
|
|
|
|
|
import com.glxp.api.res.basic.UdiRelevanceResponse;
|
|
|
|
|
import com.glxp.api.service.auth.InvWarehouseService;
|
|
|
|
|
import com.glxp.api.service.inv.InvPreProductDetailService;
|
|
|
|
|
import com.glxp.api.service.inv.InvPreinProductDetailService;
|
|
|
|
|
import com.glxp.api.service.system.SystemParamConfigService;
|
|
|
|
|
import com.glxp.api.util.*;
|
|
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.glxp.api.constant.ConstantStatus.ORDER_STATUS_CHECK_PROCESS;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class IoAddInoutService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IBasicBussinessTypeService basicBussinessTypeService;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoOrderService orderService;
|
|
|
|
|
@Resource
|
|
|
|
|
GennerOrderUtils gennerOrderUtils;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCodeService codeService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCodeTempService codeTempService;
|
|
|
|
|
@Resource
|
|
|
|
|
UdiRlSupService udiRlSupService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailCodeService orderDetailCodeService;
|
|
|
|
|
@Resource
|
|
|
|
|
UdiRelevanceService udiRelevanceService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvProductDetailService invProductDetailService;
|
|
|
|
|
@Resource
|
|
|
|
|
BasicCorpService basicCorpService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCheckInoutService ioCheckInoutService;
|
|
|
|
|
@Resource
|
|
|
|
|
SystemParamConfigService systemParamConfigService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailBizService orderDetailBizService;
|
|
|
|
|
@Resource
|
|
|
|
|
private IoOrderDetailCodeDao orderDetailCodeDao;
|
|
|
|
|
@Resource
|
|
|
|
|
InvWarehouseService invWarehouseService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvProductService invProductService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCheckInvService checkInvService;
|
|
|
|
|
|
|
|
|
|
//新增扫码单据处理
|
|
|
|
|
public BaseResponse dealProcess(IoOrderEntity orderEntity) {
|
|
|
|
|
|
|
|
|
|
orderEntity.setErrMsg("正在处理!");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESSING);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
|
|
|
|
|
List<IoOrderEntity> orderEntities = orderService.isExitRepeat(orderEntity.getCorpOrderId(), orderEntity.getBillNo());
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(orderEntities)) {
|
|
|
|
|
orderEntity.setErrMsg("单据重复上传");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
|
|
|
if (bussinessTypeEntity == null) {
|
|
|
|
|
orderEntity.setErrMsg("单据类型不存在");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isEmpty(orderEntity.getFromCorp()) && StrUtil.isEmpty(orderEntity.getFromInvCode())) {
|
|
|
|
|
orderEntity.setErrMsg("未选择往来单位");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
} else if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) {
|
|
|
|
|
updateCorp(bussinessTypeEntity, orderEntity.getFromCorp(), orderEntity.getSickerAdNum());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(orderEntity.getInvCode())) {
|
|
|
|
|
orderEntity.setErrMsg("未选择当前仓库信息");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IoCodeTempEntity> filterList = codeTempService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
List<IoCodeTempEntity> insertList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < filterList.size(); j++) {
|
|
|
|
|
IoCodeTempEntity warehouseEntity = filterList.get(j);
|
|
|
|
|
String result = checkOrderRepeatCode(warehouseEntity, filterList);
|
|
|
|
|
if (result == null) {
|
|
|
|
|
insertList.add(warehouseEntity);
|
|
|
|
|
} else {
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg(result);
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
insertList.clear();
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bussinessTypeEntity.isCodeFillCheck()) {
|
|
|
|
|
//三期校验
|
|
|
|
|
String checkOriginMsg = checkOriginCode(warehouseEntity);
|
|
|
|
|
if (StrUtil.isNotEmpty(checkOriginMsg)) {
|
|
|
|
|
orderEntity.setErrMsg(checkOriginMsg);
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
insertList.clear();
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//产品是否已维护已关联
|
|
|
|
|
if ((warehouseEntity.getRelId() == null)) {
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg("udi码:" + warehouseEntity.getCode() + "上传时对照数据丢失!");
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//产品是否指定供应商
|
|
|
|
|
if (StrUtil.isEmpty(warehouseEntity.getSupId())) {
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg("udi码:" + warehouseEntity.getCode() + "未指定供应商!");
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//校验是否是当前供应商
|
|
|
|
|
if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_OUT) {
|
|
|
|
|
UdiRlSupEntity udiRlSupEntity = udiRlSupService.findByUdiRlIdUnitFk(warehouseEntity.getRelId() + "", orderEntity.getFromCorp());
|
|
|
|
|
if (udiRlSupEntity == null) {
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg("udi码:" + warehouseEntity.getCode() + "当前供应商不存在此配送产品");
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//产品是否可以以使用单元入库
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectGroupById(warehouseEntity.getRelId());
|
|
|
|
|
if (udiRelevanceResponse == null) {
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg("udi码:" + warehouseEntity.getCode() + "该产品信息未维护");
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
} else if (!udiRelevanceResponse.getUseDy() && udiRelevanceResponse.getDiType() == ConstantStatus.DITYPE_SYDY) {
|
|
|
|
|
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg("udi码:" + warehouseEntity.getCode() + "该产品不允许以使用单元入库");
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseResponse baseResponse = checkInvService.check(bussinessTypeEntity, warehouseEntity, udiRelevanceResponse);
|
|
|
|
|
if (baseResponse != null) {
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg(baseResponse.getMessage());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return baseResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(insertList)) {
|
|
|
|
|
//生成扫码单据详情
|
|
|
|
|
if (!orderDetailCodeService.isExit(orderEntity.getBillNo())) {
|
|
|
|
|
for (IoCodeTempEntity codeTempEntity : insertList) {
|
|
|
|
|
genOrderDetailCode(orderEntity, codeTempEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg("");
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderEntity.setErrMsg("未添加UDI码");
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//新增业务单据处理
|
|
|
|
|
public BaseResponse dealBusProcess(IoOrderEntity orderEntity, BasicBussinessTypeEntity bussinessTypeEntity) {
|
|
|
|
|
|
|
|
|
|
orderEntity.setErrMsg("正在处理!");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESSING);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IoOrderEntity> orderEntities = orderService.isExitRepeat(orderEntity.getCorpOrderId(), orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(orderEntities)) {
|
|
|
|
|
orderEntity.setErrMsg("单据重复上传");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(orderEntity.getFromCorp()) && StrUtil.isEmpty(orderEntity.getFromInvCode())) {
|
|
|
|
|
orderEntity.setErrMsg("未选择往来单位");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(orderEntity.getInvCode())) {
|
|
|
|
|
orderEntity.setErrMsg("未选择当前仓库信息");
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String errMsg = "";
|
|
|
|
|
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
|
|
|
|
|
for (IoOrderDetailBizEntity orderDetailBizEntity : orderDetailBizEntities) {
|
|
|
|
|
if (StrUtil.isEmpty(orderDetailBizEntity.getSupId())) {
|
|
|
|
|
errMsg = errMsg + orderDetailBizEntity.getCoName() + "未绑定供应商;";
|
|
|
|
|
}
|
|
|
|
|
if (orderDetailBizEntity.getBindRlFk() == null) {
|
|
|
|
|
errMsg = errMsg + orderDetailBizEntity.getCoName() + "未绑定耗材字典编码;";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
|
|
orderEntity.setErrMsg(errMsg);
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATS_ERROR);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
return ResultVOUtils.error(orderEntity.getErrMsg());
|
|
|
|
|
}
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderEntity.setUpdateTime(new Date());
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
//业务单直接生成扫码单
|
|
|
|
|
if (bussinessTypeEntity.getCheckWebNew() == 4) {
|
|
|
|
|
boolean exit = codeTempService.isExit(orderEntity.getBillNo());
|
|
|
|
|
if (!exit) {
|
|
|
|
|
stockGenScan(orderEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 业务单生成扫码单
|
|
|
|
|
*/
|
|
|
|
|
public void stockGenScan(IoOrderEntity orderEntity) {
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> bizEntities = orderDetailBizService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
List<IoCodeTempEntity> codeTempEntities = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (IoOrderDetailBizEntity bizEntity : bizEntities) {
|
|
|
|
|
IoCodeTempEntity codeTempEntity = new IoCodeTempEntity();
|
|
|
|
|
String udiCode = "#" + bizEntity.getNameCode()
|
|
|
|
|
+ "#" + StrUtil.trimToEmpty(bizEntity.getProductDate())
|
|
|
|
|
+ "#" + StrUtil.trimToEmpty(bizEntity.getExpireDate()) +
|
|
|
|
|
"#" + StrUtil.trimToEmpty(bizEntity.getBatchNo()) + "#" + "#" + "#";
|
|
|
|
|
codeTempEntity.setCode(udiCode);
|
|
|
|
|
codeTempEntity.setMainAction(orderEntity.getMainAction());
|
|
|
|
|
codeTempEntity.setAction(orderEntity.getAction());
|
|
|
|
|
codeTempEntity.setOrderId(orderEntity.getBillNo());
|
|
|
|
|
codeTempEntity.setCorpOrderId(orderEntity.getCorpOrderId());
|
|
|
|
|
codeTempEntity.setNameCode(bizEntity.getNameCode());
|
|
|
|
|
codeTempEntity.setBatchNo(bizEntity.getBatchNo());
|
|
|
|
|
codeTempEntity.setProduceDate(bizEntity.getProductDate());
|
|
|
|
|
codeTempEntity.setExpireDate(bizEntity.getExpireDate());
|
|
|
|
|
codeTempEntity.setSupId(bizEntity.getSupId());
|
|
|
|
|
codeTempEntity.setRelId(bizEntity.getBindRlFk());
|
|
|
|
|
codeTempEntity.setCount(bizEntity.getCount());
|
|
|
|
|
codeTempEntity.setReCount(bizEntity.getCount());
|
|
|
|
|
codeTempEntity.setDeptCode(orderEntity.getDeptCode());
|
|
|
|
|
codeTempEntity.setInvCode(orderEntity.getInvCode());
|
|
|
|
|
codeTempEntity.setUpdateTime(new Date());
|
|
|
|
|
codeTempEntity.setCreateTime(new Date());
|
|
|
|
|
codeTempEntity.setPrice(bizEntity.getPrice());
|
|
|
|
|
if (orderEntity.getBillNo() != null && orderEntity.getBillNo().length() >= 12) {
|
|
|
|
|
codeTempEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12));
|
|
|
|
|
}
|
|
|
|
|
codeTempEntities.add(codeTempEntity);
|
|
|
|
|
}
|
|
|
|
|
codeTempService.insertBatch(codeTempEntities);
|
|
|
|
|
bizEntities.forEach(orderDetailBizEntity -> {
|
|
|
|
|
IoOrderDetailCodeEntity orderDetailCodeEntity = new IoOrderDetailCodeEntity();
|
|
|
|
|
BeanUtils.copyProperties(orderDetailBizEntity, orderDetailCodeEntity);
|
|
|
|
|
orderDetailCodeEntity.setId(null);
|
|
|
|
|
orderDetailCodeEntity.setReCount(orderDetailBizEntity.getCount());
|
|
|
|
|
orderDetailCodeEntity.setCount(orderDetailBizEntity.getCount());
|
|
|
|
|
orderDetailCodeService.insert(orderDetailCodeEntity);
|
|
|
|
|
});
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//生成扫码单据详情
|
|
|
|
|
public List<IoOrderDetailCodeEntity> genOrderDetailCode(IoOrderEntity orderEntity, IoCodeTempEntity codeTempEntity) {
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailCodeEntity> ioOrderDetailCodeEntities = orderDetailCodeDao.selectList(new QueryWrapper<IoOrderDetailCodeEntity>().select("id", "count", "reCount", "bindRlFk", "batchNo", "price").eq("orderIdFk", orderEntity.getBillNo()));
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectSupGroupById(codeTempEntity.getRelId(), codeTempEntity.getSupId());
|
|
|
|
|
if (codeTempEntity.getPrice() == null) {
|
|
|
|
|
codeTempEntity.setPrice(udiRelevanceResponse.getPrice());
|
|
|
|
|
codeTempService.updateById(codeTempEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(ioOrderDetailCodeEntities)) {
|
|
|
|
|
orderDetailCodeService.insert(buildEntity(orderEntity, codeTempEntity, udiRelevanceResponse));
|
|
|
|
|
ioOrderDetailCodeEntities = orderDetailCodeDao.selectList(new QueryWrapper<IoOrderDetailCodeEntity>().select("id", "count", "reCount", "bindRlFk", "batchNo", "price").eq("orderIdFk", orderEntity.getBillNo()));
|
|
|
|
|
} else {
|
|
|
|
|
boolean isUpdate = false;
|
|
|
|
|
for (IoOrderDetailCodeEntity orderDetailCodeEntity : ioOrderDetailCodeEntities) {
|
|
|
|
|
if (orderDetailCodeEntity.getBindRlFk().longValue() == udiRelevanceResponse.getId().longValue()
|
|
|
|
|
&& StrUtil.trimToEmpty(orderDetailCodeEntity.getBatchNo()).equals(StrUtil.trimToEmpty(codeTempEntity.getBatchNo()))
|
|
|
|
|
&& BigDecimalUtil.equalTo(orderDetailCodeEntity.getPrice(), codeTempEntity.getPrice())
|
|
|
|
|
) {
|
|
|
|
|
orderDetailCodeEntity.setCount(orderDetailCodeEntity.getCount() + codeTempEntity.getMyCount());
|
|
|
|
|
orderDetailCodeEntity.setReCount(orderDetailCodeEntity.getReCount() + codeTempEntity.getMyReCount());
|
|
|
|
|
UpdateWrapper<IoOrderDetailCodeEntity> updateWrapper = new UpdateWrapper<>();
|
|
|
|
|
updateWrapper.set("count", orderDetailCodeEntity.getCount()).set("reCount", orderDetailCodeEntity.getReCount());
|
|
|
|
|
orderDetailCodeEntity.setUpdateTime(new Date());
|
|
|
|
|
orderDetailCodeDao.updateCount(orderDetailCodeEntity);
|
|
|
|
|
isUpdate = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isUpdate) {
|
|
|
|
|
orderDetailCodeService.insert(buildEntity(orderEntity, codeTempEntity, udiRelevanceResponse));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ioOrderDetailCodeEntities;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//平衡补单
|
|
|
|
|
public BaseResponse supplementOrder(String orderId) {
|
|
|
|
|
|
|
|
|
|
IoOrderEntity order = orderService.findByBillNo(orderId);
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(order.getAction());
|
|
|
|
|
if (StrUtil.isBlank(bussinessTypeEntity.getSupplementOrderType())) {
|
|
|
|
|
return ResultVOUtils.error(500, "此类型单据不可补单");
|
|
|
|
|
}
|
|
|
|
|
IoOrderEntity supplementOrder = new IoOrderEntity();
|
|
|
|
|
BeanUtils.copyProperties(order, supplementOrder);
|
|
|
|
|
|
|
|
|
|
//生成补单单号,互填单号
|
|
|
|
|
String supplementOrderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
supplementOrder.setSupplementNo(orderId);
|
|
|
|
|
order.setSupplementNo(supplementOrderNo);
|
|
|
|
|
supplementOrder.setBillNo(supplementOrderNo);
|
|
|
|
|
supplementOrder.setCorpOrderId(CustomUtil.getId() + "x");
|
|
|
|
|
|
|
|
|
|
//修改状态
|
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("additional_auto_submit");
|
|
|
|
|
if ("1".equals(systemParamConfigEntity.getParamValue())) {
|
|
|
|
|
supplementOrder.setStatus(ConstantStatus.ORDER_STATUS_PROCESS); //设置状态为补录单据
|
|
|
|
|
} else {
|
|
|
|
|
supplementOrder.setStatus(ConstantStatus.ORDER_STATUS_ADDITIONAL); //设置状态为补录单据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//交换往来信息
|
|
|
|
|
supplementOrder.setFromDeptCode(order.getDeptCode());
|
|
|
|
|
supplementOrder.setFromInvCode(order.getInvCode());
|
|
|
|
|
supplementOrder.setInvCode(order.getFromInvCode());
|
|
|
|
|
supplementOrder.setDeptCode(order.getFromDeptCode());
|
|
|
|
|
supplementOrder.setFromType(ConstantStatus.FROM_PEACE_CHANGE);
|
|
|
|
|
|
|
|
|
|
//设置往来信息
|
|
|
|
|
BasicBussinessTypeEntity supplementType = basicBussinessTypeService.findByAction(bussinessTypeEntity.getSupplementOrderType());
|
|
|
|
|
supplementOrder.setMainAction(supplementType.getMainAction());
|
|
|
|
|
supplementOrder.setAction(supplementType.getAction());
|
|
|
|
|
supplementOrder.setBusType(supplementType.getBusType());
|
|
|
|
|
//复制码表
|
|
|
|
|
List<IoCodeEntity> codes = codeService.findByOrderId(orderId);
|
|
|
|
|
List<IoCodeTempEntity> supplementCodes = new ArrayList<>();
|
|
|
|
|
codes.forEach(
|
|
|
|
|
code -> {
|
|
|
|
|
IoCodeTempEntity supplementCode = new IoCodeTempEntity();
|
|
|
|
|
BeanUtils.copyProperties(code, supplementCode);
|
|
|
|
|
supplementCode.setId(null);
|
|
|
|
|
supplementCode.setInvCode(order.getFromInvCode());
|
|
|
|
|
supplementCode.setDeptCode(order.getFromDeptCode());
|
|
|
|
|
supplementCode.setOrderId(supplementOrderNo);
|
|
|
|
|
supplementCode.setAction(supplementType.getAction());
|
|
|
|
|
supplementCode.setWarehouseCode(null);
|
|
|
|
|
supplementCode.setPreInSpaceCode(null);
|
|
|
|
|
supplementCode.setPreSpaceCode(null);
|
|
|
|
|
supplementCode.setMainAction(supplementType.getMainAction());
|
|
|
|
|
supplementCodes.add(supplementCode);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//更新数据
|
|
|
|
|
orderService.insertOrder(supplementOrder);
|
|
|
|
|
orderService.update(order);
|
|
|
|
|
codeTempService.insertBatch(supplementCodes);
|
|
|
|
|
dealProcess(supplementOrder);
|
|
|
|
|
if (!ioCheckInoutService.checkManual(supplementOrder.getBillNo())) {
|
|
|
|
|
ioCheckInoutService.check(supplementOrder.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手持终端-----新增出入库单据
|
|
|
|
|
*
|
|
|
|
|
* @param pdaPostOrderRequest
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public BaseResponse creatOrderByPda(PdaPostOrderRequest pdaPostOrderRequest) {
|
|
|
|
|
|
|
|
|
|
IoOrderEntity orderEntity = pdaPostOrderRequest.getOrderEntity();
|
|
|
|
|
IoOrderEntity tempEntity = orderService.findByBillNo(orderEntity.getBillNo());
|
|
|
|
|
if (tempEntity != null) {
|
|
|
|
|
return ResultVOUtils.error(500, "单据已存在,请勿重复提交");
|
|
|
|
|
}
|
|
|
|
|
tempEntity = orderService.findByCorpOrderId(orderEntity.getCorpOrderId());
|
|
|
|
|
if (tempEntity != null) {
|
|
|
|
|
return ResultVOUtils.error(500, "单据已存在,请勿重复提交");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
|
|
|
|
|
|
|
|
BaseResponse baseResponse = checkInv(bussinessTypeEntity, pdaPostOrderRequest.getOrderDetailBizEntities(), orderEntity, pdaPostOrderRequest.getCodeTempEntities());
|
|
|
|
|
if (baseResponse != null)
|
|
|
|
|
return baseResponse;
|
|
|
|
|
List<IoCodeTempEntity> codeTempEntities = BeanUtil.copyToList(pdaPostOrderRequest.getCodeTempEntities(), IoCodeTempEntity.class);
|
|
|
|
|
String priceFifo = systemParamConfigService.selectValueByParamKey("price_fifo");
|
|
|
|
|
if (IntUtil.value(priceFifo) > 0 && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
|
|
|
|
|
|
|
|
|
|
List<IoCodeTempEntity> resultList = new ArrayList<>();
|
|
|
|
|
for (IoCodeTempEntity codeTempEntity : codeTempEntities) {
|
|
|
|
|
resultList = checkPrice(codeTempEntity, bussinessTypeEntity, resultList);
|
|
|
|
|
}
|
|
|
|
|
// for (IoCodeTempEntity codeTempEntity : resultList) {
|
|
|
|
|
// if (codeTempEntity.getId() == null)
|
|
|
|
|
//// return ResultVOUtils.error(500, "价格发生变动!");
|
|
|
|
|
// log.error("价格发生变动");
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
|
|
|
|
|
orderEntity.setBillNo(orderNo);
|
|
|
|
|
orderService.insertOrder(orderEntity);
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(pdaPostOrderRequest.getCodeTempEntities())) {
|
|
|
|
|
for (IoCodeTempEntity codeTempEntity : codeTempEntities) {
|
|
|
|
|
codeTempEntity.setOrderId(orderNo);
|
|
|
|
|
}
|
|
|
|
|
codeTempService.insertBatch(codeTempEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dealProcess(orderEntity);
|
|
|
|
|
if (!ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success("单据上传成功!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手持终端-----待配货(无三期,有三期)单据提交
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public BaseResponse waitOrderByPda(PdaPostOrderRequest pdaPostOrderRequest) {
|
|
|
|
|
IoOrderEntity orderEntity = pdaPostOrderRequest.getOrderEntity();
|
|
|
|
|
IoOrderEntity temp = orderService.findByBillNo(orderEntity.getBillNo());
|
|
|
|
|
BaseResponse tempResponse = checkSubmitEnable(temp);
|
|
|
|
|
if (tempResponse != null)
|
|
|
|
|
return tempResponse;
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> orderDetailBizEntities = pdaPostOrderRequest.getOrderDetailBizEntities();
|
|
|
|
|
List<IoCodeTempEntity> codeTempEntities = pdaPostOrderRequest.getCodeTempEntities();
|
|
|
|
|
|
|
|
|
|
orderDetailBizService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
orderDetailCodeService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
codeTempService.deleteByBillNo(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
|
|
|
|
|
orderDetailBizEntities.forEach(orderDetailBizEntity -> {
|
|
|
|
|
orderDetailBizService.insert(orderDetailBizEntity);
|
|
|
|
|
IoOrderDetailCodeEntity orderDetailCodeEntity = new IoOrderDetailCodeEntity();
|
|
|
|
|
BeanUtils.copyProperties(orderDetailBizEntity, orderDetailCodeEntity);
|
|
|
|
|
orderDetailCodeEntity.setReCount(orderDetailBizEntity.getScanCount());
|
|
|
|
|
orderDetailCodeEntity.setCount(orderDetailBizEntity.getCodeCount());
|
|
|
|
|
orderDetailCodeService.insert(orderDetailCodeEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(codeTempEntities)) {
|
|
|
|
|
codeTempEntities.forEach(codeTempEntity -> {
|
|
|
|
|
codeTempService.insert(codeTempEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
BasicBussinessTypeEntity bussinessTypeEntity = basicBussinessTypeService.findByAction(orderEntity.getAction());
|
|
|
|
|
if (ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
|
|
|
|
|
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = orderDetailCodeService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
|
|
|
|
|
if (bussinessTypeEntity.getCheckWebNew() == 1) {
|
|
|
|
|
String errMsg = ioCheckInoutService.bizOrderCheck(orderDetailBizEntities, orderDetailCodeEntities);
|
|
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
|
|
return ResultVOUtils.error(500, errMsg);
|
|
|
|
|
}
|
|
|
|
|
errMsg = ioCheckInoutService.codeOrderCheck(orderDetailCodeEntities, orderDetailBizEntities);
|
|
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
|
|
return ResultVOUtils.error(500, errMsg);
|
|
|
|
|
}
|
|
|
|
|
// saveOrderWeb(addOrderRequest);
|
|
|
|
|
orderEntity.setStatus(ORDER_STATUS_CHECK_PROCESS);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
} else {
|
|
|
|
|
String errMsg = ioCheckInoutService.bizNoPiCheck(orderDetailBizEntities, orderEntity);
|
|
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
|
|
return ResultVOUtils.error(500, errMsg);
|
|
|
|
|
}
|
|
|
|
|
orderDetailBizService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
for (IoOrderDetailCodeEntity orderDetailCodeEntity : orderDetailCodeEntities) {
|
|
|
|
|
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
|
|
|
BeanUtils.copyProperties(orderDetailCodeEntity, orderDetailBizEntity);
|
|
|
|
|
orderDetailBizEntity.setId(null);
|
|
|
|
|
orderDetailBizEntity.setCount(IntUtil.value(orderDetailCodeEntity.getReCount()));
|
|
|
|
|
ioCheckInoutService.getSomeBiz(orderDetailBizEntities, orderDetailBizEntity);
|
|
|
|
|
orderDetailBizService.insert(orderDetailBizEntity);
|
|
|
|
|
}
|
|
|
|
|
// saveOrderWeb(addOrderRequest);
|
|
|
|
|
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_CHECK);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
dealProcess(orderEntity);
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return ResultVOUtils.error(500, "单据校验提交失败,请先录入业务单据!");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
orderEntity.setStatus(ORDER_STATUS_CHECK_PROCESS);
|
|
|
|
|
dealProcess(orderEntity);
|
|
|
|
|
ioCheckInoutService.check(orderEntity.getBillNo());
|
|
|
|
|
return ResultVOUtils.success("提交成功!");
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success("提交成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手持终端------扫码结果提交
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public BaseResponse checkCodeResultByPda(Integer checkWebNewType, PdaPostOrderRequest pdaPostOrderRequest) {
|
|
|
|
|
|
|
|
|
|
IoOrderEntity orderEntity = pdaPostOrderRequest.getOrderEntity();
|
|
|
|
|
IoOrderEntity temp = orderService.findByBillNo(orderEntity.getBillNo());
|
|
|
|
|
BaseResponse tempResponse = checkSubmitEnable(temp);
|
|
|
|
|
if (tempResponse != null)
|
|
|
|
|
return tempResponse;
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> orderDetailBizEntities = pdaPostOrderRequest.getOrderDetailBizEntities();
|
|
|
|
|
List<IoCodeTempEntity> codeTempEntities = pdaPostOrderRequest.getCodeTempEntities();
|
|
|
|
|
|
|
|
|
|
orderDetailBizService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
orderDetailCodeService.deleteByOrderId(orderEntity.getBillNo());
|
|
|
|
|
codeTempService.deleteByBillNo(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(orderDetailBizEntities)) {
|
|
|
|
|
orderDetailBizEntities.forEach(orderDetailBizEntity -> {
|
|
|
|
|
orderDetailBizService.insert(orderDetailBizEntity);
|
|
|
|
|
IoOrderDetailCodeEntity orderDetailCodeEntity = new IoOrderDetailCodeEntity();
|
|
|
|
|
BeanUtils.copyProperties(orderDetailBizEntity, orderDetailCodeEntity);
|
|
|
|
|
orderDetailCodeEntity.setReCount(orderDetailBizEntity.getScanCount());
|
|
|
|
|
orderDetailCodeEntity.setCount(orderDetailBizEntity.getCodeCount());
|
|
|
|
|
orderDetailCodeService.insert(orderDetailCodeEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(codeTempEntities)) {
|
|
|
|
|
codeTempEntities.forEach(codeTempEntity -> {
|
|
|
|
|
codeTempService.insert(codeTempEntity);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
orderEntity.setStatus(ORDER_STATUS_CHECK_PROCESS);
|
|
|
|
|
orderEntity.setDealStatus(ConstantStatus.ORDER_DEAL_POST);
|
|
|
|
|
orderService.update(orderEntity);
|
|
|
|
|
ioCheckInoutService.checkCodeResult(orderEntity.getBillNo());
|
|
|
|
|
// if (checkWebNewType == 0) {
|
|
|
|
|
//
|
|
|
|
|
// } else {
|
|
|
|
|
// dealProcess(orderEntity);
|
|
|
|
|
// ioCheckInoutService.checkRightResult(orderEntity.getBillNo());
|
|
|
|
|
// }
|
|
|
|
|
return ResultVOUtils.success("提交成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//校验条码关联供应商
|
|
|
|
|
public String checkExitSup(IoCodeTempEntity ioCodeTempEntity) {
|
|
|
|
|
Long relId = ioCodeTempEntity.getRelId();
|
|
|
|
|
String batchNo = ioCodeTempEntity.getBatchNo();
|
|
|
|
|
|
|
|
|
|
FilterCompanyProductRelevanceRequest filterCompanyProductRelevanceRequest = new FilterCompanyProductRelevanceRequest();
|
|
|
|
|
filterCompanyProductRelevanceRequest.setUdiRlIdFk(relId + "");
|
|
|
|
|
List<UdiRlSupEntity> companyProductRelevanceEntities = udiRlSupService.filterCompanyProductRelevance(filterCompanyProductRelevanceRequest);
|
|
|
|
|
if (companyProductRelevanceEntities != null && companyProductRelevanceEntities.size() == 1) {
|
|
|
|
|
UdiRlSupEntity udiRlSupEntity = companyProductRelevanceEntities.get(0);
|
|
|
|
|
return udiRlSupEntity.getUnitFk();
|
|
|
|
|
} else if (companyProductRelevanceEntities != null && companyProductRelevanceEntities.size() > 1) {
|
|
|
|
|
//携带供应商号列表
|
|
|
|
|
List<String> unitFks = new ArrayList<>(companyProductRelevanceEntities.size());
|
|
|
|
|
String unitFk = companyProductRelevanceEntities.get(0).getUnitFk();
|
|
|
|
|
boolean isMuti = false;
|
|
|
|
|
for (UdiRlSupEntity udiRlSupEntity : companyProductRelevanceEntities) {
|
|
|
|
|
unitFks.add(udiRlSupEntity.getUnitFk());
|
|
|
|
|
if (!unitFk.equals(udiRlSupEntity.getUnitFk())) {
|
|
|
|
|
isMuti = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isMuti) {
|
|
|
|
|
//过滤掉库存数量为0的供应商
|
|
|
|
|
if (relId != null && StrUtil.isNotEmpty(batchNo)) {
|
|
|
|
|
unitFks = invProductService.filterReCount(relId, batchNo, unitFks);
|
|
|
|
|
if (unitFks != null && unitFks.size() == 1) {
|
|
|
|
|
return unitFks.get(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "MUTI"; //绑定多个供应商
|
|
|
|
|
} else return unitFk;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String checkInvExitSup(IoCodeEntity codeEnttity) {
|
|
|
|
|
String supId = checkNorInv(codeEnttity);
|
|
|
|
|
if (supId == null) {
|
|
|
|
|
return checkPreInv(codeEnttity);
|
|
|
|
|
}
|
|
|
|
|
return supId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查普通库存 todo
|
|
|
|
|
public String checkNorInv(IoCodeEntity codeEnttity) {
|
|
|
|
|
|
|
|
|
|
// FilterInvWarehouseRequest filterInvWarehouseRequest = new FilterInvWarehouseRequest();
|
|
|
|
|
// filterInvWarehouseRequest.setLevel(1);
|
|
|
|
|
// filterInvWarehouseRequest.setAdvanceType(false);
|
|
|
|
|
// List<InvWarehouseEntity> invWarehouseEntities = invWarehouseService.filterInvWarehouse(filterInvWarehouseRequest);
|
|
|
|
|
// List<String> codes = new ArrayList<>();
|
|
|
|
|
// if (!invWarehouseEntities.isEmpty()) {
|
|
|
|
|
// for (InvWarehouseEntity invWarehouseEntity : invWarehouseEntities) {
|
|
|
|
|
// codes.add(invWarehouseEntity.getCode());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// FilterInvProductRequest filterInvProductDetailRequest = new FilterInvProductRequest();
|
|
|
|
|
// filterInvProductDetailRequest.setRelIdFk(codeEnttity.getRelId());
|
|
|
|
|
// filterInvProductDetailRequest.setBatchNo(codeEnttity.getBatchNo());
|
|
|
|
|
// filterInvProductDetailRequest.setInvCodes(codes);
|
|
|
|
|
// List<InvProductEntity> invProductEntities = invProductService.filterInvProduct(filterInvProductDetailRequest);
|
|
|
|
|
// if (invProductEntities.size() > 0) {
|
|
|
|
|
// String supId = invProductEntities.get(0).getSupId();
|
|
|
|
|
// int count = 0;
|
|
|
|
|
// for (InvProductEntity invProductEntity : invProductEntities) {
|
|
|
|
|
// if (!supId.equals(invProductEntity.getSupId())) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// count = count + (invProductEntity.getInCount() - invProductEntity.getOutCount());
|
|
|
|
|
// }
|
|
|
|
|
// if (count > 0)
|
|
|
|
|
// return supId;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查寄售库存 todo
|
|
|
|
|
public String checkPreInv(IoCodeEntity codeEnttity) {
|
|
|
|
|
// FilterInvWarehouseRequest filterInvWarehouseRequest = new FilterInvWarehouseRequest();
|
|
|
|
|
// filterInvWarehouseRequest.setLevel(1);
|
|
|
|
|
// filterInvWarehouseRequest.setAdvanceType(true);
|
|
|
|
|
// List<InvWarehouseEntity> invWarehouseEntities = invWarehouseService.filterInvWarehouse(filterInvWarehouseRequest);
|
|
|
|
|
// List<String> codes = new ArrayList<>();
|
|
|
|
|
// if (!invWarehouseEntities.isEmpty()) {
|
|
|
|
|
// for (InvWarehouseEntity invWarehouseEntity : invWarehouseEntities) {
|
|
|
|
|
// codes.add(invWarehouseEntity.getCode());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// FilterInvProductRequest filterInvProductDetailRequest = new FilterInvProductRequest();
|
|
|
|
|
// filterInvProductDetailRequest.setRelIdFk(codeEnttity.getRelId());
|
|
|
|
|
// filterInvProductDetailRequest.setBatchNo(codeEnttity.getBatchNo());
|
|
|
|
|
// filterInvProductDetailRequest.setInvCodes(codes);
|
|
|
|
|
// List<InvProductEntity> invProductEntities = invPreProductService.filterInvProduct(filterInvProductDetailRequest);
|
|
|
|
|
// if (invProductEntities.size() > 0) {
|
|
|
|
|
// String supId = invProductEntities.get(0).getSupId();
|
|
|
|
|
// int count = 0;
|
|
|
|
|
// for (InvProductEntity invProductEntity : invProductEntities) {
|
|
|
|
|
// if (!supId.equals(invProductEntity.getSupId())) {
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// count = count + (invProductEntity.getInCount() - invProductEntity.getOutCount());
|
|
|
|
|
// }
|
|
|
|
|
// if (count > 0)
|
|
|
|
|
// return supId;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询本单是否有重复条码
|
|
|
|
|
public String checkOrderRepeatCode(IoCodeTempEntity codeEntity, List<IoCodeTempEntity> filterList) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
if (filterList != null) {
|
|
|
|
|
for (IoCodeTempEntity temp : filterList) {
|
|
|
|
|
if (temp.getCode().equals(codeEntity.getCode())
|
|
|
|
|
&& StrUtil.trimToEmpty(temp.getSerialNo()).equals(StrUtil.trimToEmpty(codeEntity.getSerialNo()))
|
|
|
|
|
&& StrUtil.trimToEmpty(temp.getInBatchNo()).equals(StrUtil.trimToEmpty(codeEntity.getInBatchNo()))
|
|
|
|
|
&& BigDecimalUtil.equalTo(temp.getPrice(), codeEntity.getPrice())
|
|
|
|
|
) {
|
|
|
|
|
count = count + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (count > 1) {
|
|
|
|
|
return codeEntity.getCode() + "条码重复";
|
|
|
|
|
} else
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String checkOriginCode(IoCodeTempEntity warehouseEntity) {
|
|
|
|
|
|
|
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(warehouseEntity.getCode());
|
|
|
|
|
//校验条码的完整性
|
|
|
|
|
String errMsg = "";
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByNameCode(udiEntity.getUdi());
|
|
|
|
|
if (udiRelevanceResponse == null) {
|
|
|
|
|
return "耗材字典不存在此产品";
|
|
|
|
|
}
|
|
|
|
|
InvProductDetailEntity invProductDetailEntity = invProductDetailService.sortFindByCode(warehouseEntity.getCode());
|
|
|
|
|
if (invProductDetailEntity != null) {
|
|
|
|
|
if (StrUtil.isEmpty(warehouseEntity.getBatchNo())) {
|
|
|
|
|
warehouseEntity.setBatchNo(invProductDetailEntity.getBatchNo());
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isEmpty(warehouseEntity.getProduceDate())) {
|
|
|
|
|
warehouseEntity.setProduceDate(invProductDetailEntity.getProduceDate());
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isEmpty(warehouseEntity.getExpireDate())) {
|
|
|
|
|
warehouseEntity.setExpireDate(invProductDetailEntity.getExpireDate());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(warehouseEntity.getBatchNo()) && !udiRelevanceResponse.getAllowNoBatch()) {
|
|
|
|
|
errMsg = errMsg + ",批次号";
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isEmpty(warehouseEntity.getProduceDate()) && !udiRelevanceResponse.getAllowNoProduct()) {
|
|
|
|
|
errMsg = errMsg + ",生产日期";
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isEmpty(warehouseEntity.getExpireDate()) && !udiRelevanceResponse.getAllowNoExpire()) {
|
|
|
|
|
errMsg = errMsg + ",失效日期";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(errMsg)) {
|
|
|
|
|
return "UDI码" + warehouseEntity.getCode() + "产品三期缺失请补齐" + errMsg.substring(1) + "";
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IoOrderDetailCodeEntity buildEntity(IoOrderEntity orderEntity, IoCodeTempEntity codeTempEntity, UdiRelevanceResponse udiRelevanceResponse) {
|
|
|
|
|
IoOrderDetailCodeEntity ioOrderDetailCodeEntity = new IoOrderDetailCodeEntity();
|
|
|
|
|
ioOrderDetailCodeEntity.setOrderIdFk(orderEntity.getBillNo());
|
|
|
|
|
ioOrderDetailCodeEntity.setBindRlFk(udiRelevanceResponse.getId());
|
|
|
|
|
ioOrderDetailCodeEntity.setUuidFk(udiRelevanceResponse.getUuid());
|
|
|
|
|
ioOrderDetailCodeEntity.setBatchNo(codeTempEntity.getBatchNo());
|
|
|
|
|
ioOrderDetailCodeEntity.setNameCode(codeTempEntity.getNameCode());
|
|
|
|
|
ioOrderDetailCodeEntity.setProductDate(codeTempEntity.getProduceDate());
|
|
|
|
|
ioOrderDetailCodeEntity.setExpireDate(codeTempEntity.getExpireDate());
|
|
|
|
|
ioOrderDetailCodeEntity.setCoName(udiRelevanceResponse.getCpmctymc());
|
|
|
|
|
ioOrderDetailCodeEntity.setCertCode(udiRelevanceResponse.getZczbhhzbapzbh());
|
|
|
|
|
ioOrderDetailCodeEntity.setYlqxzcrbarmc(udiRelevanceResponse.getYlqxzcrbarmc());
|
|
|
|
|
ioOrderDetailCodeEntity.setManufacturer(udiRelevanceResponse.getManufactory());
|
|
|
|
|
ioOrderDetailCodeEntity.setMeasname(udiRelevanceResponse.getMeasname());
|
|
|
|
|
ioOrderDetailCodeEntity.setSpec(udiRelevanceResponse.getGgxh());
|
|
|
|
|
ioOrderDetailCodeEntity.setSupId(codeTempEntity.getSupId());
|
|
|
|
|
if (codeTempEntity.getPrice() == null) {
|
|
|
|
|
ioOrderDetailCodeEntity.setPrice(udiRelevanceResponse.getPrice());
|
|
|
|
|
codeTempEntity.setPrice(udiRelevanceResponse.getPrice());
|
|
|
|
|
codeTempService.updateById(codeTempEntity);
|
|
|
|
|
} else {
|
|
|
|
|
ioOrderDetailCodeEntity.setPrice(codeTempEntity.getPrice());
|
|
|
|
|
}
|
|
|
|
|
ioOrderDetailCodeEntity.setCount(codeTempEntity.getCount());
|
|
|
|
|
ioOrderDetailCodeEntity.setReCount(codeTempEntity.getMyReCount());
|
|
|
|
|
ioOrderDetailCodeEntity.setUpdateTime(new Date());
|
|
|
|
|
return ioOrderDetailCodeEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
BasicSkSickerService basicSkSickerService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 临床出库时更新往来单位信息
|
|
|
|
|
*/
|
|
|
|
|
public String updateCorp(BasicBussinessTypeEntity bussinessTypeEntity, String fromCorp, String adNum) {
|
|
|
|
|
BasicCorpEntity basicCorpEntity;
|
|
|
|
|
BasicSkSickerEntity basicSkSickerEntity;
|
|
|
|
|
|
|
|
|
|
//要是特殊往来信息没有就创建
|
|
|
|
|
if (bussinessTypeEntity.getCorpType() == ConstantStatus.CORP_TYPE_INPUT && bussinessTypeEntity.isGenUnit()) {
|
|
|
|
|
if (StrUtil.isNotEmpty(adNum)) {
|
|
|
|
|
basicCorpEntity = basicCorpService.findBySickAdNum(adNum);
|
|
|
|
|
if (basicCorpEntity == null) {
|
|
|
|
|
basicSkSickerEntity = basicSkSickerService.findByAdNum(adNum);
|
|
|
|
|
if (basicSkSickerEntity != null) {
|
|
|
|
|
basicCorpEntity = new BasicCorpEntity();
|
|
|
|
|
basicCorpEntity.setName(basicSkSickerEntity.getName() + " " + basicSkSickerEntity.getAdNum());
|
|
|
|
|
basicCorpEntity.setAdSickNum(basicSkSickerEntity.getAdNum());
|
|
|
|
|
genBasicCorp(basicCorpEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
basicCorpEntity = basicCorpService.selectByName(fromCorp);
|
|
|
|
|
}
|
|
|
|
|
if (basicCorpEntity == null) {
|
|
|
|
|
basicCorpEntity = new BasicCorpEntity();
|
|
|
|
|
basicCorpEntity.setName(fromCorp);
|
|
|
|
|
genBasicCorp(basicCorpEntity);
|
|
|
|
|
}
|
|
|
|
|
return basicCorpEntity.getErpId();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return fromCorp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void genBasicCorp(BasicCorpEntity basicCorpEntity) {
|
|
|
|
|
basicCorpEntity.setErpId(CustomUtil.getUnitId());
|
|
|
|
|
basicCorpEntity.setCorpType(ConstantStatus.CORP_SICK);
|
|
|
|
|
basicCorpEntity.setOutType(ConstantStatus.CORP_SICK_SICK);
|
|
|
|
|
basicCorpEntity.setId(IdUtil.getSnowflakeNextId());
|
|
|
|
|
basicCorpService.insert(basicCorpEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BaseResponse checkSubmitEnable(IoOrderEntity orderEntity) {
|
|
|
|
|
if (orderEntity == null) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败,请先添加物资!");
|
|
|
|
|
}
|
|
|
|
|
if (orderEntity.getStatus() == ORDER_STATUS_CHECK_PROCESS || orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_PROCESS
|
|
|
|
|
|| orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_PROCESSING) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败,单据正在处理,请稍后刷新查看!");
|
|
|
|
|
}
|
|
|
|
|
if (orderEntity.getStatus() != 1 && orderEntity.getStatus() != 3 && orderEntity.getStatus() != 4 && orderEntity.getStatus() != 6) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败,单据已提交,请稍后刷新查看!");
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
InvPreProductDetailService invPreProductDetailService;
|
|
|
|
|
@Resource
|
|
|
|
|
InvPreinProductDetailService invPreinProductDetailService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手持终端上传校验库存
|
|
|
|
|
*/
|
|
|
|
|
public BaseResponse checkInv(BasicBussinessTypeEntity bussinessTypeEntity, List<IoOrderDetailBizEntity> orderDetailBizEntities, IoOrderEntity orderEntity, List<IoCodeTempEntity> codeTempEntities) {
|
|
|
|
|
if (bussinessTypeEntity.isScanPreIn()) { //校验预验收库存
|
|
|
|
|
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_PREIN);
|
|
|
|
|
for (IoCodeTempEntity codeTempEntity : codeTempEntities) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (checkDiAttribute(bussinessTypeEntity, codeTempEntity.getRelId(), 2)) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) {
|
|
|
|
|
if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) {
|
|
|
|
|
count = invPreinProductDetailService.vailStockCountByCode(null, invWarehouseEntity.getCode(), null, codeTempEntity.getCode());
|
|
|
|
|
} else
|
|
|
|
|
count = invPreinProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), null, invWarehouseEntity.getCode(), null);
|
|
|
|
|
} else if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_SET) {
|
|
|
|
|
if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) {
|
|
|
|
|
count = invPreinProductDetailService.vailStockCountByCode(null, invWarehouseEntity.getCode(), codeTempEntity.getPreInSpaceCode(), codeTempEntity.getCode());
|
|
|
|
|
} else
|
|
|
|
|
count = invPreinProductDetailService.vailStockCount(codeTempEntity.getRelId(), codeTempEntity.getBatchNo(), codeTempEntity.getSupId(), null, invWarehouseEntity.getCode(), codeTempEntity.getPreInSpaceCode());
|
|
|
|
|
}
|
|
|
|
|
if (count < IntUtil.value(codeTempEntity.getReCount())) {
|
|
|
|
|
return ResultVOUtils.error(500, "UDI码:" + codeTempEntity.getCode() + "预验收库存数量不足!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (bussinessTypeEntity.isAdvancePreIn()) { //校验寄售库存
|
|
|
|
|
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_ADVANCE);
|
|
|
|
|
for (IoOrderDetailBizEntity orderDetailCodeEntity : orderDetailBizEntities) {
|
|
|
|
|
if (checkDiAttribute(bussinessTypeEntity, orderDetailCodeEntity.getBindRlFk(), 3)) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) {
|
|
|
|
|
count = invPreProductDetailService.vailStockCount(orderDetailCodeEntity.getBindRlFk(), orderDetailCodeEntity.getBatchNo(), orderDetailCodeEntity.getSupId(), null, invWarehouseEntity.getCode(), null);
|
|
|
|
|
} else if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_SET) {
|
|
|
|
|
count = invPreProductDetailService.vailStockCount(orderDetailCodeEntity.getBindRlFk(), orderDetailCodeEntity.getBatchNo(), orderDetailCodeEntity.getSupId(), null, invWarehouseEntity.getCode(), orderEntity.getPreCurSpaceCode());
|
|
|
|
|
}
|
|
|
|
|
if (count < orderDetailCodeEntity.getScanCount()) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败," + orderDetailCodeEntity.getCoName() + "库存数量不足!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else { //校验普通库存
|
|
|
|
|
if (bussinessTypeEntity.isVailInv() && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
|
|
|
|
|
String outInvCode = orderEntity.getInvCode();
|
|
|
|
|
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findNoInvTypeInv(bussinessTypeEntity.getDeptNoInvType(), outInvCode);
|
|
|
|
|
if (invWarehouseEntity != null) {
|
|
|
|
|
outInvCode = invWarehouseEntity.getCode();
|
|
|
|
|
}
|
|
|
|
|
for (IoOrderDetailBizEntity orderDetailCodeEntity : orderDetailBizEntities) {
|
|
|
|
|
if (checkDiAttribute(bussinessTypeEntity, orderDetailCodeEntity.getBindRlFk(), 1)) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) {
|
|
|
|
|
count = invProductDetailService.vailStockCount(orderDetailCodeEntity.getBindRlFk(), orderDetailCodeEntity.getBatchNo(), orderDetailCodeEntity.getSupId(), null, outInvCode, null);
|
|
|
|
|
} else if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_SET) {
|
|
|
|
|
count = invProductDetailService.vailStockCount(orderDetailCodeEntity.getBindRlFk(), orderDetailCodeEntity.getBatchNo(), orderDetailCodeEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderEntity.getCurSpaceCode());
|
|
|
|
|
}
|
|
|
|
|
if (count < orderDetailCodeEntity.getScanCount()) {
|
|
|
|
|
return ResultVOUtils.error(500, "提交失败," + orderDetailCodeEntity.getCoName() + "库存数量不足!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public boolean checkDiAttribute(BasicBussinessTypeEntity bussinessTypeEntity, Long relId, Integer purType) {
|
|
|
|
|
if (bussinessTypeEntity.getUseDyCount() == 2) {
|
|
|
|
|
if (udiRelevanceService.findPurType(relId) == IntUtil.value(purType)) {
|
|
|
|
|
return true;
|
|
|
|
|
} else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 手持终端上传校验价格
|
|
|
|
|
*/
|
|
|
|
|
public List<IoCodeTempEntity> checkPrice(IoCodeTempEntity codeTempEntity, BasicBussinessTypeEntity bussinessTypeEntity, List<IoCodeTempEntity> codeTempEntities) {
|
|
|
|
|
|
|
|
|
|
List<IoCodeTempEntity> filteredAndSorted = codeTempEntities.stream()
|
|
|
|
|
.filter(person -> IntUtil.value(person.getRelId()) == IntUtil.value(codeTempEntity.getRelId())
|
|
|
|
|
&& StrUtil.trimToEmpty(person.getBatchNo()).equals(StrUtil.trimToEmpty(codeTempEntity.getBatchNo()))
|
|
|
|
|
)
|
|
|
|
|
.sorted(Comparator.comparing(IoCodeTempEntity::getInBatchNo, Comparator.nullsLast(Comparator.naturalOrder())))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
Map<String, List<IoCodeTempEntity>> stringListMap = null;
|
|
|
|
|
if (CollUtil.isNotEmpty(filteredAndSorted)) {
|
|
|
|
|
stringListMap = filteredAndSorted.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(person -> StrUtil.trimToEmpty(person.getInBatchNo()))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
List<IoCodeTempEntity> lastList = null;
|
|
|
|
|
if (stringListMap != null) {
|
|
|
|
|
lastList = stringListMap.entrySet().stream().findFirst().get().getValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int exitCount = 0;
|
|
|
|
|
int extiReCount = 0;
|
|
|
|
|
if (CollUtil.isNotEmpty(lastList)) {
|
|
|
|
|
for (IoCodeTempEntity ioCodeTempEntity : lastList) {
|
|
|
|
|
exitCount = exitCount + ioCodeTempEntity.getCount();
|
|
|
|
|
extiReCount = extiReCount + ioCodeTempEntity.getReCount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//出库时填写价格与入库批次
|
|
|
|
|
//1.获取出库最新批次
|
|
|
|
|
String lastInBatch = null;
|
|
|
|
|
if (exitCount > 0) {
|
|
|
|
|
lastInBatch = lastList.get(0).getInBatchNo();
|
|
|
|
|
} else {
|
|
|
|
|
InvProductDetailEntity invProductDetailEntity = invProductDetailService.selectLastInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), codeTempEntity.getMainAction());
|
|
|
|
|
if (invProductDetailEntity != null) {
|
|
|
|
|
lastInBatch = invProductDetailEntity.getInBatchNo();
|
|
|
|
|
codeTempEntity.setPrice(invProductDetailEntity.getPrice());
|
|
|
|
|
codeTempEntity.setInBatchNo(invProductDetailEntity.getInBatchNo());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (lastInBatch == null && exitCount == 0) {
|
|
|
|
|
//首次出库,获取入库最早批次
|
|
|
|
|
InvProductDetailEntity inProductDetail = invProductDetailService.selectFirstInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), ConstantType.TYPE_PUT);
|
|
|
|
|
if (inProductDetail != null) {
|
|
|
|
|
codeTempEntity.setPrice(inProductDetail.getPrice());
|
|
|
|
|
codeTempEntity.setInBatchNo(inProductDetail.getInBatchNo());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//非首次出库
|
|
|
|
|
//1.获取当前批次已出库数量
|
|
|
|
|
Integer outCount = IntUtil.value(invProductDetailService.selectCountByInBatch(codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), bussinessTypeEntity, lastInBatch, codeTempEntity.getInvCode(), ConstantType.TYPE_OUT));
|
|
|
|
|
//2.获取当前批次入库数量
|
|
|
|
|
Integer inCount = IntUtil.value(invProductDetailService.selectCountByInBatch(codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), bussinessTypeEntity, lastInBatch, codeTempEntity.getInvCode(), ConstantType.TYPE_PUT));
|
|
|
|
|
//3.若数量还有剩,则此次出库为当前批次
|
|
|
|
|
if (inCount >= (outCount + extiReCount + codeTempEntity.getReCount())) {
|
|
|
|
|
|
|
|
|
|
if (lastList != null) {
|
|
|
|
|
codeTempEntity.setPrice(lastList.get(0).getPrice());
|
|
|
|
|
codeTempEntity.setInBatchNo(lastList.get(0).getInBatchNo());
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// 4.若数量不足,则出下一批次
|
|
|
|
|
InvProductDetailEntity nextInvProduct = invProductDetailService.selectNextInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), ConstantType.TYPE_PUT, lastInBatch);
|
|
|
|
|
if (nextInvProduct != null) {
|
|
|
|
|
codeTempEntity.setPrice(nextInvProduct.getPrice());
|
|
|
|
|
codeTempEntity.setInBatchNo(nextInvProduct.getInBatchNo());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
codeTempEntities.add(codeTempEntity);
|
|
|
|
|
return codeTempEntities;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|