Jelajahi Sumber

立项管理bug修改
飞书同步组织架构
依斯呗问题修改

Min 1 tahun lalu
induk
melakukan
73a44d2b94

+ 147 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FeishuInfoController.java

@@ -4,6 +4,7 @@ package com.management.platform.controller;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.JsonObject;
 import com.management.platform.constant.Constant;
@@ -809,5 +810,151 @@ public class FeishuInfoController {
         }
     }
 
+    @RequestMapping("/getFeishuMembsFromPlatform")
+    public HttpRespMsg getFeishuMembsFromPlatform(HttpServletRequest request){
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        FeishuInfo feishuInfo = feishuInfoMapper.selectOne(new LambdaQueryWrapper<FeishuInfo>().eq(FeishuInfo::getCompanyId, companyId));
+        String corpId = feishuInfo.getCorpid();
+        if(feishuInfo==null){
+            msg.setData("飞书配置暂未完成,请联系服务商");
+            return msg;
+        }
+        //获取应用可用范围内的部门
+        Map<String, Object> availableRange = feishuInfoService.getAvailableRange(feishuInfo, null);
+        JSONArray deptArray = (JSONArray) availableRange.get("department_ids");
+        JSONArray departmentInfoArrays=new JSONArray();
+        for (int i = 0; i < deptArray.size(); i++) {
+            String dpId = deptArray.getString(i);
+            JSONArray departmentInfo = feishuInfoService.getDepartmentInfo(feishuInfo, dpId);
+            if(departmentInfo!=null&&departmentInfo.size()>0){
+                departmentInfoArrays.addAll(departmentInfo);
+            }
+            JSONArray subDepartmentList =getSubDepartmentList(feishuInfo,dpId);
+            if(subDepartmentList!=null&&subDepartmentList.size()>0){
+                departmentInfoArrays.addAll(subDepartmentList);
+            }
+        }
+        for (int j = 0; j < departmentInfoArrays.size(); j++) {
+            JSONObject ob = departmentInfoArrays.getJSONObject(j);
+            String departmentName = String.valueOf(ob.get("name"));
+            System.out.println("synchronizationDP========="+departmentName);
+            String departmentId = String.valueOf(ob.getString("department_id"));
+            String openDepartmentId = String.valueOf(ob.getString("open_department_id"));
+            String departmentParentId =String.valueOf(ob.getString("parent_department_id"));
+            Integer cut = departmentFeishuMapper.selectCount(new QueryWrapper<DepartmentFeishu>().eq("corpid",corpId).eq("feishu_deptid",departmentId));
+            if(cut==0&&!departmentId.equals("0")){
+                System.out.println("join===========");
+                DepartmentFeishu departmentFeishu=new DepartmentFeishu();
+                departmentFeishu.setCorpid(corpId)
+                        .setName(departmentName)
+                        .setFeishuParentid(departmentParentId)
+                        .setFeishuDeptid(departmentId)
+                        .setFeishuOpenDeptid(openDepartmentId);
+                Department department = new Department();
+                department.setCompanyId(companyId);
+                department.setDepartmentName(departmentName);
+                department.setFeishuDeptid(openDepartmentId);
+                departmentMapper.insert(department);
+                departmentFeishu.setSysDeptid(department.getDepartmentId());
+                departmentFeishuMapper.insert(departmentFeishu);
+            }
+        }
+        SysRole role = sysRoleMapper.selectOne(new QueryWrapper<SysRole>().eq("company_id", companyId).eq("rolename","普通员工"));
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+        List<DepartmentFeishu> departmentFeishuList = departmentFeishuMapper.selectList(new QueryWrapper<DepartmentFeishu>().eq("corpid", corpId));
+        List<User> userList=new ArrayList<>();
+        for (DepartmentFeishu departmentFeishu : departmentFeishuList) {
+            Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(departmentFeishu.getSysDeptid())).findFirst();
+            //获取到当前部门的上级部门
+            Optional<DepartmentFeishu> wx = departmentFeishuList.stream().filter(dl -> dl.getFeishuOpenDeptid().equals(departmentFeishu.getFeishuParentid())).findFirst();
+            if(first.isPresent()){
+                if(wx.isPresent()){
+                    Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(wx.get().getSysDeptid())).findFirst();
+                    if(dp.isPresent()){
+                        first.get().setSuperiorId(dp.get().getDepartmentId());
+                        departmentMapper.updateById(first.get());
+                    }
+                }
+            }
+            //处理部门下的人员
+            JSONArray userInfoWithDepartment=feishuInfoService.getUserInfoWithDepartment(feishuInfo,departmentFeishu.getFeishuOpenDeptid(),null);
+            for (int m=0;m<userInfoWithDepartment.size(); m++) {
+                JSONObject userJson = userInfoWithDepartment.getJSONObject(m);
+                String curUserid = userJson.getString("user_id");
+                String openUserid = userJson.getString("open_id");
+                if(!userJson.getJSONObject("status").getBoolean("is_activated")){
+                    continue;
+                }
+                List<String> departments = (List<String>) userJson.get("department_ids");
+                System.out.println("user info======:"+userJson.toString());
+                //不存在的人员, 进行插入
+                User user = new User();
+                //在当前部门下的员工
+                user.setId(SnowFlake.nextId()+"")
+                        .setRoleId(role.getId())//默认普通员工
+                        .setRoleName(role.getRolename())
+                        .setCompanyId(companyId)
+                        .setName(userJson.getString("name"))
+                        .setFeishuUserid(openUserid)
+                        .setColor(ColorUtil.randomColor())
+                        .setJobNumber(curUserid)
+                        .setPassword(MD5Util.getPassword("000000"))
+                        .setFeishuDeptid(departmentFeishu.getFeishuDeptid());
+                String max = departments.get(0);
+                Optional<DepartmentFeishu> dpFs = departmentFeishuList.stream().filter(dl -> dl.getFeishuOpenDeptid().equals(max)).findFirst();
+                if(dpFs.isPresent()){
+                    Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(dpFs.get().getSysDeptid())).findFirst();
+                    if(dp.isPresent()){
+                        user.setDepartmentName(dp.get().getDepartmentName());
+                        user.setDepartmentId(dp.get().getDepartmentId());
+                        user.setDepartmentCascade(convertDepartmentIdToCascade(dp.get().getDepartmentId(),departmentList));
+                    }
+                }
+                boolean b = userList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
+                if(!b){
+                    userList.add(user);
+                }
+            }
+        }
+        //获取应用可用范围内的人员
+        JSONArray userArray = (JSONArray) availableRange.get("user_ids");
+        for (int i = 0; i < userArray.size(); i++) {
+            String userId = userArray.getString(i);
+            JSONObject userInfo = feishuInfoService.getUserInfo(feishuInfo, userId);
+            List<String> departments = (List<String>) userInfo.get("department_ids");
+            //不存在的人员, 进行插入
+            User user = new User();
+            //在当前部门下的员工
+            String max = departments.get(0);
+            user.setId(SnowFlake.nextId()+"")
+                    .setRoleId(role.getId())//默认普通员工
+                    .setRoleName(role.getRolename())
+                    .setCompanyId(companyId)
+                    .setName(userInfo.getString("name"))
+                    .setFeishuUserid(userInfo.getString("open_id"))
+                    .setColor(ColorUtil.randomColor())
+                    .setJobNumber(userInfo.getString("user_id"))
+                    .setPassword(MD5Util.getPassword("000000"))
+                    .setFeishuDeptid(max);
+            Optional<DepartmentFeishu> dpFs = departmentFeishuList.stream().filter(dl -> dl.getFeishuDeptid().equals(max)).findFirst();
+            if(dpFs.isPresent()){
+                Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(dpFs.get().getSysDeptid())).findFirst();
+                user.setDepartmentName(dp.get().getDepartmentName());
+                user.setDepartmentId(dp.get().getDepartmentId());
+                user.setDepartmentCascade(convertDepartmentIdToCascade(dp.get().getDepartmentId(),departmentList));
+            }
+            boolean b = userList.stream().anyMatch(ul ->ul.getFeishuUserid()!=null&&ul.getFeishuUserid().equals(user.getFeishuUserid()));
+            if(!b){
+                userList.add(user);
+            }
+        }
+        System.out.println("resutlList========="+userList);
+        if (userList.size()>0) {
+            userService.saveBatch(userList);
+        }
+        return msg;
+    }
+
 }
 

