Jelajahi Sumber

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Min 1 tahun lalu
induk
melakukan
95aab8ab05

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

@@ -189,4 +189,6 @@ public interface ReportMapper extends BaseMapper<Report> {
     Double getReallWorkingTimeByProjectAndGroup(Integer projectId, Integer taskGroupId);
 
     List<Map<String, Object>> getProjectPlanData(Integer companyId, String startDate, String endDate);
+
+    List<String> getUserIds(ArrayList<Integer> deptIds, String startDate, String endDate);
 }

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

@@ -47,6 +47,8 @@ public interface UserMapper extends BaseMapper<User> {
 
     int getIsActiveCount(ArrayList<Integer> deptIds, String startDate, String endDate);
 
+    List<User> getIsActiveList(ArrayList<Integer> deptIds, String startDate, String endDate);
+
     List<User> getInActiveList(ArrayList<Integer> deptIds, String startDate, String endDate);
 
     List<User> getInActiveBewttenStartAndEndList(ArrayList<Integer> deptIds, String startDate, String endDate);

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

@@ -11576,6 +11576,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             laborHourRateVo.setChild_ids(deptIds);
             //查询该公司下某头部部门及子部门在四种项目下的工时之和,某个时间段内
             List<Report> reportList= reportMapper.getSumWorkingTime(deptIds,startDate,endDate);
+            List<String> userIds= reportMapper.getUserIds(deptIds,startDate,endDate);
+
 
             ArrayList<Report> reports = new ArrayList<>();//按时填报的report
             for (Report report : reportList) {
@@ -11604,6 +11606,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             //-- 查询 有多少个  入职时间早于起始时间 并且是在职的员工
             int isActiveCount=userMapper.getIsActiveCount(deptIds,startDate,endDate);
 
+            List<User> isActiveList = userMapper.getIsActiveList(deptIds, startDate, endDate);
+            List<String> collect = isActiveList.stream().map(User::getId).collect(Collectors.toList());
+            HashSet<String> idStrings = new HashSet<>();
+            idStrings.addAll(userIds);
+            idStrings.addAll(collect);
+
             //-- 查询 有多少个  入职时间晚于起始时间 并且在这段时间离职的员工
             List<User> inActiveBewttenStartAndEndList=userMapper.getInActiveBewttenStartAndEndList(deptIds,startDate,endDate);
             //获取入职时间晚于起始时间 并且在这段时间离职的员工在此期间工作多少天
@@ -11616,14 +11624,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
             laborHourRateVo.setWorking_time(timeSum);
             laborHourRateVo.setDate_count(dayCount);
-            laborHourRateVo.setCount(isActiveCount);
-            if (inActiveDays == 0) {
+            laborHourRateVo.setCount(idStrings.size());
+            int v = 8 * inActiveDays + idStrings.size() * 8 * dayCount;
+            if (v== 0) {
                 laborHourRateVo.setTotal_time(0L);
                 laborHourRateVo.setRate(0.0);
                 laborHourRateVos.add(laborHourRateVo);
             } else {
-                laborHourRateVo.setTotal_time((long) (8*inActiveDays+isActiveCount*8*dayCount));//应报工时还少了在职的加上可能辞职的
-                BigDecimal bd = new BigDecimal(timeSum/(8*inActiveDays+isActiveCount*8*dayCount)*100);
+                laborHourRateVo.setTotal_time((long) (v));//应报工时还少了在职的加上可能辞职的
+                BigDecimal bd = new BigDecimal(timeSum/(v)*100);
                 bd = bd.setScale(2, RoundingMode.HALF_UP);
                 laborHourRateVo.setRate(bd.doubleValue());
                 laborHourRateVos.add(laborHourRateVo);

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

@@ -980,13 +980,7 @@
         </foreach>
         AND p.company_id=936 AND p.category IN(168,169,171,172)
         AND r.create_date BETWEEN #{startDate} AND #{endDate}
-        AND r.creator_id NOT IN(8276751764399792128,8236086890927300608,8326361182460387328,
-        8342351512166014976,8236086972770754560,8236087310001184768,
-        8236087296243867648,8236087257492692992,8236088012337389568,
-        8245855829805441024,8318841602900172800,8236087360399941632,
-        8236087733260984320,8236090183732764672,8291179326062796800,
-        8236090183611129856,8236087738910711808
-        )
+        AND r.creator_id NOT IN(SELECT * from user_exclude)
     </select>
 
     <select id="getReallWorkingTimeByProjectId" resultType="java.lang.Double">
@@ -1013,4 +1007,18 @@
             and t.create_date between #{startDate} and #{endDate}
         </if>
     </select>
+
+    <select id="getUserIds" resultType="java.lang.String">
+        SELECT DISTINCT r.creator_id as id FROM report r
+        LEFT JOIN project p
+        ON r.project_id=p.id
+        WHERE
+        r.dept_id IN
+        <foreach collection="deptIds" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+        AND p.company_id=936 AND p.category IN(168,169,171,172)
+        AND r.create_date BETWEEN #{startDate} AND #{endDate}
+        AND r.creator_id NOT IN(SELECT * from user_exclude)
+    </select>
 </mapper>

+ 45 - 9
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/UserMapper.xml

@@ -182,8 +182,7 @@
             ${ew.customSqlSegment}
     </select>
 
-    <select id="getIsActiveCount" resultType="java.lang.Integer">
-        SELECT count(1) isActiveCount FROM user
+    <!--SELECT count(1) isActiveCount FROM user
         WHERE id IN (SELECT DISTINCT r.creator_id  FROM report r
         LEFT JOIN project p
         ON r.project_id=p.id
@@ -193,11 +192,19 @@
             #{id}
         </foreach>
         AND r.create_date BETWEEN #{startDate} AND #{endDate})
-        AND is_active=1 AND induction_date &lt;= #{startDate}
+        AND is_active=1 AND induction_date &lt;= #{startDate}-->
+    <select id="getIsActiveCount" resultType="java.lang.Integer">
+        SELECT count(1) isActiveCount FROM user
+        WHERE department_id IN
+          <foreach collection="deptIds" item="id" open="(" close=")" separator=",">
+            #{id}
+          </foreach>
+        AND (is_active = 1 OR inactive_date > #{endDate} OR inactive_date IS NULL)
+        AND (induction_date &lt;= #{startDate} OR induction_date is NULL)
+        AND id not IN (SELECT * from user_exclude)
     </select>
 
-    <select id="getInActiveList" resultType="com.management.platform.entity.User">
-        SELECT user.* FROM user
+    <!-- SELECT user.* FROM user
         WHERE id in
         (SELECT DISTINCT r.creator_id  FROM report r
         LEFT JOIN project p
@@ -208,11 +215,19 @@
             #{id}
         </foreach>
         AND r.create_date BETWEEN #{startDate} AND #{endDate})
-        AND inactive_date BETWEEN #{startDate} AND #{endDate} and induction_date &lt;= #{startDate}
+        AND inactive_date BETWEEN #{startDate} AND #{endDate} and induction_date &lt;= #{startDate}-->
+    <select id="getInActiveList" resultType="com.management.platform.entity.User">
+        SELECT * FROM user
+        WHERE department_id IN
+        <foreach collection="deptIds" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+        AND inactive_date &lt; #{endDate} AND inactive_date >= #{startDate}
+        AND induction_date &lt;= #{startDate}
+        AND id not IN (SELECT * from user_exclude)
     </select>
 
-    <select id="getInActiveBewttenStartAndEndList" resultType="com.management.platform.entity.User">
-        SELECT user.* FROM user
+    <!-- SELECT user.* FROM user
         WHERE id in
               (SELECT DISTINCT r.creator_id  FROM report r
                LEFT JOIN project p
@@ -223,7 +238,28 @@
                     #{id}
                 </foreach>
                AND r.create_date BETWEEN #{startDate} AND #{endDate})
-          AND induction_date BETWEEN #{startDate} AND #{endDate} AND inactive_date BETWEEN #{startDate} AND #{endDate}
+          AND induction_date BETWEEN #{startDate} AND #{endDate} AND inactive_date BETWEEN #{startDate} AND #{endDate}-->
+    <select id="getInActiveBewttenStartAndEndList" resultType="com.management.platform.entity.User">
+        SELECT * FROM user
+        WHERE department_id IN
+        <foreach collection="deptIds" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+        AND inactive_date &lt; #{endDate} AND inactive_date &gt;= #{startDate}
+        AND induction_date &lt; #{endDate} AND induction_date &gt;= #{startDate}
+        AND induction_date &lt; inactive_date
+        AND id not IN (SELECT * from user_exclude)
+    </select>
+
+    <select id="getIsActiveList" resultType="com.management.platform.entity.User">
+        SELECT id  FROM user
+        WHERE department_id IN
+        <foreach collection="deptIds" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+        AND (is_active = 1 OR inactive_date > #{endDate} OR inactive_date IS NULL)
+        AND (induction_date &lt;= #{startDate} OR induction_date is NULL)
+        AND id not IN (SELECT * from user_exclude)
     </select>
 
     <update id="updateActiveByIds">