|
|
@@ -2211,35 +2211,37 @@ left join department d on o.order_dep = d.id left join t_order_mid a on o.orde
|
|
|
</select>
|
|
|
<select id="selectExpenseCount" parameterType="com.goafanti.expenseAccount.bo.ExpenseCountsInput" resultType="com.goafanti.expenseAccount.bo.ExpenseCountsBo">
|
|
|
select a.order_no orderNo,a.contract_no contractNo,b.buyer_name buyerName,a.total_amount totalAmount,a.settlement_amount settlementAmount,
|
|
|
- c.expenseCount,c.peopleCount,c.notExamine,c.rejectCount,c.paymentAmount,c.days
|
|
|
+ c.expenseCount,c.peopleCount,c.notExamine,c.rejectCount,c.paymentAmount,c.days,c.amount expenseAmount
|
|
|
from t_order_new a left join t_order_mid b on a.order_no =b.order_no left join (select a.order_no,a.expenseCount,b.peopleCount,c.notExamine,
|
|
|
- c.rejectCount,ifnull(d.paymentAmount,0)paymentAmount,a.days from (select a.order_no,count(a.id)expenseCount,
|
|
|
+ c.rejectCount,ifnull(d.paymentAmount,0)paymentAmount,a.days,a.amount
|
|
|
+ from (select a.order_no,count(a.id)expenseCount,sum(a.amount) amount,
|
|
|
sum(ROUND(a.duration/7.5) )days from expense_account a where a.order_no in (select a.order_no from expense_account a
|
|
|
where a.target_type = #{targetType}
|
|
|
+ group by order_no)
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
</if>
|
|
|
- group by order_no)
|
|
|
-
|
|
|
group by order_no )a left join (select order_no,count(aid)peopleCount from (select a.order_no,aid from expense_account a where a.order_no in
|
|
|
(select a.order_no from expense_account a where a.target_type = #{targetType}
|
|
|
+ group by order_no)
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
</if>
|
|
|
- group by order_no)
|
|
|
group by order_no,aid )a group by order_no)b on a.order_no=b.order_no left join (select a.order_no,sum(notExamine)notExamine,sum(rejectCount)rejectCount
|
|
|
from (select a.order_no,status ,IF(status=1,1,0)notExamine,IF(status=3,1,0)rejectCount
|
|
|
from expense_account a where a.order_no in (select a.order_no from expense_account a where a.target_type = #{targetType}
|
|
|
+ group by order_no)
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
</if>
|
|
|
- group by order_no))a group by order_no)c on a.order_no=c.order_no left join ( select a.order_no ,sum(c.payment_amount) paymentAmount
|
|
|
+ )a group by order_no)c on a.order_no=c.order_no left join ( select a.order_no ,sum(c.payment_amount) paymentAmount
|
|
|
from t_order_new a left join t_order_task b on a.order_no =b.order_no left join t_order_payment c on b.id =c.tid
|
|
|
where c.status =3 and a.order_no in (select a.order_no from expense_account a where a.target_type = #{targetType}
|
|
|
+ group by order_no)
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
</if>
|
|
|
- group by order_no) group by order_no )d on a.order_no=d.order_no)c on a.order_no =c.order_no
|
|
|
+ group by order_no )d on a.order_no=d.order_no)c on a.order_no =c.order_no
|
|
|
where a.order_no in (select a.order_no from expense_account a where a.target_type = #{targetType}
|
|
|
<if test="startTime !=null and endTime != null">
|
|
|
and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
@@ -2252,5 +2254,55 @@ left join department d on o.order_dep = d.id left join t_order_mid a on o.orde
|
|
|
and a.order_dep = #{depId}
|
|
|
</if>
|
|
|
</select>
|
|
|
+ <select id="selectExpenseDepCount" resultType="com.goafanti.expenseAccount.bo.ExpenseCountsBo">
|
|
|
+ select a.id depId,a.name depName,ifnull(b.totalAmount,0) totalAmount,ifnull(b.settlementAmount,0) settlementAmount,
|
|
|
+ c.amount ExpenseAmount,ifnull(f.paymentAmount,0) paymentAmount,d.peopleCount,c.days,c.expenseCount, e.notExamine,
|
|
|
+ e.rejectCount
|
|
|
+ from department a
|
|
|
+ left join (select a.order_dep ,sum(a.total_amount)totalAmount,sum(a.settlement_amount)settlementAmount
|
|
|
+ from t_order_new a where a.order_dep in (select a.apply_dep
|
|
|
+ from expense_account a where a.target_type = 0 group by apply_dep)
|
|
|
+ <if test="startTime !=null and endTime != null">
|
|
|
+ and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
+ </if>
|
|
|
+ group by a.order_dep )b on a.id=b.order_dep
|
|
|
+ left join (select a.apply_dep,count(a.id)expenseCount, sum(ROUND(a.duration/7.5) )days ,sum(a.amount)amount
|
|
|
+ from expense_account a where a.apply_dep in (select a.apply_dep from expense_account a where a.target_type = 0 group by apply_dep)
|
|
|
+ <if test="startTime !=null and endTime != null">
|
|
|
+ and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
+ </if>
|
|
|
+ group by apply_dep )c on a.id=c.apply_dep
|
|
|
+ left join (select apply_dep,count(aid)peopleCount from (select a.apply_dep,aid from expense_account a where a.apply_dep in
|
|
|
+ (select a.apply_dep
|
|
|
+ from expense_account a where a.target_type = 0 group by apply_dep)
|
|
|
+ <if test="startTime !=null and endTime != null">
|
|
|
+ and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
+ </if>
|
|
|
+ group by apply_dep,aid )a group by apply_dep)d on a.id=d.apply_dep
|
|
|
+ left join (select a.apply_dep,sum(notExamine)notExamine,sum(rejectCount)rejectCount
|
|
|
+ from (select a.apply_dep,status ,IF(status=1,1,0)notExamine,IF(status=3,1,0)rejectCount
|
|
|
+ from expense_account a where a.apply_dep in (select a.apply_dep from expense_account a where a.target_type = 0 group by apply_dep)
|
|
|
+ <if test="startTime !=null and endTime != null">
|
|
|
+ and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
+ </if>
|
|
|
+ )a group by apply_dep)e on a.id=e.apply_dep
|
|
|
+ left join (select a.order_dep ,sum(c.payment_amount) paymentAmount from t_order_new a
|
|
|
+ left join t_order_task b on a.order_no =b.order_no left join t_order_payment c on b.id =c.tid
|
|
|
+ where c.status =3 and a.order_dep in (select a.apply_dep from expense_account a where a.target_type = 0 group by apply_dep)
|
|
|
+ <if test="startTime !=null and endTime != null">
|
|
|
+ and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
+ </if>
|
|
|
+ group by order_dep )f on a.id=f.order_dep
|
|
|
+ where a.id in (select a.apply_dep
|
|
|
+ from expense_account a where a.target_type = 0
|
|
|
+ <if test="startTime !=null and endTime != null">
|
|
|
+ and a.create_time BETWEEN #{startTime} and #{endTime}
|
|
|
+ </if>
|
|
|
+ group by apply_dep)
|
|
|
+ <if test="depId !=null ">
|
|
|
+ and a.id = #{depId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|