单据复制校验库存,申购加到货仓库

test
anthonywj 1 year ago
parent 30813b31bd
commit 6d5e0228d9

@ -38,4 +38,9 @@ public interface RedissonCacheKey {
* web
*/
String WEB_ADD_CODE = "web_add_code";
/**
*
*/
String COPY_ORDER = "copy_order";
}

@ -3,7 +3,12 @@ package com.glxp.api.controller.inout;
import cn.hutool.core.bean.BeanUtil;
import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.constant.*;
import com.glxp.api.entity.inv.InvPreInProductDetailEntity;
import com.glxp.api.res.inv.InvPlaceDetailResponse;
import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.inv.InvPreProductDetailService;
import com.glxp.api.service.inv.InvPreinProductDetailService;
import com.glxp.api.service.inv.impl.InvProductDetailService;
import com.glxp.api.service.system.SystemParamConfigService;
import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil;
@ -87,6 +92,12 @@ public class IoOrderController extends BaseController {
CustomerService customerService;
@Resource
private SystemParamConfigService systemParamConfigService;
@Resource
InvPreProductDetailService invPreProductDetailService;
@Resource
InvPreinProductDetailService invPreinProductDetailService;
@Resource
InvProductDetailService invProductDetailService;
/**
*
@ -1012,8 +1023,8 @@ public class IoOrderController extends BaseController {
@Resource
InvWarehouseService invWarehouseService;
@RepeatSubmit()
@AuthRuleAnnotation("")
@CusRedissonAnnotation(cacheName = RedissonCacheKey.COPY_ORDER, key = {"#addOrderChangeRequest.orderId"}, timeOutMsg = "系统正在处理,请勿重复提交")
@PostMapping("/udiwms/stock/order/change")
public BaseResponse stockOrderChange(@RequestBody AddOrderChangeRequest addOrderChangeRequest) {
@ -1058,21 +1069,46 @@ public class IoOrderController extends BaseController {
List<IoCodeEntity> products = addOrderChangeRequest.getProducts();
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(originOrder.getBillNo());
// 计算出两个集合之间产品批次号组成的差异
List<IoOrderDetailBizEntity> IoStatDayEntityList = orderDetailBizEntities.stream()
List<IoOrderDetailBizEntity> insertBizList = orderDetailBizEntities.stream()
.filter(comment -> products.stream()
.anyMatch(p -> Objects.equals(p.getBatchNo(), comment.getBatchNo()) // 使用 Objects.equals 来进行非空判断
&& Objects.equals(p.getRelId(), comment.getBindRlFk())))
.collect(Collectors.toList());
//生成业务单
if (CollUtil.isNotEmpty(IoStatDayEntityList)) {
for (IoOrderDetailBizEntity orderDetailBizEntity : IoStatDayEntityList) {
if (CollUtil.isNotEmpty(insertBizList)) {
for (IoOrderDetailBizEntity orderDetailBizEntity : insertBizList) {
orderDetailBizEntity.setOrderIdFk(newOrder.getBillNo());
orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId());
orderDetailBizService.insert(orderDetailBizEntity);
if (bussinessTypeEntity.isScanPreIn()) { //校验预验收库存
if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) {
BaseResponse invRes = checkPreInInv(orderDetailBizEntity);
if (invRes != null) {
return invRes;
}
}
} else if (bussinessTypeEntity.isAdvancePreIn()) { //校验寄售库存
if (bussinessTypeEntity.getSpaceOut() == ConstantStatus.SPACE_OUT_NULL) {
BaseResponse invRes = checkPreInv(orderDetailBizEntity);
if (invRes != null) {
return invRes;
}
}
} else {
if (bussinessTypeEntity.isVailInv() && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
BaseResponse invRes = checkInv(orderDetailBizEntity, newOrder);
if (invRes != null) {
return invRes;
}
}
}
}
orderDetailBizService.batchInsertBizs(insertBizList);
}
originCodes.forEach(
code -> {
//复制选中的产品
@ -1228,4 +1264,51 @@ public class IoOrderController extends BaseController {
return bizEntity.getCoName() + "数量不匹配!";
}
public BaseResponse checkInv(IoOrderDetailBizEntity bizEntity, IoOrderEntity orderEntity) {
int count = 0;
count = invProductDetailService.vailStockCount(bizEntity.getBindRlFk(), bizEntity.getBatchNo(), bizEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), null);
if (count <= 0) {
if (count == -1) {
return ResultVOUtils.error(500, "该产品未入库");
} else
return ResultVOUtils.error(500, "当前库存不足");
}
return null;
}
/**
*
*/
public BaseResponse checkPreInv(IoOrderDetailBizEntity bizEntity) {
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_ADVANCE);
int count = 0;
count = invPreProductDetailService.vailStockCount(bizEntity.getBindRlFk(), bizEntity.getBatchNo(), bizEntity.getSupId(), null, invWarehouseEntity.getCode(), null);
if (count <= 0) {
if (count == -1) {
return ResultVOUtils.error(500, "该产品未入库");
} else
return ResultVOUtils.error(500, "寄售库存数量不足!");
}
return null;
}
// 校验预验收库存
public BaseResponse checkPreInInv(IoOrderDetailBizEntity bizEntity) {
InvWarehouseEntity invWarehouseEntity = invWarehouseService.findByOne(ConstantStatus.ACTION_TYPE_PREIN);
int count = 0;
count = invPreinProductDetailService.vailStockCount(bizEntity.getBindRlFk(), bizEntity.getBatchNo(), bizEntity.getSupId(), null, invWarehouseEntity.getCode(), null);
if (count <= 0) {
if (count == -1) {
return ResultVOUtils.error(500, "该产品未入库");
} else
return ResultVOUtils.error(500, "预验收库存数量不足!");
}
return null;
}
}

