|
|
@@ -10,10 +10,14 @@ import com.dk.common.model.pojo.PageList;
|
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
+import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
|
|
|
+import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.pur.PurChaseConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.pur.PurChaseItemConvert;
|
|
|
import com.dk.mdm.mapper.common.CommonMapper;
|
|
|
+import com.dk.mdm.mapper.mst.GoodsSkuMapper;
|
|
|
import com.dk.mdm.mapper.pur.PurchaseItemMapper;
|
|
|
+import com.dk.mdm.model.pojo.mst.GoodsSku;
|
|
|
import com.dk.mdm.model.pojo.pur.Purchase;
|
|
|
import com.dk.mdm.mapper.pur.PurchaseMapper;
|
|
|
import com.dk.common.service.BaseService;
|
|
|
@@ -30,12 +34,14 @@ import com.dk.mdm.model.vo.pur.PurchaseItemVO;
|
|
|
import com.dk.mdm.model.vo.pur.PurchaseVO;
|
|
|
import com.dk.mdm.service.common.CommonService;
|
|
|
import com.dk.mdm.service.ivt.inbound.InboundItemService;
|
|
|
+import com.dk.mdm.service.ivt.inbound.InboundPurchaseService;
|
|
|
import com.dk.mdm.service.ivt.inbound.InboundService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -80,6 +86,18 @@ public class PurchaseService extends BaseService<Purchase> {
|
|
|
@Autowired
|
|
|
private InboundItemService inboundItemService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InboundItemConvert inboundItemConvert;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InboundConvert inboundConvert;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GoodsSkuMapper goodsSkuMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InboundPurchaseService inboundPurchaseService;
|
|
|
+
|
|
|
/**
|
|
|
* @desc : 条件查询
|
|
|
* @author : 常皓宁
|
|
|
@@ -165,6 +183,71 @@ public class PurchaseService extends BaseService<Purchase> {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
+ /****************************************判断是否生成采购入库单****************************************/
|
|
|
+ //region 判断是否生成采购入库单
|
|
|
+ if(purchasevo.getInboundProcessingFlag()!=null && purchasevo.getInboundProcessingFlag()){
|
|
|
+ List<InboundItemVO> inboundItemVOList = new ArrayList<>();
|
|
|
+ //region 明细
|
|
|
+ for (PurchaseItemVO purchaseItemVO : purchasevo.getPurchaseItemVOList()) {
|
|
|
+ //region 采购订单明细转换采购入库明细
|
|
|
+ InboundItemVO inboundItemVO = inboundItemConvert.convertPurchaseItemVOToInboundItemVO(purchaseItemVO);
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 赋值 采购订单明细和入库单明细不一致的字段要单独set
|
|
|
+ //来源id
|
|
|
+ inboundItemVO.setFromId(purchasevo.getPurId());
|
|
|
+ //来源明细id
|
|
|
+ inboundItemVO.setFromItemId(purchaseItemVO.getItemId());
|
|
|
+ //入库价
|
|
|
+ inboundItemVO.setPriceInto(purchaseItemVO.getPricePur());
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 根据sku查询商品信息
|
|
|
+ if (inboundItemVO.getSkuId() != null) {
|
|
|
+ GoodsSku goodsSku = goodsSkuMapper.selectById(inboundItemVO.getSkuId());
|
|
|
+ //商品名称
|
|
|
+ inboundItemVO.setSkuName(goodsSku.getSkuName());
|
|
|
+ //商品型号
|
|
|
+ inboundItemVO.setSkuModel(goodsSku.getSkuModel());
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 箱片计算
|
|
|
+ //入库中 或者待入库
|
|
|
+ if (Constant.IntoStatus.RUKUZHONG.getName().equals(inboundItemVO.getIntoStatus()) ||
|
|
|
+ Constant.IntoStatus.DAIRUKU.getName().equals(inboundItemVO.getIntoStatus())) {
|
|
|
+ //箱
|
|
|
+ inboundItemVO.setIntoingBox(Integer.valueOf(inboundItemVO.getIntoingQty().divide(inboundItemVO.getPackBox(), 0, RoundingMode.DOWN).toString()));
|
|
|
+ //片
|
|
|
+ inboundItemVO.setIntoingPiece(inboundItemVO.getIntoingQty().remainder(inboundItemVO.getPackBox()));
|
|
|
+ }
|
|
|
+ //已入库
|
|
|
+ else {
|
|
|
+ //箱
|
|
|
+ inboundItemVO.setIntoBox(Integer.valueOf(inboundItemVO.getIntoingQty().divide(inboundItemVO.getPackBox(), 0, RoundingMode.DOWN).toString()));
|
|
|
+ //片
|
|
|
+ inboundItemVO.setIntoPiece(inboundItemVO.getIntoingQty().remainder(inboundItemVO.getPackBox()));
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 入库明细list添加
|
|
|
+ inboundItemVOList.add(inboundItemVO);
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 总单
|
|
|
+ InboundVO inboundVO = inboundConvert.convertPurchaseVOToInboundVO(purchasevo);
|
|
|
+ inboundVO.setItemList(inboundItemVOList);
|
|
|
+ //endregion
|
|
|
+ //新建采购入库单
|
|
|
+ inboundPurchaseService.purchaseInboundInsert(inboundVO);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ /****************************************判断是否生成采购入库单****************************************/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return ResponseResultUtil.success();
|
|
|
}
|
|
|
|