| | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.ArrayList; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_MPS_MERGE_ISSUE_DISABLED; |
| | | |
| | | @Tag(name = "管理后台 - MES 生产主计划") |
| | | @RestController |
| | | @RequestMapping("/mes/pro-mps") |
| | | @Validated |
| | | @Slf4j |
| | | public class MesProMpsController { |
| | | |
| | | @Resource |
| | |
| | | @Operation(summary = "合并下发生产主计划") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-mps:merge-issue')") |
| | | public CommonResult<Long> mergeAndIssueMps(@RequestBody List<Long> mpsIds) { |
| | | return success(mpsService.mergeAndIssueMps(mpsIds)); |
| | | // 旧入口保留用于明确提示旧客户端升级,禁止绕过新的逐条下发权限校验。 |
| | | throw exception(PRO_MPS_MERGE_ISSUE_DISABLED); |
| | | } |
| | | |
| | | @PostMapping("/batch-issue") |
| | | @Operation(summary = "批量逐条下发生产主计划") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-mps:issue')") |
| | | public CommonResult<List<BatchIssueResult>> batchIssueMps(@RequestBody @NotEmpty List<@NotNull Long> ids) { |
| | | List<BatchIssueResult> results = new ArrayList<>(); |
| | | for (Long id : ids) { |
| | | BatchIssueResult result = new BatchIssueResult(); |
| | | result.setMpsId(id); |
| | | try { |
| | | result.setWorkOrderId(mpsService.issueMps(id)); |
| | | } catch (ServiceException ex) { |
| | | result.setError(ex.getMessage()); |
| | | } catch (Exception ex) { |
| | | log.error("[batchIssueMps] 下发失败,mpsId={}", id, ex); |
| | | result.setError("下发失败,请联系管理员查看日志"); |
| | | } |
| | | results.add(result); |
| | | } |
| | | return success(results); |
| | | } |
| | | |
| | | @Data |
| | | public static class BatchIssueResult { |
| | | private Long mpsId; |
| | | private Long workOrderId; |
| | | private String error; |
| | | } |
| | | |
| | | @PostMapping("/cancel") |
| | |
| | | }); |
| | | } |
| | | |
| | | } |
| | | } |