|
@@ -8,15 +8,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.Condition;
|
|
|
import com.fjhx.constants.StatusConstant;
|
|
|
import com.fjhx.entity.abnormal.AbnormalInfo;
|
|
|
+import com.fjhx.entity.order.OrderInfo;
|
|
|
import com.fjhx.entity.product.ProductInfo;
|
|
|
import com.fjhx.entity.stock.StockTransfer;
|
|
|
import com.fjhx.entity.warehouse.Warehouse;
|
|
|
import com.fjhx.enums.stock.InTypeEnum;
|
|
|
import com.fjhx.mapper.stock.StockTransferMapper;
|
|
|
-import com.fjhx.params.stock.ChangeProduct;
|
|
|
-import com.fjhx.params.stock.StockChangeDto;
|
|
|
-import com.fjhx.params.stock.StockTransferAddDto;
|
|
|
-import com.fjhx.params.stock.StockTransferEx;
|
|
|
+import com.fjhx.params.order.OrderInfoVo;
|
|
|
+import com.fjhx.params.stock.*;
|
|
|
import com.fjhx.service.abnormal.AbnormalInfoService;
|
|
|
import com.fjhx.service.product.ProductInfoService;
|
|
|
import com.fjhx.service.stock.StockService;
|
|
@@ -27,6 +26,7 @@ import com.fjhx.utils.UserClientUtil;
|
|
|
import com.fjhx.utils.wrapperUtil.IWrapper;
|
|
|
import com.fjhx.utils.wrapperUtil.KeywordData;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -34,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -96,6 +97,40 @@ public class StockTransferServiceImpl extends ServiceImpl<StockTransferMapper, S
|
|
|
|
|
|
return page;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<StockTransferVo> getPage1(Condition condition) {
|
|
|
+ IWrapper<Object> wrapper = IWrapper.getWrapper(condition);
|
|
|
+ wrapper.eq("st", StockTransfer::getInWarehouseId);
|
|
|
+ wrapper.eq("st", StockTransfer::getOutWarehouseId);
|
|
|
+ wrapper.eq("st", StockTransfer::getInStatus);
|
|
|
+ wrapper.keyword(new KeywordData("pi", ProductInfo::getName), new KeywordData("pi", ProductInfo::getCode));
|
|
|
+ wrapper.orderByDesc("st", StockTransfer::getId);
|
|
|
+ wrapper.isNotNull("st.jd_order_info_id");
|
|
|
+
|
|
|
+
|
|
|
+ Page<StockTransferVo> page = baseMapper.getPage1(condition.getPage(), wrapper);
|
|
|
+ List<StockTransferVo> records = page.getRecords();
|
|
|
+ if (records.size() == 0) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@@ -171,18 +206,68 @@ public class StockTransferServiceImpl extends ServiceImpl<StockTransferMapper, S
|
|
|
stockService.changeQuantity(stockChangeDto);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void receive1(List<StockTransfer> dto) {
|
|
|
+
|
|
|
+ List<ChangeProduct> changeProductList = new ArrayList<>();
|
|
|
+ List<AbnormalInfo> abnormalInfoList = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<Long, StockTransfer> stockTransferMap = dto.stream().collect(Collectors.toMap(StockTransfer::getId, Function.identity()));
|
|
|
+ List<Long> ids = dto.stream().map(StockTransfer::getId).collect(Collectors.toList());
|
|
|
+ List<StockTransfer> stockTransfers = listByIds(ids);
|
|
|
+ for(StockTransfer stockTransfer :stockTransfers){
|
|
|
+ Assert.eqTrue(StatusConstant.NO.equals(stockTransfer.getInStatus()), "物品已接收");
|
|
|
+
|
|
|
+ stockTransfer.setInUser(AuthUtil.getUserId());
|
|
|
+ stockTransfer.setInQuantity(stockTransferMap.get(stockTransfer.getId()).getInQuantity());
|
|
|
+ stockTransfer.setInTime(new Date());
|
|
|
+ stockTransfer.setInStatus(StatusConstant.YES);
|
|
|
+
|
|
|
+ ChangeProduct changeProduct = new ChangeProduct();
|
|
|
+ changeProduct.setBusinessId(stockTransfer.getId());
|
|
|
+ changeProduct.setProductId(stockTransfer.getProductId());
|
|
|
+ changeProduct.setQuantity(stockTransfer.getInQuantity());
|
|
|
+ changeProductList.add(changeProduct);
|
|
|
+
|
|
|
+
|
|
|
+ if (stockTransfer.getInQuantity() != stockTransfer.getOutQuantity()) {
|
|
|
+ AbnormalInfo abnormalInfo = new AbnormalInfo();
|
|
|
+ abnormalInfo.setId(IdWorker.getId());
|
|
|
+ abnormalInfo.setType(30);
|
|
|
+ abnormalInfo.setLinkId(stockTransfer.getId());
|
|
|
+ abnormalInfo.setTitle("调仓接收数量与发出数量不一致");
|
|
|
+ abnormalInfoList.add(abnormalInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ updateBatchById(stockTransfers);
|
|
|
+ abnormalInfoService.saveBatch(abnormalInfoList);
|
|
|
+
|
|
|
+ StockChangeDto stockChangeDto = new StockChangeDto();
|
|
|
+ stockChangeDto.setDefaultWarehouseId(100l);
|
|
|
+
|
|
|
+ stockChangeDto.setTypeEnum(InTypeEnum.TRANSFER);
|
|
|
+ stockChangeDto.setChangeDetailsList(changeProductList);
|
|
|
+
|
|
|
+ stockService.changeQuantity(stockChangeDto);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public StockTransferEx detailed(StockTransfer stockTransfer){
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
queryWrapper.eq("st.id",stockTransfer.getId());
|
|
|
queryWrapper.or();
|
|
|
queryWrapper.eq("st.jd_order_info_id",stockTransfer.getId());
|
|
|
- StockTransferEx detailed = baseMapper.detailed(queryWrapper);
|
|
|
+ List<StockTransferEx> detailedList = baseMapper.detailed(queryWrapper);
|
|
|
+ StockTransferEx detailed = detailedList.get(0);
|
|
|
Warehouse inWarehouse = warehouseService.getById(detailed.getInWarehouseId());
|
|
|
if(ObjectUtil.isNotEmpty(inWarehouse)) {
|
|
|
detailed.setInWarehouseName(inWarehouse.getName());
|
|
|
}
|
|
|
- List<ProductInfo> productInfoList = productInfoService.list(q -> q.eq(ProductInfo::getId, detailed.getProductId()));
|
|
|
+ List<Long> ids = detailedList.stream().map(StockTransferEx::getProductId).collect(Collectors.toList());
|
|
|
+ List<ProductInfo> productInfoList = productInfoService.list(q -> q.in(ProductInfo::getId, ids));
|
|
|
detailed.setProductInfoList(productInfoList);
|
|
|
return detailed;
|
|
|
}
|