| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065 |
- <?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.goafanti.common.dao.ExpenseAccountMapper">
- <resultMap id="BaseResultMap" type="com.goafanti.common.model.ExpenseAccount">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="prid" jdbcType="INTEGER" property="prid" />
- <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
- <result column="aid" jdbcType="VARCHAR" property="aid" />
- <result column="aname" jdbcType="VARCHAR" property="aname" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="type_other" jdbcType="VARCHAR" property="typeOther" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="process_status" jdbcType="INTEGER" property="processStatus" />
- <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
- <result column="attachment_url" jdbcType="VARCHAR" property="attachmentUrl" />
- <result column="apply_dep" jdbcType="VARCHAR" property="applyDep" />
- <result column="pay_dep" jdbcType="VARCHAR" property="payDep" />
- <result column="eaaid" jdbcType="INTEGER" property="eaaid" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="district_name" jdbcType="VARCHAR" property="districtName" />
- <result column="user_names" jdbcType="VARCHAR" property="userNames" />
- <result column="release_start" jdbcType="TIMESTAMP" property="releaseStart" />
- <result column="release_end" jdbcType="TIMESTAMP" property="releaseEnd" />
- <result column="duration" jdbcType="DOUBLE" property="duration" />
- <result column="examine_name" jdbcType="VARCHAR" property="examineName" />
- <result column="settlement_amount" jdbcType="DECIMAL" property="settlementAmount" />
- <result column="debit_id" jdbcType="INTEGER" property="debitId" />
- <result column="target_type" jdbcType="INTEGER" property="targetType" />
- <result column="liquidation_status" jdbcType="INTEGER" property="liquidationStatus" />
- <result column="remarks" jdbcType="VARCHAR" property="remarks" />
- <result column="check_no" jdbcType="VARCHAR" property="checkNo" />
- <result column="expense_main" jdbcType="INTEGER" property="expenseMain" />
- <result column="real_amount" jdbcType="DECIMAL" property="realAmount" />
- <result column="secondary_type" jdbcType="INTEGER" property="secondaryType" />
- <result column="secondary_type_other" jdbcType="VARCHAR" property="secondaryTypeOther" />
- <result column="amount" jdbcType="DECIMAL" property="amount" />
- <result column="approval" jdbcType="INTEGER" property="approval" />
- </resultMap>
- <sql id="Base_Column_List">
- id, prid, order_no, aid, aname, `type`, type_other, `status`, process_status, total_amount,
- attachment_url, apply_dep, pay_dep, eaaid, create_time, district_name, user_names,
- release_start, release_end, duration, examine_name, settlement_amount, debit_id,
- target_type, liquidation_status, remarks, check_no, expense_main, real_amount, secondary_type,
- secondary_type_other, amount, approval
- </sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from expense_account
- where id = #{id,jdbcType=INTEGER}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from expense_account
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
- insert into expense_account (prid, order_no, aid,
- aname, `type`, type_other,
- `status`, process_status, total_amount,
- attachment_url, apply_dep, pay_dep,
- eaaid, create_time, district_name,
- user_names, release_start, release_end,
- duration, examine_name, settlement_amount,
- debit_id, target_type, liquidation_status,
- remarks, check_no, expense_main,
- real_amount, secondary_type, secondary_type_other,
- amount, approval)
- values (#{prid,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
- #{aname,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{typeOther,jdbcType=VARCHAR},
- #{status,jdbcType=INTEGER}, #{processStatus,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL},
- #{attachmentUrl,jdbcType=VARCHAR}, #{applyDep,jdbcType=VARCHAR}, #{payDep,jdbcType=VARCHAR},
- #{eaaid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{districtName,jdbcType=VARCHAR},
- #{userNames,jdbcType=VARCHAR}, #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP},
- #{duration,jdbcType=DOUBLE}, #{examineName,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
- #{debitId,jdbcType=INTEGER}, #{targetType,jdbcType=INTEGER}, #{liquidationStatus,jdbcType=INTEGER},
- #{remarks,jdbcType=VARCHAR}, #{checkNo,jdbcType=VARCHAR}, #{expenseMain,jdbcType=INTEGER},
- #{realAmount,jdbcType=DECIMAL}, #{secondaryType,jdbcType=INTEGER}, #{secondaryTypeOther,jdbcType=VARCHAR},
- #{amount,jdbcType=DECIMAL}, #{approval,jdbcType=INTEGER})
- </insert>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
- insert into expense_account
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="prid != null">
- prid,
- </if>
- <if test="orderNo != null">
- order_no,
- </if>
- <if test="aid != null">
- aid,
- </if>
- <if test="aname != null">
- aname,
- </if>
- <if test="type != null">
- `type`,
- </if>
- <if test="typeOther != null">
- type_other,
- </if>
- <if test="status != null">
- `status`,
- </if>
- <if test="processStatus != null">
- process_status,
- </if>
- <if test="totalAmount != null">
- total_amount,
- </if>
- <if test="attachmentUrl != null">
- attachment_url,
- </if>
- <if test="applyDep != null">
- apply_dep,
- </if>
- <if test="payDep != null">
- pay_dep,
- </if>
- <if test="eaaid != null">
- eaaid,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="districtName != null">
- district_name,
- </if>
- <if test="userNames != null">
- user_names,
- </if>
- <if test="releaseStart != null">
- release_start,
- </if>
- <if test="releaseEnd != null">
- release_end,
- </if>
- <if test="duration != null">
- duration,
- </if>
- <if test="examineName != null">
- examine_name,
- </if>
- <if test="settlementAmount != null">
- settlement_amount,
- </if>
- <if test="debitId != null">
- debit_id,
- </if>
- <if test="targetType != null">
- target_type,
- </if>
- <if test="liquidationStatus != null">
- liquidation_status,
- </if>
- <if test="remarks != null">
- remarks,
- </if>
- <if test="checkNo != null">
- check_no,
- </if>
- <if test="expenseMain != null">
- expense_main,
- </if>
- <if test="realAmount != null">
- real_amount,
- </if>
- <if test="secondaryType != null">
- secondary_type,
- </if>
- <if test="secondaryTypeOther != null">
- secondary_type_other,
- </if>
- <if test="amount != null">
- amount,
- </if>
- <if test="approval != null">
- approval,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="prid != null">
- #{prid,jdbcType=INTEGER},
- </if>
- <if test="orderNo != null">
- #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="aid != null">
- #{aid,jdbcType=VARCHAR},
- </if>
- <if test="aname != null">
- #{aname,jdbcType=VARCHAR},
- </if>
- <if test="type != null">
- #{type,jdbcType=INTEGER},
- </if>
- <if test="typeOther != null">
- #{typeOther,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- #{status,jdbcType=INTEGER},
- </if>
- <if test="processStatus != null">
- #{processStatus,jdbcType=INTEGER},
- </if>
- <if test="totalAmount != null">
- #{totalAmount,jdbcType=DECIMAL},
- </if>
- <if test="attachmentUrl != null">
- #{attachmentUrl,jdbcType=VARCHAR},
- </if>
- <if test="applyDep != null">
- #{applyDep,jdbcType=VARCHAR},
- </if>
- <if test="payDep != null">
- #{payDep,jdbcType=VARCHAR},
- </if>
- <if test="eaaid != null">
- #{eaaid,jdbcType=INTEGER},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="districtName != null">
- #{districtName,jdbcType=VARCHAR},
- </if>
- <if test="userNames != null">
- #{userNames,jdbcType=VARCHAR},
- </if>
- <if test="releaseStart != null">
- #{releaseStart,jdbcType=TIMESTAMP},
- </if>
- <if test="releaseEnd != null">
- #{releaseEnd,jdbcType=TIMESTAMP},
- </if>
- <if test="duration != null">
- #{duration,jdbcType=DOUBLE},
- </if>
- <if test="examineName != null">
- #{examineName,jdbcType=VARCHAR},
- </if>
- <if test="settlementAmount != null">
- #{settlementAmount,jdbcType=DECIMAL},
- </if>
- <if test="debitId != null">
- #{debitId,jdbcType=INTEGER},
- </if>
- <if test="targetType != null">
- #{targetType,jdbcType=INTEGER},
- </if>
- <if test="liquidationStatus != null">
- #{liquidationStatus,jdbcType=INTEGER},
- </if>
- <if test="remarks != null">
- #{remarks,jdbcType=VARCHAR},
- </if>
- <if test="checkNo != null">
- #{checkNo,jdbcType=VARCHAR},
- </if>
- <if test="expenseMain != null">
- #{expenseMain,jdbcType=INTEGER},
- </if>
- <if test="realAmount != null">
- #{realAmount,jdbcType=DECIMAL},
- </if>
- <if test="secondaryType != null">
- #{secondaryType,jdbcType=INTEGER},
- </if>
- <if test="secondaryTypeOther != null">
- #{secondaryTypeOther,jdbcType=VARCHAR},
- </if>
- <if test="amount != null">
- #{amount,jdbcType=DECIMAL},
- </if>
- <if test="approval != null">
- #{approval,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccount">
- update expense_account
- <set>
- <if test="prid != null">
- prid = #{prid,jdbcType=INTEGER},
- </if>
- <if test="orderNo != null">
- order_no = #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="aid != null">
- aid = #{aid,jdbcType=VARCHAR},
- </if>
- <if test="aname != null">
- aname = #{aname,jdbcType=VARCHAR},
- </if>
- <if test="type != null">
- `type` = #{type,jdbcType=INTEGER},
- </if>
- <if test="typeOther != null">
- type_other = #{typeOther,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- `status` = #{status,jdbcType=INTEGER},
- </if>
- <if test="processStatus != null">
- process_status = #{processStatus,jdbcType=INTEGER},
- </if>
- <if test="totalAmount != null">
- total_amount = #{totalAmount,jdbcType=DECIMAL},
- </if>
- <if test="attachmentUrl != null">
- attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
- </if>
- <if test="applyDep != null">
- apply_dep = #{applyDep,jdbcType=VARCHAR},
- </if>
- <if test="payDep != null">
- pay_dep = #{payDep,jdbcType=VARCHAR},
- </if>
- <if test="eaaid != null">
- eaaid = #{eaaid,jdbcType=INTEGER},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="districtName != null">
- district_name = #{districtName,jdbcType=VARCHAR},
- </if>
- <if test="userNames != null">
- user_names = #{userNames,jdbcType=VARCHAR},
- </if>
- <if test="releaseStart != null">
- release_start = #{releaseStart,jdbcType=TIMESTAMP},
- </if>
- <if test="releaseEnd != null">
- release_end = #{releaseEnd,jdbcType=TIMESTAMP},
- </if>
- <if test="duration != null">
- duration = #{duration,jdbcType=DOUBLE},
- </if>
- <if test="examineName != null">
- examine_name = #{examineName,jdbcType=VARCHAR},
- </if>
- <if test="settlementAmount != null">
- settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
- </if>
- <if test="debitId != null">
- debit_id = #{debitId,jdbcType=INTEGER},
- </if>
- <if test="targetType != null">
- target_type = #{targetType,jdbcType=INTEGER},
- </if>
- <if test="liquidationStatus != null">
- liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
- </if>
- <if test="remarks != null">
- remarks = #{remarks,jdbcType=VARCHAR},
- </if>
- <if test="checkNo != null">
- check_no = #{checkNo,jdbcType=VARCHAR},
- </if>
- <if test="expenseMain != null">
- expense_main = #{expenseMain,jdbcType=INTEGER},
- </if>
- <if test="realAmount != null">
- real_amount = #{realAmount,jdbcType=DECIMAL},
- </if>
- <if test="secondaryType != null">
- secondary_type = #{secondaryType,jdbcType=INTEGER},
- </if>
- <if test="secondaryTypeOther != null">
- secondary_type_other = #{secondaryTypeOther,jdbcType=VARCHAR},
- </if>
- <if test="amount != null">
- amount = #{amount,jdbcType=DECIMAL},
- </if>
- <if test="approval != null">
- approval = #{approval,jdbcType=INTEGER},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccount">
- update expense_account
- set prid = #{prid,jdbcType=INTEGER},
- order_no = #{orderNo,jdbcType=VARCHAR},
- aid = #{aid,jdbcType=VARCHAR},
- aname = #{aname,jdbcType=VARCHAR},
- `type` = #{type,jdbcType=INTEGER},
- type_other = #{typeOther,jdbcType=VARCHAR},
- `status` = #{status,jdbcType=INTEGER},
- process_status = #{processStatus,jdbcType=INTEGER},
- total_amount = #{totalAmount,jdbcType=DECIMAL},
- attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
- apply_dep = #{applyDep,jdbcType=VARCHAR},
- pay_dep = #{payDep,jdbcType=VARCHAR},
- eaaid = #{eaaid,jdbcType=INTEGER},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- district_name = #{districtName,jdbcType=VARCHAR},
- user_names = #{userNames,jdbcType=VARCHAR},
- release_start = #{releaseStart,jdbcType=TIMESTAMP},
- release_end = #{releaseEnd,jdbcType=TIMESTAMP},
- duration = #{duration,jdbcType=DOUBLE},
- examine_name = #{examineName,jdbcType=VARCHAR},
- settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
- debit_id = #{debitId,jdbcType=INTEGER},
- target_type = #{targetType,jdbcType=INTEGER},
- liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
- remarks = #{remarks,jdbcType=VARCHAR},
- check_no = #{checkNo,jdbcType=VARCHAR},
- expense_main = #{expenseMain,jdbcType=INTEGER},
- real_amount = #{realAmount,jdbcType=DECIMAL},
- secondary_type = #{secondaryType,jdbcType=INTEGER},
- secondary_type_other = #{secondaryTypeOther,jdbcType=VARCHAR},
- amount = #{amount,jdbcType=DECIMAL},
- approval = #{approval,jdbcType=INTEGER}
- where id = #{id,jdbcType=INTEGER}
- </update>
- <sql id="selectDtailsSql">
- a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
- a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,a.debit_id debitId,
- a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,a.district_name districtName,a.approval,
- a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name applyDepName,a.amount,
- c.name payDepName,d.name ,d.bank ,d.accounts ,a.settlement_amount settlementAmount,a.secondary_type secondaryType,
- a.liquidation_status liquidationStatus, a.remarks,a.check_no checkNo,a.secondary_type_other secondaryTypeOther,
- a.create_time createTime, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,pr.type publicReleaseType,
- date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
- date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
- FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
- left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
- left join t_order_mid tm on a.order_no =tm.order_no left join public_release pr on a.prid=pr.id
- </sql>
- <select id="selectByid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
- SELECT
- <include refid="selectDtailsSql"/>
- WHERE a.id= #{id}
- </select>
- <select id="selectByCheckNo" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
- SELECT
- <include refid="selectDtailsSql"/>
- WHERE a.check_no= #{checkNo}
- </select>
- <select id="selectExpenseAccountList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountBo">
- select a.id,a.total_amount totalAmount,a.`type`,a.process_status processStatus,a.type_other typeOther,
- a.attachment_url attachmentUrl ,a.real_amount realAmount,e.contract_no contractNo,tm.buyer_name buyerName,
- a.secondary_type secondaryType, a.secondary_type_other secondaryTypeOther,a.status,a.user_names userNames,
- date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,a.user_names userNames,a.amount,
- date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr,
- <if test="processStatus ==1">
- eae.type eaeType,
- </if>
- <if test="expenseMain ==0">
- mea.examine_name examineName,mea.check_no checkNo,mea.id mainId, a.target_type targetType,
- </if>
- <if test="expenseMain ==1">
- a.examine_name examineName,a.check_no checkNo,a.target_type targetType,
- </if>
- f.name depName,d2.name financeName, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,a.aname,
- b.name applyDepName, c.name payDepName
- from expense_account a
- <if test="type !=null">
- right join (select a.id
- from expense_account a left join expense_relationship b on a.id =b.id
- left join expense_account c on b.ea_id =c.id
- where c.`type` = #{type})x on a.id=x.id
- </if>
- left join admin d on a.aid =d.id left join department f on d.department_id =f.id
- <if test="expenseMain ==0">
- left join expense_relationship er on a.id=er.ea_id
- left join expense_account mea on er.id=mea.id
- left join t_order_new e on a.order_no =e.order_no
- left join department b on mea.apply_dep =b.id left join department c on mea.pay_dep =c.id
- left join admin d2 on b.expense_finance_id =d2.id
- </if>
- <if test="expenseMain ==1">
- left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
- left join t_order_new e on a.order_no =e.order_no
- left join admin d2 on b.expense_finance_id =d2.id
- </if>
- left join t_order_mid tm on e.order_no =tm.order_no
- <if test="processStatus ==1">
- inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
- where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
- </if>
- <include refid="selectExpenseAccountSql"/>
- order by a.status,a.create_time desc
- <if test="page_sql !=null">
- ${page_sql}
- </if>
- </select>
- <sql id="selectExpenseAccountSql">
- where 1=1
- <if test="processStatus ==1">
- and a.process_status>0
- <if test="examineStatus ==1">
- and a.process_status =eae.`type`
- </if>
- <if test="examineStatus ==2">
- and a.process_status >eae.`type`
- </if>
- </if>
- <if test="processStatus ==2">
- <if test="roleType ==0">
- and f.finance_id = #{auditor}
- </if>
- <if test="examineStatus ==0">
- and a.process_status> 1
- and a.status in (1,2)
- </if>
- <if test="examineStatus ==1">
- and a.process_status= 2
- and a.status=1
- </if>
- <if test="examineStatus ==2">
- and a.process_status> 2
- and a.status in (1,2)
- </if>
- </if>
- <if test="processStatus ==5">
- and f.finance_id in (select id from admin where superior_id = #{auditor})
- </if>
- <if test="processStatus ==6">
- <if test="examineStatus ==1">
- and a.status=1
- </if>
- <if test="examineStatus ==2">
- and a.status in (2)
- </if>
- </if>
- <if test=" aid !=null">
- and a.aid= #{aid}
- </if>
- <if test="status != null">
- and a.status= #{status}
- </if>
- <if test="checkNo != null " >
- <if test="expenseMain ==0">
- and mea.check_no like concat('%',#{checkNo},'%')
- </if>
- <if test="expenseMain ==1">
- and a.check_no like concat('%',#{checkNo},'%')
- </if>
- </if>
- <if test="username != null" >
- and a.user_names like concat('%',#{username},'%')
- </if>
- <if test="startTime !=null and endTime !=null">
- and a.create_time between #{startTime} and #{endTime}
- </if>
- <if test="depId != null">
- and d.department_id = #{depId}
- </if>
- <if test="contractNo != null">
- and e.contract_no like concat('%',#{contractNo},'%')
- </if>
- <if test="applyDep != null">
- and a.apply_dep = #{applyDep}
- </if>
- <if test="payDep != null">
- and a.pay_dep = #{payDep}
- </if>
- <if test="expenseMain != null">
- and a.expense_main= #{expenseMain}
- </if>
- <if test="secondaryType != null">
- and a.secondary_type= #{secondaryType}
- </if>
- </sql>
- <select id="selectExpenseAccountCount" resultType="java.lang.Integer">
- select count(*)
- from expense_account a
- <if test="type !=null">
- right join (select a.id
- from expense_account a left join expense_relationship b on a.id =b.id
- left join expense_account c on b.ea_id =c.id
- where c.`type` = #{type})x on a.id=x.id
- </if>
- left join admin d on a.aid =d.id left join department f on d.department_id =f.id
- left join admin d2 on f.finance_id =d2.id
- <if test="expenseMain ==0">
- left join expense_relationship er on a.id=er.ea_id
- left join expense_account mea on er.id=mea.id
- left join t_order_new e on mea.order_no =e.order_no
- left join department b on mea.apply_dep =b.id left join department c on mea.pay_dep =c.id
- </if>
- <if test="expenseMain ==1">
- left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
- </if>
- <if test="processStatus ==1">
- inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
- where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
- </if>
- <include refid="selectExpenseAccountSql"/>
- </select>
- <select id="selectExpenseAccountTotalAmount" resultType="java.util.Map">
- select sum(a.amount) totalAmount
- from expense_account a
- <if test="type !=null">
- right join (select a.id
- from expense_account a left join expense_relationship b on a.id =b.id
- left join expense_account c on b.ea_id =c.id
- where c.`type` = #{type})x on a.id=x.id
- </if>
- left join admin d on a.aid =d.id left join department f on d.department_id =f.id
- <if test="expenseMain ==0">
- left join expense_relationship er on a.id=er.ea_id
- left join expense_account mea on er.id=mea.id
- left join t_order_new e on mea.order_no =e.order_no
- left join department b on mea.apply_dep =b.id left join department c on mea.pay_dep =c.id
- </if>
- <if test="expenseMain ==1">
- left join t_order_new e on a.order_no =e.order_no
- left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
- </if>
- <if test="processStatus ==1">
- inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
- where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
- </if>
- <include refid="selectExpenseAccountSql"/>
- </select>
- <select id="selectByaidAndPrid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
- SELECT
- <include refid="selectDtailsSql"/>
- WHERE 1=1 and a.status < 4
- <if test="status !=null">
- and a.status= #{status}
- </if>
- and a.prid= #{prid} and a.aid = #{aid}
- </select>
- <select id="selectByaidAndType" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
- SELECT
- a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
- a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,a.debit_id debitId,
- a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,a.district_name districtName,
- a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name applyDepName,
- c.name payDepName,d.name ,d.bank ,d.accounts ,t0.amount settlementAmount,a.check_no checkNo,
- a.liquidation_status liquidationStatus, a.remarks,a.real_amount realAmount,
- date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
- date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
- date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
- FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
- left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
- left join t_order_mid tm on a.order_no =tm.order_no
- left join (select debit_id ,sum(settlement_amount) amount from expense_account where debit_id is not null and
- id != #{id} group by debit_id )t0 on a.id =t0.debit_id
- WHERE a.status=2 and a.liquidation_status in (0,1,2)
- and a.aid= #{aid} and a.type= #{type} and a.pay_dep= #{depId}
- order by a.create_time desc
- </select>
- <select id="selectStatistics" resultType="com.goafanti.expenseAccount.bo.OutMyEAStatistics">
- select a.aid,a.aname ,a.type,a.status ,a.amount totalAmount ,ifnull(a.debit_id,0) debitId ,a.target_type targetType ,ifnull(a2.settlement_amount,0) bxdkAmount
- from expense_account a
- left join expense_account a2 on a.debit_id =a2.id left join admin ad on a.aid=ad.id
- left join department dep on ad.department_id=dep.id
- where 1=1 and a.expense_main=0 and a.status>0
- <if test="lander != null">
- and dep.finance_id = #{lander}
- </if>
- <if test="name != null">
- and a.aname like concat('%',#{name},'%')
- </if>
- <if test="depId != null">
- and ad.department_id = #{depId}
- </if>
- <if test="startTime != null and endTime != null">
- and a.create_time between #{startTime} and #{endTime}
- </if>
- </select>
- <select id="selectByDebitId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from expense_account
- where debit_id = #{debitId}
- </select>
- <select id="selectByCheckNoNot" parameterType="java.lang.Integer" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from expense_account
- where check_no =''
- </select>
- <select id="selectCountByFinance" resultType="com.goafanti.common.model.FinanceCount">
- select x.aid, x.dates dateTime, count(*)expenseCount, sum(if(x.process_status = 1, 1, 0))expenseUnauditedCount
- from (select c.finance_id aid , a.process_status, DATE_FORMAT(a.create_time , '%Y-%m-%d') dates
- from expense_account a left join admin b on a.aid=b.id left join department c on b.department_id =c.id
- where a.status in (1, 2) and a.process_status >0 and c.finance_id = #{aid})x
- group by x.aid, x.dates;
- </select>
- <select id="selectByIds" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from expense_account
- where id in
- <foreach collection="list" open="(" close=")" separator="," item="id">
- #{id}
- </foreach>
- </select>
- <select id="selectByMainId" resultMap="MainMap">
- select b.id,b.check_no,b.total_amount,b.amount,b.aname,b.apply_dep,b.pay_dep,b.real_amount,b.type_other ,b.aid,
- date_format(b.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,b.examine_name, dep.name applyDepName,dep2.name payDepName,
- b.remarks,b.eaaid ,eap.name ,eap.bank ,eap.accounts ,b.status,b.process_status,
- c.id sonId,c.total_amount sonTotalAmount,c.settlement_amount sonSettlementAmount,c.amount sonAmount, c.`type` sonType,c.type_other sonTypeOther,
- c.user_names ,c.release_start ,c.release_end , c.district_name districtName,c.user_names userNames,c.secondary_type ,c.secondary_type_other,c.attachment_url,
- c.duration,pr.plan,c.real_amount sonRealAmount,o.order_no,o.contract_no,pr.type publicReleaseType,
- c.debit_id debitId, debit.real_amount DebitRealAmount ,debit.settlement_amount DebitSettlementAmount,debit.liquidation_status DebitliquidationStatus,
- d.id detId,d.`type` detType,d.amount detAmount,d.real_amount detRealAmount ,d.start_district ,d.end_district,d.vehicle,d.vehicle_other,
- d.pay_type ,d.invoice_type ,d.invoice_no,d.payer_name ,d.open_bank ,d.bank_accounts ,d.open_bank_address,d.type_other detTypeOther,
- date_format(d.start_time,'%Y-%m-%d %H:%i:%S')startTime,date_format(d.end_time,'%Y-%m-%d %H:%i:%S')endTime,
- date_format(d.agree_time,'%Y-%m-%d')agreeTime
- from expense_relationship a left join expense_account b on a.id =b.id left join expense_account c on a.ea_id =c.id
- left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
- left join expense_account_private eap on b.eaaid =eap.id left join expense_account_details d on c.id =d.eaid
- left join t_order_new o on c.order_no =o.order_no left join public_release pr on c.prid=pr.id left join t_order_new pro on pr.order_no=pro.order_no
- left join expense_account debit on c.debit_id=debit.id
- where a.id= #{id}
- </select>
- <select id="selectListByMainId" resultMap="BaseResultMap">
- select b.*
- from expense_relationship a left join expense_account b on a.ea_id =b.id
- where a.id =#{id}
- </select>
- <resultMap id="MainMap" type="com.goafanti.expenseAccount.bo.MainExpenseAccount">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="check_no" jdbcType="VARCHAR" property="checkNo" />
- <result column="aid" jdbcType="VARCHAR" property="aid" />
- <result column="type_other" jdbcType="VARCHAR" property="typeOther" />
- <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
- <result column="real_amount" jdbcType="DECIMAL" property="realAmount" />
- <result column="amount" jdbcType="DECIMAL" property="amount" />
- <result column="aname" jdbcType="VARCHAR" property="aname" />
- <result column="apply_dep" jdbcType="VARCHAR" property="applyDep" />
- <result column="pay_dep" jdbcType="VARCHAR" property="payDep" />
- <result column="applyDepName" jdbcType="VARCHAR" property="applyDepName" />
- <result column="payDepName" jdbcType="VARCHAR" property="payDepName" />
- <result column="remarks" jdbcType="VARCHAR" property="remarks" />
- <result column="eaaid" jdbcType="INTEGER" property="eaaid" />
- <result column="name" jdbcType="VARCHAR" property="name" />
- <result column="bank" jdbcType="VARCHAR" property="bank" />
- <result column="accounts" jdbcType="VARCHAR" property="accounts" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="process_status" jdbcType="INTEGER" property="processStatus" />
- <result column="createTimeStr" jdbcType="VARCHAR" property="createTimeStr" />
- <result column="examine_name" jdbcType="VARCHAR" property="examineName" />
- <association property="sonList" resultMap="SonExpenseAccountMap"/>
- </resultMap>
- <resultMap id="SonExpenseAccountMap" type="com.goafanti.expenseAccount.bo.SonExpenseAccount">
- <id column="sonId" jdbcType="INTEGER" property="id" />
- <result column="prid" jdbcType="INTEGER" property="prid" />
- <result column="sonTotalAmount" jdbcType="DECIMAL" property="totalAmount" />
- <result column="sonSettlementAmount" jdbcType="DECIMAL" property="settlementAmount" />
- <result column="sonRealAmount" jdbcType="DECIMAL" property="realAmount" />
- <result column="sonAmount" jdbcType="DECIMAL" property="amount" />
- <result column="sonType" jdbcType="INTEGER" property="type" />
- <result column="sonTypeOther" jdbcType="VARCHAR" property="typeOther" />
- <result column="secondary_type" jdbcType="INTEGER" property="secondaryType" />
- <result column="secondary_type_other" jdbcType="INTEGER" property="secondaryTypeOther" />
- <result column="attachment_url" jdbcType="INTEGER" property="attachmentUrl" />
- <result column="user_names" jdbcType="VARCHAR" property="userNames" />
- <result column="release_start" jdbcType="VARCHAR" property="releaseStart" />
- <result column="release_end" jdbcType="VARCHAR" property="releaseEnd" />
- <result column="districtName" jdbcType="VARCHAR" property="districtName" />
- <result column="duration" jdbcType="VARCHAR" property="duration" />
- <result column="plan" jdbcType="VARCHAR" property="plan" />
- <result column="debitId" jdbcType="INTEGER" property="debitId" />
- <result column="debitRealAmount" jdbcType="DECIMAL" property="debitRealAmount" />
- <result column="debitSettlementAmount" jdbcType="DECIMAL" property="debitSettlementAmount" />
- <result column="debitLiquidationStatus" jdbcType="INTEGER" property="debitLiquidationStatus" />
- <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
- <result column="contract_no" jdbcType="VARCHAR" property="contractNo" />
- <result column="publicReleaseType" jdbcType="INTEGER" property="publicReleaseType" />
- <association property="detList" resultMap="ExpenseAccountDetailsMap"/>
- </resultMap>
- <resultMap id="ExpenseAccountDetailsMap" type="com.goafanti.expenseAccount.bo.SonExpenseAccountDetails">
- <id column="detId" jdbcType="INTEGER" property="id" />
- <result column="detType" jdbcType="INTEGER" property="type" />
- <result column="detTypeOther" jdbcType="INTEGER" property="typeOther" />
- <result column="detAmount" jdbcType="DECIMAL" property="amount" />
- <result column="detRealAmount" jdbcType="DECIMAL" property="realAmount" />
- <result column="start_district" jdbcType="VARCHAR" property="startDistrict" />
- <result column="end_district" jdbcType="VARCHAR" property="endDistrict" />
- <result column="vehicle" jdbcType="INTEGER" property="vehicle" />
- <result column="vehicle_other" jdbcType="VARCHAR" property="vehicleOther" />
- <result column="pay_type" jdbcType="INTEGER" property="payType" />
- <result column="invoice_type" jdbcType="INTEGER" property="invoiceType" />
- <result column="invoice_no" jdbcType="VARCHAR" property="invoiceNo" />
- <result column="payer_name" jdbcType="VARCHAR" property="payerName" />
- <result column="open_bank" jdbcType="VARCHAR" property="openBank" />
- <result column="bank_accounts" jdbcType="VARCHAR" property="bankAccounts" />
- <result column="open_bank_address" jdbcType="VARCHAR" property="openBankAddress" />
- <result column="startTime" jdbcType="VARCHAR" property="startTime" />
- <result column="endTime" jdbcType="VARCHAR" property="endTime" />
- <result column="agreeTime" jdbcType="VARCHAR" property="agreeTime" />
- </resultMap>
- <update id="updateByIds" >
- update expense_account
- set status= #{status}
- where id in
- <foreach collection="list" open="(" close=")" separator="," item="item">
- #{item.id}
- </foreach>
- </update>
- <update id="updateByMainId">
- update expense_relationship a ,expense_account b
- set b.status= #{status}
- where a.id= #{id} and a.ea_id=b.id
- </update>
- <update id="updateSonByDetId">
- update expense_account x ,(select b.id,sum(c.real_amount) amount
- from expense_account_details a left join expense_account b on a.eaid =b.id
- left join expense_account_details c on b.id =c.eaid
- where a.id= #{id} group by b.id)y
- set x.real_amount =y.amount
- where x.id=y.id;
- </update>
- <update id="updateMainByDetId">
- update expense_account x ,( select a.id,sum(c.real_amount)amount
- from expense_account a left join expense_relationship b on a.id=b.id
- left join expense_account c on b.ea_id =c.id
- where a.id in(select c.id
- from expense_account_details a left join expense_account b on a.eaid =b.id
- left join expense_relationship c on b.id =c.ea_id
- where a.id= #{id}) group by a.id)y
- set x.real_amount =y.amount
- where x.id=y.id
- </update>
- <update id="updateDeleteDebitId">
- update expense_account
- set debit_id=null,settlement_amount=0
- where id= #{id}
- </update>
- <update id="updateSonByMainId">
- update expense_relationship a left join expense_account b on a.id =b.id
- left join expense_account c on a.ea_id =c.id
- set c.status =b.status ,c.process_status =b.process_status
- where a.id= #{id}
- </update>
- <select id="ExpenseMainList" resultMap="MainMap">
- select b.id,b.check_no,b.total_amount,b.real_amount ,b.order_no,o.contract_no ,b.aname,b.apply_dep,b.pay_dep,b.amount,
- date_format(b.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,b.status,b.process_status,b.examine_name,
- dep.name applyDepName,dep2.name payDepName, b.remarks,b.eaaid
- from expense_account b left join department dep on b.apply_dep =dep.id
- left join department dep2 on b.pay_dep =dep2.id left join t_order_new o on b.order_no =o.order_no
- left join admin ad on b.aid=ad.id
- left join department adDep on ad.department_id=adDep.id
- <if test="roleType > 0">
- inner join (select eaid ,auditor,min(process_status)`type`,status from expense_account_examine
- where auditor= #{aid}
- <if test="listStatus ==0"> and status=0 </if>
- <if test="listStatus ==1"> and status=1 </if>
- group by eaid) eae on b.id=eae.eaid
- </if>
- <if test="username !=null">
- left join expense_relationship er on er.id=b.id
- left join expense_account ea2 on ea2.id=er.ea_id
- </if>
- <include refid="ExpenseMainSql"/>
- order by if(b.status=3,-1,b.status) ,b.create_time desc
- ${page_sql}
- </select>
- <sql id="ExpenseMainSql">
- where 1=1 and b.expense_main =1 and b.status < 4
- <if test="checkNo !=null">
- and b.check_no like concat('%',#{checkNo},'%')
- </if>
- <if test=" status != null">
- and b.status = #{status}
- </if>
- <if test=" roleType ==0">
- and b.aid = #{aid}
- <if test="listStatus ==0">
- and b.status >=0
- </if>
- <if test="listStatus ==1">
- and b.status =2
- </if>
- </if>
- <if test="roleType > 0">
- <if test="listStatus ==0">
- and b.process_status =eae.type
- and eae.status=0
- </if>
- <if test="listStatus ==1">
- and b.process_status >= eae.type
- and eae.status=1
- </if>
- </if>
- <if test="startTime !=null and endTime !=null ">
- and b.create_time between #{startTime} and #{endTime}
- </if>
- <if test="username !=null">
- and ea2.user_names like concat('%',#{username},'%')
- </if>
- </sql>
- <select id="ExpenseMainCount" resultType="java.lang.Integer">
- select count(*)
- from expense_account b
- <if test="username !=null">
- left join expense_relationship er on er.id=b.id
- left join expense_account ea2 on ea2.id=er.ea_id
- </if>
- left join admin ad on b.aid=ad.id left join department adDep on ad.department_id=adDep.id
- <if test="roleType > 0">
- inner join (select eaid ,auditor,min(process_status)`type`,status from expense_account_examine
- where auditor= #{aid}
- <if test="listStatus ==0"> and status=0 </if>
- <if test="listStatus ==1"> and status=1 </if>
- group by eaid) eae on b.id=eae.eaid
- </if>
- <include refid="ExpenseMainSql"/>
- </select>
- <select id="ExpenseDetailsList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountDetailsList">
- select mea.check_no checkNo ,ead.`type`,ead.type_other typeOther,
- ead.amount ,ead.real_amount realAmount ,o.contract_no contractNo ,dep.name applyDepName,
- a.id sonId,a.type sonType ,a.type_other sonTypeOther ,a.release_start releaseStart ,a.release_end releaseEnd ,a.duration ,ROUND(a.duration/7.5) days,
- dep2.name payDepName ,a.aname ,ad2.name financeName,mea.status ,mea.process_status processStatus ,mea.id mainId,a.target_type targetType,
- tm.buyer_name buyerName ,date_format(mea.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr
- from expense_account_details ead left join expense_account a on ead.eaid =a.id
- left join expense_relationship er on a.id=er.ea_id left join expense_account mea on er.id=mea.id
- left join t_order_new o on a.order_no =o.order_no left join t_order_mid tm on o.order_no =tm.order_no
- left join department dep on mea.apply_dep =dep.id
- left join department dep2 on mea.pay_dep =dep2.id left join admin ad on a.aid=ad.id
- left join department dep3 on ad.department_id =dep3.id left join admin ad2 on dep.expense_finance_id =ad2.id
- where 1=1
- <include refid="ExpenseDetailsSql"/>
- ${page_sql}
- </select>
- <sql id="ExpenseDetailsSql">
- <if test=" status != null">
- and mea.status = #{status}
- </if>
- <if test=" aid != null">
- and a.aid= #{aid}
- </if>
- <if test="deps !=null">
- and ad.department_id in
- <foreach collection="deps" item="dep" open="(" close=")" separator=",">
- #{dep}
- </foreach>
- </if>
- <if test="roleType ==1">
- and dep.expense_finance_id = #{current}
- </if>
- <if test="roleType ==2">
- and (dep.expense_finance_id in (select id from admin where superior_id = #{current}) or dep.expense_finance_id = #{current})
- </if>
- <if test=" contractNo != null">
- and o.contract_no like concat('%',#{contractNo},'%')
- </if><if test=" buyerName != null">
- and tm.buyer_name like concat('%','buyerName','%')
- </if><if test=" type != null">
- and ead.`type` = #{type}
- </if><if test=" aname != null">
- and mea.aname like concat('%',#{aname},'%')
- </if><if test=" applyDep != null">
- and mea.apply_dep =#{applyDep}
- </if><if test=" payDep != null">
- and mea.pay_dep =#{payDep}
- </if><if test=" startTime != null and endTime !=null">
- and mea.create_time between #{startTime} and #{endTime}
- </if><if test=" checkNo != null">
- and mea.check_no like concat('%',#{checkNo},'%')
- </if>
- </sql>
- <select id="ExpenseDetailsCount" resultType="java.lang.Integer">
- select count(*)
- from expense_account_details ead left join expense_account a on ead.eaid =a.id
- left join expense_relationship er on a.id=er.ea_id left join expense_account mea on er.id=mea.id
- left join t_order_new o on mea.order_no =o.order_no left join t_order_mid tm on o.order_no =tm.order_no
- left join department dep on mea.apply_dep =dep.id
- left join department dep2 on mea.pay_dep =dep2.id left join admin ad on mea.aid=ad.id
- left join department dep3 on ad.department_id =dep3.id left join admin ad2 on dep3.finance_id =ad2.id
- where 1=1
- <include refid="ExpenseDetailsSql"/>
- </select>
- <select id="ExpenseDetailsTotalAmount" resultType="java.util.Map">
- select sum(ead.amount) totalAmount
- from expense_account_details ead left join expense_account a on ead.eaid =a.id
- left join expense_relationship er on a.id=er.ea_id left join expense_account mea on er.id=mea.id
- left join t_order_new o on mea.order_no =o.order_no left join t_order_mid tm on o.order_no =tm.order_no
- left join department dep on mea.apply_dep =dep.id
- left join department dep2 on mea.pay_dep =dep2.id left join admin ad on mea.aid=ad.id
- left join department dep3 on ad.department_id =dep3.id left join admin ad2 on dep3.finance_id =ad2.id
- where 1=1
- <include refid="ExpenseDetailsSql"/>
- </select>
- <select id="selectCountByIdsAndType" resultType="java.lang.Integer">
- select count(*) from expense_account
- where type =#{type}
- and id in
- <foreach collection="list" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </select>
- <select id="selectAllMain" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from expense_account
- where expense_main=1
- </select>
- <select id="selectSonByMainIds" resultMap="MainMap">
- select b.id,
- c.id sonId,c.total_amount sonTotalAmount,c.settlement_amount sonSettlementAmount,c.amount sonAmount,c.real_amount sonRealAmount,
- c.`type` sonType,c.type_other sonTypeOTher, c.user_names ,c.release_start ,c.release_end,c.prid,
- c.attachment_url attachmentUrl,c.secondary_type,c.secondary_type_other
- from expense_relationship a
- left join expense_account b on a.id =b.id
- left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
- left join t_order_new o on b.order_no =o.order_no left join expense_account c on a.ea_id =c.id
- left join admin ad on b.aid=ad.id left join department adDep on ad.department_id=adDep.id
- where b.id in
- <foreach collection="list" separator="," open="(" close=")" item="id">
- #{id}
- </foreach>
- </select>
- <select id="selectbySonId" resultMap="MainMap">
- select b.id id,
- c.id sonId,c.total_amount sonTotalAmount,c.settlement_amount sonSettlementAmount,c.amount sonAmount,c.real_amount sonRealAmount,
- c.`type` sonType,c.type_other sonTypeOTher, c.user_names ,c.release_start ,c.release_end,
- c.attachment_url attachmentUrl,c.secondary_type,c.secondary_type_other
- from expense_relationship a
- left join expense_account b on a.id =b.id
- left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
- left join t_order_new o on b.order_no =o.order_no left join expense_account c on a.ea_id =c.id
- left join admin ad on b.aid=ad.id left join department adDep on ad.department_id=adDep.id
- where b.id in (select id from expense_relationship where ea_id = #{id} )
- </select>
- <select id="selectDeleteIdBySonId" resultType="java.lang.Integer">
- select b.id
- from expense_account a left join expense_relationship b on a.id =b.ea_id
- left join expense_account c on b.id =c.id
- where a.id= #{id} and c.id is null
- </select>
- <update id="updateSonTypeOther">
- update expense_account a
- set a.type_other = #{types}
- where a.id in (select id from expense_relationship where ea_id = #{id} )
- </update>
- </mapper>
|