Explorar el Código

项目阶段工时表修改

yurk hace 2 años
padre
commit
bec3092239

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

@@ -8,4 +8,5 @@ public class StageCost {
     public Double cost;
     public Double workingTime;
     public float stagesTime;
+    public Integer projectId;
 }

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.management.platform.entity.Project;
 import com.management.platform.entity.vo.CustomerProject;
 import com.management.platform.entity.vo.ProjectWithStage;
+import com.management.platform.entity.vo.StageCost;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
 
@@ -68,7 +69,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<Map> getTaskPlanByProject(@Param("projectIds") List<Integer> projectIds, @Param("startDate") String startDate,
                                 @Param("endDate") String endDate, @Param("companyId") Integer companyId);
 
-    List<ProjectWithStage> selectWithStage(Integer companyId, Integer startIndex, Integer endIndex, Integer projectId,List<Integer> inchagerIds,String startDate,String endDate);
+    List<ProjectWithStage> selectWithStage(Integer companyId, Integer startIndex, Integer endIndex, Integer projectId,String inchargerId,String startDate,String endDate);
 
     List<Map<String, Object>> getTimeCostReport(@Param("companyId") Integer companyId, @Param("startDate") String startDate, @Param("endDate") String endDate,
                                           @Param("projectId") Integer projectId,@Param("deptIds")List<Integer> deptIds);
@@ -144,4 +145,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<Map<String, Object>> getSubProjectTimeCost(Integer companyId, String startDate, String endDate, Integer projectId,Integer start,Integer size, List<Integer> inchagerIds);
 
     long countWithSubProjectTimeCost(Integer companyId, String startDate, String endDate, Integer projectId, Integer start,Integer size, List<Integer> inchagerIds);
+
+    List<StageCost> selectStageSum(List<Integer> projectIds,Integer projectId, String  inchargerId, String startDate, String endDate);
+
 }

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

@@ -2625,33 +2625,35 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         int startIndex = (pageIndex-1)*pageSize;
         int endIndex = pageSize*pageIndex;
         HttpRespMsg msg = new HttpRespMsg();
-        List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
         List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全部项目阶段工时表");
         List<SysRichFunction> functionInchargeList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责项目阶段工时表");
         //判断查看权限
-        List<Integer> inchagerIds=null;
+        List<ProjectWithStage> record = projectMapper.selectWithStage(companyId, startIndex, endIndex, projectId,null,startDate,endDate);
+        List<Integer> projectIds = record.stream().map(ProjectWithStage::getId).distinct().collect(Collectors.toList());
+        List<StageCost> allStageCostList = projectMapper.selectStageSum(projectIds,projectId,null,startDate,endDate);
+        String inchargerId=null;
         if(functionAllList.size()==0){
-            inchagerIds=new ArrayList<>();
             if(functionInchargeList.size()>0){
-                List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
-                if(list!=null){
-                    List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
-                    inchagerIds.addAll(collect);
-                }
-            }else {
-                inchagerIds.add(-1);
+                record = projectMapper.selectWithStage(companyId, startIndex, endIndex, projectId,user.getId(),startDate,endDate);
+                projectIds = record.stream().map(ProjectWithStage::getId).distinct().collect(Collectors.toList());
+                allStageCostList = projectMapper.selectStageSum(projectIds,projectId,user.getId(),startDate,endDate);
+                inchargerId=user.getId();
             }
         }
         QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
         if (projectId != null) {
             queryWrapper.eq("id", projectId);
         }