+ 7 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/GroupBudgetReviewController.java

@@ -20,7 +20,9 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
@@ -162,10 +164,13 @@ public class GroupBudgetReviewController {
     public HttpRespMsg list(String startDate,String endDate,Integer projectId,Integer status,String checkUserId){
         HttpRespMsg httpRespMsg=new HttpRespMsg();
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
-
+        DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        DateTimeFormatter df1=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime localDateTimesStart = LocalDate.parse(startDate, df).atTime(LocalTime.MIN);
+        LocalDateTime localDateTimesEnd = LocalDate.parse(endDate, df).atTime(LocalTime.MAX);
         LambdaQueryWrapper<GroupBudgetReview> queryWrapper = new LambdaQueryWrapper<GroupBudgetReview>().eq(GroupBudgetReview::getCompanyId, companyId).orderByDesc(GroupBudgetReview::getCreateTime);
         if(startDate!=null && endDate!=null){
-            queryWrapper.between(GroupBudgetReview::getCreateTime,startDate,endDate);
+            queryWrapper.between(GroupBudgetReview::getCreateTime,localDateTimesStart.format(df1),localDateTimesEnd.format(df1));
         }
         if(projectId!=null){
             queryWrapper.eq(GroupBudgetReview::getProjectId,projectId);

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

@@ -207,7 +207,7 @@ public class ProjectApprovalController {
                                 value.put("text",projectApproval.getIsPublic()==0?"正式项目":"非项目");
                                 break;
                             case "项目经理":
-                                value.put("text",projectApproval.getInchargerName()==null?"":projectApproval.getInchargerName());
+                                value.put("text",projectApproval.getInchargerName()==null?"":("$userName="+projectApproval.getInchargerName()+"$"));
                                 break;
                             case "级别":
                                 value.put("text",arr[projectApproval.getLevel()-1]);

+ 6 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectApprovalServiceImpl.java

@@ -216,8 +216,8 @@ public class ProjectApprovalServiceImpl extends ServiceImpl<ProjectApprovalMappe
                 if (ExcelUtil.isRowEmpty(row)) {
                     continue;
                 }
-                XSSFCell participatorCell = row.getCell(6);
-                XSSFCell inchargerCell = row.getCell(7);
+                XSSFCell participatorCell = row.getCell(5);
+                XSSFCell inchargerCell = row.getCell(6);
 
                 String part = "";
                 String inchargerName = "";
@@ -671,8 +671,10 @@ public class ProjectApprovalServiceImpl extends ServiceImpl<ProjectApprovalMappe
                                 }
                             } else {
                                 switch (exception){
-                                    case 0:throw new Exception("["+split[0]+"]在系统中不存在");
-                                    case 1:throw new Exception("["+split[1]+"]在系统中不存在");
+                                    case 0:
+                                        throw new Exception("["+split[0]+"]在系统中不存在");
+                                    case 1:
+                                        throw new Exception("["+split[1]+"]在系统中不存在");
                                 }
                             }
                         }

+ 16 - 4
fhKeeper/formulahousekeeper/timesheet/src/views/projectApproval/projectApproval.vue

@@ -45,7 +45,7 @@
                         <el-table-column prop="projectName" :label="$t('headerTop.projectName')" min-width="250" sortable="custom">
                         <template slot-scope="scope">
                             <div> 
-                                <el-button type="text" v-if="scope.row.isPublic==0" @click="showProjectApprovalDeatil(scope.row)">{{scope.row.projectName}}</el-button>
+                                <el-button type="text" v-if="user.company.packageProject==1 && (user.company.nonProjectSimple==0 || (user.company.nonProjectSimple==1&&scope.row.isPublic==0))" @click="showProjectApprovalDeatil(scope.row)">{{scope.row.projectName}}</el-button>
                                 <span v-else>{{scope.row.projectName}}</span>
                             </div>
                         </template>
@@ -369,7 +369,7 @@
                             <el-button type="primary" @click="projectApprovalDetailVisible = false" >{{'关闭'}}</el-button>
                         </div>
                     </el-dialog>
-                    <el-dialog :title="$t('other.Batchimportofworkinghours')" v-if="importDialog" :visible.sync="importDialog" customClass="customWidth" width="500px">
+                    <el-dialog :title="'立项导入'" v-if="importDialog" :visible.sync="importDialog" customClass="customWidth" width="500px">
                     <p>1. {{$t('other.download')}}
                     <el-link type="primary" style="margin-left:5px;" :underline="false" :href="'./upload/立项导入模板.xlsx'" :download="'立项导入模板.xlsx'">{{'立项导入模板.xlsx'}}</el-link>
                     </p>
@@ -380,6 +380,11 @@
                     </el-upload>
                     </p>
                     </el-dialog>
+                    <el-dialog append-to-body :title="'立项导入结果'" v-if="showImportResult" :visible.sync="showImportResult" width="40%">
+                            <div >
+                                {{importResultMsg}}
+                            </div>
+                    </el-dialog>
             </div>
         </div>
     </section>
@@ -455,6 +460,10 @@ return {
     importDialog:false,
     approvalLogData:[],
     approvalTypeStr:["提交","编辑","通过","驳回","撤销"],
+    addLoading:false,
+    importingData:false,
+    showImportResult:false,
+    importResultMsg:null
 }
 },
 computed: {},
