丽知:1、钉钉回调优化。2、钉钉日志记录优化
This commit is contained in:
parent
b67c8cbe23
commit
b2d5c41966
|
@ -9,6 +9,8 @@ import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
|
|||
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.ProfilesActiveConstant;
|
||||
import com.hzya.frame.plugin.lets.dao.IArapDjzbDao;
|
||||
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;
|
||||
|
@ -18,13 +20,16 @@ import com.hzya.frame.plugin.lets.dingtalk.utils.PushU8CFileUtil;
|
|||
import com.hzya.frame.plugin.lets.dingtalk.vo.DingCallbackCrypto;
|
||||
import com.hzya.frame.plugin.lets.dingtalk.vo.FileModuleVO;
|
||||
import com.hzya.frame.plugin.lets.dingtalk.vo.SysFileVO;
|
||||
import com.hzya.frame.plugin.lets.entity.ArapDjzbEntity;
|
||||
import com.hzya.frame.plugin.lets.entity.BdCorpEntity;
|
||||
import com.hzya.frame.plugin.lets.entity.BdDeptdocEntity;
|
||||
import com.hzya.frame.plugin.lets.u8cdto.*;
|
||||
import com.hzya.frame.plugin.lets.util.QueryU8CEntityUtil;
|
||||
import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil;
|
||||
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 com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
|
@ -42,24 +47,7 @@ import java.util.*;
|
|||
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
|
||||
* 钉钉回调,push_status一定是Y
|
||||
*/
|
||||
@Service("callBackService")
|
||||
public class CallBackServiceImpl implements CallBackService {
|
||||
|
@ -69,6 +57,8 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
|
||||
@Autowired
|
||||
private IDingU8cBillDao dingU8cBillDao;
|
||||
@Autowired
|
||||
private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil;
|
||||
|
||||
@Value("${DING.CorpId}")
|
||||
private String CorpId;
|
||||
|
@ -105,7 +95,7 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
|
||||
String eventType = eventJson.getString("EventType");
|
||||
|
||||
//防止钉钉回调
|
||||
//防止钉钉重复回调
|
||||
if(eventJson.getString("processInstanceId")!=null) {
|
||||
if (!eventJson.getString("processInstanceId").equals(dingId)) {
|
||||
dingId = eventJson.getString("processInstanceId");
|
||||
|
@ -172,8 +162,29 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
String processInstanceId = eventJson.getString("processInstanceId");
|
||||
DingU8cBillEntity dingU8cBillEntity = queryU8CDing(processInstanceId);
|
||||
if (dingU8cBillEntity == null) {
|
||||
Assert.state(false, "代理采购(付款单)->采购付款申请(店群专用)回调:未查询到相关审批实例,实例id:{}", processInstanceId);
|
||||
Assert.state(false, "委外采购(付款单)->采购付款申请(新)回调:未查询到相关审批实例,实例id:{}", processInstanceId);
|
||||
}
|
||||
|
||||
if("Y".equals(dingU8cBillEntity.getApprove())){
|
||||
return;
|
||||
}
|
||||
|
||||
//查询u8c单据信息
|
||||
ArapDjzbEntity arapDjzbEntity = queryArapDjzbEntity(dingU8cBillEntity.getU8c_pk_corp(), dingU8cBillEntity.getU8c_bill_code());
|
||||
if(arapDjzbEntity==null){
|
||||
Assert.state(false,"根据公司编码:{},单据号:{},未查询到U8C付款单。",dingU8cBillEntity.getU8c_code_corp(),dingU8cBillEntity.getU8c_bill_code());
|
||||
}
|
||||
|
||||
//djzt单据状态 1保存 3完成
|
||||
if("3".equals(arapDjzbEntity.getDjzt())){
|
||||
return;
|
||||
}
|
||||
|
||||
//spzt审批状态 null未审批 1审批
|
||||
if("1".equals(arapDjzbEntity.getSpzt())){
|
||||
return;
|
||||
}
|
||||
|
||||
//查询实例的具体信息
|
||||
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
||||
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
||||
|
@ -189,7 +200,7 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
String status = null;//审批状态。RUNNING:审批中 TERMINATED:已撤销 COMPLETED:审批完成
|
||||
String result = null;//审批结果。agree:同意 refuse:拒绝
|
||||
String userId = null;//任务处理人。
|
||||
String mobile = null;//处理人手机号
|
||||
// String mobile = null;//处理人手机号
|
||||
|
||||
status = processInstanceResponseBodyResult.getStatus();
|
||||
if ("RUNNING".equals(status) || "TERMINATED".equals(status)) {
|
||||
|
@ -202,22 +213,35 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks task : tasks) {
|
||||
userId=task.getUserId();
|
||||
}
|
||||
mobile = getMobileByUserId(token, userId);
|
||||
// mobile = getMobileByUserId(token, userId);
|
||||
|
||||
result = processInstanceResponseBodyResult.getResult();
|
||||
if ("agree".equals(result)) {
|
||||
//同意
|
||||
//审批u8c单据
|
||||
approveArapDjzb(dingU8cBillEntity,mobile);
|
||||
approveArapDjzb(dingU8cBillEntity);
|
||||
}else if ("refuse".equals(result)) {
|
||||
//拒绝
|
||||
dingU8cBillEntity.setApprove("N");
|
||||
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||
//后续林姐姐给接口,拒绝之后清空process_id、approve:N
|
||||
refuse(dingU8cBillEntity, mobile);
|
||||
refuse(dingU8cBillEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("代理采购(付款单)->采购付款申请(店群专用)回调报错:" + e);
|
||||
logger.error("回调报错:" + e);
|
||||
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(eventJson.getString("processInstanceId"));
|
||||
integrationTaskLivingDetailsEntity.setRootAppBill(eventJson.getString("processInstanceId"));
|
||||
integrationTaskLivingDetailsEntity.setPluginId("dingtalk.DingCallBackServicePluginInitializer");
|
||||
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -236,6 +260,28 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
if (dingU8cBillEntity == null) {
|
||||
Assert.state(false, "代理采购(付款单)->采购付款申请(店群专用)回调:未查询到相关审批实例,实例id:{}", processInstanceId);
|
||||
}
|
||||
|
||||
|
||||
if("Y".equals(dingU8cBillEntity.getApprove())){
|
||||
return;
|
||||
}
|
||||
|
||||
//查询u8c单据信息
|
||||
ArapDjzbEntity arapDjzbEntity = queryArapDjzbEntity(dingU8cBillEntity.getU8c_pk_corp(), dingU8cBillEntity.getU8c_bill_code());
|
||||
if(arapDjzbEntity==null){
|
||||
Assert.state(false,"根据公司编码:{},单据号:{},未查询到U8C付款单。",dingU8cBillEntity.getU8c_code_corp(),dingU8cBillEntity.getU8c_bill_code());
|
||||
}
|
||||
|
||||
//djzt单据状态 1保存 3完成
|
||||
if("3".equals(arapDjzbEntity.getDjzt())){
|
||||
return;
|
||||
}
|
||||
|
||||
//spzt审批状态 null未审批 1审批
|
||||
if("1".equals(arapDjzbEntity.getSpzt())){
|
||||
return;
|
||||
}
|
||||
|
||||
//查询实例的具体信息
|
||||
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
||||
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
||||
|
@ -251,7 +297,7 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
String status = null;//审批状态。RUNNING:审批中 TERMINATED:已撤销 COMPLETED:审批完成
|
||||
String result = null;//审批结果。agree:同意 refuse:拒绝
|
||||
String userId = null;//任务处理人。
|
||||
String mobile = null;//处理人手机号
|
||||
// String mobile = null;//处理人手机号
|
||||
|
||||
status = processInstanceResponseBodyResult.getStatus();
|
||||
if ("RUNNING".equals(status) || "TERMINATED".equals(status)) {
|
||||
|
@ -264,22 +310,36 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks task : tasks) {
|
||||
userId=task.getUserId();
|
||||
}
|
||||
mobile = getMobileByUserId(token, userId);
|
||||
// mobile = getMobileByUserId(token, userId);
|
||||
|
||||
result = processInstanceResponseBodyResult.getResult();
|
||||
if ("agree".equals(result)) {
|
||||
//同意
|
||||
//审批u8c单据
|
||||
approveArapDjzb(dingU8cBillEntity,mobile);
|
||||
approveArapDjzb(dingU8cBillEntity);
|
||||
}else if ("refuse".equals(result)) {
|
||||
//拒绝
|
||||
dingU8cBillEntity.setApprove("N");
|
||||
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||
//后续林姐姐给接口,拒绝之后清空process_id、approve:N
|
||||
refuse(dingU8cBillEntity, mobile);
|
||||
refuse(dingU8cBillEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("代理采购(付款单)->采购付款申请(店群专用)回调报错:" + e);
|
||||
logger.error("回调报错:" + e);
|
||||
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(eventJson.getString("processInstanceId"));
|
||||
integrationTaskLivingDetailsEntity.setRootAppBill(eventJson.getString("processInstanceId"));
|
||||
integrationTaskLivingDetailsEntity.setPluginId("dingtalk.DingCallBackServicePluginInitializer");
|
||||
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,6 +376,29 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
//新增u8c付款单、保存日志、上传附件
|
||||
addArapBill(processInstanceId, token);
|
||||
} else {
|
||||
|
||||
if("Y".equals(dingU8cBillEntity.getApprove())){
|
||||
return;
|
||||
}
|
||||
|
||||
//查询u8c单据信息
|
||||
ArapDjzbEntity arapDjzbEntity = queryArapDjzbEntity(dingU8cBillEntity.getU8c_pk_corp(), dingU8cBillEntity.getU8c_bill_code());
|
||||
if(arapDjzbEntity==null){
|
||||
Assert.state(false,"根据公司编码:{},单据号:{},未查询到U8C付款单。",dingU8cBillEntity.getU8c_code_corp(),dingU8cBillEntity.getU8c_bill_code());
|
||||
}
|
||||
|
||||
//djzt单据状态 1保存 3完成
|
||||
if("3".equals(arapDjzbEntity.getDjzt())){
|
||||
return;
|
||||
}
|
||||
|
||||
//spzt审批状态 null未审批 1审批
|
||||
if("1".equals(arapDjzbEntity.getSpzt())){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//查询实例的具体信息
|
||||
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, processInstanceId);
|
||||
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
||||
|
@ -337,7 +420,7 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
String status = null;//审批状态。RUNNING:审批中 TERMINATED:已撤销 COMPLETED:审批完成
|
||||
String result = null;//审批结果。agree:同意 refuse:拒绝
|
||||
String userId = null;//任务处理人。
|
||||
String mobile = null;//处理人手机号
|
||||
// String mobile = null;//处理人手机号
|
||||
|
||||
status = processInstanceResponseBodyResult.getStatus();
|
||||
if ("RUNNING".equals(status) || "TERMINATED".equals(status)) {
|
||||
|
@ -350,24 +433,38 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks task : tasks) {
|
||||
userId=task.getUserId();
|
||||
}
|
||||
mobile = getMobileByUserId(token, userId);
|
||||
// mobile = getMobileByUserId(token, userId);
|
||||
|
||||
result = processInstanceResponseBodyResult.getResult();
|
||||
if ("agree".equals(result)) {
|
||||
//同意
|
||||
//审批u8c单据
|
||||
approveArapDjzb(dingU8cBillEntity,mobile);
|
||||
approveArapDjzb(dingU8cBillEntity);
|
||||
}else if ("refuse".equals(result)) {
|
||||
//拒绝
|
||||
dingU8cBillEntity.setApprove("N");
|
||||
dingU8cBillDao.callBackSaveOrUpdate(dingU8cBillEntity);
|
||||
//后续林姐姐给接口,拒绝之后清空process_id、approve:N
|
||||
refuse(dingU8cBillEntity, mobile);
|
||||
refuse(dingU8cBillEntity);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("调拨单内部交易(付款单)->特殊业务处理(新)回调报错:" + e);
|
||||
logger.error("回调报错:" + e);
|
||||
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(eventJson.getString("processInstanceId"));
|
||||
integrationTaskLivingDetailsEntity.setRootAppBill(eventJson.getString("processInstanceId"));
|
||||
integrationTaskLivingDetailsEntity.setPluginId("dingtalk.DingCallBackServicePluginInitializer");
|
||||
saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,7 +474,7 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
/**
|
||||
* 审核付款单,并保存日志
|
||||
*/
|
||||
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity,String mobile) throws Exception {
|
||||
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity) throws Exception {
|
||||
//获取当前时间
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
|
@ -385,8 +482,8 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
bills.put("djbh", dingU8cBillEntity.getU8c_bill_code());
|
||||
bills.put("dwbm", dingU8cBillEntity.getU8c_code_corp());
|
||||
bills.put("opinion", "同意");
|
||||
// bills.put("operatorid", OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||
bills.put("operatorid", mobile);
|
||||
bills.put("operatorid", OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||
// bills.put("operatorid", mobile);
|
||||
bills.put("operatedate", now.toString());
|
||||
String jsonStr = JSONUtil.toJsonStr(bills);
|
||||
jsonStr = "{\"bills\":[" + jsonStr + "]}";
|
||||
|
@ -614,7 +711,7 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
/**
|
||||
* 钉钉拒绝审批,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");
|
||||
// 接口地址
|
||||
|
@ -630,7 +727,8 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
//请求体
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("instanceId", dingU8cBillEntity.getDing_talk_process_id());
|
||||
fileMap.put("userCode", mobile);//审批人
|
||||
// fileMap.put("userCode", mobile);//审批人
|
||||
fileMap.put("userCode", OverallConstant.getOverAllValue("u8cApiZdrCode"));//审批人
|
||||
fileMap.put("ckeckResult", "R");
|
||||
fileMap.put("ckeckNote", "无");
|
||||
String jsonFileMap = JSONUtil.toJsonStr(fileMap);
|
||||
|
@ -651,4 +749,24 @@ public class CallBackServiceImpl implements CallBackService {
|
|||
String responseBodyAsString = httpPost.getResponseBodyAsString();
|
||||
System.out.println(responseBodyAsString);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private IArapDjzbDao arapDjzbDao;
|
||||
/**
|
||||
* 查询u8c付款单主表
|
||||
*/
|
||||
public ArapDjzbEntity queryArapDjzbEntity(String u8cPkCorp, String u8cBillCode){
|
||||
ArapDjzbEntity arapDjzbEntity = new ArapDjzbEntity();
|
||||
arapDjzbEntity.setDr("0");
|
||||
arapDjzbEntity.setDwbm(u8cPkCorp);
|
||||
arapDjzbEntity.setDjbh(u8cBillCode);
|
||||
arapDjzbEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
|
||||
List<ArapDjzbEntity> query = arapDjzbDao.query(arapDjzbEntity);
|
||||
if(query.size()==0){
|
||||
return null;
|
||||
}else {
|
||||
return query.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class DingU8CBillController extends DefaultController {
|
|||
}
|
||||
return getSuccessMessageEntity("根据Id补推",query);
|
||||
}catch (Exception e){
|
||||
return getFailureMessageEntity("根据Id补推失败");
|
||||
return getFailureMessageEntity("根据Id补推失败,失败原因:{}。",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ public class DingU8cBillDaoImpl extends MybatisGenericDao<DingU8cBillEntity, Str
|
|||
}else if("N".equals(dingU8cBillEntityNew.getPush_status())){
|
||||
//钉钉发起单据 N->N
|
||||
dingU8cBill.setId(dingU8cBillEntity.getId());
|
||||
dingU8cBill.setApprove("N");
|
||||
// dingU8cBill.setApprove("N");
|
||||
dingU8cBill.setPush_status("N");
|
||||
dingU8cBill.setModify_time(new Date());
|
||||
dingU8cBill.setDing_res(null);
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.hzya.frame.page.PageAttribute;
|
|||
import com.hzya.frame.plugin.lets.constant.OverallConstant;
|
||||
import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant;
|
||||
import com.hzya.frame.plugin.lets.dao.IArapDjzbDao;
|
||||
import com.hzya.frame.plugin.lets.dingtalk.callback.service.impl.CallBackServiceImpl;
|
||||
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.service.IDingU8cBillService;
|
||||
|
@ -56,6 +57,8 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
this.dao = dao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private CallBackServiceImpl callBackService;
|
||||
|
||||
@Override
|
||||
public PageAttribute<DingU8cBillEntity> queryPaged(DingU8cBillEntity baseEntity) {
|
||||
|
@ -90,6 +93,15 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 没有推送成功的,不允许重推,请到u8c重推
|
||||
* 推送成功的,查询审批状态
|
||||
*
|
||||
* 钉钉发起:有实例id,但是没有推送成功
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DingU8cBillEntity pushById(DingU8cBillEntity dingU8cBillEntity) {
|
||||
try{
|
||||
|
@ -102,9 +114,19 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
}
|
||||
DingU8cBillEntity dingU8cBillEntityNew = query.get(0);
|
||||
|
||||
//没有推送成功的
|
||||
if(dingU8cBillEntityNew.getDing_talk_process_id()==null||"".equals(dingU8cBillEntityNew.getDing_talk_process_id().trim())){
|
||||
Assert.state(false,"请到U8C系统中进行重新推送。");
|
||||
}
|
||||
//获取token
|
||||
String token = getDingTalkToken();
|
||||
|
||||
//钉钉发起
|
||||
if ("D".equals(dingU8cBillEntityNew.getInitiate())) {
|
||||
callBackService.addArapBill(dingU8cBillEntityNew.getDing_talk_process_id(),token);
|
||||
return dingU8cBillEntityNew;
|
||||
}
|
||||
|
||||
//查询实例的具体信息
|
||||
GetProcessInstanceResponse processInstanceDetails = DingTalkUtils.getProcessInstanceDetails(token, dingU8cBillEntityNew.getDing_talk_process_id());
|
||||
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult processInstanceResponseBodyResult = processInstanceDetails.getBody().getResult();
|
||||
|
@ -112,7 +134,6 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
String status = null;//审批状态。RUNNING:审批中 TERMINATED:已撤销 COMPLETED:审批完成
|
||||
String result = null;//审批结果。agree:同意 refuse:拒绝
|
||||
String userId = null;//任务处理人。
|
||||
String mobile = null;//处理人手机号
|
||||
|
||||
status = processInstanceResponseBodyResult.getStatus();
|
||||
if ("RUNNING".equals(status) || "TERMINATED".equals(status)) {
|
||||
|
@ -132,13 +153,12 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks task : tasks) {
|
||||
userId=task.getUserId();
|
||||
}
|
||||
mobile = getMobileByUserId(token, userId);
|
||||
|
||||
result = processInstanceResponseBodyResult.getResult();
|
||||
if("agree".equals(result)){
|
||||
approveArapDjzb(dingU8cBillEntityNew,mobile);
|
||||
approveArapDjzb(dingU8cBillEntityNew);
|
||||
}else if("refuse".equals(result)){
|
||||
refuse(dingU8cBillEntityNew,mobile);
|
||||
refuse(dingU8cBillEntityNew);
|
||||
}
|
||||
return dingU8cBillEntityNew;
|
||||
}catch (Exception e){
|
||||
|
@ -149,7 +169,7 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
|
||||
@Autowired
|
||||
private PushU8CByApiCode pushU8CByApiCode;
|
||||
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity,String mobile) throws Exception {
|
||||
public void approveArapDjzb(DingU8cBillEntity dingU8cBillEntity) throws Exception {
|
||||
//获取当前时间
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
|
@ -157,8 +177,8 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
bills.put("djbh", dingU8cBillEntity.getU8c_bill_code());
|
||||
bills.put("dwbm", dingU8cBillEntity.getU8c_code_corp());
|
||||
bills.put("opinion", "同意");
|
||||
// bills.put("operatorid", OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||
bills.put("operatorid", mobile);
|
||||
bills.put("operatorid", OverallConstant.getOverAllValue("u8cApiZdrCode"));
|
||||
// bills.put("operatorid", mobile);
|
||||
bills.put("operatedate", now.toString());
|
||||
String jsonStr = JSONUtil.toJsonStr(bills);
|
||||
jsonStr = "{\"bills\":[" + jsonStr + "]}";
|
||||
|
@ -195,7 +215,7 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
}
|
||||
|
||||
}
|
||||
public void refuse(DingU8cBillEntity dingU8cBillEntity, String mobile) throws IOException {
|
||||
public void refuse(DingU8cBillEntity dingU8cBillEntity) throws IOException {
|
||||
// 服务器访问地址及端口,例如 http://ip:port
|
||||
String serviceUrl = OverallConstant.getOverAllValue("u8cApiUrl");
|
||||
// 接口地址
|
||||
|
@ -211,7 +231,7 @@ public class DingU8cBillServiceImpl extends BaseService<DingU8cBillEntity, Strin
|
|||
//请求体
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("instanceId", dingU8cBillEntity.getDing_talk_process_id());
|
||||
fileMap.put("userCode", mobile);//审批人
|
||||
fileMap.put("userCode", OverallConstant.getOverAllValue("u8cApiZdrCode"));//审批人
|
||||
fileMap.put("ckeckResult", "R");
|
||||
fileMap.put("ckeckNote", "无");
|
||||
String jsonFileMap = JSONUtil.toJsonStr(fileMap);
|
||||
|
|
Loading…
Reference in New Issue