Bladeren bron

部门条件修改

yusm 1 maand geleden
bovenliggende
commit
23bc76fcb6

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/FinanceMapper.java

@@ -15,5 +15,5 @@ import java.util.List;
  */
 public interface FinanceMapper extends BaseMapper<Finance> {
 
-    List<Finance> selectListByDept(Integer companyId, String yearMonth, Integer deptId);
+    List<Finance> selectListByDept(Integer companyId, String yearMonth, List<Integer> deptIds);
 }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -129,7 +129,7 @@ public interface ReportMapper extends BaseMapper<Report> {
 
     List<Map<String, Object>> getRealProjectTime(@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, Integer companyId);
 
-    List<Map<String, Object>> getRealProjectTimeNew(@Param("ym")String ym,@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, Integer companyId,Integer deptId);
+    List<Map<String, Object>> getRealProjectTimeNew(@Param("ym")String ym,@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, Integer companyId,List<Integer> deptIds);
 
     List<Map<String, Object>> getReportFillStatus(String startDate, String endDate, String userId);
 

+ 22 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java

@@ -94,6 +94,9 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     @Resource
     private FinanceExcludeProjectMapper financeExcludeProjectMapper;
 
+    @Resource
+    private DepartmentService departmentService;
+
     @Resource
     private ProjectMapper projectMapper;
     @Value(value = "${upload.path}")
@@ -103,7 +106,11 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     public HttpRespMsg getByMonth(Integer companyId, String yearMonth,Integer deptId) {
         HttpRespMsg msg = new HttpRespMsg();
 //        List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
-        List<Finance> financeList = financeMapper.selectListByDept(companyId, yearMonth,deptId);
+        //查看当前部门包括子部门的人员
+        List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+        deptId = deptId == null ? -1 : deptId;
+        List<Integer> deptIds = departmentService.getDeptIncludeSubDeptIds(deptId, allDeptList);
+        List<Finance> financeList = financeMapper.selectListByDept(companyId, yearMonth,deptIds);
         TimeType timeType = timeTypeMapper.selectById(companyId);
         //当前月是否有项目日报数据
         List<Map<String, Object>> userList = reportMapper.selectFillReportUserList(companyId, yearMonth+"-01", yearMonth+"-31");
@@ -777,7 +784,10 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
 //            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTime(startDate, endDate, companyId);
             /**添加非分摊项目过滤*/
-            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTimeNew(yearMonth,startDate, endDate, companyId,deptId);
+            List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+            deptId = deptId == null ? -1 : deptId;
+            List<Integer> deptIds = departmentService.getDeptIncludeSubDeptIds(deptId, allDeptList);
+            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTimeNew(yearMonth,startDate, endDate, companyId,deptIds);
             //如果定义了可分摊项目的过滤,按照数据处理一下
             CostProjectSetting setting = costProjectSettingMapper.selectOne(new QueryWrapper<CostProjectSetting>().eq("company_id", companyId));
             if (setting != null && setting.getSettingType() > 0) {
@@ -819,7 +829,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                 }
             }
 //            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
-            List<Finance> finances = financeMapper.selectListByDept(companyId,yearMonth,deptId);
+            List<Finance> finances = financeMapper.selectListByDept(companyId, yearMonth,deptIds);
             List<Finance> noProjectUser = new ArrayList<>();
             //计算无项目的人员
             for (Finance f : finances) {
@@ -2006,7 +2016,10 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
 //            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTime(startDate, endDate, companyId);
             /**添加非分摊项目过滤*/
-            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTimeNew(yearMonth,startDate, endDate, companyId,deptId);
+            List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+            deptId = deptId == null ? -1 : deptId;
+            List<Integer> deptIds = departmentService.getDeptIncludeSubDeptIds(deptId, allDeptList);
+            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTimeNew(yearMonth,startDate, endDate, companyId,deptIds);
             //如果定义了可分摊项目的过滤,按照数据处理一下
             CostProjectSetting setting = costProjectSettingMapper.selectOne(new QueryWrapper<CostProjectSetting>().eq("company_id", companyId));
             if (setting != null && setting.getSettingType() > 0) {
@@ -2046,7 +2059,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                 }
             }
 //            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
-            List<Finance> finances = financeMapper.selectListByDept(companyId,yearMonth,deptId);
+            List<Finance> finances = financeMapper.selectListByDept(companyId, yearMonth,deptIds);
             //未投入项目的人员
             ProjectSumItem noProjectItem = new ProjectSumItem();
             List<Finance> noProjectUser = new ArrayList<>();
@@ -2341,7 +2354,10 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
             //获取月成本列表
 //            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
-            List<Finance> finances = financeMapper.selectListByDept(companyId,yearMonth,deptId);
+            List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+            deptId = deptId == null ? -1 : deptId;
+            List<Integer> deptIds = departmentService.getDeptIncludeSubDeptIds(deptId, allDeptList);
+            List<Finance> finances = financeMapper.selectListByDept(companyId, yearMonth,deptIds);
             for (Finance f : finances) {
                 User user = userList.stream().filter(ul -> ul.getId().equals(f.getUserId())).findFirst().get();
                 BigDecimal cost = f.getTotalCost();

+ 5 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/FinanceMapper.xml

@@ -39,8 +39,11 @@
                 left JOIN user on f.user_id=user.id
                 left JOIN department d on d.department_id=`user`.department_id
         <where>
-            <if test="deptId !=null">
-                and d.department_id=#{deptId}
+            <if test="deptIds !=null and deptIds.size()>0">
+                and d.department_id in
+                <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
             </if>
             <if test="companyId !=null">
                 and f.company_id=#{companyId}

+ 5 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -934,8 +934,11 @@
         <if test="endDate != null">
             AND report.create_date &lt; #{endDate}
         </if>
-        <if test="deptId != null">
-            AND report.dept_id= #{deptId}
+        <if test="deptIds !=null and deptIds.size()>0">
+            and report.dept_id in
+            <foreach collection="deptIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
         </if>
         AND not exists(
         select 1 from finance_exclude_project fep where fep.company_id = report.company_id and fep.use_ym = #{ym} and fep.project_id = report.project_id