zss
2023-09-25 a3f47b5e065878e5f41699ac1c597fd9ac9c4a21
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
package com.yuanchu.mom.controller;
 
import com.yuanchu.mom.pojo.dto.InspectionItemDto;
import com.yuanchu.mom.pojo.dto.UpdateInspectionItemDto;
import com.yuanchu.mom.service.DeviceService;
import com.yuanchu.mom.service.InspectionItemService;
import com.yuanchu.mom.utils.JackSonUtil;
import com.yuanchu.mom.utils.Jwt;
 
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
 * @since 2023-08-01
 */
@Api(tags = "QMS管理-->成品过程检验项目")
@RestController
@RequestMapping("/inspection-item")
public class InspectionItemController {
 
    @Autowired
    private InspectionItemService inspectionItemService;
 
    @Resource
    DeviceService deviceService;
 
 
    @Autowired
    private Jwt jwt;
 
    @ApiOperation(value = "新增按钮-->2、查询所有检验项目")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单Id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/list_user")
    public Result<?> selectInspectionItem(Integer id, Integer type) {
        List<InspectionItemDto> inspectionItemDto = inspectionItemService.selectInspectionItem(id, type);
        return Result.success(inspectionItemDto);
    }
 
    @ApiOperation(value = "新增检验单-->选择检验设备")
    @GetMapping("/chooseDev")
    public Result<?> chooseDev() {
        return Result.success(deviceService.chooseDevice());
    }
 
    @ApiOperation(value = "检验项目的检验值-->失去焦点发起该请求")
    @PostMapping("/lose_focus_update")
    public Result<?> addInspectionItem(@RequestHeader("token") String token, @RequestBody UpdateInspectionItemDto updateInspectionItemDto) throws Exception {
        Map<String, String> usernameMessage = jwt.readJWT(token);
        Map<String, Object> usernameAndId = JackSonUtil.unmarshal(usernameMessage.get("data"), Map.class);
        String name = usernameAndId.get("name").toString().replaceAll("\"", "");
        Integer isInsertSuccess = inspectionItemService.addProcessInspectionSheet(name, updateInspectionItemDto);
        Map<String, Object> map = new HashMap<>();
        map.put("result", isInsertSuccess);
        map.put("username", name);
        return Result.success(map);
    }
 
    @ApiOperation(value = "更改设备")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单Id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "DevId", value = "设备id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/updateDevByInsId")
    public Result updateDevByInsId(Integer id, Integer type, Integer devId) {
        inspectionItemService.updateDevByInsId(id, type, devId);
        return Result.success();
    }
 
}