Min 1 yıl önce
ebeveyn
işleme
90d1a28ba7

+ 27 - 35
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/mapper/ReportMapper.xml

@@ -189,7 +189,7 @@
         from plan_procedure_total a
         left join plan b on a.plan_id=b.id
         left join prod_procedure c on a.prod_procedure_id=c.id
-        where b.company_id=#{companyId}
+        where b.company_id=#{companyId} and b.status!=2
         <if test="userId!=null and userId!=''">
             and d.user_id=#{userId}
         </if>
@@ -200,7 +200,7 @@
             and b.foreman_id=#{foremanId}
         </if>
         <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
-            and (b.start_date &gt;= #{startDate} and b.end_date &lt;= #{endDate})
+            and b.start_date between #{startDate} and #{endDate}
         </if>
         order by b.create_time desc ,a.id
         <if test="pageStart!=null and pageSize!=null">
@@ -215,7 +215,7 @@
         from plan_procedure_total a
         left join plan b on a.plan_id=b.id
         left join prod_procedure c on a.prod_procedure_id=c.id
-        where b.company_id=#{companyId}
+        where b.company_id=#{companyId} and b.status!=2
         <if test="userId!=null and userId!=''">
             and d.user_id=#{userId}
         </if>
@@ -226,7 +226,7 @@
             and b.foreman_id=#{foremanId}
         </if>
         <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
-            and (b.start_date &gt;= #{startDate} and b.end_date &lt;= #{endDate})
+            and b.start_date between #{startDate} and #{endDate}
         </if>
         ) as total
     </select>
@@ -373,31 +373,27 @@
     </select>
 
     <select id="getDpetStatisticsProgressList" resultType="java.util.Map">
-        select de.department_id as departmentId, de.department_name as departmentName,
-        SUM(d.work_time) as planWorkTime,
-        SUM((select SUM(working_time) from report where user_procedure_team_id = d.id)) as nowWorkTime,
-        SUM((select SUM(cost) from report where user_procedure_team_id = d.id)) as  nowCost
-        from plan_procedure_total a
-        left join plan b on a.plan_id=b.id
-        left join prod_procedure c on a.prod_procedure_id=c.id
-        left join prod_procedure_team d on a.id=d.plan_procedure_id
-        left join user u on u.id=d.user_id
-        left join department de on b.station_id=de.department_id
-        where b.company_id=#{companyId}
+        select d.department_id as departmentId,d.department_name as departmentName,IFNULL(SUM((select SUM(working_time) from report where plan_id = p.id)),0) as nowWorkTime,
+        IFNULL(SUM((select SUM(cost) from report where plan_id  = p.id)),0) as  nowCost,
+        IFNULL(SUM((select SUM(total_working_hours) from plan_procedure_total where plan_id  = p.id)),0) as   planWorkTime
+        from
+        department d
+        left join plan p on p.station_id=d.department_id
+        where p.company_id=#{companyId} and p.status!=2
         <if test="userId!=null and userId!=''">
             and d.user_id=#{userId}
         </if>
         <if test="deptId!=null and deptId!=''">
-            and b.station_id=#{deptId}
+            and p.station_id=#{deptId}
         </if>
         <if test="foremanId!=null and foremanId!=''">
-            and b.foreman_id=#{foremanId}
+            and p.foreman_id=#{foremanId}
         </if>
         <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
-            and (b.start_date &gt;= #{startDate} and b.end_date &lt;= #{endDate})
+            and p.start_date between #{startDate} and #{endDate}
         </if>
-        group by b.station_id
-        order by b.create_time desc ,a.id
+        group by d.department_id
+        order by p.create_time desc
         <if test="pageStart!=null and pageSize!=null">
             limit #{pageStart},#{pageSize}
         </if>
@@ -405,30 +401,26 @@
 
     <select id="getDpetStatisticsProgressCount" resultType="java.lang.Integer">
         select count(1) from (
-        select de.department_name as departmentName,
-        SUM(d.work_time) as planWorkTime,
-        SUM((select SUM(working_time) from report where user_procedure_team_id = d.id)) as nowWorkTime,
-        SUM((select SUM(cost) from report where user_procedure_team_id = d.id)) as  nowCost
-        from plan_procedure_total a
-        left join plan b on a.plan_id=b.id
-        left join prod_procedure c on a.prod_procedure_id=c.id
-        left join prod_procedure_team d on a.id=d.plan_procedure_id
-        left join user u on u.id=d.user_id
-        left join department de on b.station_id=de.department_id
-        where b.company_id=#{companyId}
+        select d.department_id as departmentId,d.department_name as departmentName,IFNULL(SUM((select SUM(working_time) from report where plan_id = p.id)),0) as nowWorkTime,
+        IFNULL(SUM((select SUM(cost) from report where plan_id  = p.id)),0) as  nowCost,
+        IFNULL(SUM((select SUM(total_working_hours) from plan_procedure_total where plan_id  = p.id)),0) as   planWorkTime
+        from
+        department d
+        left join plan p on p.station_id=d.department_id
+        where p.company_id=#{companyId} and p.status!=2
         <if test="userId!=null and userId!=''">
             and d.user_id=#{userId}
         </if>
         <if test="deptId!=null and deptId!=''">
-            and b.station_id=#{deptId}
+            and p.station_id=#{deptId}
         </if>
         <if test="foremanId!=null and foremanId!=''">
-            and b.foreman_id=#{foremanId}
+            and p.foreman_id=#{foremanId}
         </if>
         <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
-            and (b.start_date &gt;= #{startDate} and b.end_date &lt;= #{endDate})
+            and p.start_date between #{startDate} and #{endDate}
         </if>
-        group by b.station_id
+        group by d.department_id
         ) as total
     </select>
     <select id="getReportList" resultType="java.util.Map">