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

test
anthonywj 2 years ago
parent 30813b31bd
commit 6d5e0228d9

@ -38,4 +38,9 @@ public interface RedissonCacheKey {
* web * web
*/ */
String WEB_ADD_CODE = "web_add_code"; 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 cn.hutool.core.bean.BeanUtil;
import com.glxp.api.annotation.CusRedissonAnnotation; import com.glxp.api.annotation.CusRedissonAnnotation;
import com.glxp.api.constant.*; 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.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 com.glxp.api.service.system.SystemParamConfigService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
@ -87,6 +92,12 @@ public class IoOrderController extends BaseController {
CustomerService customerService; CustomerService customerService;
@Resource @Resource
private SystemParamConfigService systemParamConfigService; private SystemParamConfigService systemParamConfigService;
@Resource
InvPreProductDetailService invPreProductDetailService;
@Resource
InvPreinProductDetailService invPreinProductDetailService;
@Resource
InvProductDetailService invProductDetailService;
/** /**
* *
@ -1012,8 +1023,8 @@ public class IoOrderController extends BaseController {
@Resource @Resource
InvWarehouseService invWarehouseService; InvWarehouseService invWarehouseService;
@RepeatSubmit()
@AuthRuleAnnotation("") @AuthRuleAnnotation("")
@CusRedissonAnnotation(cacheName = RedissonCacheKey.COPY_ORDER, key = {"#addOrderChangeRequest.orderId"}, timeOutMsg = "系统正在处理,请勿重复提交")
@PostMapping("/udiwms/stock/order/change") @PostMapping("/udiwms/stock/order/change")
public BaseResponse stockOrderChange(@RequestBody AddOrderChangeRequest addOrderChangeRequest) { public BaseResponse stockOrderChange(@RequestBody AddOrderChangeRequest addOrderChangeRequest) {
@ -1058,21 +1069,46 @@ public class IoOrderController extends BaseController {
List<IoCodeEntity> products = addOrderChangeRequest.getProducts(); List<IoCodeEntity> products = addOrderChangeRequest.getProducts();
List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(originOrder.getBillNo()); List<IoOrderDetailBizEntity> orderDetailBizEntities = orderDetailBizService.findByOrderId(originOrder.getBillNo());
// 计算出两个集合之间产品批次号组成的差异 // 计算出两个集合之间产品批次号组成的差异
List<IoOrderDetailBizEntity> IoStatDayEntityList = orderDetailBizEntities.stream() List<IoOrderDetailBizEntity> insertBizList = orderDetailBizEntities.stream()
.filter(comment -> products.stream() .filter(comment -> products.stream()
.anyMatch(p -> Objects.equals(p.getBatchNo(), comment.getBatchNo()) // 使用 Objects.equals 来进行非空判断 .anyMatch(p -> Objects.equals(p.getBatchNo(), comment.getBatchNo()) // 使用 Objects.equals 来进行非空判断
&& Objects.equals(p.getRelId(), comment.getBindRlFk()))) && Objects.equals(p.getRelId(), comment.getBindRlFk())))
.collect(Collectors.toList()); .collect(Collectors.toList());
//生成业务单 //生成业务单
if (CollUtil.isNotEmpty(IoStatDayEntityList)) { if (CollUtil.isNotEmpty(insertBizList)) {
for (IoOrderDetailBizEntity orderDetailBizEntity : IoStatDayEntityList) { for (IoOrderDetailBizEntity orderDetailBizEntity : insertBizList) {
orderDetailBizEntity.setOrderIdFk(newOrder.getBillNo()); orderDetailBizEntity.setOrderIdFk(newOrder.getBillNo());
orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); 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( originCodes.forEach(
code -> { code -> {
//复制选中的产品 //复制选中的产品
@ -1228,4 +1264,51 @@ public class IoOrderController extends BaseController {
return bizEntity.getCoName() + "数量不匹配!"; 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) { if (purApplyRequest.getStatus() == null) {
purApplyRequest.setStatus(10); //查询未审核和已审核状态 purApplyRequest.setStatus(10); //查询未审核和已审核状态
} }
if (purApplyRequest.getIsInvCode() != null && purApplyRequest.getIsInvCode()) { // if (purApplyRequest.getIsInvCode() != null && purApplyRequest.getIsInvCode()) {
AuthAdmin authAdmin = customerService.getUserBean(); // AuthAdmin authAdmin = customerService.getUserBean();
purApplyRequest.setTargetInvCode(authAdmin.getLocInvCode() + ""); //查询自己仓库 // purApplyRequest.setTargetInvCode(authAdmin.getLocInvCode() + ""); //查询自己仓库
} // }
List<PurApplyResponse> purApplyEntities = purApplyService.queryPageList(purApplyRequest); List<PurApplyResponse> purApplyEntities = purApplyService.queryPageList(purApplyRequest);
PageInfo<PurApplyResponse> pageInfo; PageInfo<PurApplyResponse> pageInfo;
pageInfo = new PageInfo<>(purApplyEntities); pageInfo = new PageInfo<>(purApplyEntities);

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

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

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

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

Loading…
Cancel
Save