package com.ycl.common.dingding; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.log.Log; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.xxpt.gateway.shared.api.request.OapiMoziOrganizationListOrganizationsByCodesRequest; import com.alibaba.xxpt.gateway.shared.api.request.OapiMoziOrganizationPageOrganizationEmployeePositionsRequest; import com.alibaba.xxpt.gateway.shared.api.request.OapiMoziOrganizationPageSubOrganizationCodesRequest; import com.alibaba.xxpt.gateway.shared.api.response.OapiMoziOrganizationListOrganizationsByCodesResponse; import com.alibaba.xxpt.gateway.shared.api.response.OapiMoziOrganizationPageOrganizationEmployeePositionsResponse; import com.alibaba.xxpt.gateway.shared.api.response.OapiMoziOrganizationPageSubOrganizationCodesResponse; import com.alibaba.xxpt.gateway.shared.client.http.*; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.ycl.config.DingConfig; import com.ycl.entity.depart.UmsDepart; import com.ycl.entity.dingding.DingUserInfo; import com.ycl.entity.user.UmsRole; import com.ycl.exception.ApiException; import com.ycl.service.depart.UmsDepartService; import com.ycl.service.user.UmsRoleService; import com.ycl.util.DingUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.*; import java.util.concurrent.TimeUnit; import static com.ycl.common.constant.DingConst.*; /** * Ding 获取接口api相关 * * @author cjx */ @Component public class DingCommon { private static final Log log = Log.get(); @Autowired private StringRedisTemplate redisTemplate; @Resource private ExecutableClient executableClient; @Autowired private UmsDepartService umsDepartService; @Autowired private DingUtil dingUtil; /** * 获取用户信息 * * @param code 临时授权码 前台获取 * @return */ public DingUserInfo getDingUserInfo(String code) { // 判断ding 信息是否存在 boolean hasDing = redisTemplate.hasKey("ding"); String getToken = ""; if (hasDing) { log.info("redis正常有消息"); String dingStr = redisTemplate.opsForValue().get("ding"); JSONObject dingObj = JSONObject.parseObject(dingStr); getToken = dingObj.getString("token"); } else { getToken = dingUtil.getToken(); } if (ObjectUtil.isEmpty(code) || ObjectUtil.isEmpty(getToken)) { throw new ApiException("登录异常"); } //获取用户信息 PostClient postClient = executableClient.newPostClient(GET_USER_INFO); postClient.addParameter("access_token", getToken); //token postClient.addParameter("auth_code", code);//临时授权码 String apiResult = postClient.post(); JSONObject resObj = parsingJson(apiResult); log.info("resObj--------------->{}", resObj); if (null != resObj) { resObj = resObj.getJSONObject("data"); redisTemplate.opsForValue().set("realmId", resObj.getString("realmId")); JSONObject empCodeObj = getEmpByCode(resObj.getString("employeeCode"), resObj.getString("realmId")); if (ObjectUtil.isNotEmpty(empCodeObj)) { resObj.putAll(empCodeObj); } DingUserInfo dingUserInfo = BeanUtil.toBean(resObj, DingUserInfo.class); String accId = DingEncodeUtil.getMD5(resObj.getString("employeeCode").getBytes()); dingUserInfo.setUserId(Long.parseLong(accId)); String employeeCode = resObj.getString("employeeCode"); JSONArray users = getAccountId(Arrays.asList(employeeCode)); JSONObject jsonObject = users.getJSONObject(0); String accountId = jsonObject.getString("accountId"); dingUserInfo.setAccountId(Long.parseLong(accountId)); return dingUserInfo; } return null; } /** * 根据员工Code查询详情 * * @param employeeCode 员工code列表 * @param tenantId 租户id * @return */ public JSONObject getEmpByCode(String employeeCode, String tenantId) { //获取用户信息 PostClient postClient = executableClient.newPostClient(GET_EMP_BY_CODE); postClient.addParameter("employeeCode", employeeCode); postClient.addParameter("tenantId", tenantId); String apiResult = postClient.post(); JSONObject resObj = parsingJson(apiResult); if (null != resObj) { resObj = resObj.getJSONObject("data"); } else { resObj = null; } return resObj; } /** * 发送文本消息 * * @param receiverIds 接收人用户ID(accountId), 多个人时使用半角逗号分隔, * @param content 消息,最好500字以内 * @return */ public JSONObject sendDingMsgStr(String receiverIds, String content) { //获取用户信息 PostClient postClient = executableClient.newPostClient(POST_SEND_NOTIFY); postClient.addParameter("receiverIds", receiverIds); postClient.addParameter("tenantId", dingConfig.getTenantId()); postClient.addParameter("msg", getJsonStringText(content)); String apiResult = postClient.post(); log.info("apiResult------>{}", apiResult); JSONObject resObj = parsingJson(apiResult); if (null != resObj) { resObj = resObj.getJSONObject("data"); } return resObj; } /** * 发送markdown消息 * * @param receiverIds 接收人用户ID(accountId), 多个人时使用半角逗号分隔, * @param text 消息,最好500字以内 * @return */ public JSONObject sendDingMsgMarkDown(String receiverIds, String title, String text) { //获取用户信息 PostClient postClient = executableClient.newPostClient(POST_SEND_NOTIFY); postClient.addParameter("receiverIds", receiverIds); postClient.addParameter("tenantId", dingConfig.getTenantId()); postClient.addParameter("msg", getJsonMarkDown(title, text)); String apiResult = postClient.post(); log.info("apiResult------>{}", apiResult); JSONObject resObj = parsingJson(apiResult); if (null != resObj) { resObj = resObj.getJSONObject("data"); } return resObj; } /** * 发送链接消息 * * @param receiverIds 接收人用户ID(accountId), 多个人时使用半角逗号分隔, * @param content 消息,最好500字以内 * @param title 消息标题 * @param picUrl 图片地址 * @param urlLink 链接跳转路径 * @return */ public JSONObject sendDingMsgLink(String receiverIds, String title, String urlLink, String content, String picUrl) { //获取用户信息 PostClient postClient = executableClient.newPostClient(POST_SEND_NOTIFY); postClient.addParameter("receiverIds", receiverIds); postClient.addParameter("tenantId", dingConfig.getTenantId()); postClient.addParameter("msg", getJsonStringLink(urlLink, picUrl, title, content)); String apiResult = postClient.post(); JSONObject resObj = parsingJson(apiResult); return resObj; } public JSONObject sendDingMsgCardLink(String receiverIds, String title, String urlLink, String pcUrlLink, String content) { //获取用户信息 PostClient postClient = executableClient.newPostClient(POST_SEND_NOTIFY); postClient.addParameter("receiverIds", receiverIds); postClient.addParameter("tenantId", dingConfig.getTenantId()); postClient.addParameter("bizMsgId", StrUtil.uuid()); postClient.addParameter("msg", getJsonStringCardLink(urlLink, pcUrlLink, title, content)); String apiResult = postClient.post(); JSONObject resObj = parsingJson(apiResult); return resObj; } @Resource private DingConfig dingConfig; /** * 获取通讯录权限范围 */ public JSONObject getBookAuthority() { //获取用户信息 GetClient postClient = executableClient.newGetClient(GET_BOOK_AUTH); postClient.addParameter("tenantId", dingConfig.getTenantId()); String apiResult = postClient.get(); JSONObject resObj = parsingJson(apiResult); return resObj; } /** * 查询全部部门信息 * * @return */ public List getOrgInfo(JSONArray deptTopArr) { List orgList = new ArrayList<>(); if (CollectionUtils.isEmpty(deptTopArr)) { return null; } //获取全部部门code //JSONObject topObj = getBookAuthority(); //顶级部门id // JSONArray deptTopArr = topObj.getJSONArray("deptVisibleScopes"); //根据分页获取下⼀级组织 Code 列表 一层一层获取组织 Code 列表 String topCode = deptTopArr.getString(0); orgNameList.add(topCode); getPageOrgCode(topCode); //根据code查询组织详情 JSONArray resDept = getOrgDetailByCodeList(orgNameList); //解析为系统组织结构实体类 for (int i = 0; i < resDept.size(); i++) { JSONObject orgObj = resDept.getJSONObject(i); UmsDepart depart = new UmsDepart(); //本级code编码 String code = orgObj.getString("organizationCode"); //父级code编码 String pcode = orgObj.getString("parentCode"); //本级名称 String name = orgObj.getString("organizationName"); //排序 Integer sort = orgObj.getInteger("displayOrder"); code = DingEncodeUtil.getMD5(code.getBytes()); pcode = DingEncodeUtil.getMD5(pcode.getBytes()); depart.setParentId(Long.parseLong(pcode)); depart.setId(Long.parseLong(code)); depart.setCode(orgObj.getString("organizationCode")); depart.setDepartName(name); depart.setSort(sort); orgList.add(depart); } orgNameList = new ArrayList<>(); return orgList; } /** * 根据组织code 查询 通讯录人员信息 *

* // * @return * // */ public Set getPersonInfoByOrgCode() { LambdaQueryWrapper orgLambdaQueryWrapper = new LambdaQueryWrapper<>(); orgLambdaQueryWrapper.select(UmsDepart::getCode); orgLambdaQueryWrapper.likeRight(UmsDepart::getCode, "GO_"); List orgList = umsDepartService.list(orgLambdaQueryWrapper); Set dingUserInfoList = new HashSet<>(); List employeeCodes = new ArrayList(); for (UmsDepart org : orgList) { if (ObjectUtil.isNotEmpty(org.getCode())) { IntelligentGetClient intelligentGetClient = executableClient.newIntelligentGetClient(POST_PERSON_INFO_BY_ORG_CODE); OapiMoziOrganizationPageOrganizationEmployeePositionsRequest orgOptions = new OapiMoziOrganizationPageOrganizationEmployeePositionsRequest(); //是否请求总数,默认是false // orgOptions.setReturnTotalSize(true); //分页大小,默认是20,最大100 orgOptions.setPageSize(100); //员工状态,A为有效,F为无效,默认是所有 orgOptions.setEmployeeStatus("A"); //组织code orgOptions.setOrganizationCode(org.getCode()); //请求起始页,默认是1 // orgOptions.setPageNo(1); //租户id orgOptions.setTenantId(Long.valueOf(dingConfig.getTenantId())); //page页 Integer page = 0; //是否有下一页 boolean isHasPage; do { isHasPage = false; page++; // postClient.addParameter("pageNo", page.toString()); // String apiResult = postClient.post(); orgOptions.setPageNo(page); OapiMoziOrganizationPageOrganizationEmployeePositionsResponse apiResult = intelligentGetClient.get(orgOptions); JSONObject resObj = parsingJson(JSON.toJSONString(apiResult)); if (null != resObj) { if (resObj.containsKey("data")) { JSONArray dataArr = resObj.getJSONArray("data"); for (int i = 0; i < dataArr.size(); i++) { //人员信息 JSONObject data = dataArr.getJSONObject(i); // String empName = data.getString("employeeName"); String employeeCode = data.getString("employeeCode"); employeeCodes.add(employeeCode); //根据员工code 获取员工详情 DingUserInfo dingUserInfo = getEmpInfoByCode(employeeCode); if (ObjectUtil.isNotEmpty(dingUserInfo)) { dingUserInfoList.add(dingUserInfo); } } isHasPage = true; } } //解析数据,判断是否继续查询下一页 } while (isHasPage); } } //补充accountId if (CollectionUtils.isNotEmpty(employeeCodes)) { log.info("开始补充accountId"); JSONArray users = getAccountId(employeeCodes); if (CollectionUtils.isNotEmpty(users)) { for (int i = 0; i < users.size(); i++) { JSONObject jsonObject = users.getJSONObject(i); String employeeCode = jsonObject.getString("employeeCode"); String accountId = jsonObject.getString("accountId"); Optional first = dingUserInfoList.stream().filter(dingUserInfo -> dingUserInfo.getEmployeeCode().equals(employeeCode)) .findFirst(); if (first.isPresent()) { DingUserInfo dingUserInfo = first.get(); dingUserInfo.setAccountId(Long.parseLong(accountId)); } } } } JSONArray arr = new JSONArray(Collections.singletonList(dingUserInfoList)); redisTemplate.opsForValue().set("userJsonList", arr.toJSONString()); return dingUserInfoList; } /** * 根据员工code 获取员工accountId * * @param employeeCodes 员工code * @return 钉钉用户体系实体对象 */ private JSONArray getAccountId(List employeeCodes) { log.info("Code参数集合------>{}", employeeCodes); PostClient postClient = executableClient.newPostClient(POST_ACCOUNTID_BY_EMPLOYEECODE); for (String code : employeeCodes) { postClient.addParameter("employeeCodes", code); } postClient.addParameter("tenantId", dingConfig.getTenantId()); String apiResult = postClient.post(); JSONObject resObj = parsingJson(apiResult); if (null != resObj) { return resObj.getJSONArray("data"); } return null; } @Resource UmsRoleService userRoleService; /** * 根据员工code 获取员工详情 * * @param employeeCode 员工code * @return 钉钉用户体系实体对象 */ public DingUserInfo getEmpInfoByCode(String employeeCode) { if (ObjectUtil.isNotEmpty(employeeCode)) { //根据员工code获取员工详细信息 JSONObject empCodeObj = getEmpByCode(employeeCode, dingConfig.getTenantId()); if (ObjectUtil.isNotEmpty(empCodeObj)) { empCodeObj.put("userId", DingEncodeUtil.getMD5(employeeCode.getBytes())); //查询任职 JSONArray jobArr = getStaffAppointment(employeeCode); assert jobArr != null; //临时保存任职的ids(系统的用户体系) List posIds = new ArrayList<>(); //用户角色code List roleCodeList = new ArrayList<>(); for (int j = 0; j < jobArr.size(); j++) { JSONObject jobPos = jobArr.getJSONObject(j); //是否主职 Boolean isMain = jobPos.getBoolean("mainJob"); if (isMain) { JSONObject holdapost = jobArr.getJSONObject(0); String orgCode = holdapost.getString("organizationCode"); if (StrUtil.isNotBlank(orgCode)) { // JSONObject orgDetail = getOrgDetailByCode(orgCode); // if (null != orgDetail) { // String orgId = orgDetail.getString("organizationCode"); // String orgName = orgDetail.getString("organizationName"); Long orgId = Long.parseLong(DingEncodeUtil.getMD5(orgCode.getBytes())); empCodeObj.put("orgId", orgId); // empCodeObj.put("orgName", orgName); // } } } //职位信息 String posName = jobPos.getString("govEmpPosJob"); if (StrUtil.isBlank(posName)) { posName = "未填写职位名称"; } //角色 String roleCode = jobPos.getString("empPosEmployeeRoleCode"); roleCodeList.add(roleCode); String code = DingEncodeUtil.getMD5(posName.getBytes()); //查询是否有重复的 LambdaQueryWrapper posLambdaQueryWrapper = new LambdaQueryWrapper<>(); // posLambdaQueryWrapper.eq(UmsRole::getCode, code); posLambdaQueryWrapper.eq(UmsRole::getName, posName); posLambdaQueryWrapper.last("LIMIT 1"); UmsRole posOne = userRoleService.getOne(posLambdaQueryWrapper); //任职名称不存在,自动添加 if (ObjectUtil.isEmpty(posOne)) { posOne = new UmsRole(); posOne.setSort(100); posOne.setName(posName); posOne.setCode(code); posOne.setStatus(1); userRoleService.save(posOne); } else { posOne.setCode(code); userRoleService.updateById(posOne); } posIds.add(posOne.getId()); } //转换为实体类 DingUserInfo dingUserInfo = BeanUtil.toBean(empCodeObj, DingUserInfo.class); Long orgId = dingUserInfo.getOrgId(); if (ObjectUtil.isNotEmpty(orgId)) { dingUserInfo.setPosIdList(posIds); dingUserInfo.setRoleCodeList(roleCodeList); } return dingUserInfo; } } return null; } /** * 根据员工Code获取员工的任职 */ private JSONArray getStaffAppointment(String empCode) { PostClient postClient = executableClient.newPostClient(POST_STAFF_APPOINTMENT); postClient.addParameter("tenantId", dingConfig.getTenantId()); postClient.addParameter("employeeCode", empCode); String apiResult = postClient.post(); JSONObject dataObj = parsingJson(apiResult); if (null != dataObj) { return dataObj.getJSONArray("data"); } return null; } /** * 根据组织code获取组织详情 */ private JSONObject getOrgDetailByCode(String orgCode) { PostClient postClient = executableClient.newPostClient(POST_ORG_BY_CODE); postClient.addParameter("tenantId", dingConfig.getTenantId()); postClient.addParameter("organizationCode", orgCode); String apiResult = postClient.post(); JSONObject dataObj = parsingJson(apiResult); if (null != dataObj) { return dataObj.getJSONObject("data"); } return dataObj; } /** * 批量根据组织Code查询详情 */ private JSONArray getOrgDetailByCodeList(List codeList) { JSONArray resultArr = new JSONArray(); if (ObjectUtil.isNotEmpty(codeList)) { int codeIndexSize = codeList.size() % 100 == 0 ? codeList.size() / 100 : codeList.size() / 100 + 1; List result; int start = 0; int end = 0; for (int i = 1; i <= codeIndexSize; i++) { if (codeList.size() >= 100) { end += 100; if (i == codeIndexSize) { end = codeList.size(); } result = codeList.subList(start, end); start = end; } else { result = codeList; } //executableClient保证单例 IntelligentPostClient intelligentPostClient = executableClient.newIntelligentPostClient(POST_ORG_DETIAL_CODE_BATTH); OapiMoziOrganizationListOrganizationsByCodesRequest oapiMoziOrganizationListOrganizationsByCodesRequest = new OapiMoziOrganizationListOrganizationsByCodesRequest(); oapiMoziOrganizationListOrganizationsByCodesRequest.setOrganizationCodes(result); oapiMoziOrganizationListOrganizationsByCodesRequest.setTenantId(Long.parseLong(dingConfig.getTenantId())); //获取结果 OapiMoziOrganizationListOrganizationsByCodesResponse apiResult = intelligentPostClient.post(oapiMoziOrganizationListOrganizationsByCodesRequest); if (apiResult.getSuccess()) { JSONArray obj = JSONArray.parseArray(apiResult.getContent().getData()); resultArr.addAll(obj); } } } return resultArr; } /** * 根据分页获取下⼀级组织 Code 列表 * * @return */ private List orgNameList = new ArrayList<>(); /** * 分页获取下⼀级组织 Code 列表 * * @param partCode */ private void getPageOrgCode(String partCode) { //临时存放当前组织 List currTempOrgList = new ArrayList<>(); // PostClient postClient = executableClient.newPostClient(POST_ORG_PAGE_CODE_LIST); // postClient.addParameter("tenantId", TENANT_ID); // postClient.addParameter("organizationCode", partCode); //只查询有效数据 // postClient.addParameter("status", "A"); // postClient.addParameter("pageSize", "100"); IntelligentGetClient intelligentGetClient = executableClient.newIntelligentGetClient(POST_ORG_PAGE_CODE_LIST); OapiMoziOrganizationPageSubOrganizationCodesRequest options = new OapiMoziOrganizationPageSubOrganizationCodesRequest(); // options.setReturnTotalSize(true); options.setOrganizationCode(partCode); options.setPageSize(100); options.setStatus("A"); options.setTenantId(Long.valueOf(dingConfig.getTenantId())); //page页 Integer page = 0; //是否有下一页 boolean isHasPage; do { isHasPage = false; page++; // postClient.addParameter("pageNo", page.toString()); // String apiResult = postClient.post(); options.setPageNo(page); OapiMoziOrganizationPageSubOrganizationCodesResponse apiResult = intelligentGetClient.get(options); JSONObject resObj = parsingJson(JSON.toJSONString(apiResult)); if (null != resObj) { if (resObj.containsKey("data")) { JSONArray dataArr = resObj.getJSONArray("data"); for (int i = 0; i < dataArr.size(); i++) { String deptCode = dataArr.getString(i); currTempOrgList.add(deptCode); orgNameList.add(deptCode); } isHasPage = true; } } //解析数据,判断是否继续查询下一页 } while (isHasPage); for (String str : currTempOrgList) { getPageOrgCode(str); } } /** * 解析返回值 * * @param apiResult */ private JSONObject parsingJson(String apiResult) { try { if (ObjectUtil.isNotNull(apiResult)) { JSONObject resJson = JSONObject.parseObject(apiResult); if (resJson.getBoolean("success")) { JSONObject data = resJson.getJSONObject("content"); if (ObjectUtil.isNotEmpty(data)) { return data; } } else if (!ObjectUtil.equals("OPF-B001-05-16-0006", resJson.getString("bizErrorCode"))) { log.error("DING_ERROR:" + resJson.toJSONString()); return resJson; } } } catch (Exception e) { redisTemplate.opsForValue().set("error_" + System.currentTimeMillis(), apiResult, 10, TimeUnit.MINUTES); return null; } return null; } /** * 拼接要发送的消息 文本消息 * json对象 必须 {"msgtype":"text","text":{"content":"消息内容"}} * 消息内容,目前支持:文本消息:text, 链接消息:link, OA消息:oa, 卡片消息:action_card。最长不超过2048个字节 * * @param content */ private String getJsonStringText(String content) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msgtype", "text");//消息类型,此时固定为:text JSONObject text = new JSONObject(); text.put("content", content);//消息内容,建议500字符以内 jsonObject.put("text", text); String jsonStr = JSONObject.toJSONString(jsonObject); return jsonStr; } /** * 拼接要发送的消息 markdown消息 * json对象 必须 {"msgtype":"markdown","markdown":{"title":"首屏会话透出的展示内容","text":"消息内容"}} * * @param title 首屏会话透出的展示内容 */ private String getJsonMarkDown(String title, String text) { JSONObject jsonObject = new JSONObject(); jsonObject.put("msgtype", "markdown");//消息类型,此时固定为:markdown JSONObject markdown = new JSONObject(); markdown.put("title", title);//首屏会话透出的展示内容 markdown.put("text", text);//消息内容,建议500字符以内 jsonObject.put("markdown", markdown); String jsonStr = JSONObject.toJSONString(jsonObject); return jsonStr; } /** * 拼接要发送的消息 链接消息 * * @param messageUrl 消息点击链接地址,当发送消息为小程序时支持小程序跳转链接 * @param picUrl 图片地址 * @param title 消息标题,建议100字符以内 * @param text 消息描述,建议500字符以内 */ private String getJsonStringLink(String messageUrl, String picUrl, String title, String text) { JSONObject jsonObject = new JSONObject(); //消息类型,此时固定为:text jsonObject.put("msgtype", "link"); JSONObject link = new JSONObject(); link.put("messageUrl", messageUrl); link.put("picUrl", picUrl); link.put("title", title); link.put("text", text); jsonObject.put("link", link); String jsonStr = JSONObject.toJSONString(jsonObject); return jsonStr; } /** * 拼接要发送的消息 卡片链接消息 * * @param messageUrl 消息点击链接地址,当发送消息为小程序时支持小程序跳转链接 * @param title 消息标题,建议100字符以内 * @param text 消息描述,建议500字符以内 */ private String getJsonStringCardLink(String messageUrl, String messagePcUrl, String title, String text) { JSONObject jsonObject = new JSONObject(); //消息类型,此时固定为:text jsonObject.put("msgtype", "action_card"); JSONObject link = new JSONObject(); link.put("title", title); link.put("markdown", text); link.put("single_title", "查看详情"); link.put("single_url", messageUrl); link.put("single_pc_url", messagePcUrl); jsonObject.put("action_card", link); String jsonStr = JSONObject.toJSONString(jsonObject); return jsonStr; } // // /** // * 下载员工头像 // * // * @param mediaId 媒体头像id // */ // public void downloadEmployeeAvatar(String mediaId) { // try { // String api = "/media/download"; // GetClient getClient = executableClient.newGetClient(api); // //设置参数 // String dingStr = redisTemplate.opsForValue().get("ding"); // JSONObject dingObj = JSONObject.parseObject(dingStr); // String getToken = dingObj.getString("token"); // getClient.addParameter("access_token", getToken); // getClient.addParameter("media_id", mediaId.replace("$", "")); // CloseableHttpResponse response = getClient.getB(); // //调用API // String fileName = mediaId + ".jpg"; // String path = ConstantContextHolder.getSysConfig("SNOWY_FILE_UPLOAD_PATH_FOR_WINDOWS", String.class, null) + "/Avatar/"; // File voice = new File(path + fileName); // FileUtil.writeFromStream(response.getEntity().getContent(), voice); // } catch (Exception e) { // log.error("DING_ERROR:" + e.getMessage()); // System.out.println(e); // } // } }