Browse Source

Merge remote-tracking branch 'origin/dev' into dev

tags/24080901
WendyYang 11 months ago
parent
commit
825d067887
3 changed files with 138 additions and 0 deletions
  1. +83
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java
  2. +32
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java
  3. +23
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/TodoDto.java

+ 83
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/TodoServiceClient.java View File

@@ -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<String,Object> 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<TodoDto>() {
});
// return JSON.parseObject(responseResult, new TypeReference<HashMap<String, String>>() {
// }).get("data");
return todoDto;
}

/**
* 完成待办
* @param wkhandleId 待办ID
*/
public TodoDto completeTodo(String wkhandleId){
String url = todoUrl + TODO_COMPLETE;
HashMap<String,Object> 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<TodoDto>() {
});
return todoDto;
}


}

+ 32
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/AddSingleWkHandleDTO.java View File

@@ -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;

}

+ 23
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/TodoDto.java View File

@@ -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;
}

Loading…
Cancel
Save