| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.annotation.AuthHandler; |
| | | import com.yuanchu.limslaboratory.enums.InterfaceType; |
| | | import com.yuanchu.limslaboratory.enums.MenuEnums; |
| | | import com.yuanchu.limslaboratory.mapper.ProductMapper; |
| | | import com.yuanchu.limslaboratory.pojo.Material; |
| | | import com.yuanchu.limslaboratory.pojo.Product; |
| | | import com.yuanchu.limslaboratory.pojo.RawMaterial; |
| | | import com.yuanchu.limslaboratory.service.RawMaterialService; |
| | | import com.yuanchu.limslaboratory.pojo.vo.InspectionVo; |
| | | import com.yuanchu.limslaboratory.service.*; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.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.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | |
| | | @Autowired |
| | | private RawMaterialService rawMaterialService; |
| | | |
| | | @Autowired |
| | | private StandardService standardService; |
| | | |
| | | @Autowired |
| | | private MaterialService materialService; |
| | | |
| | | @Resource |
| | | private ProductMapper productMapper; |
| | | |
| | | @Resource |
| | | private InspectionService inspectionService; |
| | | |
| | | @ApiOperation("查询所有检验计划分配") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "起始页", dataTypeClass = Integer.class, required = true), |
| | |
| | | map.put("total", iPage.getTotal()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation("原材料报检添加") |
| | | @PostMapping("/add") |
| | | @AuthHandler(type = InterfaceType.ADD,menuId = MenuEnums.reportForInspection,isAdd = true) |
| | | public Result<?> insertRawMaterial(@Validated @RequestBody RawMaterial rawMaterial) { |
| | | Integer integer = rawMaterialService.insertRawMaterial(rawMaterial); |
| | | if (integer >= 1) { |
| | | return Result.success("添加成功"); |
| | | } |
| | | return Result.fail("添加失败"); |
| | | } |
| | | |
| | | @ApiOperation("原材料报检删除") |
| | | @PostMapping("/delete") |
| | | @AuthHandler(type = InterfaceType.DELETE,menuId = MenuEnums.reportForInspection,isAdd = true) |
| | | public Result<?> deleteRawMaterial(String deleteId) { |
| | | Integer integer = rawMaterialService.deleteRawMaterial(deleteId); |
| | | if (integer >= 1) { |
| | | return Result.success("删除成功"); |
| | | } |
| | | return Result.fail("删除失败"); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("获取物料名称") |
| | | @GetMapping("/getMaterielName") |
| | | @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.reportForInspection,isAdd = true) |
| | | public Result<?> getMaterielName(){ |
| | | LambdaQueryWrapper<Material> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(Material::getId, Material::getName, Material::getCode) |
| | | .eq(Material::getType,0).eq(Material::getState,1); |
| | | List<Map<String, Object>> maps = materialService.listMaps(wrapper); |
| | | return Result.success(maps); |
| | | } |
| | | |
| | | @ApiOperation("获取规格型号") |
| | | @GetMapping("/specification") |
| | | @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.reportForInspection,isAdd = true) |
| | | public Result<?> getSpecificationIdAndName(String materialId) { |
| | | List<Map<String, Object>> specificationIdAndName = standardService.getSpecificationIdAndName(materialId); |
| | | return Result.success(specificationIdAndName); |
| | | } |
| | | |
| | | @ApiOperation("选择版本") |
| | | @GetMapping("/chooseVer") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "name", value = "产品名称", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "mcode", value = "产品编号", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "specifications", value = "规格型号", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.reportForInspection,isAdd = true) |
| | | public Result<?> chooseVer(String name, String mcode, String specifications) { |
| | | return Result.success(inspectionService.chooseVer(name, mcode, specifications)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "查看该版本下我们要做的项目要求") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "name", value = "产品名称", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "mcode", value = "产品编号", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "specifications", value = "规格型号", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "version", value = "版本(默认最新版本)", dataTypeClass = Integer.class,required = true ), |
| | | }) |
| | | @GetMapping("/lookProByVer") |
| | | @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.reportForInspection,isAdd = true) |
| | | public Result lookProByVer(String name, String mcode, String specifications,Integer version) { |
| | | return Result.success(inspectionService.lookProByVer(name, mcode, specifications,version,null)); |
| | | } |
| | | |
| | | @ApiOperation(value = "原材料生成报检单") |
| | | @PostMapping("/addInspect") |
| | | @AuthHandler(type = InterfaceType.ADD,menuId = MenuEnums.reportForInspection,isAdd = true) |
| | | public Result addInspect(@RequestHeader("X-Token") String token, @Validated @RequestBody InspectionVo inspectionVo) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | return Result.success(inspectionService.addInspect((Integer) unmarshal.get("id"), inspectionVo)); |
| | | } |
| | | |
| | | } |