@@ -672,9 +681,10 @@ methods: {
                 bu: [],
                 manDay:0,
                 fromOutside: 0,
-                status:0
+                status:0,
             }
             this.projectBaseCostData = [];
+            this.addFormUserNames = [];
             this.auseList = [];
             for (var m=0;m<this.baseCostItemList.length; m++) {
                 this.projectBaseCostData.push({baseId: this.baseCostItemList[m].id, baseName:this.baseCostItemList[m].name, baseAmount:0});
@@ -1316,11 +1326,13 @@ methods: {
             this.importingData = false;
             if (res.code == "ok") {
                 //换成弹出框,以免有人等了半天回来啥也没看到
-                this.importResultMsg = "成功导入"+res.data+'立项数据'+(res.msg?res.msg:"");;
+                this.importResultMsg = res.data+'立项数据'+(res.msg?res.msg:"");;
+                this.showImportResult=true
                 this.getList();
                 this.importDialog = false;
             } else {
                 this.importResultMsg = this.$t('export.Importfailure')+":"+res.msg;
+                this.showImportResult=true
             }
         },
         error => {

+ 30 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -125,6 +125,10 @@
                         <el-link type="primary" :underline="false" @click="showCorpDDSyncDialog">{{ $t('synchronizetheaddressbook') }}</el-link>
                     </el-form-item>
 
+                    <el-form-item style="float:right;" v-if="user.feishuUserid != null && permissions.structureImport">
+                        <el-link type="primary" :underline="false" @click="syncFeishu">{{ '同步飞书通讯录' }}</el-link>
+                    </el-form-item>
+
                     <el-form-item style="float:right;" v-if="user.timeType.syncAd==1">
                         <el-link type="primary" :underline="false" @click="syncAd">{{ '同步AD域控通讯录'}}</el-link>
                     </el-form-item>
@@ -2624,6 +2628,32 @@ export default {
         }
       );
     },
+    syncFeishu(){
+      this.http.post(
+            "/feishu-info/getFeishuMembsFromPlatform",
+            {},
+            (res) => {
+              if (res.code == "ok") {
+                this.$message({
+                  message: '同步成功',
+                  type: "success",
+                });
+              } else {
+                this.$message({
+                  message: res.msg,
+                  type: "error",
+                });
+              }
+            },
+            (error) => {
+              this.listLoading = false;
+              this.$message({
+                message: error,
+                type: "error",
+              });
+            }
+          );
+    },
 
     syncAd(){
       this.http.post(