|
|
@@ -14,6 +14,7 @@ import com.dk.common.service.BaseService;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
|
|
|
import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
|
|
|
import com.dk.mdm.mapper.common.CommonMapper;
|
|
|
+import com.dk.mdm.mapper.ivt.InOutRecordMapper;
|
|
|
import com.dk.mdm.mapper.ivt.InboundItemMapper;
|
|
|
import com.dk.mdm.mapper.ivt.InboundMapper;
|
|
|
import com.dk.mdm.model.pojo.ivt.Inbound;
|
|
|
@@ -44,6 +45,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -81,6 +83,7 @@ public class InboundOtherService extends BaseService<Inbound> {
|
|
|
private InventoryService inventoryService;
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* @desc : 条件查询
|
|
|
* @date : 2024/3/7 14:12
|
|
|
@@ -110,12 +113,54 @@ public class InboundOtherService extends BaseService<Inbound> {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @desc : 查询入库价
|
|
|
+ * @date : 2024/7/1 11:29
|
|
|
+ * @author : 寇珊珊
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public InboundItemResponse selectPriceInto(InboundItemVO inboundItemVO) {
|
|
|
+ List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectPriceInto(new InboundItemQuery().setSkuId(inboundItemVO.getSkuId())
|
|
|
+ .setNonStdCode(inboundItemVO.getNonStdCode())
|
|
|
+ .setWhId(inboundItemVO.getWhId()));
|
|
|
+ if (inboundItemResponses != null && inboundItemResponses.size() > 0) {
|
|
|
+ return inboundItemResponses.get(0);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @desc : 其他入库新建
|
|
|
* @date : 2024/3/7 14:13
|
|
|
* @author : 寇珊珊
|
|
|
*/
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public ResponseResultVO<?> otherInboundInsert(InboundVO inboundVO) {
|
|
|
+ //校验明细
|
|
|
+ if (inboundVO.getItemList().size() == 0) {
|
|
|
+ throw new BaseBusinessException(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
+ ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 查询当前入库明细中是否存在未空或者0的入库价,如果存在去库存流水差最近一条有价格的数据赋值到当前明细
|
|
|
+ Boolean priceIntoFlag = false;
|
|
|
+ for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
+ if(inboundItemVO.getPriceInto()==null || inboundItemVO.getPriceInto().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ priceIntoFlag = true;
|
|
|
+ //查询库存批次最近一条入库价
|
|
|
+ InboundItemResponse inboundItemResponse = this.selectPriceInto(inboundItemVO);
|
|
|
+ inboundItemVO.setPriceInto(inboundItemResponse != null ? inboundItemResponse.getPriceInto() : BigDecimal.ZERO);
|
|
|
+ inboundItemVO.setIntoingAmt(inboundItemResponse != null ? inboundItemResponse.getPriceInto().multiply(inboundItemVO.getIntoingQty()).setScale(2, BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
|
|
|
+ inboundItemVO.setCostPrice(inboundItemResponse != null ? inboundItemResponse.getCostPrice() : BigDecimal.ZERO);
|
|
|
+ inboundItemVO.setCostAmt(inboundItemResponse != null ? inboundItemResponse.getCostPrice().multiply(inboundItemVO.getIntoingQty()).setScale(2, BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(priceIntoFlag){
|
|
|
+ BigDecimal intoingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
|
|
|
+ inboundVO.setIntoingAmt(intoingAmt);
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+
|
|
|
//region 查询当前公司的系统参数 自动办理信息 并赋值
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("cpId", inboundVO.getCpId());
|
|
|
@@ -162,11 +207,6 @@ public class InboundOtherService extends BaseService<Inbound> {
|
|
|
//endregion
|
|
|
|
|
|
//region 明细
|
|
|
- //校验明细
|
|
|
- if (inboundVO.getItemList().size() == 0) {
|
|
|
- throw new BaseBusinessException(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
|
|
|
- ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
|
|
|
- }
|
|
|
for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
|
|
|
//region 将库存需要的参数赋值
|
|
|
inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
@@ -212,7 +252,6 @@ public class InboundOtherService extends BaseService<Inbound> {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
-
|
|
|
return ResponseResultUtil.success(inboundVO);
|
|
|
}
|
|
|
|
|
|
@@ -305,6 +344,7 @@ public class InboundOtherService extends BaseService<Inbound> {
|
|
|
InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
|
|
|
inboundItemMapper.insert(inboundItem);
|
|
|
inboundItemVO.setItemId(inboundItem.getItemId());
|
|
|
+
|
|
|
//region 将库存需要的参数赋值
|
|
|
inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
|
|
|
inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.OTHER_INBOUND.getValue());
|