From 616c9c94af30ae75eb5994a2cea3fac16acaa005 Mon Sep 17 00:00:00 2001
From: 李林 <z1292839451@163.com>
Date: 星期四, 20 七月 2023 11:21:50 +0800
Subject: [PATCH] 增加请求“检验模块”

---
 inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/InspectionController.java |  111 ++++++++++++++++++++++++-------------------------------
 1 files changed, 49 insertions(+), 62 deletions(-)

diff --git a/inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/InspectionController.java b/inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/InspectionController.java
index 501a4fa..816739d 100644
--- a/inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/InspectionController.java
+++ b/inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/InspectionController.java
@@ -5,21 +5,14 @@
 import com.yuanchu.limslaboratory.pojo.Inspection;
 import com.yuanchu.limslaboratory.pojo.InspectionProductList;
 import com.yuanchu.limslaboratory.pojo.Product;
-import com.yuanchu.limslaboratory.service.InspectionProductListService;
-import com.yuanchu.limslaboratory.service.InspectionService;
-import com.yuanchu.limslaboratory.service.ProductService;
-import com.yuanchu.limslaboratory.service.SpecificationsService;
+import com.yuanchu.limslaboratory.service.*;
 import com.yuanchu.limslaboratory.utils.JackSonUtil;
 import com.yuanchu.limslaboratory.utils.RedisUtil;
 import com.yuanchu.limslaboratory.vo.Result;
 import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
@@ -44,68 +37,62 @@
     private InspectionService inspectionService;
 
     @Autowired
-    private ProductService productService;
-
-    @Autowired
-    private SpecificationsService specificationsService;
+    private InspectionMaterialListService inspectionMaterialListService;
 
     @Autowired
     private InspectionProductListService inspectionProductListService;
 
+    @Autowired
+    private MaterialService materialService;
+
     @ApiOperation("娣诲姞妫�楠岀敵璇峰崟")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "materialId", value = "鐗╂枡淇℃伅id", dataTypeClass = Integer.class, required = true),
+            @ApiImplicitParam(name = "type", value = "妫�楠岀被鍨�", dataTypeClass = Integer.class, required = true),
     })
     @PostMapping("/addInspection")
-    @Transactional(rollbackFor = Exception.class)
-    public Result addInspection(@RequestHeader("X-Token") String token, int materialId,int type) throws Exception {
-        List<Product> list = productService.selectProductByMaterialId(materialId);
-        Map<String, Object> map = specificationsService.selectSNameSNName(materialId);
-        if (map==null)return Result.fail("鎵句笉鍒拌鐗╂枡淇℃伅");
+    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);
-        Inspection inspection = new Inspection();
-        inspection.setId(IdWorker.getIdStr())
-                .setType(type)
-                .setInspectionStatus(0)
-                .setState(1)
-                .setVersion(1)
-                .setUserName("" + unmarshal.get("name"))
-                .setMaterialNum(Integer.valueOf("" + map.get("num")))
-                .setMaterialSupplier("" + map.get("supplier"))
-                .setMaterialName("" + map.get("m_name"))
-                .setMaterialLocation("" + map.get("location"))
-                .setMaterialBatch("" + map.get("batch"))
-                .setMaterialReelNumber("" + map.get("reel_number"))
-                .setSpecificationsSerialNumber("" + map.get("ss_name"))
-                .setSpecificationsVoltageLevel("" + map.get("voltage_level"))
-                .setSpecificationsCrossSection("" + map.get("cross_section"))
-                .setSpecificationsNumberOfCores("" + map.get("number_of_cores"))
-                .setSpecificationsInstruct("" + map.get("instruct"));
-        int judge1 = 0;
-        int judge2 = 0;
-        try {
-            judge1 = inspectionService.addInspection(inspection);
-            List<InspectionProductList> list2 = new ArrayList<>();
-            list.forEach(a -> {
-                InspectionProductList inspectionProductList = new InspectionProductList();
-                inspectionProductList.setName(a.getName())
-                        .setMethod(a.getMethod())
-                        .setUnit(a.getUnit())
-                        .setRequired(a.getRequired())
-                        .setInternal(a.getInternal())
-                        .setState(1)
-                        .setVersion(1)
-                        .setInspectionId(inspection.getId())
-                        .setUserId(Integer.parseInt("" + unmarshal.get("id")))
-                        .setCreateTime(new Date())
-                        .setUpdateTime(new Date());
-                list2.add(inspectionProductList);
-            });
-            judge2 = inspectionProductListService.addInspectionProductList(list2);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return Result.success(judge1 > 0 && judge2 > 0 ? "鎻愪氦鎴愬姛" : "鎻愪氦澶辫触", judge1 > 0 && judge2 > 0);
+        return Result.success(inspectionService.addInspection("" + unmarshal.get("name"), type));
     }
+
+    @ApiOperation("鏌ヨ鎵�鏈夋楠屽崟鍒楄〃")
+    @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)
+    })
+    @GetMapping("/selectAllInspection")
+    public Result selectAllInspection(int pageSize, int countSize, Integer state) {
+        return Result.success(inspectionService.selectAllInspection(pageSize, countSize, state));
+    }
+
+    @ApiOperation("鏌ヨ妫�楠屽崟閲岄潰鐨勭墿鏂欎俊鎭�")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "inspectionId", value = "鎶ユ鍗旾D", dataTypeClass = String.class, required = true),
+    })
+    @PostMapping("/selectMaterialByInsId")
+    public Result selectMaterialByInsId(String inspectionId) {
+        return Result.success(inspectionMaterialListService.selectInspectionMaterialListByInsId(inspectionId));
+    }
+
+    @ApiOperation("鏌ヨ鐗╂枡淇℃伅")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "pageSize", value = "椤垫暟", dataTypeClass = Integer.class, required = true),
+            @ApiImplicitParam(name = "countSize", value = "鏉℃暟/椤�", dataTypeClass = Integer.class, required = true)
+    })
+    @GetMapping("/selectMaterialLimit")
+    public Result selectMaterialLimit(int pageSize, int countSize) {
+        return Result.success(materialService.selectMaterialLimit(pageSize, countSize));
+    }
+
+    @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));
+    }
+
 }

--
Gitblit v1.9.3