| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028 |
- <?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" />
- </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
- </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
- )
- 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}
- )
- </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>
- </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>
- </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>
- </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}
- 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.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name appDepName,
- 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,
- 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
- </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.target_type targetType , e.contract_no contractNo,tm.buyer_name buyerName ,
- a.secondary_type secondaryType, a.secondary_type_other secondaryTypeOther,a.status,
- date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
- 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,
- </if>
- <if test="expenseMain ==1">
- a.examine_name examineName,a.check_no checkNo,
- </if>
- f.name depName,d2.name financeName, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,a.aname,
- b.name appDepName, c.name payDepName
- from expense_account a
- left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
- left join t_order_mid tm on a.order_no =tm.order_no 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.id
- left join expense_account mea on er.ea_id=mea.id
- 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>
- where 1=1
- <if test="processStatus ==2">
- and a.process_status>=0
- <if test="examineStatus ==1">
- and a.status=1
- </if>
- <if test="examineStatus ==2">
- and a.status=2
- </if>
- </if>
- <if test=" aid !=null">
- and a.aid= #{aid}
- </if>
- <if test="processStatus ==1">
- and a.process_status>0
- <if test="examineStatus ==0">
- and a.process_status =eae.`type`
- </if>
- <if test="examineStatus ==1">
- and a.process_status >eae.`type`
- </if>
- </if>
- <if test="status != null">
- and a.status= #{status}
- </if>
- <if test="type != null">
- and a.type= #{type}
- </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 tm.buyer_name 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 = #{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>
- order by a.status,a.create_time desc
- <if test="page_sql !=null">
- ${page_sql}
- </if>
- </select>
- <select id="selectExpenseAccountCount" resultType="java.lang.Integer">
- select count(*)
- 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 admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
- left join t_order_mid tm on a.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>
- where 1=1
- <if test="processStatus ==2">
- and a.process_status>=0
- <if test="examineStatus ==1">
- and a.status=1
- </if>
- <if test="examineStatus ==2">
- and a.status=2
- </if>
- </if>
- <if test=" aid !=null">
- and a.aid= #{aid}
- </if>
- <if test="processStatus ==1">
- and a.process_status>0
- <if test="examineStatus ==0">
- and a.process_status =eae.`type`
- </if>
- <if test="examineStatus ==1">
- and a.process_status >eae.`type`
- </if>
- </if>
- <if test="status != null">
- and a.status= #{status}
- </if>
- <if test="type != null">
- and a.type= #{type}
- </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 tm.buyer_name 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 = #{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>
- </select>
- <select id="selectExpenseAccountTotalAmount" resultType="java.lang.Integer">
- select sum(a.total_amount) totalAmount
- 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 admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
- left join t_order_mid tm on a.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>
- where 1=1
- <if test="processStatus ==2">
- and a.process_status>=0
- <if test="examineStatus ==1">
- and a.status=1
- </if>
- <if test="examineStatus ==2">
- and a.status=2
- </if>
- </if>
- <if test=" aid !=null">
- and a.aid= #{aid}
- </if>
- <if test="processStatus ==1">
- and a.process_status>0
- <if test="examineStatus ==0">
- and a.process_status =eae.`type`
- </if>
- <if test="examineStatus ==1">
- and a.process_status >eae.`type`
- </if>
- </if>
- <if test="status != null">
- and a.status= #{status}
- </if>
- <if test="type != null">
- and a.type= #{type}
- </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 tm.buyer_name 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 = #{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>
- </select>
- <select id="selectByaidAndPrid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
- SELECT
- <include refid="selectDtailsSql"/>
- WHERE a.status= #{status}
- 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 appDepName,
- c.name payDepName,d.name ,d.bank ,d.accounts ,t0.amount settlementAmount,a.check_no checkNo,
- a.liquidation_status liquidationStatus, a.remarks,
- 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.total_amount totalAmount ,ifnull(a.debit_id,0) debitId ,a.target_type targetType ,ifnull(a2.total_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
- where 1=1 and a.expense_main=0
- <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">
- <include refid="mainAllSql"/>
- where a.id= #{id}
- </select>
- <sql id="mainAllSql">
- select b.id,b.check_no,b.total_amount,b.order_no,o.contract_no,b.aname,b.apply_dep,b.pay_dep,b.real_amount,
- 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 sonAmount,c.`type` ,c.type_other ,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,
- d.id detId,d.`type` detType,d.amount,d.real_amount realAmount ,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
- 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_private eap on b.eaaid =eap.id
- left join expense_account c on a.ea_id =c.id left join expense_account_details d on c.id =d.eaid
- </sql>
- <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="total_amount" jdbcType="DECIMAL" property="totalAmount" />
- <result column="real_amount" jdbcType="DECIMAL" property="realAmount" />
- <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
- <result column="contract_no" jdbcType="VARCHAR" property="contractNo" />
- <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"></association>
- </resultMap>
- <resultMap id="SonExpenseAccountMap" type="com.goafanti.expenseAccount.bo.SonExpenseAccount">
- <id column="sonId" jdbcType="INTEGER" property="id" />
- <result column="sonAmount" jdbcType="DECIMAL" property="totalAmount" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="type_other" 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" />
- <association property="detList" resultMap="ExpenseAccountDetailsMap"></association>
- </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="amount" jdbcType="DECIMAL" property="amount" />
- <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" />
- </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>
- <select id="ExpenseMainList" resultMap="MainMap">
- select b.id,b.check_no,b.total_amount,b.order_no,o.contract_no,b.aname,b.apply_dep,b.pay_dep,
- date_format(a.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 ,
- c.id sonId,c.total_amount sonAmount,c.`type` ,c.type_other ,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 1=1 and b.expense_main =1
- <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>
- <if test="roleType == 1">
- <if test="listStatus ==0">
- and b.process_status =1
- </if>
- <if test="listStatus ==1">
- and b.process_status > 1
- </if>
- and ad.superior_id= #{aid}
- </if>
- <if test="roleType == 2">
- <if test="listStatus ==0">
- and b.process_status =2
- </if>
- <if test="listStatus ==1">
- and b.process_status > 2
- </if>
- and adDep.finance_id = #{aid}
- </if>
- <if test="roleType == 3">
- <if test="listStatus ==0">
- and b.process_status =3
- </if>
- <if test="listStatus ==1">
- and b.process_status > 3
- </if>
- and ad.department_id in
- <foreach collection="deps" item="dep" open="(" close=")" separator=",">
- #{dep}
- </foreach>
- </if>
- ${page_sql}
- </select>
- <select id="ExpenseMainCount" resultType="java.lang.Integer">
- select count(*)
- from expense_account b
- left join admin ad on b.aid=ad.id
- left join department adDep on ad .department_id=adDep.id
- where 1=1 and b.expense_main =1
- <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>
- <if test="roleType == 1">
- <if test="listStatus ==0">
- and b.process_status =1
- </if>
- <if test="listStatus ==1">
- and b.process_status > 1
- </if>
- and ad.superior_id= #{aid}
- </if>
- <if test="roleType == 2">
- <if test="listStatus ==0">
- and b.process_status =2
- </if>
- <if test="listStatus ==1">
- and b.process_status > 2
- </if>
- and adDep.finance_id = #{aid}
- </if>
- <if test="roleType == 3">
- <if test="listStatus ==0">
- and b.process_status =3
- </if>
- <if test="listStatus ==1">
- and b.process_status > 3
- </if>
- and ad.department_id in
- <foreach collection="deps" item="dep" open="(" close=")" separator=",">
- #{dep}
- </foreach>
- </if>
- </select>
- <select id="ExpenseDetailsList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountDetailsList">
- select mea.check_no ,ead.`type`,ead.amount ,ead.real_amount ,o.contract_no ,dep.name applyDepName,
- dep2.name payDepName ,mea.aname ,ad2.name financeName,mea.status ,mea.process_status ,mea.id mainId,
- 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 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
- <if test=" status != null">
- and mea.status = #{status}
- </if>
- <if test="deps !=null">
- and ad.department_id in
- <foreach collection="deps" item="dep" open="(" close=")" separator=",">
- #{dep}
- </foreach>
- </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>
- ${page_sql}
- </select>
- <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
- <if test=" status != null">
- and mea.status = #{status}
- </if>
- <if test="deps !=null">
- and ad.department_id in
- <foreach collection="deps" item="dep" open="(" close=")" separator=",">
- #{dep}
- </foreach>
- </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>
- </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>
- </mapper>
|