@ -146,10 +146,10 @@ public class PurApplyController {
if (purApplyRequest.getStatus() == null) {
purApplyRequest.setStatus(10); //查询未审核和已审核状态
}
if (purApplyRequest.getIsInvCode() != null && purApplyRequest.getIsInvCode()) {
AuthAdmin authAdmin = customerService.getUserBean();
purApplyRequest.setTargetInvCode(authAdmin.getLocInvCode() + ""); //查询自己仓库
}
// if (purApplyRequest.getIsInvCode() != null && purApplyRequest.getIsInvCode()) {
// AuthAdmin authAdmin = customerService.getUserBean();
// purApplyRequest.setTargetInvCode(authAdmin.getLocInvCode() + ""); //查询自己仓库
// }
List<PurApplyResponse> purApplyEntities = purApplyService.queryPageList(purApplyRequest);
PageInfo<PurApplyResponse> pageInfo;
pageInfo = new PageInfo<>(purApplyEntities);

@ -33,6 +33,7 @@ public interface IoOrderDetailBizService {
boolean isExit(Long relId, String bacthNo, Long ignoreId, String orderId);
IoOrderDetailBizEntity findByUnique(String orderId, Long relId, String bacthNo, String productDate, String expireDate);
IoOrderDetailBizEntity findByUnique(String orderId, Long relId, String bacthNo);
@ -58,4 +59,7 @@ public interface IoOrderDetailBizService {
List<IoOrderDetailResultResponse> getInvoicResultDetail(FilterOrderDetailCodeRequest orderDetailBizRequest);
Boolean batchInsertBizs(List<IoOrderDetailBizEntity> bizEntities);
}

@ -149,6 +149,11 @@ public class IoOrderDetailBizServiceImpl implements IoOrderDetailBizService {
return ioOrderDetailBizDao.getfilterOrderList(OrderDetailCodeRequest);
}
@Override
public Boolean batchInsertBizs(List<IoOrderDetailBizEntity> bizEntities) {
return ioOrderDetailBizDao.insertBatch(bizEntities);
}
@Override
public IoOrderDetailBizEntity selectByBatchNoAndBindRlFk(String batchNo, String bindRlFk) {
QueryWrapper<IoOrderDetailBizEntity> ew = new QueryWrapper<>();

@ -470,6 +470,9 @@
<when test="key != null and key != ''">
GROUP BY basic_udirel.id
</when>
<otherwise>
GROUP BY basic_udirel.id,company_product_relevance.unitFk
</otherwise>
</choose>
</select>

@ -445,7 +445,7 @@
</foreach>
</if>
<if test="billNo != null and billNo != ''">
AND billNo like concat('%', #{billNo}, '%')
AND io.billNo like concat('%', #{billNo}, '%')
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}

Loading…
Cancel
Save