#chabaodao-3# bot审批
This commit is contained in:
parent
68d2203ada
commit
58976e9142
|
|
@ -123,7 +123,7 @@ public class Esb2EsignSyncTemplateCron implements EsbServerlessRpcRemoteInterfac
|
|||
}
|
||||
log.error("addDatas:{}",addDatas.size());
|
||||
|
||||
Map<String,Object> recordMap = formFieldDao.queryTableFormId(Constants.sealTable);
|
||||
Map<String,Object> recordMap = formFieldDao.queryTableFormId(Constants.templateTable);
|
||||
String formId = recordMap.get("id").toString();
|
||||
String appId = recordMap.get("app_id").toString();
|
||||
log.error("formId:{}",formId);
|
||||
|
|
|
|||
|
|
@ -68,4 +68,6 @@ public class Constants {
|
|||
|
||||
public static String botTemplateId = "1008";
|
||||
|
||||
public static String updateBotUrl = "/open-apis/approval/v1/message/update";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.cost.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.cost.util.DatabaseUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class WorkflowBotMessageDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(WorkflowBotMessageDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> queryUserBotMessageId(String requestid,String nodeid,String operatorid){
|
||||
String groupId = "weaver-ebuilder-form-service";
|
||||
String sourceType = "LOGIC";
|
||||
List<Map<String, Object>> recordList = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
String dataSql =" select czzid,message_id \n" +
|
||||
" from uf_bot_message \n" +
|
||||
" where lcid= ? and jdid = ? and czzid in ("+operatorid+")" +
|
||||
" and delete_type = 0 and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(requestid);
|
||||
paramList.add(nodeid);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.dao;
|
||||
|
||||
import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity;
|
||||
import com.weaver.seconddev.chapanda.cost.constant.Constants;
|
||||
import com.weaver.seconddev.chapanda.cost.util.DatabaseUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class WorkflowTableDao {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(WorkflowTableDao.class);
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String queryWorkflowTable(String workflowId){
|
||||
String groupId = "weaver-workflow-report-serviceworkflowreport";
|
||||
String sourceType = "LOGIC";
|
||||
String formTable = "";
|
||||
try{
|
||||
String dataSql =" select table_name \n" +
|
||||
" from form_table \n" +
|
||||
" where form_id in(select relatekey from wfp_relateform where workflowid=? and delete_type = 0 and tenant_key = ? ) " +
|
||||
" and delete_type = 0 and tenant_key = ? " ;
|
||||
|
||||
log.error("dataSql:" + dataSql);
|
||||
List<String> paramList = new ArrayList<>(100);
|
||||
paramList.add(workflowId);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
paramList.add(Constants.TENANT_KEY);
|
||||
List<SqlParamEntity> sqlParamList = databaseUtils.querySqlParamEntity(paramList);
|
||||
Map<String, Object> result = databaseUtils.executeForQuery(sourceType, groupId, dataSql, sqlParamList);
|
||||
List<Map<String, Object>> recordList = databaseUtils.getDataSourceList(result);
|
||||
log.error("recordList:"+recordList.size());
|
||||
if(recordList.size() > 0){
|
||||
formTable = String.valueOf(recordList.get(0).get("table_name"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("e:" + e);
|
||||
}
|
||||
return formTable;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuBotCreateTodoUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuBotCreateTodoAction")
|
||||
public class Esb2FeishuBotCreateTodoAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuBotCreateTodoAction.class);
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuBotCreateTodoUtil esb2FeishuBotCreateTodoUtil;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("requestName:{}",requestName);
|
||||
|
||||
String mobileurl = String.valueOf(params.get("mobileurl"));
|
||||
String pcurl = String.valueOf(params.get("pcurl"));
|
||||
String creatorid = String.valueOf(params.get("creatorid"));
|
||||
String creatorname = "";
|
||||
|
||||
String senderid = String.valueOf(params.get("senderid"));
|
||||
|
||||
String operatorid = String.valueOf(params.get("operatorid"));
|
||||
String requestmark = String.valueOf(params.get("requestmark"));
|
||||
if("null".equals(requestmark) || requestmark == null){
|
||||
requestmark = "";
|
||||
}
|
||||
String msgType = String.valueOf(params.get("msgType"));
|
||||
|
||||
String nodeid = String.valueOf(params.get("nodeid"));
|
||||
|
||||
log.error("msgType:{}",msgType);
|
||||
log.error("mobileurl:{}",mobileurl);
|
||||
log.error("pcurl:{}",pcurl);
|
||||
log.error("operatorid:{}",operatorid);
|
||||
log.error("requestmark:{}",requestmark);
|
||||
log.error("creatorid:{}",creatorid);
|
||||
|
||||
String message_ids = "";
|
||||
|
||||
if("0".equals(msgType)){
|
||||
String senderMobile ="";
|
||||
if(StringUtils.isNotBlank(senderid)){
|
||||
Long sender_id = Long.parseLong(senderid);
|
||||
SimpleEmployee senderEmployee = hrmCommonUtil.getSimpleEmployee(sender_id);
|
||||
senderMobile = senderEmployee.getMobile();
|
||||
}
|
||||
|
||||
String creatorMobile = "";
|
||||
if(StringUtils.isNotBlank(creatorid)){
|
||||
Long creator_id = Long.parseLong(creatorid);
|
||||
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
|
||||
creatorMobile = creatorEmployee.getMobile();
|
||||
creatorname = creatorEmployee.getUsername();
|
||||
}
|
||||
|
||||
log.error("creatorMobile:{}",creatorMobile);
|
||||
log.error("creatorname:{}",creatorname);
|
||||
String create_open_id = "";
|
||||
if(StringUtils.isNotBlank(creatorMobile)) {
|
||||
Map<String, Object> creatorMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
|
||||
create_open_id = String.valueOf(creatorMap.get(creatorMobile));
|
||||
}
|
||||
|
||||
String send_open_id = "";
|
||||
if(StringUtils.isNotBlank(senderMobile)){
|
||||
Map<String, Object> senderMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(senderMobile);
|
||||
send_open_id = String.valueOf(senderMap.get(creatorMobile));
|
||||
}
|
||||
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
for(int i=0;i<todoUserids.length;i++){
|
||||
String todoUserid = todoUserids[i];
|
||||
log.error("todoUserid:{}",todoUserid);
|
||||
if(StringUtils.isNotBlank(todoUserid)){
|
||||
Long userid = Long.parseLong(todoUserid);
|
||||
log.error("userid:{}",userid);
|
||||
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
|
||||
String userMobile = userEmployee.getMobile();
|
||||
log.error("userMobile:{}",userMobile);
|
||||
if(StringUtils.isNotBlank(userMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(userMobile);
|
||||
String user_open_id = String.valueOf(userMap.get(userMobile));
|
||||
log.error("user_open_id:{}",user_open_id);
|
||||
todoOpenIdList.add(user_open_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.error("create_open_id:{}",create_open_id);
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
if(StringUtils.isNotBlank(send_open_id)){
|
||||
if(todoOpenIdList.size() > 0){
|
||||
if("0".equals(msgType)){
|
||||
message_ids = esb2FeishuBotCreateTodoUtil.senBotTodoMessage(
|
||||
requestid,requestName,requestmark,
|
||||
create_open_id,send_open_id,todoOpenIdList,
|
||||
mobileurl,pcurl
|
||||
);
|
||||
}
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
}
|
||||
}else{
|
||||
log.error("send_open_id:{}","获取待办人员为空");
|
||||
}
|
||||
}else{
|
||||
log.error("creatorMobile:{}","创建人飞书openid为空");
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("messageid",message_ids);
|
||||
actionMap.put("requestid",requestid);
|
||||
actionMap.put("requestname",requestName);
|
||||
actionMap.put("nodeid",nodeid);
|
||||
actionMap.put("operatorid",operatorid);
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,8 @@ package com.weaver.seconddev.chapanda.feishu.esb;
|
|||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.common.hrm.util.HrmCommonUtil;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuBotTodoUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.dao.WorkflowTableDao;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuBotCreateTodoUtil;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuOpenIdUtil;
|
||||
import com.weaver.teams.domain.user.SimpleEmployee;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -11,14 +12,15 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuBotTodoAction")
|
||||
public class Esb2FeishuBotTodoAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuBotTodoAction.class);
|
||||
@Service("Esb2FeishuDteleteBotTodoAction")
|
||||
public class Esb2FeishuBotDteleteTodoAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuBotDteleteTodoAction.class);
|
||||
|
||||
@Autowired
|
||||
private HrmCommonUtil hrmCommonUtil;
|
||||
|
|
@ -27,11 +29,15 @@ public class Esb2FeishuBotTodoAction implements EsbServerlessRpcRemoteInterface
|
|||
Esb2FeishuOpenIdUtil esb2FeishuOpenIdUtil;
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuBotTodoUtil esb2FeishuBotTodoUtil;
|
||||
Esb2FeishuBotCreateTodoUtil esb2FeishuBotTodoUtil;
|
||||
|
||||
@Autowired
|
||||
WorkflowTableDao workflowTableDao;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
log.error("Esb2FeishuSendTodoAction start");
|
||||
|
||||
String workflowid = String.valueOf(params.get("workflowid"));
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
log.error("requestid:{}",requestid);
|
||||
|
|
@ -86,6 +92,11 @@ public class Esb2FeishuBotTodoAction implements EsbServerlessRpcRemoteInterface
|
|||
send_open_id = String.valueOf(senderMap.get(creatorMobile));
|
||||
}
|
||||
|
||||
String formTable = "";
|
||||
if(StringUtils.isNotBlank(workflowid)){
|
||||
formTable = workflowTableDao.queryWorkflowTable(workflowid);
|
||||
}
|
||||
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
|
|
@ -113,7 +124,7 @@ public class Esb2FeishuBotTodoAction implements EsbServerlessRpcRemoteInterface
|
|||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
if(StringUtils.isNotBlank(send_open_id)){
|
||||
if(todoOpenIdList.size() > 0){
|
||||
if("0".equals(msgType)){
|
||||
if("1".equals(msgType)){
|
||||
message_ids = esb2FeishuBotTodoUtil.senBotTodoMessage(
|
||||
requestid,requestName,requestmark,
|
||||
create_open_id,send_open_id,todoOpenIdList,
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.esb;
|
||||
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
||||
import com.weaver.seconddev.chapanda.feishu.dao.WorkflowBotMessageDao;
|
||||
import com.weaver.seconddev.chapanda.feishu.util.Esb2FeishuBotUpdateTodoUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("Esb2FeishuBotUpdateTodoAction")
|
||||
public class Esb2FeishuBotUpdateTodoAction implements EsbServerlessRpcRemoteInterface {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuBotUpdateTodoAction.class);
|
||||
|
||||
@Autowired
|
||||
Esb2FeishuBotUpdateTodoUtil esb2FeishuBotUpdateTodoUtil;
|
||||
|
||||
@Autowired
|
||||
WorkflowBotMessageDao workflowBotMessageDao;
|
||||
@Override
|
||||
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
||||
|
||||
String requestid = String.valueOf(params.get("requestid"));
|
||||
String requestName = String.valueOf(params.get("requestName"));
|
||||
log.error("requestid:{}",requestid);
|
||||
log.error("requestName:{}",requestName);
|
||||
String nodeid = String.valueOf(params.get("nodeid"));
|
||||
String operatorid = String.valueOf(params.get("operatorid"));
|
||||
String msgType = String.valueOf(params.get("msgType"));
|
||||
|
||||
log.error("msgType:{}",msgType);
|
||||
|
||||
String update_message_id = "";
|
||||
if("1".equals(msgType)){
|
||||
String status = "PROCESSED";
|
||||
List<Map<String,Object>> todoMessageIdList = new ArrayList<Map<String,Object>>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
todoMessageIdList = workflowBotMessageDao.queryUserBotMessageId(requestid,nodeid,operatorid);
|
||||
}
|
||||
log.error("todoMessageIdList:{}",todoMessageIdList.size());
|
||||
if(todoMessageIdList.size() > 0){
|
||||
update_message_id = esb2FeishuBotUpdateTodoUtil.senBotTodoMessage(status,todoMessageIdList);
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
actionMap.put("code",200);
|
||||
actionMap.put("msg","成功");
|
||||
actionMap.put("messageid",update_message_id);
|
||||
actionMap.put("updatemessageid",update_message_id);
|
||||
|
||||
return WeaResult.success(actionMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -91,48 +91,48 @@ public class Esb2FeishuSendDoneAction implements EsbServerlessRpcRemoteInterface
|
|||
log.error("recepttime:{}",recepttime);
|
||||
|
||||
String code = "";
|
||||
String creatorMobile = "";
|
||||
if(StringUtils.isNotBlank(creatorid)){
|
||||
Long creator_id = Long.parseLong(creatorid);
|
||||
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
|
||||
creatorMobile = creatorEmployee.getMobile();
|
||||
creatorname = creatorEmployee.getUsername();
|
||||
}
|
||||
log.error("creatorMobile:{}",creatorMobile);
|
||||
log.error("creatorname:{}",creatorname);
|
||||
if("1".equals(msgType)){
|
||||
String status = "APPROVED";
|
||||
String creatorMobile = "";
|
||||
if(StringUtils.isNotBlank(creatorid)){
|
||||
Long creator_id = Long.parseLong(creatorid);
|
||||
SimpleEmployee creatorEmployee = hrmCommonUtil.getSimpleEmployee(creator_id);
|
||||
creatorMobile = creatorEmployee.getMobile();
|
||||
creatorname = creatorEmployee.getUsername();
|
||||
}
|
||||
log.error("creatorMobile:{}",creatorMobile);
|
||||
log.error("creatorname:{}",creatorname);
|
||||
|
||||
String create_open_id = "";
|
||||
if(StringUtils.isNotBlank(creatorMobile)) {
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
|
||||
create_open_id = String.valueOf(userMap.get(creatorMobile));
|
||||
}
|
||||
String create_open_id = "";
|
||||
if(StringUtils.isNotBlank(creatorMobile)) {
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(creatorMobile);
|
||||
create_open_id = String.valueOf(userMap.get(creatorMobile));
|
||||
}
|
||||
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
for(int i=0;i<todoUserids.length;i++){
|
||||
String todoUserid = todoUserids[i];
|
||||
log.error("todoUserid:{}",todoUserid);
|
||||
if(StringUtils.isNotBlank(todoUserid)){
|
||||
Long userid = Long.parseLong(todoUserid);
|
||||
log.error("userid:{}",userid);
|
||||
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
|
||||
String userMobile = userEmployee.getMobile();
|
||||
log.error("userMobile:{}",userMobile);
|
||||
if(StringUtils.isNotBlank(userMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(userMobile);
|
||||
String user_open_id = String.valueOf(userMap.get(userMobile));
|
||||
log.error("user_open_id:{}",user_open_id);
|
||||
todoOpenIdList.add(user_open_id);
|
||||
List<String> todoOpenIdList = new ArrayList<String>();
|
||||
if(StringUtils.isNotBlank(operatorid)){
|
||||
String[] todoUserids = operatorid.split(",");
|
||||
for(int i=0;i<todoUserids.length;i++){
|
||||
String todoUserid = todoUserids[i];
|
||||
log.error("todoUserid:{}",todoUserid);
|
||||
if(StringUtils.isNotBlank(todoUserid)){
|
||||
Long userid = Long.parseLong(todoUserid);
|
||||
log.error("userid:{}",userid);
|
||||
SimpleEmployee userEmployee = hrmCommonUtil.getSimpleEmployee(userid);
|
||||
String userMobile = userEmployee.getMobile();
|
||||
log.error("userMobile:{}",userMobile);
|
||||
if(StringUtils.isNotBlank(userMobile)){
|
||||
Map<String, Object> userMap = esb2FeishuOpenIdUtil.queryFeishuOpenIdByMobiles(userMobile);
|
||||
String user_open_id = String.valueOf(userMap.get(userMobile));
|
||||
log.error("user_open_id:{}",user_open_id);
|
||||
todoOpenIdList.add(user_open_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
if(todoOpenIdList.size()>0){
|
||||
if("1".equals(msgType)){
|
||||
String status = "APPROVED";
|
||||
if(StringUtils.isNotBlank(create_open_id)){
|
||||
if(todoOpenIdList.size()>0){
|
||||
code = esb2FeishuSendDoneUtil.senTodoMessage(
|
||||
requestid,requestName,requestmark,
|
||||
creatorname,createTime,
|
||||
|
|
@ -144,12 +144,12 @@ public class Esb2FeishuSendDoneAction implements EsbServerlessRpcRemoteInterface
|
|||
if(!"0".equals(code)){
|
||||
log.error("todoOpenIdList:{}","创建飞书待办异常");
|
||||
}
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
}
|
||||
}else{
|
||||
log.error("todoOpenIdList:{}","获取待办人员为空");
|
||||
log.error("creatorMobile:{}","创建人飞书openid为空");
|
||||
}
|
||||
}else{
|
||||
log.error("creatorMobile:{}","创建人飞书openid为空");
|
||||
}
|
||||
|
||||
Map<String, Object> actionMap = new HashMap<String, Object>();
|
||||
|
|
|
|||
|
|
@ -9,19 +9,15 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuBotTodoUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuBotTodoUtil.class);
|
||||
public class Esb2FeishuBotCreateTodoUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuBotCreateTodoUtil.class);
|
||||
|
||||
@Autowired
|
||||
private Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
|
@ -128,89 +124,29 @@ public class Esb2FeishuBotTodoUtil {
|
|||
JSONArray actionsArray = new JSONArray();
|
||||
JSONObject actionsObject = new JSONObject();
|
||||
actionsObject.put("action_name","DETAIL");
|
||||
actionsObject.put("url",mobileurl);
|
||||
actionsObject.put("android_url",mobileurl);
|
||||
actionsObject.put("ios_url",mobileurl);
|
||||
actionsObject.put("pc_url",pcurl);
|
||||
actionsObject.put("url",Constants.HrmHost+mobileurl);
|
||||
actionsObject.put("android_url",Constants.HrmHost+mobileurl);
|
||||
actionsObject.put("ios_url",Constants.HrmHost+mobileurl);
|
||||
actionsObject.put("pc_url",Constants.HrmHost+pcurl);
|
||||
actionsArray.add(actionsObject);
|
||||
bodyJson.put("actions",actionsArray);
|
||||
|
||||
|
||||
JSONArray i18nResourcesTextsArray = new JSONArray();
|
||||
|
||||
JSONObject i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@title");
|
||||
i18nResourcesTextsJson.put("value",requestName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@summary");
|
||||
i18nResourcesTextsJson.put("value",requestName);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson = new JSONObject();
|
||||
i18nResourcesTextsJson.put("key","@i18n@requestid");
|
||||
i18nResourcesTextsJson.put("value",requestid);
|
||||
i18nResourcesTextsArray.add(i18nResourcesTextsJson);
|
||||
|
||||
i18nResourcesTextsJson.put("@i18n@title",requestName);
|
||||
i18nResourcesTextsJson.put("@i18n@summary",requestName);
|
||||
i18nResourcesTextsJson.put("@i18n@requestid",requestid);
|
||||
JSONObject i18nResourcesJson = new JSONObject();
|
||||
i18nResourcesJson.put("locale","zh-CN");
|
||||
i18nResourcesJson.put("texts",i18nResourcesTextsArray);
|
||||
i18nResourcesJson.put("is_default","true");
|
||||
i18nResourcesJson.put("texts",i18nResourcesTextsJson);
|
||||
i18nResourcesJson.put("is_default",true);
|
||||
|
||||
JSONArray i18nResourcesArray = new JSONArray();
|
||||
i18nResourcesArray.add(i18nResourcesJson);
|
||||
|
||||
bodyJson.put("i18n_resources",i18nResourcesArray);
|
||||
|
||||
return bodyJson.toJSONString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Esb2FeishuBotTodoUtil esb2FeishuSendTodoUtil = new Esb2FeishuBotTodoUtil();
|
||||
|
||||
String requestid = "1154744413522714631";
|
||||
String requestName = "督导奖励申请流程-石磊-2025-07-09";
|
||||
|
||||
String create_open_id = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
|
||||
String department_id = "";
|
||||
String department_name = "";
|
||||
String start_time = String.valueOf(System.currentTimeMillis());
|
||||
String end_time = String.valueOf(System.currentTimeMillis());
|
||||
|
||||
Map<String, Object> textsMap = new HashMap<String,Object>();
|
||||
|
||||
List<Map<String, Object>> taskList = new ArrayList<Map<String, Object>>();
|
||||
Map<String,Object> taskMap = new HashMap<String,Object>();
|
||||
taskMap.put("open_id",create_open_id);
|
||||
taskList.add(taskMap);
|
||||
|
||||
|
||||
|
||||
List<Map<String, Object>> formList = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","创建人");
|
||||
formMap.put("value","石磊");
|
||||
formList.add(formMap);
|
||||
formMap = new HashMap<String,Object>();
|
||||
formMap.put("name","紧急程度");
|
||||
formMap.put("value","紧急");
|
||||
formList.add(formMap);
|
||||
String node_id = "1151724772346716177";
|
||||
String nodeName = "1级审批";
|
||||
|
||||
// String data = esb2FeishuSendTodoUtil.appendBodyParam(requestid,
|
||||
// requestName,create_open_id,department_id,department_name,start_time,end_time,
|
||||
// formList,node_id,nodeName,new ArrayList<String>(),"","","");
|
||||
// System.out.println(data);
|
||||
|
||||
String date = "2025-07-17 21:07:48";
|
||||
|
||||
esb2FeishuSendTodoUtil.convertTimeStamp(date);
|
||||
}
|
||||
|
||||
|
||||
public long convertTimeStamp(String date) {
|
||||
|
||||
if(StringUtils.isNotBlank(date)){
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.weaver.seconddev.chapanda.feishu.util;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.weaver.seconddev.chapanda.feishu.constant.Constants;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class Esb2FeishuBotUpdateTodoUtil {
|
||||
private final static Logger log = LoggerFactory.getLogger(Esb2FeishuBotUpdateTodoUtil.class);
|
||||
|
||||
@Autowired
|
||||
private Esb2FeishuTokenUtil esb2FeishuTokenUtil;
|
||||
|
||||
public String senBotTodoMessage(String status,List<Map<String,Object>> todoOpenIdList) {
|
||||
String update_message_ids = "";
|
||||
String token = esb2FeishuTokenUtil.getToken();
|
||||
log.error("token:"+token);
|
||||
if(StringUtils.isNotBlank(token)){
|
||||
for(int i=0;i<todoOpenIdList.size();i++){
|
||||
String message_id = String.valueOf(todoOpenIdList.get(i).get("message_id"));
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("message_id",message_id);
|
||||
bodyJson.put("status",status);
|
||||
|
||||
JSONObject textsJson = new JSONObject();
|
||||
JSONObject i18nResourcesJson = new JSONObject();
|
||||
i18nResourcesJson.put("locale","zh-CN");
|
||||
i18nResourcesJson.put("texts",textsJson);
|
||||
i18nResourcesJson.put("is_default","true");
|
||||
JSONArray i18nResourcesArray = new JSONArray();
|
||||
i18nResourcesArray.add(i18nResourcesJson);
|
||||
bodyJson.put("i18n_resources",i18nResourcesArray);
|
||||
|
||||
String message = doSendPost(bodyJson.toJSONString(),token);
|
||||
if(StringUtils.isNotBlank(message)){
|
||||
JSONObject returnData = JSONObject.parseObject(message);
|
||||
if(returnData.containsKey("code")){
|
||||
String code = returnData.getString("code");
|
||||
if("0".equals(code)){
|
||||
JSONObject dataJson = returnData.getJSONObject("data");
|
||||
if(dataJson.containsKey("message_id")){
|
||||
String update_message_id = dataJson.getString("message_id");
|
||||
update_message_ids += StringUtils.isBlank(update_message_ids) ? update_message_id : ","+update_message_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return update_message_ids;
|
||||
}
|
||||
|
||||
|
||||
public String doSendPost(String bodyData, String token){
|
||||
String msg = "";
|
||||
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
RequestBody body = RequestBody.create(mediaType, bodyData);
|
||||
|
||||
// RequestBody body = RequestBody.create(mediaType, "{\n \"message_id\":\"7530608640169000988\",\n \"status\":\"PROCESSED\",\n \"i18n_resources\":[\n {\n \"locale\":\"zh-CN\",\n \"is_default\":true,\n \"texts\":{\n \n \n }\n }\n ]\n}");
|
||||
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(Constants.feishuHost+Constants.updateBotUrl)
|
||||
.method("POST", body)
|
||||
.addHeader("Authorization", "Bearer "+token)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
int code = response.code();
|
||||
log.error("code:{}",code);
|
||||
msg = response.body().string();
|
||||
log.error("msg:"+msg);
|
||||
} catch (IOException e) {
|
||||
log.error("e:"+e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue