丽知:钉钉回调、推送日志更新
This commit is contained in:
parent
942897faa6
commit
28be3efaa5
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponseBody;
|
import com.aliyun.dingtalkoauth2_1_0.models.GetAccessTokenResponseBody;
|
||||||
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
|
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
|
||||||
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
|
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
|
||||||
|
import com.dingtalk.api.response.OapiV2UserGetResponse;
|
||||||
import com.hzya.frame.plugin.lets.constant.OverallConstant;
|
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.callback.service.CallBackService;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.dao.IDingU8cBillDao;
|
import com.hzya.frame.plugin.lets.dingtalk.dao.IDingU8cBillDao;
|
||||||
|
@ -24,21 +25,47 @@ import com.hzya.frame.plugin.lets.util.QueryU8CEntityUtil;
|
||||||
import com.hzya.frame.plugin.lets.util.pushData.Attribute;
|
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.PushU8CByApiCode;
|
||||||
import com.hzya.frame.plugin.lets.util.pushData.ZTResult;
|
import com.hzya.frame.plugin.lets.util.pushData.ZTResult;
|
||||||
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
|
import org.apache.commons.httpclient.methods.PostMethod;
|
||||||
|
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||||
|
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回调:审批通过的(U):记录:
|
||||||
|
* push_info:success
|
||||||
|
* ding_talk_process_id
|
||||||
|
* modify_time:new Date()
|
||||||
|
* ding_res:
|
||||||
|
* approve:Y
|
||||||
|
* initiate:U
|
||||||
|
* 回调:审批通过的(D):记录:
|
||||||
|
* 全记录
|
||||||
|
* initiate:D
|
||||||
|
* <p>
|
||||||
|
* 回调:审批失败的(U):记录:
|
||||||
|
* push_info:success
|
||||||
|
* ding_talk_process_id
|
||||||
|
* modify_time:new Date()
|
||||||
|
* ding_res:
|
||||||
|
* approve:Y
|
||||||
|
* initiate:U
|
||||||
|
*/
|
||||||
@Service("callBackService")
|
@Service("callBackService")
|
||||||
public class CallBackServiceImpl implements CallBackService {
|
public class CallBackServiceImpl implements CallBackService {
|
||||||
|
|
||||||
protected static Logger logger = LogManager.getLogger(CallBackServiceImpl.class);
|
protected static Logger logger = LogManager.getLogger(CallBackServiceImpl.class);
|
||||||
public String dingId="";
|
public String dingId = "";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDingU8cBillDao dingU8cBillDao;
|
private IDingU8cBillDao dingU8cBillDao;
|
||||||
|
@ -79,7 +106,7 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
String eventType = eventJson.getString("EventType");
|
String eventType = eventJson.getString("EventType");
|
||||||
|
|
||||||
//防止钉钉回调
|
//防止钉钉回调
|
||||||
if(!eventJson.getString("processInstanceId").equals(dingId)) {
|
if (!eventJson.getString("processInstanceId").equals(dingId)) {
|
||||||
dingId = eventJson.getString("processInstanceId");
|
dingId = eventJson.getString("processInstanceId");
|
||||||
|
|
||||||
// 4. 根据EventType分类处理
|
// 4. 根据EventType分类处理
|
||||||
|
@ -120,6 +147,17 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
return tokenBody.getAccessToken();
|
return tokenBody.getAccessToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据钉钉userId获取手机号
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getMobileByUserId(String token, String userId) {
|
||||||
|
OapiV2UserGetResponse user = DingTalkUtils.getUserById(token, userId);
|
||||||
|
String mobile = user.getResult().getMobile();
|
||||||
|
return mobile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 委外采购(付款单)->采购付款申请(新)
|
* 委外采购(付款单)->采购付款申请(新)
|
||||||
* 回调,审核付款单
|
* 回调,审核付款单
|
||||||
|
@ -145,40 +183,30 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
} else if (processInstanceResponseBodyResult.getStatus().equals("COMPLETED")) {//审批完成
|
} else if (processInstanceResponseBodyResult.getStatus().equals("COMPLETED")) {//审批完成
|
||||||
logger.info("采购付款申请(新)--->审批完成");
|
logger.info("采购付款申请(新)--->审批完成");
|
||||||
}
|
}
|
||||||
//获取所有审批意见
|
|
||||||
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecords> operationRecords = processInstanceResponseBodyResult.getOperationRecords();
|
|
||||||
|
|
||||||
//审批意见过滤掉:START_PROCESS_INSTANCE:发起流程实例
|
|
||||||
operationRecords = operationRecords.stream().filter(item -> !item.getType().equals("START_PROCESS_INSTANCE")).collect(Collectors.toList());
|
|
||||||
System.out.println(operationRecords);
|
|
||||||
String remark = "";
|
String remark = "";
|
||||||
|
|
||||||
//钉钉问题记录执行明细
|
//任务列表,文档地址:https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.33293c33eWKtYM#/?devType=org&api=workflow_1.0%23GetProcessInstance
|
||||||
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecords operationRecord : operationRecords) {
|
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks> tasks = processInstanceResponseBodyResult.getTasks();
|
||||||
//操作结果
|
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks task : tasks) {
|
||||||
switch (operationRecord.getResult()) {
|
if ("COMPLETED".equals(task.getStatus())) {//完成状态
|
||||||
case "AGREE":
|
//获取人员得手机号作为u8c得审核人编码
|
||||||
dingU8cBillEntity.setDing_res("同意");
|
String userId = task.getUserId();
|
||||||
break;
|
String mobile = getMobileByUserId(token, userId);
|
||||||
case "REFUSE":
|
if ("AGREE".equals(task.getResult())) {
|
||||||
dingU8cBillEntity.setDing_res("拒绝");
|
//同意
|
||||||
break;
|
|
||||||
case "NONE":
|
|
||||||
dingU8cBillEntity.setDing_res("未处理");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//处理意见
|
|
||||||
remark = operationRecord.getRemark();
|
|
||||||
}
|
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
|
||||||
|
|
||||||
if("拒绝".equals(dingU8cBillEntity.getDing_res())||"未处理".equals(dingU8cBillEntity.getDing_res())){
|
|
||||||
//后续林姐姐给接口
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//审批u8c单据
|
//审批u8c单据
|
||||||
approveArapDjzb(dingU8cBillEntity, remark);
|
approveArapDjzb(dingU8cBillEntity, remark);
|
||||||
|
dingU8cBillEntity.setApprove("Y");
|
||||||
|
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||||
|
} else if ("REFUSE".equals(task.getResult())) {
|
||||||
|
//拒绝
|
||||||
|
//后续林姐姐给接口,拒绝之后清空process_id、approve:N
|
||||||
|
refuse(dingU8cBillEntity, mobile);
|
||||||
|
dingU8cBillEntity.setApprove("N");
|
||||||
|
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("代理采购(付款单)->采购付款申请(店群专用)回调报错:" + e);
|
logger.error("代理采购(付款单)->采购付款申请(店群专用)回调报错:" + e);
|
||||||
}
|
}
|
||||||
|
@ -236,9 +264,9 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
//处理意见
|
//处理意见
|
||||||
remark = operationRecord.getRemark();
|
remark = operationRecord.getRemark();
|
||||||
}
|
}
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||||
|
|
||||||
if("拒绝".equals(dingU8cBillEntity.getDing_res())||"未处理".equals(dingU8cBillEntity.getDing_res())){
|
if ("拒绝".equals(dingU8cBillEntity.getDing_res()) || "未处理".equals(dingU8cBillEntity.getDing_res())) {
|
||||||
//后续林姐姐给接口
|
//后续林姐姐给接口
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +309,7 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
DingU8cBillEntity dingU8cBillEntity = queryU8CDing(processInstanceId);
|
DingU8cBillEntity dingU8cBillEntity = queryU8CDing(processInstanceId);
|
||||||
if (dingU8cBillEntity == null) {
|
if (dingU8cBillEntity == null) {
|
||||||
//新增u8c付款单、保存日志、上传附件
|
//新增u8c付款单、保存日志、上传附件
|
||||||
addArapBill(processInstanceId,token);
|
addArapBill(processInstanceId, token);
|
||||||
} else {
|
} else {
|
||||||
//查询实例的具体信息
|
//查询实例的具体信息
|
||||||
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
||||||
|
@ -319,9 +347,9 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
//处理意见
|
//处理意见
|
||||||
remark = operationRecord.getRemark();
|
remark = operationRecord.getRemark();
|
||||||
}
|
}
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||||
|
|
||||||
if("拒绝".equals(dingU8cBillEntity.getDing_res())||"未处理".equals(dingU8cBillEntity.getDing_res())){
|
if ("拒绝".equals(dingU8cBillEntity.getDing_res()) || "未处理".equals(dingU8cBillEntity.getDing_res())) {
|
||||||
//后续林姐姐给接口
|
//后续林姐姐给接口
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -336,8 +364,9 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PushU8CByApiCode pushU8CByApiCode;
|
private PushU8CByApiCode pushU8CByApiCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审核付款单
|
* 审核付款单,并保存日志
|
||||||
*
|
*
|
||||||
* @param remark 处理意见
|
* @param remark 处理意见
|
||||||
*/
|
*/
|
||||||
|
@ -375,28 +404,30 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
}
|
}
|
||||||
//成功
|
//成功
|
||||||
dingU8cBillEntity.setApprove("Y");
|
dingU8cBillEntity.setApprove("Y");
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("推送U8C--> 丽知:审核付款单审核 失败" + e);
|
logger.error("推送U8C--> 丽知:审核付款单审核 失败" + e);
|
||||||
//失败
|
//失败
|
||||||
dingU8cBillEntity.setApprove("N");
|
dingU8cBillEntity.setApprove("N");
|
||||||
dingU8cBillEntity.setPushInfo(e.getMessage());
|
dingU8cBillEntity.setPushInfo(e.getMessage());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private QueryU8CEntityUtil queryU8CEntityUtil;
|
private QueryU8CEntityUtil queryU8CEntityUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileUtil fileUtil;
|
private FileUtil fileUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PushU8CFileUtil pushU8CFileUtil;
|
private PushU8CFileUtil pushU8CFileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 付款单新增
|
* 付款单新增
|
||||||
* 1、付款单保存及审批
|
* 1、付款单保存及审批
|
||||||
* 2、附件上传
|
* 2、附件上传
|
||||||
*/
|
*/
|
||||||
public void addArapBill(String processInstanceId,String token) throws Exception {
|
public void addArapBill(String processInstanceId, String token) throws Exception {
|
||||||
//查询实例的具体信息
|
//查询实例的具体信息
|
||||||
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
||||||
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
||||||
|
@ -414,7 +445,7 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
String ly = "";
|
String ly = "";
|
||||||
String je = "";
|
String je = "";
|
||||||
String bz = "";
|
String bz = "";
|
||||||
String fjJson="";
|
String fjJson = "";
|
||||||
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues formComponentValue : formComponentValues) {
|
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues formComponentValue : formComponentValues) {
|
||||||
if ("费用所属公司".equals(formComponentValue.getName())) {
|
if ("费用所属公司".equals(formComponentValue.getName())) {
|
||||||
corpName = formComponentValue.getValue();
|
corpName = formComponentValue.getValue();
|
||||||
|
@ -437,13 +468,13 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
if ("备注".equals(formComponentValue.getName())) {
|
if ("备注".equals(formComponentValue.getName())) {
|
||||||
bz = formComponentValue.getValue();
|
bz = formComponentValue.getValue();
|
||||||
}
|
}
|
||||||
if("DDAttachment".equals(formComponentValue.getComponentType())){
|
if ("DDAttachment".equals(formComponentValue.getComponentType())) {
|
||||||
fjJson = formComponentValue.getValue();
|
fjJson = formComponentValue.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String mapStr="";
|
String mapStr = "";
|
||||||
String response="";
|
String response = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ArapDjzbVO billvo = new ArapDjzbVO();
|
ArapDjzbVO billvo = new ArapDjzbVO();
|
||||||
|
@ -486,7 +517,7 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
children.add(childrenvo);
|
children.add(childrenvo);
|
||||||
billvo.setParentvo(parentvo);
|
billvo.setParentvo(parentvo);
|
||||||
billvo.setChildren(children);
|
billvo.setChildren(children);
|
||||||
mapStr="{\"billvo\":["+JSONUtil.toJsonStr(billvo)+"]}";
|
mapStr = "{\"billvo\":[" + JSONUtil.toJsonStr(billvo) + "]}";
|
||||||
//推送u8c
|
//推送u8c
|
||||||
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("arapFkApproveCode"), mapStr);
|
ZTResult ztResult = pushU8CByApiCode.pushByCode(OverallConstant.getOverAllValue("arapFkApproveCode"), mapStr);
|
||||||
if ("false".equals(ztResult.getFlag())) {
|
if ("false".equals(ztResult.getFlag())) {
|
||||||
|
@ -522,7 +553,7 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
dingU8cBillEntity.setCreate_time(new Date());//创建时间
|
dingU8cBillEntity.setCreate_time(new Date());//创建时间
|
||||||
dingU8cBillEntity.setApprove(null);//Y审核 N不审核
|
dingU8cBillEntity.setApprove(null);//Y审核 N不审核
|
||||||
dingU8cBillEntity.setInitiate("D");//D钉钉发起,U u8c发起
|
dingU8cBillEntity.setInitiate("D");//D钉钉发起,U u8c发起
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||||
|
|
||||||
//上传附件,获取附件的表单,转base64,上传u8c
|
//上传附件,获取附件的表单,转base64,上传u8c
|
||||||
List<FileModuleVO> fileModuleVOList = JSONUtil.toList(fjJson, FileModuleVO.class);
|
List<FileModuleVO> fileModuleVOList = JSONUtil.toList(fjJson, FileModuleVO.class);
|
||||||
|
@ -530,9 +561,9 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
|
|
||||||
for (SysFileVO sysFileVO : sysFileVOS) {
|
for (SysFileVO sysFileVO : sysFileVOS) {
|
||||||
//上传u8c单据
|
//上传u8c单据
|
||||||
pushU8CFileUtil.pushFile(vbillId,sysFileVO);
|
pushU8CFileUtil.pushFile(vbillId, sysFileVO);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
//成功
|
//成功
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
||||||
|
@ -547,7 +578,7 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
dingU8cBillEntity.setCreate_time(new Date());//创建时间
|
dingU8cBillEntity.setCreate_time(new Date());//创建时间
|
||||||
dingU8cBillEntity.setApprove(null);//Y审核 N不审核
|
dingU8cBillEntity.setApprove(null);//Y审核 N不审核
|
||||||
dingU8cBillEntity.setInitiate("D");//D钉钉发起,U u8c发起
|
dingU8cBillEntity.setInitiate("D");//D钉钉发起,U u8c发起
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,4 +598,45 @@ public class CallBackServiceImpl implements CallBackService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钉钉拒绝审批,http请求
|
||||||
|
*/
|
||||||
|
public void refuse(DingU8cBillEntity dingU8cBillEntity, String mobile) throws IOException {
|
||||||
|
// 服务器访问地址及端口,例如 http://ip:port
|
||||||
|
String serviceUrl = OverallConstant.getOverAllValue("u8cApiUrl");
|
||||||
|
// 接口地址
|
||||||
|
String serviceName = "/u8cloud/api/dev/define";
|
||||||
|
|
||||||
|
//请求头
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
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<String, String> fileMap = new HashMap<>();
|
||||||
|
fileMap.put("instanceId", dingU8cBillEntity.getDingTalkProcessId());
|
||||||
|
fileMap.put("userCode", mobile);//审批人
|
||||||
|
fileMap.put("ckeckResult", "同意");
|
||||||
|
fileMap.put("ckeckNote", "无");
|
||||||
|
String jsonFileMap = JSONUtil.toJsonStr(fileMap);
|
||||||
|
String json = "{\"json\":" + jsonFileMap + "}";
|
||||||
|
|
||||||
|
|
||||||
|
//请求
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
PostMethod httpPost = new PostMethod(serviceUrl + serviceName);
|
||||||
|
httpPost.setRequestHeader("content-type", "application/json;charset=utf-8");
|
||||||
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
|
httpPost.setRequestHeader(entry.getKey(), entry.getValue()
|
||||||
|
.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
RequestEntity entity = new StringRequestEntity(json, "application/json", "UTF-8");
|
||||||
|
httpPost.setRequestEntity(entity);
|
||||||
|
httpClient.executeMethod(httpPost);
|
||||||
|
String responseBodyAsString = httpPost.getResponseBodyAsString();
|
||||||
|
System.out.println(responseBodyAsString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,9 @@ import com.hzya.frame.basedao.dao.IBaseDao;
|
||||||
* @since 2024-10-28 15:45:32
|
* @since 2024-10-28 15:45:32
|
||||||
*/
|
*/
|
||||||
public interface IDingU8cBillDao extends IBaseDao<DingU8cBillEntity, String> {
|
public interface IDingU8cBillDao extends IBaseDao<DingU8cBillEntity, String> {
|
||||||
public void saveOrUpDateV2(DingU8cBillEntity dingU8cBillEntity);
|
public void pushSaveOrUpdate(DingU8cBillEntity dingU8cBillEntity);
|
||||||
|
|
||||||
|
public void callBackSaveOrUpdate(DingU8cBillEntity dingU8cBillEntity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.hzya.frame.plugin.lets.dingtalk.dao.impl;
|
package com.hzya.frame.plugin.lets.dingtalk.dao.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity;
|
import com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity;
|
||||||
import com.hzya.frame.plugin.lets.dingtalk.dao.IDingU8cBillDao;
|
import com.hzya.frame.plugin.lets.dingtalk.dao.IDingU8cBillDao;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
||||||
|
@ -11,112 +14,141 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (DingU8cBill)表数据库访问层
|
* (DingU8cBill)表数据库访问层
|
||||||
|
* 推送状态
|
||||||
* ->Y
|
* ->Y
|
||||||
* ->N
|
* ->N
|
||||||
* N->N
|
* N->N
|
||||||
* N->Y
|
* N->Y
|
||||||
|
* 回调状态
|
||||||
|
* ->Y
|
||||||
* Y->Y
|
* Y->Y
|
||||||
|
* Y->N
|
||||||
|
*
|
||||||
* @author makejava
|
* @author makejava
|
||||||
* @since 2024-10-28 15:45:32
|
* @since 2024-10-28 15:45:32
|
||||||
*/
|
*/
|
||||||
@Repository("dingU8cBillDao")
|
@Repository("dingU8cBillDao")
|
||||||
public class DingU8cBillDaoImpl extends MybatisGenericDao<DingU8cBillEntity, String> implements IDingU8cBillDao{
|
public class DingU8cBillDaoImpl extends MybatisGenericDao<DingU8cBillEntity, String> implements IDingU8cBillDao {
|
||||||
|
Logger logger = LoggerFactory.getLogger(DingU8cBillDaoImpl.class);
|
||||||
// private IDingU8cBillDao dingU8cBillDao;
|
|
||||||
// @Override
|
|
||||||
// public void saveOrUpDateV2(DingU8cBillEntity dingU8cBillEntityNew) {
|
|
||||||
// DingU8cBillEntity dingU8cBill = new DingU8cBillEntity();
|
|
||||||
// String u8cCodeCorp = dingU8cBillEntityNew.getU8cCodeCorp();
|
|
||||||
// String u8cBillCode = dingU8cBillEntityNew.getU8cBillCode();
|
|
||||||
// String u8cBillId = dingU8cBillEntityNew.getU8cBillId();
|
|
||||||
// String dingTalkProcessId = dingU8cBillEntityNew.getDingTalkProcessId();
|
|
||||||
// dingU8cBill.setU8cCodeCorp(u8cCodeCorp);
|
|
||||||
// dingU8cBill.setU8cBillCode(u8cBillCode);
|
|
||||||
// dingU8cBill.setU8cBillId(u8cBillId);
|
|
||||||
// dingU8cBill.setDingTalkProcessId(dingTalkProcessId);
|
|
||||||
// dingU8cBill.setSts("Y");
|
|
||||||
// List<DingU8cBillEntity> query = this.query(dingU8cBill);
|
|
||||||
// if (query.size() == 0) {
|
|
||||||
// //->N
|
|
||||||
// //->Y
|
|
||||||
// this.save(dingU8cBillEntityNew);
|
|
||||||
// }else {
|
|
||||||
// DingU8cBillEntity dingU8cBillEntity = query.get(0);
|
|
||||||
// String pushStatus = dingU8cBillEntity.getPushStatus();
|
|
||||||
// String pushStatusNew = dingU8cBillEntityNew.getPushStatus();
|
|
||||||
// if("N".equals(pushStatus)&&"N".equals(pushStatusNew)){
|
|
||||||
// //N->N
|
|
||||||
// dingU8cBill.setId(dingU8cBillEntity.getId());
|
|
||||||
// dingU8cBill.setModify_time(new Date());
|
|
||||||
// dingU8cBill.setPushStatus("N");
|
|
||||||
// dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
|
||||||
// this.update(dingU8cBill);
|
|
||||||
// }else if("N".equals(pushStatus)&&"Y".equals(pushStatusNew)){
|
|
||||||
// //N->Y
|
|
||||||
// dingU8cBill.setId(dingU8cBillEntity.getId());
|
|
||||||
// dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());
|
|
||||||
// dingU8cBill.setModify_time(new Date());
|
|
||||||
// dingU8cBill.setPushStatus("Y");
|
|
||||||
// dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
|
||||||
// this.update(dingU8cBill);
|
|
||||||
// }else if("Y".equals(pushStatus)&&"Y".equals(pushStatusNew)){
|
|
||||||
// //Y->Y
|
|
||||||
// dingU8cBill.setId(dingU8cBillEntity.getId());
|
|
||||||
// dingU8cBill.setModify_time(new Date());
|
|
||||||
// dingU8cBill.setDing_res(dingU8cBillEntityNew.getDing_res());
|
|
||||||
// dingU8cBill.setApprove(dingU8cBillEntityNew.getApprove());
|
|
||||||
// this.update(dingU8cBill);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据:公司、单据号、实例id、来源D|U
|
* 根据:公司、单据号、实例id、来源D|U
|
||||||
* @param dingU8cBillEntityNew
|
* ->Y
|
||||||
|
* ->N
|
||||||
|
* N->N
|
||||||
|
* N->Y
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveOrUpDateV2(DingU8cBillEntity dingU8cBillEntityNew) {
|
public void pushSaveOrUpdate(DingU8cBillEntity dingU8cBillEntityNew) {
|
||||||
DingU8cBillEntity dingU8cBill = new DingU8cBillEntity();
|
DingU8cBillEntity dingU8cBill = new DingU8cBillEntity();
|
||||||
dingU8cBill.setU8cCodeCorp(dingU8cBillEntityNew.getU8cCodeCorp());//公司
|
dingU8cBill.setU8cCodeCorp(dingU8cBillEntityNew.getU8cCodeCorp());//公司
|
||||||
dingU8cBill.setU8cBillCode(dingU8cBillEntityNew.getU8cBillCode());//单据号
|
dingU8cBill.setU8cBillCode(dingU8cBillEntityNew.getU8cBillCode());//单据号
|
||||||
dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());//实例id
|
// dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());//实例id
|
||||||
dingU8cBill.setInitiate(dingU8cBillEntityNew.getInitiate());//来源平台
|
dingU8cBill.setInitiate(dingU8cBillEntityNew.getInitiate());//来源平台,默认是U,如果发自钉钉会传D
|
||||||
List<DingU8cBillEntity> query = this.query(dingU8cBill);
|
List<DingU8cBillEntity> query = this.query(dingU8cBill);
|
||||||
if(query.size()==0){
|
if (query.size() == 0) {
|
||||||
|
if("N".equals(dingU8cBillEntityNew.getPushStatus())){
|
||||||
//->N
|
//->N
|
||||||
//->Y
|
|
||||||
this.save(dingU8cBillEntityNew);
|
this.save(dingU8cBillEntityNew);
|
||||||
}else {
|
} else if ("Y".equals(dingU8cBillEntityNew.getPushStatus())) {
|
||||||
|
//->Y
|
||||||
|
dingU8cBillEntityNew.setPush_count(1L);
|
||||||
|
dingU8cBillEntityNew.setPush_process_ids(dingU8cBillEntityNew.getDingTalkProcessId());
|
||||||
|
this.save(dingU8cBillEntityNew);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
DingU8cBillEntity dingU8cBillEntity = query.get(0);
|
DingU8cBillEntity dingU8cBillEntity = query.get(0);
|
||||||
String pushStatus = dingU8cBillEntity.getPushStatus();
|
String pushStatus = dingU8cBillEntity.getPushStatus();
|
||||||
String pushStatusNew = dingU8cBillEntityNew.getPushStatus();
|
String pushStatusNew = dingU8cBillEntityNew.getPushStatus();
|
||||||
if("N".equals(pushStatus)&&"N".equals(pushStatusNew)){
|
if ("N".equals(pushStatus) && "N".equals(pushStatusNew)) {
|
||||||
//N->N
|
//N->N
|
||||||
dingU8cBill.setId(dingU8cBillEntity.getId());
|
dingU8cBill.setId(dingU8cBillEntity.getId());
|
||||||
dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());
|
|
||||||
dingU8cBill.setModify_time(new Date());
|
dingU8cBill.setModify_time(new Date());
|
||||||
dingU8cBill.setPushStatus("N");
|
dingU8cBill.setPushStatus("N");
|
||||||
dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
||||||
this.update(dingU8cBill);
|
this.update(dingU8cBill);
|
||||||
} else if ("N".equals(pushStatus)&&"Y".equals(pushStatusNew)) {
|
} else if ("N".equals(pushStatus) && "Y".equals(pushStatusNew)) {
|
||||||
//N->Y
|
//N->Y,可能重复推送
|
||||||
dingU8cBill.setId(dingU8cBillEntity.getId());
|
dingU8cBill.setId(dingU8cBillEntity.getId());
|
||||||
dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());
|
dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());
|
||||||
dingU8cBill.setModify_time(new Date());
|
dingU8cBill.setModify_time(new Date());
|
||||||
dingU8cBill.setPushStatus("Y");
|
dingU8cBill.setPushStatus("Y");
|
||||||
dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
||||||
|
dingU8cBill.setPush_count(dingU8cBillEntity.getPush_count() == null ? 1L : dingU8cBillEntityNew.getPush_count() + 1);
|
||||||
|
dingU8cBill.setPush_process_ids(dingU8cBillEntity.getPush_process_ids() == null ? dingU8cBillEntityNew.getDingTalkProcessId() : dingU8cBillEntityNew.getPush_process_ids() + "," + dingU8cBillEntityNew.getDingTalkProcessId());
|
||||||
this.update(dingU8cBill);
|
this.update(dingU8cBill);
|
||||||
} else if ("Y".equals(pushStatus)&&"Y".equals(pushStatusNew)) {
|
}
|
||||||
//Y->Y
|
// else if ("Y".equals(pushStatus)&&"Y".equals(pushStatusNew)) {
|
||||||
|
// //Y->Y
|
||||||
|
// dingU8cBill.setId(dingU8cBillEntity.getId());
|
||||||
|
// dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());
|
||||||
|
// dingU8cBill.setModify_time(new Date());
|
||||||
|
// dingU8cBill.setDing_res(dingU8cBillEntityNew.getDing_res());
|
||||||
|
// dingU8cBill.setApprove(dingU8cBillEntityNew.getApprove());
|
||||||
|
// dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
||||||
|
// dingU8cBill.setPush_count(dingU8cBillEntityNew.getPush_count());
|
||||||
|
// dingU8cBill.setPush_process_ids(dingU8cBillEntityNew.getPush_process_ids());
|
||||||
|
// this.update(dingU8cBill);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钉钉回调
|
||||||
|
* ->Y 钉钉发起单据,审批不通过的不接
|
||||||
|
* Y->Y 钉钉审批通过
|
||||||
|
* Y->N 钉钉审批拒绝
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void callBackSaveOrUpdate(DingU8cBillEntity dingU8cBillEntityNew) {
|
||||||
|
try {
|
||||||
|
DingU8cBillEntity dingU8cBill = new DingU8cBillEntity();
|
||||||
|
dingU8cBill.setU8cCodeCorp(dingU8cBillEntityNew.getU8cCodeCorp());//公司
|
||||||
|
dingU8cBill.setU8cBillCode(dingU8cBillEntityNew.getU8cBillCode());//单据号
|
||||||
|
dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());//实例id
|
||||||
|
// dingU8cBill.setInitiate(dingU8cBillEntityNew.getInitiate());//来源平台,默认是U,如果发自钉钉会传D
|
||||||
|
List<DingU8cBillEntity> query = this.query(dingU8cBill);
|
||||||
|
if (query.size() == 0) {
|
||||||
|
//->Y 钉钉发起单据
|
||||||
|
if ("D".equals(dingU8cBillEntityNew.getInitiate())) {
|
||||||
|
this.save(dingU8cBillEntityNew);
|
||||||
|
}
|
||||||
|
} else if (query.size() == 1) {
|
||||||
|
DingU8cBillEntity dingU8cBillEntity = query.get(0);
|
||||||
|
String pushStatus = dingU8cBillEntity.getPushStatus();
|
||||||
|
String pushStatusNew = dingU8cBillEntityNew.getPushStatus();
|
||||||
|
String approveNew = dingU8cBillEntityNew.getApprove();
|
||||||
|
//Y->Y 钉钉审批通过
|
||||||
|
//Y->N 钉钉审批拒绝
|
||||||
|
if("Y".equals(pushStatus) && "Y".equals(approveNew)){
|
||||||
|
//Y->Y 钉钉审批通过,推送成功,审批成功
|
||||||
dingU8cBill.setId(dingU8cBillEntity.getId());
|
dingU8cBill.setId(dingU8cBillEntity.getId());
|
||||||
dingU8cBill.setDingTalkProcessId(dingU8cBillEntityNew.getDingTalkProcessId());
|
|
||||||
dingU8cBill.setModify_time(new Date());
|
|
||||||
dingU8cBill.setDing_res(dingU8cBillEntityNew.getDing_res());
|
dingU8cBill.setDing_res(dingU8cBillEntityNew.getDing_res());
|
||||||
dingU8cBill.setApprove(dingU8cBillEntityNew.getApprove());
|
dingU8cBill.setApprove("Y");
|
||||||
|
dingU8cBill.setModify_time(new Date());
|
||||||
|
dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
||||||
|
this.update(dingU8cBill);
|
||||||
|
} else if ("Y".equals(pushStatus) && "N".equals(approveNew)) {
|
||||||
|
//Y->N 钉钉审批拒绝,推送成功,审批拒绝
|
||||||
|
dingU8cBill.setId(dingU8cBillEntity.getId());
|
||||||
|
dingU8cBill.setApprove("N");
|
||||||
|
dingU8cBill.setPushStatus("N");
|
||||||
|
dingU8cBill.setDing_res(null);
|
||||||
|
dingU8cBill.setDingTalkProcessId(null);
|
||||||
dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
dingU8cBill.setPushInfo(dingU8cBillEntityNew.getPushInfo());
|
||||||
this.update(dingU8cBill);
|
this.update(dingU8cBill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Assert.state(false, "钉钉回调报错,根据公司:{}、单据号:{}、实例id:{},查询单据不唯一。请检查!", dingU8cBillEntityNew.getU8cCodeCorp(), dingU8cBillEntityNew.getU8cBillCode(), dingU8cBillEntityNew.getDingTalkProcessId());
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("钉钉回调报错:{}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,11 @@ public class DingU8cBillEntity extends BaseEntity {
|
||||||
/** D钉钉发起,U u8c发起 */
|
/** D钉钉发起,U u8c发起 */
|
||||||
private String initiate="U";
|
private String initiate="U";
|
||||||
|
|
||||||
|
/** 发起次数 */
|
||||||
|
private Long push_count;
|
||||||
|
/** 历史实例id */
|
||||||
|
private String push_process_ids;
|
||||||
|
|
||||||
public DingU8cBillEntity(String u8cPkCorp, String u8cCodeCorp, String u8cBillType, String u8cBillCode, String u8cBillId, String pushStatus, String pushInfo, String dingTalkProcessId, String ding_res) {
|
public DingU8cBillEntity(String u8cPkCorp, String u8cCodeCorp, String u8cBillType, String u8cBillCode, String u8cBillId, String pushStatus, String pushInfo, String dingTalkProcessId, String ding_res) {
|
||||||
this.u8cPkCorp = u8cPkCorp;
|
this.u8cPkCorp = u8cPkCorp;
|
||||||
this.u8cCodeCorp = u8cCodeCorp;
|
this.u8cCodeCorp = u8cCodeCorp;
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
<result property="ding_res" column="ding_res" jdbcType="VARCHAR"/>
|
<result property="ding_res" column="ding_res" jdbcType="VARCHAR"/>
|
||||||
<result property="approve" column="approve" jdbcType="VARCHAR"/>
|
<result property="approve" column="approve" jdbcType="VARCHAR"/>
|
||||||
<result property="initiate" column="initiate" jdbcType="VARCHAR"/>
|
<result property="initiate" column="initiate" jdbcType="VARCHAR"/>
|
||||||
|
<result property="push_count" column="push_count" jdbcType="INTEGER"/>
|
||||||
|
<result property="push_process_ids" column="push_process_ids" jdbcType="VARCHAR"/>
|
||||||
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
|
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="sts" column="sts" jdbcType="VARCHAR"/>
|
<result property="sts" column="sts" jdbcType="VARCHAR"/>
|
||||||
|
@ -33,6 +35,8 @@
|
||||||
,ding_res
|
,ding_res
|
||||||
,approve
|
,approve
|
||||||
,initiate
|
,initiate
|
||||||
|
,push_count
|
||||||
|
,push_process_ids
|
||||||
,modify_time
|
,modify_time
|
||||||
,create_time
|
,create_time
|
||||||
,sts
|
,sts
|
||||||
|
@ -55,6 +59,8 @@
|
||||||
<if test="ding_res != null and ding_res != ''"> and ding_res = #{ding_res} </if>
|
<if test="ding_res != null and ding_res != ''"> and ding_res = #{ding_res} </if>
|
||||||
<if test="approve != null and approve != ''"> and approve = #{approve} </if>
|
<if test="approve != null and approve != ''"> and approve = #{approve} </if>
|
||||||
<if test="initiate != null and initiate != ''"> and initiate = #{initiate} </if>
|
<if test="initiate != null and initiate != ''"> and initiate = #{initiate} </if>
|
||||||
|
<if test="push_count != null and push_count != ''"> and push_count = #{push_count} </if>
|
||||||
|
<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="modify_time != null"> and modify_time = #{modify_time} </if>
|
||||||
<if test="create_time != null"> and create_time = #{create_time} </if>
|
<if test="create_time != null"> and create_time = #{create_time} </if>
|
||||||
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
||||||
|
@ -77,6 +83,8 @@
|
||||||
<if test="ding_res != null and ding_res != ''"> and ding_res = #{ding_res} </if>
|
<if test="ding_res != null and ding_res != ''"> and ding_res = #{ding_res} </if>
|
||||||
<if test="approve != null and approve != ''"> and approve = #{approve} </if>
|
<if test="approve != null and approve != ''"> and approve = #{approve} </if>
|
||||||
<if test="initiate != null and initiate != ''"> and initiate = #{initiate} </if>
|
<if test="initiate != null and initiate != ''"> and initiate = #{initiate} </if>
|
||||||
|
<if test="push_count != null and push_count != ''"> and push_count = #{push_count} </if>
|
||||||
|
<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="modify_time != null"> and modify_time = #{modify_time} </if>
|
||||||
<if test="create_time != null"> and create_time = #{create_time} </if>
|
<if test="create_time != null"> and create_time = #{create_time} </if>
|
||||||
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
<if test="sts != null and sts != ''"> and sts = #{sts} </if>
|
||||||
|
@ -102,6 +110,8 @@
|
||||||
<if test="ding_res != null and ding_res != ''"> and ding_res like concat('%',#{ding_res},'%') </if>
|
<if test="ding_res != null and ding_res != ''"> and ding_res like concat('%',#{ding_res},'%') </if>
|
||||||
<if test="approve != null and approve != ''"> and approve like concat('%',#{approve},'%') </if>
|
<if test="approve != null and approve != ''"> and approve like concat('%',#{approve},'%') </if>
|
||||||
<if test="initiate != null and initiate != ''"> and initiate like concat('%',#{initiate},'%') </if>
|
<if test="initiate != null and initiate != ''"> and initiate like concat('%',#{initiate},'%') </if>
|
||||||
|
<if test="push_count != null and push_count != ''"> and push_count like concat('%',#{push_count},'%') </if>
|
||||||
|
<if test="push_process_ids != null and push_process_ids != ''"> and push_process_ids like concat('%',#{push_process_ids},'%') </if>
|
||||||
<if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
|
<if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
|
||||||
<if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
|
<if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
|
||||||
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
|
<if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
|
||||||
|
@ -127,6 +137,8 @@
|
||||||
<if test="ding_res != null and ding_res != ''"> or ding_res = #{ding_res} </if>
|
<if test="ding_res != null and ding_res != ''"> or ding_res = #{ding_res} </if>
|
||||||
<if test="approve != null and approve != ''"> or approve = #{approve} </if>
|
<if test="approve != null and approve != ''"> or approve = #{approve} </if>
|
||||||
<if test="initiate != null and initiate != ''"> or initiate = #{initiate} </if>
|
<if test="initiate != null and initiate != ''"> or initiate = #{initiate} </if>
|
||||||
|
<if test="push_count != null and push_count != ''"> or push_count = #{push_count} </if>
|
||||||
|
<if test="push_process_ids != null and push_process_ids != ''"> or push_process_ids = #{push_process_ids} </if>
|
||||||
<if test="modify_time != null"> or modify_time = #{modify_time} </if>
|
<if test="modify_time != null"> or modify_time = #{modify_time} </if>
|
||||||
<if test="create_time != null"> or create_time = #{create_time} </if>
|
<if test="create_time != null"> or create_time = #{create_time} </if>
|
||||||
<if test="sts != null and sts != ''"> or sts = #{sts} </if>
|
<if test="sts != null and sts != ''"> or sts = #{sts} </if>
|
||||||
|
@ -150,6 +162,8 @@
|
||||||
<if test="ding_res != null and ding_res != ''"> ding_res , </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="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>
|
||||||
<if test="modify_time != null"> modify_time , </if>
|
<if test="modify_time != null"> modify_time , </if>
|
||||||
<if test="create_time != null"> create_time , </if>
|
<if test="create_time != null"> create_time , </if>
|
||||||
<if test="sts != null and sts != ''"> sts , </if>
|
<if test="sts != null and sts != ''"> sts , </if>
|
||||||
|
@ -169,6 +183,8 @@
|
||||||
<if test="ding_res != null and ding_res != ''"> #{ding_res} ,</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="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>
|
||||||
<if test="modify_time != null"> #{modify_time} ,</if>
|
<if test="modify_time != null"> #{modify_time} ,</if>
|
||||||
<if test="create_time != null"> #{create_time} ,</if>
|
<if test="create_time != null"> #{create_time} ,</if>
|
||||||
<if test="sts != null and sts != ''"> #{sts} ,</if>
|
<if test="sts != null and sts != ''"> #{sts} ,</if>
|
||||||
|
@ -191,12 +207,43 @@ update ding_u8c_bill set
|
||||||
<if test="ding_res != null and ding_res != ''"> ding_res = #{ding_res},</if>
|
<if test="ding_res != null and ding_res != ''"> ding_res = #{ding_res},</if>
|
||||||
<if test="approve != null and approve != ''"> approve = #{approve},</if>
|
<if test="approve != null and approve != ''"> approve = #{approve},</if>
|
||||||
<if test="initiate != null and initiate != ''"> initiate = #{initiate},</if>
|
<if test="initiate != null and initiate != ''"> initiate = #{initiate},</if>
|
||||||
|
<if test="push_count != null and push_count != ''"> push_count = #{push_count},</if>
|
||||||
|
<if test="push_process_ids != null and push_process_ids != ''"> push_process_ids = #{push_process_ids},</if>
|
||||||
<if test="modify_time != null"> modify_time = #{modify_time},</if>
|
<if test="modify_time != null"> modify_time = #{modify_time},</if>
|
||||||
<if test="create_time != null"> create_time = #{create_time},</if>
|
<if test="create_time != null"> create_time = #{create_time},</if>
|
||||||
<if test="sts != null and sts != ''"> sts = #{sts},</if>
|
<if test="sts != null and sts != ''"> sts = #{sts},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<!--通过主键修改方法-->
|
||||||
|
<update id="entity_updateV2" parameterType = "com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity" >
|
||||||
|
update ding_u8c_bill set
|
||||||
|
<trim suffix="" suffixOverrides=",">
|
||||||
|
<if test="u8cPkCorp != null and u8cPkCorp != ''"> u8c_pk_corp = #{u8cPkCorp},</if>
|
||||||
|
<if test="u8cCodeCorp != null and u8cCodeCorp != ''"> u8c_code_corp = #{u8cCodeCorp},</if>
|
||||||
|
<if test="u8cBillType != null and u8cBillType != ''"> u8c_bill_type = #{u8cBillType},</if>
|
||||||
|
<if test="u8cBillCode != null and u8cBillCode != ''"> u8c_bill_code = #{u8cBillCode},</if>
|
||||||
|
<if test="u8cBillId != null and u8cBillId != ''"> u8c_bill_id = #{u8cBillId},</if>
|
||||||
|
<if test="pushStatus != null and pushStatus != ''"> push_status = #{pushStatus},</if>
|
||||||
|
<if test="pushStatus == null"> push_status = null,</if>
|
||||||
|
<if test="pushInfo != null and pushInfo != ''"> push_info = #{pushInfo},</if>
|
||||||
|
<if test="pushInfo == null"> push_info = null,</if>
|
||||||
|
<if test="dingTalkProcessId != null and dingTalkProcessId != ''"> ding_talk_process_id = #{dingTalkProcessId},</if>
|
||||||
|
<if test="dingTalkProcessId == null"> ding_talk_process_id = null,</if>
|
||||||
|
<if test="ding_res != null and ding_res != ''"> ding_res = #{ding_res},</if>
|
||||||
|
<if test="ding_res == null"> ding_res = null,</if>
|
||||||
|
<if test="approve != null and approve != ''"> approve = #{approve},</if>
|
||||||
|
<if test="approve == null"> approve = null,</if>
|
||||||
|
<if test="initiate != null and initiate != ''"> initiate = #{initiate},</if>
|
||||||
|
<if test="push_count != null and push_count != ''"> push_count = #{push_count},</if>
|
||||||
|
<if test="push_process_ids != null and push_process_ids != ''"> push_process_ids = #{push_process_ids},</if>
|
||||||
|
<if test="modify_time != null"> modify_time = #{modify_time},</if>
|
||||||
|
<if test="create_time != null"> create_time = #{create_time},</if>
|
||||||
|
<if test="sts != null and sts != ''"> sts = #{sts},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
<!-- 逻辑删除 -->
|
<!-- 逻辑删除 -->
|
||||||
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity" >
|
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.dingtalk.entity.DingU8cBillEntity" >
|
||||||
update ding_u8c_bill set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
|
update ding_u8c_bill set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
|
||||||
|
|
|
@ -108,9 +108,9 @@ public class PushU8CServiceImpl implements PushU8CService {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("委外采购(付款单)->采购付款申请(新)报错", e);
|
logger.error("委外采购(付款单)->采购付款申请(新)报错", e);
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(djFileVO.getDjzbVO().getParentvo().getDwbm(), djFileVO.getDjzbVO().getParentvo().getDwbm_code(), djFileVO.getDjzbVO().getParentvo().getBusitypecode(), djFileVO.getDjzbVO().getParentvo().getDjbh(), djFileVO.getDjzbVO().getParentvo().getVouchid(), "N", e.getMessage(), null,null);
|
// DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(djFileVO.getDjzbVO().getParentvo().getDwbm(), djFileVO.getDjzbVO().getParentvo().getDwbm_code(), djFileVO.getDjzbVO().getParentvo().getBusitypecode(), djFileVO.getDjzbVO().getParentvo().getDjbh(), djFileVO.getDjzbVO().getParentvo().getVouchid(), "N", e.getMessage(), null,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
// dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
// dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
Assert.state(false,e.getMessage());
|
Assert.state(false,e.getMessage());
|
||||||
}
|
}
|
||||||
return instanceId;
|
return instanceId;
|
||||||
|
@ -148,9 +148,9 @@ public class PushU8CServiceImpl implements PushU8CService {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("代理采购(付款单)->采购付款申请(店群专用)报错", e);
|
logger.error("代理采购(付款单)->采购付款申请(店群专用)报错", e);
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(djFileVO.getDjzbVO().getParentvo().getDwbm(), djFileVO.getDjzbVO().getParentvo().getDwbm_code(), djFileVO.getDjzbVO().getParentvo().getBusitypecode(), djFileVO.getDjzbVO().getParentvo().getDjbh(), djFileVO.getDjzbVO().getParentvo().getVouchid(), "N", e.getMessage(), null,null);
|
// DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(djFileVO.getDjzbVO().getParentvo().getDwbm(), djFileVO.getDjzbVO().getParentvo().getDwbm_code(), djFileVO.getDjzbVO().getParentvo().getBusitypecode(), djFileVO.getDjzbVO().getParentvo().getDjbh(), djFileVO.getDjzbVO().getParentvo().getVouchid(), "N", e.getMessage(), null,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
// dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
// dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
Assert.state(false,e.getMessage());
|
Assert.state(false,e.getMessage());
|
||||||
}
|
}
|
||||||
return instanceId;
|
return instanceId;
|
||||||
|
@ -186,9 +186,9 @@ public class PushU8CServiceImpl implements PushU8CService {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("调拨单内部交易(付款单)->特殊业务处理(新)报错", e);
|
logger.error("调拨单内部交易(付款单)->特殊业务处理(新)报错", e);
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(djFileVO.getDjzbVO().getParentvo().getDwbm(), djFileVO.getDjzbVO().getParentvo().getDwbm_code(), djFileVO.getDjzbVO().getParentvo().getBusitypecode(), djFileVO.getDjzbVO().getParentvo().getDjbh(), djFileVO.getDjzbVO().getParentvo().getVouchid(), "N", e.getMessage(), null,null);
|
// DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(djFileVO.getDjzbVO().getParentvo().getDwbm(), djFileVO.getDjzbVO().getParentvo().getDwbm_code(), djFileVO.getDjzbVO().getParentvo().getBusitypecode(), djFileVO.getDjzbVO().getParentvo().getDjbh(), djFileVO.getDjzbVO().getParentvo().getVouchid(), "N", e.getMessage(), null,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
// dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
// dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
Assert.state(false,e.getMessage());
|
Assert.state(false,e.getMessage());
|
||||||
}
|
}
|
||||||
return instanceId;
|
return instanceId;
|
||||||
|
@ -331,8 +331,9 @@ public class PushU8CServiceImpl implements PushU8CService {
|
||||||
|
|
||||||
//记录成功记录
|
//记录成功记录
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "Y", "success", instanceId,null);
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "Y", "success", instanceId,null);
|
||||||
|
// DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), null, null, null,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
return instanceId;
|
return instanceId;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -340,7 +341,7 @@ public class PushU8CServiceImpl implements PushU8CService {
|
||||||
//记录失败记录
|
//记录失败记录
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "N", e.getMessage(), null,null);
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "N", e.getMessage(), null,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -388,8 +389,7 @@ public class PushU8CServiceImpl implements PushU8CService {
|
||||||
//记录成功记录
|
//记录成功记录
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "Y", "success", instanceId,null);
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "Y", "success", instanceId,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
|
|
||||||
return instanceId;
|
return instanceId;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -397,7 +397,7 @@ public class PushU8CServiceImpl implements PushU8CService {
|
||||||
//记录失败记录
|
//记录失败记录
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "N", e.getMessage(), null,null);
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "N", e.getMessage(), null,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
}
|
}
|
||||||
return instanceId;
|
return instanceId;
|
||||||
}
|
}
|
||||||
|
@ -440,14 +440,14 @@ public class PushU8CServiceImpl implements PushU8CService {
|
||||||
//记录成功记录
|
//记录成功记录
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "Y", "success", instanceId,null);
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "Y", "success", instanceId,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage());
|
logger.error(e.getMessage());
|
||||||
//记录失败记录
|
//记录失败记录
|
||||||
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "N", e.getMessage(), null,null);
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity(parentvo.getDwbm(), parentvo.getDwbm_code(), parentvo.getBusitypecode(), parentvo.getDjbh(), parentvo.getVouchid(), "N", e.getMessage(), null,null);
|
||||||
dingU8cBillEntity.setCreate_time(new Date());
|
dingU8cBillEntity.setCreate_time(new Date());
|
||||||
dingU8cBillDao.saveOrUpDateV2(dingU8cBillEntity);
|
dingU8cBillDao.pushSaveOrUpdate(dingU8cBillEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return instanceId;
|
return instanceId;
|
||||||
|
|
|
@ -1,20 +1,52 @@
|
||||||
package com.hzya.frame.plugin.lets.plugin.dingtalk;
|
package com.hzya.frame.plugin.lets.plugin.dingtalk;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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.base.PluginBaseEntity;
|
import com.hzya.frame.base.PluginBaseEntity;
|
||||||
|
import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant;
|
||||||
|
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.util.SaveOrUpdateBusinessLogUtil;
|
||||||
|
import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao;
|
||||||
|
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
||||||
|
import com.hzya.frame.web.entity.BaseResult;
|
||||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 为避免回调超时,每天定时检查所有未审批完成的审批实例。
|
* 为避免回调超时,每天定时检查所有未审批完成的审批实例。
|
||||||
|
* 只检测u8c推送钉钉的,不检测钉钉自己发起的审批实例
|
||||||
*/
|
*/
|
||||||
|
@Service("DingCallBackService")
|
||||||
public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
||||||
Logger logger = LoggerFactory.getLogger(DingCallBackPluginInitializer.class);
|
Logger logger = LoggerFactory.getLogger(DingCallBackPluginInitializer.class);
|
||||||
|
|
||||||
private static final ReentrantLock LOCK = new ReentrantLock(true);
|
private static final ReentrantLock LOCK = new ReentrantLock(true);
|
||||||
|
@Value("${DING.APPKEY}")
|
||||||
|
private String APPKEY;
|
||||||
|
@Value("${DING.AppSecret}")
|
||||||
|
private String AppSecret;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil;
|
||||||
|
@Autowired
|
||||||
|
private IDingU8cBillDao dingU8cBillDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
@ -48,8 +80,170 @@ public class DingCallBackPluginInitializer extends PluginBaseEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
|
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
|
||||||
return null;
|
try {
|
||||||
|
logger.info("调用:" + getPluginName() + "-插件");
|
||||||
|
String prod = "prod";
|
||||||
|
String param = String.valueOf(requestJson.get("param"));
|
||||||
|
if (requestJson != null && ProfilesActiveConstant.TYPE_VBILLCODE.equals(requestJson.get("type")) && param != null && !"".equals(param)) {
|
||||||
|
//按单号
|
||||||
|
start(param);
|
||||||
|
} else if (ProfilesActiveConstant.TYPE_DETAIL_ERROR.equals(requestJson.get("type"))) {
|
||||||
|
String integrationTaskLivingDetails = (String) requestJson.get("integration_task_living_details_id");
|
||||||
|
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = saveOrUpdateBusinessLogUtil.queryIntegrationTaskLivingDetailsEntity(integrationTaskLivingDetails);
|
||||||
|
start(integrationTaskLivingDetailsEntity.getRootAppPk());
|
||||||
|
} else if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(prod)) {
|
||||||
|
//默认
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("executeBusiness方法抛出异常", e);
|
||||||
|
}
|
||||||
|
return BaseResult.getSuccessMessageEntity("插件执行成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测所有插件
|
||||||
|
*/
|
||||||
|
public void start() {
|
||||||
|
try {
|
||||||
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
||||||
|
dingU8cBillEntity.setSts("Y");
|
||||||
|
dingU8cBillEntity.setInitiate("U");
|
||||||
|
List<DingU8cBillEntity> query = dingU8cBillDao.query(dingU8cBillEntity);
|
||||||
|
if (query == null || query.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//过滤同意 且 实例id不为null
|
||||||
|
List<DingU8cBillEntity> filterData = filterPass(query);
|
||||||
|
if (filterData == null || filterData.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// List<String> collect = filterData.stream().map(DingU8cBillEntity::getDingTalkProcessId).collect(Collectors.toList());
|
||||||
|
// if (collect == null || collect.size() == 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
implement(filterData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("丽知:钉钉审批实例自动检查start()报错,报错信息:{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测是定插件
|
||||||
|
*
|
||||||
|
* @param processInstanceId
|
||||||
|
*/
|
||||||
|
public void start(String processInstanceId) {
|
||||||
|
try {
|
||||||
|
DingU8cBillEntity dingU8cBillEntity = new DingU8cBillEntity();
|
||||||
|
dingU8cBillEntity.setDingTalkProcessId(processInstanceId);
|
||||||
|
dingU8cBillEntity.setSts("Y");
|
||||||
|
dingU8cBillEntity.setInitiate("U");
|
||||||
|
List<DingU8cBillEntity> query = dingU8cBillDao.query(dingU8cBillEntity);
|
||||||
|
if (query == null || query.size() == 0) {
|
||||||
|
Assert.state(false,"根据审批实例id:{},无法查询到推送记录",processInstanceId);
|
||||||
|
}
|
||||||
|
//过滤同意 且 实例id不为null
|
||||||
|
List<DingU8cBillEntity> filterData = filterPass(query);
|
||||||
|
if (filterData == null || filterData.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
implement(filterData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("丽知:钉钉审批实例自动检查start(String processInstanceId)报错,报错信息:{}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤审核通过的
|
||||||
|
*
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<DingU8cBillEntity> filterPass(List<DingU8cBillEntity> query) {
|
||||||
|
List<DingU8cBillEntity> filter = new ArrayList<>();
|
||||||
|
for (DingU8cBillEntity dingU8cBillEntity : query) {
|
||||||
|
if ("Y".equals(dingU8cBillEntity.getApprove()) || (dingU8cBillEntity.getDingTalkProcessId() == null && "".equals(dingU8cBillEntity.getDingTalkProcessId().trim()))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
filter.add(dingU8cBillEntity);
|
||||||
|
}
|
||||||
|
return filter;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询表单,看返回接口。
|
||||||
|
*
|
||||||
|
* @param filterData
|
||||||
|
*/
|
||||||
|
public void implement(List<DingU8cBillEntity> filterData) throws Exception {
|
||||||
|
//获取token
|
||||||
|
String token = getDingTalkToken();
|
||||||
|
for (DingU8cBillEntity dingU8cBillEntity : filterData) {
|
||||||
|
if(dingU8cBillEntity.getDingTalkProcessId()==null||"".equals(dingU8cBillEntity.getDingTalkProcessId().trim())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询u8c付款单审核状态,审核的continue,没审核的查询钉钉表单上的状态
|
||||||
|
|
||||||
|
try {
|
||||||
|
//查询实例的具体信息
|
||||||
|
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, dingU8cBillEntity.getDingTalkProcessId());
|
||||||
|
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
||||||
|
//获取所有审批意见
|
||||||
|
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecords> operationRecords = processInstanceResponseBodyResult.getOperationRecords();
|
||||||
|
//审批意见过滤掉:START_PROCESS_INSTANCE:发起流程实例
|
||||||
|
operationRecords = operationRecords.stream().filter(item -> !item.getType().equals("START_PROCESS_INSTANCE")).collect(Collectors.toList());
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
//审核
|
||||||
|
|
||||||
|
//拒审
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("丽知:钉钉审批实例自动检查implement(List<String> processInstanceIds)报错,报错信息:{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取钉钉应用token
|
||||||
|
*/
|
||||||
|
public String getDingTalkToken() throws Exception {
|
||||||
|
GetAccessTokenResponseBody tokenBody = DingTalkUtils.getTokenBody(APPKEY, AppSecret);
|
||||||
|
return tokenBody.getAccessToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批拒绝后清除ding_talk_process_id、ding_res、approve、initiate、push_count++,push_process_ids
|
||||||
|
* @param dingU8cBillEntity
|
||||||
|
*/
|
||||||
|
public void updateDingU8C(DingU8cBillEntity dingU8cBillEntity){
|
||||||
|
dingU8cBillEntity.setDingTalkProcessId(null);
|
||||||
|
dingU8cBillDao.update(dingU8cBillEntity);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,7 +409,7 @@ public class RefundOnlyPluginInitializer extends PluginBaseEntity {
|
||||||
//lrr 录入人
|
//lrr 录入人
|
||||||
parentvo.setLrr(OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
parentvo.setLrr(OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||||
//wldx 往来对象标识 (0 客户 2部门 3业务员)
|
//wldx 往来对象标识 (0 客户 2部门 3业务员)
|
||||||
parentvo.setWldx("2");
|
parentvo.setWldx("0");
|
||||||
//hbbm 客商==店铺,根据店铺区分tob、toc,,,编码需要转换,转换称自定义项。
|
//hbbm 客商==店铺,根据店铺区分tob、toc,,,编码需要转换,转换称自定义项。
|
||||||
BdCubasdocEntity entity = queryU8CEntityUtil.getFuzzyQueryCustomers(split[1]);
|
BdCubasdocEntity entity = queryU8CEntityUtil.getFuzzyQueryCustomers(split[1]);
|
||||||
if(entity==null){
|
if(entity==null){
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.hzya.frame.plugin.lets.plugin.base;
|
package com.hzya.frame.plugin.lets.plugin.base;
|
||||||
|
|
||||||
import com.hzya.frame.WebappApplication;
|
import com.hzya.frame.WebappApplication;
|
||||||
|
import com.hzya.frame.plugin.lets.plugin.dingtalk.DingCallBackPluginInitializer;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -21,6 +22,8 @@ public class BaseTest {
|
||||||
private GoodsAutoAllotPluginInitializer goodsAutoAllotPluginInitializer;
|
private GoodsAutoAllotPluginInitializer goodsAutoAllotPluginInitializer;
|
||||||
@Autowired
|
@Autowired
|
||||||
private KitPluginInitializer kitPluginInitializer;
|
private KitPluginInitializer kitPluginInitializer;
|
||||||
|
@Autowired
|
||||||
|
private DingCallBackPluginInitializer dingCallBackPluginInitializer;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////SKU
|
////////////////////////////////////////////////////////////////////////////////////SKU
|
||||||
@Test
|
@Test
|
||||||
|
@ -73,4 +76,16 @@ public class BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////钉钉审批实例
|
||||||
|
@Test
|
||||||
|
public void t40(){
|
||||||
|
dingCallBackPluginInitializer.start("I96QXUaPRuulq3OUBa-N8Q05751730363617");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t41(){
|
||||||
|
dingCallBackPluginInitializer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class TransferTest {
|
||||||
@Test
|
@Test
|
||||||
public void t31(){
|
public void t31(){
|
||||||
// adjustInPluginInitializer.start("LETS-RE2024091100000001");
|
// adjustInPluginInitializer.start("LETS-RE2024091100000001");
|
||||||
adjustInPluginInitializer.start("LETS-RE2024102400000004");
|
adjustInPluginInitializer.start("LETS-RE2024110500000028");
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void t32(){
|
public void t32(){
|
||||||
|
@ -133,7 +133,7 @@ public class TransferTest {
|
||||||
public void t80(){
|
public void t80(){
|
||||||
// refundOnlyPluginInitializer.start("LETS-RO2024091900000001");
|
// refundOnlyPluginInitializer.start("LETS-RO2024091900000001");
|
||||||
// refundOnlyPluginInitializer.start("LETS-RO2023060900005007");
|
// refundOnlyPluginInitializer.start("LETS-RO2023060900005007");
|
||||||
refundOnlyPluginInitializer.start("LETS-RO2024101800001577");
|
refundOnlyPluginInitializer.start("LETS-RO2024111900003595");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue