|
@@ -3,8 +3,10 @@ package com.imcs.admin.business.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.imcs.admin.business.constants.Status;
|
|
|
import com.imcs.admin.business.dao.MaterialDao;
|
|
|
import com.imcs.admin.business.dao.WInventoryTransactionOrdersDao;
|
|
|
import com.imcs.admin.business.dao.WInventoryTransactionOrdersDetailDao;
|
|
@@ -20,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -45,69 +48,77 @@ public class OrderServiceImpl extends BaseServiceImpl implements OrderService {
|
|
|
saveOrder(orders);
|
|
|
|
|
|
//入库任务 save
|
|
|
- saveOrderTask(orders);
|
|
|
+ int trTaskId = saveOrderTask(orders);
|
|
|
|
|
|
//获取目标库位
|
|
|
getEndPosition(orders);
|
|
|
|
|
|
+ List<WInventoryTransactionChildTask> subList=new ArrayList<>();
|
|
|
//生成 移库 子任务
|
|
|
- createSubTask(orders.getEndPosition());
|
|
|
- }
|
|
|
-
|
|
|
- private void createSubTask(String endPosition) {
|
|
|
- //判断是否需要移库
|
|
|
- if(checkStorageRelocation(endPosition)){
|
|
|
-
|
|
|
-
|
|
|
+ createSubTask(orders.getEndPosition(),subList,trTaskId);
|
|
|
|
|
|
+ //保存移库子任务
|
|
|
+ saveSubTask(subList,null);
|
|
|
+ }
|
|
|
|
|
|
+ private void saveSubTask(List<WInventoryTransactionChildTask> subList,String faCode) {
|
|
|
+ if(CollectionUtil.isNotEmpty(subList)){
|
|
|
+ subList.stream().forEach(vo->{
|
|
|
+ String code = generateSerial.generateSerialNumber("childTask");
|
|
|
+ vo.setChildTaskCode(code);
|
|
|
+ saveSubTask(vo.getSuList(),code);
|
|
|
+ childTaskDao.insert(vo);
|
|
|
+ updateStorageStatus(Status.PRE_RESERVED.getCode(),vo.getEndPosition());
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Boolean checkStorageRelocation(String endPosition) {
|
|
|
- WShelfManagement shelfManagement = storageLocationDao.getShelfManagement(endPosition);
|
|
|
- Integer inOut = shelfManagement.getInOut();
|
|
|
- //内侧不需要移库
|
|
|
- if(inOut == 1){
|
|
|
- return false;
|
|
|
- }else if(inOut == 2){
|
|
|
+ private List<WInventoryTransactionChildTask> createSubTask(String endPosition,List<WInventoryTransactionChildTask> subList,int trTaskId) {
|
|
|
+ //获取endPosition 需要移库的所有库位,获得的顺序为从内侧到外侧(先移动最外侧库位托盘)
|
|
|
+ List<WStorageLocationManagement> wStorageLocationManagements = checkStorageRelocation(endPosition);
|
|
|
+ List<WInventoryTransactionChildTask> faTask=new ArrayList<>();
|
|
|
|
|
|
- //find 同一个区域的货架
|
|
|
- LambdaQueryWrapper<WShelfManagement> wrapper = Wrappers.lambdaQuery(WShelfManagement.class)
|
|
|
- .eq(WShelfManagement::getArea,shelfManagement.getArea())
|
|
|
- .ne(WShelfManagement::getShelfCode,shelfManagement.getShelfCode());
|
|
|
- WShelfManagement wShelfManagement = shelfDao.selectOne(wrapper);
|
|
|
+ //判断是否需要移库
|
|
|
+ if(CollectionUtil.isNotEmpty(wStorageLocationManagements)){
|
|
|
+ wStorageLocationManagements.stream().forEach(vo->{
|
|
|
+ WInventoryTransactionChildTask task=new WInventoryTransactionChildTask();
|
|
|
+ task.setWInventoryTransactionTaskId(Long.valueOf(trTaskId));
|
|
|
+ //保存的时候塞入值
|
|
|
+ //task.getChildTaskCode()
|
|
|
+ task.setStartPosition(vo.getLocationCode());
|
|
|
+ //TODO
|
|
|
+ //task.setEndPosition();
|
|
|
+ task.setVectorCode(vo.getPalletCode());
|
|
|
+ task.setStatus(0);
|
|
|
+ task.setChildTaskType(3);
|
|
|
+ task.setCreatedAt(new Date());
|
|
|
+ task.setCreatedBy(getUserId());
|
|
|
|
|
|
- //定位到同一层 同高度
|
|
|
- String result = endPosition.substring(endPosition.indexOf("-") + 1);
|
|
|
+ //迭代调用
|
|
|
+ task.setSuList(createSubTask(task.getEndPosition(), subList, trTaskId));
|
|
|
+ faTask.add(task);
|
|
|
+ });
|
|
|
|
|
|
- //不确定需要 移库的库位
|
|
|
- String other=wShelfManagement.getShelfCode()+"-"+result;
|
|
|
|
|
|
- //找小库位
|
|
|
- List<String> subStorage = storageLocationDao.getSubStorage(other);
|
|
|
+ subList.addAll(faTask);
|
|
|
+ }
|
|
|
+ return faTask;
|
|
|
|
|
|
- subStorage.add(other);
|
|
|
+ }
|
|
|
|
|
|
- LambdaQueryWrapper<WInventoryManagement> inventoryWrapper = Wrappers.lambdaQuery(WInventoryManagement.class)
|
|
|
- .in(WInventoryManagement::getStorageLocationCode,subStorage);
|
|
|
|
|
|
- //如果目标库位的内侧库位存在托盘阻挡,则需要移库
|
|
|
- List<WInventoryManagement> wInventoryManagements = inventoryDao.selectList(inventoryWrapper);
|
|
|
|
|
|
- if(CollectionUtil.isNotEmpty(wInventoryManagements)){
|
|
|
+ private void getEndPosition(WInventoryTransactionOrders orders) {
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
+ //设置为预占用
|
|
|
+ updateStorageStatus(Status.PRE_RESERVED.getCode(),orders.getEndPosition());
|
|
|
}
|
|
|
|
|
|
- private void getEndPosition(WInventoryTransactionOrders orders) {
|
|
|
|
|
|
- }
|
|
|
|
|
|
- private void saveOrderTask(WInventoryTransactionOrders orders) {
|
|
|
+
|
|
|
+ private int saveOrderTask(WInventoryTransactionOrders orders) {
|
|
|
//入库任务
|
|
|
|
|
|
WInventoryTransactionTask.WInventoryTransactionTaskBuilder inTask = WInventoryTransactionTask.builder().taskCode(generateSerial.generateSerialNumber("inTask"))
|
|
@@ -117,7 +128,6 @@ public class OrderServiceImpl extends BaseServiceImpl implements OrderService {
|
|
|
.vectorCode(orders.getVectorCode())
|
|
|
.status(0)
|
|
|
.taskType(2)
|
|
|
- .startTime(new Date())
|
|
|
.createdAt(new Date())
|
|
|
.createdBy(getUserId());
|
|
|
int insert = taskDao.insert(inTask.build());
|
|
@@ -138,7 +148,7 @@ public class OrderServiceImpl extends BaseServiceImpl implements OrderService {
|
|
|
});
|
|
|
|
|
|
//判断目标库是否需要
|
|
|
-
|
|
|
+ return insert;
|
|
|
}
|
|
|
|
|
|
private void verifyMaterialCode(WInventoryTransactionOrders orders) {
|