| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | import com.yuanchu.limslaboratory.annotation.AuthHandler; |
| | | import com.yuanchu.limslaboratory.enums.InterfaceType; |
| | | import com.yuanchu.limslaboratory.enums.MenuEnums; |
| | | import com.yuanchu.limslaboratory.pojo.Product; |
| | | import com.yuanchu.limslaboratory.pojo.dto.StandardProductAddDto; |
| | | import com.yuanchu.limslaboratory.service.ProductService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-17 |
| | | */ |
| | | @Api(tags = "标准库-->5、规格-->查看-->子模块") |
| | | @Api(tags = "标准库-->4、项目") |
| | | @RestController |
| | | @RequestMapping("/product") |
| | | public class ProductController { |
| | |
| | | @Autowired |
| | | private ProductService productService; |
| | | |
| | | @ApiOperation("添加测试标准") |
| | | @PostMapping("/add") |
| | | public Result<?> addProductInformation(@RequestHeader("X-Token") String token, @RequestBody Product product) throws Exception { |
| | | Object userMessage = RedisUtil.get(token); |
| | | if (!ObjectUtils.isEmpty(userMessage)){ |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(userMessage), Map.class); |
| | | product.setUserId(Integer.parseInt(unmarshal.get("id").toString())); |
| | | } else { |
| | | return Result.fail("对不起,Token错误!"); |
| | | } |
| | | Integer isProductSuccess = productService.addProductInformation(product); |
| | | if (isProductSuccess == 1) { |
| | | return Result.success("添加物料【"+ product.getName() +"】成功!"); |
| | | } |
| | | return Result.fail("添加物料【"+ product.getName() +"】失败!"); |
| | | } |
| | | |
| | | @ApiOperation("根据物料ID查询所有测试标准") |
| | | @GetMapping("/list") |
| | | @ApiOperation("查询该型号下的项目-->选择版本") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "物料ID", name = "materialId", dataTypeClass = String.class) |
| | | @ApiImplicitParam(name = "specificationsId", value = "型号ID", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | public Result<?> getListProductInformation(String materialId) { |
| | | List<Map<String, Object>> listMaterialInformation = productService.getListProductInformation(materialId); |
| | | return Result.success(listMaterialInformation); |
| | | @GetMapping("/chooseVersion") |
| | | @AuthHandler |
| | | public Result<?> chooseVersion(Integer specificationsId) { |
| | | return Result.success(productService.chooseVersion(specificationsId)); |
| | | } |
| | | |
| | | @ApiOperation("根据测试标准ID查询基本信息") |
| | | @GetMapping("/productId") |
| | | @ApiOperation("查询该型号下的项目") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "测试标准ID", name = "productId", dataTypeClass = String.class) |
| | | @ApiImplicitParam(name = "specificationsId", value = "型号ID", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "version", value = "版本(默认最新版本)", dataTypeClass = Integer.class,required = true ) |
| | | }) |
| | | public Result<?> getProductInformation(Integer productId) { |
| | | Map<String, Object> productInformation = productService.getProductInformation(productId); |
| | | return Result.success(productInformation); |
| | | @GetMapping("/page") |
| | | @AuthHandler |
| | | public Result<?> pageProductInformation(Integer specificationsId,Integer version) { |
| | | return Result.success(productService.pageProductInformation(specificationsId,version)); |
| | | } |
| | | |
| | | @ApiOperation("删除测试标准模块数据") |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("填写标准值与内控值,鼠标移开保存") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(value = "测试标准ID", name = "productId", dataTypeClass = String.class) |
| | | @ApiImplicitParam(name = "id", value = "标准项目ID", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "required", value = "标准值", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "internal", value = "内控值", dataTypeClass = String.class, required = true) |
| | | |
| | | }) |
| | | public Result<?> deleteProductInformation(Integer productId) { |
| | | Integer isDeleteProduct = productService.deleteProductInformation(productId); |
| | | if (isDeleteProduct == 1) { |
| | | return Result.success("删除成功!"); |
| | | @PostMapping("/write") |
| | | @AuthHandler |
| | | public Result<?> write(Integer id, String required, String internal) { |
| | | Integer write = productService.write(id, required, internal); |
| | | if (write >= 1){ |
| | | return Result.success("更新成功"); |
| | | } |
| | | return Result.fail("删除失败!"); |
| | | return Result.fail("更新失败"); |
| | | } |
| | | |
| | | @ApiOperation("根据测试标准Id修改数据") |
| | | @PutMapping("/update") |
| | | public Result<?> updateMaterialInformation(@RequestBody Product product) { |
| | | Integer isUpdateMaterialSuccess = productService.updateMaterialInformation(product); |
| | | if (isUpdateMaterialSuccess == 1) { |
| | | return Result.success("修改【"+ product.getName() +"】成功!"); |
| | | } |
| | | return Result.fail("修改【"+ product.getName() +"】失败!"); |
| | | @ApiOperation("项目Id列表删除") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "ids", value = "标准项目ID", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @DeleteMapping("/deleteList") |
| | | @AuthHandler |
| | | public Result<?> deleteList(String ids) { |
| | | if(ids==null||ids.equals(""))return Result.fail(); |
| | | MyUtil.PrintLog(ids); |
| | | productService.deleteList(ids); |
| | | return Result.success("删除成功"); |
| | | } |
| | | |
| | | @ApiOperation("添加同一个型号的其他版本") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "specificationsId", value = "型号id", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "version", value = "当前版本", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/addVersion") |
| | | @AuthHandler |
| | | public Result<?> addVersion(Integer specificationsId,Integer version ) { |
| | | Integer version1 = productService.addVersion(specificationsId,version); |
| | | return Result.success("添加版本"+version1+"成功"); |
| | | } |
| | | |
| | | @ApiOperation("标注库-》添加项目") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "specificationId", value = "型号id", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "version", value = "当前版本", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "name", value = "项目名", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "father", value = "项目分组", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "unit", value = "单位", dataTypeClass = String.class, required = true), |
| | | }) |
| | | @PostMapping("/addProduct") |
| | | @AuthHandler(type = InterfaceType.ADD,menuId = MenuEnums.index,isAdd = true) |
| | | public Result<?> addProduct(@RequestBody StandardProductAddDto dto){ |
| | | return Result.success(productService.addProduct(dto)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |