|
@@ -1,11 +1,14 @@
|
|
|
package com.lote.wms.outstock.outshelf.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+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.core.db.DataAccessHolder;
|
|
|
import org.mybatis.plugin.model.Pager;
|
|
|
import org.mybatis.plugin.util.PagerUtil;
|
|
|
import org.slf4j.Logger;
|
|
@@ -46,6 +49,9 @@ public class OutInventoryAllocationServiceImpl implements OutInventoryAllocation
|
|
|
@Autowired
|
|
|
private OutInventoryAllocationMapper outInventoryAllocationMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LocationMapper locationMapper;
|
|
|
+
|
|
|
@Resource
|
|
|
private OutOrderService outOrderService;
|
|
|
|
|
@@ -64,6 +70,8 @@ public class OutInventoryAllocationServiceImpl implements OutInventoryAllocation
|
|
|
@Resource
|
|
|
private InventoryService inventoryService;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private static final Logger logger = LoggerFactory.getLogger(OutInventoryAllocationServiceImpl.class);
|
|
|
|
|
|
public OutInventoryAllocation add(OutInventoryAllocation record) {
|
|
@@ -156,10 +164,10 @@ public class OutInventoryAllocationServiceImpl implements OutInventoryAllocation
|
|
|
message.setMsg("出库单Id不能为空,请先提交出库单号");
|
|
|
return message;
|
|
|
}
|
|
|
- if (StringUtil.isEmpty(vo.getLocationCode())) {
|
|
|
- message.setMsg("库位号码不能为空");
|
|
|
- return message;
|
|
|
- }
|
|
|
+// if (StringUtil.isEmpty(vo.getLocationCode())) {
|
|
|
+// message.setMsg("库位号码不能为空");
|
|
|
+// return message;
|
|
|
+// }
|
|
|
if (StringUtil.isEmpty(vo.getBarcode())) {
|
|
|
message.setMsg("商品条码不能为空");
|
|
|
return message;
|
|
@@ -170,17 +178,38 @@ public class OutInventoryAllocationServiceImpl implements OutInventoryAllocation
|
|
|
Criteria cri = criteria.createCriteria();
|
|
|
cri.andOutOrderIdEqualTo(vo.getOutOrderId());
|
|
|
cri.andBarcodeEqualTo(vo.getBarcode().trim());
|
|
|
- cri.andLocationCodeEqualTo(vo.getLocationCode().trim());
|
|
|
+// cri.andLocationCodeEqualTo(vo.getLocationCode().trim());
|
|
|
List<OutInventoryAllocation> list = outInventoryAllocationMapper.selectByConditionList(criteria);
|
|
|
if (list.size() == 0) {
|
|
|
- String msg = "该订单没有库位:" + vo.getLocationCode() + ",条码:" + vo.getBarcode() + "待下架";
|
|
|
+ String msg = "该订单没有条码:" + vo.getBarcode() + "待下架";
|
|
|
message.setMsg(msg);
|
|
|
return message;
|
|
|
}
|
|
|
- List<OutInventoryAllocation> newList = new ArrayList<OutInventoryAllocation>();
|
|
|
+
|
|
|
+ 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()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<OutInventoryAllocation> newList = new ArrayList<>();
|
|
|
for (OutInventoryAllocation temp : list) {
|
|
|
if (temp.getOutQuantity() >= temp.getQuantity()) {
|
|
|
- message.setMsg("该库位和条码已完成下架");
|
|
|
+ message.setMsg("该条码已完成下架");
|
|
|
continue;
|
|
|
}
|
|
|
newList.add(temp);
|