Ver código fonte

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper into master

seyason 2 anos atrás
pai
commit
ec230c8223

+ 7 - 0
fhKeeper/formulahousekeeper/management-platform/pom.xml

@@ -185,6 +185,13 @@
             <version>0.1.55</version>
         </dependency>
 
+        <!--ladp集成 AD域认证-->
+        <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-data-ldap</artifactId>
+        <version>2.3.12.RELEASE</version>
+        </dependency>
+
         <dependency>
             <groupId>com.aliyun</groupId>
             <artifactId>dysmsapi20170525</artifactId>

+ 40 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/config/LdapConfig.java

@@ -0,0 +1,40 @@
+package com.management.platform.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.ldap.core.support.LdapContextSource;
+
+@Configuration
+public class LdapConfig {
+    @Value("${spring.ldap.urls}")
+    private String ldapUrl;
+    @Value("${spring.ldap.username}")
+    private String userName;
+    @Value("${spring.ldap.password}")
+    private String passWord;
+    @Value("${spring.ldap.base}")
+    private String base;
+
+
+
+    @Bean
+    public LdapContextSource ldapContextSource(){
+        LdapContextSource source = new LdapContextSource();
+        source.setBase(base);
+        source.setUrl(ldapUrl);
+        source.setPassword(passWord);
+        source.setUserDn(userName);
+        source.setReferral("follow");
+        return source;
+    }
+
+    @Bean
+    public LdapTemplate ldapTemplate(){
+        return new LdapTemplate(ldapContextSource());
+    }
+
+
+}
+

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserController.java

@@ -10,7 +10,10 @@ import com.management.platform.service.FeishuInfoService;
 import com.management.platform.service.UserService;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.ldap.filter.EqualsFilter;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
@@ -39,6 +42,9 @@ public class UserController {
     @Resource
     private HttpServletRequest request;
 
+    @Resource
+    private LdapTemplate ldapTemplate;
+
     @Resource
     private FeishuInfoService feishuInfoService;
 
@@ -300,5 +306,15 @@ public class UserController {
         return httpRespMsg;
     }
 
+
+    @RequestMapping(value = "/testLdap4", method = RequestMethod.GET)
+    public HttpRespMsg testLdap4(@RequestParam String username, @RequestParam String passWord) {
+        EqualsFilter filter = new EqualsFilter("sAMAccountName", username);
+        boolean res =  ldapTemplate.authenticate("",filter.toString(), passWord);
+        HttpRespMsg httpRespMsg=new HttpRespMsg();
+        httpRespMsg.setMsg(res==true?"验证成功":"验证失败");
+        return httpRespMsg;
+    }
+
 }
 

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/User.java

