From b1495ca1b21991cd8f2e4ca8661dcd15e7a9ea44 Mon Sep 17 00:00:00 2001 From: wangrenkang <1173308176@qq.com> Date: Wed, 3 Jan 2024 11:21:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=85=E5=8A=9E=E4=BA=8B=E9=A1=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3:=E6=B7=BB=E5=8A=A0=E5=BE=85=E5=8A=9E=20=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=BE=85=E5=8A=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hz/pm/api/external/todo/TodoServiceClient.java | 83 ++++++++++++++++++++++ .../external/todo/dto/AddSingleWkHandleDTO.java | 32 +++++++++ .../com/hz/pm/api/external/todo/dto/TodoDto.java | 23 ++++++ 3 files changed, 138 insertions(+) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/TodoDto.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java new file mode 100644 index 0000000..416e5fd --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java @@ -0,0 +1,83 @@ +package com.hz.pm.api.external.todo; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import cn.hutool.http.Method; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.hz.pm.api.external.todo.dto.AddSingleWkHandleDTO; +import com.hz.pm.api.external.todo.dto.TodoDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author 王仁康 + * @date 2024-01-02 16:55:51 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class TodoServiceClient { + + /** + * 外部系统域名 + */ + @Value("${sms.client-url:}") + private String todoUrl; + + // 发送待办 + public static final String TODO_ADD = "/single_wk_handle/addWkhandle"; + + // 完成待办 + public static final String TODO_COMPLETE = "/single_wk_handle/completeHandle"; + + + /** + * 添加待办方法 + * @param addSingleWkHandleDTO + * @return 接口返回待办ID + */ + public TodoDto addTodo(AddSingleWkHandleDTO addSingleWkHandleDTO) { + String url = todoUrl + TODO_ADD; + Map map = new HashMap<>(); + JSONObject json = (JSONObject) JSONObject.toJSON(addSingleWkHandleDTO.getParams()); + String jsonString = JSON.toJSONString(json); + map.put("params", jsonString); + map.put("wkContent",addSingleWkHandleDTO.getWkContent()); + map.put("wkType",addSingleWkHandleDTO.getWkType()); + map.put("wkUser",addSingleWkHandleDTO.getWkUser()); + String responseResult = HttpUtil.post(url, JSON.toJSONString(map)); + TodoDto todoDto = JSON.parseObject(responseResult, new TypeReference() { + }); +// return JSON.parseObject(responseResult, new TypeReference>() { +// }).get("data"); + return todoDto; + } + + /** + * 完成待办 + * @param wkhandleId 待办ID + */ + public TodoDto completeTodo(String wkhandleId){ + String url = todoUrl + TODO_COMPLETE; + HashMap map = new HashMap<>(); + map.put("wkhandleId",wkhandleId); + // 发送PUT请求 + HttpRequest request = HttpUtil.createRequest(Method.PUT,url) + .form("wkhandleId",wkhandleId); + HttpResponse response = request.execute(); + String responseBody = response.body(); + TodoDto todoDto = JSON.parseObject(responseBody, new TypeReference() { + }); + return todoDto; + } + + +} \ No newline at end of file diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java new file mode 100644 index 0000000..5ed6fb2 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java @@ -0,0 +1,32 @@ +package com.hz.pm.api.external.todo.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author 王仁康 + * @date 2024-01-02 16:55:51 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AddSingleWkHandleDTO implements Serializable { + + private static final long serialVersionUID = -2067546352159912820L; + + // 待办参数,ObjectJson字符串 + private Object params; + + // 待办内容,默认取待办配置中的 + private String wkContent; + + // 待办类型 + private String wkType; + + // 待办用户 + private String wkUser; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/TodoDto.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/TodoDto.java new file mode 100644 index 0000000..75cb99f --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/TodoDto.java @@ -0,0 +1,23 @@ +package com.hz.pm.api.external.todo.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author 王仁康 + * @date 2024-01-02 17:04:09 + */ +@AllArgsConstructor +@Data +public class TodoDto implements Serializable { + + private static final long serialVersionUID = 241303725133613373L; + + private Integer code; + + private String msg; + + private String data; +}