| | |
| | | package com.mes.downworkstation.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | 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.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * 前端控制器 |
| | | * 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author zhoush |
| | | * @since 2024-03-27 |
| | | */ |
| | | |
| | | @RestController |
| | | @RequestMapping("/downWorkstation") |
| | | @Api(description = "工位") |
| | | @RequestMapping("/downWorkStation") |
| | | public class DownWorkstationController { |
| | | |
| | | @Autowired |
| | | private DownWorkstationService downWorkstationService; |
| | | @Autowired |
| | | private GlassInfoService glassInfoService; |
| | | |
| | | @ApiOperation("获取工位信息") |
| | | @GetMapping("/getone") |
| | | public Result getOneDownWorkstations() { |
| | | try { |
| | | List<DownWorkstation> data = downWorkstationService.getoneDownWorkstations(1, 6); |
| | | // 构建符合预期格式的响应数据 |
| | | return Result.build(200, "获取工位信息成功", data); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | // 如果出现异常,返回错误信息 |
| | | return Result.build(500, "获取工位信息失败", 1); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("获取流程卡号") |
| | | @GetMapping("/getflowCardId") |
| | | public Result getflowCardId() { |
| | | |
| | | try { |
| | | List<Map<String, Object>> data = glassInfoService.getFlowCardId(); |
| | | return Result.build(200, "获取流程卡号成功", data); |
| | | } catch (Exception e) { |
| | | return Result.build(500, "获取流程卡号失败", 1); |
| | | } |
| | | } |
| | | |
| | | |
| | | //绑定架子 |
| | | @ApiOperation("绑定架子") |
| | | @PostMapping("/updateFlowCardId") |
| | | public Result updateFlowCardId(@RequestBody DownWorkRequest request) { |
| | | |
| | | // 绑定架子 |
| | | downWorkstationService.updateFlowCardIdAndCount(request.getFlowCardId(), request.getWorkstationId(), request.getLayer()); |
| | | |
| | | return Result.build(200, "绑定架子成功", 1); |
| | | } |
| | | |
| | | @ApiOperation("清除工位信息") |
| | | @PostMapping("/clear") |
| | | 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); |
| | | return Result.build(200, "清除工位信息成功", 1); |
| | | } else { |
| | | // 如果总数量和落架数量不一致,返回错误响应 |
| | | return Result.build(500, "清除工位信息失败", 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); |
| | | } |
| | | |
| | | |
| | | } |
| | | |