XiaoRuby
2023-09-09 08b73231454d852f1af710fa039a4d5376e764d9
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
package com.yuanchu.mom.controller;
 
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.ProcessInspect;
import com.yuanchu.mom.pojo.vo.ProcessInspectVo;
import com.yuanchu.mom.utils.JackSonUtil;
import com.yuanchu.mom.utils.Jwt;
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.ProcessInspectService;
 
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
 
 
/**
 * 过程检验(ProcessInspect)表控制层
 *
 * @author zss
 * @since 2023-09-06 13:36:02
 */
@Api(tags = "QMS管理-->过程检验")
@RestController
@RequestMapping("/processInspect")
public class ProcessInspectController {
 
    @Autowired
    private ProcessInspectService processInspectService;
 
    @Resource
    Jwt jwt;
 
    @ApiOperation(value = "新增过程检验单-->根据订单号选择产品信息和工艺")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "orderNumber", value = "订单编号", dataTypeClass = String.class, required = true)
    })
    @GetMapping("/chooseMater")
    public Result<?> chooseMater(String orderNumber) {
        return Result.success(processInspectService.chooseMater(orderNumber));
    }
 
    @ApiOperation(value = "新增过程检验单")
    @PostMapping("/addProcess")
    public Result<?> addProcess(@RequestHeader("token") String token,@Validated @RequestBody ProcessInspectVo processInspectVo) throws Exception {
        Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class);
        return Result.success(processInspectService.addProcess(data.get("id").replaceAll("\"", ""), processInspectVo));
    }
 
    @ApiOperation(value = "上报(更新检验状态)")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/updateProcessInspectsById")
    public Result updateProcessInspectsById(Integer id) {
        //如果已经上报了不能再一次上报
        ProcessInspect processInspect = processInspectService.getById(id);
        if (ObjectUtils.isNotEmpty(processInspect.getResult())) {
            return Result.fail("已经上报过了,不能再次上报!");
        }
        return Result.success(processInspectService.updateProcessInspectsById(id));
    }
 
    @ApiOperation(value = "根据检验单id查询过程检验单详情")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/selectProcessInspectsListById")
    public Result selectProcessInspectsListById(Integer id) {
        return Result.success(processInspectService.selectProcessInspectsListById(id));
    }
 
    @ApiOperation(value = "分页查询过程检验单列表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "techfather", value = "工序", dataTypeClass = String.class),
            @ApiImplicitParam(name = "result", value = "检测结果(为空=全部)", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "name", value = "产品名称", dataTypeClass = String.class)
    })
    @PostMapping("/selectProcessInspectsList")
    public Result selectProcessInspectsList(Integer pageSize, Integer countSize, String techfather, Integer result, String name) {
        IPage<Map<String, Object>> page = processInspectService.selectProcessInspectsList(new Page<Object>(pageSize, countSize), techfather, result, name);
        Map<String, Object> map = new HashMap<>();
        map.put("total", page.getTotal());
        map.put("row", page.getRecords());
        return Result.success(map);
    }
 
}