|
|
@@ -0,0 +1,103 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
|
|
+<mapper namespace="com.usoftchina.saas.money.mapper.StatsinfoMapper" >
|
|
|
+ <resultMap id="BaseResultMap" type="com.usoftchina.saas.money.po.Statsinfo">
|
|
|
+ <result column="si_yearmonth" jdbcType="DOUBLE" property="si_yearmonth" />
|
|
|
+ <result column="si_amount_pay" jdbcType="DOUBLE" property="si_amount_pay" />
|
|
|
+ <result column="si_amount_otherpay" jdbcType="DOUBLE" property="si_amount_otherpay" />
|
|
|
+ <result column="si_amount_rec" jdbcType="DOUBLE" property="si_amount_rec" />
|
|
|
+ <result column="si_amount_otherrec" jdbcType="DOUBLE" property="si_amount_otherrec" />
|
|
|
+ <result column="companyid" jdbcType="INTEGER" property="companyid" />
|
|
|
+ <result column="si_type" jdbcType="VARCHAR" property="si_type" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <insert id="insert" parameterType="com.usoftchina.saas.money.po.Statsinfo">
|
|
|
+ insert into statsinfo
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides="," >
|
|
|
+ <if test="si_yearmonth != null" >
|
|
|
+ si_yearmonth,
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_pay != null" >
|
|
|
+ si_amount_pay,
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_otherpay != null" >
|
|
|
+ si_amount_otherpay,
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_rec != null" >
|
|
|
+ si_amount_rec,
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_otherrec != null" >
|
|
|
+ si_amount_otherrec,
|
|
|
+ </if>
|
|
|
+ <if test="companyid != null" >
|
|
|
+ companyid,
|
|
|
+ </if>
|
|
|
+ si_type,
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides="," >
|
|
|
+ <if test="si_yearmonth != null" >
|
|
|
+ #{si_yearmonth,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_pay != null" >
|
|
|
+ select sum(pd_amount) from paybalancedet left join paybalance on pd_pbid=pb_id
|
|
|
+ where paybalance.companyId= #{companyid,jdbcType=INTEGER}
|
|
|
+ and pd_ym=#{si_yearmonth,jdbcType=INTEGER} and pb_statuscode='AUDITED',
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_otherpay != null" >
|
|
|
+ (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_orid
|
|
|
+ where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
|
|
|
+ and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_rec != null" >
|
|
|
+ (select sum(rd_amount) from recbalancedet left join recbalance on rd_rbid=rb_id
|
|
|
+ where recbalancedet.companyId=#{companyid,jdbcType=INTEGER}
|
|
|
+ and rd_ym=#{si_yearmonth,jdbcType=INTEGER} and rb_statuscode='AUDITED'),
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_otherrec != null" >
|
|
|
+ (select sum(or_amount) from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
|
|
|
+ where othreceiptsdetail.companyId=#{companyid,jdbcType=INTEGER}
|
|
|
+ and ord_ym=#{si_yearmonth,jdbcType=INTEGER} and or_statuscode='AUDITED'),
|
|
|
+ </if>
|
|
|
+ <if test="companyid != null" >
|
|
|
+ #{companyid,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
+ 'FUND',
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="update" parameterType="com.usoftchina.saas.money.po.Statsinfo" >
|
|
|
+ update statsinfo
|
|
|
+ <set >
|
|
|
+ <if test="si_amount_pay != null" >
|
|
|
+ si_amount_pay =
|
|
|
+ (select sum(pd_amount) from paybalancedet left join paybalance on pd_pbid=pb_id
|
|
|
+ where paybalance.companyId= #{companyid,jdbcType=INTEGER}
|
|
|
+ and pd_ym=#{si_yearmonth,jdbcType=INTEGER} and pb_statuscode='AUDITED'),
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_otherpay != null" >
|
|
|
+ si_amount_otherpay =
|
|
|
+ (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_orid
|
|
|
+ where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
|
|
|
+ and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_rec != null" >
|
|
|
+ si_amount_rec =
|
|
|
+ (select sum(rd_amount) from recbalancedet left join recbalance on rd_rbid=rb_id
|
|
|
+ where recbalancedet.companyId=#{companyid,jdbcType=INTEGER}
|
|
|
+ and rd_ym=#{si_yearmonth,jdbcType=INTEGER} and rb_statuscode='AUDITED'),
|
|
|
+ </if>
|
|
|
+ <if test="si_amount_otherrec != null" >
|
|
|
+ si_amount_otherrec =
|
|
|
+ (select sum(or_amount) from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
|
|
|
+ where othreceiptsdetail.companyId=#{companyid,jdbcType=INTEGER}
|
|
|
+ and ord_ym=#{si_yearmonth,jdbcType=INTEGER} and or_statuscode='AUDITED'),
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where si_yearmonth = #{si_yearmonth,jdbcType=INTEGER} and companyid = #{companyid,jdbcType=INTEGER}
|
|
|
+ and si_type = 'FUND'
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <select id="select" resultType="java.lang.Integer">
|
|
|
+ select DISTINCT si_yearmonth from statsinfo where si_yearmonth =#{si_yearmonth,jdbcType=INTEGER} and companyid = #{companyid,jdbcType=INTEGER}
|
|
|
+ </select>
|
|
|
+</mapper>
|