|
@@ -6,7 +6,6 @@ import java.util.List;
|
|
|
|
|
|
import com.ruoyi.ams.asn.form.PaForm;
|
|
|
import com.ruoyi.ams.asn.form.StockForm;
|
|
|
-import com.ruoyi.ams.asn.form.StockInfoForm;
|
|
|
import com.ruoyi.ams.asn.form.UnlockForm;
|
|
|
import com.ruoyi.ams.asn.mapper.WmsDocAsnDetailsMapper;
|
|
|
import com.ruoyi.ams.box.domain.WmsBoxInfo;
|
|
@@ -16,12 +15,16 @@ import com.ruoyi.ams.inv.domain.ActTransactionLog;
|
|
|
import com.ruoyi.ams.inv.domain.InvLotAtt;
|
|
|
import com.ruoyi.ams.inv.domain.InvLotLocId;
|
|
|
import com.ruoyi.ams.inv.domain.form.InvLotLocIdMoveForm;
|
|
|
+import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
|
|
|
import com.ruoyi.ams.inv.service.IActTransactionLogService;
|
|
|
import com.ruoyi.ams.inv.service.IInvLotAttService;
|
|
|
import com.ruoyi.ams.inv.service.IInvLotLocIdService;
|
|
|
+import com.ruoyi.ams.order.domain.ActAllocationDetails;
|
|
|
import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
|
|
|
import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
|
|
|
+import com.ruoyi.ams.order.dto.WmsDocOrderDTO;
|
|
|
import com.ruoyi.ams.order.mapper.WmsDocOrderDetailsMapper;
|
|
|
+import com.ruoyi.ams.order.service.IActAllocationDetailsService;
|
|
|
import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
|
|
|
import com.ruoyi.base.constant.Constant;
|
|
|
import com.ruoyi.base.domain.BaseSku;
|
|
@@ -30,6 +33,7 @@ import com.ruoyi.base.utils.IdSequenceUtils;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.uuid.SnowflakeIdWorker;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -71,6 +75,10 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
private IdSequenceUtils idSequenceUtils;
|
|
|
@Autowired
|
|
|
private IInvLotAttService invLotAttService;
|
|
|
+ @Autowired
|
|
|
+ private InvLotLocIdMapper invLotLocIdMapper;
|
|
|
+ @Autowired
|
|
|
+ private IActAllocationDetailsService actAllocationDetailsService;
|
|
|
|
|
|
/**
|
|
|
* 查询入库单
|
|
@@ -120,7 +128,7 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
@Override
|
|
|
public int insertWmsDocAsnHeader(WmsDocAsnHeader wmsDocAsnHeader) {
|
|
|
int rows = wmsDocAsnHeaderMapper.insertWmsDocAsnHeader(wmsDocAsnHeader);
|
|
|
- insertWmsDocAsnDetails(wmsDocAsnHeader);
|
|
|
+ //insertWmsDocAsnDetails(wmsDocAsnHeader);
|
|
|
return rows;
|
|
|
}
|
|
|
|
|
@@ -205,6 +213,23 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 检查是否有相同分类的物料在同一个托盘上
|
|
|
+ *
|
|
|
+ * @param palletNo 托盘编号
|
|
|
+ * @param sku 物料
|
|
|
+ * @return true没有相同的false有
|
|
|
+ */
|
|
|
+ private boolean checkSameTypeByPalletNo(String palletNo, String sku) {
|
|
|
+ BaseSku baseSku = baseSkuService.selectBaseSkuByCustomerId(Constant.CUSTOMER_ID, sku);
|
|
|
+ List<InvLotLocId> invLotLocIdList = invLotLocIdMapper.querySameTypeByPalletNo(baseSku.getSkuType(), palletNo);
|
|
|
+ if (invLotLocIdList != null && invLotLocIdList.size() > 0) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 入库码盘
|
|
|
*
|
|
@@ -215,9 +240,11 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
@Override
|
|
|
public AjaxResult doStock(StockForm stockForm) {
|
|
|
String STAGE01 = "900";
|
|
|
+ BigDecimal totalQty = new BigDecimal(stockForm.getQty());
|
|
|
WmsDocOrderHeader wmsDocOrderHeader;
|
|
|
List<WmsDocOrderDetails> orderDetails;
|
|
|
- Map<String, WmsDocOrderDetails> orderMap = new HashMap<>();
|
|
|
+ Map<String, List<WmsDocOrderDTO>> orderMap = new HashMap<>();
|
|
|
+
|
|
|
//产品条码属于出入库单
|
|
|
if (stockForm.getStockTag().equals("Y") && StringUtils.isEmpty(stockForm.getOrderNo())) {
|
|
|
return AjaxResult.error("备货必须选择出库单号");
|
|
@@ -232,12 +259,160 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
}
|
|
|
orderDetails = wmsDocOrderHeader.getWmsDocOrderDetailsList();
|
|
|
}
|
|
|
-
|
|
|
+ //匹配出库单
|
|
|
+ BigDecimal orderQty = BigDecimal.ZERO;
|
|
|
for (WmsDocOrderDetails de : orderDetails) {
|
|
|
- orderMap.put(de.getSku(), de);
|
|
|
+ if (!de.getSku().equals(stockForm.getSku())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (de.getQtyOrdered().compareTo(de.getQtyAllocated()) == 1) {
|
|
|
+ BigDecimal current = de.getQtyOrdered().subtract(de.getQtyAllocated());
|
|
|
+ orderQty = orderQty.add(current);
|
|
|
+ List<WmsDocOrderDTO> list = orderMap.get(de.getSku());
|
|
|
+ if (list == null) {
|
|
|
+ list = new ArrayList<>();
|
|
|
+ }
|
|
|
+ WmsDocOrderDTO orderDTO = new WmsDocOrderDTO();
|
|
|
+ orderDTO.setOrderNo(de.getOrderNo());
|
|
|
+ orderDTO.setOrderLineNo(de.getOrderLineNo().longValue());
|
|
|
+ orderDTO.setQty(current);
|
|
|
+ list.add(orderDTO);
|
|
|
+ orderMap.put(de.getSku(), list);
|
|
|
+ if (orderQty.compareTo(totalQty) == 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (stockForm.getStockTag().equals("Y")) {
|
|
|
+ if (orderQty.compareTo(BigDecimal.ZERO) != 1 || orderQty.compareTo(new BigDecimal(stockForm.getQty())) == -1) {
|
|
|
+ return AjaxResult.error("接收数超出出货单需求数量");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断成品条码
|
|
|
+ InvLotAtt queryAtt = new InvLotAtt();
|
|
|
+ queryAtt.setSku(stockForm.getSku());
|
|
|
+ queryAtt.setLotatt02(stockForm.getSkuSn());
|
|
|
+ List<InvLotLocId> invList = invLotLocIdService.queryInvByInvLotatt(queryAtt, stockForm.getPalletNo());
|
|
|
+ if (invList != null && invList.size() > 1) {
|
|
|
+ throw new ServiceException("每个成品条码只允许码一次");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (checkSameTypeByPalletNo(stockForm.getPalletNo(), stockForm.getSku()) == false) {
|
|
|
+ throw new ServiceException("不同的产品分类不允许放一个托盘上");
|
|
|
+ }
|
|
|
+
|
|
|
+ //匹配对应的入库单,出库单
|
|
|
+ if (stockForm.getAsnNo() != null && stockForm.getAsnNo().size() > 0) {
|
|
|
+ List<WmsDocAsnDetails> list = wmsDocAsnDetailsMapper.selectDetailsListByAsnNos(stockForm.getAsnNo(), stockForm.getSku());
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ return AjaxResult.error("没有可以接收的入库单");
|
|
|
+ } else {
|
|
|
+ for (WmsDocAsnDetails details : list) {
|
|
|
+ //如果入库单预计数量大于接收数
|
|
|
+ if (details.getExpectedQty().compareTo(details.getReceivedQty()) == 1) {
|
|
|
+ //当前入库单可以接收的数量
|
|
|
+ BigDecimal current = details.getExpectedQty().subtract(details.getReceivedQty());
|
|
|
+ BigDecimal asnCurrent = current;//当前需要扣减的数量
|
|
|
+ if (current.compareTo(BigDecimal.ZERO) != 1) {
|
|
|
+ //如果没有可以接收的数量那么直接跳过
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (totalQty.compareTo(current) != 1) { //如果入库数量<=订单数量
|
|
|
+ current = totalQty;
|
|
|
+ }
|
|
|
+ //判断提交的总数是否已经分配完了
|
|
|
+ if (totalQty.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ String asnStatus;
|
|
|
+ if (details.getExpectedQty().compareTo(details.getReceivedQty().add(current)) == 1) {
|
|
|
+ //部分接收
|
|
|
+ asnStatus = "30";
|
|
|
+ } else {
|
|
|
+ //接收完成
|
|
|
+ asnStatus = "40";
|
|
|
+ }
|
|
|
+ //更新入库单接收数量及状态
|
|
|
+ wmsDocAsnDetailsMapper.updateWmsReceivedQty(details.getAsnNo(), details.getAsnLineNo().intValue(), current, asnStatus);
|
|
|
+ if (!StringUtils.isEmpty(stockForm.getOrderNo())) {
|
|
|
+ //绑定对应入库单号
|
|
|
+ WmsDocAsnDetails updateDetails = new WmsDocAsnDetails();
|
|
|
+ updateDetails.setAsnNo(details.getAsnNo());
|
|
|
+ updateDetails.setAsnLineNo(details.getAsnLineNo());
|
|
|
+ wmsDocAsnDetailsMapper.updateWmsDocAsnDetails(updateDetails);
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 检查头单状态
|
|
|
+ /*WmsDocAsnDetails detailsQuery = new WmsDocAsnDetails();
|
|
|
+ detailsQuery.setAsnNo(details.getAsnNo());
|
|
|
+ List<WmsDocAsnDetails> detailsCheckList = wmsDocAsnDetailsMapper.selectWmsDocAsnDetailsList(detailsQuery);
|
|
|
+ for (WmsDocAsnDetails d : detailsCheckList) {
|
|
|
+
|
|
|
+ }*/
|
|
|
+ WmsDocAsnHeader headerUpdate = new WmsDocAsnHeader();
|
|
|
+ headerUpdate.setAsnNo(details.getAsnNo());
|
|
|
+ headerUpdate.setAsnStatus(asnStatus);
|
|
|
+ wmsDocAsnHeaderMapper.updateWmsDocAsnHeader(headerUpdate);
|
|
|
+
|
|
|
+ //生成库存
|
|
|
+ LotattDTO lotattDTO = new LotattDTO();
|
|
|
+ lotattDTO.setLotatt02(stockForm.getSkuSn());
|
|
|
+ lotattDTO.setLotatt05("90");
|
|
|
+ lotattDTO.setLotatt07(stockForm.getPalletNo());
|
|
|
+ lotattDTO.setLotatt08(details.getAsnNo());
|
|
|
+ lotattDTO.setLotatt12("N");
|
|
|
+ lotattDTO.setLotatt13(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
|
|
|
+ lotattDTO.setLotatt14(stockForm.getOrderNo());
|
|
|
+ String lotnum = invLotLocIdService.initInv(STAGE01, stockForm.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, current);
|
|
|
+
|
|
|
+ //更新出库单备货数量
|
|
|
+ List<WmsDocOrderDTO> odList = orderMap.get(details.getSku());
|
|
|
+ BigDecimal orderCurrent = current;//当前需要扣减的数量
|
|
|
+ for (WmsDocOrderDTO dto : odList) {
|
|
|
+ BigDecimal subQty;
|
|
|
+ String soStatus;
|
|
|
+ //如果当前订单需要的数量大于扣减数,那么就加上所有扣减数
|
|
|
+ if (dto.getQty().compareTo(orderCurrent) == 1) {
|
|
|
+ soStatus = "10";
|
|
|
+ subQty = orderCurrent;
|
|
|
+ wmsDocOrderHeaderService.updateOrderDetailsStock(dto.getOrderNo(), dto.getOrderLineNo().longValue(), details.getSku(), orderCurrent.doubleValue(), soStatus);
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ //如果当前订单需求数量小于扣减数那么循环对下一个订单继续扣减
|
|
|
+ soStatus = "20";
|
|
|
+ subQty = dto.getQty();
|
|
|
+ orderCurrent = orderCurrent.subtract(dto.getQty());
|
|
|
+ wmsDocOrderHeaderService.updateOrderDetailsStock(dto.getOrderNo(), dto.getOrderLineNo().longValue(), details.getSku(), dto.getQty().doubleValue(), soStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 修改头单状态
|
|
|
+ WmsDocOrderHeader odHeaderUpdate = new WmsDocOrderHeader();
|
|
|
+ odHeaderUpdate.setOrderNo(dto.getOrderNo());
|
|
|
+ odHeaderUpdate.setOrderStatus(soStatus);
|
|
|
+ wmsDocOrderHeaderService.updateWmsDocOrderHeader(odHeaderUpdate);
|
|
|
+
|
|
|
+ //记录分配明细(由于是初始化的库存所以只绑定到对应的托盘)
|
|
|
+ /*ActAllocationDetails actAllocationDetails = new ActAllocationDetails();
|
|
|
+ actAllocationDetails.setAllocationId(SnowflakeIdWorker.generateId().toString());
|
|
|
+ actAllocationDetails.setLineNo(dto.getOrderLineNo());
|
|
|
+ actAllocationDetails.setOrderNo(dto.getOrderNo());
|
|
|
+ actAllocationDetails.setQty(subQty);
|
|
|
+ actAllocationDetails.setMaterial(details.getSku());
|
|
|
+ actAllocationDetails.setStatus("00");
|
|
|
+ actAllocationDetails.setLotnum(lotnum);
|
|
|
+ actAllocationDetails.setUserdefine1(stockForm.getPalletNo());
|
|
|
+ actAllocationDetailsService.insertActAllocationDetails(actAllocationDetails);*/
|
|
|
+ }
|
|
|
+ totalQty = totalQty.subtract(current);
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //查询托盘是否存在
|
|
|
+ //查询托盘是否存在,生成托盘绑定信息
|
|
|
WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
|
|
|
wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
|
|
|
wmsBoxInfo = boxInfoService.selectWmsBoxInfoByModel(wmsBoxInfo);
|
|
@@ -255,95 +430,6 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
wmsBoxInfo.setLocationId(Long.parseLong(STAGE01));
|
|
|
boxInfoService.updateWmsBoxInfo(wmsBoxInfo);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- List<StockInfoForm> stockInfoForms = stockForm.getStockInfoFormList();
|
|
|
- String skuType = "";
|
|
|
- for (StockInfoForm s : stockInfoForms) {
|
|
|
- BaseSku baseSku = baseSkuService.selectBaseSkuByCustomerId(Constant.CUSTOMER_ID, s.getSku());
|
|
|
- if (skuType.equals("")) {
|
|
|
- skuType = baseSku.getSkuType();
|
|
|
- } else {
|
|
|
- if (!baseSku.getSkuType().equals(skuType)) {
|
|
|
- throw new ServiceException("不同的产品分类不允许放一个托盘上");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //判断成品条码
|
|
|
- InvLotAtt queryAtt = new InvLotAtt();
|
|
|
- queryAtt.setSku(s.getSku());
|
|
|
- queryAtt.setLotatt02(s.getSkuSn());
|
|
|
- List<InvLotLocId> invList = invLotLocIdService.queryInvByInvLotatt(queryAtt, stockForm.getPalletNo());
|
|
|
- if (invList != null && invList.size() > 1) {
|
|
|
- throw new ServiceException("每个成品条码只允许码一次");
|
|
|
- }
|
|
|
-
|
|
|
- WmsDocAsnDetails asnDetails = wmsDocAsnHeaderMapper.selectWmsDocDetailsOne(s.getAsnNo(), s.getAsnLineNo());
|
|
|
- if (asnDetails == null) {
|
|
|
- throw new ServiceException("入库记录不存在");
|
|
|
- }
|
|
|
-
|
|
|
- if (stockForm.getStockTag().equals("Y")) {
|
|
|
- //如果是备货需要判断入库单
|
|
|
- WmsDocOrderDetails od = orderMap.get(s.getSku());
|
|
|
-// if (od.getQtyOrdered().subtract(new BigDecimal(s.getQty())).compareTo(BigDecimal.ZERO) != 1) {
|
|
|
-// throw new ServiceException("备货数量超出出库单需求数量");
|
|
|
-// }
|
|
|
- if (od.getQtyOrdered().compareTo(new BigDecimal(s.getQty()).add(od.getQtySoftAllocated())) == -1) {
|
|
|
- throw new ServiceException("备货数量超出出库单需求数量");
|
|
|
- }
|
|
|
- //更新出库单备货数量
|
|
|
- wmsDocOrderHeaderService.updateOrderDetailsStock(od.getOrderNo(), od.getOrderLineNo().longValue(), od.getSku(), new BigDecimal(s.getQty()).doubleValue());
|
|
|
- }
|
|
|
- //生成库存
|
|
|
- LotattDTO lotattDTO = new LotattDTO();
|
|
|
- lotattDTO.setLotatt02(s.getSkuSn());
|
|
|
- lotattDTO.setLotatt05("90");
|
|
|
- lotattDTO.setLotatt07(stockForm.getPalletNo());
|
|
|
- lotattDTO.setLotatt08(s.getAsnNo());
|
|
|
- lotattDTO.setLotatt12("N");
|
|
|
- lotattDTO.setLotatt13(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
|
|
|
- lotattDTO.setLotatt14(stockForm.getOrderNo());
|
|
|
- invLotLocIdService.initInv(STAGE01, s.getSku(), Constant.CUSTOMER_ID, new BigDecimal(s.getQty()).doubleValue(), lotattDTO);
|
|
|
-
|
|
|
- //更新数量
|
|
|
- asnDetails.setReceivedQty(asnDetails.getReceivedQty().add(new BigDecimal(s.getQty())));
|
|
|
- String asnStatus = "30";
|
|
|
- if (asnDetails.getReceivedQty().compareTo(asnDetails.getExpectedQty()) == 0) {
|
|
|
- asnStatus = "40";
|
|
|
- boolean isClose = true;
|
|
|
- WmsDocAsnDetails query = new WmsDocAsnDetails();
|
|
|
- query.setAsnNo(s.getAsnNo());
|
|
|
- List<WmsDocAsnDetails> detailsList = wmsDocAsnDetailsMapper.selectWmsDocAsnDetailsList(query);
|
|
|
- if (detailsList != null && detailsList.size() > 0) {
|
|
|
- for (WmsDocAsnDetails de : detailsList) {
|
|
|
- if (de.getLineStatus().equals("30")) {
|
|
|
- isClose = false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- WmsDocAsnHeader updateStatus = new WmsDocAsnHeader();
|
|
|
- if (isClose) {
|
|
|
- updateStatus.setAsnStatus("40");
|
|
|
- } else {
|
|
|
- updateStatus.setAsnStatus("30");
|
|
|
- }
|
|
|
- wmsDocAsnHeaderMapper.updateWmsDocAsnHeader(updateStatus);
|
|
|
- }
|
|
|
-
|
|
|
- //更新入库单数量
|
|
|
- wmsDocAsnDetailsMapper.updateWmsReceivedQty(asnDetails.getAsnNo(), asnDetails.getAsnLineNo().intValue(), new BigDecimal(s.getQty()), asnStatus);
|
|
|
- if (!StringUtils.isEmpty(stockForm.getOrderNo())) {
|
|
|
- //绑定对应入库单号
|
|
|
- WmsDocAsnDetails updateDetails = new WmsDocAsnDetails();
|
|
|
- updateDetails.setAsnNo(asnDetails.getAsnNo());
|
|
|
- updateDetails.setAsnLineNo(asnDetails.getAsnLineNo());
|
|
|
- updateDetails.setdEdi01(stockForm.getOrderNo());
|
|
|
- updateDetails.setdEdi02(s.getSkuSn());//产品sn
|
|
|
- wmsDocAsnDetailsMapper.updateWmsDocAsnDetails(updateDetails);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
return AjaxResult.success("操作成功");
|
|
|
}
|
|
|
|
|
@@ -369,9 +455,6 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
moveForm.setLocationTo(paForm.getLocationTo());
|
|
|
moveForm.setIsCallCar("N");
|
|
|
|
|
|
- //更新明细状态
|
|
|
-
|
|
|
-
|
|
|
List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvByInvLotatt(null, palletNo);
|
|
|
InvLotAtt invLotAtt = null;
|
|
|
if (invLotLocIdList != null && invLotLocIdList.size() > 0) {
|