|
|
@@ -18,6 +18,7 @@ package org.springblade.purchase.sales.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
@@ -646,7 +647,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
// 判断是否有审批流,如果审批流已开启就进入审批流,否则直接走申请通过
|
|
|
Integer checkFlag = order.getCheckFlag();
|
|
|
- AuditPathsActs pathsActs = null;
|
|
|
+ AuditPathsActs pathsActs;
|
|
|
if (checkFlag == null) {
|
|
|
throw new SecurityException("请核失败:未配置请核标识");
|
|
|
}
|
|
|
@@ -703,11 +704,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 判断是采购审批 还是 销售审批
|
|
|
- if (checkFlag == 2) {
|
|
|
- pathsActs = iCheckClient.getActsByActId(3, "status");
|
|
|
- } else if (checkFlag == 1) {
|
|
|
+ // 判断是采购审批 还是 销售审批 新增3特批审核
|
|
|
+ if (checkFlag == 1) {
|
|
|
pathsActs = iCheckClient.getActsByActId(4, "status");
|
|
|
+ } else if (checkFlag == 2) {
|
|
|
+ pathsActs = iCheckClient.getActsByActId(3, "status");
|
|
|
+ } else if (checkFlag == 3) {
|
|
|
+ pathsActs = iCheckClient.getActsByActId(13, "status");
|
|
|
} else {
|
|
|
throw new SecurityException("请核失败:请核标识设置不正确");
|
|
|
}
|
|
|
@@ -717,16 +720,24 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
if (pathsActs == null || pathsActs.getIsEnable() == 2) {
|
|
|
throw new SecurityException("当前租户未查询到审批流配置");
|
|
|
} else {
|
|
|
- salesOrder.setStatus(1);
|
|
|
- salesOrder.setCheckDate(new Date());
|
|
|
+ if (checkFlag == 3) {
|
|
|
+ salesOrder.setSpecialCheckStatus(1);
|
|
|
+ salesOrder.setSpecialCheckUser(AuthUtil.getUserName());
|
|
|
+ salesOrder.setSpecialCheckTime(new Date());
|
|
|
+ } else {
|
|
|
+ salesOrder.setStatus(1);
|
|
|
+ salesOrder.setCheckDate(new Date());
|
|
|
+ }
|
|
|
baseMapper.updateById(salesOrder);
|
|
|
|
|
|
//获取审批级次
|
|
|
List<AuditPathsLevels> auditPathsLevels;
|
|
|
- if (checkFlag == 2) {
|
|
|
+ if (checkFlag == 1) {
|
|
|
+ auditPathsLevels = iCheckClient.listLevelsByActId(4, "status");
|
|
|
+ } else if (checkFlag == 2){
|
|
|
auditPathsLevels = iCheckClient.listLevelsByActId(3, "status");
|
|
|
} else {
|
|
|
- auditPathsLevels = iCheckClient.listLevelsByActId(4, "status");
|
|
|
+ auditPathsLevels = iCheckClient.listLevelsByActId(13, "status");
|
|
|
}
|
|
|
if (CollectionUtils.isEmpty(auditPathsLevels)) {
|
|
|
throw new SecurityException("开启审批失败:未查询到审批信息");
|
|
|
@@ -749,10 +760,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
auditProecessDTO.setPageLabel(order.getPageLabel());
|
|
|
//增加审批类型
|
|
|
|
|
|
- if (checkFlag == 2) {
|
|
|
+ if (checkFlag == 1) {
|
|
|
+ auditProecessDTO.setProcessType("采购审批");
|
|
|
+ } else if (checkFlag == 2) {
|
|
|
auditProecessDTO.setProcessType("销售审批");
|
|
|
} else {
|
|
|
- auditProecessDTO.setProcessType("采购审批");
|
|
|
+ auditProecessDTO.setProcessType("销售特批审批");
|
|
|
}
|
|
|
LambdaQueryWrapper<OrderItems> orderItemsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
orderItemsLambdaQueryWrapper
|
|
|
@@ -1012,6 +1025,41 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void passSpecialCheck(Long id) {
|
|
|
+ Order order = baseMapper.selectById(id);
|
|
|
+ if (order == null) {
|
|
|
+ throw new SecurityException("审批失败");
|
|
|
+ }
|
|
|
+ order.setSpecialCheck(1);
|
|
|
+ order.setSpecialCheckStatus(3);
|
|
|
+ baseMapper.updateById(order);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void underSpecialReview(Long id) {
|
|
|
+ Order order = baseMapper.selectById(id);
|
|
|
+ if (order == null) {
|
|
|
+ throw new SecurityException("审批失败");
|
|
|
+ }
|
|
|
+ order.setSpecialCheckStatus(2);
|
|
|
+ baseMapper.updateById(order);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void passSpecialCancel(Long id) {
|
|
|
+ Order order = baseMapper.selectById(id);
|
|
|
+ if (order == null) {
|
|
|
+ throw new SecurityException("审批失败");
|
|
|
+ }
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<Order>()
|
|
|
+ .set(Order::getSpecialCheckStatus, 0)
|
|
|
+ .set(Order::getSpecialCheckUser, null)
|
|
|
+ .set(Order::getSpecialCheckTime, null)
|
|
|
+ .eq(Order::getId, id)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@GlobalTransactional(rollbackFor = Exception.class)
|
|
|
public void repealCancel(Order orderMessage) {
|
|
|
@@ -1023,68 +1071,81 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
if (order == null) {
|
|
|
throw new SecurityException("未找到订单");
|
|
|
}
|
|
|
- if (order.getStatus() == 0) {
|
|
|
- throw new SecurityException("订单未开启审批");
|
|
|
- }
|
|
|
- if (order.getStatus() != 1) {
|
|
|
- throw new SecurityException("订单已经开启审批不能撤销");
|
|
|
- }
|
|
|
- // 销售审核撤销释放库存
|
|
|
- if ("XS".equals(order.getBillType()) && "681169".equals(SecureUtil.getTenantId())) {
|
|
|
- // ===========================Start 审核撤销释放库存=============================
|
|
|
- // 获取此销售订单下,所有明细的库存
|
|
|
- LambdaQueryWrapper<OrderItems> orderItemsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- orderItemsLambdaQueryWrapper
|
|
|
- .eq(OrderItems::getGoodType, 0)
|
|
|
- .eq(OrderItems::getPid, order.getId())
|
|
|
- .eq(OrderItems::getIsDeleted, 0);
|
|
|
- List<OrderItems> orderItems = orderItemsMapper.selectList(orderItemsLambdaQueryWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(orderItems)) {
|
|
|
- orderItems.forEach(e -> {
|
|
|
- StockGoods stockGoods = new StockGoods();
|
|
|
- stockGoods.setCorpId(e.getCorpId());
|
|
|
- stockGoods.setGoodsId(e.getItemId());
|
|
|
- stockGoods.setTenantId(SecureUtil.getTenantId());
|
|
|
- List<StockGoods> listStockGoods = stockGoodsClient.postListStockByCondition(stockGoods);
|
|
|
- if (listStockGoods.size() > 1 || CollectionUtils.isEmpty(listStockGoods)) {
|
|
|
- throw new SecurityException("撤销失败:未查询到库存 或者 存在多条库存记录");
|
|
|
- }
|
|
|
- // 开始锁定库存,减少可用
|
|
|
- StockGoods oneStock = stockGoodsClient.getOneStock(stockGoods);
|
|
|
- if (oneStock == null) {
|
|
|
- throw new SecurityException("撤销失败:未查询到库存信息");
|
|
|
- }
|
|
|
- // 原单据的订货数量
|
|
|
- BigDecimal orderQuantity = e.getOrderQuantity();
|
|
|
- // 可用库存
|
|
|
- BigDecimal surplusRouteQuantity = oneStock.getSurplusRouteQuantity();
|
|
|
- // 锁定库存
|
|
|
- BigDecimal lockingQuantity = oneStock.getLockingQuantity();
|
|
|
|
|
|
- // 判断比较大小
|
|
|
- if (orderQuantity.compareTo(lockingQuantity) > 0) {
|
|
|
- throw new SecurityException("撤销失败:原单据的订货数量大于锁定库存,无法释放 库存");
|
|
|
- }
|
|
|
- // 增加可用库存
|
|
|
- oneStock.setSurplusRouteQuantity(surplusRouteQuantity.add(orderQuantity));
|
|
|
- // 减少锁定库存
|
|
|
- oneStock.setLockingQuantity(lockingQuantity == null ? new BigDecimal("0") : lockingQuantity.subtract(orderQuantity));
|
|
|
- // 更新库存
|
|
|
- R r = stockGoodsClient.updateStock(oneStock);
|
|
|
- if (!r.isSuccess()) {
|
|
|
- throw new SecurityException("撤销失败: 更新库存失败");
|
|
|
- }
|
|
|
- });
|
|
|
+ if (orderMessage.getCheckFlag() != 3) {
|
|
|
+ if (order.getStatus() == 0) {
|
|
|
+ throw new SecurityException("订单未开启审批");
|
|
|
}
|
|
|
+ if (order.getStatus() != 1) {
|
|
|
+ throw new SecurityException("订单已经开启审批不能撤销");
|
|
|
+ }
|
|
|
+ // 销售审核撤销释放库存
|
|
|
+ if ("XS".equals(order.getBillType()) && "681169".equals(SecureUtil.getTenantId())) {
|
|
|
+ // ===========================Start 审核撤销释放库存=============================
|
|
|
+ // 获取此销售订单下,所有明细的库存
|
|
|
+ LambdaQueryWrapper<OrderItems> orderItemsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ orderItemsLambdaQueryWrapper
|
|
|
+ .eq(OrderItems::getGoodType, 0)
|
|
|
+ .eq(OrderItems::getPid, order.getId())
|
|
|
+ .eq(OrderItems::getIsDeleted, 0);
|
|
|
+ List<OrderItems> orderItems = orderItemsMapper.selectList(orderItemsLambdaQueryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(orderItems)) {
|
|
|
+ orderItems.forEach(e -> {
|
|
|
+ StockGoods stockGoods = new StockGoods();
|
|
|
+ stockGoods.setCorpId(e.getCorpId());
|
|
|
+ stockGoods.setGoodsId(e.getItemId());
|
|
|
+ stockGoods.setTenantId(SecureUtil.getTenantId());
|
|
|
+ List<StockGoods> listStockGoods = stockGoodsClient.postListStockByCondition(stockGoods);
|
|
|
+ if (listStockGoods.size() > 1 || CollectionUtils.isEmpty(listStockGoods)) {
|
|
|
+ throw new SecurityException("撤销失败:未查询到库存 或者 存在多条库存记录");
|
|
|
+ }
|
|
|
+ // 开始锁定库存,减少可用
|
|
|
+ StockGoods oneStock = stockGoodsClient.getOneStock(stockGoods);
|
|
|
+ if (oneStock == null) {
|
|
|
+ throw new SecurityException("撤销失败:未查询到库存信息");
|
|
|
+ }
|
|
|
+ // 原单据的订货数量
|
|
|
+ BigDecimal orderQuantity = e.getOrderQuantity();
|
|
|
+ // 可用库存
|
|
|
+ BigDecimal surplusRouteQuantity = oneStock.getSurplusRouteQuantity();
|
|
|
+ // 锁定库存
|
|
|
+ BigDecimal lockingQuantity = oneStock.getLockingQuantity();
|
|
|
+
|
|
|
+ // 判断比较大小
|
|
|
+ if (orderQuantity.compareTo(lockingQuantity) > 0) {
|
|
|
+ throw new SecurityException("撤销失败:原单据的订货数量大于锁定库存,无法释放 库存");
|
|
|
+ }
|
|
|
+ // 增加可用库存
|
|
|
+ oneStock.setSurplusRouteQuantity(surplusRouteQuantity.add(orderQuantity));
|
|
|
+ // 减少锁定库存
|
|
|
+ oneStock.setLockingQuantity(lockingQuantity == null ? new BigDecimal("0") : lockingQuantity.subtract(orderQuantity));
|
|
|
+ // 更新库存
|
|
|
+ R r = stockGoodsClient.updateStock(oneStock);
|
|
|
+ if (!r.isSuccess()) {
|
|
|
+ throw new SecurityException("撤销失败: 更新库存失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ order.setStatus(0);
|
|
|
+ baseMapper.updateById(order);
|
|
|
+ } else {
|
|
|
+ baseMapper.update(null, new LambdaUpdateWrapper<Order>()
|
|
|
+ .set(Order::getSpecialCheckStatus, 0)
|
|
|
+ .set(Order::getSpecialCheckUser, null)
|
|
|
+ .set(Order::getSpecialCheckTime, null)
|
|
|
+ .eq(Order::getId, orderMessage.getId())
|
|
|
+ );
|
|
|
}
|
|
|
- order.setStatus(0);
|
|
|
- baseMapper.updateById(order);
|
|
|
+
|
|
|
// 删除审批流数据
|
|
|
AuditProecessDTO proecessDTO = new AuditProecessDTO();
|
|
|
- if (orderMessage.getCheckFlag() == 2) {
|
|
|
- proecessDTO.setProcessType("销售审批");
|
|
|
- } else if (orderMessage.getCheckFlag() == 1) {
|
|
|
+ if (orderMessage.getCheckFlag() == 1) {
|
|
|
proecessDTO.setProcessType("采购审批");
|
|
|
+ } else if (orderMessage.getCheckFlag() == 2) {
|
|
|
+ proecessDTO.setProcessType("销售审批");
|
|
|
+ } else {
|
|
|
+ proecessDTO.setProcessType("销售特批审批");
|
|
|
}
|
|
|
proecessDTO.setCheckType(orderMessage.getCheckType());
|
|
|
proecessDTO.setBillId(orderMessage.getId());
|