李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
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
package com.chinaztt.mes.aps.controller;
 
import com.chinaztt.mes.aps.core.ApsMain;
import com.chinaztt.mes.aps.dto.OrderDTO;
import com.chinaztt.mes.aps.service.ApsCoreService;
import com.chinaztt.mes.aps.vo.GanttTaskVo;
import com.chinaztt.ztt.common.core.util.R;
import com.chinaztt.ztt.common.log.annotation.SysLog;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
 
/**
 * @Author: zhangxy
 * @Date: 2020-10-14 9:58
 */
@RestController
@AllArgsConstructor
@RequestMapping("/aps/main")
public class ApsMainController {
 
    private ApsMain apsMain;
    private ApsCoreService apsCoreService;
 
 
    /**
     * 加载甘特图数据
     *
     * @param sceneId
     * @param groupId
     * @param viewStart
     * @param viewEnd
     * @return
     */
    @ApiOperation(value = "加载甘特图", notes = "加载甘特图")
    @GetMapping
    public R get(Long sceneId, Long groupId, LocalDate viewStart, LocalDate viewEnd) {
        return R.ok(apsCoreService.query(sceneId, groupId, viewStart, viewEnd.plusDays(1)));
    }
 
    /**
     * 加载甘特图数据
     *
     * @param sceneId
     * @param workStationList
     * @param viewStart
     * @param viewEnd
     * @param stateList
     * @return
     */
    @ApiOperation(value = "加载甘特图", notes = "加载甘特图")
    @GetMapping("/loadGantt")
    public R get(Long sceneId, @RequestParam(value = "workStationList", required = false) List<Long> workStationList, String workCenter
            , LocalDate viewStart, LocalDate viewEnd, @RequestParam(value = "stateList", required = false) List<String> stateList) {
        return R.ok(apsCoreService.loadGantt(sceneId, workStationList, workCenter, viewStart, viewEnd.plusDays(1), stateList));
    }
 
    /**
     * 运行排产
     *
     * @param orders
     * @return
     */
    @ApiOperation(value = "执行订单排产", notes = "执行订单排产")
    @PostMapping("/run/{sceneId}")
    public R run(@RequestBody OrderDTO[] orders, @PathVariable Long sceneId) {
        return apsMain.run(orders, sceneId);
    }
 
    /**
     * 修改排产
     *
     * @param task
     * @return
     */
    @ApiOperation(value = "修改排产", notes = "修改排产")
    @SysLog("修改排产")
    @PutMapping
    public R updateById(@RequestBody GanttTaskVo task) {
        return R.ok(apsCoreService.updateTaskById(task));
    }
 
    /**
     * 根据机台计算开始结束时间
     *
     * @return
     */
    @ApiOperation(value = "计算开始结束时间", notes = "计算开始结束时间")
    @SysLog("计算开始结束时间")
    @GetMapping("/calOperationTaskTime")
    public R calOperationTaskTime(Long workstationId, Long partId, BigDecimal qty) {
        return R.ok(apsCoreService.calOperationTaskTime(workstationId, partId, qty));
    }
 
    /**
     * 根据机台计算开始结束时间
     *
     * @return
     */
    @ApiOperation(value = "自动选择机台", notes = "自动选择机台")
    @SysLog("自动选择机台")
    @GetMapping("/autoSetTime")
    public R autoSetTime(String workCenter, Long partId, BigDecimal qty) {
        return R.ok(apsCoreService.autoSetTime(workCenter, partId, qty));
    }
 
    /**
     * 删除排产
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "通过id删除排产", notes = "通过id删除排产")
    @SysLog("通过id删除排产")
    @DeleteMapping("/{id}")
    public R removeById(@PathVariable Long id) {
        return R.ok(apsCoreService.removeSceneTask(id));
    }
 
 
    /**
     * 应用至实际场景
     *
     * @param sceneId
     * @return
     */
    @ApiOperation(value = "应用至实际场景", notes = "应用至实际场景")
    @SysLog("应用至实际场景")
    @PostMapping("/apply/{sceneId}")
    public R apply(@PathVariable Long sceneId) {
        return apsCoreService.applyToReality(sceneId);
    }
 
 
}