最新版本541200007最新版本541200007
| | |
| | | * http 相关的常量 |
| | | */ |
| | | public class HttpConstant { |
| | | public static final String HOST = "https://api.jiandaoyun.com/api/"; |
| | | // public static final String HOST = "https://api.jiandaoyun.com/api/"; |
| | | // public static final String HOST = "https://lcdp.ahyc.com.cn:30443/api/"; |
| | | |
| | | /** |
| | | * 部门相关的接口前缀 |
| | |
| | | package com.doumee.core.jiandaoyun.model.http; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.core.jiandaoyun.util.LimitUtil; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | */ |
| | | public Map<String, Object> sendPostRequest(HttpRequestParam param) throws Exception { |
| | | if (param == null || StringUtils.isBlank(param.getPath())) { |
| | | throw new RuntimeException("缺失参数!"); |
| | | throw new Exception("缺失参数!"); |
| | | } |
| | | HttpClient client = getSSLHttpClient(); |
| | | Header[] headers = getHttpHeaders(this.getApiKey()); |
| | | String url = this.host + param.getPath(); |
| | | log.error("===简道云接口url:"+url); |
| | | HttpRequestBase request = new HttpPost(url); |
| | | |
| | | // 请求参数 |
| | |
| | | result = (Map<String, Object>) mapper.readValue(response.getEntity().getContent(), Object.class); |
| | | } |
| | | if (statusCode >= 400) { |
| | | throw new RuntimeException("请求错误,statusCode:" + statusCode + ",Error Code: " + result.get("code") + ", Error Msg: " + result.get("msg")); |
| | | log.error("===简道云接口:请求错误,statusCode:" + statusCode + ",Error Code: " + result.get("code") + ", Error Msg: " + result.get("msg")); |
| | | throw new Exception("请求错误,statusCode:" + statusCode + ",Error Code: " + result.get("code") + ", Error Msg: " + result.get("msg")); |
| | | } else { |
| | | // 处理返回结果 |
| | | log.error("===简道云接口:请求成功result:" + JSONObject.toJSONString(result)); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | private String sex; |
| | | private String job_date; |
| | | private String can_visit;//可拜访 不可拜访 |
| | | private String master;//是 否 |
| | | private String phone; |
| | | private String name; |
| | | private String idcardno; |
| | |
| | | public static final String JDY_CAR_SECRET = " JDY_CAR_SECRET"; |
| | | public static final String JDY_SECRET ="JDY_SECRET"; |
| | | public static final String JDY_MEMBER_PUSH_STATUS_URL ="JDY_MEMBER_PUSH_STATUS_URL"; |
| | | public static final String JDY_API_HOST = "API_HOST"; |
| | | |
| | | /** |
| | | * 操作类型,用于做接口验证分组 |
| | |
| | | public static final String LOCATION ="LOCATION" ; |
| | | public static final String API_KEY ="API_KEY" ; |
| | | public static final String JDY_CONFIG ="JDY_CONFIG" ; |
| | | public static final String JDY_COMPANY_ROOT_NO ="JDY_COMPANY_ROOT_NO" ; |
| | | public static final String CABINET_CONFIG ="CABINET_CONFIG" ; |
| | | public static final String BLOW_TIME ="BLOW_TIME" ; |
| | | public static final String PRESSURE ="PRESSURE" ; |
| | |
| | | @Override |
| | | public String syncJdyCompany() { |
| | | //{ |
| | | // "dept_no": 1,//数字 1 为根部门编号。 |
| | | // "dept_no": 1,//数字 1 为根部门编号。483636217:芜湖市公司 |
| | | // "has_child": true |
| | | //} |
| | | DeptApiClient deptApiClient = new DeptApiClient(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.API_KEY).getCode(), HttpConstant.HOST); |
| | | DeptApiClient deptApiClient = new DeptApiClient(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.API_KEY).getCode() |
| | | ,systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_HOST).getCode()); |
| | | try { |
| | | Map<String, Object> result = deptApiClient.deptList(1,true,deptApiClient.getDefaultVersion()); |
| | | int root = 1; |
| | | try { |
| | | root = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_COMPANY_ROOT_NO).getCode()); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | Map<String, Object> result = deptApiClient.deptList(root,true,deptApiClient.getDefaultVersion()); |
| | | if(result!=null && result.get("departments")!=null ){ |
| | | TypeReference<List<DeptEntityModel>> typeReference = new TypeReference<List<DeptEntityModel>>(){}; |
| | | Object obj = result.get("departments"); |
| | |
| | | e.printStackTrace(); |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "同步数据异常!"); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 整理钉钉同步 新增组织对象 |
| | | * @return |
| | |
| | | private Company getUpdateCompanyModel(Company param, Company company) { |
| | | return syncDDEditCompanyModel(param,company); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据ERPID 判断数据是否已在集合里存在 |
| | |
| | | import com.doumee.core.dingTalk.DingTalkStream; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.jiandaoyun.api.arch.DeptApiClient; |
| | | import com.doumee.core.jiandaoyun.api.jdy.FormDataApiClient; |
| | | import com.doumee.core.jiandaoyun.model.form.FormDataCreateParam; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.business.*; |
| | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ddUserIdList)){ |
| | | for (String ddUserId:ddUserIdList) { |
| | | this.getJDYData(warningEvent,ddUserId, |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.API_KEY).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.APPID).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.ENTRY_ID).getCode() |
| | | ); |
| | | } |
| | |
| | | * 简道云消息推送 定制 |
| | | * @param warningEvent |
| | | * @param ddUserId 接收人 钉钉主键 |
| | | * @param jdyApiKey 简单云APIKEY |
| | | * @param appid 应用ID |
| | | * @param entryId 表单ID |
| | | * @throws IOException |
| | | */ |
| | | public void getJDYData(WarningEvent warningEvent,String ddUserId,String jdyApiKey,String appid,String entryId) throws IOException { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("app_id",appid); |
| | | map.put("entry_id",entryId); |
| | | map.put("is_start_workflow","false"); |
| | | map.put("is_start_trigger","true"); |
| | | map.put("data",this.getJdyChildData(warningEvent,ddUserId)); |
| | | |
| | | // OkHttpClient client = new OkHttpClient().newBuilder() |
| | | // .build(); |
| | | // MediaType mediaType = MediaType.parse("application/json"); |
| | | // RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(map));//"{\"data\":{\"notice_time\":{\"value\":\"2025-12-23 04:56:29\"},\"title\":{\"value\":\"跨越生产线\"},\"user\":{\"value\":\"1568490244651036\"},\"content\":{\"value\":\"跨越生产线-芜湖物流中心北围墙过道东\"},\"notice_type\":{\"value\":\"跨越生产线\"}},\"is_start_trigger\":\"true\",\"app_id\":\"6909d0fbdb93b068192dc4a9\",\"entry_id\":\"694a19ecf57e071788efc20b\",\"is_start_workflow\":\"false\"}"); |
| | | // log.error("简道云发送通知请求信息" + JSONObject.toJSONString(map)); |
| | | // Request request = new Request.Builder() |
| | | // .url("https://api.jiandaoyun.com/api/v5/app/entry/data/create") |
| | | // .method("POST", body) |
| | | // .addHeader("Authorization", "Bearer "+jdyApiKey) |
| | | // .addHeader("Content-Type", "application/json") |
| | | // .build(); |
| | | // Response response = client.newCall(request).execute(); |
| | | // |
| | | // log.error("简道云发送通知返回信息" + JSONObject.toJSONString(response)); |
| | | |
| | | public void getJDYData(WarningEvent warningEvent,String ddUserId , String entryId) { |
| | | try { |
| | | log.error("简道云发送通知返回信息开始" ); |
| | | FormDataApiClient apiClient = new FormDataApiClient(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.API_KEY).getCode() |
| | | ,systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_HOST).getCode()); |
| | | FormDataCreateParam param =new FormDataCreateParam(); |
| | | param.setData(this.getJdyChildData(warningEvent,ddUserId)); |
| | | param.setApp_id(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.APPID).getCode()); |
| | | param.setEntry_id(entryId); |
| | | param.setIs_start_trigger(false); |
| | | param.setIs_start_trigger(true); |
| | | Map<String, Object> response = apiClient.singleDataCreate(param,apiClient.getDefaultVersion()); |
| | | /* |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("app_id",appid); |
| | | map.put("entry_id",entryId); |
| | | map.put("is_start_workflow","false"); |
| | | map.put("is_start_trigger","true"); |
| | | map.put("data",this.getJdyChildData(warningEvent,ddUserId)); |
| | | OkHttpClient client = new OkHttpClient().newBuilder() |
| | | .build(); |
| | | MediaType mediaType = MediaType.parse("application/json"); |
| | | RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(map));//"{\"data\":{\"notice_time\":{\"value\":\"2025-12-23 04:56:29\"},\"title\":{\"value\":\"跨越生产线\"},\"user\":{\"value\":\"1568490244651036\"},\"content\":{\"value\":\"跨越生产线-芜湖物流中心北围墙过道东\"},\"notice_type\":{\"value\":\"跨越生产线\"}},\"is_start_trigger\":\"true\",\"app_id\":\"6909d0fbdb93b068192dc4a9\",\"entry_id\":\"694a19ecf57e071788efc20b\",\"is_start_workflow\":\"false\"}"); |
| | | log.error("简道云发送通知请求信息" + JSONObject.toJSONString(map)); |
| | | Request request = new Request.Builder() |
| | | .url(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_HOST).getCode()+"v5/app/entry/data/create") |
| | | .method("POST", body) |
| | | .addHeader("Authorization", "Bearer "+jdyApiKey) |
| | | .addHeader("Content-Type", "application/json") |
| | | .build(); |
| | | Response response = client.newCall(request).execute();*/ |
| | | log.error("简道云发送通知返回信息" + JSONObject.toJSONString(response)); |
| | | }catch (Exception e){ |
| | | log.error("简道云发送通知返回信息异常:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ddUserIdList)){ |
| | | for (String ddUserId:ddUserIdList) { |
| | | this.getJDYData(warningEvent,ddUserId, |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.API_KEY).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.APPID).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.ENTRY_ID).getCode() |
| | | |
| | | ); |
| | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ddUserIdList)){ |
| | | for (String ddUserId:ddUserIdList) { |
| | | impl.getJDYData(warningEvent,ddUserId, |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.API_KEY).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.APPID).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.ENTRY_ID).getCode() |
| | | |
| | | ); |
| | |
| | | .eq( Member::getType,Constants.TWO ) |
| | | .last("limit 1")); |
| | | } |
| | | boolean addOrEdit = false; |
| | | if(member == null){ |
| | | //新增人员 |
| | | if(data.getDeleter()!=null){ |
| | |
| | | } |
| | | member = getAddOrUpdateModelFromJDY(data,true); |
| | | this.create(member); |
| | | addOrEdit=true; |
| | | }else{ |
| | | //更新人员 |
| | | if(data.getDeleter()!=null){ |
| | |
| | | //更新人员信息 |
| | | Member updateMember =getAddOrUpdateModelFromJDY(data,false); |
| | | updateMember.setId(member.getId()); |
| | | addOrEdit=true; |
| | | this.updateById(updateMember); |
| | | } |
| | | } |
| | | if(addOrEdit && Constants.equalsInteger(member.getHeadStatus(),Constants.ONE) && member.getCompanyModel()!=null){ |
| | | //如果是部门主管 |
| | | Company updateCom = new Company(); |
| | | updateCom.setHeadId(member.getId()); |
| | | updateCom.setId(member.getCompanyModel().getId()); |
| | | companyMapper.updateById(updateCom);//更新部门主管人员 |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | if(StringUtils.isNotBlank(data.getCan_visit())){ |
| | | member.setCanVisit(StringUtils.equals(data.getCan_visit(),"可拜访")?1:0); |
| | | } |
| | | if(StringUtils.isNotBlank(data.getMaster())){ |
| | | member.setHeadStatus(StringUtils.equals(data.getMaster(),"是")?1:0); |
| | | } |
| | | member.setErpId(data.getUsername()); |
| | | if(data.getDepartment()!=null){ |
| | |
| | | |
| | | @Override |
| | | public String syncJdyUserInfo() { |
| | | DeptApiClient deptApiClient = new DeptApiClient(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.API_KEY).getCode(), HttpConstant.HOST); |
| | | DeptApiClient deptApiClient = new DeptApiClient(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.API_KEY).getCode() |
| | | ,systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_HOST).getCode()); |
| | | try { |
| | | Map<String, Object> result = deptApiClient.deptMemberList(1,true,deptApiClient.getDefaultVersion()); |
| | | if(result!=null && result.get("users")!=null ){ |
| | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ddUserIdList)){ |
| | | for (String ddUserId:ddUserIdList) { |
| | | impl.getJDYData(warningEvent,ddUserId, |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.API_KEY).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.APPID).getCode(), |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.ENTRY_ID).getCode() |
| | | |
| | | ); |