VerifyController.java
10.3 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package com.huaheng.tool.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.core.exception.BaseException;
import com.huaheng.common.core.web.domain.AjaxResult;
import com.huaheng.config.api.RemoteLocationService;
import com.huaheng.config.api.domain.Location;
import com.huaheng.task.api.RemoteTaskService;
import com.huaheng.task.api.domain.TaskHeader;
import com.huaheng.tool.domain.LocationVerify;
import com.huaheng.tool.domain.TaskVerify;
import com.huaheng.tool.domain.ContrastLocation;
import com.huaheng.tool.domain.ContrastTask;
import com.huaheng.tool.service.WcslocationService;
import com.huaheng.tool.service.WcstaskService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/verify")
public class VerifyController {
@Resource
private WcslocationService wcslocationService;
@Resource
private WcstaskService wcstaskService;
@Resource
private RemoteLocationService locationService;
@Resource
private RemoteTaskService taskService;
@GetMapping("/locationStatusList")
public AjaxResult locationStatusList() {
LambdaQueryWrapper<ContrastLocation> wcsWrapper = Wrappers.lambdaQuery();
wcsWrapper.eq(ContrastLocation::getStatus, "lock");
AjaxResult result = locationService.getAllLocation();
List<Location> locations = locationService.remoteList("status");
if (locations==null){
throw new BaseException("调用库位服务失败");
}
if (locations.size()==0){
return AjaxResult.success("本地锁定状态库位为空");
}
List<ContrastLocation> contrastLocations = wcslocationService.list(wcsWrapper);
if (contrastLocations.size()==0){
return AjaxResult.success("对照数据库锁定状态库位为空");
}
ArrayList<LocationVerify> verifyLocations = new ArrayList<>();
ArrayList<Location> removeWmsLocation = new ArrayList<>();
ArrayList<ContrastLocation> removeWcsLocation = new ArrayList<>();
for (Location location : locations) {
for (ContrastLocation contrastLocation : contrastLocations) {
if (location.getCode().equals(contrastLocation.getCode())) {
removeWmsLocation.add(location);
removeWcsLocation.add(contrastLocation);
}
}
}
if (removeWcsLocation.size() == contrastLocations.size() && removeWmsLocation.size() == locations.size()) {
return AjaxResult.success("校验通过,数据匹配");
} else {
locations.removeAll(removeWmsLocation);
contrastLocations.removeAll(removeWcsLocation);
if (locations.size() != 0) {
for (Location location : locations) {
LocationVerify locationVerify = new LocationVerify();
locationVerify.setLocalContain(location.getContainerCode());
locationVerify.setLocalLocation(location.getCode());
locationVerify.setLocalLocationStatus(location.getStatus());
locationVerify.setContrastLocationStatus("empty");
verifyLocations.add(locationVerify);
}
if (contrastLocations.size() != 0) {
for (ContrastLocation contrastLocation : contrastLocations) {
LocationVerify locationVerify = new LocationVerify();
locationVerify.setLocalContain(contrastLocation.getContainerCode());
locationVerify.setLocalLocation(contrastLocation.getCode());
locationVerify.setLocalLocationStatus("empty");
locationVerify.setContrastLocationStatus("lock");
verifyLocations.add(locationVerify);
}
}
}
return AjaxResult.success("校验不通过,有"+verifyLocations.size()+"条数据不符",verifyLocations);
}
}
@GetMapping("locationWithContainerList")
public AjaxResult locationWithContainerList() {
LambdaQueryWrapper<ContrastLocation> wcsWrapper = Wrappers.lambdaQuery();
wcsWrapper.isNotNull(ContrastLocation::getContainerCode);
List<Location> locations = locationService.remoteList("container");
if (locations.size()==0){
return AjaxResult.success("本地库位为空");
}
List<ContrastLocation> contrastLocations = wcslocationService.list(wcsWrapper);
if (contrastLocations.size()==0){
return AjaxResult.success("对照数据库库位为空");
}
ArrayList<LocationVerify> verifyLocations = new ArrayList<>();
ArrayList<Location> removeWmsLocation = new ArrayList<>();
ArrayList<ContrastLocation> removeWcsLocation = new ArrayList<>();
for (Location location : locations) {
for (ContrastLocation contrastLocation : contrastLocations) {
if (location.getCode().equals(contrastLocation.getCode())) {
if (!location.getContainerCode().equals(contrastLocation.getContainerCode())) {
LocationVerify locationVerify = new LocationVerify();
locationVerify.setLocalLocation(location.getCode());
locationVerify.setContrastLocation(contrastLocation.getCode());
locationVerify.setLocalContain(location.getContainerCode());
locationVerify.setContrastLocation(location.getContainerCode());
verifyLocations.add(locationVerify);
}
removeWmsLocation.add(location);
removeWcsLocation.add(contrastLocation);
}
}
}
if (removeWcsLocation.size() == contrastLocations.size() && removeWmsLocation.size() == locations.size() &&
verifyLocations.size() == 0) {
return AjaxResult.success("校验通过,数据匹配");
} else {
locations.removeAll(removeWmsLocation);
contrastLocations.removeAll(removeWcsLocation);
if (locations.size() != 0) {
for (Location location : locations) {
LocationVerify locationVerify = new LocationVerify();
locationVerify.setLocalContain(location.getContainerCode());
locationVerify.setLocalLocation(location.getCode());
locationVerify.setContrastLocation(location.getCode());
locationVerify.setContrastContain("");
verifyLocations.add(locationVerify);
}
if (contrastLocations.size() != 0) {
for (ContrastLocation contrastLocation : contrastLocations) {
LocationVerify locationVerify = new LocationVerify();
locationVerify.setLocalContain("");
locationVerify.setLocalLocation(contrastLocation.getCode());
locationVerify.setContrastContain(contrastLocation.getContainerCode());
locationVerify.setContrastLocation(contrastLocation.getCode());
verifyLocations.add(locationVerify);
}
}
}
return AjaxResult.success("校验不通过,有"+verifyLocations.size()+"条数据不符",verifyLocations);
}
}
@GetMapping("/taskStatuslist")
public AjaxResult taskStatuslist(){
LambdaQueryWrapper<TaskHeader> localTaskWrapper = Wrappers.lambdaQuery();
LambdaQueryWrapper<ContrastTask> wcsTaskWrapper = Wrappers.lambdaQuery();
localTaskWrapper.gt(TaskHeader::getStatus,10)
.lt(TaskHeader::getStatus,100);
wcsTaskWrapper.lt(ContrastTask::getTaskStatus,100);
List<TaskHeader> taskHeaders = taskService.remoteList(localTaskWrapper);
List<ContrastTask> contrastTasks = wcstaskService.list(wcsTaskWrapper);
ArrayList<TaskVerify> verifyTasks = new ArrayList<>();
ArrayList<TaskHeader> removeWmsTask = new ArrayList<>();
ArrayList<ContrastTask> removeWcsTask = new ArrayList<>();
for (TaskHeader taskHeader : taskHeaders) {
for (ContrastTask contrastTask : contrastTasks) {
if (taskHeader.getId().equals(Integer.valueOf(contrastTask.getRemoteTaskNo()))) {
removeWmsTask.add(taskHeader);
removeWcsTask.add(contrastTask);
}
}
}
if (removeWcsTask.size() == contrastTasks.size() && removeWmsTask.size() == taskHeaders.size()) {
return AjaxResult.success("校验通过,数据匹配");
} else {
taskHeaders.removeAll(removeWmsTask);
contrastTasks.removeAll(removeWcsTask);
if (taskHeaders.size() != 0) {
for (TaskHeader taskHeader : taskHeaders) {
TaskVerify taskVerify = new TaskVerify();
taskVerify.setLocalId(taskHeader.getId());
taskVerify.setLocalContainerCode(taskHeader.getContainerCode());
taskVerify.setLocalTaskStatus(taskHeader.getStatus());
taskVerify.setContrastTaskStatus(100);
verifyTasks.add(taskVerify);
}
if (contrastTasks.size() != 0) {
for (ContrastTask contrastTask : contrastTasks) {
TaskVerify taskVerify = new TaskVerify();
taskVerify.setLocalId(Integer.valueOf(contrastTask.getRemoteTaskNo()));
taskVerify.setLocalContainerCode(contrastTask.getContainerCode());
taskVerify.setLocalTaskStatus(100);
taskVerify.setContrastTaskStatus((int) contrastTask.getTaskStatus());
verifyTasks.add(taskVerify);
}
}
}
return AjaxResult.success("校验不通过,有"+verifyTasks.size()+"条数据不符",verifyTasks);
}
}
}