XiaoRuby
2023-08-17 95bd45377f1e04b448d407e3af4ee2707b90a24b
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
package com.yuanchu.mom.controller;
 
import com.yuanchu.mom.pojo.dto.InspectionItemDto;
import com.yuanchu.mom.pojo.dto.UpdateInspectionItemDto;
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 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;
 
    @Autowired
    private Jwt jwt;
 
    @ApiOperation(value = "新增按钮-->2、查询所有检验项目")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "finishInspectId",value = "成品检验单Id",dataTypeClass  = Integer.class,required = true)
    })
    @GetMapping("/list_user")
    public Result<?> selectInspectionItem(Integer finishInspectId){
        List<InspectionItemDto> inspectionItemDto = inspectionItemService.selectInspectionItem(finishInspectId);
        return Result.success(inspectionItemDto);
    }
 
    @ApiOperation(value = "新增按钮-->2、检验项目-->失去焦点发起该请求")
    @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 = "新增按钮-->2、检验项目-->试验设备下拉框")
    @GetMapping("/list_device")
    public Result<?> selectDeviceIdAndName(){
        List<Map<String, Object>> maps = inspectionItemService.selectDeviceIdAndName();
        return Result.success(maps);
    }
}