新增触发工作流功能

This commit is contained in:
itzhang 2025-08-15 10:17:05 +08:00
parent 8b269beec5
commit 6e127de27a
4 changed files with 55 additions and 12 deletions

View File

@ -355,7 +355,7 @@ public class DesignController {
}
//开始回写
JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
JSONObject backReq = crmRequestUtil.updateCRMWorkflow(backReqMap);
System.out.println("回写请求为:" + JSON.parseObject(JSON.toJSONString(backReq)));
@ -751,7 +751,7 @@ public class DesignController {
}
//开始回写
JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
JSONObject backReq = crmRequestUtil.updateCRMWorkflow(backReqMap);
JSONObject backRes = new JSONObject();

View File

@ -379,7 +379,7 @@ public class InvoiceController {
System.out.println("解锁" + unlockRes);
}
JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
JSONObject backReq = crmRequestUtil.updateCRMWorkflow(backReqMap);
JSONObject backRes = new JSONObject();
@ -729,7 +729,7 @@ public class InvoiceController {
}
System.out.println("解锁" + unlockRes);
}
JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
JSONObject backReq = crmRequestUtil.updateCRMWorkflow(backReqMap);
JSONObject backRes = new JSONObject();

View File

@ -519,7 +519,7 @@ public class XSHTController {
System.out.println("解锁" + unlockRes);
}
JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
JSONObject backReq = crmRequestUtil.updateCRMWorkflow(backReqMap);
System.out.println("回写请求为:" + JSON.parseObject(JSON.toJSONString(backReq)));
@ -1003,7 +1003,7 @@ public class XSHTController {
//开始回写
JSONObject backReq = crmRequestUtil.updateCRM(backReqMap);
JSONObject backReq = crmRequestUtil.updateCRMWorkflow(backReqMap);
JSONObject backRes = new JSONObject();

View File

@ -120,6 +120,49 @@ public class CrmRequestUtil {
return requestJSON;
}
public JSONObject updateCRMWorkflow(Map data) {
String corpAccessToken = "";
//判断咖啡因中是否有数据
if (CaffeineCacheUtil.get("corpAccessToken") != null) {
log.info("咖啡因中有缓存的token数据");
corpAccessToken = CaffeineCacheUtil.get("corpAccessToken").toString();
} else {
log.info("咖啡因中不存在token缓存");
//封装请求
Map tokenParams = new HashMap<>();
tokenParams.put("appId", CertificateConstant.APP_ID);
tokenParams.put("appSecret", CertificateConstant.APP_SECRET);
tokenParams.put("permanentCode", CertificateConstant.PERMANENT_CODE);
JSONObject tokenResponse = restTemplate.postForObject(URLConstant.GET_CORPACCESSTOKEN_URL, tokenParams, JSONObject.class);
//判断是否获取成功
if (tokenResponse.containsKey("errorMessage") && tokenResponse.getString("errorMessage").equals("success")) {
corpAccessToken = tokenResponse.getString("corpAccessToken");
} else {
log.info("获取纷享销客token失败{}", tokenResponse);
}
}
//封装object_data
Map objectData = new HashMap<>();
objectData.put("object_data", data);
// Map rootData = new HashMap<>();
// rootData.put("data", objectData);
Map request = new HashMap<>();
request.put("corpAccessToken", corpAccessToken);
request.put("currentOpenUserId", CertificateConstant.CURRENT_OPEN_USERID);
request.put("corpId", CertificateConstant.CORP_ID);
request.put("triggerWorkFlow", true);
request.put("triggerApprovalFlow", "false");
request.put("data", objectData);
JSONObject requestJSON = new JSONObject(request);
return requestJSON;
}
//封装新建单据的请求参数
public JSONObject createCRM(Map map) {
String corpAccessToken = "";
@ -394,9 +437,9 @@ public class CrmRequestUtil {
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
JSONObject args = new JSONObject();
args.put("entityNumber","f9w5_pmp_priceapproval");
args.put("billPkId",erpId);
args.put("controlKey","f9w5_technicalstd");
args.put("entityNumber", "f9w5_pmp_priceapproval");
args.put("billPkId", erpId);
args.put("controlKey", "f9w5_technicalstd");
body.add("attachmentUploadFileArgs", args);
@ -465,9 +508,9 @@ public class CrmRequestUtil {
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
JSONObject args = new JSONObject();
args.put("entityNumber","conm_salcontract");
args.put("billPkId",erpId);
args.put("controlKey","attachmentpanel");
args.put("entityNumber", "conm_salcontract");
args.put("billPkId", erpId);
args.put("controlKey", "attachmentpanel");
body.add("attachmentUploadFileArgs", args);