| | |
| | | package com.example.erp.controller.pp; |
| | | |
| | | import com.example.erp.dto.pp.MesCalculateDTO; |
| | | import org.springframework.core.io.InputStreamResource; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.common.Result; |
| | |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.sql.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | @RestController |
| | | @Api(value="优化管理controller",tags={"优化管理操作接口"}) |
| | |
| | | public Result getProcessCard( |
| | | @PathVariable String projectNo){ |
| | | return Result.success(glassOptimizeService.getProcessCardSv(projectNo)); |
| | | } |
| | | |
| | | @ApiOperation("工程信息查询接口") |
| | | @PostMapping ("/getProjectState/{projectNo}") |
| | | public Result getProjectState( |
| | | @PathVariable String projectNo){ |
| | | return Result.success(glassOptimizeService.getProjectState(projectNo)); |
| | | } |
| | | |
| | | //库存信息 |
| | |
| | | @PathVariable Integer states, |
| | | @PathVariable Integer code |
| | | ) throws JsonProcessingException { |
| | | if (glassOptimizeService.updateProjectState(projectNumber, state,states,code)) { |
| | | return Result.success(); |
| | | } else { |
| | | throw new ServiceException(Constants.Code_500, "修改失败"); |
| | | |
| | | try { |
| | | if (glassOptimizeService.updateProjectState(projectNumber, state, states, code)) { |
| | | return Result.success(); |
| | | } else { |
| | | throw new ServiceException(Constants.Code_500, "修改失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | return Result.error("201", e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Result.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @PostMapping("/mesCalculate") |
| | | public ResponseEntity<Map<String, Object>> receiveOptimizeRequest( |
| | | @RequestBody MesCalculateDTO mesCalculateDTO) { |
| | | |
| | | Map<String, Object> response = new HashMap<>(); |
| | | |
| | | try { |
| | | // 立即返回接收成功的响应 |
| | | response.put("code", "200"); |
| | | response.put("msg", "success"); |
| | | response.put("data", true); |
| | | |
| | | // 使用CompletableFuture 异步处理计算任务 |
| | | CompletableFuture.runAsync(() -> { |
| | | try { |
| | | glassOptimizeService.processExternalOptimizeRequest(mesCalculateDTO); |
| | | } catch (Exception e) { |
| | | System.err.println("异步处理优化请求时发生错误: " + e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | return ResponseEntity.ok(response); |
| | | } catch (Exception e) { |
| | | response.put("code", 201); |
| | | response.put("msg", e.getMessage()); |
| | | response.put("data", false); |
| | | return ResponseEntity.status(500).body(response); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation("mes工程生产不可见接口") |
| | | @PostMapping("/issuingCancelProject") |
| | | public Result issuingCancelProject(@RequestBody String projectNo){ |
| | | return Result.success(glassOptimizeService.issuingCancelProject(projectNo)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |