瀏覽代碼

修改企业微信登录, 出差和请假支持泛微OA同步显示

seyason 2 年之前
父節點
當前提交
eb92035641

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/AuthRedirectController.java

@@ -229,6 +229,9 @@ public class AuthRedirectController {
                 new RedirectView(redirecUrl), reqParam);
         reqParam.put("isPrivateCorpWX", 1);
         System.out.println("跳转=="+redirecUrl);
+        if (reqParam.containsKey("errorMsg")) {
+            System.out.println(reqParam.get("errorMsg"));
+        }
         return modelAndView;
     }
 

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/DingDingController.java

@@ -110,6 +110,12 @@ public class DingDingController {
         return null;
     }
 
+    @RequestMapping("/inactiveUserNotInAuthRange")
+    public HttpRespMsg inactiveUserNotInAuthRange(String corpid) {
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.data = dingDingService.inactiveUserNotInAuthRange(corpid);
+        return msg;
+    }
 
     @RequestMapping("/syncCorpMembs")
     public HttpRespMsg syncCorpMembs(String corpid) {

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/DingDingService.java

@@ -48,4 +48,6 @@ public interface DingDingService {
     void userLeaveOrg(String corpId, JSONArray userIdArray, LocalDate leaveDate);
 
     void userAddOrg(String corpId, JSONArray userIdArray);
+
+    String inactiveUserNotInAuthRange(String corpid);
 }

+ 67 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DingDingServiceImpl.java

@@ -445,6 +445,73 @@ public class DingDingServiceImpl implements DingDingService {
         }
     }
 
