Compare commits

...

4 Commits

Author SHA1 Message Date
fang a84a366703 Merge remote-tracking branch 'origin/main' into main 2024-11-18 14:53:15 +08:00
fang 9277d7f052 待办 2024-11-18 14:52:07 +08:00
fang e7016f3387 待办_1 2024-11-14 12:14:55 +08:00
fang 45bc094c89 待办_1 2024-11-14 11:02:45 +08:00
6 changed files with 150 additions and 76 deletions

View File

@ -12,5 +12,5 @@ public class ToDoCenterConstant {
public static String URI_SEND_finish = "/bpm/task/api/finishByRecordIdAndUserId.dhtml";
public static String URI_send_deleteP = "/oa/task/api/deletePendingByRecordIdAndUserId.dhtml";
public static String URI_send_deleteP = "/bpm/task/api/deletePendingByRecordIdAndUserId.dhtml";
}

View File

@ -28,28 +28,37 @@ public class CreateToDoHandler {
}
return _CreateToDoHandler;
}
public boolean sendCreateToDo(BacklogMessage messageInfo) {
public boolean sendCreateToDo(String messageInfo,String title) {
logger.info("###进入待办推送接口数据组装");
try {
//body
JSONObject jsonObject2 = new JSONObject();
/* JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("params",messageInfo);
String jsonMessage = jsonObject2.toJSONString();
String jsonMessage = jsonObject2.toJSONString();*/
//调用接口结果
String result = RequestClient.getInstance().callService(ToDoCenterConstant.URI_send_addNew,jsonMessage);
String result = RequestClient.getInstance().callService(ToDoCenterConstant.URI_send_addNew,messageInfo);
logger.info("###接口返回结果"+result);
//接口调用结果
JSONObject jsonObject = JSONObject.parseObject(result);
if(Objects.equals("success",jsonObject.getString("status"))){
//发送成功
//调用保存操作
RequestClient.getInstance().saveCreateToDo(messageInfo.getTitle(),ToDoCenterConstant.URI_send_addNew,true,result,jsonMessage);
return true;
if(jsonObject == null){
RequestClient.getInstance().saveCreateToDo(title,ToDoCenterConstant.URI_send_addNew,false,result,messageInfo);
logger.info("###响应报文为空");
return false;
}else{
//调用保存操作
RequestClient.getInstance().saveCreateToDo(messageInfo.getTitle(),ToDoCenterConstant.URI_send_addNew,false,result,jsonMessage);
//发送失败
logger.error("##接口调通失败");
return false;
if(Objects.equals("success",jsonObject.getString("status"))){
//发送成功
//调用保存操作
RequestClient.getInstance().saveCreateToDo(title,ToDoCenterConstant.URI_send_addNew,true,result,messageInfo);
return true;
}else{
//调用保存操作
RequestClient.getInstance().saveCreateToDo(title,ToDoCenterConstant.URI_send_addNew,false,result,messageInfo);
//发送失败
logger.error("###接口调通失败");
return false;
}
}
} catch (Exception e) {
logger.error("###调用接口失败:"+e.getMessage(),e);
return false;

View File

@ -19,40 +19,49 @@ public class DealToDoHandler {
private static DealToDoHandler _DealToDoHandler;
public static synchronized DealToDoHandler get_DealToDoHandler(){
if(_DealToDoHandler == null){
_DealToDoHandler = new DealToDoHandler();
public static synchronized DealToDoHandler get_DealToDoHandler() {
if (_DealToDoHandler == null) {
_DealToDoHandler = new DealToDoHandler();
}
return _DealToDoHandler;
}
public boolean sendDealToDo(Long appRecordId,String userId) {
public boolean sendDealToDo(Long appRecordId, String userId) {
try {
//body
JSONObject jsonObject2 = new JSONObject();
JSONObject jsonObject_1 = new JSONObject();
// JSONObject jsonObject2 = new JSONObject();
/* JSONObject jsonObject_1 = new JSONObject();
jsonObject_1.put("appRecordId", appRecordId);
jsonObject_1.put("userId",userId);
jsonObject2.put("params",jsonObject_1);
String jsonMessage = jsonObject2.toJSONString();
jsonObject_1.put("userId",userId);*/
String part = " {\"appRecordId\": " + appRecordId + ",\"userId\": " + userId + "}";
/* jsonObject2.put("params",part);
String jsonMessage = jsonObject2.toJSONString();*/
//调用接口结果
String result = RequestClient.getInstance().callService(ToDoCenterConstant.URI_SEND_finish,jsonMessage);
String result = RequestClient.getInstance().callService(ToDoCenterConstant.URI_SEND_finish, part);
//保存发送消息日志
// writeMessageLog(MessageCenterConstant.URI_SEND_MESSAGE,messageInfo,result);
//接口调用结果
JSONObject jsonObject = JSONObject.parseObject(result);
if(jsonObject.getBoolean("success")){
//发送成功
RequestClient.getInstance().saveDeLToDo(appRecordId,userId,ToDoCenterConstant.URI_SEND_finish,true,result,jsonMessage,"2");
return true;
}else{
if (jsonObject == null) {
//发送失败
RequestClient.getInstance().saveDeLToDo(appRecordId,userId,ToDoCenterConstant.URI_SEND_finish,false,result,jsonMessage,"2");
RequestClient.getInstance().saveDeLToDo(appRecordId, userId, ToDoCenterConstant.URI_SEND_finish, false, result, part, "2");
logger.info("###响应报文为空");
return false;
} else {
if (jsonObject.getBoolean("success")) {
//发送成功
RequestClient.getInstance().saveDeLToDo(appRecordId, userId, ToDoCenterConstant.URI_SEND_finish, true, result, part, "2");
return true;
} else {
//发送失败
RequestClient.getInstance().saveDeLToDo(appRecordId, userId, ToDoCenterConstant.URI_SEND_finish, false, result, part, "2");
return false;
}
}
} catch (Exception e) {
logger.error("调用接口失败:"+e.getMessage(),e);
logger.error("调用接口失败:" + e.getMessage(), e);
return false;
}
}
}

View File

@ -29,26 +29,31 @@ public class deleteToDoHandler {
public boolean sendDeleteToDo(Long appRecordId,String userId) {
try {
//body
JSONObject jsonObject2 = new JSONObject();
JSONObject jsonObject_1 = new JSONObject();
jsonObject_1.put("appRecordId", appRecordId);
jsonObject_1.put("userId",userId);
jsonObject2.put("params",jsonObject_1);
String jsonMessage = jsonObject2.toJSONString();
// JSONObject jsonObject2 = new JSONObject();
String part = " {\"appRecordId\": "+appRecordId+",\"userId\": "+userId+"}";
// jsonObject2.put("params",part);
// String jsonMessage = jsonObject2.toJSONString();
//调用接口结果
String result = RequestClient.getInstance().callService(ToDoCenterConstant.URI_send_deleteP,jsonMessage);
String result = RequestClient.getInstance().callService(ToDoCenterConstant.URI_send_deleteP,part);
//保存发送消息日志
// writeMessageLog(MessageCenterConstant.URI_SEND_MESSAGE,messageInfo,result);
//接口调用结果
JSONObject jsonObject = JSONObject.parseObject(result);
if(jsonObject.getBoolean("success")){
//发送成功
RequestClient.getInstance().saveDeLToDo(appRecordId,userId,ToDoCenterConstant.URI_send_deleteP,true,result,jsonMessage,"5");
return true;
}else{
RequestClient.getInstance().saveDeLToDo(appRecordId,userId,ToDoCenterConstant.URI_send_deleteP,false,result,jsonMessage,"5");
if(jsonObject== null){
RequestClient.getInstance().saveDeLToDo(appRecordId,userId,ToDoCenterConstant.URI_send_deleteP,false,result,part,"5");
logger.info("###响应报文为空");
return false;
}else{
if(jsonObject.getBoolean("success")){
//发送成功
RequestClient.getInstance().saveDeLToDo(appRecordId,userId,ToDoCenterConstant.URI_send_deleteP,true,result,part,"5");
return true;
}else{
RequestClient.getInstance().saveDeLToDo(appRecordId,userId,ToDoCenterConstant.URI_send_deleteP,false,result,part,"5");
return false;
}
}
} catch (Exception e) {
logger.error("###调用中台服务消息中心发送消息服务异常:"+e.getMessage(),e);
return false;

View File

@ -34,13 +34,42 @@ public class BacklogServiceHandle extends AbstractServiceHandler {
logger.info("###创建待办_createToDo");
//几个待办
List<Long> userIds = todoInfo.getUserIds();
DynamicObjectCollection query = QueryServiceHelper.query("bos_user", "id,name,phone", new QFilter[]{new QFilter("id", "in", userIds)});
DynamicObjectCollection query = QueryServiceHelper.query("bos_user", "id,name,phone,username", new QFilter[]{new QFilter("id", "in", userIds)});
DynamicObject dynamicObject = QueryServiceHelper.queryOne("wf_hitaskinst", "billno,startname,id,name",
new QFilter[]{new QFilter("id", "=", todoInfo.getTaskId())});
logger.info("####待办taskid:"+todoInfo.getTaskId());
for (DynamicObject query_one : query) {
BacklogMessage backlogMessage = new BacklogMessage();
//业务类型名称
StringBuffer form = new StringBuffer();
// BacklogMessage backlogMessage = new BacklogMessage();
form.append("{");
form.append("\"title\":");
form.append("\""+todoInfo.getTitle()+"\",");
form.append("\"bName\":");
form.append("\""+ctx.getEntityName()+"\",");
form.append("\"bussinessCode\":");
form.append("\""+dynamicObject.getString("billno")+"\",");
form.append("\"urGency\":");
form.append("\"0\",");
form.append("\"currentStepName\":");
form.append("\""+dynamicObject.getString("name")+"\",");
form.append("\"sendUserName\":");
form.append("\""+dynamicObject.getString("startname")+"\",");
form.append("\"receiveUsersysName\":");
form.append("\""+query_one.getString("username")+"\",");
form.append("\"receiveUserId\":");
form.append("\""+query_one.getString("username")+"\",");
form.append("\"handleUrl\":");
form.append("\""+todoInfo.getUrl()+"\",");
form.append("\"appHandleUrl\":");
form.append("\""+todoInfo.getUrl()+"\",");
form.append("\"appName\":");
form.append("\""+ctx.getEntityName()+"\",");
form.append("\"pendingId\":");
form.append("\""+todoInfo.getTaskId()+"\",");
form.append("\"pendingAttr\":");
form.append("\"0\"");
form.append("}");
/* //业务类型名称
backlogMessage.setbName("业务类型名称");
// 紧急程度
backlogMessage.setUrGency("0");
@ -50,8 +79,8 @@ public class BacklogServiceHandle extends AbstractServiceHandler {
backlogMessage.setPreStepName("");
// startname发起人名称
backlogMessage.setSendUserName(dynamicObject.getString("startname"));
//接收人手机号
backlogMessage.setReceiveUserId(query_one.getString("phone"));
//接收人用户名
backlogMessage.setReceiveUserId(query_one.getString("username"));
//标题
backlogMessage.setTitle(todoInfo.getTitle());
//PC地址
@ -75,8 +104,9 @@ public class BacklogServiceHandle extends AbstractServiceHandler {
//notifyMethod 通知方式
backlogMessage.setNotifyMethod("");
//业务自定义数据
backlogMessage.setJsonData("");
CreateToDoHandler.get_CreateToDoHandler().sendCreateToDo(backlogMessage);
backlogMessage.setJsonData("");*/
logger.info("###待办拼接请求体:"+form);
CreateToDoHandler.get_CreateToDoHandler().sendCreateToDo(form.toString(),todoInfo.getTitle());
}
logger.info("###结束待办_createToDo");
@ -87,24 +117,27 @@ public class BacklogServiceHandle extends AbstractServiceHandler {
logger.info("###创建已办_dealToDo");
//几个已办
List<Long> userIds = info.getUserIds();
DynamicObjectCollection query = QueryServiceHelper.query("bos_user", "id,name,phone", new QFilter[]{new QFilter("id", "in", userIds)});
logger.info("####已办taskid:"+info.getTaskId());
DynamicObjectCollection query = QueryServiceHelper.query("bos_user", "id,name,phone,username", new QFilter[]{new QFilter("id", "in", userIds)});
//业务id
Long taskId = ctx.getTaskId();
for (DynamicObject queryOne : query) {
DealToDoHandler.get_DealToDoHandler().sendDealToDo(taskId,queryOne.getString("phone"));
DealToDoHandler.get_DealToDoHandler().sendDealToDo(taskId,queryOne.getString("username"));
}
logger.info("###结束已办_dealToDo");
}
//撤销
public void deleteToDo(MessageContext ctx, ToDoInfo info){
logger.info("###创建撤销_deleteToDo");
List<Long> userIds = info.getUserIds();
DynamicObjectCollection query = QueryServiceHelper.query("bos_user", "id,name,phone", new QFilter[]{new QFilter("id", "in", userIds)});
DynamicObjectCollection query = QueryServiceHelper.query("bos_user", "id,name,phone,username", new QFilter[]{new QFilter("id", "in", userIds)});
//业务id
Long taskId = ctx.getTaskId();
logger.info("####撤销taskid:"+info.getTaskId());
for (DynamicObject queryOne : query) {
deleteToDoHandler.get_deleteToDoHandler().sendDeleteToDo(taskId,queryOne.getString("phone"));
deleteToDoHandler.get_deleteToDoHandler().sendDeleteToDo(taskId,queryOne.getString("username"));
}
logger.info("###结束撤销_deleteToDo");
}

View File

@ -1,16 +1,13 @@
package shkd.sys.sys.midservice.utils;
import cn.hutool.crypto.SmUtil;
import com.alibaba.fastjson.JSON;
import cn.hutool.http.HttpRequest;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.util.HttpClientUtils;
import kd.bos.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -52,30 +49,49 @@ public class RequestClient {
* 封装中台请求头执行POST请求
*
* @param url 接口地址不含http://ip:port的后半部分
* @param body JSON格式字符串
* @param body FORM格式字符串
* @return 响应结果报文
*/
public String callService(String url, String body){
Map<String, String> headers = getHeaders();
// Map<String, String> headers = getHeaders();
StringBuffer urlStr = new StringBuffer();
urlStr.append(this.protocal).append("://").append(this.ip);
if (!StringUtils.isEmpty(this.port)) {
urlStr.append(":").append(this.port);
}
logger.info("环境参数,protocal:"+this.protocal+",ip:"+this.ip+",this.port:"+this.port);
logger.info("###环境参数,protocal:"+this.protocal+",ip:"+this.ip+",this.port:"+this.port);
urlStr.append(url);
String responseText = null;
String timestamp = Long.toString(System.currentTimeMillis() / 1000);
byte[] securityKey = this.clientSecret.substring(10, 26).getBytes();
String authenticationCode = SmUtil.sm4(securityKey).encryptHex(clientKey + clientSecret + timestamp);
logger.info("###请求头主要参数:authen(sign)"+authenticationCode+"###时间戳"+timestamp);
Map<String,Object> params=new HashMap<>(2);
params.put("params",body);
/* Map<String,Object> params=new HashMap<>(2);
params.put("params",body);
String timestamp = Long.toString(System.currentTimeMillis() / 1000);
byte[] securityKey = clientSecret.substring(10, 26).getBytes();
String authenticationCode = SmUtil.sm4(securityKey).encryptHex(clientKey + clientSecret + timestamp);
*/
try {
//直接POST请求
responseText = HttpClientUtils.postjson(urlStr.toString(), headers, body);
logger.info(String.format("###调用接口成功请求URL%s请求Header%s请求Body%s响应报文%s", urlStr, JSON.toJSONString(headers), body, responseText));
} catch (IOException e) {
logger.error(String.format("###调用接口异常:%s请求URL%s请求Header%s请求Body%s", e.getMessage(), urlStr, JSON.toJSONString(headers), body), e);
responseText = HttpRequest.post(urlStr.toString())
.header("authen", authenticationCode)
.header("clientKey", clientKey)
.header("timestamp", timestamp)
.header("origin_client", "HttpToken")
.form(params)
.execute().body();
logger.info(String.format("###调用接口成功请求URL%s请求Body%s响应报文%s", urlStr, body, responseText));
} catch (Exception e) {
logger.error(String.format("###调用接口异常:%s请求URL%s,请求Body%s", e.getMessage(), urlStr, body), e);
}
return responseText;
}
private Map<String, String> getHeaders(){
/* private Map<String, String> getHeaders(){
logger.info("###进入拼接请求头方法");
Map<String,String> header=new HashMap<>();
String timestamp = Long.toString(System.currentTimeMillis() / 1000);
byte[] securityKey = this.clientSecret.substring(10, 26).getBytes();
@ -86,7 +102,7 @@ public class RequestClient {
header.put("origin_client", "HttpToken");
logger.info("###authen(sign)"+authenticationCode+"###时间戳"+timestamp);
return header;
}
}*/
/***
* 保存待办日志
* @param title 标题
@ -103,17 +119,17 @@ public class RequestClient {
urlStr.append(":").append(this.port);
}
urlStr.append(url);;
logger.info("保存时,环境参数,protocal:"+this.protocal+",ip:"+this.ip+",this.port:"+this.port);
logger.info("###保存时,环境参数,protocal:"+this.protocal+",ip:"+this.ip+",this.port:"+this.port);
DynamicObject dynamicObject = BusinessDataServiceHelper.newDynamicObject("shkd_backlog");
logger.info("保存日志表id"+dynamicObject.getPkValue());
logger.info("###保存日志表id"+dynamicObject.getPkValue());
dynamicObject.set("shkd_url",urlStr);
dynamicObject.set("shkd_request",title);
dynamicObject.set("shkd_request_tag",jsonMessage);
dynamicObject.set("shkd_response",isTrue);
dynamicObject.set("shkd_response",result);
dynamicObject.set("shkd_response_tag",result);
dynamicObject.set("shkd_status","0");
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
logger.info("保存日志表id"+dynamicObject.getPkValue());
logger.info("###保存日志表id"+dynamicObject.getPkValue());
logger.info("###结束调用待办保存日志方法");
}
/***
@ -139,9 +155,11 @@ public class RequestClient {
dynamicObject.set("shkd_request","业务id:"+appRecordId+",接收人手机号:"+userId);
dynamicObject.set("shkd_request_tag",jsonMessage);
dynamicObject.set("shkd_response",isTrue);
dynamicObject.set("shkd_response",result);
dynamicObject.set("shkd_response_tag",result);
dynamicObject.set("shkd_status",status);
logger.info("###开始调用已办、撤销保存日志方法");
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
logger.info("###保存日志表id"+dynamicObject.getPkValue());
logger.info("###结束调用已办、撤销保存日志方法");
}