丽知:钉钉回调修改
This commit is contained in:
parent
472964e254
commit
b4faeaadd0
|
@ -690,6 +690,21 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
dingU8cBillEntity.setApprove(null);//Y审核 N不审核
|
||||
dingU8cBillEntity.setInitiate("D");//D钉钉发起,U u8c发起
|
||||
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
//做一个钉钉的日志
|
||||
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
|
||||
integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N);
|
||||
integrationTaskLivingDetailsEntity.setRootAppNewData("付款单新增回调报错");
|
||||
integrationTaskLivingDetailsEntity.setNewTransmitInfo(e.getMessage());
|
||||
integrationTaskLivingDetailsEntity.setNewPushDate(new Date());
|
||||
integrationTaskLivingDetailsEntity.setBusinessDate(now.toString());
|
||||
integrationTaskLivingDetailsEntity.setRootAppPk(processInstanceId);
|
||||
integrationTaskLivingDetailsEntity.setRootAppBill(processInstanceId);
|
||||
integrationTaskLivingDetailsEntity.setPluginId("dingtalk.DingCallBackServicePluginInitializer");
|
||||
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ public class DingU8cBillDaoImpl extends MybatisGenericDao<DingU8cBillEntity, Str
|
|||
dingU8cBill.setPush_info(dingU8cBillEntityNew.getPush_info());
|
||||
this.update(dingU8cBill);
|
||||
} else if ("N".equals(pushStatus) && "Y".equals(pushStatusNew)) {
|
||||
dingU8cBill.setApprove(null);
|
||||
//N->Y,可能重复推送
|
||||
dingU8cBill.setId(dingU8cBillEntity.getId());
|
||||
dingU8cBill.setDing_talk_process_id(dingU8cBillEntityNew.getDing_talk_process_id());
|
||||
|
|
|
@ -44,6 +44,10 @@ public class DingU8cBillEntity extends BaseEntity {
|
|||
private Long push_count;
|
||||
/** 历史实例id */
|
||||
private String push_process_ids;
|
||||
/** 开始时间 */
|
||||
private String start_time;
|
||||
/** 结束时间 */
|
||||
private String end_time;
|
||||
|
||||
public DingU8cBillEntity(String u8c_pk_corp, String u8c_code_corp, String u8c_bill_type, String u8c_bill_code, String u8c_bill_id, String push_status, String push_info, String ding_talk_process_id, String ding_res) {
|
||||
this.u8c_pk_corp = u8c_pk_corp;
|
||||
|
|
|
@ -66,6 +66,9 @@
|
|||
<if test="push_process_ids != null and push_process_ids != ''"> and push_process_ids = #{push_process_ids} </if>
|
||||
<if test="modify_time != null"> and modify_time = #{modify_time} </if>
|
||||
<if test="create_time != null"> and create_time = #{create_time} </if>
|
||||
|
||||
<if test="start_time != null"> and create_time >= #{start_time} </if>
|
||||
<if test="end_time != null"> and create_time <= #{end_time} </if>
|
||||
and sts='Y'
|
||||
</trim>
|
||||
</select>
|
||||
|
@ -166,6 +169,7 @@
|
|||
<if test="ding_talk_process_id != null and ding_talk_process_id != ''"> ding_talk_process_id , </if>
|
||||
<if test="ding_res != null and ding_res != ''"> ding_res , </if>
|
||||
<if test="approve != null and approve != ''"> approve , </if>
|
||||
<if test="approve == null and approve == ''"> approve , </if>
|
||||
<if test="initiate != null and initiate != ''"> initiate , </if>
|
||||
<if test="push_count != null and push_count != ''"> push_count , </if>
|
||||
<if test="push_process_ids != null and push_process_ids != ''"> push_process_ids , </if>
|
||||
|
@ -188,6 +192,7 @@
|
|||
<if test="ding_talk_process_id != null and ding_talk_process_id != ''"> #{ding_talk_process_id} ,</if>
|
||||
<if test="ding_res != null and ding_res != ''"> #{ding_res} ,</if>
|
||||
<if test="approve != null and approve != ''"> #{approve} ,</if>
|
||||
<if test="approve == null and approve == ''"> null ,</if>
|
||||
<if test="initiate != null and initiate != ''"> #{initiate} ,</if>
|
||||
<if test="push_count != null and push_count != ''"> #{push_count} ,</if>
|
||||
<if test="push_process_ids != null and push_process_ids != ''"> #{push_process_ids} ,</if>
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -45,7 +46,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
/**
|
||||
* 为避免回调超时,每天定时检查所有未审批完成的审批实例。
|
||||
* 只检测u8c推送钉钉的,不检测钉钉自己发起的审批实例
|
||||
* 只检测u8c成功推送钉钉的,不检测钉钉自己发起的审批实例
|
||||
*/
|
||||
@Service("DingCallBackService")
|
||||
public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
||||
|
@ -121,12 +122,20 @@ public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
|||
|
||||
/**
|
||||
* 检测所有插件
|
||||
* 只检测u8c成功推送钉钉的 ,不检测钉钉自己发起的审批实例
|
||||
*/
|
||||
public void start() {
|
||||
try {
|
||||
LocalDate now = LocalDate.now();
|
||||
// 减去3个月
|
||||
LocalDate nowBeforeThreeMonths = now.minus(3, ChronoUnit.MONTHS);
|
||||
|
||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
||||
dingU8cBillEntity.setStart_time(nowBeforeThreeMonths+" 00:00:00");
|
||||
dingU8cBillEntity.setEnd_time(now+" 23:59:59");
|
||||
dingU8cBillEntity.setSts("Y");
|
||||
dingU8cBillEntity.setInitiate("U");
|
||||
dingU8cBillEntity.setPush_status("Y");
|
||||
List<DingU8cBillEntity> query = dingU8cBillDao.query(dingU8cBillEntity);
|
||||
if (query == null || query.size() == 0) {
|
||||
return;
|
||||
|
@ -136,10 +145,6 @@ public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
|||
if (filterData == null || filterData.size() == 0) {
|
||||
return;
|
||||
}
|
||||
// List<String> collect = filterData.stream().map(DingU8cBillEntity::getDing_talk_process_id).collect(Collectors.toList());
|
||||
// if (collect == null || collect.size() == 0) {
|
||||
// return;
|
||||
// }
|
||||
implement(filterData);
|
||||
} catch (Exception e) {
|
||||
logger.error("丽知:钉钉审批实例自动检查start()报错,报错信息:{}", e);
|
||||
|
@ -185,29 +190,23 @@ public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
|||
if ("Y".equals(dingU8cBillEntity.getApprove()) || (dingU8cBillEntity.getDing_talk_process_id() == null || "".equals(dingU8cBillEntity.getDing_talk_process_id().trim()))) {
|
||||
continue;
|
||||
}
|
||||
if(dingU8cBillEntity.getApprove()==null){
|
||||
filter.add(dingU8cBillEntity);
|
||||
}
|
||||
}
|
||||
return filter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表单,看返回接口。
|
||||
*
|
||||
* push_status:Y approve:(null)
|
||||
* @param filterData
|
||||
*/
|
||||
public void implement(List<DingU8cBillEntity> filterData) throws Exception {
|
||||
//获取token
|
||||
String token = getDingTalkToken();
|
||||
for (DingU8cBillEntity dingU8cBillEntity : filterData) {
|
||||
if(dingU8cBillEntity.getDing_talk_process_id()==null||"".equals(dingU8cBillEntity.getDing_talk_process_id().trim())){
|
||||
continue;
|
||||
}
|
||||
if("Y".equals(dingU8cBillEntity.getApprove())){
|
||||
continue;
|
||||
}
|
||||
|
||||
//查询u8c付款单审核状态,审核的continue,没审核的查询钉钉表单上的状态
|
||||
|
||||
try {
|
||||
//查询实例的具体信息
|
||||
|
@ -225,51 +224,51 @@ public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
|||
return;
|
||||
}
|
||||
|
||||
//查询u8c的单据状态//spzt:1审核 null 未审核
|
||||
//查询u8c的单据状态
|
||||
String u8cPkCorp = dingU8cBillEntity.getU8c_pk_corp();
|
||||
String u8cBillCode = dingU8cBillEntity.getU8c_bill_code();
|
||||
ArapDjzbEntity arapDjzbEntity = queryArapDjzbEntity(u8cPkCorp, u8cBillCode);
|
||||
if(arapDjzbEntity==null){
|
||||
return;
|
||||
Assert.state(false,"根据公司主键:{},单据号:{},未查询到u8c付款单,请检查。",u8cPkCorp,u8cBillCode);
|
||||
}
|
||||
|
||||
//任务列表,文档地址:https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.33293c33eWKtYM#/?devType=org&api=workflow_1.0%23GetProcessInstance
|
||||
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks> tasks = processInstanceResponseBodyResult.getTasks();
|
||||
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks task : tasks) {
|
||||
userId=task.getUserId();
|
||||
//djzt单据状态 1保存 3完成
|
||||
if("3".equals(arapDjzbEntity.getDjzt())){
|
||||
continue;
|
||||
}
|
||||
//spzt审批状态 null未审批 1审批
|
||||
if("1".equals(arapDjzbEntity.getSpzt())){
|
||||
continue;
|
||||
}
|
||||
mobile = getMobileByUserId(token, userId);
|
||||
|
||||
result = processInstanceResponseBodyResult.getResult();
|
||||
if("agree".equals(result)){
|
||||
approveArapDjzb(dingU8cBillEntity,mobile);
|
||||
}else if("refuse".equals(result)){
|
||||
refuse(dingU8cBillEntity,mobile);
|
||||
if ("agree".equals(result)) {
|
||||
//同意
|
||||
//审批u8c单据
|
||||
approveArapDjzb(dingU8cBillEntity);
|
||||
}else if ("refuse".equals(result)) {
|
||||
//拒绝
|
||||
dingU8cBillEntity.setApprove("N");
|
||||
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||
//后续林姐姐给接口,拒绝之后清空process_id、approve:N
|
||||
refuse(dingU8cBillEntity);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("丽知:钉钉审批实例自动检查implement(List<String> processInstanceIds)报错,报错信息:{}", e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 审批拒绝后清除ding_talk_process_id、ding_res、approve、initiate、push_count++,push_process_ids
|
||||
* @param dingU8cBillEntity
|
||||
*/
|
||||
public void updateDingU8C(DingU8cBillEntity dingU8cBillEntity){
|
||||
dingU8cBillEntity.setDing_talk_process_id(null);
|
||||
dingU8cBillDao.update(dingU8cBillEntity);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private PushU8CByApiCode pushU8CByApiCode;
|
||||
/**
|
||||
* 审核付款单
|
||||
*/
|
||||
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity,String mobile) throws Exception {
|
||||
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity) throws Exception {
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
|
@ -278,7 +277,7 @@ public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
|||
bills.put("dwbm", dingU8cBillEntity.getU8c_code_corp());
|
||||
bills.put("opinion", "同意");
|
||||
// bills.put("operatorid", OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||
bills.put("operatorid", mobile);
|
||||
bills.put("operatorid", "tbadmin");
|
||||
bills.put("operatedate", now.toString());
|
||||
String jsonStr = JSONUtil.toJsonStr(bills);
|
||||
jsonStr = "{\"bills\":[" + jsonStr + "]}";
|
||||
|
@ -318,7 +317,7 @@ public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
|||
/**
|
||||
* 钉钉拒绝审批,http请求
|
||||
*/
|
||||
public void refuse(DingU8cBillEntity dingU8cBillEntity, String mobile) throws IOException {
|
||||
public void refuse(DingU8cBillEntity dingU8cBillEntity) throws IOException {
|
||||
// 服务器访问地址及端口,例如 http://ip:port
|
||||
String serviceUrl = OverallConstant.getOverAllValue("u8cApiUrl");
|
||||
// 接口地址
|
||||
|
@ -329,12 +328,12 @@ public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
|||
map.put("usercode", OverallConstant.getOverAllValue("u8cApiUsercodeCode")); // 用户
|
||||
map.put("password", OverallConstant.getOverAllValue("u8cApiPasswordCode")); // 密码,需要 MD5 加密后录入
|
||||
map.put("system", OverallConstant.getOverAllValue("u8cApiSystemCode")); // 系统编码
|
||||
map.put("custdevpclass", "nc.bs.ding.process.ProcessDingImpl"); //方法路径
|
||||
map.put("custdevpclass", "u8c.api.dev.dingTalk.RefuseApprove"); //方法路径
|
||||
|
||||
//请求体
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("instanceId", dingU8cBillEntity.getDing_talk_process_id());
|
||||
fileMap.put("userCode", mobile);//审批人
|
||||
fileMap.put("userCode", "tbadmin");//审批人
|
||||
fileMap.put("ckeckResult", "R");
|
||||
fileMap.put("ckeckNote", "无");
|
||||
String jsonFileMap = JSONUtil.toJsonStr(fileMap);
|
||||
|
|
|
@ -2,7 +2,10 @@ package com.hzya.frame.plugin.lets.plugin.transfer;
|
|||
|
||||
import com.hzya.frame.WebappApplication;
|
||||
import com.hzya.frame.plugin.lets.plugin.adjust.*;
|
||||
import com.hzya.frame.plugin.lets.plugin.dingtalk.DingCallBackPluginInitializer;
|
||||
import com.hzya.frame.plugin.lets.plugin.sales.RefundOnlyPluginInitializer;
|
||||
import com.hzya.frame.plugin.lets.plugin.sales.RefundOnlyPluginInitializerToB;
|
||||
import com.hzya.frame.plugin.lets.plugin.sales.RefundOnlyPluginInitializerToC;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -81,7 +84,7 @@ public class TransferTest {
|
|||
@Test
|
||||
public void t31(){
|
||||
// adjustInPluginInitializer.start("LETS-RE2024091100000001");
|
||||
adjustInPluginInitializer.start("LETS-RE2024110500000028");
|
||||
adjustInPluginInitializer.start("LETS-RE2024101700000004");
|
||||
}
|
||||
@Test
|
||||
public void t32(){
|
||||
|
@ -143,4 +146,25 @@ public class TransferTest {
|
|||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////仅退款
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////仅退款TOB
|
||||
@Autowired
|
||||
private RefundOnlyPluginInitializerToB refundOnlyPluginInitializerToB;
|
||||
////////////////////////////////////////////////////////////////////////////////////仅退款TOB
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////仅退款TOC
|
||||
@Autowired
|
||||
private RefundOnlyPluginInitializerToC refundOnlyPluginInitializerToC;
|
||||
////////////////////////////////////////////////////////////////////////////////////仅退款TOC
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////dingtalk
|
||||
@Autowired
|
||||
private DingCallBackPluginInitializer dingCallBackPluginInitializer;
|
||||
|
||||
@Test
|
||||
public void t1101(){
|
||||
dingCallBackPluginInitializer.start();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////dingtalk
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue