yusm hai 2 meses
pai
achega
01c0c50bcc

+ 5 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -1106,6 +1106,7 @@ public class WeiXinCorpController {
                             contactSyncLogMapper.insert(contactSyncLog);
                         }else {
                             userMapper.insert(user);
+                            wxCorpInfoService.getUserByCompanyIdAndTransferLicense(companyId,user.getCorpwxUserid());
                             contactSyncLog.setResult(1);
                             //contactSyncLog.setMsg("同步成功");
                             contactSyncLog.setMsg(MessageUtils.message("wx.synSuccess"));
@@ -2385,7 +2386,7 @@ public class WeiXinCorpController {
 
     //改造老版的接口,从平台获取客户通讯录
     @RequestMapping("/getCorpMembsFromPlatform")
-    public HttpRespMsg getCorpMembsFromPlatform(Integer companyId) {
+    public HttpRespMsg getCorpMembsFromPlatform(Integer companyId) throws Exception {
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
         Company company = companyMapper.selectOne(new QueryWrapper<Company>().eq("id", companyId));
         Integer employeeCnt = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active",1));
@@ -2581,6 +2582,9 @@ public class WeiXinCorpController {
                     return msg;
                 }else {
                     userService.saveBatch(newUserList);
+                    for (User user : newUserList) {
+                        wxCorpInfoService.getUserByCompanyIdAndTransferLicense(companyId,user.getCorpwxUserid());
+                    }
                 }
             }
             //姓名,部门,账号的同步更新

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/WxCorpInfoService.java

@@ -89,4 +89,7 @@ public interface WxCorpInfoService extends IService<WxCorpInfo> {
     public String applyEvent(HttpServletRequest request, JSONObject data) throws Exception;
 
     String getAsyncJobResult(String tmpFileJobId,WxCorpInfo wxCorpInfo)  throws Exception;
+
+
+    void getUserByCompanyIdAndTransferLicense(Integer companyId,String takeoverId) throws Exception;
 }

+ 71 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -257,8 +257,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         params.put("type","file");
         params.put("filename",fileName);
 //        params.put("url","https://worktime.ttkuaiban.com/upload/"+fileName);
-        params.put("url","http://47.101.180.183:9097/upload/"+fileName);
-//        System.out.println("uploadJobFileUrl=== "+"http://47.101.180.183:9097/upload/"+fileName);
+        params.put("url","http://1.94.62.58:9097/upload/"+fileName);
+//        System.out.println("uploadJobFileUrl=== "+"http://1.94.62.58:9097/upload/"+fileName);
         params.put("md5",md5);
         String requestBody = JSONObject.toJSONString(params);
         HttpEntity<String> entity = new HttpEntity<>(requestBody, headers);
@@ -2485,6 +2485,73 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         return resultList;
     }
 
+
+    @Override
+    @Async("taskExecutor")
+    public void getUserByCompanyIdAndTransferLicense(Integer companyId,String takeoverId) throws Exception {
+        if (StringUtils.isEmpty(takeoverId)){
+            return;
+        }
+        String providerAccessToken = getProviderAccessToken();
+        String url ="https://qyapi.weixin.qq.com/cgi-bin/license/get_active_info_by_user?provider_access_token=" + providerAccessToken;
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
+        List<User> users = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active", 0));
+        if (users.size() != 0 && wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
+            //发送请求
+            HttpHeaders headers = new HttpHeaders();
+            RestTemplate restTemplate = new RestTemplate();
+            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
+            headers.setContentType(type);
+            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
+            for (User item : users) {
+                JSONObject requestMap = new JSONObject();
+                requestMap.put("corpid", wxCorpInfo.getCorpid());
+                requestMap.put("userid", item.getCorpwxUserid());
+                HttpEntity<JSONObject> entity = new HttpEntity<>(requestMap, headers);
+                ResponseEntity<String> ResponseEntity = restTemplate.postForEntity(url, entity, String.class);
+                if (ResponseEntity.getStatusCode() == HttpStatus.OK) {
+                    String resp = ResponseEntity.getBody();
+                    JSONObject respJson = JSONObject.parseObject(resp);
+                    if (respJson.getInteger("errcode")==0){
+                        Integer status = respJson.getInteger("active_status");
+                        if (status.equals(1)){
+                            HashMap<String, String> map = new HashMap<>();
+                            String handoverId = item.getCorpwxUserid();//要转移的成员
+
+                            String url1 ="https://qyapi.weixin.qq.com/cgi-bin/license/batch_transfer_license?provider_access_token=" + providerAccessToken;
+                            HttpHeaders headers1 = new HttpHeaders();
+                            RestTemplate restTemplate1 = new RestTemplate();
+                            MediaType type1 = MediaType.parseMediaType("application/json; charset=UTF-8");
+                            headers1.setContentType(type1);
+                            headers1.add("Accept", MediaType.APPLICATION_JSON.toString());
+                            JSONObject requestMap1 = new JSONObject();
+                            requestMap1.put("corpid", wxCorpInfo.getCorpid());
+                            ArrayList<HashMap<String, String>> list1 = new ArrayList<>();
+                            HashMap<String, String> map1 = new HashMap<>();
+                            map1.put("handover_userid",handoverId);
+                            map1.put("takeover_userid",takeoverId);
+                            list1.add(map1);
+                            requestMap1.put("transfer_list", list1);
+                            HttpEntity<JSONObject> entity1 = new HttpEntity<>(requestMap1, headers1);
+                            ResponseEntity<String> ResponseEntity1=restTemplate1.postForEntity(url1, entity1, String.class);
+                            if (ResponseEntity1.getStatusCode()==HttpStatus.OK){
+                                String body = ResponseEntity1.getBody();
+                                JSONObject respJson1 = JSONObject.parseObject(body);
+
+                                if (respJson1.getInteger("errcode")==0){
+                                    log.info("转移失败");
+                                } else {
+                                    log.info("转移失败:"+respJson1.toJSONString());
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+    }
+
     /**
      * 企业微信账号继承
      * @param handoverId
@@ -2708,4 +2775,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         System.out.println("end getAsyncJobResult method");
         return mediaId;
     }
+
+
 }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -1450,7 +1450,7 @@ public class TimingTask {
         }
         SysConfig config = sysConfigMapper.selectOne(new QueryWrapper<SysConfig>().eq("param_key", "wx_suite_ticket"));
         if (config != null) {
-            String url = "http://47.101.180.183:10010/wxcorp/updateSuiteTicket?suiteTicket="
+            String url = "http://1.94.62.58:10010/wxcorp/updateSuiteTicket?suiteTicket="
                     +config.getParamValue();
             String forObject = this.restTemplate.getForObject(url, String.class);
             JSONObject json = JSONObject.parseObject(forObject);

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/CodeGenerator.java

@@ -92,7 +92,7 @@ public class CodeGenerator {
 
         // 数据源配置
         DataSourceConfig dsc = new DataSourceConfig();
-        dsc.setUrl("jdbc:mysql://47.101.180.183:17089/man_dev?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
+        dsc.setUrl("jdbc:mysql://1.94.62.58:17089/man_dev?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
 //        dsc.setSchemaName("public");
         dsc.setDriverName("com.mysql.cj.jdbc.Driver");
         dsc.setUsername("root");

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application-bkserver.yml

@@ -13,7 +13,7 @@ spring:
       max-request-size: 100MB
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://47.101.180.183:3306/man_dev?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&&useSSL=false
+    url: jdbc:mysql://1.94.62.58:3306/man_dev?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&&useSSL=false
     username: root
     password: HuoshiDB@2022
     hikari:

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application-privatewx.yml

@@ -86,7 +86,7 @@ referer:
     - localhost
     - privatewx.ttkuaiban.com
     - mobprivatewx.ttkuaiban.com
-    - 47.101.180.183
+    - 1.94.62.58
 #企业微信相关参数
 suitId: ww4e237fd6abb635af
 suitSecret: 1ApL6LIB4Z0v7wBrKTUNmJrerRWV3gEQWBlYOm8Kijw

+ 4 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application.yml

@@ -1,5 +1,5 @@
 server:
-  port: 10010
+  port: 10030
   tomcat:
     uri-encoding: utf-8
     max-http-form-post-size: -1
@@ -15,7 +15,7 @@ spring:
       location: C:/upload/
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://47.101.180.183:17089/man_hour_manager?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&useSSL=false
+    url: jdbc:mysql://1.94.62.58:17089/man_hour_manager?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&useSSL=false
     username: root
     password: P011430@Huoshi*
 #    url: jdbc:mysql://47.100.37.243:7644/man_hour_manager?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
@@ -129,7 +129,7 @@ management:
   security:
     enabled:false:
   server:
-    port: 10012
+    port: 10019
 #  endpoints:
 #    web:
 #      exposure:
@@ -151,7 +151,7 @@ referer:
     - app71020.eapps.dingtalkcloud.com
     - mldmobworktime.ttkuaiban.com
     - mldworktime.ttkuaiban.com
-    - 47.101.180.183
+    - 1.94.62.58
 excludeUrls: /wxcorp/*,/wxcorp/*/*,/dingding/*,/feishu-info/*,/error,/testClient,/corpWXAuth,/corpWXScanningAuth,/corpInsideWXAuth,/wx-corp-info/*,/clean/*,/innerRoles/*,/project/getProjectListByToken,/project/getTimeCostByToken,/report/getReportListByToken,/report/getProcessErrorData,/project/synchronizationProject,/user/updateUserDeptHierarchy,/report/getUserTimeCostByThird,/report/getProjectTimeCostByThird,/leave-sheet-fv/*,/report/getNotFullReportUserList
 
 #企业微信相关参数