Parcourir la source

update:企微进线统计部门多选

ct il y a 1 semaine
Parent
commit
86dfa84b10

+ 2 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyDeptMapper.java

@@ -118,4 +118,6 @@ public interface CompanyDeptMapper
     CompanyDept selectDeptNameBydeptName(@Param("deptName") String deptName);
 
     void deleteCompanyDeptByCompanyIds(Long[] companyIds);
+
+    List<CompanyDept> selectCompanyDeptByIds(@Param("depts")List<Long> deptIds);
 }

+ 1 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseWatchLogListParam.java

@@ -103,5 +103,6 @@ public class FsCourseWatchLogListParam implements Serializable {
      */
     private String qwUserName;
     private Long deptId;
+    private List<Long> deptIds;
     private String ids;
 }

+ 14 - 2
fs-service/src/main/java/com/fs/qw/mapper/QwWatchLogMapper.java

@@ -93,7 +93,13 @@ public interface QwWatchLogMapper extends BaseMapper<QwWatchLog>{
             "<if test ='nickName !=null and nickName!=\"\"'>\n" +
             "   and qu.qw_user_name like concat( #{nickName}, '%')\n" +
             "</if>" +
-            "<if test ='deptId !=null and deptId!=\"\"'>\n" +
+            "<if test ='deptIds !=null and deptIds.size > 0'>\n" +
+            "and cu.dept_id in" +
+            "<foreach collection=\"deptIds\" item=\"deptId\" index=\"index\"  separator=\",\" open=\"(\" close=\")\">\n" +
+            "     #{deptId}\n" +
+            "</foreach>" +
+            "</if>" +
+            "<if test ='(deptIds ==null or deptIds.size = 0) and deptId !=null and deptId!=\"\"'>\n" +
             "   and cu.dept_id = #{deptId}\n" +
             "</if>" +
             "<if test ='ids !=null and ids!=\"\"'>\n" +
@@ -176,7 +182,13 @@ public interface QwWatchLogMapper extends BaseMapper<QwWatchLog>{
             "<if test ='nickName !=null and nickName!=\"\"'>\n" +
             "   and qu.qw_user_name like concat( #{nickName}, '%')\n" +
             "</if>" +
-            "<if test ='deptId !=null and deptId!=\"\"'>\n" +
+            "<if test ='deptIds !=null and deptIds.size > 0'>\n" +
+            "and cu.dept_id in" +
+            "<foreach collection=\"deptIds\" item=\"deptId\" index=\"index\"  separator=\",\" open=\"(\" close=\")\">\n" +
+            "     #{deptId}\n" +
+            "</foreach>" +
+            "</if>" +
+            "<if test ='(deptIds == null or deptIds.size == 0) and deptId !=null and deptId!=\"\"'>\n" +
             "   and cu.dept_id = #{deptId}\n" +
             "</if>" +
             "<if test ='ids !=null and ids!=\"\"'>\n" +

+ 1 - 0
fs-service/src/main/java/com/fs/qw/param/QwWatchLogStatisticsListParam.java

@@ -36,6 +36,7 @@ public class QwWatchLogStatisticsListParam {
     private Long courseId;
     private Long videoId;
     private Long deptId;
+    private List<Long> deptIds; //多选
 
     private Long pageNum;
     private Long pageSize;

+ 36 - 6
fs-service/src/main/java/com/fs/qw/service/impl/QwWatchLogServiceImpl.java

@@ -148,10 +148,26 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
 
     @Override
     public List<QwWatchLogStatisticsListVO> selectQwWatchLogStatisticsListVOExport(FsCourseWatchLogListParam param) {
-        CompanyDept companyDept = companyDeptMapper.selectCompanyDeptById(param.getDeptId());
-        if (ObjectUtils.isNotEmpty(companyDept)&&companyDept.getParentId()==0L){
-            param.setDeptId(null);
+        List<Long> deptIds = param.getDeptIds();
+        if (deptIds !=null && !deptIds.isEmpty()){
+            List<CompanyDept> companyDeptList  = companyDeptMapper.selectCompanyDeptByIds(deptIds);
+            if (companyDeptList!=null && !companyDeptList.isEmpty()){
+                for (CompanyDept c : companyDeptList) {
+                    if (c.getParentId() == 0L) {
+                        param.setDeptId(null);
+                        param.setDeptIds(null);
+                        break;
+                    }
+                }
+            }
+        } else {
+            CompanyDept companyDept = companyDeptMapper.selectCompanyDeptById(param.getDeptId());
+            if (ObjectUtils.isNotEmpty(companyDept)&&companyDept.getParentId()==0L){
+                param.setDeptId(null);
+            }
         }
+
+
         if (param.getCompanyUserId()!=null){
             param.setIds(companyUserMapper.selectQwUserIdsByCompany(param.getCompanyUserId()));
         }
@@ -170,9 +186,23 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
 
     @Override
     public TableDataInfo selectQwWatchLogStatisticsListVO(QwWatchLogStatisticsListParam param) {
-        CompanyDept companyDept = companyDeptMapper.selectCompanyDeptById(param.getDeptId());
-        if (ObjectUtils.isNotEmpty(companyDept)&&companyDept.getParentId()==0L){
-            param.setDeptId(null);
+        List<Long> deptIds = param.getDeptIds();
+        if (deptIds !=null && !deptIds.isEmpty()){
+            List<CompanyDept> companyDeptList  = companyDeptMapper.selectCompanyDeptByIds(deptIds);
+            if (companyDeptList!=null && !companyDeptList.isEmpty()){
+                for (CompanyDept c : companyDeptList) {
+                    if (c.getParentId() == 0L) {
+                        param.setDeptId(null);
+                        param.setDeptIds(null);
+                        break;
+                    }
+                }
+            }
+        } else {
+            CompanyDept companyDept = companyDeptMapper.selectCompanyDeptById(param.getDeptId());
+            if (ObjectUtils.isNotEmpty(companyDept)&&companyDept.getParentId()==0L){
+                param.setDeptId(null);
+            }
         }
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(HttpStatus.SUCCESS);

+ 8 - 0
fs-service/src/main/resources/mapper/company/CompanyDeptMapper.xml

@@ -170,5 +170,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectChildrenDeptById" parameterType="Long" resultMap="CompanyDeptResult">
         select * from company_dept where find_in_set(#{deptId}, ancestors)
     </select>
+    <select id="selectCompanyDeptByIds" resultType="com.fs.company.domain.CompanyDept">
+        <include refid="selectCompanyDeptVo"/>
+        where dept_id in
+        <foreach collection="depts" item="deptId" index="index"
+                 separator="," open="(" close=")">
+            #{deptId}
+        </foreach>
+    </select>
 
 </mapper>