feiyu02
2022-11-15 23bd719cebe5feeff4e48fde925b0b39755eea93
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
81
82
83
84
85
86
<?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="cn.flightfeather.supervision.domain.mapper.LedgerRecordMapper" >
  <resultMap id="BaseResultMap" type="cn.flightfeather.supervision.domain.entity.LedgerRecord" >
    <!--
      WARNING - @mbg.generated
    -->
    <id column="LR_GUID" property="lrGuid" jdbcType="VARCHAR" />
    <result column="LS_SubTypeId" property="lsSubtypeid" jdbcType="INTEGER" />
    <result column="LS_SubTypeName" property="lsSubtypename" jdbcType="VARCHAR" />
    <result column="LR_Year" property="lrYear" jdbcType="INTEGER" />
    <result column="LR_Month" property="lrMonth" jdbcType="TINYINT" />
    <result column="LR_Day" property="lrDay" jdbcType="TINYINT" />
    <result column="CI_GUID" property="ciGuid" jdbcType="VARCHAR" />
    <result column="CI_Name" property="ciName" jdbcType="VARCHAR" />
    <result column="LR_EASubmitKind" property="lrEasubmitkind" jdbcType="TINYINT" />
    <result column="LR_VerifierID" property="lrVerifierid" jdbcType="VARCHAR" />
    <result column="LR_VerifierRealName" property="lrVerifierrealname" jdbcType="VARCHAR" />
    <result column="LR_VerifyDate" property="lrVerifydate" jdbcType="TIMESTAMP" />
    <result column="LR_IsVerify" property="lrIsverify" jdbcType="BIT" />
    <result column="LR_VerifyRst" property="lrVerifyrst" jdbcType="VARCHAR" />
    <result column="LR_AIVerifyTime" property="lrAiverifytime" jdbcType="INTEGER" />
    <result column="LR_AIIsVerify" property="lrAiisverify" jdbcType="BIT" />
    <result column="LR_AIVerifyRst" property="lrAiverifyrst" jdbcType="VARCHAR" />
    <result column="LR_IsAI" property="lrIsai" jdbcType="BIT" />
    <result column="LR_SubmitID" property="lrSubmitid" jdbcType="VARCHAR" />
    <result column="LR_SubmitName" property="lrSubmitname" jdbcType="VARCHAR" />
    <result column="LR_IsSubmitOnTime" property="lrIssubmitontime" jdbcType="BIT" />
    <result column="LR_SubmitDate" property="lrSubmitdate" jdbcType="TIMESTAMP" />
    <result column="LR_UpdateType" property="lrUpdatetype" jdbcType="TINYINT" />
    <result column="LR_Extension1" property="lrExtension1" jdbcType="VARCHAR" />
    <result column="LR_Extension2" property="lrExtension2" jdbcType="VARCHAR" />
    <result column="LR_Extension3" property="lrExtension3" jdbcType="VARCHAR" />
    <result column="LR_Remark" property="lrRemark" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbg.generated
    -->
    LR_GUID, LS_SubTypeId, LS_SubTypeName, LR_Year, LR_Month, LR_Day, CI_GUID, CI_Name, 
    LR_EASubmitKind, LR_VerifierID, LR_VerifierRealName, LR_VerifyDate, LR_IsVerify, 
    LR_VerifyRst, LR_AIVerifyTime, LR_AIIsVerify, LR_AIVerifyRst, LR_IsAI, LR_SubmitID, 
    LR_SubmitName, LR_IsSubmitOnTime, LR_SubmitDate, LR_UpdateType, LR_Extension1, LR_Extension2, 
    LR_Extension3, LR_Remark
  </sql>
 
  <select id="selectByUser" resultMap="BaseResultMap">
    select *
    from ea_t_ledgerrecord
    where LR_SubmitID = #{param1} and LR_Year = #{param2} and LR_Month = #{param3}
    <if test="param4 != null">
      and LS_SubTypeId = #{param4}
    </if>
    <if test="param5 == 1">
      and (LR_Extension1 is null or LR_Extension1 = #{param5})
    </if>
    <if test="param5 != 0">
      and LR_Extension1 = #{param5}
    </if>
    <if test="param6 != null">
      limit #{param6}, #{param7}
    </if>
  </select>
 
  <select id="getNeedCopyLedgers" resultMap="BaseResultMap">
    SELECT * FROM
    (SELECT
    @row_number:=CASE WHEN @median_group = t_ledger.g THEN @row_number+1 else 1 END AS i,
    @median_group:= t_ledger.g AS median_group,
    t_ledger.*
    FROM
    (
    SELECT
    a.*,
    STR_TO_DATE(concat(a.LR_Year,'-',a.LR_Month,'-',a.LR_Day),'%Y-%m-%d') as d,
    CONCAT(a.LR_SubmitID, a.LS_SubTypeId) as g
    FROM
    ea_t_ledgerrecord AS a
    ORDER BY LR_SubmitID, LS_SubTypeId, d DESC
    ) as t_ledger
    LEFT JOIN sm_t_userinfo AS b ON t_ledger.LR_SubmitID = b.UI_GUID
    LEFT JOIN ea_t_ledgersubtype AS c ON t_ledger.LS_SubTypeId = c.LS_SubTypeId
    WHERE b.UI_IsEnable = TRUE AND c.L_Auto_Copy = TRUE) as r
    WHERE i = 1
  </select>
</mapper>