emis-service/emis-biz/src/main/resources/mapper/EmisWaybillAjustApplyMapper.xml
2024-07-10 19:10:41 +08:00

343 lines
23 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.xdadan.erp.emis.mapper.EmisWaybillAjustApplyMapper">
<resultMap type="EmisWaybillAjustApply" id="BaseEmisWaybillAjustApplyResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="billCode" column="bill_code" />
<result property="applyType" column="apply_type" />
<result property="applyManCode" column="apply_man_code" />
<result property="applySiteCode" column="apply_site_code" />
<result property="applyFinanceCenterCode" column="apply_finance_center_code" />
<result property="applyDate" column="apply_date" />
<result property="blDestConfirmed" column="bl_dest_confirmed" />
<result property="destConfirmSiteCode" column="dest_confirm_site_code" />
<result property="destConfirmDate" column="dest_confirm_date" />
<result property="destConfirmNote" column="dest_confirm_note" />
<result property="destConfirmManCode" column="dest_confirm_man_code" />
<result property="destFinanceCenterCode" column="dest_finance_center_code" />
<result property="oldValue" column="old_value" />
<result property="newValue" column="new_value" />
<result property="blValueJson" column="bl_value_json" />
<result property="jsonData" column="json_data" />
<result property="applyMemo" column="apply_memo" />
<result property="blCenterConfirmed" column="bl_center_confirmed" />
<result property="centerConfirmSiteCode" column="center_confirm_site_code" />
<result property="centerConfirmManCode" column="center_confirm_man_code" />
<result property="centerConfirmDate" column="center_confirm_date" />
<result property="centerConfirmNote" column="center_confirm_note" />
<association property="applyTypeName" column="apply_type" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectAjustTypeNameByCode"/>
<association property="applyManName" column="apply_man_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
<association property="applySiteName" column="apply_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="applyFinanceCenterName" column="apply_finance_center_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="destConfirmSiteName" column="dest_confirm_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="destConfirmManName" column="dest_confirm_man_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
<association property="destFinanceCenterName" column="dest_finance_center_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="centerConfirmSiteName" column="center_confirm_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="centerConfirmManName" column="center_confirm_man_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
</resultMap>
<resultMap type="EmisWaybillAjustApply" extends="BaseEmisWaybillAjustApplyResult" id="EmisWaybillAjustApplyResult" >
<association property="waybillDetail"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
</resultMap>
<sql id="selectEmisWaybillAjustApplyVo">
select id, bill_code, apply_type, apply_man_code, apply_site_code, apply_finance_center_code, apply_date, bl_dest_confirmed, dest_confirm_site_code, dest_confirm_date, dest_confirm_note, dest_confirm_man_code, dest_finance_center_code, old_value, new_value, bl_value_json, apply_memo, bl_center_confirmed, center_confirm_site_code, center_confirm_man_code, center_confirm_date, center_confirm_note, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_waybill_ajust_apply
</sql>
<select id="selectEmisWaybillAjustApplyList" parameterType="EmisWaybillAjustApply" resultMap="EmisWaybillAjustApplyResult">
<include refid="selectEmisWaybillAjustApplyVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(`bill_code`,#{billCode}) or bill_code like concat('%', #{billCode}, '%') ) </if>
<if test="applyType != null and applyType != ''"> and FIND_IN_SET(`apply_type`,#{applyType})</if>
<if test="applyManCode != null and applyManCode != ''"> and apply_man_code = #{applyManCode}</if>
<if test="applySiteCode != null and applySiteCode != ''"> and apply_site_code = #{applySiteCode}</if>
<if test="applyFinanceCenterCode != null and applyFinanceCenterCode != ''"> and apply_finance_center_code = #{applyFinanceCenterCode}</if>
<if test="applyDate != null "> and apply_date = #{applyDate}</if>
<if test="blDestConfirmed != null and blDestConfirmed != ''"> and bl_dest_confirmed = #{blDestConfirmed}</if>
<if test="destConfirmSiteCode != null and destConfirmSiteCode != ''"> and dest_confirm_site_code = #{destConfirmSiteCode}</if>
<if test="destConfirmDate != null "> and dest_confirm_date = #{destConfirmDate}</if>
<if test="destConfirmNote != null and destConfirmNote != ''"> and dest_confirm_note = #{destConfirmNote}</if>
<if test="destConfirmManCode != null and destConfirmManCode != ''"> and dest_confirm_man_code = #{destConfirmManCode}</if>
<if test="destFinanceCenterCode != null and destFinanceCenterCode != ''"> and dest_finance_center_code like concat('%', #{destFinanceCenterCode}, '%')</if>
<if test="oldValue != null and oldValue != ''"> and old_value like concat('%', #{oldValue}, '%')</if>
<if test="newValue != null and newValue != ''"> and new_value like concat('%', #{newValue}, '%')</if>
<if test="blValueJson != null and blValueJson != ''"> and bl_value_json like concat('%', #{blValueJson}, '%')</if>
<if test="applyMemo != null and applyMemo != ''"> and apply_memo like concat('%', #{applyMemo}, '%')</if>
<if test="blCenterConfirmed != null and blCenterConfirmed != ''"> and bl_center_confirmed like concat('%', #{blCenterConfirmed}, '%')</if>
<if test="centerConfirmSiteCode != null and centerConfirmSiteCode != ''"> and center_confirm_site_code like concat('%', #{centerConfirmSiteCode}, '%')</if>
<if test="centerConfirmManCode != null and centerConfirmManCode != ''"> and center_confirm_man_code like concat('%', #{centerConfirmManCode}, '%')</if>
<if test="centerConfirmDate != null "> and center_confirm_date = #{centerConfirmDate}</if>
<if test="centerConfirmNote != null and centerConfirmNote != ''"> and center_confirm_note like concat('%', #{centerConfirmNote}, '%')</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id like concat('%', #{tenantId}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
<if test="params.beginApplyDate != null and params.beginApplyDate != ''">
and apply_date <![CDATA[ >= ]]> #{params.beginApplyDate}
</if>
<if test="params.endApplyDate != null and params.endApplyDate != ''">
and apply_date <![CDATA[ <= ]]> #{params.endApplyDate}
</if>
<if test="params.processStatus != null and params.processStatus == 1">
and bl_dest_confirmed='0'
</if>
<if test="params.processStatus != null and params.processStatus == 2">
and bl_dest_confirmed='1'
</if>
<if test="params.processStatus != null and params.processStatus == 3">
and bl_center_confirmed='1'
</if>
<if test="params.processStatus != null and params.processStatus == 4">
and bl_dest_confirmed='2'
</if>
<if test="params.processStatus != null and params.processStatus == 5">
and bl_center_confirmed='2'
</if>
<if test="params.processStatus != null and params.processStatus == 6">
and bl_center_confirmed='0'
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and (
apply_site_code in (
SELECT t1.site_code FROM (
SELECT * FROM emis_site WHERE parent_site_code IS NOT NULL ) t1,( SELECT @pid :=
#{params.privSiteCode} ) pd
WHERE FIND_IN_SET( parent_site_code, @pid ) > 0 AND @pid := concat(@pid,',',site_code)
UNION
SELECT #{params.privSiteCode} FROM dual
)
or
dest_confirm_site_code in (
SELECT t1.site_code FROM (
SELECT * FROM emis_site WHERE parent_site_code IS NOT NULL ) t1,( SELECT @pid :=
#{params.privSiteCode} ) pd
WHERE FIND_IN_SET( parent_site_code, @pid ) > 0 AND @pid := concat(@pid,',',site_code)
UNION
SELECT #{params.privSiteCode} FROM dual
)
)
</if>
</where>
ORDER BY
<if test="params.orderSnSortList != null and params.orderSnSortList.size >0 ">
FIELD
<foreach collection="params.orderSnSortList" item="item" open="(order_sn," separator="," close=")">
#{item}
</foreach>
,
</if>
<if test="params.billCodeSortList != null and params.billCodeSortList.size >0 ">
FIELD
<foreach collection="params.billCodeSortList" item="item" open="(bill_code," separator="," close=")">
#{item}
</foreach>
,
</if>
create_time desc
</select>
<!--
未确认 - 1
已确认 - 2
中心已审核 - 3
网点驳回 - 4
中心驳回 - 5
-->
<select id="checkUnique" parameterType="EmisWaybillAjustApply" resultType="int">
select count(1) from emis_waybill_ajust_apply
where del_flag='0'
and bill_code = #{billCode}
limit 1
</select>
<select id="selectEmisWaybillAjustApplyById" parameterType="Long" resultMap="EmisWaybillAjustApplyResult">
select id, bill_code, apply_type, apply_man_code, apply_site_code, apply_finance_center_code, apply_date, bl_dest_confirmed, dest_confirm_site_code, dest_confirm_date, dest_confirm_note, dest_confirm_man_code, dest_finance_center_code, old_value, new_value, bl_value_json, json_data, apply_memo, bl_center_confirmed, center_confirm_site_code, center_confirm_man_code, center_confirm_date, center_confirm_note, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_waybill_ajust_apply a
where a.id = #{id}
</select>
<update id="auditDestPass" parameterType="EmisWaybillAjustApply">
update emis_waybill_ajust_apply
set bl_dest_confirmed='1',dest_confirm_date=now() ,
dest_confirm_man_code = #{destConfirmManCode}
where id = #{id}
</update>
<update id="auditDestNoPass" parameterType="EmisWaybillAjustApply">
update emis_waybill_ajust_apply
set bl_dest_confirmed='2',dest_confirm_note = #{destConfirmNote},dest_confirm_date=now() ,
dest_confirm_man_code = #{destConfirmManCode}
where id = #{id}
</update>
<update id="auditCenterPass" parameterType="EmisWaybillAjustApply">
update emis_waybill_ajust_apply
set bl_center_confirmed='1',center_confirm_date=now() ,
center_confirm_man_code = #{centerConfirmManCode}
where id = #{id}
</update>
<update id="auditCenterNoPass" parameterType="EmisWaybillAjustApply">
update emis_waybill_ajust_apply
set bl_center_confirmed='2',center_confirm_note = #{centerConfirmNote},center_confirm_date=now() ,
center_confirm_man_code = #{centerConfirmManCode}
where id = #{id}
</update>
<insert id="insertEmisWaybillAjustApply" parameterType="EmisWaybillAjustApply" useGeneratedKeys="true" keyProperty="id">
insert into emis_waybill_ajust_apply
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="billCode != null and billCode != ''">bill_code,</if>
<if test="applyType != null and applyType != ''">apply_type,</if>
<if test="applyManCode != null and applyManCode != ''">apply_man_code,</if>
<if test="applySiteCode != null and applySiteCode != ''">apply_site_code,</if>
<if test="applyFinanceCenterCode != null and applyFinanceCenterCode != ''">apply_finance_center_code,</if>
<if test="applyDate != null">apply_date,</if>
<if test="blDestConfirmed != null and blDestConfirmed != ''">bl_dest_confirmed,</if>
<if test="destConfirmSiteCode != null and destConfirmSiteCode != ''">dest_confirm_site_code,</if>
<if test="destConfirmDate != null">dest_confirm_date,</if>
<if test="destConfirmNote != null and destConfirmNote != ''">dest_confirm_note,</if>
<if test="destConfirmManCode != null and destConfirmManCode != ''">dest_confirm_man_code,</if>
<if test="destFinanceCenterCode != null and destFinanceCenterCode != ''">dest_finance_center_code,</if>
<if test="oldValue != null and oldValue != ''">old_value,</if>
<if test="newValue != null and newValue != ''">new_value,</if>
<if test="blValueJson != null and blValueJson != ''">bl_value_json,</if>
<if test="jsonData != null and jsonData != ''">json_data,</if>
<if test="applyMemo != null and applyMemo != ''">apply_memo,</if>
<if test="blCenterConfirmed != null and blCenterConfirmed != ''">bl_center_confirmed,</if>
<if test="centerConfirmSiteCode != null and centerConfirmSiteCode != ''">center_confirm_site_code,</if>
<if test="centerConfirmManCode != null and centerConfirmManCode != ''">center_confirm_man_code,</if>
<if test="centerConfirmDate != null">center_confirm_date,</if>
<if test="centerConfirmNote != null and centerConfirmNote != ''">center_confirm_note,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="billCode != null and billCode != ''">#{billCode},</if>
<if test="applyType != null and applyType != ''">#{applyType},</if>
<if test="applyManCode != null and applyManCode != ''">#{applyManCode},</if>
<if test="applySiteCode != null and applySiteCode != ''">#{applySiteCode},</if>
<if test="applyFinanceCenterCode != null and applyFinanceCenterCode != ''">#{applyFinanceCenterCode},</if>
<if test="applyDate != null">#{applyDate},</if>
<if test="blDestConfirmed != null and blDestConfirmed != ''">#{blDestConfirmed},</if>
<if test="destConfirmSiteCode != null and destConfirmSiteCode != ''">#{destConfirmSiteCode},</if>
<if test="destConfirmDate != null">#{destConfirmDate},</if>
<if test="destConfirmNote != null and destConfirmNote != ''">#{destConfirmNote},</if>
<if test="destConfirmManCode != null and destConfirmManCode != ''">#{destConfirmManCode},</if>
<if test="destFinanceCenterCode != null and destFinanceCenterCode != ''">#{destFinanceCenterCode},</if>
<if test="oldValue != null and oldValue != ''">#{oldValue},</if>
<if test="newValue != null and newValue != ''">#{newValue},</if>
<if test="blValueJson != null and blValueJson != ''">#{blValueJson},</if>
<if test="jsonData != null and jsonData != ''">#{jsonData},</if>
<if test="applyMemo != null and applyMemo != ''">#{applyMemo},</if>
<if test="blCenterConfirmed != null and blCenterConfirmed != ''">#{blCenterConfirmed},</if>
<if test="centerConfirmSiteCode != null and centerConfirmSiteCode != ''">#{centerConfirmSiteCode},</if>
<if test="centerConfirmManCode != null and centerConfirmManCode != ''">#{centerConfirmManCode},</if>
<if test="centerConfirmDate != null">#{centerConfirmDate},</if>
<if test="centerConfirmNote != null and centerConfirmNote != ''">#{centerConfirmNote},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisWaybillAjustApply" parameterType="EmisWaybillAjustApply">
update emis_waybill_ajust_apply
<trim prefix="SET" suffixOverrides=",">
<if test="billCode != null and billCode != ''">bill_code = #{billCode},</if>
<if test="applyType != null and applyType != ''">apply_type = #{applyType},</if>
<if test="applyManCode != null and applyManCode != ''">apply_man_code = #{applyManCode},</if>
<if test="applySiteCode != null and applySiteCode != ''">apply_site_code = #{applySiteCode},</if>
<if test="applyFinanceCenterCode != null and applyFinanceCenterCode != ''">apply_finance_center_code = #{applyFinanceCenterCode},</if>
<if test="applyDate != null">apply_date = #{applyDate},</if>
<if test="blDestConfirmed != null and blDestConfirmed != ''">bl_dest_confirmed = #{blDestConfirmed},</if>
<if test="destConfirmSiteCode != null and destConfirmSiteCode != ''">dest_confirm_site_code = #{destConfirmSiteCode},</if>
<if test="destConfirmDate != null">dest_confirm_date = #{destConfirmDate},</if>
<if test="destConfirmNote != null and destConfirmNote != ''">dest_confirm_note = #{destConfirmNote},</if>
<if test="destConfirmManCode != null and destConfirmManCode != ''">dest_confirm_man_code = #{destConfirmManCode},</if>
<if test="destFinanceCenterCode != null and destFinanceCenterCode != ''">dest_finance_center_code = #{destFinanceCenterCode},</if>
<if test="oldValue != null and oldValue != ''">old_value = #{oldValue},</if>
<if test="newValue != null and newValue != ''">new_value = #{newValue},</if>
<if test="blValueJson != null and blValueJson != ''">bl_value_json = #{blValueJson},</if>
<if test="jsonData != null and jsonData != ''">json_data = #{jsonData},</if>
<if test="applyMemo != null and applyMemo != ''">apply_memo = #{applyMemo},</if>
<if test="blCenterConfirmed != null and blCenterConfirmed != ''">bl_center_confirmed = #{blCenterConfirmed},</if>
<if test="centerConfirmSiteCode != null and centerConfirmSiteCode != ''">center_confirm_site_code = #{centerConfirmSiteCode},</if>
<if test="centerConfirmManCode != null and centerConfirmManCode != ''">center_confirm_man_code = #{centerConfirmManCode},</if>
<if test="centerConfirmDate != null">center_confirm_date = #{centerConfirmDate},</if>
<if test="centerConfirmNote != null and centerConfirmNote != ''">center_confirm_note = #{centerConfirmNote},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmisWaybillAjustApplyById" parameterType="Long">
update emis_waybill_ajust_apply set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisWaybillAjustApplyByIds" parameterType="String">
update emis_waybill_ajust_apply set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>