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