| | |
| | | import com.mes.service.DownWorkstationService;
|
| | | import com.mes.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 java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | @RestController
|
| | | @RequestMapping("/downWorkstation")
|
| | | @RequestMapping("/api/downWorkstation")
|
| | | public class DownWorkstationController {
|
| | |
|
| | | @Autowired
|
| | |
| | | private GlassInfoService glassInfoService;
|
| | |
|
| | | @GetMapping("/getone")
|
| | | public List<DownWorkstation> getoneDownWorkstations() {
|
| | | return downWorkstationService.getoneDownWorkstations();
|
| | | public ResponseEntity<?> getOneDownWorkstations() {
|
| | | try {
|
| | | List<DownWorkstation> data = downWorkstationService.getoneDownWorkstations();
|
| | | // 构建符合预期格式的响应数据
|
| | | 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")
|
| | |
| | | return downWorkstationService.gettwoDownWorkstations();
|
| | | }
|
| | | @GetMapping("/getflowCardId")
|
| | | public List<Map<String, Object>> getflowCardId() {
|
| | | return downWorkstationService.getflowCardId();
|
| | | public ResponseEntity<Map<String, Object>> getflowCardId() {
|
| | | Map<String, Object> responseData = new HashMap<>();
|
| | | try {
|
| | | List<Map<String, Object>> data = downWorkstationService.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 String updateFlowCardId(@RequestBody Map<String, Object> requestData) {
|
| | | 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 表中的总数量
|
| | | glassInfoService.updateFlowCardIdAndCount(flowCardId, glassInfoCount);
|
| | | glassInfoService.updateFlowCardIdAndCount(flowCardId, glassInfoCount, workstationId);
|
| | |
|
| | | // 返回处理结果,比如成功或失败信息
|
| | | return "updated successfully";
|
| | | // 构建响应数据
|
| | | Map<String, Object> responseData = new HashMap<>();
|
| | | responseData.put("message", "updated successfully");
|
| | | responseData.put("code", 200);
|
| | | // 返回处理结果
|
| | | return ResponseEntity.ok(responseData);
|
| | | }
|
| | |
|
| | |
|
| | | @DeleteMapping("/clear/{workstationId}")
|
| | | public String clearWorkstationInfo(@PathVariable("workstationId") int workstationId) {
|
| | | @PostMapping("/clear")
|
| | | public ResponseEntity<Map<String, Object>> clearWorkstationInfo(@RequestBody Map<String, Object> requestData) {
|
| | | // 调用 DownWorkstationService 中的方法清除指定工位ID的信息
|
| | | downWorkstationService.clearFlowCardId(workstationId);
|
| | | // 返回处理结果,比如成功或失败信息
|
| | | return "cleared successfully";
|
| | | 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);
|
| | | }
|
| | |
|
| | |
|
| | | // 构建响应数据
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | }
|