cs 2 anni fa
parent
commit
fb8fdc9581

+ 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, Integer projectId,String degreeId, List<Integer> deptIds, List<Integer> filterDeptIds, List<Integer> deptRelatedProjectIds);
+    List<Map<String, Object>> getDegreeDetailCost(Integer companyId, String startDate, String endDate, Integer projectId,int curProjectId, List<Integer> finalDeptIds, List<Integer> filterDeptIds, List<Integer> deptIds);
 }

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

@@ -9121,7 +9121,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             //headList.add("人员");
             headList.add(MessageUtils.message("entry.personnel"));
             //headList.add("部门");
-            headList.add(MessageUtils.message("excel.department"));
+//            headList.add(MessageUtils.message("excel.department"));
             headList.add(timeType.getCustomDegreeName());
             if(functionTimeList.size()>0){
                 //headList.add("工时(h)");
@@ -9147,12 +9147,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 }
                 totalCostTime += (Double)map.get("cost");
                 List<String> rowData = new ArrayList<String>();
+                rowData.add(map.get("projectCode")==null?"":map.get("projectCode").toString());
+                rowData.add(map.get("projectName")==null?"":map.get("projectName").toString());
+                rowData.add(map.get("categoryName")==null?"":map.get("categoryName").toString());
                 rowData.add("");
                 rowData.add("");
-                rowData.add("");
-                rowData.add("");
-                rowData.add("");
-                rowData.add(map.get("name")==null?"未分配":(String)map.get("name"));
+//                rowData.add("");
 
                 if(functionTimeList.size()>0){
                     rowData.add(((Double)map.get("cost")).toString());
@@ -9161,29 +9161,35 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     rowData.add(((BigDecimal)map.get("costMoney")).toString());
                 }
                 allList.add(rowData);
-                String degreeId = null;
-                if (map.containsKey("id")){
-                    degreeId = map.get("id").toString();
+
+                //统计每个项目中的人员时间成本投入
+                int curProjectId = (Integer)map.get("id");
+                //判断是否是当前项目的所属部门的主要或者其他负责人
+                List<Integer> finalDeptIds = null;
+                if (deptRelatedProjectIds.contains(curProjectId)) {
+                    //有权限看该项目的全部参与人员,不需要按照部门过滤了
+                } else {
+                    finalDeptIds = deptIds;
                 }
-                List<Map<String, Object>> membList = projectMapper.getDegreeDetailCost(companyId,startDate, endDate,projectId,degreeId,deptIds,filterDeptIds,deptRelatedProjectIds);
+                List<Map<String, Object>> membList = projectMapper.getDegreeDetailCost(companyId,startDate, endDate,projectId,curProjectId,finalDeptIds,filterDeptIds,deptIds);
                 map.put("membList", membList);
                 for (Map<String, Object> membMap : membList) {
                     List<String> membRowData = new ArrayList<String>();
-                    membRowData.add(membMap.get("projectCode")==null?"":membMap.get("projectCode").toString());
-                    membRowData.add(membMap.get("projectName")==null?"":membMap.get("projectName").toString());
-                    membRowData.add(membMap.get("categoryName")==null?"":membMap.get("categoryName").toString());
+                    membRowData.add("");
+                    membRowData.add("");
+                    membRowData.add("");
                     if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
                         membRowData.add(("$userName="+membMap.get("corpwxUserId")+"$"));
-                        if(membMap.get("departmentName").equals("未分配")){
-                            membRowData.add("未分配");
-                        }else {
-                            membRowData.add((String)("$departmentName="+membMap.get("corpwxDeptId")+"$"));
-                        }
+//                        if(membMap.get("departmentName").equals("未分配")){
+//                            membRowData.add("未分配");
+//                        }else {
+//                            membRowData.add((String)("$departmentName="+membMap.get("corpwxDeptId")+"$"));
+//                        }
                     }else {
                         membRowData.add((String)membMap.get("name"));
-                        membRowData.add((String)membMap.get("departmentName"));
+//                        membRowData.add((String)membMap.get("departmentName"));
                     }
-                    membRowData.add("");
+                    membRowData.add(membMap.get("degreeName")==null?"未分配":(String)membMap.get("degreeName"));
                     if(functionTimeList.size()>0){
                         membRowData.add(((Double)membMap.get("cost")).toString());
                     }
@@ -9197,7 +9203,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             sumRow=new ArrayList<>();
             //sumRow.add("合计");
             sumRow.add(MessageUtils.message("entry.total"));
-            sumRow.add("");
+            //sumRow.add("");
             sumRow.add("");
             sumRow.add("");
             sumRow.add("");

+ 24 - 35
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -1486,33 +1486,34 @@
         </if>
     </select>
 
-    <!--获取按维度分组的工时成本-->
+    <!--获取按项目分组的工时成本-->
     <select id="getExportDegreeCost" resultType="java.util.Map">
-        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}
+        SELECT a.id, a.project_code as projectCode, a.project_name AS projectName, SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney,a.category_name as categoryName
+        FROM project AS a
+        LEFT JOIN report AS b ON b.project_id = a.id
+        JOIN user AS c ON b.creator_id = c.id
+        WHERE a.company_id = #{companyId}
         <if test="projectId != null">
