| | |
| | | public class MesProTaskController { |
| | | |
| | | @Resource |
| | | private cn.iocoder.yudao.module.mes.service.pro.task.schedule.MesProBatchScheduleService batchScheduleService; |
| | | |
| | | @PostMapping("/auto-schedule/preview") |
| | | @Operation(summary = "批量一键排产预览(09–18点,排除周末和节假日)") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-task:create')") |
| | | public CommonResult<cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProBatchSchedulePreviewRespVO> previewBatchSchedule( |
| | | @Valid @RequestBody cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProBatchScheduleReqVO request) { |
| | | return success(batchScheduleService.preview(request)); |
| | | } |
| | | |
| | | @PostMapping("/auto-schedule") |
| | | @Operation(summary = "确认批量一键排产(重新校验预览,整批原子提交)") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-task:create')") |
| | | public CommonResult<java.util.Map<String, Object>> executeBatchSchedule( |
| | | @Valid @RequestBody cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProBatchScheduleReqVO request) { |
| | | return success(java.util.Map.of("taskIds", batchScheduleService.execute(request))); |
| | | } |
| | | |
| | | @Resource |
| | | private MesProTaskService taskService; |
| | | @Resource |
| | | private MesProWorkOrderService workOrderService; |
| | |
| | | private MesProTaskPauseRecordMapper pauseRecordMapper; |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | @Resource |
| | | private cn.iocoder.yudao.module.system.api.permission.PermissionApi permissionApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建生产任务") |
| | |
| | | @Parameter(name = "workstationId", description = "工作站编号", required = true), |
| | | @Parameter(name = "quantity", description = "排产数量", required = true) |
| | | }) |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-task:query')") |
| | | public CommonResult<java.util.Map<String, Object>> calculateDuration( |
| | | @RequestParam("workstationId") Long workstationId, |
| | | @RequestParam("quantity") BigDecimal quantity) { |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得生产任务") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-task:query')") |
| | | public CommonResult<MesProTaskRespVO> getTask(@RequestParam("id") Long id) { |
| | | MesProTaskDO task = taskService.getTask(id); |
| | | if (task == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得生产任务分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-task:query')") |
| | | public CommonResult<PageResult<MesProTaskRespVO>> getTaskPage(@Valid MesProTaskPageReqVO pageReqVO) { |
| | | PageResult<MesProTaskDO> pageResult = taskService.getTaskPage(pageReqVO); |
| | | return success(new PageResult<>(buildTaskRespVOList(pageResult.getList()), pageResult.getTotal())); |
| | |
| | | |
| | | @GetMapping("/pending-feedback-page") |
| | | @Operation(summary = "获得待报工台账分页", description = "已排产且仍有待报工数量的任务(状态=进行中)") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-task:query')") |
| | | public CommonResult<PageResult<MesProTaskRespVO>> getPendingFeedbackPage(@Valid MesProTaskPageReqVO pageReqVO) { |
| | | // 根据当前登录人用户id 获取对应的生产工单列表 |
| | | pageReqVO.setAssigneeUserId(cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId()); |
| | | Long loginUserId = cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId(); |
| | | // 如果当前登录人不是超级管理员,则仅查询分配给自己的生产工单 |
| | | if (loginUserId != null && !permissionApi.hasAnyRoles(loginUserId, cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum.SUPER_ADMIN.getCode())) { |
| | | pageReqVO.setAssigneeUserId(loginUserId); |
| | | } |
| | | PageResult<MesProTaskDO> pageResult = taskService.getPendingFeedbackPage(pageReqVO); |
| | | List<MesProTaskRespVO> respVOList = buildTaskRespVOList(pageResult.getList()); |
| | | |
| | |
| | | |
| | | @GetMapping("/gantt-list") |
| | | @Operation(summary = "获得甘特图任务列表", description = "后端组装工单=project + 任务=task 列表") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-task:query')") |
| | | public CommonResult<List<GanttDataRespVO>> listGanttTaskList(@Valid MesProWorkOrderPageReqVO reqVO) { |
| | | // 1.1 查询匹配的工单(不分页) |
| | | reqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| | |
| | | convertSet(allTasks, MesProTaskDO::getProcessId)); |
| | | // 2.2 组装甘特图数据 |
| | | List<GanttDataRespVO> ganttData = new java.util.ArrayList<>(); |
| | | Set<Long> visibleWorkOrderIds = convertSet(workOrders, MesProWorkOrderDO::getId); |
| | | for (MesProWorkOrderDO workOrder : workOrders) { |
| | | // 2.2.a 工单 -> project 行 |
| | | MesMdItemDO item = itemMap.get(workOrder.getProductId()); |
| | |
| | | .setQuantity(workOrder.getQuantity()) |
| | | .setDuration(0L) |
| | | .setProgress(calcProgress(workOrder.getQuantityProduced(), workOrder.getQuantity())); |
| | | if (ObjUtil.notEqual(workOrder.getParentId(), MesProWorkOrderDO.PARENT_ID_NULL)) { |
| | | if (workOrder.getParentId() != null |
| | | && !Objects.equals(workOrder.getParentId(), MesProWorkOrderDO.PARENT_ID_NULL) |
| | | && !Objects.equals(workOrder.getParentId(), workOrder.getId()) |
| | | && visibleWorkOrderIds.contains(workOrder.getParentId())) { |
| | | woData.setParent(MesBizTypeConstants.PRO_WORKORDER + "_" + workOrder.getParentId()); |
| | | } |
| | | ganttData.add(woData); |