zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
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
<?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.changhong.epc.tenant.mapper.tenant.system.math.SystemMathMapper">
 
    <sql id="systemMathFiled">
        a.id aId, a.name aName, a.count aCount , a.view aView, a.type aType
        , a.result_fromat aResult, a.group_id aGroup
    </sql>
 
    <sql id="systemMathParamFiled">
        b.id bId, b.math_id bMath, b.md_code bMdCode, b.me_code bMeCode, b.join_math_id bJoin
        , b.def_val bDef, b.p_type bPType, b.p_index bIndex, b.md_name bMdName, b.me_name bMeName
    </sql>
 
    <resultMap type="com.changhong.epc.bean.count.system.SystemMathExtend" id="systemMathExtendMap">
        <id property="id" column="aId"/>
        <result property="name" column="aName"/>
        <result property="count" column="aCount"/>
        <result property="view" column="aView"/>
        <result property="type" column="aType"/>
        <result property="resultFromat" column="aResult"/>
        <result property="groupId" column="aGroup"/>
        <collection property="systemMathParam" ofType="com.changhong.epc.bean.count.system.SystemMathParam">
            <id property="id" column="bId"/>
            <result property="mathId" column="bMath"/>
            <result property="mdCode" column="bMdCode"/>
            <result property="meCode" column="bMeCode"/>
            <result property="joinMathId" column="bJoin"/>
            <result property="defVal" column="bDef"/>
            <result property="pType" column="bPType"/>
            <result property="pIndex" column="bIndex"/>
            <result property="mdName" column="bMdName"/>
            <result property="meName" column="bMeName"/>
        </collection>
    </resultMap>
 
    <resultMap type="com.changhong.epc.bean.count.system.SystemMath" id="systemMathNameMap">
        <id property="id" column="aId"/>
        <result property="name" column="aName"/>
    </resultMap>
 
    <select id="selectSystemMathNameList" resultMap="systemMathNameMap">
        select
            a.id aId, a.name aName
        from
            epc_system_math_{rule}   a
    </select>
 
    <select id="selectAllSystemMathExtend" resultMap="systemMathExtendMap">
        select
        <include refid="systemMathFiled"/>,
        <include refid="systemMathParamFiled"/>
        FROM
        epc_system_math_{rule} a
        LEFT JOIN epc_system_math_param_{rule} b ON b.math_id = a.id
        ORDER BY a.id DESC, b.p_index
    </select>
 
    <insert id="save" parameterType="com.changhong.epc.bean.count.system.SystemMathExtend"
            useGeneratedKeys="true" keyProperty="sys.id">
        insert into epc_system_math_{rule}  (id,name,count,view,type,result_fromat,group_id,data_start,ins_p,ins_t,upd_p,upd_t)
        values
        (null,#{sys.name},#{sys.count},#{sys.view},#{sys.type},#{sys.resultFromat},#{sys.groupId},#{sys.dataStart},#{sys.insP},#{sys.insT},#{sys.updP},#{sys.updT})
    </insert>
 
    <select id="getCostTypeByFormId" resultType="map">
 
        select f_name,type from epc_cost_from_mapping_${tenantId}_${companyId}
        where f_id = #{formId}
        and ct_id =
        (select C_type from formdata_${tenantId}_${formId} where datarownum = #{dataRowNum} limit 1)
        limit 1
    </select>
 
</mapper>