package com.api.aiyh_guijiu.web; import aiyh.utils.ApiResult; import aiyh.utils.zwl.common.ToolUtil; import com.api.aiyh_guijiu.service.WorkflowQueueService; import io.swagger.v3.oas.annotations.parameters.RequestBody; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import java.util.Map; /** * @author EBU7-dev1-ayh * @create 2021/9/3 0003 12:08 * 查询同一时段内的指定流程 */ @Path("/change2Workflow") public class ConflictWorkflowController { private final WorkflowQueueService workflowQueueService = new WorkflowQueueService(); private final ToolUtil toolUtil = new ToolUtil(); private final String className = "QueryWorkflow"; /** * 查询需要前端判断添加水印的流程和流程字段 * * @return 前端必要的配置参数 */ @Path("/queryWatermark/{workflowId}") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String queryWatermark(@PathParam("workflowId") String workflowId) { try { return workflowQueueService.getWatermarkConfig(workflowId); }catch (Exception e){ toolUtil.writeErrorLog(className + "======> queryWatermark",e.toString()); return ApiResult.error(e.toString()); } } /** * 图片添加水印请求 * * @param request 请求体 * @param response 响应对象 * @param param 请求参数 * @return 添加水印后的图片信息 */ @Path("/addWatermark") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String addWatermark(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { User user = HrmUserVarify.getUser(request, response); try { return workflowQueueService.addWaterMark(user, param); }catch (Exception e){ toolUtil.writeErrorLog(className + "======> addWatermark",e.toString()); return ApiResult.error(e.toString()); } } /** * 查询流程冲突前端需要拦截和必要的字段 * * @param workflowId 流程id * @return 配置信息 */ @Path("/queryWorkflow/config/{workflowId}") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String queryWorkflowConfig(@PathParam("workflowId") String workflowId) { try { return workflowQueueService.getWorkflowConflictConfig(workflowId); }catch (Exception e){ toolUtil.writeErrorLog(className + "======> queryWorkflowConfig",e.toString()); return ApiResult.error(e.toString()); } } /** * 查询冲突流程 * * @param param 请求参数 * @return 冲突流程的基本数据 */ @Path("/queryConflict") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String queryWorkflowQueue(@RequestBody Map param) { try { return workflowQueueService.getWorkflowQueue(param); }catch (Exception e){ toolUtil.writeErrorLog(className + "======> queryWorkflowQueue",e.toString()); e.printStackTrace(); return ApiResult.error(e.toString()); } } /** * 判断图片是否经过ps * * @param imgIds 需要判断的图片 * @return 查询ps的结果 */ @Path("/picIsPs/{imgIds}") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String queryPicIsPs(@PathParam("imgIds") String imgIds) { try { return workflowQueueService.getPicIsPs(imgIds); }catch (Exception e){ toolUtil.writeErrorLog(className + "======> queryPicIsPs",e.toString()); return ApiResult.error(e.toString()); } } /** * 查询需要校验ps的节点等信息 * * @return 配置信息 */ @Path("/queryPicPsConfig/{workflowId}") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String queryPicPsConfig(@PathParam("workflowId") String workflowId) { try { return workflowQueueService.getPicIsPsConfig(workflowId); }catch (Exception e){ toolUtil.writeErrorLog(className + "======> queryPicPsConfig",e.toString()); return ApiResult.error(e.toString()); } } }