|
|
@@ -1,15 +1,21 @@
|
|
|
package com.usoftchina.uas.office.dingtalk.service;
|
|
|
|
|
|
+import com.aliyun.dingtalktodo_1_0.models.QueryOrgTodoTasksResponseBody;
|
|
|
import com.dingtalk.api.response.OapiAlitripBtripApplySearchResponse;
|
|
|
import com.dingtalk.api.response.OapiAttendanceGetleavestatusResponse;
|
|
|
import com.dingtalk.api.response.OapiSmartworkHrmEmployeeListdimissionResponse;
|
|
|
+import com.dingtalk.api.response.OapiUserGetResponse;
|
|
|
+import com.usoftchina.dingtalk.sdk.AddrBookSdk;
|
|
|
import com.usoftchina.dingtalk.sdk.OaSdk;
|
|
|
+import com.usoftchina.dingtalk.sdk.config.DingTalkProperties;
|
|
|
+import com.usoftchina.dingtalk.sdk.util.UrlUtils;
|
|
|
import com.usoftchina.uas.office.dingtalk.core.DateUtil;
|
|
|
+import com.usoftchina.uas.office.dingtalk.manage.entity.DingTalkAgent;
|
|
|
+import com.usoftchina.uas.office.dingtalk.manage.service.DingTalkAgentService;
|
|
|
import com.usoftchina.uas.office.service.AbstractService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.support.rowset.SqlRowSet;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
@@ -23,6 +29,12 @@ public class UasOaService extends AbstractService {
|
|
|
private final Logger logger = LoggerFactory.getLogger(UasOaService.class);
|
|
|
@Autowired
|
|
|
private OaSdk oaSdk;
|
|
|
+ @Autowired
|
|
|
+ private AddrBookSdk addrBookSdk;
|
|
|
+ @Autowired
|
|
|
+ private DingTalkProperties properties;
|
|
|
+ @Autowired
|
|
|
+ private DingTalkAgentService agentService;
|
|
|
|
|
|
public void saveOa(String agentCode,int id){
|
|
|
logger.info("agentCode=="+agentCode);
|
|
|
@@ -174,4 +186,46 @@ public class UasOaService extends AbstractService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void sendJprocess(String agentCode,String url,String master,String title,String description) throws Exception {
|
|
|
+ DingTalkAgent agent = agentService.findByCode(agentCode);
|
|
|
+ //创建人
|
|
|
+ String creatorId="WQl6DqxOyZ4brwoQaiSyiSuwiEiE";
|
|
|
+ SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet("select data from configs where caller='sys' and code='sendJprocessCreator' ");
|
|
|
+ if (sqlRowSet.next()){
|
|
|
+ String data = sqlRowSet.getString("data");
|
|
|
+ if (data!=null&&!"".equals(data)){
|
|
|
+ SqlRowSet rowS = jdbcTemplate.queryForRowSet("select em_code,em_ding from employee where em_class<>'离职' and em_ding is not null and em_name='" + data + "'");
|
|
|
+ if (rowS.next()){
|
|
|
+ OapiUserGetResponse user = addrBookSdk.getUser(agentCode, rowS.getString("em_ding"));
|
|
|
+ creatorId = user.getUnionid();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //流程处理
|
|
|
+ SqlRowSet rs = jdbcTemplate.queryForRowSet("select em_code,em_ding from employee where em_class<>'离职' and em_ding is not null and nvl(em_issendding,0)<>0");
|
|
|
+ while (rs.next()){
|
|
|
+ OapiUserGetResponse user = addrBookSdk.getUser(agentCode, rs.getString("em_ding"));
|
|
|
+ String unionid = user.getUnionid();
|
|
|
+ //删除旧流程
|
|
|
+ List<QueryOrgTodoTasksResponseBody.QueryOrgTodoTasksResponseBodyTodoCards> allTodo = oaSdk.getAllTodo(agentCode, unionid, "0", false);
|
|
|
+ for (QueryOrgTodoTasksResponseBody.QueryOrgTodoTasksResponseBodyTodoCards todo:allTodo) {
|
|
|
+ if (title.equals(todo.subject)){
|
|
|
+ oaSdk.deleteTodo(agentCode,unionid,todo.taskId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //推送新流程
|
|
|
+ SqlRowSet rowSet = jdbcTemplate.queryForRowSet("SELECT ROW_NUMBER() OVER(ORDER BY JP_LAUNCHTIME ASC) RN , count(JP_ID) OVER(ORDER BY JP_NODEDEALMAN DESC) COUNTS, \n" +
|
|
|
+ "TRUNC(SYSDATE-JP_LAUNCHTIME) PASSTIME,JP_LAUNCHERNAME,Jp_nodeid,TYPECODE,JP_NODEDEALMAN,JP_LAUNCHTIME,JP_NAME,CURRENTMASTER \n" +
|
|
|
+ "FROM JPROCESSVIEW WHERE JP_NODEDEALMAN ='" + rs.getString("em_code") + "' AND JP_STATUS = '待审批'");
|
|
|
+ if (rowSet.next()){
|
|
|
+ String appUrl = UrlUtils.generateAuthUrl(properties.getCorpId(),master, agentCode,agent.getOuterUrl(),url+"office/authorize", "uas/uasApproval/MOYING");
|
|
|
+ System.err.println(appUrl);
|
|
|
+ String pcUrl="";
|
|
|
+ //String pcUrl=url+"office/authorize?corpId="+properties.getCorpId()+"&agent="+agentCode+"&url=aHR0cDovLzExMy4xMDYuNzIuMjQ1OjgwOTkvRVJQL3Vhcy91YXNBcHByb3ZhbC9NT1lJTkcv&master="+master;
|
|
|
+ oaSdk.createTodo(agentCode,unionid,creatorId,appUrl,pcUrl,title,description,40,"1",false);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|