|
@@ -0,0 +1,452 @@
|
|
|
+package com.muzhi.shennongshi.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
|
|
|
+import com.aliyun.tea.TeaException;
|
|
|
+import com.aliyun.teautil.models.RuntimeOptions;
|
|
|
+import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
+import com.dingtalk.api.DingTalkClient;
|
|
|
+import com.dingtalk.api.request.OapiSmartworkHrmEmployeeV2ListRequest;
|
|
|
+import com.dingtalk.api.request.OapiSmartworkHrmEmployeeV2UpdateRequest;
|
|
|
+import com.dingtalk.api.response.OapiSmartworkHrmEmployeeV2ListResponse;
|
|
|
+import com.dingtalk.api.response.OapiSmartworkHrmEmployeeV2UpdateResponse;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.muzhi.shennongshi.common.R;
|
|
|
+import com.muzhi.shennongshi.service.AccessTokenService;
|
|
|
+import com.muzhi.shennongshi.service.DingOaService;
|
|
|
+import com.taobao.api.ApiException;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class DingOaServiceImpl implements DingOaService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AccessTokenService accessTokenService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单打开时加载(原所属主体)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map getSuoshuzhuti(String userid){
|
|
|
+ log.info("获取当前表单传参人员userid:" + userid);
|
|
|
+
|
|
|
+ //智能人事获取员工花名册信息,抓取【人员主体】字段信息
|
|
|
+ String body = null;
|
|
|
+ String label = null;
|
|
|
+ String value = null;
|
|
|
+ try {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/list");
|
|
|
+ OapiSmartworkHrmEmployeeV2ListRequest req = new OapiSmartworkHrmEmployeeV2ListRequest();
|
|
|
+ //待查询人员userid
|
|
|
+ req.setUseridList(userid);
|
|
|
+ req.setAgentid(2358039528L);
|
|
|
+ OapiSmartworkHrmEmployeeV2ListResponse rsp = client.execute(req, accessTokenService.getAccessToken());
|
|
|
+ body = rsp.getBody();
|
|
|
+ System.out.println(body);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSON.parseObject(body);
|
|
|
+ JSONArray result = jsonObject.getJSONArray("result");
|
|
|
+ JSONArray field_data_list = result.getJSONObject(0).getJSONArray("field_data_list");
|
|
|
+
|
|
|
+ for (int i = 0; i < field_data_list.size(); i++) {
|
|
|
+ //字段code
|
|
|
+ String field_code = field_data_list.getJSONObject(i).getString("field_code");
|
|
|
+// log.info("当前花名册字段field_code:" + field_code);
|
|
|
+ switch (field_code) {
|
|
|
+ //人员主体
|
|
|
+ case "3ee15b1a-3fda-46d5-ac4b-c11ea01e0c5c":
|
|
|
+ JSONArray field_value_list = field_data_list.getJSONObject(i).getJSONArray("field_value_list");
|
|
|
+ //人员主体内容
|
|
|
+ label = field_value_list.getJSONObject(0).getString("label");
|
|
|
+ //人员主体编号
|
|
|
+ value = field_value_list.getJSONObject(0).getString("value");
|
|
|
+ //当前字段下标
|
|
|
+ int old_index = i;
|
|
|
+ log.info("当前字段下标:" + old_index);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("当前人员所属主体:" + label + "<-->" + "所属主体编号:" + value);
|
|
|
+
|
|
|
+ //封装连接器出参
|
|
|
+ List list = new ArrayList();
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("vlaue",value);
|
|
|
+ map.put("label",label);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单提交审批通过后反写智能人事花名册更新(所属主体)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R updateSuoshuzhuti(String userid,String sszt){
|
|
|
+ log.info("获取当前表单传参待更新人员userid:" + userid);
|
|
|
+ log.info("获取当前表单传参待更新人员所属主体:" + sszt);
|
|
|
+
|
|
|
+ String ssztid = null;
|
|
|
+ if (sszt.equals("餐饮")){
|
|
|
+ ssztid = "10001";
|
|
|
+ }else if (sszt.equals("管理")){
|
|
|
+ ssztid = "10002";
|
|
|
+ }else if (sszt.equals("神唐")){
|
|
|
+ ssztid = "10003";
|
|
|
+ }else if (sszt.equals("五斗米")){
|
|
|
+ ssztid = "10004";
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新智能人事员工花名册【人员主体】字段信息
|
|
|
+ String body = null;
|
|
|
+ String success = null;
|
|
|
+ String errmsg = null;
|
|
|
+ try {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/update");
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest req = new OapiSmartworkHrmEmployeeV2UpdateRequest();
|
|
|
+ req.setAgentid(2358039528L);
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest.EmpUpdateByCustomParam obj1 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpUpdateByCustomParam();
|
|
|
+ List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo> list3 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo>();
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo obj4 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo();
|
|
|
+ list3.add(obj4);
|
|
|
+ List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo> list7 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo>();
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo obj8 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo();
|
|
|
+ list7.add(obj8);
|
|
|
+ List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo> list11 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo>();
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo obj12 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo();
|
|
|
+ list11.add(obj12);
|
|
|
+ //智能人事花名册中【人员主体】字段编号
|
|
|
+ obj12.setFieldCode("3ee15b1a-3fda-46d5-ac4b-c11ea01e0c5c");
|
|
|
+ //更新内容编号
|
|
|
+ obj12.setValue(ssztid);
|
|
|
+ obj8.setSection(list11);
|
|
|
+ //TODO 智能人事花名册中【人员主体】数组下标
|
|
|
+ obj8.setOldIndex(30L);
|
|
|
+ obj4.setSections(list7);
|
|
|
+ //字段分组编号
|
|
|
+ obj4.setGroupId("sys01");
|
|
|
+ obj1.setGroups(list3);
|
|
|
+ //更新人员的userid
|
|
|
+ obj1.setUserid(userid);
|
|
|
+ req.setParam(obj1);
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateResponse rsp = client.execute(req, accessTokenService.getAccessToken());
|
|
|
+ body = rsp.getBody();
|
|
|
+ System.out.println(body);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(body);
|
|
|
+ success = jsonObject.getString("success");
|
|
|
+ log.info("钉钉智能人事更新员工花名册字段返回结果标识:" + success);
|
|
|
+ errmsg = jsonObject.getString("errmsg");
|
|
|
+ log.info("钉钉智能人事更新员工花名册字段返回结果信息:" + errmsg);
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ //封装返回信息
|
|
|
+ if (success.equals("true")){
|
|
|
+ return R.ok().message(errmsg);
|
|
|
+ }else {
|
|
|
+ return R.error().message(errmsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单打开时加载(人员类型)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String getRenyuanleixing(String userid){
|
|
|
+ log.info("获取当前表单传参人员userid:" + userid);
|
|
|
+
|
|
|
+ //智能人事获取员工花名册信息,抓取【人员类型】字段信息
|
|
|
+ String body = null;
|
|
|
+ String label = null;
|
|
|
+ try {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/list");
|
|
|
+ OapiSmartworkHrmEmployeeV2ListRequest req = new OapiSmartworkHrmEmployeeV2ListRequest();
|
|
|
+ //待查询人员userid
|
|
|
+ req.setUseridList(userid);
|
|
|
+ req.setAgentid(2358039528L);
|
|
|
+ OapiSmartworkHrmEmployeeV2ListResponse rsp = client.execute(req, accessTokenService.getAccessToken());
|
|
|
+ body = rsp.getBody();
|
|
|
+ System.out.println(body);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSON.parseObject(body);
|
|
|
+ JSONArray result = jsonObject.getJSONArray("result");
|
|
|
+ JSONArray field_data_list = result.getJSONObject(0).getJSONArray("field_data_list");
|
|
|
+
|
|
|
+ for (int i = 0; i < field_data_list.size(); i++) {
|
|
|
+ //字段code
|
|
|
+ String field_code = field_data_list.getJSONObject(i).getString("field_code");
|
|
|
+// log.info("当前花名册字段field_code:" + field_code);
|
|
|
+ switch (field_code) {
|
|
|
+ //人员类型
|
|
|
+ case "691436b8-b2ed-4f7d-b4dd-d8cd7a6fc98b":
|
|
|
+ JSONArray field_value_list = field_data_list.getJSONObject(i).getJSONArray("field_value_list");
|
|
|
+ //人员类型
|
|
|
+ label = field_value_list.getJSONObject(0).getString("label");
|
|
|
+ //当前字段下标
|
|
|
+ int old_index = i;
|
|
|
+ log.info("当前字段下标:" + old_index);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("人员类型:" + label);
|
|
|
+
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单提交时校验
|
|
|
+ * @param rylx(连接器传参人员类型)
|
|
|
+ * @param jbbcfs(连接器传参加班补偿方式)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map getJBJY(String rylx,String jbbcfs){
|
|
|
+ System.out.println("连接器传参人员类型:" + rylx);
|
|
|
+ System.out.println("连接器传参加班补偿方式:" + jbbcfs);
|
|
|
+
|
|
|
+ Boolean zhi = null;
|
|
|
+
|
|
|
+ if (rylx.equals("领导")){
|
|
|
+ if (jbbcfs.equals("转调休")){
|
|
|
+ zhi = true;
|
|
|
+ }else {
|
|
|
+ zhi = false;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ zhi = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("校验结果:" + zhi);
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("jiaoyanjieguo", zhi);
|
|
|
+ map.put("jiaoyanxinxi","【领导】人员,不允许选择加班费,请重新选择!");
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单打开时加载(员工假期类型)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String getJiaqileixing(String userid){
|
|
|
+ log.info("获取当前表单传参人员userid:" + userid);
|
|
|
+
|
|
|
+ //智能人事获取员工花名册信息,抓取【人员类型】字段信息
|
|
|
+ String body = null;
|
|
|
+ String label = null;
|
|
|
+ try {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/list");
|
|
|
+ OapiSmartworkHrmEmployeeV2ListRequest req = new OapiSmartworkHrmEmployeeV2ListRequest();
|
|
|
+ //待查询人员userid
|
|
|
+ req.setUseridList(userid);
|
|
|
+ req.setAgentid(2358039528L);
|
|
|
+ OapiSmartworkHrmEmployeeV2ListResponse rsp = client.execute(req, accessTokenService.getAccessToken());
|
|
|
+ body = rsp.getBody();
|
|
|
+ System.out.println(body);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSON.parseObject(body);
|
|
|
+ JSONArray result = jsonObject.getJSONArray("result");
|
|
|
+ JSONArray field_data_list = result.getJSONObject(0).getJSONArray("field_data_list");
|
|
|
+
|
|
|
+ for (int i = 0; i < field_data_list.size(); i++) {
|
|
|
+ //字段code
|
|
|
+ String field_code = field_data_list.getJSONObject(i).getString("field_code");
|
|
|
+// log.info("当前花名册字段field_code:" + field_code);
|
|
|
+ switch (field_code) {
|
|
|
+ //员工假期类型
|
|
|
+ case "02b2e018-0ba3-4d2c-ba8a-2d248ce23087":
|
|
|
+ JSONArray field_value_list = field_data_list.getJSONObject(i).getJSONArray("field_value_list");
|
|
|
+ //员工假期类型
|
|
|
+ label = field_value_list.getJSONObject(0).getString("label");
|
|
|
+ //当前字段下标
|
|
|
+ int old_index = i;
|
|
|
+ log.info("当前字段下标:" + old_index);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("员工假期类型:" + label);
|
|
|
+
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //宜搭接口服务【审批单实例详情】
|
|
|
+ public static com.aliyun.dingtalkworkflow_1_0.Client createClient() throws Exception {
|
|
|
+ com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
|
|
|
+ config.protocol = "https";
|
|
|
+ config.regionId = "central";
|
|
|
+ return new com.aliyun.dingtalkworkflow_1_0.Client(config);
|
|
|
+ }
|
|
|
+
|
|
|
+ //TB接口服务【创建自由任务】
|
|
|
+ public static com.aliyun.dingtalkproject_1_0.Client createClient1() throws Exception {
|
|
|
+ com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
|
|
|
+ config.protocol = "https";
|
|
|
+ config.regionId = "central";
|
|
|
+ return new com.aliyun.dingtalkproject_1_0.Client(config);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 请假审批表单提交后反校验是否提交单据内容是否符合规则,不符合执行撤销审批实例
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ @Override
|
|
|
+ public R revocationProcessInstances(String processInstances,String ygjqlx,String userid){
|
|
|
+ log.info("获取当前表单传参审批实例id:" + processInstances);
|
|
|
+ log.info("获取当前员工假期类型:" + ygjqlx);
|
|
|
+ log.info("获取当前员工userid:" + userid);
|
|
|
+
|
|
|
+ //查询请假审批单实例详情,获取请假类型
|
|
|
+ JSONObject jsonObject = null;
|
|
|
+ String qjlx = null;
|
|
|
+ try {
|
|
|
+ com.aliyun.dingtalkworkflow_1_0.Client client = createClient();
|
|
|
+ com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders getProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders();
|
|
|
+ getProcessInstanceHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
+ com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest getProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest()
|
|
|
+ //审批实例id
|
|
|
+ .setProcessInstanceId(processInstances);
|
|
|
+
|
|
|
+ GetProcessInstanceResponse processInstanceWithOptions = client.getProcessInstanceWithOptions(getProcessInstanceRequest, getProcessInstanceHeaders, new RuntimeOptions());
|
|
|
+ System.out.println(JSON.toJSONString(processInstanceWithOptions.getBody()));
|
|
|
+ String s = JSON.toJSONString(processInstanceWithOptions.getBody());
|
|
|
+ jsonObject = JSON.parseObject(s);
|
|
|
+ System.out.println("审批详情接口object对象:" + jsonObject);
|
|
|
+ } catch (TeaException err) {
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
+ // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ }
|
|
|
+ } catch (Exception _err) {
|
|
|
+ TeaException err = new TeaException(_err.getMessage(), _err);
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
+ // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONObject result = jsonObject.getJSONObject("result");
|
|
|
+ JSONArray formComponentValues = result.getJSONArray("formComponentValues");
|
|
|
+ for (int i = 0; i < formComponentValues.size(); i++) {
|
|
|
+ //请假套件类型
|
|
|
+ String componentType = formComponentValues.getJSONObject(i).getString("componentType");
|
|
|
+ switch (componentType) {
|
|
|
+ //请假套件类型
|
|
|
+ case "DDHolidayField":
|
|
|
+ JSONArray value = formComponentValues.getJSONObject(i).getJSONArray("value");
|
|
|
+ //请假类型
|
|
|
+ qjlx = value.get(4).toString();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("当前请假套件选择的请假类型:" + qjlx);
|
|
|
+
|
|
|
+ //世界标准时间
|
|
|
+ Date Date = new Date();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(Date);
|
|
|
+ calendar.add(Calendar.HOUR_OF_DAY,-8);
|
|
|
+ String format = sdf.format(calendar.getTime());
|
|
|
+ System.out.println("世界标准时间:" + format);
|
|
|
+
|
|
|
+ //判断当前员工类型属于【退休返聘】,则不能提交【年假】的请假类型
|
|
|
+ if (ygjqlx.equals("退休返聘") && qjlx.equals("年假")){
|
|
|
+ //一、发起自由任务的通知
|
|
|
+ try {
|
|
|
+ com.aliyun.dingtalkproject_1_0.Client client = createClient1();
|
|
|
+ com.aliyun.dingtalkproject_1_0.models.CreateOrganizationTaskHeaders createOrganizationTaskHeaders = new com.aliyun.dingtalkproject_1_0.models.CreateOrganizationTaskHeaders();
|
|
|
+ createOrganizationTaskHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
+ com.aliyun.dingtalkproject_1_0.models.CreateOrganizationTaskRequest createOrganizationTaskRequest = new com.aliyun.dingtalkproject_1_0.models.CreateOrganizationTaskRequest()
|
|
|
+ //任务可见性。
|
|
|
+ //involves:仅参与者可见
|
|
|
+ //members:所有人可见
|
|
|
+ .setVisible("involves")
|
|
|
+ //自由任务优先级
|
|
|
+ //较低,默认值:10
|
|
|
+ //普通:0
|
|
|
+ //紧急:1
|
|
|
+ //非常紧急:2
|
|
|
+ .setPriority(0)
|
|
|
+ //执行者userid
|
|
|
+ .setExecutorId(userid)
|
|
|
+ //是否禁止通知。
|
|
|
+ //true:禁止,不显示通知。
|
|
|
+ //false:不禁止,显示通知。
|
|
|
+ .setDisableNotification(false)
|
|
|
+ .setContent("请假审批撤销通知")
|
|
|
+ //任务截止时间:【格式:YYYY-MM-DDTHH:mm:ssZ(ISO 8601/RFC 3339)】【世界标准时间】
|
|
|
+ .setDueDate(format);
|
|
|
+
|
|
|
+ client.createOrganizationTaskWithOptions(userid, createOrganizationTaskRequest, createOrganizationTaskHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
|
|
+ } catch (TeaException err) {
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
+ // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ }
|
|
|
+ } catch (Exception _err) {
|
|
|
+ TeaException err = new TeaException(_err.getMessage(), _err);
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
+ // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //二、休眠16秒后,进行审批实例撤销
|
|
|
+ try {
|
|
|
+ log.info("休眠中,时长为:16秒...");
|
|
|
+ Thread.sleep(16000);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("开始执行撤销审批实例操作===>");
|
|
|
+ try {
|
|
|
+ com.aliyun.dingtalkworkflow_1_0.Client client = createClient();
|
|
|
+ com.aliyun.dingtalkworkflow_1_0.models.TerminateProcessInstanceHeaders terminateProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.TerminateProcessInstanceHeaders();
|
|
|
+ terminateProcessInstanceHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
|
|
|
+ com.aliyun.dingtalkworkflow_1_0.models.TerminateProcessInstanceRequest terminateProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.TerminateProcessInstanceRequest()
|
|
|
+ //是否通过系统操作。
|
|
|
+ //true:由系统直接终止
|
|
|
+ //false:由指定的操作者终止(需要传发起人才能撤销)
|
|
|
+ .setIsSystem(true)
|
|
|
+ //审批实例id
|
|
|
+ .setProcessInstanceId(processInstances)
|
|
|
+ //终止说明
|
|
|
+ .setRemark("当前人员属于【退休返聘】,不能提交年假,系统自动发起撤销!");
|
|
|
+
|
|
|
+ client.terminateProcessInstanceWithOptions(terminateProcessInstanceRequest, terminateProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
|
|
|
+ } catch (TeaException err) {
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
+ // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ }
|
|
|
+ } catch (Exception _err) {
|
|
|
+ TeaException err = new TeaException(_err.getMessage(), _err);
|
|
|
+ if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
|
|
|
+ // err 中含有 code 和 message 属性,可帮助开发定位问题
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.error().message("当前人员属于【退休返聘】,不能提交年假,将发起审批撤回!");
|
|
|
+ }else {
|
|
|
+ return R.ok().message("正常通过提交...");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|