XiaoRuby
2023-09-01 8e39c9bbf8a8bb4707f2a766295b40497ae96706
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
package com.yuanchu.mom.controller;
 
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.dto.ManualTechnologyDto;
import com.yuanchu.mom.service.DeviceService;
import com.yuanchu.mom.service.ManualTechnologyService;
import com.yuanchu.mom.service.ManufactureSchedulingService;
import com.yuanchu.mom.utils.MyUtil;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.yuanchu.mom.service.ManufactureOrderService;
 
import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
/**
 * 生产订单表(ManufactureOrder)表控制层
 *
 * @author zss
 * @since 2023-08-17 14:16:24
 */
@Api(tags = "生产管理-->生产订单")
@RestController
@RequestMapping("/manufactureOrder")
public class ManufactureOrderController {
 
    @Autowired
    private ManufactureOrderService manufactureOrderService;
 
    @Autowired
    private ManufactureSchedulingService manufactureSchedulingService;
 
    @Resource
    ManualTechnologyService manualTechnologyService;
 
    @Resource
    DeviceService deviceService;
 
 
    @ApiOperation(value = "查询生产订单列表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "downTime", value = "下单日期", dataTypeClass = String.class),
            @ApiImplicitParam(name = "delTime", value = "交货日期", dataTypeClass = String.class),
            @ApiImplicitParam(name = "customerCode", value = "合同编号", dataTypeClass = String.class),
            @ApiImplicitParam(name = "type", value = "状态(为空=全部)", dataTypeClass = Integer.class)
    })
    @GetMapping("/selectAllManord")
    public Result selectAllManord(int pageSize, int countSize, String downTime, String delTime, String customerCode, Integer type) {
        IPage<Map<String, Object>> manufactureOrderPage = manufactureOrderService.selectAllManord(new Page<Object>(pageSize, countSize), downTime, delTime, customerCode, type);
        Map<String, Object> map = new HashMap<>();
        map.put("total", manufactureOrderPage.getTotal());
        map.put("row", manufactureOrderPage.getRecords());
        return Result.success(map);
    }
 
    @ApiOperation(value = "点击排产获取表格二级树")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "manOrdId", value = "生产订单id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/seleDatil")
    public Result seleDatil(Integer manOrdId) {
        return Result.success(manualTechnologyService.seleDatil(manOrdId));
    }
 
    @ApiOperation(value = "点击查看排产")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "manOrdId", value = "生产订单id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/select_Scheduling")
    public Result<?> selectScheduling(Integer manOrdId) {
        return Result.success(manufactureSchedulingService.selectScheduling(manOrdId));
    }
 
    @ApiOperation(value = "点击排产-->二级树选择设备")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "deviceGroup", value = "设备组", dataTypeClass = String.class, required = true)
    })
    @GetMapping("/seleDevice")
    public Result seleDevice(String deviceGroup) {
        return Result.success(deviceService.getDeviceNameByGroup(deviceGroup));
    }
 
    @ApiOperation(value = "点击排产-->确定按钮")
    @PostMapping("/output")
    public Result<?> output(@Validated @RequestBody ManualTechnologyDto manualTechnologyDto) throws ParseException {
        // 判断输入数量是否超出
        Integer isExceed = manufactureOrderService.checkScheduled(manualTechnologyDto.getManOrdId(), manualTechnologyDto.getSchedulingNumber());
        if (isExceed >= 0){
            manualTechnologyService.output(manualTechnologyDto);
            return Result.success("排产成功!");
        } else {
            MyUtil.PrintLog(isExceed.toString());
            int i = manualTechnologyDto.getSchedulingNumber() + isExceed;
            return Result.fail("排产错误,当前剩余排产为:" + i);
        }
    }
 
    @ApiOperation(value = "下达")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "manufactureOrderId", value = "订单id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "schedulingId", value = "排产Id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/down")
    public Result<?> down(Integer manufactureOrderId, Integer schedulingId) {
        manufactureOrderService.down(manufactureOrderId, schedulingId);
        return Result.success("下达成功!");
    }
 
    @ApiOperation(value = "多选删除")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "manOrdId", value = "生产订单id", dataTypeClass = String.class, dataType = "list", required = true)
    })
    @DeleteMapping("/delete")
    public Result<?> deleteManufacture(List<String> manOrdId) {
        manufactureOrderService.deleteManufacture(manOrdId);
        return Result.success("删除成功!");
    }
}