| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | | import com.yuanchu.limslaboratory.mapper.InspectionMapper; |
| | | import com.yuanchu.limslaboratory.pojo.Inspection; |
| | | import com.yuanchu.limslaboratory.pojo.InspectionMaterialList; |
| | | import com.yuanchu.limslaboratory.pojo.Material; |
| | | import com.yuanchu.limslaboratory.pojo.dto.InspectionMaterialListDto; |
| | | import com.yuanchu.limslaboratory.service.InspectionMaterialListService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-17 |
| | | */ |
| | | @Api(tags = "检验模块") |
| | | @Api(tags = "检验模块-->检验单-->样品相关") |
| | | @RestController |
| | | @RequestMapping("/inspectionMaterialList") |
| | | public class InspectionMaterialListController { |
| | |
| | | @Autowired |
| | | InspectionMaterialListService inspectionMaterialListService; |
| | | |
| | | @ApiOperation("添加样品") |
| | | @Resource |
| | | InspectionMapper inspectionMapper; |
| | | |
| | | @ApiOperation("添加检验单中的检验样品") |
| | | @PostMapping("/addInspectionMaterialList") |
| | | public Result addInspectionMaterialList(@RequestHeader("X-Token") String token, @RequestBody InspectionMaterialList inspectionMaterialList) throws Exception { |
| | | inspectionMaterialList.setState(1); |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | return Result.success(inspectionMaterialListService.addInspectionMaterialList(inspectionMaterialList, ""+unmarshal.get("id"))); |
| | | //如果检验单已作废,状态为0,则无法添加样品 |
| | | Inspection inspection = inspectionMapper.selectById(inspectionMaterialList.getInspectionId()); |
| | | if (inspection.getState()==0) { |
| | | return Result.fail("检验单已作废无法添加检验样品"); |
| | | } |
| | | else { |
| | | inspectionMaterialList.setState(1); |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | inspectionMaterialListService.addInspectionMaterialList(inspectionMaterialList, "" + unmarshal.get("id")); |
| | | return Result.success(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("删除样品") |
| | |
| | | }) |
| | | @PostMapping("/delInspectionMaterialList") |
| | | public Result delInspectionMaterialList(int inspectionMaterialListId) { |
| | | return Result.success(inspectionMaterialListService.delInspectionMaterialListByInsId(inspectionMaterialListId)); |
| | | inspectionMaterialListService.delInspectionMaterialListByInsId(inspectionMaterialListId); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation("根据样品Id查询样品信息") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "inspectionMaterialListId", value = "样品ID", dataTypeClass = Integer.class, required = true), |
| | | }) |
| | | @PutMapping("/selectInspectionMaterialListById/{inspectionMaterialListId}") |
| | | public Result selectInspectionMaterialListById(@PathVariable Integer inspectionMaterialListId) { |
| | | return Result.success(inspectionMaterialListService.getById(inspectionMaterialListId)); |
| | | } |
| | | |
| | | @ApiOperation("根据样品id修改样品信息") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "inspectionMaterialListId", value = "样品ID", dataTypeClass = Integer.class, required = true), |
| | | }) |
| | | @PutMapping("/updateInspectionMaterialList/{inspectionMaterialListId}") |
| | | public Result updateInspectionMaterialList(@PathVariable Integer inspectionMaterialListId, @RequestBody InspectionMaterialListDto inspectionMaterialListDto) { |
| | | inspectionMaterialListService.updateInspectionMaterialList(inspectionMaterialListId, inspectionMaterialListDto); |
| | | return Result.success(); |
| | | } |
| | | } |