|
@@ -1,28 +1,27 @@
|
|
|
package com.fjhx.wms.service.stock.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
+import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
|
|
|
+import com.fjhx.wms.entity.stock.dto.StockWaitDetailsSelectDto;
|
|
|
import com.fjhx.wms.entity.stock.emums.JournalType;
|
|
|
import com.fjhx.wms.entity.stock.emums.StockWaitType;
|
|
|
import com.fjhx.wms.entity.stock.po.*;
|
|
|
+import com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo;
|
|
|
import com.fjhx.wms.mapper.stock.StockWaitDetailsMapper;
|
|
|
import com.fjhx.wms.service.WmsService;
|
|
|
import com.fjhx.wms.service.stock.*;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.wms.utils.CodeEnum;
|
|
|
import com.obs.services.internal.ServiceException;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo;
|
|
|
-import com.fjhx.wms.entity.stock.dto.StockWaitDetailsSelectDto;
|
|
|
-import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
-import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
-import javax.xml.ws.soap.Addressing;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
@@ -33,7 +32,7 @@ import java.util.List;
|
|
|
* 待出入库明细 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
- * @author
|
|
|
+ * @author
|
|
|
* @since 2023-04-13
|
|
|
*/
|
|
|
@Service
|
|
@@ -57,16 +56,16 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
|
|
|
public Page<StockWaitDetailsVo> getPage(StockWaitDetailsSelectDto dto) {
|
|
|
IWrapper<StockWaitDetails> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("swd", StockWaitDetails::getId);
|
|
|
- wrapper.eq("sw", StockWait::getType,dto.getType());
|
|
|
- if(ObjectUtil.isNotEmpty(dto.getKeyword())){
|
|
|
- wrapper.and(q->q.like(StockWaitDetails::getQuantity,dto.getKeyword()).or().like(StockWaitDetailsVo::getBusinessCode,dto.getKeyword()));
|
|
|
+ wrapper.eq("sw", StockWait::getType, dto.getType());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
|
+ wrapper.and(q -> q.like(StockWaitDetails::getQuantity, dto.getKeyword()).or().like(StockWaitDetailsVo::getBusinessCode, dto.getKeyword()));
|
|
|
}
|
|
|
- wrapper.eq("sw", StockWait::getBusinessType,dto.getBusinessType());
|
|
|
- wrapper.eq("sw", StockWait::getStatus,dto.getStatus());
|
|
|
+ wrapper.eq("sw", StockWait::getBusinessType, dto.getBusinessType());
|
|
|
+ wrapper.eq("sw", StockWait::getStatus, dto.getStatus());
|
|
|
Page<StockWaitDetailsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<StockWaitDetailsVo> records = page.getRecords();
|
|
|
for (StockWaitDetailsVo record : records) {
|
|
|
- if(ObjectUtil.isEmpty(record.getReceiptQuantity())){
|
|
|
+ if (ObjectUtil.isEmpty(record.getReceiptQuantity())) {
|
|
|
record.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
@@ -88,14 +87,15 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
|
|
|
StockWaitDetailsVo result = BeanUtil.toBean(StockWaitDetails, StockWaitDetailsVo.class);
|
|
|
//查询待入库信息
|
|
|
StockWait stockWait = stockWaitService.getById(result.getStockWaitId());
|
|
|
- if(ObjectUtil.isEmpty(stockWait)){
|
|
|
- throw new ServiceException("无法查询到待入库信息,待入库id"+result.getStockWaitId());
|
|
|
+ if (ObjectUtil.isEmpty(stockWait)) {
|
|
|
+ throw new ServiceException("无法查询到待入库信息,待入库id" + result.getStockWaitId());
|
|
|
}
|
|
|
result.setBusinessType(stockWait.getBusinessType());
|
|
|
- result.setBusinessCode(stockWait.getBusinessCode());;
|
|
|
+ result.setBusinessCode(stockWait.getBusinessCode());
|
|
|
+ ;
|
|
|
ProductInfo byId = productInfoService.getById(StockWaitDetails.getProductId());
|
|
|
- if(ObjectUtil.isEmpty(byId)){
|
|
|
- throw new ServiceException("无法查询到产品信息,产品id"+StockWaitDetails.getProductId());
|
|
|
+ if (ObjectUtil.isEmpty(byId)) {
|
|
|
+ throw new ServiceException("无法查询到产品信息,产品id" + StockWaitDetails.getProductId());
|
|
|
}
|
|
|
result.setProductName(byId.getName());
|
|
|
return result;
|
|
@@ -104,34 +104,11 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
|
|
|
@Override
|
|
|
@DSTransactional
|
|
|
public void add(StockWaitDetailsDto stockWaitDetailsDto) {
|
|
|
- //更新已入库数量 根据明细id
|
|
|
+ //修改待出库状态
|
|
|
+ changeStockWaitStatus(stockWaitDetailsDto);
|
|
|
StockWaitDetails stockWaitDetails = getById(stockWaitDetailsDto.getId());
|
|
|
- if(ObjectUtil.isEmpty(stockWaitDetails)){
|
|
|
- throw new ServiceException("无法查询到明细信息");
|
|
|
- }
|
|
|
- BigDecimal receiptQuantity = stockWaitDetails.getReceiptQuantity();
|
|
|
- receiptQuantity = ObjectUtil.isEmpty(receiptQuantity) ? BigDecimal.ZERO : receiptQuantity;
|
|
|
- stockWaitDetails.setReceiptQuantity(receiptQuantity.add(stockWaitDetailsDto.getQuantity()));
|
|
|
- if (stockWaitDetails.getReceiptQuantity().compareTo(stockWaitDetails.getQuantity()) > 0) {
|
|
|
- throw new ServiceException("出库数量+已出库数量不能大于待出库数量");
|
|
|
- }
|
|
|
- updateById(stockWaitDetails);
|
|
|
- //更新待出库记录状态
|
|
|
- Integer statusFlag = 0;
|
|
|
- List<StockWaitDetails> stockWaitDetailsList = list(q -> q.eq(StockWaitDetails::getStockWaitId, stockWaitDetails.getStockWaitId()));
|
|
|
- for (StockWaitDetails waitDetails : stockWaitDetailsList) {
|
|
|
- //计算已经完全出库的数量
|
|
|
- if (waitDetails.getReceiptQuantity().compareTo(waitDetails.getQuantity()) == 0) {
|
|
|
- statusFlag++;
|
|
|
- }
|
|
|
- }
|
|
|
StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
|
|
|
- if (statusFlag == stockWaitDetailsList.size()) {
|
|
|
- byId.setStatus(2);//入库完成
|
|
|
- } else {
|
|
|
- byId.setStatus(1);//部分入库
|
|
|
- }
|
|
|
- stockWaitService.updateById(byId);
|
|
|
+
|
|
|
//创建出入库记录
|
|
|
StockJournal stockJournal = new StockJournal();
|
|
|
stockJournal.setOpType(byId.getType());
|
|
@@ -149,11 +126,11 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
|
|
|
} else if (StockWaitType.BACK_OUT.getDetailType().equals(businessType)) {
|
|
|
//退货出货
|
|
|
stockJournal.setType(JournalType.BACK_OUT.getDetailType());
|
|
|
- }else if (StockWaitType.SALE_ORDER_OUT.getDetailType().equals(businessType)) {
|
|
|
+ } else if (StockWaitType.SALE_ORDER_OUT.getDetailType().equals(businessType)) {
|
|
|
//销售订单出库
|
|
|
stockJournal.setType(JournalType.SALES_OUT.getDetailType());
|
|
|
wmsService.outbound(stockWaitDetailsDto);
|
|
|
- }else if (StockWaitType.PRODUCTION_TASK_OUT.getDetailType().equals(businessType)) {
|
|
|
+ } else if (StockWaitType.PRODUCTION_TASK_OUT.getDetailType().equals(businessType)) {
|
|
|
//生产任务待出库
|
|
|
stockJournal.setType(JournalType.PRODUCTION_TASK_OUT.getDetailType());
|
|
|
//减少冻结库存
|
|
@@ -178,6 +155,41 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
|
|
|
stockJournalDetailsService.saveBatch(stockJournalDetailsList);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新待出入库状态
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void changeStockWaitStatus(StockWaitDetailsDto stockWaitDetailsDto) {
|
|
|
+ //更新已入库数量 根据明细id
|
|
|
+ StockWaitDetails stockWaitDetails = getById(stockWaitDetailsDto.getId());
|
|
|
+ if (ObjectUtil.isEmpty(stockWaitDetails)) {
|
|
|
+ throw new ServiceException("无法查询到明细信息");
|
|
|
+ }
|
|
|
+ BigDecimal receiptQuantity = stockWaitDetails.getReceiptQuantity();
|
|
|
+ receiptQuantity = ObjectUtil.isEmpty(receiptQuantity) ? BigDecimal.ZERO : receiptQuantity;
|
|
|
+ stockWaitDetails.setReceiptQuantity(receiptQuantity.add(stockWaitDetailsDto.getQuantity()));
|
|
|
+ if (stockWaitDetails.getReceiptQuantity().compareTo(stockWaitDetails.getQuantity()) > 0) {
|
|
|
+ throw new ServiceException("出库数量+已出库数量不能大于待出库数量");
|
|
|
+ }
|
|
|
+ updateById(stockWaitDetails);
|
|
|
+ //更新待出库记录状态
|
|
|
+ Integer statusFlag = 0;
|
|
|
+ List<StockWaitDetails> stockWaitDetailsList = list(q -> q.eq(StockWaitDetails::getStockWaitId, stockWaitDetails.getStockWaitId()));
|
|
|
+ for (StockWaitDetails waitDetails : stockWaitDetailsList) {
|
|
|
+ //计算已经完全出库的数量
|
|
|
+ if (waitDetails.getReceiptQuantity().compareTo(waitDetails.getQuantity()) == 0) {
|
|
|
+ statusFlag++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
|
|
|
+ if (statusFlag == stockWaitDetailsList.size()) {
|
|
|
+ byId.setStatus(2);//入库完成
|
|
|
+ } else {
|
|
|
+ byId.setStatus(1);//部分入库
|
|
|
+ }
|
|
|
+ stockWaitService.updateById(byId);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void edit(StockWaitDetailsDto stockWaitDetailsDto) {
|
|
|
this.updateById(stockWaitDetailsDto);
|