#
vincentlu
3 天以前 0267cc2886bbdce2c9a55755789c10e0dcaff9f0
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
package com.zy.acs.manager.core.integrate.wms;
 
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.R;
import com.zy.acs.manager.common.annotation.OperationLog;
import com.zy.acs.manager.common.constant.Constants;
import com.zy.acs.manager.core.integrate.dto.OpenBusCancelParam;
import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam;
import com.zy.acs.manager.core.service.MainService;
import com.zy.acs.manager.manager.entity.Bus;
import com.zy.acs.manager.manager.entity.Task;
import com.zy.acs.manager.manager.service.BusService;
import com.zy.acs.manager.manager.service.TaskService;
import com.zy.acs.manager.system.controller.BaseController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * Created by vincent on 2023/6/12
 */
@Api(tags = "Open Api")
@RestController
@RequestMapping("/api/open")
public class OpenController extends BaseController {
 
    @Autowired
    private MainService mainService;
    @Autowired
    private TaskService taskService;
    @Autowired
    private BusService busService;
 
    @PostMapping("/bus/submit")
    @OperationLog("generate task from open api")
    public R submit(@RequestBody OpenBusSubmitParam param) {
        mainService.generateBusAndTask(param, null);
        return R.ok("generate tasks success");
    }
 
    @PostMapping("/bus/cancel")
    @OperationLog("cancel task from open api")
    public R cancel(@RequestBody OpenBusCancelParam param) {
        if (Cools.isEmpty(param.getTasks())) {
            return R.error("tasks is empty");
        }
        Long busId = null;
        if (!Cools.isEmpty(param.getBatchNo())) {
            Bus bus = busService.selectByBusNo(param.getBatchNo());
            if (null != bus) {
                busId = bus.getId();
            }
        } else {
//            return R.error("batch_no is empty");
        }
        for (String taskNo : param.getTasks()) {
            Task task = taskService.selectBySeqNum(busId, taskNo);
            if (null == task) {
                continue;
            }
            taskService.cancel(task.getId(), null, Constants.UPLINK);
        }
        return R.ok("cancel tasks success");
    }
 
}