IAgvTaskServiceImpl.java
23.5 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
package com.huaheng.pc.task.agvTask.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.http.HttpUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.service.ConfigService;
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.pointPosition.domain.PointPosition;
import com.huaheng.pc.config.pointPosition.service.IPointPositionService;
import com.huaheng.pc.task.agvTask.domain.AgvSendParam;
import com.huaheng.pc.task.agvTask.domain.AgvTask;
import com.huaheng.pc.task.agvTask.domain.Shelf;
import com.huaheng.pc.task.agvTask.mapper.AgvTaskMapper;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/*
* AGVTask任务服务层
* */
@Service
public class IAgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> implements IAgvTaskService {
@Resource
private IPointPositionService pointPositionService;
@Resource
private ContainerService containerService;
@Resource
private ShelfService shelfService;
@Resource
private ConfigService configService;
@Resource
private AddressService addressService;
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private TaskDetailService taskDetailService;
@Override
public AgvTask getByTaskNo(String taskNo) {
return this.getOne(new LambdaQueryWrapper<AgvTask>()
.eq(AgvTask::getTaskNo,taskNo)
.last("LIMIT 1"));
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult createAGVTask(AgvTask agvTask) {
if(StringUtils.isNull(agvTask)){
return AjaxResult.error("agvTask 实体不能为空");
}
//校验请求参数,判断目标点位是否存在任务和是否锁定
AjaxResult ajaxResult = checkAgvTaskPosition(agvTask);
if(ajaxResult.hasErr()){
return ajaxResult;
}
//校验货架是否存在任务及是否锁定,校验起始点位是否锁定
Shelf shelf = checkContainerAndPositionStatus(agvTask);
agvTask.setFromPort(shelf.getPositionName());
agvTask.setStatus(QuantityConstant.TASK_STATUS_BUILD);
agvTask.setWarehouseCode(ShiroUtils.getWarehouseCode());
agvTask.setCompanyCode(ShiroUtils.getCompanyCode());
agvTask.setCreatedBy(ShiroUtils.getLoginName());
agvTask.setTaskType(QuantityConstant.STATUS_TASK_SHELF);
agvTask.setCreatedTime(new Date());
agvTask.setUpdated(new Date());
agvTask.setShelfNo(shelf.getShelfNo());
agvTask.setUpdatedBy(ShiroUtils.getLoginName());
agvTask.setTaskNo(UUID.randomUUID().toString());
shelf.setStatus(QuantityConstant.STATUS_CONTAINER_LOCK);
if (this.save(agvTask)) {
pointPositionService.updateStatus(agvTask.getFromPort(), QuantityConstant.STATUS_CONTAINER_LOCK, agvTask.getWarehouseCode());
pointPositionService.updateStatus(agvTask.getToPort(), QuantityConstant.STATUS_CONTAINER_LOCK, agvTask.getWarehouseCode());
shelfService.updateById(shelf);
} else {
return AjaxResult.error("AGV创建任务失败");
}
return AjaxResult.success("执行生成任务成功", agvTask);
}
@Override
public AjaxResult executeAGVTask(String[] ids) {
if(StringUtils.isEmpty(ids)){
return AjaxResult.error("ids为空");
}
List<Integer> newIds = new ArrayList<>();
for (String id : ids) {
AjaxResult ajaxResult = executeAGVTask(id);
if(!ajaxResult.hasErr()){
newIds.add(Integer.valueOf(ajaxResult.getData().toString()));
}
}
return AjaxResult.success("成功下发【"+newIds.size()+"】条任务。").setData(newIds);
}
@Transactional(rollbackFor = Exception.class)
@Override
public AjaxResult executeAGVTask(String id) {
AgvTask agvTask = this.getById(id);
if(agvTask.getStatus() >= QuantityConstant.TASK_STATUS_RELEASE){
return AjaxResult.error("任务" + id + "已经下发,请不要重复下发,操作中止");
}
if(StringUtils.isEmpty(agvTask.getToPort())){
return AjaxResult.error("任务【" + id + " 】没有目标点位,不允许下发");
}
AgvTask one = this.getOne(new LambdaQueryWrapper<AgvTask>()
.eq(AgvTask::getStatus, QuantityConstant.TASK_STATUS_RUNNING)
.eq(AgvTask::getToPort, agvTask.getToPort())
.last("LIMIT 1"));
if (StringUtils.isNotNull(one)) {
return AjaxResult.error("目标点位存在任务,请更换目标点位");
}
//获取url
String url = addressService.selectAddress(QuantityConstant.AGV_CREATED_TASK,QuantityConstant.WAREHOUSE_CS);
if(StringUtils.isEmpty(url)){
return AjaxResult.error("AGV_CREATED_TASK地址为配置");
}
String key = configService.getKey(QuantityConstant.RULE_CONNECT_AGV,agvTask.getWarehouseCode());
Integer value = Integer.valueOf(key);
if(value == QuantityConstant.RULE_AGV_CONNECT){
int orientation ="A".equals(agvTask.getOrientation()) ? 1 : 2;
String param = new AgvSendParam()
.setFromPort(agvTask.getFromPort())
.setToPort(agvTask.getToPort())
.setTaskNo(agvTask.getTaskNo())
.setTaskType(agvTask.getTaskType())
.setOrientation(orientation).toJSON();
AjaxResult ajaxResult = callAGV(param, url);
if(ajaxResult.hasErr()){
return ajaxResult;
}
}
agvTask.setStatus(QuantityConstant.TASK_STATUS_RELEASE);
agvTask.setUpdatedBy(ShiroUtils.getLoginName());
agvTask.setUpdated(DateUtils.getNowDate());
this.updateById(agvTask);
return AjaxResult.success().setData(id);
}
@Transactional(rollbackFor = Exception.class)
@Override
public AjaxResult cancelAGVTasks(String[] ids) {
for (String id : ids) {
AjaxResult ajaxResult = cancelAGVTask(id);
if(ajaxResult.hasErr()){
return ajaxResult;
}
}
return AjaxResult.success();
}
@Transactional(rollbackFor = Exception.class)
@Override
public AjaxResult cancelAGVTask(String id) {
if(StringUtils.isNull(id)){
return AjaxResult.error("任务号【"+id+"】不能为空");
}
AgvTask agvTask = this.getById(id);
if(StringUtils.isNull(agvTask)){
return AjaxResult.error("任务" + id + "未找到,操作中止");
}
if (agvTask.getStatus() > QuantityConstant.TASK_STATUS_RELEASE) {
return AjaxResult.error("存在任务" + agvTask.getId() + "已下发或执行,操作中止");
}
//获取url
String url = addressService.selectAddress(QuantityConstant.AGV_CANCEL_TASK, agvTask.getWarehouseCode());
if(StringUtils.isEmpty(url)){
return AjaxResult.error("AGV_CANCEL_TASK地址为配置");
}
String key = configService.getKey(QuantityConstant.RULE_CONNECT_AGV,agvTask.getWarehouseCode());
Integer value = Integer.valueOf(key);
if(value == QuantityConstant.RULE_AGV_CONNECT){
//取消AGV任务
AjaxResult ajaxResult = callAGV(id, url);
if(ajaxResult.hasErr()){
return ajaxResult;
}
}
int preTaskNo = Integer.valueOf(id);
AgvTask agvTask1=new AgvTask();
agvTask1.setPreTaskNo(String.valueOf(preTaskNo));
AgvTask agvTask2 = this.getOne(new LambdaQueryWrapper<AgvTask>()
.eq(AgvTask::getPreTaskNo,preTaskNo)
.last("LIMIT 1"));
if (agvTask2 != null) {
return AjaxResult.error("取消任务失败, 有前置任务" + agvTask.getId());
}
//删除任务
this.removeById(id);
//更新点位信息
cancelPositionStatus(agvTask);
//更新货架信息
cancelShelfStatus(agvTask);
return AjaxResult.success("取消成功",id);
}
@Override
public AjaxResult updateAGVTask(String taskNo,int priority) {
if(StringUtils.isEmpty(taskNo)) {
throw new ServiceException("任务号为空");
}
AgvTask agvTask = this.getByTaskNo(taskNo);
agvTask.setPriority(priority);
agvTask.setUpdated(new Date());
agvTask.setUpdatedBy(ShiroUtils.getLoginName());
if(this.updateById(agvTask)) {
AjaxResult.error("更新优先级失败");
}
return AjaxResult.success();
}
@Override
public AjaxResult notifyAGVTask(String taskNo, String carNo, Integer status, String updateBy) {
if(StringUtils.isNull(taskNo)) {
return AjaxResult.error("任务号为空");
}
if(StringUtils.isNull(carNo)) {
return AjaxResult.error("小车编号为空");
}
if(StringUtils.isNull(status)) {
return AjaxResult.error("任务状态为空");
}
if(StringUtils.isNull(updateBy)) {
return AjaxResult.error("更新人不能为空");
}
AgvTask agvTask = this.getByTaskNo(taskNo);
agvTask.setCarNo(carNo);
AjaxResult ajaxResult = agvTaskStatusNowStart(status.toString(), agvTask);
return ajaxResult;
}
@Override
public AjaxResult notifyAGVPort(String taskNo, String carNo, String oldPort, String newPort, String createdBy) {
if(StringUtils.isNull(taskNo)) {
return AjaxResult.error("任务号为空");
}
if(StringUtils.isNull(carNo)) {
return AjaxResult.error("小车编号为空");
}
if(StringUtils.isNull(oldPort)) {
return AjaxResult.error("起点为空");
}
if(StringUtils.isNull(newPort)) {
return AjaxResult.error("终点为空");
}
AgvTask agvTask = this.getById(taskNo);
if(StringUtils.isNull(agvTask)){
return AjaxResult.error("没有找到任务为:【"+taskNo+"】的任务");
}
AjaxResult ajaxResult = checkPointPositionExist(oldPort, newPort);
if(ajaxResult.hasErr()){
return ajaxResult;
}
agvTask.setCarNo(carNo);
agvTask.setFromPort(oldPort);
agvTask.setToPort(newPort);
if(this.updateById(agvTask)){
return AjaxResult.error("更新失败");
}
return AjaxResult.success();
}
@Transactional(rollbackFor = Exception.class)
@Override
public AjaxResult completeAGVTask(String[] ids) {
List<String> newIds = new ArrayList<>();
if(StringUtils.isNull(ids)){
return AjaxResult.error("任务号【"+ids+"】不能为空");
}
for (String id : ids) {
AjaxResult ajaxResult = completeAGVTask(id);
if(!ajaxResult.hasErr()){
newIds.add(id);
}
}
return AjaxResult.success("完成AGV【"+newIds.size()+"】条任务。").setData(newIds);
}
@Transactional(rollbackFor = Exception.class)
@Override
public AjaxResult completeAGVTask(String id) {
if(StringUtils.isNull(id)){
return AjaxResult.error("任务号【"+id+"】不能为空");
}
AgvTask agvTask = this.getById(id);
if(StringUtils.isNull(agvTask)){
return AjaxResult.error("任务" + id + "未找到,操作中止");
}
String value = configService.getKey(QuantityConstant.RULE_CONNECT_AGV,agvTask.getWarehouseCode());
int connectAGV = Integer.parseInt(value);
if(connectAGV == QuantityConstant.RULE_AGV_CONNECT){
return AjaxResult.error("AGV任务不可手动完成");
}
//更新点位和托盘信息
if(StringUtils.isNotEmpty(agvTask.getFromPort())){
PointPosition sourcePosition = pointPositionService.getPositionByPositionName(agvTask.getFromPort(), agvTask.getWarehouseCode());
if(StringUtils.isNull(sourcePosition)){
return AjaxResult.error("源点位未找到");
}
pointPositionService.updateStatus(agvTask.getFromPort(), QuantityConstant.STATUS_CONTAINER_EMPTY,agvTask.getWarehouseCode());
pointPositionService.setContainerCode(agvTask.getFromPort(),null,agvTask.getWarehouseCode());
}
if(StringUtils.isNotEmpty(agvTask.getToPort())){
PointPosition desPosition = pointPositionService.getPositionByPositionName(agvTask.getToPort(), agvTask.getWarehouseCode());
if(StringUtils.isNull(desPosition)){
return AjaxResult.error("目标点位未找到");
}
pointPositionService.updateStatus(agvTask.getToPort(), QuantityConstant.STATUS_CONTAINER_SOME,agvTask.getWarehouseCode());
pointPositionService.setContainerCode(agvTask.getToPort(),agvTask.getContainerCode(),agvTask.getWarehouseCode());
containerService.updateLocationCodeAndStatus(agvTask.getContainerCode(),agvTask.getToPort(), QuantityConstant.STATUS_CONTAINER_EMPTY);
}
//更新agv任务状态
agvTask.setStatus(QuantityConstant.TASK_STATUS_COMPLETED);
agvTask.setUpdated(new Date());
agvTask.setUpdatedBy(ShiroUtils.getLoginName());
if(!this.updateById(agvTask)) {
throw new ServiceException("完成任务失败");
}
return AjaxResult.success();
}
//根据任务类型检验参数
@SuppressWarnings({"AlibabaRemoveCommentedCode", "AlibabaCommentsMustBeJavadocFormat"})
private AjaxResult checkAgvTaskPosition(AgvTask agvTask){
//校验托盘
if (StringUtils.isNull(agvTask)) {
return AjaxResult.error("任务数据为空,请重新下发");
}
if (StringUtils.isEmpty(agvTask.getContainerCode())) {
return AjaxResult.error("托盘为空");
}
//校验目标点位
if (StringUtils.isEmpty(agvTask.getToPort())) {
return AjaxResult.error("目标点位为空");
}
PointPosition desPosition = pointPositionService.getPositionByPositionName(agvTask.getToPort(), agvTask.getWarehouseCode());
if (StringUtils.isNull(desPosition)) {
return AjaxResult.error("目标点位:" + agvTask.getToPort() + "未找到");
}
List<AgvTask> agvTasks = this.list(new LambdaQueryWrapper<AgvTask>()
.eq(AgvTask::getStatus,110)
.eq(AgvTask::getToPort,desPosition.getPositionName()));
if(CollectionUtils.isNotEmpty(agvTasks)){
return AjaxResult.error("目标点位:" + agvTask.getToPort() + "存在任务");
}
if(desPosition.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)){
return AjaxResult.error("目标点位:" + agvTask.getToPort() + "禁用");
}
if(StringUtils.isNotEmpty(desPosition.getShelfNo())){
return AjaxResult.error("目标点位:" + agvTask.getToPort() + "存在货架:"+desPosition.getShelfNo());
}
return AjaxResult.success();
}
/**
* 检查托盘和点位是否存在未完成的任务
* @param agvTask
*/
private Shelf checkContainerAndPositionStatus(AgvTask agvTask){
Container containerStatus = containerService.getContainerByCode(agvTask.getContainerCode(),QuantityConstant.WAREHOUSE_CS);
if(StringUtils.isNull(containerStatus)){
throw new ServiceException("托盘"+agvTask.getContainerCode()+"不存在");
}
//拿到货架编号
String shelfNo = containerStatus.getGoodsShelfNo();
List<AgvTask> list = this.list(new LambdaQueryWrapper<AgvTask>()
.eq(AgvTask::getStatus, 110)
.eq(AgvTask::getShelfNo, shelfNo));
//判断此货架是否有任务存在
if (CollectionUtils.isNotEmpty(list)) {
throw new ServiceException("货架"+shelfNo+"存在未完成的任务");
}
//判断货架是否锁定
Shelf shelfOne = shelfService.getOne(new LambdaQueryWrapper<Shelf>()
.eq(Shelf::getShelfNo, shelfNo)
.last("LIMIT 1"));
if(StringUtils.isNotNull(shelfOne) && "lock".equals(shelfOne.getStatus())){
throw new ServiceException("货架"+shelfNo+"已锁定");
}
//判断起始点位是否锁定
PointPosition one = pointPositionService.getOne(new LambdaQueryWrapper<PointPosition>()
.eq(PointPosition::getStatus, QuantityConstant.STATUS_CONTAINER_LOCK)
.eq(PointPosition::getPositionName, shelfOne.getPositionName())
.last("LIMIT 1"));
if(StringUtils.isNotNull(one)){
throw new ServiceException("起始点位"+shelfNo+"已锁定");
}
return shelfOne;
}
//更新点位状态
@SuppressWarnings("AlibabaCommentsMustBeJavadocFormat")
private void cancelPositionStatus(AgvTask agvTask) {
if (agvTask.getFromPort() != null) {
//更新点位状态
PointPosition pointPosition= pointPositionService.getPositionByPositionName(agvTask.getFromPort(),agvTask.getWarehouseCode());
if(pointPosition!=null&& StringUtils.isNotEmpty(pointPosition.getShelfNo())){
pointPositionService.updateStatus(agvTask.getFromPort(), QuantityConstant.STATUS_CONTAINER_SOME,agvTask.getWarehouseCode());
} else {
pointPositionService.updateStatus(agvTask.getFromPort(), QuantityConstant.STATUS_CONTAINER_EMPTY,agvTask.getWarehouseCode());
}
}
if (agvTask.getToPort() != null) {
//更新点位状态
PointPosition pointPosition=pointPositionService.getPositionByPositionName(agvTask.getToPort(),agvTask.getWarehouseCode());
if(pointPosition!=null&& StringUtils.isNotEmpty(pointPosition.getShelfNo())){
pointPositionService.updateStatus(agvTask.getToPort(), QuantityConstant.STATUS_CONTAINER_SOME,agvTask.getWarehouseCode());
} else {
pointPositionService.updateStatus(agvTask.getToPort(), QuantityConstant.STATUS_CONTAINER_EMPTY,agvTask.getWarehouseCode());
}
}
}
//更新货架状态
@SuppressWarnings("AlibabaCommentsMustBeJavadocFormat")
private void cancelShelfStatus(AgvTask agvTask){
Shelf shelf = shelfService.getByShelfNo(agvTask.getShelfNo());
shelf.setStatus("relax");
shelfService.updateById(shelf);
}
/**
* 将参数传输给AGV
* @return
*/
private AjaxResult callAGV(String params,String url){
String value = configService.getKey(QuantityConstant.RULE_CONNECT_AGV,QuantityConstant.WAREHOUSE_KS);
int connectAGV = Integer.parseInt(value);
if (connectAGV == QuantityConstant.RULE_AGV_CONNECT) {
String result = HttpUtils.bodypost(url, params,QuantityConstant.WAREHOUSE_KS);
AjaxResult ajaxResult= JSONObject.parseObject(result, AjaxResult.class);
if(StringUtils.isEmpty(result)){
throw new ServiceException("AGV接口地址错误或服务器连接不到或返回为空");
}
if(ajaxResult.hasErr()){
AjaxResult.error("AGV: " + ajaxResult.getMsg());
}
}
return AjaxResult.success("下发成功");
}
//根据agv的任务状态来判断
private AjaxResult agvTaskStatusNowStart(String status, AgvTask agvTask){
AgvTask task = this.getByTaskNo(agvTask.getTaskNo());
if(task==null) {
return AjaxResult.error("任务号"+agvTask.getId()+"不存在");
}
if(task.getStatus().equals(QuantityConstant.TASK_STATUS_COMPLETED)) {
return AjaxResult.error("任务"+agvTask.getId()+"已经完成");
}
task.setStatus(Integer.valueOf(status));
if("100".equals(status)){
//货架写入点位数据,状态为relax
Shelf shelf = shelfService.getByPositionName(agvTask.getShelfNo());
shelf.setStatus("relax");
shelf.setPositionName(agvTask.getToPort());
shelfService.updateById(shelf);
//源点位货架数据清空,状态empty
PointPosition pointPosition = pointPositionService.getPositionByPositionName(agvTask.getFromPort(),agvTask.getWarehouseCode());
pointPositionService.clearShelfByPositionName(pointPosition.getPositionName());
//目标点位货架写入,状态some
pointPositionService.fillShelfByPositionName(agvTask.getToPort(),agvTask.getShelfNo());
}
//agv任务完成
return AjaxResult.toAjax(this.updateById(task));
}
//检查点位是否存在
@SuppressWarnings("AlibabaCommentsMustBeJavadocFormat")
private AjaxResult checkPointPositionExist(String sourcePort,String destPort){
PointPosition sourcePosition = pointPositionService.getPositionByPositionName(sourcePort, QuantityConstant.WAREHOUSE_CS);
PointPosition desPosition = pointPositionService.getPositionByPositionName(destPort, QuantityConstant.WAREHOUSE_CS);
if (StringUtils.isNull(sourcePosition)) {
return AjaxResult.error("源点位:" + sourcePort + "未找到");
}
if (StringUtils.isNull(desPosition)) {
return AjaxResult.error("目标点位:" + destPort + "未找到");
}
return AjaxResult.success();
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult completTasks(String id){
if (StringUtils.isNull(id)) {
return AjaxResult.error("任务详情id为空");
}
TaskDetail taskDetail=taskDetailService.getById(id);
taskDetail.setNumber(2);
taskDetailService.updateById(taskDetail);
Boolean tag=isAllComplete(taskDetail.getTaskId());
if(tag){
AjaxResult ajaxResult = taskHeaderService.completeTaskByWMS(Convert.toIntArray(taskDetail.getTaskId().toString()),null);
if(ajaxResult.hasErr()){
throw new ServiceException(ajaxResult.getMsg());
}
return ajaxResult;
}
return AjaxResult.success("成功");
}
public Boolean isAllComplete(Integer taskid){
LambdaQueryWrapper<TaskDetail> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(TaskDetail::getTaskId, taskid);
queryWrapper.eq(TaskDetail::getNumber,1);
int detailSize= taskDetailService.list(queryWrapper).size();
if(detailSize==0){
//全部完成0
return true;
}
return false;
}
}