|
@@ -29,7 +29,9 @@ import com.ruoyi.ams.order.service.IWmsDocOrderDetailsService;
|
|
|
import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
|
|
|
import com.ruoyi.base.constant.Constant;
|
|
|
import com.ruoyi.base.domain.BaseSku;
|
|
|
+import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
|
|
|
import com.ruoyi.base.service.IBaseSkuService;
|
|
|
+import com.ruoyi.base.service.ICodeSkuRelationshipService;
|
|
|
import com.ruoyi.base.utils.IdSequenceUtils;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
@@ -81,6 +83,8 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
private InvLotLocIdMapper invLotLocIdMapper;
|
|
|
@Autowired
|
|
|
private IActAllocationDetailsService actAllocationDetailsService;
|
|
|
+ @Autowired
|
|
|
+ private ICodeSkuRelationshipService codeSkuRelationshipService;
|
|
|
|
|
|
/**
|
|
|
* 查询入库单
|
|
@@ -245,13 +249,46 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
String STAGE01 = "900";
|
|
|
BigDecimal totalQty = new BigDecimal(stockForm.getQty());
|
|
|
WmsDocOrderHeader wmsDocOrderHeader;
|
|
|
- List<WmsDocOrderDetails> orderDetails;
|
|
|
+ List<WmsDocOrderDetails> orderDetails = new ArrayList<>();
|
|
|
Map<String, List<WmsDocOrderDTO>> orderMap = new HashMap<>();
|
|
|
|
|
|
+ //查询托盘是否存在,生成托盘绑定信息
|
|
|
+ WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
|
|
|
+ wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
|
|
|
+ wmsBoxInfo = boxInfoService.selectWmsBoxInfoByModel(wmsBoxInfo);
|
|
|
+ if (wmsBoxInfo == null) {
|
|
|
+ //不存在则创建托盘信息
|
|
|
+ wmsBoxInfo = new WmsBoxInfo();
|
|
|
+ wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
|
|
|
+ wmsBoxInfo.setBoxState(1);
|
|
|
+ wmsBoxInfo.setBoxType("pallet");
|
|
|
+ wmsBoxInfo.setIsFull(stockForm.getFullTag());
|
|
|
+ wmsBoxInfo.setCreateBy(loginUser.getUsername());
|
|
|
+ wmsBoxInfo.setCreateTime(new Date());
|
|
|
+ wmsBoxInfo.setUpdateBy(loginUser.getUsername());
|
|
|
+ wmsBoxInfo.setUpdateTime(new Date());
|
|
|
+ boxInfoService.insertWmsBoxInfo(wmsBoxInfo);
|
|
|
+ } else {
|
|
|
+ //判断已满拖的话不接收
|
|
|
+ if (wmsBoxInfo.getIsFull().equals("Y")) {
|
|
|
+ throw new ServiceException("该托盘已放满");
|
|
|
+ }
|
|
|
+ wmsBoxInfo.setBoxState(1);
|
|
|
+ wmsBoxInfo.setIsFull(stockForm.getFullTag());
|
|
|
+ wmsBoxInfo.setLocationId(Long.parseLong(STAGE01));
|
|
|
+ wmsBoxInfo.setUpdateBy(loginUser.getUsername());
|
|
|
+ wmsBoxInfo.setUpdateTime(new Date());
|
|
|
+ boxInfoService.updateWmsBoxInfo(wmsBoxInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断成品条码
|
|
|
+ CodeSkuRelationshipVO codeSkuRelationshipVO = codeSkuRelationshipService.checkIsProduct(stockForm.getSkuSn());
|
|
|
+
|
|
|
//产品条码属于出入库单
|
|
|
if (stockForm.getStockTag().equals("Y") && StringUtils.isEmpty(stockForm.getOrderNo())) {
|
|
|
return AjaxResult.error("备货必须选择出库单号");
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ if (stockForm.getStockTag().equals("Y")) {
|
|
|
//查询出库单
|
|
|
wmsDocOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(stockForm.getOrderNo());
|
|
|
if (wmsDocOrderHeader == null) {
|
|
@@ -261,58 +298,63 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
return AjaxResult.error("出库单已完成");
|
|
|
}
|
|
|
orderDetails = wmsDocOrderHeader.getWmsDocOrderDetailsList();
|
|
|
- }
|
|
|
- //匹配出库单
|
|
|
- BigDecimal orderQty = BigDecimal.ZERO;
|
|
|
- for (WmsDocOrderDetails de : orderDetails) {
|
|
|
- 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<>();
|
|
|
+
|
|
|
+ //匹配出库单
|
|
|
+ BigDecimal orderQty = BigDecimal.ZERO;
|
|
|
+ for (WmsDocOrderDetails de : orderDetails) {
|
|
|
+ if (!de.getSku().equals(codeSkuRelationshipVO.getSku())) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- 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 (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 (codeSkuRelationshipVO.isProduct()) {
|
|
|
+ stockForm.setQty("1");
|
|
|
|
|
|
- if (checkSameTypeByPalletNo(stockForm.getPalletNo(), stockForm.getSku()) == false) {
|
|
|
- throw new ServiceException("不同的产品分类不允许放一个托盘上");
|
|
|
+ InvLotAtt queryAtt = new InvLotAtt();
|
|
|
+ queryAtt.setSku(codeSkuRelationshipVO.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(), codeSkuRelationshipVO.getSku()) == false) {
|
|
|
+ throw new ServiceException("不同的产品分类不允许放一个托盘上");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//匹配对应的入库单,出库单
|
|
|
if (stockForm.getAsnNo() != null && stockForm.getAsnNo().size() > 0) {
|
|
|
- List<WmsDocAsnDetails> list = wmsDocAsnDetailsMapper.selectDetailsListByAsnNos(stockForm.getAsnNo(), stockForm.getSku());
|
|
|
+ List<WmsDocAsnDetails> list = wmsDocAsnDetailsMapper.selectDetailsListByAsnNos(stockForm.getAsnNo(), codeSkuRelationshipVO.getSku());
|
|
|
if (list == null || list.size() == 0) {
|
|
|
return AjaxResult.error("没有可以接收的入库单");
|
|
|
} else {
|
|
|
for (WmsDocAsnDetails details : list) {
|
|
|
+ if (new BigDecimal(stockForm.getQty()).compareTo(details.getExpectedQty()) == 1) {
|
|
|
+ throw new ServiceException("入库数量超出入库单数量");
|
|
|
+ }
|
|
|
//如果入库单预计数量大于接收数
|
|
|
if (details.getExpectedQty().compareTo(details.getReceivedQty()) == 1) {
|
|
|
//当前入库单可以接收的数量
|
|
@@ -367,85 +409,10 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
lotattDTO.setLotatt05("90");
|
|
|
lotattDTO.setLotatt07(stockForm.getPalletNo());
|
|
|
lotattDTO.setLotatt08(details.getAsnNo());
|
|
|
- lotattDTO.setLotatt12("N");
|
|
|
+ lotattDTO.setLotatt12("Y");
|
|
|
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(), orderCurrent.doubleValue(), soStatus);
|
|
|
-
|
|
|
- //TODO 修改头单状态
|
|
|
- WmsDocOrderHeader odHeaderUpdate = new WmsDocOrderHeader();
|
|
|
- odHeaderUpdate.setOrderNo(dto.getOrderNo());
|
|
|
- odHeaderUpdate.setOrderStatus(soStatus);
|
|
|
- odHeaderUpdate.setUpdateBy(loginUser.getUsername());
|
|
|
- odHeaderUpdate.setUpdateTime(new Date());
|
|
|
- wmsDocOrderHeaderService.updateWmsDocOrderHeader(odHeaderUpdate);
|
|
|
-
|
|
|
- //记录分配明细(由于是初始化的库存所以只绑定到对应的托盘)
|
|
|
- ActAllocationDetails actAllocationDetails = new ActAllocationDetails();
|
|
|
- actAllocationDetails.setAllocationId(SnowflakeIdWorker.generateId().toString());
|
|
|
- actAllocationDetails.setLineNo(dto.getOrderLineNo());
|
|
|
- actAllocationDetails.setOrderNo(dto.getOrderNo());
|
|
|
- actAllocationDetails.setQty(subQty);
|
|
|
- actAllocationDetails.setPickQty(BigDecimal.ZERO);
|
|
|
- actAllocationDetails.setMaterial(details.getSku());
|
|
|
- actAllocationDetails.setStatus("00");
|
|
|
- actAllocationDetails.setLotnum(lotnum);
|
|
|
- actAllocationDetails.setUserdefine1(stockForm.getPalletNo());
|
|
|
- actAllocationDetails.setCreateBy(loginUser.getUsername());
|
|
|
- actAllocationDetails.setCreateTime(new Date());
|
|
|
- actAllocationDetails.setUpdateBy(loginUser.getUsername());
|
|
|
- actAllocationDetails.setUpdateTime(new Date());
|
|
|
- actAllocationDetailsService.addOrUpdateAllocationDetails(actAllocationDetails);
|
|
|
-
|
|
|
- break;
|
|
|
- } else {
|
|
|
- //如果当前订单需求数量小于扣减数那么循环对下一个订单继续扣减
|
|
|
- soStatus = "20";
|
|
|
- subQty = dto.getQty();
|
|
|
- orderCurrent = orderCurrent.subtract(dto.getQty());
|
|
|
- wmsDocOrderHeaderService.updateOrderDetailsStock(dto.getOrderNo(), dto.getOrderLineNo().longValue(), dto.getQty().doubleValue(), soStatus);
|
|
|
-
|
|
|
- //TODO 修改头单状态
|
|
|
- WmsDocOrderHeader odHeaderUpdate = new WmsDocOrderHeader();
|
|
|
- odHeaderUpdate.setOrderNo(dto.getOrderNo());
|
|
|
- odHeaderUpdate.setOrderStatus(soStatus);
|
|
|
- odHeaderUpdate.setCreateBy(loginUser.getUsername());
|
|
|
- odHeaderUpdate.setCreateTime(new Date());
|
|
|
- odHeaderUpdate.setUpdateBy(loginUser.getUsername());
|
|
|
- odHeaderUpdate.setUpdateTime(new Date());
|
|
|
- wmsDocOrderHeaderService.updateWmsDocOrderHeader(odHeaderUpdate);
|
|
|
-
|
|
|
- //记录分配明细(由于是初始化的库存所以只绑定到对应的托盘)
|
|
|
- ActAllocationDetails actAllocationDetails = new ActAllocationDetails();
|
|
|
- actAllocationDetails.setAllocationId(SnowflakeIdWorker.generateId().toString());
|
|
|
- actAllocationDetails.setLineNo(dto.getOrderLineNo());
|
|
|
- actAllocationDetails.setOrderNo(dto.getOrderNo());
|
|
|
- actAllocationDetails.setQty(subQty);
|
|
|
- actAllocationDetails.setPickQty(BigDecimal.ZERO);
|
|
|
- actAllocationDetails.setMaterial(details.getSku());
|
|
|
- actAllocationDetails.setStatus("00");
|
|
|
- actAllocationDetails.setLotnum(lotnum);
|
|
|
- actAllocationDetails.setUserdefine1(stockForm.getPalletNo());
|
|
|
- actAllocationDetails.setCreateBy(loginUser.getUsername());
|
|
|
- actAllocationDetails.setCreateTime(new Date());
|
|
|
- actAllocationDetails.setUpdateBy(loginUser.getUsername());
|
|
|
- actAllocationDetails.setUpdateTime(new Date());
|
|
|
- actAllocationDetailsService.addOrUpdateAllocationDetails(actAllocationDetails);
|
|
|
- }
|
|
|
- }
|
|
|
- totalQty = totalQty.subtract(current);
|
|
|
+ String lotnum = invLotLocIdService.initInv(STAGE01, codeSkuRelationshipVO.getSku(), Constant.CUSTOMER_ID, current.doubleValue(), lotattDTO, BigDecimal.ZERO);
|
|
|
} else {
|
|
|
break;
|
|
|
}
|
|
@@ -453,31 +420,6 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //查询托盘是否存在,生成托盘绑定信息
|
|
|
- WmsBoxInfo wmsBoxInfo = new WmsBoxInfo();
|
|
|
- wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
|
|
|
- wmsBoxInfo = boxInfoService.selectWmsBoxInfoByModel(wmsBoxInfo);
|
|
|
- if (wmsBoxInfo == null) {
|
|
|
- //不存在则创建托盘信息
|
|
|
- wmsBoxInfo = new WmsBoxInfo();
|
|
|
- wmsBoxInfo.setBoxNo(stockForm.getPalletNo());
|
|
|
- wmsBoxInfo.setBoxState(1);
|
|
|
- wmsBoxInfo.setBoxType("pallet");
|
|
|
- wmsBoxInfo.setIsFull(stockForm.getFullTag());
|
|
|
- wmsBoxInfo.setCreateBy(loginUser.getUsername());
|
|
|
- wmsBoxInfo.setCreateTime(new Date());
|
|
|
- wmsBoxInfo.setUpdateBy(loginUser.getUsername());
|
|
|
- wmsBoxInfo.setUpdateTime(new Date());
|
|
|
- boxInfoService.insertWmsBoxInfo(wmsBoxInfo);
|
|
|
- } else {
|
|
|
- wmsBoxInfo.setBoxState(1);
|
|
|
- wmsBoxInfo.setIsFull(stockForm.getFullTag());
|
|
|
- wmsBoxInfo.setLocationId(Long.parseLong(STAGE01));
|
|
|
- wmsBoxInfo.setUpdateBy(loginUser.getUsername());
|
|
|
- wmsBoxInfo.setUpdateTime(new Date());
|
|
|
- boxInfoService.updateWmsBoxInfo(wmsBoxInfo);
|
|
|
- }
|
|
|
return AjaxResult.success("操作成功");
|
|
|
}
|
|
|
|
|
@@ -502,7 +444,8 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
lotatt08 = invLotAtt.getLotatt08();
|
|
|
}
|
|
|
//更新托盘库存到起始库位
|
|
|
- invLotLocIdMapper.updateInvLotLocIdLocationId(Long.parseLong(inv.getLocationId()), Long.parseLong(paForm.getLocationTo()));
|
|
|
+ //invLotLocIdMapper.updateInvLotLocIdLocationId(Long.parseLong(inv.getLocationId()), Long.parseLong(paForm.getLocationTo()));
|
|
|
+ invLotLocIdMapper.updateInvLotLocIdToByLotnum(inv.getLotnum(), Long.parseLong(paForm.getLocationTo()));
|
|
|
}
|
|
|
|
|
|
wmsBoxInfo.setLocationId(Long.parseLong(paForm.getLocationTo()));
|
|
@@ -584,6 +527,8 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
|
|
|
allQuery.setUserdefine1(unlockForm.getPalletNo());
|
|
|
List<ActAllocationDetails> allocationDetails = actAllocationDetailsService.selectActAllocationDetailsList(allQuery);
|
|
|
for (ActAllocationDetails actAllocationDetails : allocationDetails) {
|
|
|
+ //删除分配表
|
|
|
+ actAllocationDetailsService.deleteActAllocationDetailsByAllocationId(actAllocationDetails.getAllocationId());
|
|
|
wmsDocOrderDetailsMapper.updateOrderDetailsStock(actAllocationDetails.getOrderNo(), actAllocationDetails.getLineNo(), (-1 * actAllocationDetails.getQty().doubleValue()), "00");
|
|
|
}
|
|
|
return AjaxResult.success("解绑成功");
|