丽知:钉钉回调

This commit is contained in:
zhengyf 2024-11-01 08:45:56 +08:00
parent 224ab57805
commit 2643dd64d1
3 changed files with 123 additions and 25 deletions

View File

@ -70,6 +70,11 @@ public class OverallConstant {
//应收单
prodOverPublic.put("arapYsInsertApproveCode", "8000370069");//自定义档案内容查询
//付款单
prodOverPublic.put("arapFkInsetCode", "8000370044");//付款单审批
prodOverPublic.put("arapFkApproveCode", "8000370005");//付款单保存即审批
prodOverPublic.put("appId", "800037");//数智中台
prodOverPublic.put("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj");//数智中台

View File

@ -1,17 +1,23 @@
package com.hzya.frame.plugin.lets.dingtalk.callback.service.impl;
import cn.hutool.core.lang.Assert;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponseBody;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
import com.hzya.frame.plugin.lets.constant.OverallConstant;
import com.hzya.frame.plugin.lets.dingtalk.callback.service.CallBackService;
import com.hzya.frame.plugin.lets.dingtalk.dao.IDingU8cBillDao;
import com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity;
import com.hzya.frame.plugin.lets.dingtalk.utils.DingTalkUtils;
import com.hzya.frame.plugin.lets.dingtalk.vo.DingCallbackCrypto;
import com.hzya.frame.plugin.lets.u8cdto.ArapDjzb;
import com.hzya.frame.plugin.lets.u8cdto.GeneralBillVO_4ADto;
import com.hzya.frame.plugin.lets.util.pushData.Attribute;
import com.hzya.frame.plugin.lets.util.pushData.PushU8CByApiCode;
import com.hzya.frame.plugin.lets.util.pushData.ZTResult;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +25,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -79,7 +86,7 @@ public class CallBackServiceImpl implements CallBackService {
break;
case "PROC-AC33FC85-FB44-49FC-B926-1D966AE3BBD2":
logger.info("采购付款申请(新) -> PROC-AC33FC85-FB44-49FC-B926-1D966AE3BBD2");
// transferBill(eventJson);//特殊业务处理
transferBill(eventJson);//特殊业务处理
break;
}
@ -109,10 +116,15 @@ public class CallBackServiceImpl implements CallBackService {
* 回调审核付款单
*/
public void outSourceBill(JSONObject eventJson) throws Exception {
try {
//获取token
String token = getDingTalkToken();
//实例ID
String processInstanceId = eventJson.getString("processInstanceId");
DingU8cBillEntity dingU8cBillEntity = queryU8CDing(processInstanceId);
if (dingU8cBillEntity == null) {
Assert.state(false, "代理采购(付款单)->采购付款申请(店群专用)回调未查询到相关审批实例实例id{}", processInstanceId);
}
//查询实例的具体信息
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
@ -129,6 +141,34 @@ public class CallBackServiceImpl implements CallBackService {
//审批意见过滤掉START_PROCESS_INSTANCE发起流程实例
operationRecords = operationRecords.stream().filter(item -> !item.getType().equals("START_PROCESS_INSTANCE")).collect(Collectors.toList());
System.out.println(operationRecords);
String remark = "";
//钉钉问题记录执行明细
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecords operationRecord : operationRecords) {
//操作结果
switch (operationRecord.getResult()) {
case "AGREE":
dingU8cBillEntity.setDing_res("同意");
break;
case "REFUSE":
dingU8cBillEntity.setDing_res("拒绝");
break;
case "NONE":
dingU8cBillEntity.setDing_res("未处理");
break;
}
//处理意见
remark = operationRecord.getRemark();
}
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
//审批u8c单据
approveArapDjzb(dingU8cBillEntity, remark);
}catch (Exception e){
logger.error("代理采购(付款单)->采购付款申请(店群专用)回调报错:"+e);
}
}
/**
@ -137,8 +177,6 @@ public class CallBackServiceImpl implements CallBackService {
*/
public void agencyBill(JSONObject eventJson) throws Exception{
try {
//获取token
String token = getDingTalkToken();
//实例ID
@ -207,11 +245,66 @@ public class CallBackServiceImpl implements CallBackService {
}
}
public void transferBill(JSONObject eventJson) throws Exception{
//获取token
String token = getDingTalkToken();
}
@Autowired
private PushU8CByApiCode pushU8CByApiCode;
/**
* 审核付款单
* @param remark 处理意见
*/
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity,String remark){
ArapDjzb arapDjzb = new ArapDjzb();
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity,String remark) throws Exception {
Map bills=new HashMap();
bills.put("djbh",dingU8cBillEntity.getU8cBillCode());
bills.put("dwbm",dingU8cBillEntity.getU8cCodeCorp());
bills.put("opinion",remark);
bills.put("operatorid", OverallConstant.getOverAllValue("u8cApiZdrCode"));
String jsonStr = JSONUtil.toJsonStr(bills);
jsonStr="{\"bills\":["+jsonStr+"]}";
System.out.println(jsonStr);
//推送
String response="";
try {
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("arapFkApproveCode"), jsonStr);
//两层判断,一层中台转发,一层u8c返回
if ("false".equals(ztResult.getFlag())) {
//转发失败
response = JSONUtil.toJsonStr(ztResult.getAttribute());
Assert.state(false, "丽知:审核付款单审核失败,失败原因:{}", ztResult.getAttribute());
}
Attribute attribute = ztResult.getAttribute();
boolean isSuccess = false;
if ("success".equals(attribute.getStatus())) {
isSuccess = true;
}
if (!isSuccess) {
Assert.state(false, "推送U8C--> 丽知:审核付款单审核 失败 接口返回结果:{} ", response);
}
//成功
dingU8cBillEntity.setApprove("Y");
dingU8cBillDao.save(dingU8cBillEntity);
}catch (Exception e){
logger.error("推送U8C--> 丽知:审核付款单审核 失败"+e);
//失败
dingU8cBillEntity.setApprove("N");
dingU8cBillEntity.setPushInfo(e.getMessage());
dingU8cBillDao.save(dingU8cBillEntity);
}
}
public static void main(String[] args) {
Map bills=new HashMap();
bills.put("djbh","FK2108160001");
bills.put("dwbm","SHLZ");
bills.put("operatorid", "tbadmin");
String jsonStr = JSONUtil.toJsonStr(bills);
jsonStr="{\"bills\":["+jsonStr+"]}";
System.out.println(jsonStr);
}
}

View File

@ -13,7 +13,7 @@
<result property="pushInfo" column="push_info" jdbcType="VARCHAR"/>
<result property="dingTalkProcessId" column="ding_talk_process_id" jdbcType="VARCHAR"/>
<result property="ding_res" column="ding_res" jdbcType="VARCHAR"/>
<result property="approve" column="approve" jdbcType="approve"/>
<result property="approve" column="approve" jdbcType="VARCHAR"/>
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="sts" column="sts" jdbcType="VARCHAR"/>