+    public String inactiveUserNotInAuthRange(String corpid) {
+        CompanyDingding dingding = companyDingdingMapper.selectById(corpid);
+        String accessToken = null;
+        Integer companyId = dingding.getCompanyId();
+        String resultStr = "";
+        try {
+            if (dingding.getExpireTime().isBefore(LocalDateTime.now())) {
+                SysConfig config = sysConfigMapper.selectOne(new QueryWrapper<SysConfig>().eq("param_key", "dingding_suite_ticket"));
+                OapiServiceGetCorpTokenResponse result = getAuthCorpAccessToken(corpid, config.getParamValue());
+                if (result != null) {
+                    if (result.getErrcode() == 0L) {
+                        //返回成功
+                        dingding.setAccessToken(result.getAccessToken());
+                        LocalDateTime time = LocalDateTime.now();
+                        time = time.plusSeconds(result.getExpiresIn());//设置token过期时间
+                        dingding.setExpireTime(time);
+                        companyDingdingMapper.updateById(dingding);
+
+                        accessToken = dingding.getAccessToken();
+                    } else {
+                        System.out.println(result.getBody());
+                    }
+                }
+            } else {
+                accessToken = dingding.getAccessToken();
+            }
+            List<User> allActiveUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active", 1));
+            List<User> errorUserList = new ArrayList<>();
+            for (User user : allActiveUserList) {
+                DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
+                OapiV2UserGetRequest req = new OapiV2UserGetRequest();
+                req.setUserid(user.getDingdingUserid());
+                req.setLanguage("zh_CN");
+                OapiV2UserGetResponse rsp = client.execute(req, accessToken);
+                JSONObject resp = JSONObject.parseObject(rsp.getBody());
+                if (resp.getInteger("errcode") == 0) {
+                    System.out.println("读取正确");
+                } else {
+                    errorUserList.add(user);
+                }
+            }
+            if (errorUserList.size() == 0) {
+                System.out.println("全部正确");
+                resultStr = "全部在授权范围,无需停用";
+            } else {
+                List<User> updateUser = new ArrayList<>();
+                errorUserList.stream().forEach(err->{
+                    System.out.println("无效User:"+err.getName());
+                    User u = new User();
+                    u.setId(err.getId());
+                    u.setIsActive(0);
+                    u.setInductionDate(LocalDate.now());
+                    updateUser.add(u);
+                });
+                if (updateUser.size() > 0) {
+                    userService.updateBatchById(updateUser);
+                }
+                resultStr = "已检测到:" + errorUserList.stream().map(User::getName).collect(Collectors.joining(","))+"不在授权范围,自动处理为停用";
+            }
+
+        } catch (ApiException e) {
+            e.printStackTrace();
+            resultStr = e.getMessage();
+        }
+        return resultStr;
+    }
+
     private void getAuthedDeptsAndUsers(CompanyDingding dingding, String accessToken) {
         try {
             //查找默认角色

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

@@ -107,8 +107,8 @@ configEnv:
   isPrivateDeploy: true
 
 privateDeployURL:
-  pcUrl: http://gspc.sgai.com.cn/#/
-  mobUrl: http://gsmb.sgai.com.cn/#/
+  pcUrl: http://gspc.sgai.com.cn
+  mobUrl: http://gsmb.sgai.com.cn
 
 # 私有化部署的企业自己的corpId
 corpId: ww69287a3380830fb1

+ 12 - 12
fhKeeper/formulahousekeeper/timesheet/src/views/awayOffice/awayOffice.vue

@@ -1,6 +1,6 @@
 <template>
 <section>
-    <div class="sidebars" ref="sidebars" style="width: 200px;display: block;background: #fff" v-if="!isDingding">
+    <div class="sidebars" ref="sidebars" style="width: 200px;display: block;background: #fff" v-if="!isSyncData">
         <h3><i class="iconfont firerock-iconbaoxiao" style="padding-right: 10px"></i>{{ $t('navigation.evectionManagement') }}</h3>
         <el-divider ></el-divider>
         <el-col :span="12">
@@ -16,7 +16,7 @@
                     </template>
                     <!-- 导航切换 -->
                     <el-menu-item index="2-1" v-if="permissions.awayOfficeAll"><p @click="bills(false, 2)">{{ $t('all') }}</p></el-menu-item>
-                    <el-menu-item index="2-2" v-if="permissions.awayOfficeAudit && !isDingding"><p @click="bills(true, 1)">{{ $t('state.WaitingAudit') }}</p></el-menu-item>
+                    <el-menu-item index="2-2" v-if="permissions.awayOfficeAudit && !isSyncData"><p @click="bills(true, 1)">{{ $t('state.WaitingAudit') }}</p></el-menu-item>
                 </el-submenu>
                 <el-menu-item index="3" @click="bills(false, 2)" v-if="!permissions.awayOfficeAll">
                     <i class="iconfont firerock-iconbaoxiaodan"></i>
@@ -153,7 +153,7 @@
             </div>
         </div>
         <!-- 出差列表 -->
-        <div class="tops" v-if="displayTable && apk == 0" :style="isDingding ? 'padding-left:20px' : ''">
+        <div class="tops" v-if="displayTable && apk == 0" :style="isSyncData ? 'padding-left:20px' : ''">
             <div class="ctons">
         <!-- 出差列表筛选 -->
                 <div class="flex">
@@ -237,10 +237,10 @@
                             <span v-if="scope.row.way == 4">{{ $t('leave.other') }}</span>
                         </template>
                     </el-table-column>
-                    <el-table-column :label="$t('trip')" width="120" align="center" v-if="!isDingding">
+                    <el-table-column :label="$t('trip')" width="120" align="center" v-if="!isSyncData">
                         <template slot-scope="scope">{{scope.row.cityFrom + '-' + scope.row.cityTo}}</template>
                     </el-table-column>
-                    <el-table-column prop="indate" :label="$t('applytime')" width="150" align="center" v-if="!isDingding"></el-table-column>
+                    <el-table-column prop="indate" :label="$t('applytime')" width="150" align="center" v-if="!isSyncData"></el-table-column>
                     
                     <el-table-column prop="startDate" :label="$t('starttimeofbusinessrip')" width="150"></el-table-column>
                     <el-table-column prop="endDate" :label="$t('endtimeofbusinesstrip')" width="150"></el-table-column>
@@ -260,7 +260,7 @@
                             <span v-if="scope.row.status == 3" style="color: #666666">{{ $t('btn.undo') }}</span>
                         </template>
                     </el-table-column>
-                    <el-table-column v-if="!isDingding" :label="isAuditList ? $t('other.audit') : $t('operation')" width="180" fixed="right" >
+                    <el-table-column v-if="!isSyncData" :label="isAuditList ? $t('other.audit') : $t('operation')" width="180" fixed="right" >
                         <template slot-scope="scope">
                             <div v-if="isAuditList">
                                 <el-button icon="el-icon-check" circle size="mini" @click="approve(scope.row)"></el-button>
@@ -272,7 +272,7 @@
                             </div>
                         </template>
                     </el-table-column>
-                    <el-table-column v-if="isDingding" :label="$t('operation')" width="150" fixed="right">
+                    <el-table-column v-if="isSyncData" :label="$t('operation')" width="150" fixed="right">
                         <template slot-scope="scope">
                             <el-button icon="iconfont firerock-iconguanlian" circle size="mini" @click="DingdingEditor(scope.row)"></el-button>
                             <el-button v-if="permissions.awayOfficeDelete" icon="el-icon-delete" circle size="mini" @click="deleteOfDingding(scope.row)"></el-button>
@@ -778,7 +778,7 @@ export default {
             susers: [],
 
             // 钉钉环境交互
-            isDingding: 0,
+            isSyncData: 0,
             DingdingEditDialog: false,
             DingdingTableLoading: false,
             appendAddorModDialog: false,
@@ -815,10 +815,10 @@ export default {
         window.onresize = function temp() {
             that.tableHeight = window.innerHeight - 195;
         };
-        this.isDingding = this.wuduData.syncDingding
+        this.isSyncData = (this.wuduData.syncDingding || this.wuduData.syncFanwei)
     },
     mounted(){
-        if(this.isDingding){
+        if(this.isSyncData){
             this.staffs(2,['2'])
         }
         this.getTableList()
@@ -1174,7 +1174,7 @@ export default {
         handleSizeChange(val){
             this.size = val;
             this.page = 1
-            if(this.isDingding){
+            if(this.isSyncData){
                 this.billss()
             }else{
                 this.bills()
@@ -1184,7 +1184,7 @@ export default {
         handleCurrentChange(val) {
             // console.log(val, 1, '1')
             this.page =  val;
-            if(this.isDingding){
+            if(this.isSyncData){
                 this.billss()
             }else{
                 this.bills()

+ 9 - 9
fhKeeper/formulahousekeeper/timesheet/src/views/leave/list.vue

@@ -4,7 +4,7 @@
       <h3><i class="iconfont firerock-iconbaoxiao" style="padding-right: 10px"></i>{{ $t('navigation.askForLeaveManagement') }}</h3>
       <el-divider ></el-divider>
       <el-col :span="12">
-        <el-menu :default-active="isDingding ? '7' : '1'" class="el-menu-vertical-demo" @select="staffs" background-color="#ffffff" text-color="#666666" active-text-color="#20A0FF" style="width:100%">
+        <el-menu :default-active="isSyncData ? '7' : '1'" class="el-menu-vertical-demo" @select="staffs" background-color="#ffffff" text-color="#666666" active-text-color="#20A0FF" style="width:100%">
           <!-- <el-submenu index="1">
             <template slot="title">
               <i class="iconfont firerock-icontianbao"></i>
@@ -15,7 +15,7 @@
               <el-menu-item index="1-3"><p @click="ssl(2)">请年假</p></el-menu-item>
               <el-menu-item index="1-4"><p @click="ssl(3)">请产假</p></el-menu-item>
           </el-submenu> -->
-          <template v-if="!isDingding">
+          <template v-if="!isSyncData">
           <el-menu-item index="1" v-if="permissions.leaveFil">
             <i class="iconfont firerock-icontianbao"></i>
             <span slot="title">{{ $t('staffleavetofillin') }}</span>
@@ -55,7 +55,7 @@
           </template>
 
           <!-- 钉钉环境对接 -->
-          <template v-if="isDingding">
+          <template v-if="isSyncData">
             <el-menu-item index="7">
                 <template slot="title">
                   <i class="iconfont firerock-iconbaoxiaodan"></i>
@@ -80,7 +80,7 @@
       </div> -->
     <!-- 内容主体区域 -->
   <div class="contents">
-    <div v-if="!displayTable && !isDingding" class="headine" ref="headine">
+    <div v-if="!displayTable && !isSyncData" class="headine" ref="headine">
       <h3 ref="headHe" style="padding-left: 220px">{{ $t('aketimeoffto') }}</h3>
       <!-- <p style="float: right;margin-right: 25px;"><el-button type="primary" @click="submits('addFormRules')" size="mini">提交</el-button></p> -->
     </div>
@@ -273,7 +273,7 @@
                     </el-popover>
                   </template>
                 </el-table-column>
-                <el-table-column :label="$t('operation')" min-width="180" fixed="right" v-if="isAuditList && !isDingding">
+                <el-table-column :label="$t('operation')" min-width="180" fixed="right" v-if="isAuditList && !isSyncData">
                     <template slot-scope="scope">
                       <div>
                         <el-button icon="el-icon-check" circle size="mini" @click.stop.native="approve(scope.row)"></el-button>
@@ -281,7 +281,7 @@
                       </div>
                     </template>
                 </el-table-column>
-                <el-table-column :label="$t('operation')" min-width="180" fixed="right" v-if="!isAuditList && !isDingding">
+                <el-table-column :label="$t('operation')" min-width="180" fixed="right" v-if="!isAuditList && !isSyncData">
                     <template slot-scope="scope">
                       <div v-if="(scope.row.status != 0 && scope.row.ownerId == user.id) || permissions.leaveAll">
                         <el-button icon="el-icon-delete" circle size="mini"  @click.stop.native="deletes(scope.row)" ></el-button>
@@ -855,7 +855,7 @@ export default {
       txselnum: 0,
 
       approverList: [],
-      isDingding: 0,
+      isSyncData: 0,
       vacationList: [],
       leaveTypeList: [],
       leaveTypeItem: '',
@@ -883,11 +883,11 @@ export default {
                 that.tableHeight = window.innerHeight - 195;
             };
     // console.log('user',this.user);
-    this.isDingding = this.user.timeType.syncDingding
+    this.isSyncData = this.user.timeType.syncDingding || this.user.timeType.syncFanwei;
   },
 
   mounted() {
-    if(this.isDingding){
+    if(this.isSyncData){
       this.bills(false,2)
       this.staffs(7,['7'])
       this.getUsers()