Browse Source

对接信产待办接口

tags/24080901
WendyYang 8 months ago
parent
commit
a41a3ecb72
5 changed files with 66 additions and 29 deletions
  1. +32
    -28
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java
  2. +26
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/todo/dto/MhTodoRequestDTO.java
  3. +2
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/sys/entity/MhTodoRecord.java
  4. +3
    -0
      hz-pm-api/src/main/resources/application-dev.yml
  5. +3
    -0
      hz-pm-api/src/main/resources/application-prod.yml

+ 32
- 28
hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java View File

@@ -6,18 +6,15 @@ 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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.external.todo.dto.AddSingleWkHandleDTO;
import com.hz.pm.api.external.todo.dto.MhTodoRequestDTO;
import com.hz.pm.api.external.todo.dto.MhTodoRetDTO;
import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum;
import com.hz.pm.api.sys.entity.MhTodoRecord;
import com.hz.pm.api.sys.service.IMhTodoRecordService;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.CollUtils;
@@ -27,7 +24,10 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

/**
* @author 王仁康
@@ -39,12 +39,6 @@ import java.util.*;
public class MHTodoClient {

/**
* 外部系统域名
*/
@Value("${sms.client-url:}")
private String todoUrl;

/**
* 发送待办接口地址
*/
private static final String TODO_ADD = "/single_wk_handle/addWkhandle";
@@ -54,24 +48,37 @@ public class MHTodoClient {
*/
private static final String TODO_COMPLETE = "/single_wk_handle/completeHandle";

private static final String WK_HANDLE_ID = "wkhandleId";

private static final TypeReference<MhTodoRetDTO> TYPE_REF = new TypeReference<MhTodoRetDTO>() {
};

//==================================================================================================================

private final IMhTodoRecordService todoRecordService;


/**
* 外部系统域名
*/
@Value("${mh.api-host:}")
private String mhApiHost;

@Transactional(rollbackFor = Exception.class)
public void addTodo(Object paramObj, UserFullInfoDTO receiver, MHTodoTypeEnum type, String bizId, String content) {
String url = todoUrl + TODO_ADD;
Map<String, Object> map = new HashMap<>(8);
String url = mhApiHost + TODO_ADD;
String paramObjs = JSON.toJSONString(paramObj);
map.put("params", paramObjs);
map.put("wkContent", content);
map.put("wkType", type.name());
map.put("wkUser", receiver.getMhUserId());
log.info("添加新创待办:{}", map);
String responseResult = HttpUtil.post(url, JSON.toJSONString(map));
MhTodoRetDTO retData = JSON.parseObject(responseResult, new TypeReference<MhTodoRetDTO>() {
});
MhTodoRequestDTO todoReq = MhTodoRequestDTO.builder()
.wkContent(content)
.wkType(type.name())
.params(paramObjs)
.wkUser(receiver.getMhUserId())
.build();
log.info("添加新创待办:{}", todoReq);
String responseResult = HttpUtil.post(url, JSON.toJSONString(todoReq));
MhTodoRetDTO retData = JSON.parseObject(responseResult, TYPE_REF);
if (retData.getCode() != 0 || StrUtil.isBlank(retData.getData())) {
log.warn("发送待办失败:{} {}", map, retData);
log.warn("发送待办失败:{} {}", todoReq, retData);
throw BizException.wrap("发送待办失败");
}
MhTodoRecord todo = new MhTodoRecord();
@@ -92,15 +99,12 @@ public class MHTodoClient {
* @param wkhandleId 待办ID
*/
public void complete(String wkhandleId) {
String url = todoUrl + TODO_COMPLETE;
HashMap<String, Object> map = new HashMap<>();
map.put("wkhandleId", wkhandleId);
String url = mhApiHost + TODO_COMPLETE;
// 发送PUT请求
HttpRequest request = HttpUtil.createRequest(Method.PUT, url)
.form("wkhandleId", wkhandleId);
.form(WK_HANDLE_ID, wkhandleId);
try (HttpResponse response = request.execute()) {
MhTodoRetDTO retData = JSON.parseObject(response.body(), new TypeReference<MhTodoRetDTO>() {
});
MhTodoRetDTO retData = JSON.parseObject(response.body(), TYPE_REF);
boolean state = Boolean.parseBoolean(retData.getData());
if (!state) {
log.error("待办完成失败:{} {}", wkhandleId, retData);


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

@@ -0,0 +1,26 @@
package com.hz.pm.api.external.todo.dto;

import lombok.Builder;
import lombok.Data;

/**
* <p>
* MhTodoRequestDTO
* </p>
*
* @author WendyYang
* @since 10:08 2024/3/14
*/
@Data
@Builder
public class MhTodoRequestDTO {

private String wkType;

private String wkUser;

private String wkContent;

private String params;

}

+ 2
- 1
hz-pm-api/src/main/java/com/hz/pm/api/sys/entity/MhTodoRecord.java View File

@@ -64,7 +64,8 @@ public class MhTodoRecord implements Serializable {
public enum TodoStatusEnum {

PENDING(1, "待处理"),
HANDED(2, "已处理");
HANDED(2, "已处理"),
DELETED(3, "已删除");

private final Integer code;
private final String val;


+ 3
- 0
hz-pm-api/src/main/resources/application-dev.yml View File

@@ -249,6 +249,9 @@ mh:
sso:
client-id: ningda-74a5e5da-3bc3-414a-b9e6-004b7d87e310
client-secret: ningda-df746ce4-0c79-4242-b3c7-90ff8630c9742c6727cd-3ae7-48ae-87ad-2b39188ebabd
zwdd-work-notice:
client-id: ningda-74a5e5da-3bc3-414a-b9e6-004b7d87e310
client-secret: ningda-df746ce4-0c79-4242-b3c7-90ff8630c9742c6727cd-3ae7-48ae-87ad-2b39188ebabd
api-host: https://hzszxc.hzswb.cn:8443/test/mh-gateway/auth-single
expert-qr-code-url: https://jiema.wwei.cn/uploads/2023/12/28/658d7a3f15f06.jpg
file:


+ 3
- 0
hz-pm-api/src/main/resources/application-prod.yml View File

@@ -247,6 +247,9 @@ mh:
sso:
client-id: ningda-74a5e5da-3bc3-414a-b9e6-004b7d87e310
client-secret: ningda-df746ce4-0c79-4242-b3c7-90ff8630c9742c6727cd-3ae7-48ae-87ad-2b39188ebabd
zwdd-work-notice:
client-id: ningda-74a5e5da-3bc3-414a-b9e6-004b7d87e310
client-secret: ningda-df746ce4-0c79-4242-b3c7-90ff8630c9742c6727cd-3ae7-48ae-87ad-2b39188ebabd
api-host: http://10.54.38.13:8081/mh-gateway/auth-single
expert-qr-code-url: http://10.54.38.13:8081/mh-gateway/problem/expert/getExpertQrCode
file:


Loading…
Cancel
Save