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();
|
}
|
|
}
|