-            AND report.project_id = #{projectId}
+            AND a.id = #{projectId}
         </if>
         <if test="startDate != null and endDate != null">
-            AND report.create_date between #{startDate} and #{endDate}
+            AND b.create_date between #{startDate} and #{endDate}
         </if>
         <choose>
             <when test="filterDeptIds!=null and filterDeptIds.size()>0">
-                and report.dept_id in
+                and b.dept_id in
                 <foreach collection="filterDeptIds" open="(" item="item" separator="," close=")">
                     #{item}
                 </foreach>
             </when>
             <otherwise>
                 <if test="deptIds!=null and deptIds.size()>0">
-                    and (report.dept_id in
+                    and (b.dept_id in
                     <foreach collection="deptIds" open="(" item="item" separator="," close=")">
                         #{item}
                     </foreach>
                     <if test="deptRelatedProjectIds.size() > 0">
-                        or report.project_id in
+                        or a.id in
                         <foreach collection="deptRelatedProjectIds" open="(" item="pid" separator="," close=")">
                             #{pid}
                         </foreach>
@@ -1521,29 +1522,24 @@
                 </if>
             </otherwise>
         </choose>
-        AND report.state = 1
-        GROUP BY report.degree_id,r.name
-        ORDER BY report.degree_id
+        AND b.state = 1
+        GROUP BY a.id
+        ORDER BY a.id ASC
     </select>
 
-    <!--获取某个维度每个人分别需要的工时-->
+    <!--获取某个项目每个维度分别需要的工时-->
     <select id="getDegreeDetailCost" resultType="java.util.Map">
-        SELECT b.id as creatorId,a.project_id as projectId, b.name,b.corpwx_userid as corpwxUserId,a.dept_id as deptId,department.corpwx_deptid as corpwxDeptId, IFNULL(department.department_name, '未分配') as departmentName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney,
-        p.project_name as projectName,p.project_code as projectCode,p.category_name as categoryName
+        SELECT b.id as creatorId,a.project_id as projectId, b.name,b.corpwx_userid as corpwxUserId,a.dept_id as deptId,department.corpwx_deptid as corpwxDeptId, IFNULL(department.department_name, '未分配') as departmentName, SUM(a.working_time) AS cost, SUM(a.cost) AS costMoney,r.name as degreeName
         FROM report AS a
         JOIN user AS b ON a.creator_id = b.id
-        left JOIN project AS P on a.project_id = p.id
         left join department on department.department_id = a.dept_id
+        left join report_extra_degree as r on a.degree_id = r.id
         WHERE a.company_id=#{companyId}
-        and a.state = 1
-        <if test="projectId != null">
-            AND a.project_id = #{projectId}
+        <if test="curProjectId != null">
+            and a.project_id = #{curProjectId}
         </if>
-        <if test="degreeId != null">
-            and a.degree_id = #{degreeId}
-        </if>
-        <if test="degreeId == null">
-            and a.degree_id is null
+        <if test="projectId != null">
+            and a.project_id = #{projectId}
         </if>
         <if test="startDate != null and endDate != null">
             AND a.create_date between #{startDate} and #{endDate}
@@ -1557,21 +1553,14 @@
             </when>
             <otherwise>
                 <if test="deptIds!=null and deptIds.size()>0">
-                    and (report.dept_id in
+                    and a.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 a.project_id,a.creator_id,a.degree_id
-        ORDER BY b.id ASC, a.dept_id ASC
+        GROUP BY a.project_id,b.id,a.degree_id
+        ORDER BY b.id,a.degree_id ASC
     </select>
 </mapper>