cs 2 rokov pred
rodič
commit
f05a97542f

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

@@ -150,5 +150,5 @@ public interface ProjectMapper extends BaseMapper<Project> {
 
     List<Map<String, Object>> getExportDegreeCost(Integer companyId, String startDate, String endDate,Integer projectId, List<Integer> deptIds, List<Integer> filterDeptIds, List<Integer> deptRelatedProjectIds);
 
-    List<Map<String, Object>> getDegreeDetailCost(Integer companyId, String startDate, String endDate,String degreeId,List<Integer> filterDeptIds);
+    List<Map<String, Object>> getDegreeDetailCost(Integer companyId, String startDate, String endDate, String degreeId, List<Integer> deptIds, List<Integer> filterDeptIds, List<Integer> deptRelatedProjectIds);
 }

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

@@ -9109,7 +9109,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             //deptIds:管理的部门;filterDeptIds:筛选的部门;deptRelatedProjectIds:负责部门相关联的项目
             List<Map<String, Object>> list = projectMapper.getExportDegreeCost(companyId, startDate, endDate,projectId,deptIds,filterDeptIds,deptRelatedProjectIds);
             TimeType timeType = timeTypeMapper.selectById(companyId);
-            BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             List<List<String>> allList=null ;
             List<String> sumRow = null;
             List<String> headList = new ArrayList<String>();
@@ -9135,6 +9134,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
             allList=new ArrayList<>();
             allList.add(headList);
+            BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             double totalCostTime = 0;
             for (Map<String, Object> map : list) {
                 if (!map.containsKey("cost")) {
@@ -9165,7 +9165,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 if (map.containsKey("id")){
                     degreeId = map.get("id").toString();
                 }
-                List<Map<String, Object>> membList = projectMapper.getDegreeDetailCost(companyId,startDate, endDate,degreeId,filterDeptIds);
+                List<Map<String, Object>> membList = projectMapper.getDegreeDetailCost(companyId,startDate, endDate,degreeId,deptIds,filterDeptIds,deptRelatedProjectIds);
                 map.put("membList", membList);
                 for (Map<String, Object> membMap : membList) {
                     List<String> membRowData = new ArrayList<String>();

+ 27 - 14
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -1488,33 +1488,31 @@
 
     <!--获取按维度分组的工时成本-->
     <select id="getExportDegreeCost" resultType="java.util.Map">
-        SELECT r.name as name,r.id as id,SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney
-        FROM project AS a
-        LEFT JOIN report AS b ON b.project_id = a.id
-        LEFT JOIN report_extra_degree AS r ON b.degree_id = r.id
-        JOIN user AS c ON b.creator_id = c.id
-        WHERE a.company_id = #{companyId}
+        SELECT r.name as name,report.degree_id as id,SUM(report.working_time) AS cost, SUM(report.cost) AS costMoney
+        FROM report
+        LEFT JOIN report_extra_degree AS r ON report.degree_id = r.id
+        WHERE report.company_id = #{companyId}
         <if test="projectId != null">
-            AND a.id = #{projectId}
+            AND report.project_id = #{projectId}
         </if>
         <if test="startDate != null and endDate != null">
-            AND b.create_date between #{startDate} and #{endDate}
+            AND report.create_date between #{startDate} and #{endDate}
         </if>
         <choose>
             <when test="filterDeptIds!=null and filterDeptIds.size()>0">
-                and b.dept_id in
+                and report.dept_id in
                 <foreach collection="filterDeptIds" open="(" item="item" separator="," close=")">
                     #{item}
                 </foreach>
             </when>
             <otherwise>
                 <if test="deptIds!=null and deptIds.size()>0">
-                    and (b.dept_id in
+                    and (report.dept_id in
                     <foreach collection="deptIds" open="(" item="item" separator="," close=")">
                         #{item}
                     </foreach>
                     <if test="deptRelatedProjectIds.size() > 0">
-                        or a.id in
+                        or report.project_id in
                         <foreach collection="deptRelatedProjectIds" open="(" item="pid" separator="," close=")">
                             #{pid}
                         </foreach>
@@ -1523,9 +1521,9 @@
                 </if>
             </otherwise>
         </choose>
-        AND b.state = 1
-        GROUP BY b.degree_id
-        ORDER BY b.degree_id
+        AND report.state = 1
+        GROUP BY report.degree_id,r.name
+        ORDER BY report.degree_id
     </select>
 
     <!--获取某个维度每个人分别需要的工时-->
@@ -1551,6 +1549,21 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                <if test="deptIds!=null and deptIds.size()>0">
+                    and (report.dept_id in
+                    <foreach collection="deptIds" open="(" item="item" separator="," close=")">
+                        #{item}
+                    </foreach>
+                    <if test="deptRelatedProjectIds.size() > 0">
+                        or report.project_id in
+                        <foreach collection="deptRelatedProjectIds" open="(" item="pid" separator="," close=")">
+                            #{pid}
+                        </foreach>
+                    </if>
+                    )
+                </if>
+            </otherwise>
         </choose>
         GROUP BY b.id, a.dept_id, a.degree_id
         ORDER BY b.id ASC, a.dept_id ASC