| | |
| | | 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.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.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; |
| | | |
| | | @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 { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | return Result.success(inspectionService.addInspection("" + unmarshal.get("name"), type)); |
| | | } |
| | | |
| | | @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") |
| | | 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") |
| | | public Result selectAll(Integer type) { |
| | | switch (type) { |
| | | case 0 : |
| | | //原材料 |
| | | return Result.success(rawMaterialService.selectRawmaAll()); |
| | | case 1 : |
| | | //委托单 |
| | | return Result.success(linkBasicInformationService.selectLinkAll()); |
| | | case 2 : |
| | | //成品检验 |
| | | 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 = "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) |
| | | }) |
| | | @GetMapping("/selectMaterialLimit") |
| | | public Result selectMaterialLimit(int pageSize, int countSize) { |
| | | return Result.success(materialService.selectMaterialLimit(pageSize, countSize)); |
| | | @GetMapping("/selectRawmaById") |
| | | public Result selectRawmaById(Integer id, String startTime, String endTime) throws ParseException { |
| | | return Result.success(rawMaterialService.selectRawmaById(id,startTime,endTime)); |
| | | } |
| | | |
| | | @ApiOperation("选择物料信息") |
| | | |
| | | @ApiOperation(value = "选择委托报检和样品") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "materialId", value = "物料ID", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "bid", value = "委托报检单id", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "did", value = "委托报检样品id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/selectMaterialById") |
| | | public Result selectMaterialById(String materialId) { |
| | | return Result.success(materialService.selectMaterialById(materialId)); |
| | | @GetMapping("/selectLinkByid") |
| | | public Result selectLinkByid(Integer bid, Integer did) { |
| | | return Result.success(linkBasicInformationService.selectLinkByid(bid, did)); |
| | | } |
| | | |
| | | @ApiOperation("提交检验单申请") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "inspectionId", value = "检验单ID", dataTypeClass = String.class, required = true), |
| | | }) |
| | | @PostMapping("/submitInspection") |
| | | public Result submitInspection(String inspectionId) { |
| | | inspectionService.subInspectionByInsId(inspectionId); |
| | | return Result.success(); |
| | | |
| | | @ApiOperation(value = "新增检验单") |
| | | @PostMapping("/addInspect") |
| | | public Result addInspect(@RequestHeader("token") String token, @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("/delInspection") |
| | | public Result delInspection(String inspectionId) { |
| | | inspectionService.delInspectionByInsId(inspectionId); |
| | | return Result.success(); |
| | | @GetMapping("/selectInspectsListById") |
| | | public Result selectInspectsListById(Integer id) { |
| | | return Result.success(inspectionService.selectInspectsListById(id)); |
| | | } |
| | | |
| | | @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)); |
| | | } |
| | | |
| | | } |
| | | |