zss
2023-08-25 3a4ec5e2eae59901979f4309acb44eebacb75c56
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
package com.yuanchu.limslaboratory.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
 
import java.text.ParseException;
import java.util.*;
 
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yuanchu.limslaboratory.mapper.UserMapper;
import com.yuanchu.limslaboratory.pojo.Inspection;
import com.yuanchu.limslaboratory.pojo.Report;
import com.yuanchu.limslaboratory.pojo.vo.InspectionVo;
import com.yuanchu.limslaboratory.service.LinkBasicInformationService;
import com.yuanchu.limslaboratory.service.RawMaterialService;
import com.yuanchu.limslaboratory.utils.JackSonUtil;
import com.yuanchu.limslaboratory.utils.RedisUtil;
import com.yuanchu.limslaboratory.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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.limslaboratory.service.InspectionService;
 
import javax.annotation.Resource;
 
/**
 * 申请表(Inspection)表控制层
 *
 * @author zss
 * @since 2023-08-03 13:03:36
 */
@Api(tags = "试验管理-->检验申请")
@RestController
@RequestMapping("/inspection")
public class InspectionController {
 
    @Autowired
    private InspectionService inspectionService;
 
    @Resource
    RawMaterialService rawMaterialService;
 
    @Resource
    LinkBasicInformationService linkBasicInformationService;
 
    @Resource
    UserMapper userMapper;
 
    @ApiOperation(value = "查询检验申请单列表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "message", value = "申请单号/原材料名称", dataTypeClass = String.class)
    })
    @GetMapping("/selectInspectsList")
    public Result selectInspectsList(int pageSize, int countSize, String message) {
        IPage<Map<String, Object>> inspectionPage = inspectionService.selectInspectsList(new Page<Object>(pageSize, countSize), message);
        Map<String, Object> map = new HashMap<>();
        map.put("total", inspectionPage.getTotal());
        map.put("row", inspectionPage.getRecords());
        return Result.success(map);
    }
 
 
    @ApiOperation(value = "查询所有报检")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/selectAll")
    public Result selectAll(Integer type) {
        switch (type) {
            case 0:
                //原材料
                return Result.success(rawMaterialService.selectRawmaAll());
            case 2:
                //委托单
                return Result.success(linkBasicInformationService.selectLinkAll());
            case 1:
                //成品检验
                return Result.success("请输入检验信息!");
        }
        return Result.fail("类型错误!");
    }
 
    @ApiOperation(value = "新增检验单-->选择检验项目版本")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "name", value = "产品名称", dataTypeClass = String.class, required = true),
            @ApiImplicitParam(name = "mcode", value = "产品编号", dataTypeClass = String.class, required = true),
            @ApiImplicitParam(name = "specifications", value = "规格型号", dataTypeClass = String.class, required = true)
    })
    @GetMapping("/chooseVer")
    public Result chooseVer(String name, String mcode, String specifications) {
        return Result.success(inspectionService.chooseVer(name, mcode, specifications));
    }
 
 
    @ApiOperation(value = "新增检验单")
    @PostMapping("/addInspect")
    public Result addInspect(@RequestHeader("token") String token, @Validated @RequestBody InspectionVo inspectionVo) throws Exception {
        Object object = RedisUtil.get(token);
        Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class);
        return Result.success(inspectionService.addInspect((Integer) unmarshal.get("id"), inspectionVo));
    }
 
    @ApiOperation(value = "根据检验单id查询检验单详情")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/selectInspectsListById")
    public Result selectInspectsListById(Integer id) {
        return Result.success(inspectionService.selectInspectsListById(id));
    }
 
    @ApiOperation(value = "选择检验项目的责任人")
    @GetMapping("/selectUser")
    public Result selectUser() {
        return Result.success(userMapper.selectUser());
    }
 
    @ApiOperation(value = "保存检验项目责任人")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单项目id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "userProId", value = "责任人id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/chooseUseProId")
    public Result chooseUseProId(Integer id, Integer userProId) {
        return Result.success(inspectionService.chooseUseProId(id, userProId));
    }
 
    @ApiOperation(value = "作废检验单")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/delInspect")
    public Result delInspect(Integer id) {
        return Result.success(inspectionService.delInspect(id));
    }
 
 
}