@@ -65,6 +65,7 @@ public class User extends Model<User> {
      */
     @TableField("create_time")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
     private LocalDateTime createTime;
 
     /**

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

@@ -90,4 +90,6 @@ public interface UserService extends IService<User> {
     ModelAndView loginByWXCode(String code, String state);
 
     HttpRespMsg areaData(String token);
+
+    boolean ldapAuth(String username, String passWord);
 }

+ 11 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -63,6 +63,7 @@ import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 
 /**
@@ -10032,7 +10033,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         int days = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, 0).size();
         TimeType allDay = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", targetUser.getCompanyId()));
         Float monthTime = days * allDay.getAllday();
-
         if(pageIndex!=null&&pageSize!=null){
             Integer size=pageSize;
             Integer start=(pageIndex-1)*size;
@@ -10042,7 +10042,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             resultList=projectMapper.getFTEData(targetUser.getCompanyId(),startDate,endDate,null,null,area,branchDepartment,deptIds);
         }
         for (Map<String, Object> map : resultList) {
-            map.put("FTE",Float.parseFloat(map.get("workTime").toString())/monthTime);
+            map.put("FTE",Float.parseFloat(map.get("workTime") == null?"0":map.get("workTime").toString())/monthTime);
         }
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", targetUser.getCompanyId()));
         if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
@@ -10100,6 +10100,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         Float aTimeSum = 0.0F;
         Float aFteSum = 0.0F;
         for (int i = 0; i < resultList.size(); i++) {
+            if(resultList.get(i).get("workTime") == null){
+                resultList.get(i).put("workTime",0);
+            }
+            if(resultList.get(i).get("projectName") == null){
+                resultList.get(i).put("projectName","");
+            }
+            if(resultList.get(i).get("projectCode") == null){
+                resultList.get(i).put("projectCode","");
+            }
             if (!resultList.get(i).containsKey("area")){
                 resultList.get(i).put("area","无");
             }else if(org.apache.commons.lang3.StringUtils.isBlank(resultList.get(i).get("area").toString())){

+ 11 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -32,6 +32,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.*;
+import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.ldap.filter.EqualsFilter;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.web.client.RestTemplate;
@@ -187,6 +189,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     @Resource
     private ParticipationService participationService;
 
+    @Resource
+    private LdapTemplate ldapTemplate;
+
     public static String provider_access_token = null;
     public static long providerTokenExpireTime = 0L;
     //登录网页端
@@ -2902,4 +2907,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         httpRespMsg.data = areas;
         return httpRespMsg;
     }
+
+    @Override
+    public boolean ldapAuth(String username, String passWord) {
+        EqualsFilter filter = new EqualsFilter("sAMAccountName",username);
+        return ldapTemplate.authenticate("",filter.toString(),passWord);
+    }
 }

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

@@ -50,6 +50,17 @@ spring:
   messages:
     basename: i18n.messages #配置国际化资源文件路径
     encoding: UTF-8
+
+  ##AD认证
+  ldap:
+    ##AD服务器IP,默认端口389
+    urls: ldap://192.168.2.18:389
+    ##登录账号
+    username: huliangpeng@huoshi.cn
+    ##密码
+    password: Hlp123456
+    #distinguishedName的部分节点
+    base: DC=huoshi,DC=cn
 ##########日志配置
 logging:
   level:
@@ -118,6 +129,8 @@ management:
   health:
     redis:
       enabled: false
+    ldap:
+      enabled: false
 
 referer:
   refererDomain:

+ 16 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -1612,16 +1612,23 @@
     </select>
 
     <select id="getFTEData" resultType="java.util.Map">
-        SELECT u.id,u.name userName,u.corpwx_userid wxUserId,u.plate1 area,SUM(r.working_time) workTime,p.project_name projectName,p.project_code projectCode
+        SELECT u.id,u.name userName,u.corpwx_userid wxUserId,u.plate1 area,r.projectName,r.projectCode,r.workTime
         FROM `user` u
-        LEFT JOIN report r
+        LEFT JOIN (
+            SELECT p.project_name projectName,p.project_code projectCode,report.working_time,report.creator_id,SUM(working_time) workTime
+            FROM report
+            LEFT JOIN project p
+            ON report.project_id = p.id
+            LEFT JOIN `user`
+            ON user.id = report.creator_id
+            WHERE report.state = 1
+            AND p.is_public = 0
+            AND report.company_id=#{companyId}
+            AND report.create_date BETWEEN #{startDate} AND #{endDate}
+            GROUP BY user.id,p.id,user.plate1,p.project_name,p.project_code
+        ) r
         ON u.id = r.creator_id
-        LEFT JOIN project p
-        ON r.project_id = p.id
-        WHERE r.state = 1
-        AND p.is_public = 0
-        AND u.company_id=#{companyId}
-        AND r.create_date BETWEEN #{startDate} AND #{endDate}
+        WHERE u.company_id=#{companyId}
         <if test="area!=null and area != '' ">
             and u.plate1 = #{area}
         </if>
@@ -1637,8 +1644,7 @@
                 #{item}
             </foreach>
         </if>
-        GROUP BY u.id,p.id,u.plate1,p.project_name,u.name,u.corpwx_userid,p.project_code
-        order by area,id
+        order by area,workTime,id
         <if test="start!=null and size!=null">
             limit #{start},#{size}
         </if>

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -1383,7 +1383,7 @@
           <!-- </div> -->
         </el-tab-pane>
 
-        <el-tab-pane :label="$t('other.unfilledPersonList')" name="second" >
+        <el-tab-pane label="未提交人员列表" name="second" >
           <div class="selectworktime_export" style="margin-top:10px">
             <div class="selectworktime_export_l">
               <el-date-picker

+ 3 - 0
fhKeeper/formulahousekeeper/timesheet_h5/public/index.html

@@ -18,6 +18,9 @@
     <!-- 引入企业微信js -->
     <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js" referrerpolicy="origin"></script>
     <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js" referrerpolicy="origin"></script>
+    <!-- 接入飞书 -->
+    <script type="text/javascript" src="https://lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.16.js"></script>
+    <!-- <script src="https://s.url.cn/qqun/qun/qqweb/m/qun/confession/js/vconsole.min.js "></script> -->
 
     <meta name="wpk-bid" content="dta_2_71020">
         <script>

+ 63 - 23
fhKeeper/formulahousekeeper/timesheet_h5/src/views/login/index.vue

@@ -217,6 +217,23 @@
                         this.$toast.fail(res.msg);
                     }
                 }).catch(err=> {this.$toast.clear();});
+            },
+            // 飞书登录
+            flyingBook(appid, code) {
+                this.$axios.post('/feishu-info/loginByFeishu', {appId: appid,code: code})
+                .then(res => {
+                    if(res.code == "ok") {
+                        let user = res.data;
+                        this.$store.commit("updateLogin", true);
+                        localStorage.userInfo = JSON.stringify(user);
+                        
+                        this.$router.push("/index").catch(err => { console.log(err, '错误3')});
+                        //强制刷新,避免index页面中的mounted不执行
+                        // window.location.reload();
+                    } else {
+                        this.$toast.fail(res.msg);
+                    }
+                }).catch(err=> {this.$toast.clear();});
             }
         },
         created() {
@@ -274,33 +291,56 @@
                         
                     } else {
                         //检查环境,如果是钉钉有$CORPID$
-                        
-                        var key = '?corpid=';
-                        var jumpkey = '&jumpto=';
-                        var url = location.href;
-                        var that = this;
-                        if (url.indexOf(key) > 0) {
-                            var corpId = ''
-                            if(url.indexOf(jumpkey) > 0){
-                                corpId = url.substring(url.indexOf(key)+key.length,url.indexOf(jumpkey));
-                            }else{
-                                corpId = url.substring(url.indexOf(key)+key.length,url.indexOf('#'));
+                        if(href.indexOf("corpid") > 0) {
+                            var key = '?corpid=';
+                            var jumpkey = '&jumpto=';
+                            var url = location.href;
+                            var that = this;
+                            if (url.indexOf(key) > 0) {
+                                var corpId = ''
+                                if(url.indexOf(jumpkey) > 0){
+                                    corpId = url.substring(url.indexOf(key)+key.length,url.indexOf(jumpkey));
+                                }else{
+                                    corpId = url.substring(url.indexOf(key)+key.length,url.indexOf('#'));
+                                }
+                                alert('钉钉登录==='+corpId);
+                                this.isDingding = true
+                                dd.ready(function() {
+                                    dd.runtime.permission.requestAuthCode({
+                                        corpId: corpId, // 企业id
+                                        onSuccess: function (info) {
+                                            var code = info.code // 通过该免登授权码可以获取用户身份
+                                            that.loginByCode(code, corpId);
+                                        }});
+                                });
+                            } 
+                        } else {
+                            // 飞书登陆
+                            if(href.indexOf("appId") > 0) {
+                                console.log('执行到这里---飞书')
+                                let arr = href.split('appId=')[1]
+                                let str = arr.split('#')[0]
+                                console.log(str, window)
+                                window.h5sdk.ready(() => { // ready方法不需要每次都调用
+                                    tt.requestAuthCode({
+                                    appId: str,
+                                    success: (info) => {
+                                        console.info(info.code, '飞书 code')
+                                        this.flyingBook(str, info.code)
+                                    },
+                                    fail: (error) => {
+                                        console.error(error)
+                                    }
+                                    });
+                                });
                             }
-                            alert('钉钉登录==='+corpId);
-                            this.isDingding = true
-                            dd.ready(function() {
-                                dd.runtime.permission.requestAuthCode({
-                                    corpId: corpId, // 企业id
-                                    onSuccess: function (info) {
-                                        var code = info.code // 通过该免登授权码可以获取用户身份
-                                        that.loginByCode(code, corpId);
-                                    }});
-                            });
-                        } 
+
+                        }
+
                     }
                 }
             }
-        }
+        },
     };
 </script>