Commit 165752f9f321d7b49874da3244a825db8eabb7a4
1 parent
7bcdd223
重入和空出处理
Showing
2 changed files
with
140 additions
and
7 deletions
src/main/java/com/huaheng/api/wcs/service/emptyOutHandle/EmptyOutHandleServiceImpl.java
... | ... | @@ -3,19 +3,29 @@ package com.huaheng.api.wcs.service.emptyOutHandle; |
3 | 3 | import com.huaheng.api.wcs.domain.WcsTask; |
4 | 4 | import com.huaheng.common.utils.StringUtils; |
5 | 5 | import com.huaheng.framework.web.domain.AjaxResult; |
6 | +import com.huaheng.pc.task.taskHeader.domain.TaskHeader; | |
7 | +import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | 9 | import org.springframework.stereotype.Service; |
10 | +import org.springframework.transaction.annotation.Transactional; | |
7 | 11 | |
8 | 12 | @Service |
9 | 13 | public class EmptyOutHandleServiceImpl implements EmptyOutHandleService { |
10 | 14 | |
15 | + | |
16 | + @Autowired | |
17 | + private TaskHeaderService taskHeaderService; | |
18 | + | |
11 | 19 | /** |
12 | 20 | * 空出处理 |
13 | 21 | * 1、判断非空字段 |
14 | - * 2、 | |
22 | + * 2、根据任务号查找任务 | |
23 | + * 3、修改该任务为空出,过后处理 | |
15 | 24 | * @param wcsTask |
16 | 25 | * @return |
17 | 26 | */ |
18 | 27 | @Override |
28 | + @Transactional | |
19 | 29 | public AjaxResult EmptyOutHandle(WcsTask wcsTask) { |
20 | 30 | |
21 | 31 | //1、判断非空字段 |
... | ... | @@ -23,7 +33,18 @@ public class EmptyOutHandleServiceImpl implements EmptyOutHandleService { |
23 | 33 | return AjaxResult.error("任务号为空"); |
24 | 34 | } |
25 | 35 | |
36 | + //2、根据任务号查找任务 | |
37 | + TaskHeader taskHeader = taskHeaderService.getById(Integer.valueOf(wcsTask.getTaskNo())); | |
38 | + if(taskHeader == null){ | |
39 | + return AjaxResult.error("任务号错误,没有找到该任务"); | |
40 | + } | |
26 | 41 | |
27 | - return null; | |
42 | + //3、修改该任务为空出,过后处理 | |
43 | + taskHeader.setUserDef1("空托出库"); | |
44 | + Boolean flag = taskHeaderService.updateById(taskHeader); | |
45 | + if(flag == false){ | |
46 | + return AjaxResult.error("修改任务失败,空出处理失败"); | |
47 | + } | |
48 | + return AjaxResult.success("空出处理成功"); | |
28 | 49 | } |
29 | 50 | } |
... | ... |
src/main/java/com/huaheng/api/wcs/service/overrideHandle/OverrideHandleServiceImpl.java
1 | 1 | package com.huaheng.api.wcs.service.overrideHandle; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | 5 | import com.huaheng.api.wcs.domain.WcsTask; |
4 | 6 | import com.huaheng.common.exception.service.ServiceException; |
5 | 7 | import com.huaheng.common.utils.StringUtils; |
8 | +import com.huaheng.common.utils.security.ShiroUtils; | |
6 | 9 | import com.huaheng.framework.web.domain.AjaxResult; |
10 | +import com.huaheng.pc.config.location.domain.Location; | |
11 | +import com.huaheng.pc.config.location.service.LocationService; | |
12 | +import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail; | |
13 | +import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService; | |
14 | +import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader; | |
15 | +import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService; | |
16 | +import com.huaheng.pc.task.taskDetail.domain.TaskDetail; | |
17 | +import com.huaheng.pc.task.taskDetail.service.TaskDetailService; | |
7 | 18 | import com.huaheng.pc.task.taskHeader.domain.TaskHeader; |
19 | +import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; | |
20 | +import org.springframework.beans.factory.annotation.Autowired; | |
8 | 21 | import org.springframework.stereotype.Service; |
22 | +import org.springframework.transaction.annotation.Transactional; | |
23 | + | |
24 | +import java.util.ArrayList; | |
25 | +import java.util.List; | |
9 | 26 | |
10 | 27 | @Service |
11 | 28 | public class OverrideHandleServiceImpl implements OverrideHandleService { |
12 | 29 | |
30 | + | |
31 | + @Autowired | |
32 | + private TaskHeaderService taskHeaderService; | |
33 | + @Autowired | |
34 | + private TaskDetailService taskDetailService; | |
35 | + @Autowired | |
36 | + private LocationService locationService; | |
37 | + @Autowired | |
38 | + private ReceiptContainerHeaderService receiptContainerHeaderService; | |
39 | + @Autowired | |
40 | + private ReceiptContainerDetailService receiptContainerDetailService; | |
41 | + | |
13 | 42 | /** |
14 | 43 | * 重入处理 |
15 | 44 | * 1、判断非空字段 |
16 | - * 2、实体转换 | |
17 | - * | |
45 | + * 2、根据任务号查找任务 | |
46 | + * 3、修改任务目的库位,修改入库组盘的库位,修改库位状态 | |
18 | 47 | */ |
19 | 48 | |
20 | 49 | @Override |
50 | + @Transactional | |
21 | 51 | public AjaxResult OverrideHandle(WcsTask wcsTask) { |
52 | + Boolean flag = true; | |
53 | + | |
22 | 54 | //1、判断非空字段 |
23 | 55 | if(StringUtils.isEmpty(wcsTask.getTaskNo())){ |
24 | 56 | return AjaxResult.error("任务号为空"); |
... | ... | @@ -27,9 +59,89 @@ public class OverrideHandleServiceImpl implements OverrideHandleService { |
27 | 59 | return AjaxResult.error("目的库位为空"); |
28 | 60 | } |
29 | 61 | |
30 | - TaskHeader taskHeader =new TaskHeader(); | |
31 | - taskHeader.setId(Integer.valueOf(wcsTask.getTaskNo())); | |
62 | + //2、根据任务号查找任务 | |
63 | + TaskHeader taskHeader = taskHeaderService.getById(Integer.valueOf(wcsTask.getTaskNo())); | |
64 | + if(taskHeader == null){ | |
65 | + return AjaxResult.error("任务号错误,没有找到该任务"); | |
66 | + } | |
67 | + | |
68 | + //3、修改任务目的库位,修改入库组盘的库位,修改库位状态 | |
69 | + //修改原来目的库位的状态 | |
70 | + LambdaQueryWrapper<Location> locationLam = Wrappers.lambdaQuery(); | |
71 | + locationLam.eq(Location::getCode,taskHeader.getToLocation()) | |
72 | + .eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
73 | + Location location = locationService.getOne(locationLam); | |
74 | + if(location == null){ | |
75 | + return AjaxResult.error("此任务的原目的库位在系统中不存在"); | |
76 | + } | |
77 | + location.setStatus("empty"); | |
78 | + flag = locationService.updateById(location); | |
79 | + if(flag == false){ | |
80 | + return AjaxResult.error("修改此任务的原目的库位错误"); | |
81 | + } | |
82 | + | |
83 | + //查看新库位 | |
84 | + locationLam.eq(Location::getCode,wcsTask.getToLocationCode()) | |
85 | + .eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
86 | + Location newlocation = locationService.getOne(locationLam); | |
87 | + if(newlocation == null){ | |
88 | + throw new ServiceException("新目的库位在系统中不存在"); | |
89 | + } | |
90 | + //修改任务 | |
32 | 91 | taskHeader.setToLocation(wcsTask.getToLocationCode()); |
33 | - return null; | |
92 | + taskHeader.setUserDef1("重入处理"); | |
93 | + flag = taskHeaderService.updateById(taskHeader); | |
94 | + if(flag == false){ | |
95 | + throw new ServiceException("修改此任务错误"); | |
96 | + } | |
97 | + | |
98 | + //修改子任务 | |
99 | + LambdaQueryWrapper<TaskDetail> taskDetailLam = Wrappers.lambdaQuery(); | |
100 | + taskDetailLam.eq(TaskDetail::getWarehouseCode,ShiroUtils.getWarehouseCode()) | |
101 | + .eq(TaskDetail::getTaskId,taskHeader.getId()); | |
102 | + List<TaskDetail> taskDetails = taskDetailService.list(taskDetailLam); | |
103 | + List<TaskDetail> taskDetailList = new ArrayList<>(); | |
104 | + if(taskDetails != null && taskDetails.size()> 0){ | |
105 | + for(TaskDetail taskDetail : taskDetails){ | |
106 | + taskDetail.setToLocation(wcsTask.getToLocationCode()); | |
107 | + taskDetailList.add(taskDetail); | |
108 | + } | |
109 | + flag = taskDetailService.updateBatchById(taskDetailList); | |
110 | + if(flag == false){ | |
111 | + throw new ServiceException("修改此任务的明细错误"); | |
112 | + } | |
113 | + } | |
114 | + | |
115 | + //修改入库组盘 | |
116 | + if(taskHeader.getAllocationHeadId() == null){ | |
117 | + throw new ServiceException("找不到此任务的组盘头id"); | |
118 | + } | |
119 | + ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(taskHeader.getAllocationHeadId()); | |
120 | + if(receiptContainerHeader == null){ | |
121 | + throw new ServiceException("找不到此任务的组盘头"); | |
122 | + } | |
123 | + receiptContainerHeader.setToLocation(wcsTask.getToLocationCode()); | |
124 | + flag = receiptContainerHeaderService.updateById(receiptContainerHeader); | |
125 | + if(flag == false){ | |
126 | + throw new ServiceException("修改此任务对应的组盘头错误"); | |
127 | + } | |
128 | + | |
129 | + //修改入库组盘明细 | |
130 | + LambdaQueryWrapper<ReceiptContainerDetail> lam = Wrappers.lambdaQuery(); | |
131 | + lam.eq(ReceiptContainerDetail::getReceiptContainerId,receiptContainerHeader.getId()) | |
132 | + .eq(ReceiptContainerDetail::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
133 | + List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(lam); | |
134 | + List<ReceiptContainerDetail> receiptContainerDetailList = new ArrayList<>(); | |
135 | + if(receiptContainerDetails != null && receiptContainerDetails.size()> 0){ | |
136 | + for(ReceiptContainerDetail receiptContainerDetail : receiptContainerDetails){ | |
137 | + receiptContainerDetail.setLocationCode(wcsTask.getToLocationCode()); | |
138 | + receiptContainerDetailList.add(receiptContainerDetail); | |
139 | + } | |
140 | + flag = receiptContainerDetailService.updateBatchById(receiptContainerDetailList); | |
141 | + if(flag == false){ | |
142 | + throw new ServiceException("修改此任务的组盘明细错误"); | |
143 | + } | |
144 | + } | |
145 | + return AjaxResult.success("重入处理成功"); | |
34 | 146 | } |
35 | 147 | } |
... | ... |