|
@@ -1,26 +1,11 @@
|
|
|
package com.lote.wms.outstock.outshelf.service.impl;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.UUID;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.mybatis.plugin.model.Pager;
|
|
|
-import org.mybatis.plugin.util.PagerUtil;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
+import com.lote.wms.base.product.dao.ProductMapper;
|
|
|
+import com.lote.wms.base.product.entity.Product;
|
|
|
+import com.lote.wms.base.product.entity.queryvo.ProductQueryVo;
|
|
|
+import com.lote.wms.base.warehouse.dao.LocationMapper;
|
|
|
+import com.lote.wms.base.warehouse.entity.queryvo.LocationQueryVo;
|
|
|
+import com.lote.wms.base.warehouse.entity.resultvo.LocationResultVo;
|
|
|
import com.lote.wms.common.config.SystemConfig;
|
|
|
import com.lote.wms.common.constants.BaseConstant;
|
|
|
import com.lote.wms.common.core.db.DataAccessHolder;
|
|
@@ -28,13 +13,7 @@ import com.lote.wms.common.core.db.IdWorkerAide;
|
|
|
import com.lote.wms.common.exception.ServiceException;
|
|
|
import com.lote.wms.common.model.Message;
|
|
|
import com.lote.wms.common.service.ILockService;
|
|
|
-import com.lote.wms.common.utils.BeanUtil;
|
|
|
-import com.lote.wms.common.utils.DateUtil;
|
|
|
-import com.lote.wms.common.utils.FileServerClient;
|
|
|
-import com.lote.wms.common.utils.LockUtil;
|
|
|
-import com.lote.wms.common.utils.NumberUtil;
|
|
|
-import com.lote.wms.common.utils.POIExcelUtil;
|
|
|
-import com.lote.wms.common.utils.StringUtil;
|
|
|
+import com.lote.wms.common.utils.*;
|
|
|
import com.lote.wms.inventory.inventory.entity.Inventory;
|
|
|
import com.lote.wms.inventory.inventory.entity.enums.InventoryOpTypeEnum;
|
|
|
import com.lote.wms.inventory.inventory.entity.expand.InventoryVo;
|
|
@@ -63,6 +42,19 @@ import com.lote.wms.outstock.wave.entity.enums.OutWaveStatusEnum;
|
|
|
import com.lote.wms.outstock.wave.service.OutWaveItemService;
|
|
|
import com.lote.wms.outstock.wave.service.OutWaveService;
|
|
|
import com.lote.wms.user.user.entity.User;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.mybatis.plugin.model.Pager;
|
|
|
+import org.mybatis.plugin.util.PagerUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service("outShelfService")
|
|
|
public class OutShelfServiceImpl implements OutShelfService {
|
|
@@ -70,6 +62,12 @@ public class OutShelfServiceImpl implements OutShelfService {
|
|
|
@Autowired
|
|
|
private OutShelfMapper outShelfMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductMapper productMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LocationMapper locationMapper;
|
|
|
+
|
|
|
@Resource
|
|
|
private OutInventoryAllocationService outInventoryAllocationService;
|
|
|
|
|
@@ -234,10 +232,10 @@ public class OutShelfServiceImpl implements OutShelfService {
|
|
|
message.setMsg("商品条码不能为空!");
|
|
|
return message;
|
|
|
}
|
|
|
- if (StringUtil.isEmpty(vo.getLocationCode())) {
|
|
|
- message.setMsg("实际库位不能为空!");
|
|
|
- return message;
|
|
|
- }
|
|
|
+// if (StringUtil.isEmpty(vo.getLocationCode())) {
|
|
|
+// message.setMsg("实际库位不能为空!");
|
|
|
+// return message;
|
|
|
+// }
|
|
|
if (vo.getQuantity() <= 0) {
|
|
|
message.setMsg("下架数量必须大于0!");
|
|
|
return message;
|
|
@@ -254,7 +252,7 @@ public class OutShelfServiceImpl implements OutShelfService {
|
|
|
// 预分配id
|
|
|
String allocationId = vo.getAllocationId();
|
|
|
String barcode = vo.getBarcode().trim();
|
|
|
- String locationCode = vo.getLocationCode().trim();
|
|
|
+// String locationCode = vo.getLocationCode().trim();
|
|
|
Integer quantity = vo.getQuantity();// 本次下架数量
|
|
|
|
|
|
OutOrder order = outOrderService.getForWms(outOrderId);
|
|
@@ -300,12 +298,12 @@ public class OutShelfServiceImpl implements OutShelfService {
|
|
|
message.setMsg("订单id和库存分配不匹配!请重新提交订单号");
|
|
|
return message;
|
|
|
}
|
|
|
- if (!StringUtil.isEqualIgnoreCase(allocation.getLocationCode(), locationCode)) {
|
|
|
- message.setMsg("请重新在库位输入框按回车提交库位");
|
|
|
- outOrderLogService.addLog(order, user, typeEnum, null, message.getMsg(), false);
|
|
|
- return message;
|
|
|
- }
|
|
|
- locationCode = allocation.getLocationCode();// 更正大小写
|
|
|
+// if (!StringUtil.isEqualIgnoreCase(allocation.getLocationCode(), locationCode)) {
|
|
|
+// message.setMsg("请重新在库位输入框按回车提交库位");
|
|
|
+// outOrderLogService.addLog(order, user, typeEnum, null, message.getMsg(), false);
|
|
|
+// return message;
|
|
|
+// }
|
|
|
+// locationCode = allocation.getLocationCode();// 更正大小写
|
|
|
|
|
|
if (!StringUtil.isEqualIgnoreCase(allocation.getBarcode(), barcode)) {
|
|
|
message.setMsg("请重新在商品条码输入框按回车提交条码");
|
|
@@ -404,10 +402,10 @@ public class OutShelfServiceImpl implements OutShelfService {
|
|
|
}
|
|
|
|
|
|
// 2019-03-20 - 给前端返回该库位是否还有商品条码未下架
|
|
|
- boolean locationisFinished = outInventoryAllocationService.isFinished(outOrderId, locationCode);
|
|
|
+ boolean locationisFinished = outInventoryAllocationService.isFinished(outOrderId, allocation.getLocationCode());
|
|
|
if (locationisFinished) {
|
|
|
// 该库位完成下架
|
|
|
- message.setMsg("该库位已下架完成,请到下一个库位");
|
|
|
+ message.setMsg("该条形码["+allocation.getBarcode()+"]的库位["+allocation.getLocationCode()+"]已下架完成,请到下一个库位");
|
|
|
message.setExtend("2");
|
|
|
} else {
|
|
|
// 代表该库位还有其他条码未完成下架
|
|
@@ -600,6 +598,16 @@ public class OutShelfServiceImpl implements OutShelfService {
|
|
|
return message;
|
|
|
}
|
|
|
List<OutShelfResultVo> list = outShelfMapper.selectForOutBox(orderId);
|
|
|
+ OutOrder outOrder = outOrderService.get(orderId);
|
|
|
+ if (Objects.nonNull(list) && list.size()>0){
|
|
|
+ for (OutShelfResultVo outShelfResultVo : list) {
|
|
|
+ ProductQueryVo productQueryVo = new ProductQueryVo();
|
|
|
+ productQueryVo.setCustomerId(outOrder.getCustomerId());
|
|
|
+ productQueryVo.setSku(outShelfResultVo.getSku());
|
|
|
+ Product product = productMapper.getByCustomerAndSku(productQueryVo);
|
|
|
+ outShelfResultVo.setProductName(product.getProductName());
|
|
|
+ }
|
|
|
+ }
|
|
|
message.setExtend(list);
|
|
|
message.setSuccess(true);
|
|
|
return message;
|
|
@@ -632,23 +640,54 @@ public class OutShelfServiceImpl implements OutShelfService {
|
|
|
return Message.fail("该波次被其他线程锁定!");
|
|
|
}
|
|
|
// 1.查询波次
|
|
|
+ boolean isExist = outWaveService.isExist(vo.getWaveNo());
|
|
|
+ if (!isExist) {
|
|
|
+ // 如果波次号不存在,判断运单是否存在
|
|
|
+ Message message = outOrderService.selectByNo(vo.getWaveNo());
|
|
|
+ if (!message.isSuccess()) {
|
|
|
+ return Message.fail("该波次单号或运单号不存在");
|
|
|
+ }
|
|
|
+ OutOrder order = (OutOrder) message.getExtend();
|
|
|
+ vo.setWaveNo(order.getWaveNo());
|
|
|
+ }
|
|
|
OutWave outWave = outWaveService.getByWaveNo(vo.getWaveNo());
|
|
|
if (outWave == null) {
|
|
|
- return Message.fail("波次号码不存在!");
|
|
|
+ return Message.fail("该波次单号不存在");
|
|
|
}
|
|
|
if (StringUtil.isEqual(outWave.getStatusCode(), OutWaveStatusEnum.FINISH.getCode())) {
|
|
|
return Message.fail("该波次已经完成下架!");
|
|
|
}
|
|
|
// 2.根据波次, 货位号 商品条码查询预下架信息
|
|
|
- String locationCode = vo.getLocationCode();
|
|
|
+// String locationCode = vo.getLocationCode();
|
|
|
String barcode = vo.getBarcode();
|
|
|
String waveId = outWave.getId();
|
|
|
- List<OutInventoryAllocation> list = outInventoryAllocationService.listForWaveOutShelf(waveId, locationCode,
|
|
|
+ List<OutInventoryAllocation> list = outInventoryAllocationService.listForWaveOutShelf(waveId,
|
|
|
barcode);
|
|
|
if (list.size() <= 0) {
|
|
|
- return Message.fail("库位号或商品条码错误,请核对拣货单!");
|
|
|
+ return Message.fail("商品条码错误,请核对拣货单!");
|
|
|
}
|
|
|
|
|
|
+ // 把list按动线号排序
|
|
|
+ for (OutInventoryAllocation allocation : list) {
|
|
|
+ String locationCode = allocation.getLocationCode(); // 当前商品的库位号
|
|
|
+ LocationQueryVo locationQueryVo = new LocationQueryVo();
|
|
|
+ locationQueryVo.setWarehouseCode(allocation.getWarehouseCode());
|
|
|
+ locationQueryVo.setCode(locationCode);
|
|
|
+ locationQueryVo.setZoneCode(allocation.getZoneCode());
|
|
|
+ List<LocationResultVo> locationResultVoList = locationMapper.selectByVoList(locationQueryVo);
|
|
|
+ if (Objects.nonNull(locationResultVoList) && locationResultVoList.size()==1){
|
|
|
+ allocation.setExtend5(locationResultVoList.get(0).getLineNumber().toString()); // 使用个临时字段存动线号
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 对list进行按动线号排序,越小越优先
|
|
|
+ Collections.sort(list, new Comparator<OutInventoryAllocation>() {
|
|
|
+ @Override
|
|
|
+ public int compare(OutInventoryAllocation o1, OutInventoryAllocation o2) {
|
|
|
+ return Integer.compare(Integer.valueOf(o2.getExtend5()==null?"0":o2.getExtend5()),Integer.valueOf(o1.getExtend5()==null?"0":o1.getExtend5()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
// 验证波次内订单状态
|
|
|
for (OutInventoryAllocation allocation : list) {
|
|
|
String outOrderId = allocation.getOutOrderId();
|
|
@@ -696,10 +735,13 @@ public class OutShelfServiceImpl implements OutShelfService {
|
|
|
handleWaveStatusForOutShelf(outWave, user, isFinished);// 更新波次单状态
|
|
|
|
|
|
Message message = Message.success("下架成功");
|
|
|
+ HashMap<String,Object> map = new HashMap<>();
|
|
|
+ map.put("allocationList",list);
|
|
|
if (isFinished) {
|
|
|
message.setMsg("波次:" + outWave.getWaveNo() + ",已完成下架,请操作下一个波次");
|
|
|
- message.setExtend("3"); // 1:该库位的该条码完成 ,2:该库位完成,3: 整个波次完成
|
|
|
+ map.put("flag","3");// 1:该库位的该条码完成 ,2:该库位完成,3: 整个波次完成
|
|
|
}
|
|
|
+ message.setExtend(map);
|
|
|
return message;
|
|
|
} finally {
|
|
|
waveLockService.unlock(vo.getWaveNo());
|