|
|
@@ -16,10 +16,7 @@ import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.OutboundConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.OutboundItemConvert;
|
|
|
import com.dk.mdm.mapper.common.CommonMapper;
|
|
|
-import com.dk.mdm.mapper.ivt.InboundItemMapper;
|
|
|
-import com.dk.mdm.mapper.ivt.InboundMapper;
|
|
|
-import com.dk.mdm.mapper.ivt.OutboundItemMapper;
|
|
|
-import com.dk.mdm.mapper.ivt.OutboundMapper;
|
|
|
+import com.dk.mdm.mapper.ivt.*;
|
|
|
import com.dk.mdm.mapper.mst.CustomerMapper;
|
|
|
import com.dk.mdm.mapper.sale.MultiOwnerMapper;
|
|
|
import com.dk.mdm.mapper.sale.OrderItemMapper;
|
|
|
@@ -34,20 +31,19 @@ import com.dk.mdm.model.pojo.pur.PurchaseItem;
|
|
|
import com.dk.mdm.model.pojo.sale.MultiOwner;
|
|
|
import com.dk.mdm.model.pojo.sale.Order;
|
|
|
import com.dk.mdm.model.pojo.sale.OrderItem;
|
|
|
+import com.dk.mdm.model.query.ivt.InventoryQuery;
|
|
|
import com.dk.mdm.model.query.ivt.OutboundItemQuery;
|
|
|
import com.dk.mdm.model.query.ivt.OutboundQuery;
|
|
|
import com.dk.mdm.model.query.sale.OrderQuery;
|
|
|
import com.dk.mdm.model.response.ivt.InboundResponse;
|
|
|
+import com.dk.mdm.model.response.ivt.InventoryResponse;
|
|
|
import com.dk.mdm.model.response.ivt.OutboundItemResponse;
|
|
|
import com.dk.mdm.model.response.ivt.OutboundResponse;
|
|
|
import com.dk.mdm.model.response.pur.PurchaseItemResponse;
|
|
|
import com.dk.mdm.model.response.pur.PurchaseResponse;
|
|
|
import com.dk.mdm.model.response.sale.OrderItemResponse;
|
|
|
import com.dk.mdm.model.response.sale.OrderResponse;
|
|
|
-import com.dk.mdm.model.vo.ivt.InboundItemVO;
|
|
|
-import com.dk.mdm.model.vo.ivt.InboundVO;
|
|
|
-import com.dk.mdm.model.vo.ivt.OutboundItemVO;
|
|
|
-import com.dk.mdm.model.vo.ivt.OutboundVO;
|
|
|
+import com.dk.mdm.model.vo.ivt.*;
|
|
|
import com.dk.mdm.model.vo.mac.RecPayVO;
|
|
|
import com.dk.mdm.service.common.CommonService;
|
|
|
import com.dk.mdm.service.ivt.inventory.InventoryService;
|
|
|
@@ -126,6 +122,99 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
|
|
|
@Autowired
|
|
|
private ReceiptService receiptService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InventoryMapper inventoryMapper;
|
|
|
+
|
|
|
+
|
|
|
+ /*****************************************先判断库存*****************************************/
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 校验库存是否存在
|
|
|
+ * @date : 2024/6/11 10:55
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(
|
|
|
+ rollbackFor = {Exception.class}
|
|
|
+ )
|
|
|
+ public InventoryResponse checkInventoryExist(OutboundItemVO outboundItemVO) {
|
|
|
+ //存在标识
|
|
|
+ //根据sku,仓库,非标号查询
|
|
|
+ InventoryResponse inventoryResponse = null;
|
|
|
+ if (outboundItemVO.getSkuId() != null) {
|
|
|
+ inventoryResponse = inventoryMapper.selectByOther(new InventoryQuery()
|
|
|
+ .setSkuId(outboundItemVO.getSkuId())
|
|
|
+ .setWhId(outboundItemVO.getWhId())
|
|
|
+ .setNonStdCode(outboundItemVO.getNonStdCode()));
|
|
|
+ }
|
|
|
+ //库存不存在
|
|
|
+ if(inventoryResponse ==null){
|
|
|
+ //当前出库商品中在库存中不存在
|
|
|
+ throw new BaseBusinessException(ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getCode(),
|
|
|
+ ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
|
|
|
+ }
|
|
|
+ return inventoryResponse;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 先查库存后出库
|
|
|
+ * @date : 2024/6/11 9:30
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public void inventoryOUtBond(OutboundVO outboundVO) {
|
|
|
+ //region 校验明细
|
|
|
+ if (outboundVO.getItemList().size() == 0) {
|
|
|
+ throw new BaseBusinessException(ErrorCodeEnum.OUTBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
+ ErrorCodeEnum.OUTBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ //可以负库存 不用交验库存直接走负库存逻辑
|
|
|
+ if (outboundVO.getFlgHandleSetting()) {
|
|
|
+ for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
|
|
|
+ //可以输入负数出库标识
|
|
|
+ outboundItemVO.setCanNegativeFlag(true);
|
|
|
+ }
|
|
|
+ //销售出库新建
|
|
|
+ this.saleOrderOutboundInsert(outboundVO,true);
|
|
|
+ }
|
|
|
+ //先查库存锁表看能出库的数量有多少 可出库数量建一张已出库的单子并扣减库存,剩下的数量建一张出库中的单子
|
|
|
+ else {
|
|
|
+ //过滤外协品
|
|
|
+ for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
|
|
|
+ //商品id不为空才校验库存 因为为空是外协品
|
|
|
+ if(outboundItemVO.getSkuId()!=null){
|
|
|
+ //查询库存是否存在
|
|
|
+ InventoryResponse inventoryResponse = this.checkInventoryExist(outboundItemVO);
|
|
|
+ BigDecimal invQty = inventoryResponse.getInvQty().subtract(outboundItemVO.getOutingQty());
|
|
|
+ // (库存量 大于等于 本次出库数量不用做任何处理)
|
|
|
+ //库存量 小于 本次出库数量
|
|
|
+ if (invQty.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ outboundItemVO.setOutingQty(inventoryResponse.getInvQty());
|
|
|
+ //不够库存数量----新建出库中数量
|
|
|
+ outboundItemVO.setNotEnoughInventoryQty(invQty.abs());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //region 过滤出不够出库的每条明细数量 ------新建出库中数据
|
|
|
+ List<OutboundItemVO> outboundIngList = outboundVO.getItemList().stream().filter(it -> it.getNotEnoughInventoryQty()!=null && it.getNotEnoughInventoryQty().compareTo(BigDecimal.ZERO)>0).collect(Collectors.toList());
|
|
|
+ if(outboundIngList != null && outboundIngList.size()>0){
|
|
|
+ outboundVO.setFlgAutoHandle(false);
|
|
|
+ outboundVO.setItemList(outboundIngList);
|
|
|
+ //销售出库新建
|
|
|
+ this.saleOrderOutboundInsert(outboundVO,true);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 库存够扣减的明细 -----------新建已出库数据并扣减库存
|
|
|
+ //销售出库新建
|
|
|
+ this.saleOrderOutboundInsert(outboundVO,true);
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*****************************************先判断库存*****************************************/
|
|
|
+
|
|
|
/**
|
|
|
* @desc : 删除外协品生产外协入库单
|
|
|
* @date : 2024/5/10 10:31
|
|
|
@@ -262,25 +351,28 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
|
|
|
/**
|
|
|
* @desc : 销售出库新建
|
|
|
+ * orderTransmitFlag :订单传递过来的
|
|
|
* @date : 2024/3/7 14:13
|
|
|
* @author : 寇珊珊
|
|
|
*/
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
- public ResponseResultVO<?> saleOrderOutboundInsert(OutboundVO outboundVO) {
|
|
|
+ public ResponseResultVO<?> saleOrderOutboundInsert(OutboundVO outboundVO,Boolean orderTransmitFlag) {
|
|
|
//region 如果没有客户id,要新建
|
|
|
- outboundVO = outCommon.insertCustomer(outboundVO);
|
|
|
+// outboundVO = outCommon.insertCustomer(outboundVO);
|
|
|
//endregion
|
|
|
|
|
|
- //region 查询当前公司的系统参数 自动办理信息 并赋值
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("cpId", outboundVO.getCpId());
|
|
|
- map.put("code", Constant.SystemConstant.IVT_001.getValue());
|
|
|
- //自动办理标识
|
|
|
- String flgHandleSetting = commonMapper.getSettingValue(map);
|
|
|
- //自动办理标识为1 自动办理入库
|
|
|
- if (Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)) {
|
|
|
- outboundVO.setFlgHandleSetting(Constant.FlgHandleSetting.TRUE.getValue());
|
|
|
- outboundVO.setFlgAutoHandle(Constant.FlgAutoHandle.TRUE.getValue());
|
|
|
+ //region 查询当前公司的系统参数 自动办理信息 并赋值
|
|
|
+ if(!orderTransmitFlag){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("cpId", outboundVO.getCpId());
|
|
|
+ map.put("code", Constant.SystemConstant.IVT_001.getValue());
|
|
|
+ //自动办理标识
|
|
|
+ String flgHandleSetting = commonMapper.getSettingValue(map);
|
|
|
+ //自动办理标识为1 自动办理入库
|
|
|
+ if (Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)) {
|
|
|
+ outboundVO.setFlgHandleSetting(Constant.FlgHandleSetting.TRUE.getValue());
|
|
|
+ outboundVO.setFlgAutoHandle(Constant.FlgAutoHandle.TRUE.getValue());
|
|
|
+ }
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
@@ -320,12 +412,12 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
//endregion
|
|
|
|
|
|
//region 新建多业务归属
|
|
|
- outCommon.insertMultiOwner(outboundVO);
|
|
|
+// outCommon.insertMultiOwner(outboundVO);
|
|
|
//endregion
|
|
|
|
|
|
//region 销售订单
|
|
|
if (outboundVO.getFromId() != null) {
|
|
|
- //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
|
|
|
+ //赋值 (这里重写了更新方法,数量在更新方法中有数据库原始数量+本次数量)
|
|
|
Order order = new Order();
|
|
|
order.setOrderId(outboundVO.getFromId());
|
|
|
//根据id查询
|
|
|
@@ -473,30 +565,6 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc : 销售出库新建>>>收款
|
|
|
- * @date : 2024/3/7 14:13
|
|
|
- * @author : 寇珊珊
|
|
|
- */
|
|
|
- @Transactional(rollbackFor = {Exception.class})
|
|
|
- public ResponseResultVO<?> saleOrderOutboundInsertCollection(OutboundVO outboundVO) {
|
|
|
- //新建销售出库
|
|
|
- saleOrderOutboundInsert(outboundVO);
|
|
|
- //新建收款退款
|
|
|
- RecPayVO recPayVO = new RecPayVO();
|
|
|
- recPayVO.setObjectId(outboundVO.getObjectId());
|
|
|
- recPayVO.setCusPhone(outboundVO.getCusPhone());
|
|
|
- recPayVO.setOrgId(outboundVO.getOrgId());
|
|
|
- recPayVO.setStaffId(outboundVO.getStaffId());
|
|
|
- recPayVO.setAccDate(outboundVO.getAccDate());
|
|
|
- recPayVO.setMakeStaff(outboundVO.getMakeStaff());
|
|
|
- recPayVO.setRpType(outboundVO.getRpType());
|
|
|
- recPayVO.setSumAmtRec(outboundVO.getSumAmtRec());
|
|
|
- recPayVO.setItemList(outboundVO.getItemListRecPayItemVO());
|
|
|
- receiptService.insertReceipt(recPayVO);
|
|
|
- return ResponseResultUtil.success();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* @desc : 销售出库编辑
|
|
|
* @date : 2024/3/25 16:25
|
|
|
* @author : 寇珊珊
|
|
|
@@ -526,6 +594,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
}
|
|
|
}
|
|
|
//endregion
|
|
|
+
|
|
|
//region 大编辑
|
|
|
else {
|
|
|
// region 更新客户信息
|
|
|
@@ -890,6 +959,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
|
|
|
//endregion
|
|
|
}
|
|
|
//endregion
|
|
|
+
|
|
|
return ResponseResultUtil.success(outboundVO);
|
|
|
}
|
|
|
|