|
@@ -7,10 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.entity.InOutBo;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
-import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.wms.entity.stock.dto.StockJournalDetailsDto;
|
|
|
-import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
|
|
|
import com.fjhx.wms.entity.stock.dto.StockWaitDto;
|
|
|
import com.fjhx.wms.entity.stock.dto.StockWaitSelectDto;
|
|
|
import com.fjhx.wms.entity.stock.emums.JournalType;
|
|
@@ -28,6 +26,7 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
@@ -40,10 +39,8 @@ import java.util.stream.Collectors;
|
|
|
* 待出入库 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
- * @author
|
|
|
* @since 2023-03-22
|
|
|
*/
|
|
|
-//@DS(SourceConstant.WMS)
|
|
|
@Service
|
|
|
public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait> implements StockWaitService {
|
|
|
@Autowired
|
|
@@ -69,103 +66,57 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
|
|
|
wrapper.eq("sw", StockWait::getBusinessType, dto.getBusinessType());
|
|
|
wrapper.eq(StockWait::getBusinessCode, dto.getKeyword());
|
|
|
wrapper.orderByDesc("sw", StockWait::getId);
|
|
|
- Page<StockWaitVo> page = this.baseMapper.getPage1(dto.getPage(), wrapper);
|
|
|
-
|
|
|
+ Page<StockWaitVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<StockWaitVo> records = page.getRecords();
|
|
|
- // 赋值产品属性
|
|
|
- productInfoService.attributeAssign(records, StockWaitVo::getProductId, (item, productInfo) -> {
|
|
|
- item.setProductCode(productInfo.getCode());
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值明细列表
|
|
|
+ setDetailsInfo(records);
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setDetailsInfo(List<StockWaitVo> records) {
|
|
|
+ //获取明细列表
|
|
|
+ List<Long> swIds = records.stream().map(StockWait::getId).collect(Collectors.toList());
|
|
|
+ List<StockWaitDetails> list = stockWaitDetailsService.list(q -> q.in(StockWaitDetails::getStockWaitId, swIds));
|
|
|
+ List<StockWaitDetailsVo> voList = BeanUtil.copyToList(list, StockWaitDetailsVo.class);
|
|
|
+ productInfoService.attributeAssign(voList, StockWaitDetails::getProductId, (item, productInfo) -> {
|
|
|
+ item.setProductCode(productInfo.getCustomCode());
|
|
|
+ item.setProductCustomCode(productInfo.getCustomCode());
|
|
|
+ item.setProductName(productInfo.getName());
|
|
|
+ item.setProductLength(productInfo.getLength());
|
|
|
+ item.setProductWidth(productInfo.getWidth());
|
|
|
+ item.setProductHeight(productInfo.getHeight());
|
|
|
+ item.setProductColor(productInfo.getColor());
|
|
|
+
|
|
|
item.setProductUnit(productInfo.getUnit());
|
|
|
item.setProductType(productInfo.getType());
|
|
|
- item.setProductName(productInfo.getName());
|
|
|
item.setProductSpec(productInfo.getSpec());
|
|
|
+ item.setProductDefinition(productInfo.getDefinition());
|
|
|
});
|
|
|
+ Map<Long, List<StockWaitDetailsVo>> voMap = voList.stream().collect(Collectors.groupingBy(StockWaitDetails::getStockWaitId));
|
|
|
|
|
|
- return page;
|
|
|
+ //赋值明细列表
|
|
|
+ records.forEach(item -> item.setStockWaitDetailsList(voMap.get(item.getId())));
|
|
|
}
|
|
|
|
|
|
-// @Override
|
|
|
-// public Page<StockWaitVo> getPageByWdly(StockWaitSelectDto dto) {
|
|
|
-// IWrapper<StockWait> wrapper = getWrapper();
|
|
|
-// wrapper.orderByDesc("sw", StockWait::getId);
|
|
|
-// //过滤入库/出库
|
|
|
-// wrapper.eq(StockWait::getType, dto.getType());
|
|
|
-// wrapper.eq(StockWait::getBusinessCode, dto.getKeyword());
|
|
|
-// wrapper.eq(StockWait::getStatus, dto.getStatus());
|
|
|
-// wrapper.eq("sw", StockWait::getBusinessType, dto.getBusinessType());
|
|
|
-//
|
|
|
-// //过滤掉待入库待出库已完成数据
|
|
|
-// wrapper.ne("sw", StockWait::getStatus, 2);
|
|
|
-//
|
|
|
-// Page<StockWaitVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
-//
|
|
|
-// List<StockWaitVo> records = page.getRecords();
|
|
|
-// //赋值操作人
|
|
|
-// UserUtil.assignmentNickName(records, StockWaitVo::getCreateUser, StockWaitVo::setOperatorName);
|
|
|
-// //赋值仓库名称和id
|
|
|
-// List<Long> warehouseIds = new ArrayList<>();
|
|
|
-// for (StockWaitVo stockWaitVo : records) {
|
|
|
-// String victoriatouristJson = stockWaitVo.getVictoriatouristJson();
|
|
|
-// if (ObjectUtil.isEmpty(victoriatouristJson)) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
-// if (!json.containsKey("receiptWarehouseId")) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// warehouseIds.add(json.getLong("receiptWarehouseId"));
|
|
|
-// }
|
|
|
-// if (ObjectUtil.isEmpty(warehouseIds)) {
|
|
|
-// return page;
|
|
|
-// }
|
|
|
-// List<Warehouse> warehouses = warehouseService.listByIds(warehouseIds);
|
|
|
-// Map<Long, String> warehousesMap = warehouses.stream().collect(Collectors.toMap(Warehouse::getId, Warehouse::getName));
|
|
|
-// for (StockWaitVo stockWaitVo : records) {
|
|
|
-// String victoriatouristJson = stockWaitVo.getVictoriatouristJson();
|
|
|
-// if (ObjectUtil.isEmpty(victoriatouristJson)) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
-// json.put("receiptWarehouseName", warehousesMap.get(json.getLong("receiptWarehouseId")));
|
|
|
-// stockWaitVo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
|
-// }
|
|
|
-//
|
|
|
-// return page;
|
|
|
-// }
|
|
|
-
|
|
|
@Override
|
|
|
public StockWaitVo detail(Long id) {
|
|
|
StockWait stockWait = this.getById(id);
|
|
|
StockWaitVo result = BeanUtil.toBean(stockWait, StockWaitVo.class);
|
|
|
|
|
|
- StockWaitDetails stockWaitDetails = stockWaitDetailsService.getOne(q -> q.eq(StockWaitDetails::getStockWaitId, id));
|
|
|
- ProductInfo byId = productInfoService.getById(stockWaitDetails.getProductId());
|
|
|
- result.setProductName(byId.getName());
|
|
|
- result.setQuantity(stockWaitDetails.getQuantity());
|
|
|
- result.setStockWaitDetailsId(stockWaitDetails.getId());
|
|
|
-
|
|
|
- //获取明细列表
|
|
|
- List<StockWaitDetails> stockWaitDetailsList = stockWaitDetailsService.list(q -> q.eq(StockWaitDetails::getStockWaitId, id));
|
|
|
- List<StockWaitDetailsVo> stockWaitDetailsVos = BeanUtil.copyToList(stockWaitDetailsList, StockWaitDetailsVo.class);
|
|
|
- //赋值产品信息
|
|
|
- productInfoService.attributeAssign(stockWaitDetailsVos, StockWaitDetailsVo::getProductId, (item, productInfo) -> {
|
|
|
- item.setProductName(productInfo.getName());
|
|
|
- });
|
|
|
- result.setStockWaitDetailsList(stockWaitDetailsVos);
|
|
|
+ //赋值产品明细列表
|
|
|
+ setDetailsInfo(Collections.singletonList(result));
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
- public void add(StockWaitDetailsDto stockWaitDetailsDto) {
|
|
|
- //优化
|
|
|
- StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDetailsDto.getId());
|
|
|
- Assert.notEmpty(stockWaitDetails, "查询不到待出库明细信息");
|
|
|
- StockWaitDto stockWaitDto = BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDto.class);
|
|
|
- stockWaitDto.setId(stockWaitDetails.getStockWaitId());
|
|
|
- stockWaitDto.setStockWaitDetailsList(Collections.singletonList(BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDetails.class)));
|
|
|
-
|
|
|
+ public void add(StockWaitDto stockWaitDto) {
|
|
|
Long warehouseId = stockWaitDto.getWarehouseId();
|
|
|
Warehouse warehouse = warehouseService.getById(warehouseId);
|
|
|
if (ObjectUtil.isEmpty(warehouse)) {
|
|
@@ -180,6 +131,11 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
|
|
|
|
|
|
List<StockWaitDetails> stockWaitDetailsDtoList = stockWaitDto.getStockWaitDetailsList();
|
|
|
|
|
|
+ //过滤数量为空,为零的数据
|
|
|
+ stockWaitDetailsDtoList = stockWaitDetailsDtoList.stream()
|
|
|
+ .filter(item -> ObjectUtil.isNotEmpty(item.getQuantity()) && item.getQuantity().compareTo(BigDecimal.ZERO) > 0)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
//更新已出入库数量以及待出入库状态
|
|
|
stockWaitDetailsService.changeStockWaitStatus(stockWaitDto);
|
|
|
StockWait stockWait = getById(stockWaitDto.getId());
|
|
@@ -217,7 +173,6 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
|
|
|
stockJournalDetails.setBusinessDetailsId(waitDetails.getId());
|
|
|
stockJournalDetails.setCompanyId(companyId);
|
|
|
stockJournalDetailsList.add(stockJournalDetails);
|
|
|
-
|
|
|
}
|
|
|
List<InOutBo> inOutBoList = BeanUtil.copyToList(stockList, InOutBo.class);
|
|
|
|
|
@@ -225,13 +180,6 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
|
|
|
stockService.changeStock(inOutBoList, warehouseId, journalType);
|
|
|
//保存出入库明细
|
|
|
stockJournalDetailsService.saveBatch(stockJournalDetailsList);
|
|
|
-
|
|
|
- //如果是采购退货 修改采购退货状态
|
|
|
- Assert.notEmpty(stockWait, "查询不到待出库信息");
|
|
|
- if (stockWait.getBusinessType() == 4) {
|
|
|
- Integer status = stockWait.getStatus();
|
|
|
- myPurchaseService.updateSalesReturnStatus(stockWaitDetails.getBusinessDetailsId(), status);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Override
|