刘光辉
4 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?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="jnpf.dmsMapper.DmsJiluDayinLiushuiMapper">
 
    <resultMap id="PrintItemResultMap"
               type="jnpf.dmsEntity.recordprint.DmsJiluDayinShenqingZixiangEntity">
        <id column="f_id" property="id"/>
        <result column="f_foreign_id" property="foreignId"/>
        <result column="wenjian_bianhao" property="wenjianBianhao"/>
        <result column="wenjian_id" property="wenjianId"/>
        <result column="wenjian_mingcheng" property="wenjianMingcheng"/>
        <result column="banbenhao" property="banbenhao"/>
        <result column="gangwei" property="gangwei"/>
        <result column="dayin_leixing" property="dayinLeixing"/>
        <result column="dayin_fenshu" property="dayinFenshu"/>
        <result column="dayin_fanwei" property="dayinFanwei"/>
        <result column="yema" property="yema"/>
        <result column="chengce_benshu" property="chengceBenshu"/>
        <result column="f_tenant_id" property="tenantId"/>
        <result column="f_delete_mark" property="deleteMark"/>
        <result column="f_delete_time" property="deleteTime"/>
        <result column="f_delete_user_id" property="deleteUserId"/>
        <result column="dayin_zhuangtai" property="dayinZhuangtai"/>
        <result column="yidayin_fenshu" property="yidayinFenshu"/>
        <result column="yiqianfa_shuliang" property="yiqianfaShuliang"/>
        <result column="weiqianfa_shuliang" property="weiqianfaShuliang"/>
        <result column="yihuishou_shuliang" property="yihuishouShuliang"/>
        <result column="f_version" property="version"/>
        <result column="f_flow_id" property="flowId"/>
        <result column="f_flow_task_id" property="flowTaskId"/>
        <result column="f_flow_state" property="flowState"/>
        <result column="dayinren" property="dayinren"/>
        <result column="dayin_shijian" property="dayinShijian"/>
        <result column="banben_id" property="banbenId"/>
    </resultMap>
 
    <select id="selectPrintItemForUpdate" resultMap="PrintItemResultMap">
        SELECT *
        FROM dms_jilu_dayin_shenqing_zixiang
        WHERE f_id = #{id}
          AND f_delete_mark IS NULL
        FOR UPDATE
    </select>
 
    <select id="countActivePrintRecords" resultType="int">
        SELECT COUNT(1)
        FROM dms_jilu_dayin_liushui
        WHERE dayin_zixiang_id = #{printItemId}
          AND f_delete_mark IS NULL
    </select>
 
    <insert id="insertPrintRecords">
        INSERT INTO dms_jilu_dayin_liushui (
            f_id, dayin_id, dayin_zixiang_id, liushuihao,
            dayinren, dayin_shijian, f_delete_mark
        ) VALUES
        <foreach collection="records" item="record" separator=",">
            (
                #{record.id}, #{record.dayinId}, #{record.dayinZixiangId},
                #{record.liushuihao}, #{record.dayinren},
                #{record.dayinShijian}, NULL
            )
        </foreach>
    </insert>
 
    <update id="markPrintItemProcessing">
        UPDATE dms_jilu_dayin_shenqing_zixiang
        SET yidayin_fenshu = dayin_fenshu,
            dayinren = #{dayinren},
            dayin_shijian = #{dayinShijian},
            dayin_zhuangtai = #{dayinZhuangtai},
            f_version = COALESCE(f_version, 0) + 1
        WHERE f_id = #{id}
          AND f_delete_mark IS NULL
          AND COALESCE(NULLIF(BTRIM(yidayin_fenshu), ''), '0') = '0'
          AND COALESCE(dayin_zhuangtai, '') &lt;&gt; #{dayinZhuangtai}
    </update>
 
</mapper>