From e72b3ab95aace19535fe596897822f0e334de5d6 Mon Sep 17 00:00:00 2001
From: “zhuo” <“zhuo@itcast.cn”>
Date: 星期五, 11 八月 2023 18:00:23 +0800
Subject: [PATCH] 8-11提交代码
---
inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/InspectionController.java | 192 +++++++++++++++++++++++++++--------------------
1 files changed, 110 insertions(+), 82 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 1d35b2e..027e223 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
@@ -1,44 +1,37 @@
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.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.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.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
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 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
*/
-@ApiModel(value = "妫�楠屾ā鍧�")
+@Api(tags = "璇曢獙绠$悊-->妫�楠岀敵璇�")
@RestController
@RequestMapping("/inspection")
public class InspectionController {
@@ -46,69 +39,104 @@
@Autowired
private InspectionService inspectionService;
- @Autowired
- private ProductService productService;
+ @Resource
+ RawMaterialService rawMaterialService;
- @Autowired
- private SpecificationsService specificationsService;
+ @Resource
+ LinkBasicInformationService linkBasicInformationService;
- @Autowired
- private InspectionProductListService inspectionProductListService;
-
- @ApiOperation("娣诲姞妫�楠岀敵璇峰崟")
+ @ApiOperation(value = "鏌ヨ妫�楠岀敵璇峰崟鍒楄〃")
@ApiImplicitParams(value = {
- @ApiImplicitParam(name = "materialId", value = "鐗╂枡淇℃伅id", dataTypeClass = Integer.class, required = true),
+ @ApiImplicitParam(name = "pageSize", value = "椤垫暟", dataTypeClass = Integer.class, required = true),
+ @ApiImplicitParam(name = "countSize", value = "鏉℃暟/椤�", dataTypeClass = Integer.class, required = true),
+ @ApiImplicitParam(name = "message", value = "鐢宠鍗曞彿/鍘熸潗鏂欏悕绉�", dataTypeClass = String.class)
})
- @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("鎵句笉鍒拌鐗╂枡淇℃伅");
+ @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(value = "鏌ヨ鎵�鏈夋姤妫�")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "type", value = "绫诲瀷", dataTypeClass = Integer.class, required = true)
+ })
+ @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(value = "閫夋嫨鍘熸潗鏂欐姤妫�")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "id", value = "鍘熸潗鏂欐姤妫�鍗昳d", dataTypeClass = Integer.class, required = true),
+ @ApiImplicitParam(name = "startTime", value = "妫�楠屽紑濮嬫棩鏈�", dataTypeClass = String.class, required = true),
+ @ApiImplicitParam(name = "endTime", 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));
+ }
+
+
+ @ApiOperation(value = "閫夋嫨濮旀墭鎶ユ鍜屾牱鍝�")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "bid", value = "濮旀墭鎶ユ鍗昳d", dataTypeClass = Integer.class, required = true),
+ @ApiImplicitParam(name = "did", value = "濮旀墭鎶ユ鏍峰搧id", dataTypeClass = Integer.class, required = true)
+ })
+
+
+ @GetMapping("/selectLinkByid")
+ public Result selectLinkByid(Integer bid, Integer did) {
+ return Result.success(linkBasicInformationService.selectLinkByid(bid, did));
+ }
+
+
+ @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);
- 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.addInspect((Integer) unmarshal.get("id"), inspectionVo));
}
+
+ @ApiOperation(value = "鏍规嵁妫�楠屽崟id鏌ヨ鍘熸潗鏂欐楠屽崟璇︽儏")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "id", value = "妫�楠屽崟id", dataTypeClass = Integer.class, required = true)
+ })
+ @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));
+ }
+
}
+
--
Gitblit v1.9.3