XiaoRuby
2023-09-05 b1ee044a6f0b6561fba149255432e0214c1884c3
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
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.FinishedInspect;
import com.yuanchu.mom.service.*;
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 java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
 * @since 2023-08-01
 */
@Api(tags = "QMS管理-->成品检验")
@RestController
@RequestMapping("/finished-inspect")
public class FinishedInspectController {
 
    @Autowired
    private FinishedInspectService finishedInspectService;
 
    @Autowired
    private UserService userService;
 
    @Autowired
    private SpecificationsService specificationsService;
 
    @Autowired
    private MaterialService materialService;
 
    @Autowired
    Jwt jwt;
 
    @ApiOperation(value = "新增按钮-->1、新增成品检验单")
    @PostMapping("/add_process_inspection_sheet")
    public Result<?> addProcessInspectionSheet(@Validated @RequestBody FinishedInspect finishedInspect){
        Integer isInsertSuccess = finishedInspectService.addProcessInspectionSheet(finishedInspect);
        if (isInsertSuccess == 1){
            return Result.success("新增成功!", finishedInspect.getId());
        }
        return Result.fail("新增失败!");
    }
 
    @ApiOperation(value = "新增按钮-->1、新增过程检验单-->主机工下拉框")
    @GetMapping("/list_user")
    public Result<?> selectUserIdAndName(){
        List<Map<String, Object>> maps = userService.listUserIdAndName();
        return Result.success(maps);
    }
 
    @ApiOperation(value = "新增按钮-->1、新增过程检验单-->2、规格型号下拉框:根据项目ID查询")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "materialId",value = "项目名称ID",dataTypeClass  = Integer.class,required = true)
    })
    @GetMapping("/list_specification")
    public Result<?> selectSpecificationIdAndName(Integer materialId){
        List<Map<String, Object>> maps = specificationsService.selectSpecificationIdAndName(materialId);
        return Result.success(maps);
    }
 
    @ApiOperation(value = "新增按钮-->1、新增过程检验单-->1、项目名称下拉框")
    @GetMapping("/list_material")
    public Result<?> selectMaterialIdAndNameAndCode(){
        List<Map<String, Object>> maps = materialService.selectMaterialIdAndNameAndCode();
        return Result.success(maps);
    }
 
    @ApiOperation(value = "新增按钮-->3、检验结论")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "finishedInspectId",value = "检验单Id",dataTypeClass  = Integer.class,required = true),
            @ApiImplicitParam(name = "result",value = "检验结论",dataTypeClass  = Integer.class,required = true),
    })
    @PostMapping("/inspection_conclusion")
    public Result<?> inspectionConclusion(@RequestHeader("token") String token,Integer finishedInspectId, Integer result) throws Exception {
        Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class);
        Integer isInsertSuccess = finishedInspectService.inspectionConclusion(data.get("name").replaceAll("\"", ""),finishedInspectId, result);
        if (isInsertSuccess == 1){
            return Result.success("上报成功!");
        }
        return Result.fail("上报失败!");
    }
 
    @ApiOperation(value = "4、主页分页")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNo", value = "条数/页", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "inspectResult", value = "检验结果", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "inspectDate", value = "检验日期", dataTypeClass = Date.class, dataType = "date"),
            @ApiImplicitParam(name = "inspectUsername", value = "主机工", dataTypeClass = String.class)
    })
    @GetMapping("/list_page")
    public Result<?> selectFinishedInspectPage(Integer pageNo, Integer pageSize, Integer inspectResult, String inspectDate, String inspectUsername){
        IPage<Map<String, Object>> page = finishedInspectService.selectFinishedInspectPage(new Page<Object>(pageNo, pageSize), inspectResult, inspectDate, inspectUsername);
        Map<String, Object> map = new HashMap<>();
        map.put("total", page.getTotal());
        map.put("row", page.getRecords());
        return Result.success(map);
    }
 
    @ApiOperation(value = "4、主页分页-->主机工条件查询下拉框")
    @GetMapping("/page_user")
    public Result<?> selectPageUserIdAndName(){
        List<Map<String, Object>> maps = userService.listUserIdAndName();
        return Result.success(maps);
    }
}