TaskBackService.java
3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.huaheng.api.wcs.service.taskFinish;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.huaheng.api.acs.service.AgvTaskCSService;
import com.huaheng.api.wcs.domain.TaskFinishDomain;
import com.huaheng.api.wcs.service.emptyOutHandle.EmptyOutHandleService;
import com.huaheng.api.wcs.service.overrideHandle.OverrideHandleService;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import java.math.BigDecimal;
import java.util.List;
@Service
public class TaskBackService {
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private InventoryDetailService inventoryDetailService;
@Transactional(rollbackFor = Exception.class)
public AjaxResult back(String taskNo) {
TaskHeader taskHeader = taskHeaderService.getById(taskNo);
if (taskHeader == null) {
return AjaxResult.error("没有找到任务,不允许回库, 任务号:" + taskNo);
}
// 返回1 表示回库
// 返回2 表示去叠盘
int flag = 1;
int taskType = taskHeader.getTaskType();
if (taskType != QuantityConstant.TASK_TYPE_SORTINGSHIPMENT) {
return AjaxResult.error("任务号" + taskNo + "不是分拣任务");
}
String containerCode = taskHeader.getContainerCode();
if (StringUtils.isEmpty(containerCode)) {
return AjaxResult.error("任务号" + taskNo + "没有托盘号");
}
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = new LambdaQueryWrapper<>();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getContainerCode, containerCode).eq(InventoryDetail::getWarehouseCode, taskHeader.getWarehouseCode());
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
for (InventoryDetail inventoryDetail : inventoryDetailList){
BigDecimal qty=inventoryDetail.getQty();
BigDecimal taskqty=inventoryDetail.getTaskQty();
if(qty.compareTo(taskqty)>0){
flag = 2;
return AjaxResult.success("任务ID:" + taskHeader.getId() + " 允许去叠盘", flag);
}
}
flag = 1; // 返回1 表示回库
return AjaxResult.success("任务ID:" + taskHeader.getId() + " 允许回库", flag);
}
}