| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | 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.LinkDetectionMapper; |
| | | import com.yuanchu.limslaboratory.pojo.LinkBasicInformation; |
| | | import com.yuanchu.limslaboratory.pojo.Material; |
| | | import com.yuanchu.limslaboratory.pojo.Standard; |
| | | import com.yuanchu.limslaboratory.pojo.LinkDetection; |
| | | import com.yuanchu.limslaboratory.pojo.vo.InspectionVo; |
| | | import com.yuanchu.limslaboratory.service.InspectionService; |
| | | import com.yuanchu.limslaboratory.service.LinkBasicInformationService; |
| | | import com.yuanchu.limslaboratory.service.MaterialService; |
| | | import com.yuanchu.limslaboratory.service.StandardService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | 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.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; |
| | | |
| | |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-08-03 |
| | | */ |
| | | @Api(tags = "报检管理-->委托检验-->链接") |
| | | @Api(tags = "报检管理-->委托检验") |
| | | @RestController |
| | | @RequestMapping("/link-basic") |
| | | @RequestMapping("/link-basic-table") |
| | | public class LinkBasicInformationController { |
| | | |
| | | @Autowired |
| | | private LinkBasicInformationService linkBasicInformationService; |
| | | |
| | | @Autowired |
| | | private MaterialService materialService; |
| | | |
| | | @Autowired |
| | | private StandardService standardService; |
| | | @Resource |
| | | private InspectionService inspectionService; |
| | | |
| | | @ApiOperation("获取链接") |
| | | @Resource |
| | | private LinkDetectionMapper linkDetectionMapper; |
| | | |
| | | @ApiOperation("链接-->获取链接") |
| | | @GetMapping("/link") |
| | | @AuthHandler |
| | | public Result<?> getLink() { |
| | | Object link1 = null; |
| | | try { |
| | |
| | | return Result.success(link1); |
| | | } |
| | | |
| | | @ApiOperation("获取样品名称") |
| | | @GetMapping("/material") |
| | | public Result<?> getMaterialIdAndName(@RequestHeader("link") String link) { |
| | | String redisLink = RedisUtil.get("link").toString(); |
| | | if (redisLink.equals(link)){ |
| | | LambdaQueryWrapper<Material> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(Material::getId, Material::getName, Material::getCode); |
| | | List<Map<String, Object>> maps = materialService.listMaps(wrapper); |
| | | return Result.success(maps); |
| | | } |
| | | return Result.fail("抱歉链接错误或已过期!"); |
| | | @ApiOperation(value = "分页表格") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "起始页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "每一页数量", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "entrustCoding", value = "委托编号", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "sampleName", value = "样品名称", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "entrusted", value = "委托单位", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "inspectionStatus", value = "检验状态", dataTypeClass = Integer.class) |
| | | }) |
| | | @GetMapping("/page") |
| | | @AuthHandler |
| | | public Result<?> getLinkBasicPage(Integer pageNo, Integer pageSize, String entrustCoding, String sampleName, String entrusted, Integer inspectionStatus) { |
| | | IPage<Map<String, Object>> linkBasicPage = linkBasicInformationService.getLinkBasicPage(new Page<Object>(pageNo, pageSize), entrustCoding, sampleName, entrusted, inspectionStatus); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("total", linkBasicPage.getTotal()); |
| | | map.put("row", linkBasicPage.getRecords()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation("获取规格型号") |
| | | @GetMapping("/specification") |
| | | public Result<?> getSpecificationIdAndName(@RequestHeader("link") String link, String materialId) { |
| | | String redisLink = RedisUtil.get("link").toString(); |
| | | if (redisLink.equals(link)){ |
| | | List<Map<String, Object>> specificationIdAndName = standardService.getSpecificationIdAndName(materialId); |
| | | return Result.success(specificationIdAndName); |
| | | } |
| | | return Result.fail("抱歉链接错误或已过期!"); |
| | | @ApiOperation("根据id查询Specifications表的Name") |
| | | @GetMapping("/getSpecificationsName") |
| | | public Result<?> getSpecificationsName(String id){ |
| | | return Result.success(linkBasicInformationService.getSpecificationsName(id)); |
| | | } |
| | | |
| | | @ApiOperation("添加检验申请单") |
| | | @PostMapping("/addInspection") |
| | | public Result<?> addLinkBasicInformation(@RequestHeader("link") String link, @RequestBody LinkBasicInformation linkBasicInformation) { |
| | | String redisLink = RedisUtil.get("link").toString(); |
| | | if (redisLink.equals(link)){ |
| | | String code = linkBasicInformationService.addLinkBasicInformation(linkBasicInformation); |
| | | if (!ObjectUtils.isEmpty(code)){ |
| | | return Result.success("添加成功!", code); |
| | | } else { |
| | | return Result.fail("添加失败!"); |
| | | } |
| | | } |
| | | return Result.fail("抱歉链接错误或已过期!"); |
| | | |
| | | @ApiOperation("删除") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "委托样品id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/delLink") |
| | | @AuthHandler(type = InterfaceType.DELETE,menuId = MenuEnums.commissionInspection,isAdd = true) |
| | | public Result<?> delLink(Integer id){ |
| | | linkBasicInformationService.delLink(id); |
| | | return Result.success("删除成功!"); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("选择版本") |
| | | @GetMapping("/chooseVer") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "id", dataTypeClass = String.class, required = true), |
| | | }) |
| | | @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.commissionInspection,isAdd = true) |
| | | public Result<?> chooseVer(String name, String id, String specifications) { |
| | | LinkDetection linkDetection = linkDetectionMapper.selectById(id); |
| | | return Result.success(linkBasicInformationService.chooseVer(linkDetection)); |
| | | } |
| | | |
| | | |
| | | @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 = "id", value = "委托信息id", dataTypeClass = Integer.class,required = true ) |
| | | }) |
| | | @GetMapping("/lookProByVer") |
| | | @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.commissionInspection,isAdd = true) |
| | | public Result lookProByVer(String name, String mcode, String specifications,Integer version,Integer id) { |
| | | return Result.success(linkBasicInformationService.lookProByVer(name,mcode, specifications,version,id)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "委托品生成报检单") |
| | | @PostMapping("/addInspect") |
| | | @AuthHandler(type = InterfaceType.ADD,menuId = MenuEnums.commissionInspection,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); |
| | | LinkDetection linkDetection = linkDetectionMapper.selectById(inspectionVo.getId()); |
| | | return Result.success(inspectionService.addInspect((Integer) unmarshal.get("id"), inspectionVo)); |
| | | } |
| | | |
| | | } |