소스 검색

部门项目参与表bug修复

cs 2 년 전
부모
커밋
28dff80663

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/BusinessTripMapper.java

@@ -17,4 +17,6 @@ import java.util.Map;
 public interface BusinessTripMapper extends BaseMapper<BusinessTrip> {
 
     public List<BusinessTrip> summaryData(String keyword, String startDate, String endDate, Integer companyId);
+
+    List<Map<String,Object>> selectBusiness(String startDate, String endDate,String deptId);
 }

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

@@ -22,6 +22,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.util.EntityUtils;
+import org.apache.ibatis.annotations.Select;
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -7677,17 +7678,31 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             total = maps.size();
         }
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+        System.err.println(resultList.toString());
         if (resultList.size() > 0){
             for (Map<String, Object> stringObjectMap : resultList) {
-                Department department = departmentMapper.selectById(stringObjectMap.get("departmentId").toString());
-                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                Department department = departmentMapper.selectById(stringObjectMap.get("deptId").toString());
+                if ("0".equals(stringObjectMap.get("deptId").toString())){
+                    stringObjectMap.put("deptName","未分配");
+                }else if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact()==1 && department != null){
                     stringObjectMap.put("deptName",getWxDepartment(department));
                 }else {
                     stringObjectMap.put("deptName",getSupDepartment(department));
                 }
+                stringObjectMap.put("deptHeadCount",stringObjectMap.get("deptHeadCount")==null?0:stringObjectMap.get("deptHeadCount"));
                 stringObjectMap.put("projectCount",stringObjectMap.get("projectCount")==null?0:stringObjectMap.get("projectCount"));
-                stringObjectMap.put("tripCount",stringObjectMap.get("tripCount")==null?0:stringObjectMap.get("tripCount"));
+                stringObjectMap.put("centerCount",stringObjectMap.get("centerCount")==null?0:stringObjectMap.get("centerCount"));
                 stringObjectMap.put("peopleCount",stringObjectMap.get("peopleCount")==null?0:stringObjectMap.get("peopleCount"));
+                if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate)){
+                    List<Map<String,Object>> businessTrips = businessTripMapper.selectBusiness(null, null,stringObjectMap.get("deptId").toString());
+                    Integer dayCount = businessTrips.stream().collect(Collectors.summingInt((b) -> (int)b.get("dayCount")));
+                    stringObjectMap.put("tripCount",dayCount==null?0:dayCount);
+                }else{
+                    List<Map<String,Object>> businessTrips = businessTripMapper.selectBusiness(startDate,endDate,stringObjectMap.get("deptId").toString());
+                    for (Map<String, Object> businessTrip : businessTrips) {
+
+                    }
+                }
             }
         }
         HashMap<String, Object> result = new HashMap<>();

+ 14 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/BusinessTripMapper.xml

@@ -45,4 +45,18 @@
         and business_trip.company_id = #{companyId}
         group by owner_id
     </select>
+
+    <select id="selectBusiness" resultType="java.util.Map">
+        SELECT `user`.department_id deptId,start_date startDate,end_date endDate,day_count dayCount
+        FROM business_trip
+        LEFT JOIN `user`
+        on business_trip.owner_id = `user`.id
+        WHERE STATUS = 0
+        <if test="deptId!=null and deptId!=''">
+            and user.department_id = #{deptId}
+        </if>
+        <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
+            and business_trip.startDate &lt;= #{endDate} and business_trip.endDate >= #{startDate}
+        </if>
+    </select>
 </mapper>

+ 34 - 51
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -1283,58 +1283,40 @@
 
     <!--    分页查询部门参与项目情况-->
     <select id="selectDeptPartInProjects" resultType="java.util.Map">
