| | |
| | | package com.mes.downworkstation.controller; |
| | | |
| | | |
| | | import com.mes.common.utils.RedisUtil; |
| | | import com.mes.downworkstation.entity.DownWorkstation; |
| | | import com.mes.downworkstation.entity.request.DownWorkRequest; |
| | | import com.mes.downworkstation.service.DownWorkstationService; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.utils.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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 javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | |
| | | */ |
| | | |
| | | @RestController |
| | | @Api(tags = "工位") |
| | | @RequestMapping("/api/unLoadGlass") |
| | | @Api(description = "工位") |
| | | @RequestMapping("/downWorkStation") |
| | | public class DownWorkstationController { |
| | | |
| | | @Autowired |
| | | private DownWorkstationService downWorkstationService; |
| | | @Autowired |
| | | private GlassInfoService glassInfoService; |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @ApiOperation("获取工位信息") |
| | | @GetMapping("/getone") |
| | | public ResponseEntity<?> getOneDownWorkstations() { |
| | | public Result getOneDownWorkstations() { |
| | | try { |
| | | List<DownWorkstation> data = downWorkstationService.getoneDownWorkstations(1,5); |
| | | List<DownWorkstation> data = downWorkstationService.getoneDownWorkstations(1, 6); |
| | | // 构建符合预期格式的响应数据 |
| | | Map<String, Object> responseData = new HashMap<>(); |
| | | responseData.put("code", 200); |
| | | responseData.put("msg", "成功"); |
| | | responseData.put("data", data); |
| | | // 返回 ResponseEntity 对象,包含响应数据和状态码 |
| | | return ResponseEntity.ok(responseData); |
| | | return Result.build(200, "获取工位信息成功", data); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | // 如果出现异常,返回错误信息 |
| | | Map<String, Object> errorResponse = new HashMap<>(); |
| | | errorResponse.put("code", 500); |
| | | errorResponse.put("msg", "服务器内部错误"); |
| | | return ResponseEntity.status(500).body(errorResponse); |
| | | return Result.build(500, "获取工位信息失败", 1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("获取流程卡号") |
| | | @GetMapping("/getflowCardId") |
| | | public ResponseEntity<Map<String, Object>> getflowCardId() { |
| | | Map<String, Object> responseData = new HashMap<>(); |
| | | public Result getflowCardId() { |
| | | |
| | | try { |
| | | List<Map<String, Object>> data = glassInfoService.getFlowCardId(); |
| | | responseData.put("code", 200); |
| | | responseData.put("msg", "成功"); |
| | | responseData.put("data", data); |
| | | return ResponseEntity.ok(responseData); |
| | | return Result.build(200, "获取流程卡号成功", data); |
| | | } catch (Exception e) { |
| | | responseData.put("code", 500); |
| | | responseData.put("msg", "失败"); |
| | | responseData.put("data", null); |
| | | return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseData); |
| | | return Result.build(500, "获取流程卡号失败", 1); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //绑定架子 |
| | | @ApiOperation("绑定架子") |
| | | //绑定架子 |
| | | @ApiOperation("绑定架子") |
| | | @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"); |
| | | public Result updateFlowCardId(@RequestBody DownWorkRequest request) { |
| | | |
| | | // 查询对应 flowCardId 的玻璃信息总数量 |
| | | int glassInfoCount = glassInfoService.getGlassInfoCountByFlowCardId(flowCardId); |
| | | // 绑定架子 |
| | | downWorkstationService.updateFlowCardIdAndCount(request.getFlowCardId(), request.getWorkstationId(), request.getLayer()); |
| | | |
| | | // 更新 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); |
| | | return Result.build(200, "绑定架子成功", 1); |
| | | } |
| | | |
| | | @ApiOperation("清除工位信息") |
| | | @PostMapping("/clear") |
| | | public ResponseEntity<Map<String, Object>> clearWorkstationInfo(@RequestBody Map<String, Object> requestData) { |
| | | public Result 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); |
| | | } |
| | | downWorkstationService.clearFlowCardId(workstationId); |
| | | return Result.build(200, "清除工位信息成功", 1); |
| | | |
| | | |
| | | // 构建响应数据 |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation("获取工位显示图1") |
| | | @GetMapping("/getwo") |
| | | public Result getwo() { |
| | | |
| | | try { |
| | | List<Map<String, Object>> data = downWorkstationService.getTotalGlassDimensionsByWorkstation(1, 3); |
| | | return Result.build(200, "获取工位显示图1成功", data); |
| | | } catch (Exception e) { |
| | | return Result.build(200, "获取工位显示图1失败", 1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("获取工位显示图2") |
| | | @GetMapping("/getwo2") |
| | | public Result getwo2() { |
| | | |
| | | try { |
| | | List<Map<String, Object>> data = downWorkstationService.getTotalGlassDimensionsByWorkstation(4, 6); |
| | | return Result.build(200, "获取工位显示图2成功", data); |
| | | } catch (Exception e) { |
| | | return Result.build(200, "获取工位显示图2失败", 1); |
| | | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(" 功能:对工位进行【启用/禁用】") |
| | | @PostMapping("/updateDownWorkstation") |
| | | @ResponseBody |
| | | public Result updateDownWorkstation(@RequestBody DownWorkstation downWorkstation) { |
| | | boolean isSucess = downWorkstationService.updateDownWorkstationstate(downWorkstation); |
| | | return Result.build(200, "更换成功", isSucess); |
| | | } |
| | | |
| | | @ApiOperation("关闭工位已满警报") |
| | | @PostMapping("/closeAlarmSignal") |
| | | @ResponseBody |
| | | public Result<String> closeAlarmSignal() { |
| | | return Result.build(200, "更换成功", downWorkstationService.closeAlarmSignal()); |
| | | } |
| | | |
| | | @ApiOperation("是否自动打印") |
| | | @PostMapping("/autoPrint") |
| | | public Result autoPrint(Boolean flag) { |
| | | downWorkstationService.autoPrint(flag); |
| | | return Result.build(200, "修改成功", redisUtil.getCacheObject("autoPrint")); |
| | | } |
| | | |
| | | |
| | | } |