762 lines
30 KiB
XML
762 lines
30 KiB
XML
<?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.bonus.boot.manager.ca.im.dao.PayableDao">
|
|
|
|
<insert id="add">
|
|
insert into ca_im_payable (rq,
|
|
pzh,
|
|
htmc,
|
|
gysmc,
|
|
spbh,
|
|
je,
|
|
fphm,
|
|
kpje,
|
|
zdr,
|
|
spzy,
|
|
account_id,
|
|
person_num,
|
|
OPER_USER,
|
|
OPER_TIME,
|
|
IS_ACTIVE
|
|
)
|
|
values (#{rq},#{pzh},#{htmcid},#{gysmc},#{spbh},#{je},#{fphm},#{kpje},#{zdr},#{spzy},#{accountId},#{personNum},#{czy},now(),'1')
|
|
</insert>
|
|
|
|
<update id="update">
|
|
update ca_im_payable
|
|
set rq = #{rq},
|
|
pzh = #{pzh},
|
|
htmc = #{htmcid},
|
|
gysmc = #{gysmc},
|
|
spbh = #{spbh},
|
|
JE = #{je},
|
|
fphm = #{fphm},
|
|
kpje = #{kpje},
|
|
spzy = #{spzy},
|
|
account_id = #{accountId},
|
|
person_num = #{personNum},
|
|
zdr = #{zdr},
|
|
oper_user = #{czy},
|
|
oper_time = now()
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="del">
|
|
update ca_im_payable
|
|
set is_active = '0',oper_user = #{czy},oper_time = now()
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<select id="getCount" resultType="java.lang.Integer">
|
|
SELECT count(1) FROM(
|
|
select
|
|
cip.rq,
|
|
cip.pzh,
|
|
cbsi.CONTRACT_OR_PRO_NAME as htmc,
|
|
cip.gysmc,
|
|
cbgi.code as spbh,
|
|
cbgi.name as spmc,
|
|
cip.je,
|
|
cip.fphm,
|
|
cip.kpje,
|
|
su.username as zdr,
|
|
cip.spzy
|
|
from ca_im_payable cip
|
|
left join ca_bm_supplier_info cbsi on cbsi.is_active = '1' and cbsi.id = cip.htmc
|
|
left join ca_bm_goods_info cbgi on cbgi.is_active = '1' and cbgi.id = cip.spbh
|
|
left join sys_user su on su.is_active = '1' and su.id = cip.zdr
|
|
where cip.is_active = '1') a
|
|
where '1' = '1'
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and a.htmc like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and a.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.spbh != null and params.spbh !='' ">
|
|
and a.spbh like concat ('%',#{params.spbh},'%')
|
|
</if>
|
|
<if test="params.pzh != null and params.pzh !='' ">
|
|
and a.pzh like concat ('%',#{params.pzh},'%')
|
|
</if>
|
|
<if test="params.zdr != null and params.zdr !='' ">
|
|
and a.zdr like concat ('%',#{params.zdr},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
and a.rq between #{params.startTime} and #{params.endTime}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getList" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT * FROM(
|
|
select
|
|
cip.id,
|
|
cip.rq,
|
|
cip.pzh,
|
|
cbsi.CONTRACT_OR_PRO_NAME as htmc,
|
|
cip.gysmc,
|
|
cbgi.code as spbh,
|
|
cbgi.name as spmc,
|
|
cbgi.id as spid,
|
|
cip.je,
|
|
cip.fphm,
|
|
cip.kpje,
|
|
su.username as zdr,
|
|
su.id as zdrid,
|
|
cip.spzy,
|
|
cip.htmc as htmcid,
|
|
po.name as department,
|
|
cbpa.id as accountId,
|
|
cbpa.name as accountName,
|
|
cip.person_num as personNum
|
|
from ca_im_payable cip
|
|
left join ca_bm_supplier_info cbsi on cbsi.is_active = '1' and cbsi.id = cip.htmc
|
|
left join pm_organization po on po.id = cbsi.department and po.is_active = '1'
|
|
left join ca_bm_goods_info cbgi on cbgi.is_active = '1' and cbgi.id = cip.spbh
|
|
left join ca_bm_pay_account_info cbpa on cbpa.id = cip.account_id and cbgi.is_active = '1'
|
|
left join sys_user su on su.is_active = '1' and su.id = cip.zdr
|
|
where cip.is_active = '1') a
|
|
where '1' = '1'
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and a.htmc like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and a.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.spbh != null and params.spbh !='' ">
|
|
and a.spbh like concat ('%',#{params.spbh},'%')
|
|
</if>
|
|
<if test="params.pzh != null and params.pzh !='' ">
|
|
and a.pzh like concat ('%',#{params.pzh},'%')
|
|
</if>
|
|
<if test="params.zdr != null and params.zdr !='' ">
|
|
and a.zdr like concat ('%',#{params.zdr},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
and a.rq between #{params.startTime} and #{params.endTime}
|
|
</if>
|
|
<if test="params.accountId != null and params.accountId !='' ">
|
|
and a.accountId = #{params.accountId}
|
|
</if>
|
|
ORDER BY a.rq DESC
|
|
</select>
|
|
|
|
<select id="getNum" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT sum(CONVERT(a.je, DECIMAL(10,2))) as numje,
|
|
sum(CONVERT(a.kpje, DECIMAL(10,2))) as numkpje
|
|
FROM(
|
|
select
|
|
cip.id,
|
|
cip.rq,
|
|
cip.pzh,
|
|
cbsi.CONTRACT_OR_PRO_NAME as htmc,
|
|
cip.gysmc,
|
|
cbgi.code as spbh,
|
|
cbgi.name as spmc,
|
|
cip.je,
|
|
cip.fphm,
|
|
cip.kpje,
|
|
su.username as zdr,
|
|
cip.spzy,
|
|
cip.htmc as htmcid
|
|
from ca_im_payable cip
|
|
left join ca_bm_supplier_info cbsi on cbsi.is_active = '1' and cbsi.id = cip.htmc
|
|
left join ca_bm_goods_info cbgi on cbgi.is_active = '1' and cbgi.id = cip.spbh
|
|
left join sys_user su on su.is_active = '1' and su.id = cip.zdr
|
|
where cip.is_active = '1') a
|
|
where '1' = '1'
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and a.htmc like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and a.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.spbh != null and params.spbh !='' ">
|
|
and a.spbh like concat ('%',#{params.spbh},'%')
|
|
</if>
|
|
<if test="params.pzh != null and params.pzh !='' ">
|
|
and a.pzh like concat ('%',#{params.pzh},'%')
|
|
</if>
|
|
<if test="params.zdr != null and params.zdr !='' ">
|
|
and a.zdr like concat ('%',#{params.zdr},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
and a.rq between #{params.startTime} and #{params.endTime}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getById" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
select
|
|
cip.id,
|
|
cip.rq,
|
|
cip.pzh,
|
|
cbsi.CONTRACT_OR_PRO_NAME as htmc,
|
|
cip.gysmc,
|
|
cbgi.code as spbh,
|
|
cbgi.name as spmc,
|
|
cbgi.id as spid,
|
|
cip.je,
|
|
cip.fphm,
|
|
cip.kpje,
|
|
su.username as zdr,
|
|
su.id as zdrid,
|
|
cip.spzy,
|
|
cip.htmc as htmcid
|
|
from ca_im_payable cip
|
|
left join ca_bm_supplier_info cbsi on cbsi.is_active = '1' and cbsi.id = cip.htmc
|
|
left join ca_bm_goods_info cbgi on cbgi.is_active = '1' and cbgi.id = cip.spbh
|
|
left join sys_user su on su.is_active = '1' and su.id = cip.zdr
|
|
where cip.is_active = '1' and cip.id = #{id}
|
|
</select>
|
|
|
|
<select id="getUnitList" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT
|
|
cip.gysmc,
|
|
SUM(CONVERT(cip.je, DECIMAL(10,2))) AS bqyf,
|
|
b.count AS htsl,
|
|
c.ht
|
|
FROM
|
|
ca_im_payable AS cip
|
|
LEFT JOIN
|
|
(SELECT gysmc, COUNT(DISTINCT CONCAT(gysmc, '-', htmc)) AS count FROM ca_im_payable WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY gysmc) b
|
|
ON b.gysmc = cip.gysmc
|
|
LEFT JOIN
|
|
(SELECT
|
|
gysmc,
|
|
GROUP_CONCAT(DISTINCT htmc SEPARATOR ', ') AS ht
|
|
FROM
|
|
ca_im_payable WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY gysmc) c
|
|
ON c.gysmc = cip.gysmc
|
|
WHERE
|
|
cip.IS_ACTIVE = '1'
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and cip.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY cip.gysmc,c.ht,b.count
|
|
</select>
|
|
|
|
<select id="getUnitCount" resultType="java.lang.Integer">
|
|
select count(1) from(
|
|
SELECT
|
|
cip.gysmc,
|
|
SUM(cip.je) AS bqyf,
|
|
b.count AS htsl,
|
|
c.ht
|
|
FROM
|
|
ca_im_payable AS cip
|
|
LEFT JOIN
|
|
(SELECT gysmc, COUNT(DISTINCT CONCAT(gysmc, '-', htmc)) AS count FROM ca_im_payable WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY gysmc) b
|
|
ON b.gysmc = cip.gysmc
|
|
LEFT JOIN
|
|
(SELECT
|
|
gysmc,
|
|
GROUP_CONCAT(DISTINCT htmc SEPARATOR ', ') AS ht
|
|
FROM
|
|
ca_im_payable WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY gysmc) c
|
|
ON c.gysmc = cip.gysmc
|
|
WHERE
|
|
cip.IS_ACTIVE = '1'
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and cip.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY cip.gysmc) d
|
|
</select>
|
|
|
|
<select id="getPayableList" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT * FROM(
|
|
select
|
|
cip.id,
|
|
cip.rq,
|
|
cip.pzh,
|
|
cbsi.CONTRACT_OR_PRO_NAME as htmc,
|
|
cip.gysmc,
|
|
cbgi.code as spbh,
|
|
cbgi.name as spmc,
|
|
cip.je,
|
|
cip.fphm,
|
|
cip.kpje,
|
|
su.username as zdr,
|
|
cip.spzy,
|
|
cip.htmc as htmcid,
|
|
po.name as department,
|
|
cbpa.id as accountId,
|
|
cbpa.name as accountName,
|
|
cip.person_num as personNum
|
|
from ca_im_payable cip
|
|
left join ca_bm_supplier_info cbsi on cbsi.is_active = '1' and cbsi.id = cip.htmc
|
|
left join pm_organization po on po.id = cbsi.department and po.is_active = '1'
|
|
left join ca_bm_goods_info cbgi on cbgi.is_active = '1' and cbgi.id = cip.spbh
|
|
left join ca_bm_pay_account_info cbpa on cbpa.id = cip.account_id and cbgi.is_active = '1'
|
|
left join sys_user su on su.is_active = '1' and su.id = cip.zdr
|
|
where cip.is_active = '1') a
|
|
where '1' = '1'
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and a.htmc like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and a.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.spbh != null and params.spbh !='' ">
|
|
and a.spbh like concat ('%',#{params.spbh},'%')
|
|
</if>
|
|
<if test="params.pzh != null and params.pzh !='' ">
|
|
and a.pzh like concat ('%',#{params.pzh},'%')
|
|
</if>
|
|
<if test="params.zdr != null and params.zdr !='' ">
|
|
and a.zdr like concat ('%',#{params.zdr},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
and a.rq between #{params.startTime} and #{params.endTime}
|
|
</if>
|
|
<if test="params.accountId != null and params.accountId !='' ">
|
|
and a.accountId = #{params.accountId}
|
|
</if>
|
|
ORDER BY a.rq asc
|
|
</select>
|
|
|
|
<select id="getIdByName" resultType="java.lang.String">
|
|
select id
|
|
from sys_user
|
|
where is_active = '1' and username = #{username}
|
|
</select>
|
|
|
|
<select id="getHTMC" resultType="com.bonus.boot.manager.ca.bm.entity.SupplierInfoBean">
|
|
select DISTINCT CONTRACT_OR_PRO_NAME as htmc
|
|
from ca_bm_supplier_info
|
|
where is_active = '1'
|
|
</select>
|
|
|
|
<select id="getGYSMCByHTMC" resultType="com.bonus.boot.manager.ca.bm.entity.SupplierInfoBean">
|
|
select DISTINCT name
|
|
from ca_bm_supplier_info
|
|
where is_active = '1' and CONTRACT_OR_PRO_NAME = #{htmc}
|
|
</select>
|
|
<select id="getSPMC" resultType="com.bonus.boot.manager.ca.bm.entity.GoodsInfoBean">
|
|
select id,name
|
|
from ca_bm_goods_info
|
|
where is_active = '1'
|
|
</select>
|
|
|
|
<select id="getZDR" resultType="com.bonus.boot.manager.manager.model.SysUser">
|
|
select id,username
|
|
from sys_user
|
|
where is_active = '1'
|
|
</select>
|
|
|
|
<select id="getFKZH" resultType="com.bonus.boot.manager.ca.bm.entity.PayAccountInfoBean">
|
|
select id,name
|
|
from ca_bm_pay_account_info
|
|
where is_active = '1'
|
|
</select>
|
|
|
|
<select id="gethtmcid" resultType="java.lang.String">
|
|
select id
|
|
from ca_bm_supplier_info
|
|
where is_active = '1' and name = #{gysmc} and CONTRACT_OR_PRO_NAME = #{htmc}
|
|
</select>
|
|
|
|
<select id="getSqyfye" resultType="java.math.BigDecimal">
|
|
SELECT TRUNCATE(COALESCE((SELECT
|
|
sum(CONVERT(OPEN_DEBT, DECIMAL(10,2)))
|
|
FROM ca_bm_supplier_info
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="ht != null and ht.length > 0">
|
|
and id in
|
|
<foreach item="item" collection="ht" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>),0) +
|
|
COALESCE((SELECT sum(CONVERT(je, DECIMAL(10,2)))
|
|
FROM ca_im_payable
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
and rq < #{params.startTime}
|
|
</if>
|
|
<if test="ht != null and ht.length > 0">
|
|
and htmc in
|
|
<foreach item="item" collection="ht" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>),0), 2) as sqyfye
|
|
</select>
|
|
|
|
<select id="getykpye" resultType="java.math.BigDecimal">
|
|
SELECT TRUNCATE(COALESCE((SELECT
|
|
sum(CONVERT(OPEN_NOT_INV, DECIMAL(10,2)))
|
|
FROM ca_bm_supplier_info
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="gysmc != null and gysmc !='' ">
|
|
and name = #{gysmc}
|
|
</if>
|
|
),0) +
|
|
COALESCE((SELECT sum(CONVERT(je, DECIMAL(10,2)))
|
|
FROM ca_im_payable
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="gysmc != null and gysmc !='' ">
|
|
and gysmc = #{gysmc}
|
|
</if>),0), 2) as ykpje
|
|
</select>
|
|
|
|
<select id="getykpje" resultType="java.math.BigDecimal">
|
|
SELECT COALESCE(SUM(CONVERT(kpje, DECIMAL(10,2))), 0) as ykpje
|
|
FROM ca_im_payable
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="gysmc != null and gysmc !='' ">
|
|
and gysmc = #{gysmc}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getbqyif" resultType="java.math.BigDecimal">
|
|
SELECT COALESCE(SUM(CONVERT(je, DECIMAL(10,2))), 0) as bqyif
|
|
FROM ca_im_payment_details
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="ht != null and ht.length > 0">
|
|
and htmc in
|
|
<foreach item="item" collection="ht" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getUnitFormList" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT
|
|
cbsi.CONTRACT_OR_PRO_NAME AS htmc,
|
|
cip.htmc AS htmcid,
|
|
cip.gysmc,
|
|
SUM(CONVERT(cip.je, DECIMAL(10,2))) AS bqyf,
|
|
a.bqyif AS bqyif,
|
|
po.name as department
|
|
FROM ca_im_payable cip
|
|
LEFT JOIN ca_bm_supplier_info cbsi ON cbsi.IS_ACTIVE = '1' AND cbsi.id = cip.htmc
|
|
left join pm_organization po on po.id = cbsi.department and po.is_active = '1'
|
|
LEFT JOIN (
|
|
SELECT htmc, COALESCE(SUM(CONVERT(je, DECIMAL(10,2))), 0) AS bqyif
|
|
FROM ca_im_payment_details
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND rq BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY htmc
|
|
) a ON a.htmc = cip.htmc
|
|
WHERE cip.IS_ACTIVE = '1'
|
|
<if test="ht != null and ht.length > 0">
|
|
and cip.htmc in
|
|
<foreach item="item" collection="ht" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and cbsi.CONTRACT_OR_PRO_NAME like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and cip.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.rq BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY cip.gysmc, cip.htmc,a.bqyif,po.name
|
|
</select>
|
|
|
|
<select id="getSqyfye2" resultType="java.math.BigDecimal">
|
|
SELECT TRUNCATE(COALESCE((select CONVERT(OPEN_DEBT, DECIMAL(10,2))
|
|
from ca_bm_supplier_info
|
|
WHERE IS_ACTIVE = '1' and id = #{htid}),0) +
|
|
COALESCE((SELECT sum(CONVERT(je, DECIMAL(10,2)))
|
|
FROM ca_im_payable
|
|
WHERE IS_ACTIVE = '1' and htmc = #{htid}
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
and rq < #{params.startTime}
|
|
</if>),0), 2) as sqyfye
|
|
</select>
|
|
|
|
<select id="getykpye2" resultType="java.math.BigDecimal">
|
|
SELECT TRUNCATE(COALESCE((SELECT
|
|
CONVERT(OPEN_NOT_INV, DECIMAL(10,2))
|
|
FROM ca_bm_supplier_info
|
|
WHERE IS_ACTIVE = '1'
|
|
and id = #{htid}),0) +
|
|
COALESCE((SELECT sum(CONVERT(je, DECIMAL(10,2)))
|
|
FROM ca_im_payable
|
|
WHERE IS_ACTIVE = '1'
|
|
and htmc = #{htid}
|
|
),0), 2) as ykpje
|
|
</select>
|
|
|
|
<select id="getykpje2" resultType="java.math.BigDecimal">
|
|
SELECT COALESCE(SUM(CONVERT(kpje, DECIMAL(10,2))), 0) as ykpje
|
|
FROM ca_im_payable
|
|
WHERE IS_ACTIVE = '1'
|
|
and htmc = #{htid}
|
|
</select>
|
|
|
|
<select id="getUnitFormCount" resultType="java.lang.Integer">
|
|
select count(1)
|
|
from (SELECT cbsi.CONTRACT_OR_PRO_NAME AS htmc,
|
|
cip.htmc AS htmcid,
|
|
cip.gysmc,
|
|
SUM(cip.je) AS bqyf,
|
|
COALESCE(a.bqyif, 0) AS bqyif
|
|
FROM ca_im_payable cip
|
|
LEFT JOIN ca_bm_supplier_info cbsi ON cbsi.IS_ACTIVE = '1' AND cbsi.id = cip.htmc
|
|
LEFT JOIN (
|
|
SELECT htmc, COALESCE(SUM(je), 0) AS bqyif
|
|
FROM ca_im_payment_details
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND rq BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY htmc
|
|
) a ON a.htmc = cip.htmc
|
|
WHERE cip.IS_ACTIVE = '1'
|
|
<if test="ht != null and ht.length > 0">
|
|
and cip.htmc in
|
|
<foreach item="item" collection="ht" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and cbsi.CONTRACT_OR_PRO_NAME like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and cip.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.rq BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY cip.gysmc, cip.htmc) a
|
|
</select>
|
|
|
|
<select id="getUnitListExp" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT cip.id as id,
|
|
cip.gysmc,
|
|
SUM(CONVERT(cip.je, DECIMAL(10,2))) AS bqyf,
|
|
b.count AS htsl,
|
|
c.ht
|
|
FROM
|
|
ca_im_payable AS cip
|
|
LEFT JOIN
|
|
(SELECT gysmc, COUNT(DISTINCT CONCAT(gysmc, '-', htmc)) AS count FROM ca_im_payable WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY gysmc) b
|
|
ON b.gysmc = cip.gysmc
|
|
LEFT JOIN
|
|
(SELECT
|
|
gysmc,
|
|
GROUP_CONCAT(DISTINCT htmc SEPARATOR ', ') AS ht
|
|
FROM
|
|
ca_im_payable WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY gysmc) c
|
|
ON c.gysmc = cip.gysmc
|
|
WHERE
|
|
cip.IS_ACTIVE = '1'
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and cip.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY cip.id,cip.gysmc,b.count,c.ht
|
|
</select>
|
|
|
|
<select id="getUnitFormListExp" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT cip.id as id,
|
|
cbsi.CONTRACT_OR_PRO_NAME AS htmc,
|
|
cip.htmc AS htmcid,
|
|
cip.gysmc,
|
|
SUM(CONVERT(cip.je, DECIMAL(10,2))) AS bqyf,
|
|
a.bqyif AS bqyif,
|
|
po.name as department
|
|
FROM ca_im_payable cip
|
|
LEFT JOIN ca_bm_supplier_info cbsi ON cbsi.IS_ACTIVE = '1' AND cbsi.id = cip.htmc
|
|
left join pm_organization po on po.id = cbsi.department and po.is_active = '1'
|
|
LEFT JOIN (
|
|
SELECT htmc, COALESCE(SUM(CONVERT(je, DECIMAL(10,2))), 0) AS bqyif
|
|
FROM ca_im_payment_details
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND rq BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY htmc
|
|
) a ON a.htmc = cip.htmc
|
|
WHERE cip.IS_ACTIVE = '1'
|
|
<if test="ht != null and ht.length > 0">
|
|
and cip.htmc in
|
|
<foreach item="item" collection="ht" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and cbsi.CONTRACT_OR_PRO_NAME like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
<if test="params.gysmc != null and params.gysmc !='' ">
|
|
and cip.gysmc like concat ('%',#{params.gysmc},'%')
|
|
</if>
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.rq BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>
|
|
GROUP BY cip.id,cip.gysmc,cip.htmc,cip.gysmc,a.bqyif,po.name
|
|
</select>
|
|
|
|
<select id="getContractList" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT a.htmc,
|
|
a.gysmc as gysmc,
|
|
a.department as department,
|
|
SUM(CONVERT(a.je, DECIMAL(10,2))) AS bqyf,
|
|
COUNT(DISTINCT CONCAT(a.htmc, '-', gysmc)) AS gyssl,
|
|
GROUP_CONCAT(DISTINCT a.htmcid SEPARATOR ', ') AS ht
|
|
FROM(
|
|
SELECT
|
|
cbsi.CONTRACT_OR_PRO_NAME as htmc,
|
|
cip.gysmc,
|
|
cip.htmc as htmcid,
|
|
cip.je as je,
|
|
po.name as department
|
|
FROM
|
|
ca_im_payable AS cip
|
|
LEFT JOIN ca_bm_supplier_info cbsi on cbsi.IS_ACTIVE = '1' and cbsi.id = cip.htmc
|
|
left join pm_organization po on po.id = cbsi.department and po.is_active = '1'
|
|
WHERE
|
|
cip.IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>) a
|
|
where '1' = '1'
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and a.htmc like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
GROUP BY a.htmc,a.gysmc,a.department
|
|
</select>
|
|
<select id="getContractCount" resultType="java.lang.Integer">
|
|
select count(1)
|
|
from (
|
|
SELECT a.htmc,
|
|
SUM(a.je) AS bqyf,
|
|
COUNT(DISTINCT CONCAT(a.htmc, '-', gysmc)) AS gyssl,
|
|
GROUP_CONCAT(DISTINCT a.htmcid SEPARATOR ', ') AS ht
|
|
FROM(
|
|
SELECT
|
|
cbsi.CONTRACT_OR_PRO_NAME as htmc,
|
|
cip.gysmc,
|
|
cip.htmc as htmcid,
|
|
cip.je as je
|
|
FROM
|
|
ca_im_payable AS cip
|
|
LEFT JOIN ca_bm_supplier_info cbsi on cbsi.IS_ACTIVE = '1' and cbsi.id = cip.htmc
|
|
WHERE
|
|
cip.IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>) a
|
|
where '1' = '1'
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and a.htmc like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
GROUP BY a.htmc
|
|
) b
|
|
</select>
|
|
<select id="getContractListExp" resultType="com.bonus.boot.manager.ca.im.entity.PayableBean">
|
|
SELECT a.id,
|
|
a.htmc,
|
|
a.gysmc as gysmc,
|
|
a.department as department,
|
|
SUM(CONVERT(a.je, DECIMAL(10,2))) AS bqyf,
|
|
COUNT(DISTINCT CONCAT(a.htmc, '-', gysmc)) AS gyssl,
|
|
GROUP_CONCAT(DISTINCT a.htmcid SEPARATOR ', ') AS ht
|
|
FROM(
|
|
SELECT
|
|
cip.id,
|
|
cbsi.CONTRACT_OR_PRO_NAME as htmc,
|
|
cip.gysmc,
|
|
cip.htmc as htmcid,
|
|
cip.je as je,
|
|
po.name as department
|
|
FROM
|
|
ca_im_payable AS cip
|
|
LEFT JOIN ca_bm_supplier_info cbsi on cbsi.IS_ACTIVE = '1' and cbsi.id = cip.htmc
|
|
left join pm_organization po on po.id = cbsi.department and po.is_active = '1'
|
|
WHERE
|
|
cip.IS_ACTIVE = '1'
|
|
<if test="params.startTime != null and params.startTime !=''and params.endTime != null and params.endTime !='' ">
|
|
AND cip.RQ BETWEEN #{params.startTime} AND #{params.endTime}
|
|
</if>) a
|
|
where '1' = '1'
|
|
<if test="params.htmc != null and params.htmc !='' ">
|
|
and a.htmc like concat ('%',#{params.htmc},'%')
|
|
</if>
|
|
GROUP BY a.id,a.htmc,a.gysmc,a.department
|
|
</select>
|
|
<select id="getykpyeByHt" resultType="java.math.BigDecimal">
|
|
SELECT TRUNCATE(COALESCE((SELECT
|
|
sum(CONVERT(OPEN_NOT_INV, DECIMAL(10,2)))
|
|
FROM ca_bm_supplier_info
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="htAll != null and htAll.size() > 0">
|
|
and id in
|
|
<foreach item="item" collection="htAll" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>),0) +
|
|
COALESCE((SELECT sum(CONVERT(je, DECIMAL(10,2)))
|
|
FROM ca_im_payable
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="htAll != null and htAll.size() > 0">
|
|
and htmc in
|
|
<foreach item="item" collection="htAll" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>),0), 2) as ykpje
|
|
</select>
|
|
<select id="getykpjeByHt" resultType="java.math.BigDecimal">
|
|
SELECT COALESCE(SUM(CONVERT(kpje, DECIMAL(10,2))), 0) as ykpje
|
|
FROM ca_im_payable
|
|
WHERE IS_ACTIVE = '1'
|
|
<if test="htAll != null and htAll.size() > 0">
|
|
and htmc in
|
|
<foreach item="item" collection="htAll" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
<select id="getHTIDByMC" resultType="java.lang.Integer">
|
|
select id
|
|
from ca_bm_supplier_info where IS_ACTIVE = '1' and CONTRACT_OR_PRO_NAME = #{htmc}
|
|
</select>
|
|
<select id="getBankAccount" resultType="com.bonus.boot.manager.ca.bm.entity.PayAccountInfoBean">
|
|
select id,name
|
|
from ca_bm_pay_account_info where IS_ACTIVE = '1'
|
|
</select>
|
|
|
|
|
|
</mapper> |