-        SELECT department.department_id AS departmentId,
-        department.department_name AS deptName,
-        u.projectCount,
-        u.peopleCount,
-        t.trip AS tripCount
-        from department
-        left JOIN (
-        SELECT `user`.department_id AS departmentId,
-        COUNT(DISTINCT(project.id)) AS projectCount,
-        COUNT(`user`.id) AS peopleCount
-        from  `user`
-        LEFT JOIN participation ON `user`.id = participation.user_id
-        LEFT JOIN project ON project.id = participation.project_id
-        WHERE user.company_id = #{companyId}
-        and project.id is not null
-        <if test="branchDepartment!=null and branchDepartment.size()>0">
-            and user.department_id in
-            <foreach collection="branchDepartment" open="(" close=")" separator="," item="item">
-                #{item}
-            </foreach>
-        </if>
-        <if test="deptIds!=null and deptIds.size()>0">
-            and user.department_id in
-            <foreach collection="deptIds" open="(" item="item" close=")" separator=",">
-                #{item}
-            </foreach>
-        </if>
-        <if test="startDate!= null and startDate!= ''" >
-            and project.create_date &gt;= #{startDate}
-        </if>
-        <if test="endDate!= null and endDate!= ''">
-            and project.create_date &lt;= #{endDate}
-        </if>
-        GROUP BY `user`.department_id
-        ) u ON department.department_id = u.departmentId
-        left join (
-            SELECT u.deptId AS deptId,SUM(tripCount) AS trip
-            FROM (
-            SELECT `user`.department_id AS deptId,SUM(day_count) AS tripCount from business_trip
-            LEFT JOIN `user` ON business_trip.owner_id = `user`.id
-            where STATUS  = 0
-            AND user.company_id = #{companyId}
-            <if test="endDate!= null and endDate!= ''" >
-                and business_trip.start_date &lt;=#{endDate}
+        SELECT department.department_id deptId,
+        department_name deptName,
+        COUNT(`user`.id) deptHeadCount,
+        pro.projectCount projectCount,
+        pro.centerCount centerCount,
+        pcon.peopleCount peopleCount
+        FROM department
+        LEFT JOIN `user`
+        ON `user`.department_id = department.department_id
+        LEFT JOIN (
+            SELECT report.dept_id,COUNT(DISTINCT(report.project_id)) projectCount,
+            COUNT(DISTINCT(r.degree_id)) centerCount
+            FROM report
+            LEFT JOIN report r
+            ON report.id = r.id AND r.degree_id != -1
+            WHERE report.state = 1
+            <if test="startDate!= null and startDate!= '' and endDate!=  null and endDate!= ''" >
+                And report.create_date BETWEEN #{startDate} AND #{endDate}
             </if>
-            <if test="startDate!= null and startDate!= ''">
-                and business_trip.end_date &gt;= #{startDate}
+            GROUP BY report.dept_id
+        ) pro
+        ON pro.dept_id = department.department_id
+        LEFT JOIN (
+            SELECT dept_id,sum(p.con) peopleCount
+            FROM (
+            SELECT dept_id,count(DISTINCT project_id)con FROM report
+            WHERE report.state = 1
+            <if test="startDate!= null and startDate!= '' and endDate!=  null and endDate!= ''" >
+                And report.create_date BETWEEN #{startDate} AND #{endDate}
             </if>
-            GROUP BY `user`.id
-            ) u
-            GROUP BY u.deptId
-        ) t on t.deptId = department.department_id
+            GROUP BY report.creator_id,report.dept_id
+        ) p  GROUP BY p.dept_id
+        ) pcon
+        ON pcon.dept_id = department.department_id
         WHERE department.company_id = #{companyId}
         <if test="branchDepartment!=null and branchDepartment.size()>0">
             and department.department_id in
@@ -1348,7 +1330,8 @@
                 #{item}
             </foreach>
         </if>
-        ORDER BY u.projectCount,u.peopleCount
+        GROUP BY department.department_id,projectCount,centerCount,peopleCount
+        ORDER BY projectCount
         <if test="size!=null and start!=null">
             limit #{start},#{size}
         </if>

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

@@ -243,7 +243,7 @@
     <!--根据员工id,日期获取当天全部报告信息-->
     <select id="getReportByDate" resultType="java.util.Map">
         SELECT a.id, a.project_id as projectId,b.project_name AS project, a.working_time AS time, a.content, a.state, a.time_type as timeType, a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,
-        a.end_time as endTime, b.incharger_id as inchargerId,
+        a.end_time as endTime, b.incharger_id as inchargerId,b.project_code as projectCode,
         a.creator_id as creatorId, d.name as subProjectName,a.task_id as taskId, task.name as taskName, a.is_overtime as isOvertime,a.progress as progress,
         a.department_audit_state as departmentAuditState, a.stage, a.pic_str as picStr, multi_worktime as multiWorktime
         , reject_reason as rejectReason, reject_username as rejectUsername, reject_userid as rejectUserid, degree_id as degree_id,report_extra_degree.name as degreeName,
@@ -379,7 +379,7 @@
     <select id="getUserReportByDate" resultType="java.util.Map">
         SELECT a.id, b.project_name AS project, a.working_time AS time, a.content, a.state, a.time_type as timeType, a.creator_id as creatorId, a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,
         a.end_time as endTime, d.name as subProjectName,a.task_id as taskId, task.name as taskName,
-        b.incharger_id as inchargerId,
+        b.incharger_id as inchargerId,b.project_code as projectCode,
         a.is_overtime as isOvertime,a.progress as progress,
         a.department_audit_state as departmentAuditState, a.stage, a.pic_str as picStr, multi_worktime as multiWorktime
         , reject_reason as rejectReason, reject_username as rejectUsername, reject_userid as rejectUserid, degree_id as degree_id,report_extra_degree.name as degreeName,