2025-01-23 15:51:16 +08:00
|
|
|
<?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.material.push.mapper.IwsCostPushMapper">
|
|
|
|
|
|
|
|
|
|
<select id="findAgreement" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
SELECT
|
2025-01-24 17:08:03 +08:00
|
|
|
bp.pro_id AS projectId, bp.pro_name AS projectName, bp.pro_code AS projectCode,
|
2025-01-23 15:51:16 +08:00
|
|
|
bu.unit_name AS unitName,
|
2025-09-01 01:39:44 +08:00
|
|
|
bma.agreement_id AS agreementId,bma.`agreement_code` AS agreementCode, bma.sign_time AS signTime, bma.is_push AS isPush,
|
|
|
|
|
IF(saa.audit_time IS NULL,0,1) AS isSettlement, saa.audit_time AS settlementTime,
|
2025-11-20 14:33:20 +08:00
|
|
|
IF(saas.audit_time IS NULL,0,1) AS safetyIsSettlement, saas.audit_time AS safetySettlementTime,
|
|
|
|
|
sd.dept_name AS impUnitName
|
2025-09-01 01:39:44 +08:00
|
|
|
FROM
|
|
|
|
|
bm_agreement_info bma
|
2025-01-23 15:51:16 +08:00
|
|
|
LEFT JOIN bm_project bp ON bp.pro_id = bma.project_id
|
2025-11-20 14:33:20 +08:00
|
|
|
LEFT JOIN sys_dept sd on sd.dept_id = bp.imp_unit
|
2025-01-23 15:51:16 +08:00
|
|
|
LEFT JOIN bm_unit bu ON bu.unit_id = bma.unit_id
|
2025-09-01 01:39:44 +08:00
|
|
|
LEFT JOIN slt_agreement_apply saa ON saa.agreement_id = bma.agreement_id AND saa.`status` = '2' AND saa.settlement_type = 1
|
|
|
|
|
LEFT JOIN slt_agreement_apply saas ON saas.agreement_id = bma.agreement_id AND saas.`status` = '2' AND saas.settlement_type = 2
|
2025-01-23 15:51:16 +08:00
|
|
|
<where>
|
2025-12-03 16:05:45 +08:00
|
|
|
bp.external_id is not null and bu.unit_id not in (68,351,412,117,4055)
|
2025-01-23 15:51:16 +08:00
|
|
|
<if test="agreementCode != null and agreementCode != ''">
|
|
|
|
|
AND bma.agreement_code LIKE CONCAT('%',#{agreementCode},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="projectId != null and projectId != ''">
|
|
|
|
|
AND bma.project_id = #{projectId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="unitId != null and unitId != ''">
|
|
|
|
|
AND bma.unit_id = #{unitId}
|
|
|
|
|
</if>
|
2025-01-23 16:13:37 +08:00
|
|
|
<if test="isPush != null">
|
2025-01-23 15:51:16 +08:00
|
|
|
AND bma.is_push = #{isPush}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="isSettlement != null and isSettlement != ''">
|
|
|
|
|
AND bma.is_slt = #{isSettlement}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
2025-01-24 17:08:03 +08:00
|
|
|
GROUP BY bma.agreement_id
|
2025-01-23 15:51:16 +08:00
|
|
|
</select>
|
|
|
|
|
|
2025-01-23 16:40:53 +08:00
|
|
|
<update id="updateAgreementIsPush">
|
2025-01-24 17:08:03 +08:00
|
|
|
UPDATE bm_agreement_info SET is_push = #{isPush} WHERE agreement_id = #{agreementId}
|
2025-01-23 16:40:53 +08:00
|
|
|
</update>
|
2025-01-23 17:51:20 +08:00
|
|
|
|
|
|
|
|
<select id="getCostPushCheckList" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
SELECT
|
2025-10-20 11:29:41 +08:00
|
|
|
pmc.id AS id, pmc.AGREEMENT_ID AS agreementId, IF(ISNULL(pmc.check_status), 0, pmc.check_status) AS checkStatus,
|
|
|
|
|
pmc.LEASE_MONEY AS leaseMoney, pmc.LOST_MONEY AS lostMoney, pmc.REPAIR_MONEY AS repairMoney, pmc.SCRAP_MONEY AS scrapMoney,
|
|
|
|
|
bma.agreement_code AS agreementCode, bma.is_slt AS isSettlement, pmc.TYPE AS settlementType,
|
|
|
|
|
bp.pro_name AS projectName, bu.unit_name AS unitName,cpm.id as taskId,
|
|
|
|
|
ROUND(
|
2025-10-21 16:46:51 +08:00
|
|
|
ifnull( pmc.LEASE_MONEY, 0 )+ ifnull( pmc.LOST_MONEY, 0 )+ ifnull( pmc.REPAIR_MONEY, 0 )+ ifnull( pmc.SCRAP_MONEY, 0 ), 2
|
2025-10-20 11:29:41 +08:00
|
|
|
) AS money,
|
|
|
|
|
a.pushStatus AS pushStatus,
|
2025-11-20 14:33:20 +08:00
|
|
|
a.pushRemark AS pushRemark,
|
|
|
|
|
sd.dept_name AS impUnitName
|
2025-01-23 17:51:20 +08:00
|
|
|
FROM
|
2025-10-20 11:29:41 +08:00
|
|
|
project_month_costs pmc
|
2025-08-30 22:16:48 +08:00
|
|
|
LEFT JOIN calc_project_month cpm on pmc.task_id = cpm.id
|
2025-01-24 17:08:03 +08:00
|
|
|
LEFT JOIN bm_agreement_info bma ON pmc.AGREEMENT_ID = bma.agreement_id
|
|
|
|
|
LEFT JOIN bm_project bp ON bp.pro_id = bma.project_id
|
2025-11-20 14:33:20 +08:00
|
|
|
LEFT JOIN sys_dept sd on sd.dept_id = bp.imp_unit
|
2025-01-24 17:08:03 +08:00
|
|
|
LEFT JOIN bm_unit bu ON bu.unit_id = bma.unit_id
|
2025-10-20 11:29:41 +08:00
|
|
|
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
pmi.agreementId,pmi.id,pmi.push_status as pushStatus,
|
|
|
|
|
pmi.push_remark as pushRemark
|
|
|
|
|
FROM calc_project_month cpm
|
|
|
|
|
LEFT JOIN project_month_info pmi ON pmi.taskId = cpm.id
|
|
|
|
|
WHERE cpm.`MONTH` = #{month} GROUP BY pmi.agreementId
|
|
|
|
|
|
|
|
|
|
UNION
|
|
|
|
|
SELECT
|
|
|
|
|
bma.agreement_id AS agreementId,
|
|
|
|
|
sad.id,sad.push_status as pushStatus,
|
|
|
|
|
sad.push_remark as pushRemark
|
|
|
|
|
FROM
|
|
|
|
|
slt_agreement_details sad
|
|
|
|
|
left join slt_agreement_apply saa on sad.apply_id = saa.id
|
|
|
|
|
LEFT JOIN bm_agreement_info bma ON bma.agreement_id = saa.agreement_id
|
2025-12-03 16:05:45 +08:00
|
|
|
WHERE LEFT(saa.create_time,7) = #{month} AND sad.slt_type = 2
|
2025-10-20 11:29:41 +08:00
|
|
|
GROUP BY bma.agreement_id
|
|
|
|
|
|
|
|
|
|
UNION
|
|
|
|
|
SELECT
|
|
|
|
|
bma.agreement_id AS agreementId,
|
|
|
|
|
sad.id,sad.push_status as pushStatus,
|
|
|
|
|
sad.push_remark as pushRemark
|
|
|
|
|
FROM
|
|
|
|
|
slt_agreement_details sad
|
|
|
|
|
left join slt_agreement_apply saa on sad.apply_id = saa.id
|
|
|
|
|
LEFT JOIN bm_agreement_info bma ON bma.agreement_id = saa.agreement_id
|
2025-12-03 16:05:45 +08:00
|
|
|
WHERE LEFT(saa.create_time,7) = #{month} AND sad.slt_type = 3 and sad.is_charge = 1
|
2025-10-20 11:29:41 +08:00
|
|
|
GROUP BY bma.agreement_id
|
|
|
|
|
|
|
|
|
|
UNION
|
|
|
|
|
SELECT
|
|
|
|
|
bma.agreement_id AS agreementId,
|
|
|
|
|
sad.id,sad.push_status as pushStatus,
|
|
|
|
|
sad.push_remark as pushRemark
|
|
|
|
|
FROM
|
|
|
|
|
slt_agreement_details sad
|
|
|
|
|
left join slt_agreement_apply saa on sad.apply_id = saa.id
|
|
|
|
|
LEFT JOIN bm_agreement_info bma ON bma.agreement_id = saa.agreement_id
|
2025-12-03 16:05:45 +08:00
|
|
|
WHERE LEFT(saa.create_time,7) = #{month} AND sad.slt_type = 4 and sad.is_charge = 1
|
2025-10-20 11:29:41 +08:00
|
|
|
GROUP BY bma.agreement_id
|
|
|
|
|
) a ON
|
|
|
|
|
pmc.AGREEMENT_ID = a.agreementId
|
|
|
|
|
|
2025-01-23 17:51:20 +08:00
|
|
|
WHERE
|
2025-09-26 16:32:33 +08:00
|
|
|
pmc.type = 1 and
|
2026-01-06 11:31:56 +08:00
|
|
|
( pmc.LEASE_MONEY > 0 OR pmc.LOST_MONEY != 0 OR pmc.REPAIR_MONEY > 0 OR pmc.SCRAP_MONEY > 0 )
|
2025-10-20 11:29:41 +08:00
|
|
|
<if test="pushStatus != null">
|
|
|
|
|
AND a.pushStatus = #{pushStatus}
|
2025-01-23 17:51:20 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="agreementCode != null and agreementCode != ''">
|
|
|
|
|
AND bma.agreement_code LIKE CONCAT('%',#{agreementCode},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="projectId != null and projectId != ''">
|
|
|
|
|
AND bma.project_id = #{projectId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="unitId != null and unitId != ''">
|
|
|
|
|
AND bma.unit_id = #{unitId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="isSettlement != null and isSettlement != ''">
|
|
|
|
|
AND bma.is_slt = #{isSettlement}
|
|
|
|
|
</if>
|
2025-08-30 22:16:48 +08:00
|
|
|
<if test="month != null">
|
|
|
|
|
AND cpm.month = #{month}
|
|
|
|
|
</if>
|
2025-09-08 18:57:58 +08:00
|
|
|
<if test="settlementType != null">
|
|
|
|
|
AND pmc.TYPE = #{settlementType}
|
|
|
|
|
</if>
|
2025-11-20 14:33:20 +08:00
|
|
|
<if test="impUnitName != null and impUnitName != ''">
|
|
|
|
|
AND sd.dept_name = #{impUnitName}
|
|
|
|
|
</if>
|
2025-01-23 17:51:20 +08:00
|
|
|
|
|
|
|
|
GROUP BY
|
2025-08-30 22:16:48 +08:00
|
|
|
pmc.AGREEMENT_ID, pmc.TYPE
|
2026-01-15 16:10:25 +08:00
|
|
|
order by sd.order_num,a.pushStatus
|
2025-01-23 17:51:20 +08:00
|
|
|
</select>
|
2025-01-24 17:08:03 +08:00
|
|
|
|
2025-08-30 22:16:48 +08:00
|
|
|
<insert id="insertCalcMonthRecord" parameterType="com.bonus.material.push.domain.IwsCostPushBean" useGeneratedKeys="true" keyProperty="taskId">
|
2025-01-24 17:08:03 +08:00
|
|
|
INSERT INTO calc_project_month (MONTH)
|
|
|
|
|
VALUES (#{month})
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<select id="getPaidSltBaseInfo" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
SELECT
|
|
|
|
|
mt1.type_name as typeName,
|
|
|
|
|
mt.type_name as modelName,
|
|
|
|
|
mt.unit_name AS unitName,
|
|
|
|
|
sai.lease_price as leasePrice,
|
|
|
|
|
bma.agreement_id AS agreementId,sai.type_id as typeId,
|
|
|
|
|
IFNULL(mt.lease_price ,0) as nowLeasePrice,
|
|
|
|
|
sai.buy_price as buyPrice,sai.num AS leaseNum,sai.start_time AS leaseDate,sai.end_time AS backDate,
|
|
|
|
|
IF(sai.`status` = 0,sai.num,0) as returnNum,
|
|
|
|
|
(datediff(sai.end_time,sai.start_time)+1) * (sai.num) * (sai.lease_price) AS leaseMoney,
|
|
|
|
|
bma.`agreement_code` AS agreementCode,bma.project_id as projectId,
|
|
|
|
|
bma.is_slt AS isSettlement,
|
|
|
|
|
bma.sign_time AS settlementTime,
|
|
|
|
|
bma.is_push AS isPush
|
|
|
|
|
FROM bm_agreement_info bma
|
|
|
|
|
LEFT JOIN slt_agreement_info sai ON bma.agreement_id = sai.agreement_id
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
2025-01-24 17:58:58 +08:00
|
|
|
<where>
|
|
|
|
|
bma.agreement_id = #{agreementId}
|
|
|
|
|
</where>
|
2025-01-24 17:08:03 +08:00
|
|
|
</select>
|
2025-02-15 16:38:24 +08:00
|
|
|
|
2025-09-01 01:39:44 +08:00
|
|
|
<select id="getLeaseCostsByAgreementIdAndMonth" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
SELECT
|
|
|
|
|
pmi.typeId as typeId, pmi.leaseNum as leaseNum, pmi.leaseDate, pmi.returnDate as backDate,
|
|
|
|
|
pmi.leasePrice as leasePrice, pmi.leaseMoney as leaseMoney, pmi.jiju_type as settlementType,
|
|
|
|
|
mt1.type_name as typeName,
|
|
|
|
|
mt.type_name as modelName,
|
|
|
|
|
mt.unit_name AS unitName
|
|
|
|
|
FROM
|
|
|
|
|
project_month_info pmi
|
|
|
|
|
INNER JOIN calc_project_month cpm ON pmi.taskId = cpm.ID AND cpm.`MONTH` = #{month}
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = pmi.typeId
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
WHERE
|
|
|
|
|
pmi.agreementId = #{agreementId}
|
|
|
|
|
AND pmi.jiju_type = #{settlementType,jdbcType=TINYINT}
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-02-15 16:38:24 +08:00
|
|
|
<insert id="insertProjectMonthCosts">
|
|
|
|
|
INSERT INTO project_month_costs(
|
|
|
|
|
AGREEMENT_ID,
|
|
|
|
|
LEASE_MONEY,
|
2025-08-30 22:16:48 +08:00
|
|
|
CONSUME_MONEY,
|
2025-02-15 16:38:24 +08:00
|
|
|
LOST_MONEY,
|
|
|
|
|
REPAIR_MONEY,
|
|
|
|
|
SCRAP_MONEY,
|
2025-08-30 22:16:48 +08:00
|
|
|
TASK_ID,
|
|
|
|
|
TYPE
|
2025-02-15 16:38:24 +08:00
|
|
|
)
|
|
|
|
|
VALUES
|
|
|
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
|
|
|
(
|
|
|
|
|
#{item.agreementId},
|
|
|
|
|
#{item.leaseMoney},
|
2025-08-30 22:16:48 +08:00
|
|
|
#{item.consumeMoney},
|
2025-02-15 16:38:24 +08:00
|
|
|
#{item.lostMoney},
|
|
|
|
|
#{item.repairMoney},
|
|
|
|
|
#{item.scrapMoney},
|
2025-08-30 22:16:48 +08:00
|
|
|
#{item.taskId},
|
|
|
|
|
#{item.settlementType}
|
2025-02-15 16:38:24 +08:00
|
|
|
)
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
2025-07-04 15:30:07 +08:00
|
|
|
|
|
|
|
|
<select id="getProLeaseInfo" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
SELECT
|
|
|
|
|
mt1.type_name as typeName,
|
|
|
|
|
mt.type_name as modelName,
|
|
|
|
|
mt.unit_name AS unitName,
|
|
|
|
|
sai.lease_price as leasePrice,
|
|
|
|
|
bma.agreement_id AS agreementId,sai.type_id as typeId,
|
|
|
|
|
IFNULL(mt.lease_price ,0) as nowLeasePrice,
|
|
|
|
|
sai.buy_price as buyPrice,sai.num AS leaseNum,sai.start_time AS leaseDate,sai.end_time AS backDate,
|
|
|
|
|
IF(sai.`status` = 0,sai.num,0) as returnNum,
|
|
|
|
|
(datediff(sai.end_time,sai.start_time)+1) * (sai.num) * (sai.lease_price) AS leaseMoney,
|
|
|
|
|
bma.`agreement_code` AS agreementCode,bma.project_id as projectId,
|
|
|
|
|
bma.is_slt AS isSettlement,
|
|
|
|
|
bma.sign_time AS settlementTime,
|
|
|
|
|
bma.is_push AS isPush
|
|
|
|
|
FROM bm_agreement_info bma
|
|
|
|
|
LEFT JOIN slt_agreement_info sai ON bma.agreement_id = sai.agreement_id
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
where 1=1
|
|
|
|
|
<if test="projectId != null and projectId != ''">
|
|
|
|
|
and bma.project_id in (${projectId})
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getTotalInfo" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
SELECT
|
|
|
|
|
parent_id as parentId,
|
|
|
|
|
pre_num AS preNum
|
|
|
|
|
FROM
|
|
|
|
|
clz_lease_apply_details
|
|
|
|
|
WHERE
|
|
|
|
|
type_id = #{typeId}
|
|
|
|
|
AND parent_id = #{parentId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getEquipmentListByType" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id AS typeId,
|
|
|
|
|
mt4.type_name AS constructionType,
|
|
|
|
|
mt4.type_id AS firstTypeId,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt3.type_id AS secondTypeId,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt2.type_id AS thirdTypeId,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
mt.unit_name AS unit,
|
|
|
|
|
IFNULL(mt.lease_price, 0) AS buyPrice,
|
|
|
|
|
IFNULL(subquery1.usNum, 0) AS storeNum,
|
|
|
|
|
IFNULL(subquery3.usNum, 0) AS usNum,
|
|
|
|
|
IFNULL(subquery1.usNum, 0) + IFNULL(subquery3.usNum, 0)
|
|
|
|
|
AS allNum,
|
|
|
|
|
CASE mt.manage_type
|
|
|
|
|
WHEN 0 THEN
|
|
|
|
|
'编码'
|
|
|
|
|
ELSE
|
|
|
|
|
'数量'
|
|
|
|
|
END manageType
|
|
|
|
|
FROM ma_type mt
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id,
|
|
|
|
|
mt4.type_name AS constructionType,
|
|
|
|
|
mt4.type_id AS firstTypeId,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt3.type_id AS secondTypeId,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt2.type_id AS thirdTypeId,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
SUM(IFNULL( sai.num, 0 )) AS usNum
|
|
|
|
|
FROM
|
|
|
|
|
slt_agreement_info sai
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
|
|
|
left join bm_agreement_info bai on sai.agreement_id=bai.agreement_id
|
|
|
|
|
WHERE
|
|
|
|
|
sai.`status` = '0'
|
|
|
|
|
<if test="agreementCode != null and agreementCode != ''">
|
|
|
|
|
and bai.agreement_code =#{agreementCode}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="projectId != null and projectId != ''">
|
|
|
|
|
and bai.project_id in (${projectId})
|
|
|
|
|
</if>
|
|
|
|
|
AND sai.end_time IS NULL
|
|
|
|
|
AND sai.back_id IS NULL
|
|
|
|
|
GROUP BY mt.type_id
|
|
|
|
|
) AS subquery1
|
|
|
|
|
ON mt.type_id = subquery1.type_id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
subquery3.type_id,
|
|
|
|
|
subquery3.typeName,
|
|
|
|
|
subquery3.typeModelName,
|
|
|
|
|
IFNULL(subquery3.outNum, 0) AS outNum,
|
|
|
|
|
IFNULL(subquery4.backNum, 0) AS backNum,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN IFNULL(subquery3.outNum, 0) - IFNULL(subquery4.backNum, 0) > 0 THEN
|
|
|
|
|
IFNULL(subquery3.outNum, 0) - IFNULL(subquery4.backNum, 0)
|
|
|
|
|
ELSE 0
|
|
|
|
|
END AS usNum
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id,
|
|
|
|
|
mt4.type_name AS constructionType,
|
|
|
|
|
mt4.type_id AS firstTypeId,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt3.type_id AS secondTypeId,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt2.type_id AS thirdTypeId,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
SUM(IFNULL(lod.out_num, 0)) AS outNum
|
|
|
|
|
FROM clz_lease_out_details lod
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = lod.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
|
|
|
WHERE lod.is_finished = '1'
|
|
|
|
|
GROUP BY mt.type_id) AS subquery3
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id,
|
|
|
|
|
mt4.type_name AS constructionType,
|
|
|
|
|
mt4.type_id AS firstTypeId,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt3.type_id AS secondTypeId,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt2.type_id AS thirdTypeId,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
SUM(IFNULL(bcd.back_num, 0)) backNum
|
|
|
|
|
FROM clz_back_check_details bcd
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
|
|
|
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
|
|
|
|
|
WHERE bcd.is_finished = '1'
|
|
|
|
|
GROUP BY mt.type_id) AS subquery4
|
|
|
|
|
ON subquery3.type_id = subquery4.type_id) AS subquery3
|
|
|
|
|
ON mt.type_id = subquery3.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
|
|
|
WHERE mt.`level` = 4 and mt.del_flag = '0'
|
|
|
|
|
<if test="deviceName != null and deviceName != ''">
|
|
|
|
|
and mt2.type_name like concat('%',#{deviceName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="deviceModel != null and deviceModel != ''">
|
|
|
|
|
and mt.type_name like concat('%',#{deviceModel},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="maType != null and maType != ''">
|
|
|
|
|
and mt3.type_name like concat('%',#{maType},'%')
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getEquipmentListByAgreementCode" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id AS typeId,
|
|
|
|
|
mt4.type_name AS constructionType,
|
|
|
|
|
mt4.type_id AS firstTypeId,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt3.type_id AS secondTypeId,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt2.type_id AS thirdTypeId,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
mt.unit_name AS unit,
|
|
|
|
|
IFNULL(mt.lease_price, 0) AS buyPrice,
|
|
|
|
|
IFNULL(subquery1.usNum, 0) AS storeNum,
|
|
|
|
|
IFNULL(subquery3.usNum, 0) AS usNum,
|
|
|
|
|
IFNULL(subquery1.usNum, 0) + IFNULL(subquery3.usNum, 0)
|
|
|
|
|
AS allNum,
|
|
|
|
|
CASE mt.manage_type
|
|
|
|
|
WHEN 0 THEN
|
|
|
|
|
'编码'
|
|
|
|
|
ELSE
|
|
|
|
|
'数量'
|
|
|
|
|
END manageType
|
|
|
|
|
FROM ma_type mt
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id,
|
|
|
|
|
mt4.type_name AS constructionType,
|
|
|
|
|
mt4.type_id AS firstTypeId,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt3.type_id AS secondTypeId,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt2.type_id AS thirdTypeId,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
SUM(IFNULL( sai.num, 0 )) AS usNum
|
|
|
|
|
FROM
|
|
|
|
|
slt_agreement_info sai
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
|
|
|
WHERE
|
|
|
|
|
sai.`status` = '0'
|
|
|
|
|
AND sai.end_time IS NULL
|
|
|
|
|
AND sai.back_id IS NULL
|
|
|
|
|
GROUP BY mt.type_id
|
|
|
|
|
) AS subquery1
|
|
|
|
|
ON mt.type_id = subquery1.type_id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
subquery3.type_id,
|
|
|
|
|
subquery3.typeName,
|
|
|
|
|
subquery3.typeModelName,
|
|
|
|
|
IFNULL(subquery3.outNum, 0) AS outNum,
|
|
|
|
|
IFNULL(subquery4.backNum, 0) AS backNum,
|
|
|
|
|
CASE
|
|
|
|
|
|
|
|
|
|
WHEN IFNULL(subquery3.outNum, 0) - IFNULL(subquery4.backNum, 0) > 0 THEN
|
|
|
|
|
IFNULL(subquery3.outNum, 0) - IFNULL(subquery4.backNum, 0)
|
|
|
|
|
ELSE 0
|
|
|
|
|
END AS usNum
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id,
|
|
|
|
|
mt4.type_name AS constructionType,
|
|
|
|
|
mt4.type_id AS firstTypeId,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt3.type_id AS secondTypeId,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt2.type_id AS thirdTypeId,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
SUM(IFNULL(lod.out_num, 0)) AS outNum
|
|
|
|
|
FROM clz_lease_out_details lod
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = lod.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
|
|
|
WHERE lod.is_finished = '1'
|
|
|
|
|
GROUP BY mt.type_id) AS subquery3
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id,
|
|
|
|
|
mt4.type_name AS constructionType,
|
|
|
|
|
mt4.type_id AS firstTypeId,
|
|
|
|
|
mt3.type_name AS materialType,
|
|
|
|
|
mt3.type_id AS secondTypeId,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt2.type_id AS thirdTypeId,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
SUM(IFNULL(bcd.back_num, 0)) backNum
|
|
|
|
|
FROM clz_back_check_details bcd
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
|
|
|
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
|
|
|
|
|
WHERE bcd.is_finished = '1'
|
|
|
|
|
GROUP BY mt.type_id) AS subquery4
|
|
|
|
|
ON subquery3.type_id = subquery4.type_id) AS subquery3
|
|
|
|
|
ON mt.type_id = subquery3.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
|
|
|
|
WHERE mt.`level` = 4 and mt.del_flag = '0'
|
|
|
|
|
<if test="maModelName != null and maModelName != ''">
|
|
|
|
|
and mt.type_name like concat('%',#{maModelName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="maTypeName != null and maTypeName != ''">
|
|
|
|
|
and mt2.type_name like concat('%',#{maTypeName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
2025-08-30 22:16:48 +08:00
|
|
|
|
|
|
|
|
<insert id="insertProjectMonthCostsDetails" parameterType="com.bonus.material.settlement.domain.vo.PeriodCostResultVo">
|
|
|
|
|
insert into project_month_info(agreementId, typeId, leaseNum, leaseDate, returnDate,
|
|
|
|
|
leasePrice, leaseMoney, taskId, buy_price, money, jiju_type)
|
|
|
|
|
values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(
|
|
|
|
|
#{item.agreementId},
|
|
|
|
|
#{item.typeId},
|
|
|
|
|
#{item.num},
|
|
|
|
|
#{item.calcStartTime},
|
|
|
|
|
#{item.calcEndTime},
|
|
|
|
|
#{item.leasePrice},
|
|
|
|
|
#{item.leaseCost},
|
|
|
|
|
#{item.taskId},
|
2025-09-08 17:05:07 +08:00
|
|
|
#{item.buyPrice},
|
|
|
|
|
#{item.consumeCost},
|
2025-08-30 22:16:48 +08:00
|
|
|
#{item.equipmentType}
|
|
|
|
|
)
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
2025-09-01 01:39:44 +08:00
|
|
|
|
2025-09-26 16:32:33 +08:00
|
|
|
<select id="getProIdsByAgreementIds" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
select project_id as proId,
|
|
|
|
|
GROUP_CONCAT(agreement_id) as agreementIdsStr
|
|
|
|
|
from bm_agreement_info where agreement_id in
|
|
|
|
|
<foreach collection="agreementIds" item="item" open="(" close=")" separator=",">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
group by project_id
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getRentalCostList" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
select
|
|
|
|
|
pmi.id as id,
|
|
|
|
|
bp.external_id as projectId,
|
|
|
|
|
bp.pro_name as projectName,
|
|
|
|
|
bu.unit_id as unitId,
|
|
|
|
|
bu.unit_name as unitName,
|
|
|
|
|
pmi.agreementId as agreementId,
|
|
|
|
|
pmi.typeId as typeId,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt.type_name as modelName,
|
|
|
|
|
pmi.leaseNum as num,
|
|
|
|
|
pmi.leaseDate as leaseDate,
|
|
|
|
|
pmi.returnDate as backDate,
|
2025-09-30 11:55:38 +08:00
|
|
|
pmi.leasePrice as leasePrice,
|
2025-09-26 16:32:33 +08:00
|
|
|
pmi.leaseMoney as money,
|
|
|
|
|
cpm.month as month,
|
|
|
|
|
1 as type,
|
|
|
|
|
1 as category,
|
|
|
|
|
#{submitUser} as submitUser
|
|
|
|
|
|
|
|
|
|
from project_month_info pmi
|
|
|
|
|
left join calc_project_month cpm on pmi.taskId = cpm.id
|
|
|
|
|
left join bm_agreement_info bai on pmi.agreementId = bai.agreement_id
|
|
|
|
|
left join bm_project bp on bai.project_id = bp.pro_id
|
|
|
|
|
left join bm_unit bu on bai.unit_id = bu.unit_id
|
|
|
|
|
left join ma_type mt on pmi.typeId = mt.type_id
|
|
|
|
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
|
|
|
|
where
|
|
|
|
|
pmi.agreementId in
|
|
|
|
|
<foreach collection="agreementIds" item="item" open="(" close=")" separator=",">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
<if test="taskId != null">
|
|
|
|
|
and pmi.taskId = #{taskId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="settlementType != null">
|
|
|
|
|
and pmi.jiju_type = #{settlementType}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getBalanceCostList" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
select
|
|
|
|
|
sad.id as id,
|
|
|
|
|
bp.external_id as projectId,
|
|
|
|
|
bp.pro_name as projectName,
|
|
|
|
|
bu.unit_id as unitId,
|
|
|
|
|
bu.unit_name as unitName,
|
|
|
|
|
saa.agreement_id as agreementId,
|
|
|
|
|
sad.type_id as typeId,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt.type_name as modelName,
|
|
|
|
|
sad.num as num,
|
2025-09-30 11:55:38 +08:00
|
|
|
sad.price as leasePrice,
|
2025-09-26 16:32:33 +08:00
|
|
|
sad.money as money,
|
2025-10-20 15:29:51 +08:00
|
|
|
case when sad.slt_type = 1 then 1
|
|
|
|
|
when sad.slt_type = 2 then 2
|
|
|
|
|
when sad.slt_type = 3 then 4
|
|
|
|
|
when sad.slt_type = 4 then 5
|
|
|
|
|
else null
|
|
|
|
|
end as type,
|
2025-09-26 16:32:33 +08:00
|
|
|
1 as category,
|
|
|
|
|
#{submitUser} as submitUser,
|
|
|
|
|
#{month} as month
|
|
|
|
|
|
|
|
|
|
from slt_agreement_details sad
|
|
|
|
|
left join slt_agreement_apply saa on saa.id = sad.apply_id
|
|
|
|
|
left join bm_agreement_info bai on saa.agreement_id = bai.agreement_id
|
|
|
|
|
left join bm_project bp on bai.project_id = bp.pro_id
|
|
|
|
|
left join bm_unit bu on bai.unit_id = bu.unit_id
|
|
|
|
|
left join ma_type mt on sad.type_id = mt.type_id
|
|
|
|
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
|
|
|
|
where
|
|
|
|
|
saa.status = 2
|
|
|
|
|
and saa.agreement_id in
|
|
|
|
|
<foreach collection="agreementIds" item="item" open="(" close=")" separator=",">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
2025-10-20 11:29:41 +08:00
|
|
|
<if test="type != null and (type == 3 or type ==4)">
|
|
|
|
|
and sad.slt_type = #{type} and sad.is_charge = 1
|
|
|
|
|
</if>
|
|
|
|
|
<if test="type != null and (type == 1 or type ==2)">
|
2025-09-26 16:32:33 +08:00
|
|
|
and sad.slt_type = #{type}
|
|
|
|
|
</if>
|
2025-10-20 15:29:51 +08:00
|
|
|
<if test="month != null and month != ''">
|
2025-12-08 17:07:38 +08:00
|
|
|
and LEFT(saa.create_time,7) = #{month}
|
2025-10-20 15:29:51 +08:00
|
|
|
</if>
|
2025-09-26 16:32:33 +08:00
|
|
|
<if test="settlementType != null">
|
|
|
|
|
and saa.settlement_type = #{settlementType}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<update id="updateCostPushCheckStatus">
|
|
|
|
|
UPDATE project_month_costs SET check_status = 1, check_time = now(),check_user = #{userName}
|
|
|
|
|
WHERE task_id = #{taskId}
|
|
|
|
|
and agreement_id in
|
|
|
|
|
<foreach collection="agreementIds" item="item" open="(" close=")" separator=",">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
<if test="settlementType != null and settlementType == 1">
|
|
|
|
|
and type = #{settlementType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="settlementType != null and settlementType == 2 and comsumeType !=null and comsumeType == 0">
|
|
|
|
|
and type = #{settlementType} and (consume_money = 0 || consume_money is null)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="settlementType != null and settlementType == 2 and comsumeType !=null and comsumeType == 1">
|
|
|
|
|
and type = #{settlementType} and consume_money > 0
|
|
|
|
|
</if>
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updatePushProjectInfo">
|
|
|
|
|
UPDATE project_month_info SET push_status = #{pushStatus}, push_time = #{pushTime}, push_remark = #{pushRemark}
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updatePushBsd">
|
|
|
|
|
UPDATE slt_agreement_details SET push_status = #{pushStatus}, push_time = #{pushTime}, push_remark = #{pushRemark}
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updatePushProjectInfoReturn">
|
|
|
|
|
UPDATE project_month_info SET push_status = 2, push_remark = #{pushRemark}
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updatePushBsdReturn">
|
|
|
|
|
UPDATE slt_agreement_details SET push_status = 2, push_remark = #{pushRemark}
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<select id="getSafetyRentalCostList" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
select
|
|
|
|
|
pmi.id as id,
|
|
|
|
|
bp.external_id as projectId,
|
|
|
|
|
bp.pro_name as projectName,
|
|
|
|
|
bu.unit_id as unitId,
|
|
|
|
|
bu.unit_name as unitName,
|
|
|
|
|
pmi.agreementId as agreementId,
|
|
|
|
|
pmi.typeId as typeId,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt.type_name as modelName,
|
|
|
|
|
pmi.leaseNum as num,
|
|
|
|
|
pmi.leaseDate as leaseDate,
|
|
|
|
|
pmi.returnDate as backDate,
|
2025-09-30 11:55:38 +08:00
|
|
|
pmi.leasePrice as leasePrice,
|
2025-09-26 16:32:33 +08:00
|
|
|
pmi.leaseMoney as money,
|
|
|
|
|
cpm.month as month,
|
|
|
|
|
1 as type,
|
|
|
|
|
2 as category,
|
|
|
|
|
#{submitUser} as submitUser
|
|
|
|
|
|
|
|
|
|
from project_month_info pmi
|
|
|
|
|
left join calc_project_month cpm on pmi.taskId = cpm.id
|
|
|
|
|
left join bm_agreement_info bai on pmi.agreementId = bai.agreement_id
|
|
|
|
|
left join bm_project bp on bai.project_id = bp.pro_id
|
|
|
|
|
left join bm_unit bu on bai.unit_id = bu.unit_id
|
|
|
|
|
left join ma_type mt on pmi.typeId = mt.type_id
|
|
|
|
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
|
|
|
|
where
|
|
|
|
|
pmi.agreementId in
|
|
|
|
|
<foreach collection="agreementIds" item="item" open="(" close=")" separator=",">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
<if test="taskId != null">
|
|
|
|
|
and pmi.taskId = #{taskId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="settlementType != null">
|
|
|
|
|
and pmi.jiju_type = #{settlementType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="comsumeType == 0">
|
|
|
|
|
and pmi.money = 0
|
|
|
|
|
</if>
|
|
|
|
|
<if test="comsumeType == 1">
|
|
|
|
|
and pmi.money > 0
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getSafetyBalanceCostList" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
select
|
|
|
|
|
sad.id as id,
|
|
|
|
|
bp.external_id as projectId,
|
|
|
|
|
bp.pro_name as projectName,
|
|
|
|
|
bu.unit_id as unitId,
|
|
|
|
|
bu.unit_name as unitName,
|
|
|
|
|
saa.agreement_id as agreementId,
|
|
|
|
|
sad.type_id as typeId,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt.type_name as modelName,
|
|
|
|
|
sad.num as num,
|
2025-09-30 11:55:38 +08:00
|
|
|
sad.price as leasePrice,
|
2025-09-26 16:32:33 +08:00
|
|
|
sad.money as money,
|
2025-10-20 15:29:51 +08:00
|
|
|
case when sad.slt_type = 1 then 1
|
|
|
|
|
when sad.slt_type = 2 then 2
|
|
|
|
|
when sad.slt_type = 3 then 4
|
|
|
|
|
when sad.slt_type = 4 then 5
|
|
|
|
|
else null
|
|
|
|
|
end as type,
|
2025-09-26 16:32:33 +08:00
|
|
|
2 as category,
|
|
|
|
|
#{submitUser} as submitUser,
|
|
|
|
|
#{month} as month
|
|
|
|
|
|
|
|
|
|
from slt_agreement_details sad
|
|
|
|
|
left join slt_agreement_apply saa on saa.id = sad.apply_id
|
|
|
|
|
left join bm_agreement_info bai on saa.agreement_id = bai.agreement_id
|
|
|
|
|
left join bm_project bp on bai.project_id = bp.pro_id
|
|
|
|
|
left join bm_unit bu on bai.unit_id = bu.unit_id
|
|
|
|
|
left join ma_type mt on sad.type_id = mt.type_id
|
|
|
|
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
|
|
|
|
where
|
|
|
|
|
saa.status = 2
|
|
|
|
|
and saa.agreement_id in
|
|
|
|
|
<foreach collection="agreementIds" item="item" open="(" close=")" separator=",">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
2025-10-20 15:29:51 +08:00
|
|
|
<if test="type != null and type !=4">
|
2025-09-26 16:32:33 +08:00
|
|
|
and sad.slt_type = #{type}
|
|
|
|
|
</if>
|
2025-10-20 15:29:51 +08:00
|
|
|
<if test="type != null and type ==4">
|
2025-12-08 18:33:01 +08:00
|
|
|
and sad.slt_type = #{type} and sad.is_charge = 1
|
2025-10-20 15:29:51 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="month != null and month != ''">
|
2025-12-08 18:33:01 +08:00
|
|
|
and LEFT(saa.create_time,7) = #{month}
|
2025-10-20 15:29:51 +08:00
|
|
|
</if>
|
2025-09-26 16:32:33 +08:00
|
|
|
<if test="settlementType != null">
|
|
|
|
|
and saa.settlement_type = #{settlementType}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getMonth" resultType="java.lang.String">
|
|
|
|
|
select
|
|
|
|
|
cpm.month as month
|
|
|
|
|
from calc_project_month cpm
|
|
|
|
|
where cpm.id = #{taskId}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getSafetyConsumeCostList" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
|
|
|
|
select
|
|
|
|
|
pmi.id as id,
|
|
|
|
|
bp.external_id as projectId,
|
|
|
|
|
bp.pro_name as projectName,
|
|
|
|
|
bu.unit_id as unitId,
|
|
|
|
|
bu.unit_name as unitName,
|
|
|
|
|
pmi.agreementId as agreementId,
|
|
|
|
|
pmi.typeId as typeId,
|
2025-09-30 11:57:48 +08:00
|
|
|
mt2.type_name as name,
|
|
|
|
|
mt.type_name as type,
|
2025-09-26 16:32:33 +08:00
|
|
|
pmi.leaseNum as quantity,
|
|
|
|
|
pmi.leaseDate as leaseDate,
|
|
|
|
|
pmi.returnDate as backDate,
|
|
|
|
|
pmi.buy_price as netPrice,
|
|
|
|
|
pmi.money as cost,
|
|
|
|
|
cpm.month as month,
|
|
|
|
|
2 as category,
|
|
|
|
|
#{submitUser} as submitUser
|
|
|
|
|
|
|
|
|
|
from project_month_info pmi
|
|
|
|
|
left join calc_project_month cpm on pmi.taskId = cpm.id
|
|
|
|
|
left join bm_agreement_info bai on pmi.agreementId = bai.agreement_id
|
|
|
|
|
left join bm_project bp on bai.project_id = bp.pro_id
|
|
|
|
|
left join bm_unit bu on bai.unit_id = bu.unit_id
|
|
|
|
|
left join ma_type mt on pmi.typeId = mt.type_id
|
|
|
|
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
|
|
|
|
where
|
|
|
|
|
pmi.agreementId in
|
|
|
|
|
<foreach collection="agreementIds" item="item" open="(" close=")" separator=",">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
<if test="taskId != null">
|
|
|
|
|
and pmi.taskId = #{taskId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="settlementType != null">
|
|
|
|
|
and pmi.jiju_type = #{settlementType}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="comsumeType == 0">
|
|
|
|
|
and pmi.money = 0
|
|
|
|
|
</if>
|
|
|
|
|
<if test="comsumeType == 1">
|
|
|
|
|
and pmi.money > 0
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
2025-09-01 01:39:44 +08:00
|
|
|
|
2025-07-04 15:30:07 +08:00
|
|
|
</mapper>
|