Fixiaobai
2023-09-08 d2ce4553e18131b9a60d7be53c496f0cbce699ca
inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/InspectionController.java
@@ -6,7 +6,13 @@
import java.util.*;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yuanchu.limslaboratory.annotation.AuthHandler;
import com.yuanchu.limslaboratory.enums.InterfaceType;
import com.yuanchu.limslaboratory.enums.MenuEnums;
import com.yuanchu.limslaboratory.mapper.InstrumentMapper;
import com.yuanchu.limslaboratory.mapper.UserMapper;
import com.yuanchu.limslaboratory.pojo.Inspection;
import com.yuanchu.limslaboratory.pojo.Report;
import com.yuanchu.limslaboratory.pojo.vo.InspectionVo;
import com.yuanchu.limslaboratory.service.LinkBasicInformationService;
import com.yuanchu.limslaboratory.service.RawMaterialService;
@@ -18,6 +24,7 @@
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.limslaboratory.service.InspectionService;
@@ -44,6 +51,12 @@
    @Resource
    LinkBasicInformationService linkBasicInformationService;
    @Resource
    UserMapper userMapper;
    @Resource
    private  InstrumentMapper instrumentMapper;
    @ApiOperation(value = "查询检验申请单列表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true),
@@ -51,6 +64,7 @@
            @ApiImplicitParam(name = "message", value = "申请单号/原材料名称", dataTypeClass = String.class)
    })
    @GetMapping("/selectInspectsList")
    @AuthHandler
    public Result selectInspectsList(int pageSize, int countSize, String message) {
        IPage<Map<String, Object>> inspectionPage = inspectionService.selectInspectsList(new Page<Object>(pageSize, countSize), message);
        Map<String, Object> map = new HashMap<>();
@@ -65,78 +79,120 @@
            @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/selectAll")
    @AuthHandler
    public Result selectAll(Integer type) {
        switch (type) {
            case 0:
                //原材料
                return Result.success(rawMaterialService.selectRawmaAll());
            case 1:
            case 2:
                //委托单
                return Result.success(linkBasicInformationService.selectLinkAll());
            case 2:
            case 1:
                //成品检验
                return Result.success("请输入检验信息!");
        }
        return Result.fail("类型错误!");
    }
    @ApiOperation(value = "选择原材料报检")
    @ApiOperation(value = "新增检验单-->选择检验项目版本")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "原材料报检单id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "startTime", value = "检验开始日期", dataTypeClass = String.class, required = true),
            @ApiImplicitParam(name = "endTime", value = "检验结束日期", dataTypeClass = String.class, required = true)
            @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)
    })
    @GetMapping("/selectRawmaById")
    public Result selectRawmaById(Integer id, String startTime, String endTime) throws ParseException {
        return Result.success(rawMaterialService.selectRawmaById(id, startTime, endTime));
    @GetMapping("/chooseVer")
    @AuthHandler
    public Result chooseVer(String name, String mcode, String specifications) {
        return Result.success(inspectionService.chooseVer(name, mcode, specifications));
    }
    @ApiOperation(value = "选择委托报检和样品")
    @ApiOperation(value = "新增检验单-->选择检验项目版本-->查看该版本下我们要做的项目要求")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "bid", value = "委托报检单id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "did", value = "委托报检样品id", dataTypeClass = Integer.class, required = true)
            @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 ),
            @ApiImplicitParam(name = "experiment", value = "试验项目(委托专属)", dataTypeClass = String.class )
    })
    @GetMapping("/selectLinkByid")
    public Result selectLinkByid(Integer bid, Integer did) {
        return Result.success(linkBasicInformationService.selectLinkByid(bid, did));
    @GetMapping("/lookProByVer")
    @AuthHandler
    public Result lookProByVer(String name, String mcode, String specifications,Integer version,String experiment) {
        return Result.success(inspectionService.lookProByVer(name, mcode, specifications,version,experiment));
    }
    @ApiOperation(value = "新增检验单")
    @PostMapping("/addInspect")
    public Result addInspect(@RequestHeader("token") String token, @RequestBody InspectionVo inspectionVo) throws Exception {
    @AuthHandler
    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));
    }
    @ApiOperation(value = "根据检验单id查询原材料检验单详情")
    @ApiOperation(value = "根据检验单id查询检验单详情")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/selectInspectsListById")
    @AuthHandler
    public Result selectInspectsListById(Integer id) {
        return Result.success(inspectionService.selectInspectsListById(id));
    }
    @ApiOperation(value = "上报(更新检验状态)")
    @ApiOperation(value = "选择检验项目的责任人")
    @GetMapping("/selectUser")
    @AuthHandler
    public Result selectUser() {
        return Result.success(userMapper.selectUser());
    }
    @ApiOperation(value = "选择检验设备")
    @GetMapping("/selectEquipment")
    @AuthHandler
    public Result selectEquipment(){return Result.success(instrumentMapper.getInstrument());}
    @ApiOperation(value = "保存检验项目责任人")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单项目id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "userProId", value = "责任人id", dataTypeClass = Integer.class, required = true)
    })
    @GetMapping("/chooseUseProId")
    @AuthHandler
    public Result chooseUseProId(Integer id, Integer userProId) {
        return Result.success(inspectionService.chooseUseProId(id, userProId));
    }
    @ApiOperation("保存设备id")
    @GetMapping("/chooseEquipment")
    @AuthHandler
    public Result chooseEquipment(Integer id,Integer equipmentId){
        return Result.success(inspectionService.chooseEquipment(id, equipmentId));
    }
    @ApiOperation(value = "作废检验单")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验单id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/updateInspectsById")
    public Result updateInspectsById(Integer id) {
        //如果已经上报了不能再一次上报
        Inspection inspection = inspectionService.getById(id);
        if (ObjectUtils.isNotEmpty(inspection.getInspectionStatus())) {
            return Result.fail("已经上报过了,不能再次上报!");
        }
        return Result.success(inspectionService.updateInspectsById(id));
    @PostMapping("/delInspect")
    @AuthHandler
    public Result delInspect(Integer id) {
        return Result.success(inspectionService.delInspect(id));
    }
    @ApiOperation(value = "获取成品信息")
    @PostMapping("/getMaterielTypeIsOne")
    @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.inspectionApplication,isAdd = true)
    public Result getMaterielTypeIsOne(){
        return Result.success(inspectionService.getMaterielTypeIsOne());
    }
    @ApiOperation(value = "根据成品获取规格型号")
    @PostMapping("/getSpecificationByMaterielId")
    @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.inspectionApplication,isAdd = true)
    public Result getSpecification(Integer id){
        return Result.success(inspectionService.getSpecification(id));
    }
}