-        if(inchagerIds!=null){
-            queryWrapper.in("id",inchagerIds);
+        if(inchargerId!=null){
+            queryWrapper.eq("incharger_id",inchargerId);
         }
         Integer total = projectMapper.selectCount(queryWrapper);
-        List<ProjectWithStage> record = projectMapper.selectWithStage(companyId, startIndex, endIndex, projectId,inchagerIds,startDate,endDate);
         List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看阶段成本");
+        List<StageCost> finalAllStageCostList = allStageCostList;
+        record.forEach(re->{
+            List<StageCost> stageCosts = finalAllStageCostList.stream().filter(al -> al.getProjectId().equals(re.id)).collect(Collectors.toList());
+            re.setStageCostList(stageCosts);
+        });
         if (functionList.size() == 0) {
             //去掉成本
             record.forEach(re->{
@@ -2692,24 +2694,19 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         Integer companyId = user.getCompanyId();
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
         HttpRespMsg msg = new HttpRespMsg();
-        List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
         List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全部项目任务报表");
         List<SysRichFunction> functionInchargeList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责项目任务报表");
         //判断查看权限
+        List<ProjectWithStage> record = projectMapper.selectWithStage(companyId, null, null, null,null,startDate,endDate);
+        List<StageCost> allStageCostList = projectMapper.selectStageSum(null,null,null,startDate,endDate);
         List<Integer> inchagerIds=null;
         if(functionAllList.size()==0){
-            inchagerIds=new ArrayList<>();
             if(functionInchargeList.size()>0){
-                List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
-                if(list!=null){
-                    List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
-                    inchagerIds.addAll(collect);
-                }
-            }else {
-                inchagerIds.add(-1);
+                 record = projectMapper.selectWithStage(companyId, null, null, null,user.getId(),startDate,endDate);
+                 allStageCostList = projectMapper.selectStageSum(null,null,user.getId(),startDate,endDate);
             }
         }
-        List<ProjectWithStage> record = projectMapper.selectWithStage(companyId, null, null, null,inchagerIds,startDate,endDate);
+
         //获取全部的列
         List<Integer> collect = record.stream().map(ProjectWithStage::getId).collect(Collectors.toList());
         final List<String> stageList = new ArrayList<>();
@@ -2733,6 +2730,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<List<String>> dataList = new ArrayList<>();
         dataList.add(titleList);
         List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看阶段成本");
+        List<StageCost> finalAllStageCostList = allStageCostList;
+        record.forEach(re->{
+            List<StageCost> stageCosts = finalAllStageCostList.stream().filter(al -> al.getProjectId().equals(re.id)).collect(Collectors.toList());
+            re.setStageCostList(stageCosts);
+        });
         if (functionList.size() == 0) {
             //去掉成本
             record.forEach(re->{
@@ -2763,7 +2765,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         //String fileName = "项目阶段工时报表_"+System.currentTimeMillis();
         String fileName = MessageUtils.message("fileName.ProPeriodWork")+System.currentTimeMillis();
         try {
-            return excelExportService.exportGeneralExcelByTitleAndList2(wxCorpInfo,fileName, dataList, path);
+            return excelExportService.exportGeneralExcelByTitleAndList2(null,fileName, dataList, path);
         } catch (Exception e) {
             e.printStackTrace();
         }

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

@@ -76,18 +76,15 @@
         <result column="project_ids" property="projectIds" />
         <result column="project_names" property="projectNames" />
     </resultMap>
-    <select id="selectWithStage" resultMap="BaseResultMap2" >
+    <select id="selectWithStage" resultType="com.management.platform.entity.vo.ProjectWithStage">
         select id, project_code, project_name,#{startDate} as startDate,#{endDate} as endDate
         from project
         where company_id = #{companyId}
         <if test="projectId != null">
             and id = #{projectId}
         </if>
-        <if test="inchagerIds!=null and inchagerIds.size()>0">
-            and id in
-            <foreach collection="inchagerIds" open="(" close=")" separator="," item="item">
-                #{item}
-            </foreach>
+        <if test="inchargerId!=null">
+            and incharger_id = #{inchargerId}
         </if>
         order by is_public desc, id asc
         <if test="startIndex != null">
@@ -97,12 +94,22 @@
     <select id="selectStageSum" resultType="com.management.platform.entity.vo.StageCost">
         select IFNULL(report.stage, '-') AS stage_name, IFNULL(SUM(report.`cost`),0) AS cost,
         IFNULL(SUM(report.`working_time`), 0) AS working_time,
-		IFNULL((SELECT SUM(stages.`stages_time`) from stages WHERE stages.stages_name = report.stage  GROUP BY stages_name), 0)  AS stages_time
+		IFNULL((SELECT SUM(stages.`stages_time`) from stages WHERE stages.stages_name = report.stage  GROUP BY stages_name), 0)  AS stages_time,report.`project_id` as projectId
         FROM report
-				where report.state = 1 and report.`project_id` = #{projectId}
+        left join project p on p.id=report.`project_id`
+				where report.state = 1
+        <if test="inchargerId!=null">
+            and p.incharger_id = #{inchargerId}
+        </if>
+        <if test="projectIds!=null and projectIds.size()>0">
+            and p.id in
+            <foreach collection="projectIds" open="(" close=")" separator="," item="item">
+                #{item}
+            </foreach>
+        </if>
 				and report.create_date &gt;= #{startDate}
                 and report.create_date &lt;= #{endDate}
-        GROUP BY report.stage
+        GROUP BY report.`project_id`,report.stage
     </select>
     <!--获取查询者所在公司每个项目的工时成本-->
     <select id="getParticipatedProject" resultType="java.util.Map">