| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | | import java.text.ParseException; |
| | | 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.InspectionMaterialList; |
| | | import com.yuanchu.limslaboratory.pojo.InspectionProductList; |
| | | import com.yuanchu.limslaboratory.pojo.Product; |
| | | import com.yuanchu.limslaboratory.service.*; |
| | | 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; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.*; |
| | | 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.transaction.annotation.Transactional; |
| | | 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; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * </p> |
| | | * 申请表(Inspection)表控制层 |
| | | * |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-17 |
| | | * @author zss |
| | | * @since 2023-08-03 13:03:36 |
| | | */ |
| | | @Api(tags = "检验模块") |
| | | @Api(tags = "试验管理-->检验申请") |
| | | @RestController |
| | | @RequestMapping("/inspection") |
| | | public class InspectionController { |
| | |
| | | @Autowired |
| | | private InspectionService inspectionService; |
| | | |
| | | @Autowired |
| | | private InspectionMaterialListService inspectionMaterialListService; |
| | | @Resource |
| | | RawMaterialService rawMaterialService; |
| | | |
| | | @Autowired |
| | | private InspectionProductListService inspectionProductListService; |
| | | @Resource |
| | | LinkBasicInformationService linkBasicInformationService; |
| | | |
| | | @Autowired |
| | | private MaterialService materialService; |
| | | @Resource |
| | | UserMapper userMapper; |
| | | |
| | | @ApiOperation("添加检验申请单") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "type", value = "检验类型", dataTypeClass = Integer.class, required = true), |
| | | }) |
| | | @PostMapping("/addInspection") |
| | | public Result addInspection(@RequestHeader("X-Token") String token, int type) throws Exception { |
| | | System.out.println(token); |
| | | System.out.println(type); |
| | | Object object = RedisUtil.get(token); |
| | | System.out.println(object); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | return Result.success(inspectionService.addInspection("" + unmarshal.get("name"), type)); |
| | | } |
| | | @Resource |
| | | private InstrumentMapper instrumentMapper; |
| | | |
| | | @ApiOperation("查询所有检验单列表") |
| | | @ApiOperation(value = "查询检验申请单列表") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "state", value = "状态(为空=全部)", dataTypeClass = Integer.class) |
| | | @ApiImplicitParam(name = "message", value = "申请单号/原材料名称", dataTypeClass = String.class) |
| | | }) |
| | | @GetMapping("/selectAllInspection") |
| | | public Result selectAllInspection(int pageSize, int countSize, Integer state) { |
| | | return Result.success(inspectionService.selectAllInspection(pageSize, countSize, state)); |
| | | @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<>(); |
| | | map.put("total", inspectionPage.getTotal()); |
| | | map.put("row", inspectionPage.getRecords()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation("查询检验单里面的物料信息") |
| | | |
| | | @ApiOperation(value = "查询所有报检") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "inspectionId", value = "报检单ID", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/selectMaterialByInsId") |
| | | public Result selectMaterialByInsId(String inspectionId) { |
| | | return Result.success(inspectionMaterialListService.selectInspectionMaterialListByInsId(inspectionId)); |
| | | @GetMapping("/selectAll") |
| | | @AuthHandler |
| | | public Result selectAll(Integer type) { |
| | | switch (type) { |
| | | case 0: |
| | | //原材料 |
| | | return Result.success(rawMaterialService.selectRawmaAll()); |
| | | case 2: |
| | | //委托单 |
| | | return Result.success(linkBasicInformationService.selectLinkAll()); |
| | | case 1: |
| | | //成品检验 |
| | | return Result.success("请输入检验信息!"); |
| | | } |
| | | return Result.fail("类型错误!"); |
| | | } |
| | | |
| | | @ApiOperation("查询物料信息") |
| | | @ApiOperation(value = "新增检验单-->选择检验项目版本") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "countSize", value = "条数/页", 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) |
| | | }) |
| | | @GetMapping("/selectMaterialLimit") |
| | | public Result selectMaterialLimit(int pageSize, int countSize) { |
| | | return Result.success(materialService.selectMaterialLimit(pageSize, countSize)); |
| | | @GetMapping("/chooseVer") |
| | | @AuthHandler |
| | | 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 ), |
| | | @ApiImplicitParam(name = "experiment", value = "试验项目(委托专属)", dataTypeClass = String.class ) |
| | | }) |
| | | @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("选择物料信息") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "materialId", value = "物料ID", dataTypeClass = Integer.class, required = true), |
| | | }) |
| | | @PostMapping("/selectMaterialById") |
| | | public Result selectMaterialById(String materialId) { |
| | | return Result.success(materialService.selectMaterialById(materialId)); |
| | | |
| | | @ApiOperation(value = "新增检验单") |
| | | @PostMapping("/addInspect") |
| | | @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("提交申请") |
| | | @ApiOperation(value = "根据检验单id查询检验单详情") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "inspectionId", value = "检验单ID", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "id", value = "检验单id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/submitInspection") |
| | | public Result submitInspection(String inspectionId) { |
| | | return Result.success(inspectionService.subInspectionByInsId(inspectionId)); |
| | | @GetMapping("/selectInspectsListById") |
| | | @AuthHandler |
| | | public Result selectInspectsListById(Integer id) { |
| | | return Result.success(inspectionService.selectInspectsListById(id)); |
| | | } |
| | | |
| | | @ApiOperation("作废申请") |
| | | @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 = "inspectionId", value = "检验单ID", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "id", value = "检验单项目id", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "userProId", value = "责任人id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/delInspection") |
| | | public Result delInspection(String inspectionId) { |
| | | return Result.success(inspectionService.delInspectionByInsId(inspectionId)); |
| | | @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("/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)); |
| | | } |
| | | } |
| | | |