From b612510f2479cc7fc04fbf9c4982742bee9e2ceb Mon Sep 17 00:00:00 2001
From: wang <3597712270@qq.com>
Date: 星期四, 18 四月 2024 16:55:46 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
---
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/controller/DownWorkstationController.java | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 114 insertions(+), 4 deletions(-)
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/controller/DownWorkstationController.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/controller/DownWorkstationController.java
index d46e65e..b08f73b 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/controller/DownWorkstationController.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downworkstation/controller/DownWorkstationController.java
@@ -1,21 +1,131 @@
package com.mes.downworkstation.controller;
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.mes.downworkstation.entity.DownWorkstation;
+import com.mes.downworkstation.service.DownWorkstationService;
+import com.mes.glassinfo.service.GlassInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
-import org.springframework.web.bind.annotation.RestController;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* <p>
- * 鍓嶇鎺у埗鍣�
+ * 鍓嶇鎺у埗鍣�
* </p>
*
* @author zhoush
* @since 2024-03-27
*/
+
@RestController
-@RequestMapping("/downWorkstation")
+@RequestMapping("/api/unLoadGlass")
public class DownWorkstationController {
+ @Autowired
+ private DownWorkstationService downWorkstationService;
+ @Autowired
+ private GlassInfoService glassInfoService;
+
+ @GetMapping("/getone")
+ public ResponseEntity<?> getOneDownWorkstations() {
+ try {
+ List<DownWorkstation> data = downWorkstationService.getoneDownWorkstations(1, 5);
+ // 鏋勫缓绗﹀悎棰勬湡鏍煎紡鐨勫搷搴旀暟鎹�
+ Map<String, Object> responseData = new HashMap<>();
+ responseData.put("code", 200);
+ responseData.put("msg", "鎴愬姛");
+ responseData.put("data", data);
+ // 杩斿洖 ResponseEntity 瀵硅薄锛屽寘鍚搷搴旀暟鎹拰鐘舵�佺爜
+ return ResponseEntity.ok(responseData);
+ } catch (Exception e) {
+ e.printStackTrace();
+ // 濡傛灉鍑虹幇寮傚父锛岃繑鍥為敊璇俊鎭�
+ Map<String, Object> errorResponse = new HashMap<>();
+ errorResponse.put("code", 500);
+ errorResponse.put("msg", "鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�");
+ return ResponseEntity.status(500).body(errorResponse);
+ }
+ }
+
+ @GetMapping("/gettwo")
+ public List<DownWorkstation> gettwoDownWorkstations() {
+ return downWorkstationService.getoneDownWorkstations(6, 10);
+ }
+
+ @GetMapping("/getflowCardId")
+ public ResponseEntity<Map<String, Object>> getflowCardId() {
+ Map<String, Object> responseData = new HashMap<>();
+ try {
+ List<Map<String, Object>> data = glassInfoService.getFlowCardId();
+ responseData.put("code", 200);
+ responseData.put("msg", "鎴愬姛");
+ responseData.put("data", data);
+ return ResponseEntity.ok(responseData);
+ } catch (Exception e) {
+ responseData.put("code", 500);
+ responseData.put("msg", "澶辫触");
+ responseData.put("data", null);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseData);
+ }
+ }
+
+
+ //缁戝畾鏋跺瓙
+ @PostMapping("/updateFlowCardId")
+ public ResponseEntity<Map<String, Object>> updateFlowCardId(@RequestBody Map<String, Object> requestData) {
+ // 浠� requestData 涓幏鍙栦紶鍏ョ殑 flowCardId
+ String flowCardId = (String) requestData.get("flowCardId");
+ int workstationId = (int) requestData.get("workstationId");
+
+ // 鏌ヨ瀵瑰簲 flowCardId 鐨勭幓鐠冧俊鎭�绘暟閲�
+ int glassInfoCount = glassInfoService.getGlassInfoCountByFlowCardId(flowCardId);
+
+ // 鏇存柊 down_workstation 琛ㄤ腑鐨勬�绘暟閲�
+ downWorkstationService.updateFlowCardIdAndCount(flowCardId, glassInfoCount, workstationId);
+
+ // 鏋勫缓鍝嶅簲鏁版嵁
+ Map<String, Object> responseData = new HashMap<>();
+ responseData.put("message", "updated successfully");
+ responseData.put("code", 200);
+ // 杩斿洖澶勭悊缁撴灉
+ return ResponseEntity.ok(responseData);
+ }
+
+
+ @PostMapping("/clear")
+ public ResponseEntity<Map<String, Object>> clearWorkstationInfo(@RequestBody Map<String, Object> requestData) {
+ // 璋冪敤 DownWorkstationService 涓殑鏂规硶娓呴櫎鎸囧畾宸ヤ綅ID鐨勪俊鎭�
+ int workstationId = (int) requestData.get("workstationId");
+
+ int totalWorkstations = downWorkstationService.getTotalQuantity(workstationId);
+ int downWorkstations = downWorkstationService.getRacksNumber(workstationId);
+
+
+ if (downWorkstations == totalWorkstations) {
+ downWorkstationService.clearFlowCardId(workstationId);
+ Map<String, Object> responseData = new HashMap<>();
+ responseData.put("message", "cleared successfully");
+ responseData.put("code", 200);
+ // 杩斿洖澶勭悊缁撴灉
+ return ResponseEntity.ok(responseData);
+ } else {
+ // 濡傛灉鎬绘暟閲忓拰钀芥灦鏁伴噺涓嶄竴鑷达紝杩斿洖閿欒鍝嶅簲
+ Map<String, Object> errorResponse = new HashMap<>();
+ errorResponse.put("message", "Total workstations count does not match down workstations count.");
+ errorResponse.put("code", 400);
+ return ResponseEntity.badRequest().body(errorResponse);
+ }
+
+
+ // 鏋勫缓鍝嶅簲鏁版嵁
+
+ }
+
+
}
--
Gitblit v1.8.0