<?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.hzya.frame.plugin.incomeInvoiceData.dao.impl.IncomeInvoiceDaoImpl">


    <select id="queryData" resultType="com.alibaba.fastjson.JSONObject"  parameterType="com.alibaba.fastjson.JSONObject">
        select
        *
        from mdm_fp
        <trim prefix="where" prefixOverrides="and">
            <if test="fphm != null and fphm != ''"> and fphm = #{fphm} </if>
            and sts = 'Y' and data_status != 'N'
        </trim>
    </select>
    <insert id="saveData" parameterType="com.alibaba.fastjson.JSONObject">
        insert into mdm_fp(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''"> id , </if>
            <if test="document_rule != null and document_rule != ''"> document_rule , </if>
            <if test="document_rule_num != null"> document_rule_num , </if>
            <if test="data_status != null and data_status != ''"> data_status , </if>
            <if test="add_status != null and add_status != ''"> add_status , </if>
            <if test="update_status != null and update_status != ''"> update_status , </if>
            <if test="delete_status != null and delete_status != ''"> delete_status , </if>
            <if test="sorts != null"> sorts , </if>
            <if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
            <if test="create_time != null"> create_time , </if>
            <if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
            <if test="modify_time != null"> modify_time , </if>
            <if test="sts != null and sts != ''"> sts , </if>
            <if test="org_id != null and org_id != ''"> org_id , </if>
            <if test="companyId != null and companyId != ''"> company_id , </if>

            <if test="fphm != null and fphm != ''"> fphm , </if>
            <if test="fpdm != null and fpdm != ''"> fpdm , </if>
            <if test="kprq != null and kprq != ''"> kprq , </if>
            <if test="xfsh != null and xfsh != ''"> xfsh , </if>
            <if test="xfmc != null and xfmc != ''"> xfmc , </if>
            <if test="gfsh != null and gfsh != ''"> gfsh , </if>
            <if test="gfmc != null and gfmc != ''"> gfmc , </if>
            <if test="hjje != null and hjje != ''"> hjje , </if>
            <if test="hjse != null and hjse != ''"> hjse , </if>
            <if test="jshj != null and jshj != ''"> jshj , </if>
            <if test="jym != null and jym != ''"> jym , </if>
            <if test="xfdzdh != null and xfdzdh != ''"> xfdzdh , </if>
            <if test="xfyhzh != null and xfyhzh != ''"> xfyhzh , </if>
            <if test="gfdzdh != null and gfdzdh != ''"> gfdzdh , </if>
            <if test="gfyhzh != null and gfyhzh != ''"> gfyhzh , </if>
            <if test="mmq != null and mmq != ''"> mmq , </if>
            <if test="bz != null and bz != ''"> bz , </if>
            <if test="jqbh != null and jqbh != ''"> jqbh , </if>
            <if test="jdhm != null and jdhm != ''"> jdhm , </if>
            <if test="kpr != null and kpr != ''"> kpr , </if>
            <if test="skr != null and skr != ''"> skr , </if>
            <if test="fhr != null and fhr != ''"> fhr , </if>
            <if test="url != null and url != ''"> url , </if>
            <if test="ofdurl != null and ofdurl != ''"> ofdurl , </if>
            <if test="xmlurl != null and xmlurl != ''"> xmlurl , </if>
            <if test="htbh != null and htbh != ''"> htbh , </if>


        </trim>
        )values
        (
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''"> #{id} , </if>
            <if test="document_rule != null and document_rule != ''"> #{document_rule} , </if>
            <if test="document_rule_num != null"> #{document_rule_num} , </if>
            <if test="data_status != null and data_status != ''"> #{data_status} , </if>
            <if test="add_status != null and add_status != ''"> #{add_status} , </if>
            <if test="update_status != null and update_status != ''"> #{update_status} , </if>
            <if test="delete_status != null and delete_status != ''"> #{delete_status} , </if>
            <if test="sorts != null"> #{sorts} , </if>
            <if test="create_user_id != null and create_user_id != ''"> #{create_user_id} , </if>
            <if test="create_time != null"> #{create_time} , </if>
            <if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} , </if>
            <if test="modify_time != null"> #{modify_time} , </if>
            <if test="sts != null and sts != ''"> #{sts} , </if>
            <if test="org_id != null and org_id != ''"> #{org_id} , </if>
            <if test="companyId != null and companyId != ''"> #{company_id} , </if>

            <if test="fphm != null and fphm != ''"> #{fphm} , </if>
            <if test="fpdm != null and fpdm != ''"> #{fpdm} , </if>
            <if test="kprq != null and kprq != ''"> #{kprq} , </if>
            <if test="xfsh != null and xfsh != ''"> #{xfsh} , </if>
            <if test="xfmc != null and xfmc != ''"> #{xfmc} , </if>
            <if test="gfsh != null and gfsh != ''"> #{gfsh} , </if>
            <if test="gfmc != null and gfmc != ''"> #{gfmc} , </if>
            <if test="hjje != null and hjje != ''"> #{hjje} , </if>
            <if test="hjse != null and hjse != ''"> #{hjse} , </if>
            <if test="jshj != null and jshj != ''"> #{jshj} , </if>
            <if test="jym != null and jym != ''"> #{jym} , </if>
            <if test="xfdzdh != null and xfdzdh != ''"> #{xfdzdh} , </if>
            <if test="xfyhzh != null and xfyhzh != ''"> #{xfyhzh} , </if>
            <if test="gfdzdh != null and gfdzdh != ''"> #{gfdzdh} , </if>
            <if test="gfyhzh != null and gfyhzh != ''"> #{gfyhzh} , </if>
            <if test="mmq != null and mmq != ''"> #{mmq} , </if>
            <if test="bz != null and bz != ''"> #{bz} , </if>
            <if test="jqbh != null and jqbh != ''"> #{jqbh} , </if>
            <if test="jdhm != null and jdhm != ''"> #{jdhm} , </if>
            <if test="kpr != null and kpr != ''"> #{kpr} , </if>
            <if test="skr != null and skr != ''"> #{skr} , </if>
            <if test="fhr != null and fhr != ''"> #{fhr} , </if>
            <if test="url != null and url != ''"> #{url} , </if>
            <if test="ofdurl != null and ofdurl != ''"> #{ofdurl} , </if>
            <if test="xmlurl != null and xmlurl != ''"> #{xmlurl} , </if>
            <if test="htbh != null and htbh != ''"> #{htbh} , </if>

        </trim>
        )
    </insert>
    <insert id="saveDetailData" parameterType="com.alibaba.fastjson.JSONObject">
        insert into mdm_fp_detail(
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''"> id , </if>
            <if test="formmain_id != null and formmain_id != ''"> formmain_id , </if>
            <if test="data_status != null and data_status != ''"> data_status , </if>
            <if test="sorts != null"> sorts , </if>
            <if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
            <if test="create_time != null"> create_time , </if>
            <if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
            <if test="modify_time != null"> modify_time , </if>
            <if test="sts != null and sts != ''"> sts , </if>
            <if test="org_id != null and org_id != ''"> org_id , </if>
            <if test="companyId != null and companyId != ''"> company_id , </if>
            <if test="remark != null and remark != ''"> remark , </if>

            <if test="xh != null and xh != ''"> xh , </if>
            <if test="ssflbm != null and ssflbm != ''"> ssflbm , </if>
            <if test="xmmc != null and xmmc != ''"> xmmc , </if>
            <if test="ggxh != null and ggxh != ''"> ggxh , </if>
            <if test="dw != null and dw != ''"> dw , </if>
            <if test="sl != null and sl != ''"> sl , </if>
            <if test="dj != null and dj != ''"> dj , </if>
            <if test="je != null and je != ''"> je , </if>
            <if test="slv != null and slv != ''"> slv , </if>
            <if test="se != null and se != ''"> se , </if>



        </trim>
        )values
        (
        <trim suffix="" suffixOverrides=",">
            <if test="id != null and id != ''"> #{id} , </if>
            <if test="formmain_id != null and formmain_id != ''"> #{formmain_id} , </if>
            <if test="data_status != null and data_status != ''"> #{data_status}, </if>
            <if test="sorts != null"> #{sorts} , </if>
            <if test="create_user_id != null and create_user_id != ''"> #{create_user_id} , </if>
            <if test="create_time != null"> #{create_time} , </if>
            <if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} , </if>
            <if test="modify_time != null"> #{modify_time} , </if>
            <if test="sts != null and sts != ''"> #{sts} , </if>
            <if test="org_id != null and org_id != ''"> #{org_id} , </if>
            <if test="companyId != null and companyId != ''"> #{company_id} , </if>
            <if test="remark != null and remark != ''"> #{remark} , </if>

            <if test="xh != null and xh != ''"> #{xh} , </if>
            <if test="ssflbm != null and ssflbm != ''"> #{ssflbm} , </if>
            <if test="xmmc != null and xmmc != ''"> #{xmmc} , </if>
            <if test="ggxh != null and ggxh != ''"> #{ggxh} , </if>
            <if test="dw != null and dw != ''"> #{dw} , </if>
            <if test="sl != null and sl != ''"> #{sl} , </if>
            <if test="dj != null and dj != ''"> #{dj} , </if>
            <if test="je != null and je != ''"> #{je} , </if>
            <if test="slv != null and slv != ''"> #{slv} , </if>
            <if test="se != null and se != ''"> #{se} , </if>

        </trim>
        )
    </insert>
    <select id="queryOaZb" resultType="com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity"  parameterType="com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity">
        select
        id as dataId,
        field0003
        from formmain_0323
        <trim prefix="where" prefixOverrides="and">
            <if test="field0003 != null and field0003 != ''"> and field0003 = #{field0003} </if>
        </trim>
    </select>

    <select id="queryOaMx" resultType="com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity"  parameterType="com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity">
        select
        id as dataId
        from formson_0702
        <trim prefix="where" prefixOverrides="and">
            <if test="field0128 != null and field0128 != ''"> and field0128 = #{field0128} </if>
        </trim>
    </select>

    <update id="updateMx" parameterType = "com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity" >
        update formson_0702  set
        <trim suffix="" suffixOverrides=",">
            <if test="field0127 != null and field0127 != ''"> field0127 = #{field0127},</if>
            <if test="field0128 != null and field0128 != ''"> field0128 = #{field0128},</if>
            <if test="field0129 != null and field0129 != ''"> field0129 = #{field0129},</if>
            <if test="field0130 != null and field0130 != ''"> field0130 = #{field0130},</if>
        </trim>
        where  id = #{dataId}
    </update>

    <insert id="saveMx" parameterType="com.hzya.frame.report.reportManage.entity.ReportManageEntity">
        insert into formson_0702(
        <trim suffix="" suffixOverrides=",">
            <if test="dataId != null and dataId != ''">id ,</if>
            <if test="formmainId != null and formmainId != ''">formmain_id ,</if>
            <if test="field0127 != null and field0127 != ''">field0127 ,</if>
            <if test="field0128 != null and field0128 != ''">field0128 ,</if>
            <if test="field0129 != null and field0129 != ''">field0129 ,</if>
            <if test="field0130 != null and field0130 != ''">field0130 ,</if>

        </trim>
        )values(
        <trim suffix="" suffixOverrides=",">
            <if test="dataId != null and dataId != ''">#{dataId} ,</if>
            <if test="formmainId != null and formmainId != ''">#{formmainId} ,</if>
            <if test="field0127 != null and field0127 != ''">#{field0127} ,</if>
            <if test="field0128 != null and field0128 != ''">#{field0128} ,</if>
            <if test="field0129 != null and field0129 != ''">#{field0129} ,</if>
            <if test="field0130 != null and field0130 != ''">#{field0130} ,</if>
        </trim>
        )
    </insert>


    <select id="queryZtzz" resultType="com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity"  parameterType="com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity">
        SELECT
        *
        FROM
        (
        SELECT
        iufo.alone_id AS aloneId,
        iufo.keyword2 AS sysData,
        orgs.code AS orgCode,
        orgs.name AS orgName,
        iufo.ver AS iufoVer
        FROM
        IUFO_MEASPUB_VIOU iufo
        LEFT JOIN org_orgs orgs ON iufo.keyword1 = orgs.pk_org

        <trim prefix="where" prefixOverrides="and">
            <if test="orgCode != null and orgCode !='' "> and orgs.code = #{orgCode} </if>
            and ver = '0'
            <if test="sysData != null and sysData !='' "> and iufo.keyword2 LIKE  CONCAT(#{sysData}, '%')   </if>
        </trim>
        ORDER BY
        iufo.keyword2 DESC
        )
        WHERE
        ROWNUM = 1

    </select>


    <select id="queryByAloneId" resultType="com.alibaba.fastjson.JSONObject"  parameterType="com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity">

        SELECT
        a.ALONE_ID as ALONE_ID,
        a.M10004 as AM10004,
        a.M10005 as AM10005,
        a.M10010 as AM10010,
        a.M10012 as AM10012,
        a.M10014 as AM10014,
        a.M10019 as AM10019,
        a.M10020 as AM10020,
        a.M10021 as AM10021,
        a.M10022 as AM10022,
        a.M10025 as AM10025,
        a.M10110 as AM10110,
        a.M10027 as AM10027,
        a.M10112 as AM10112,
        a.M10029 as AM10029,
        a.M10032 as AM10032,
        a.M10033 as AM10033,
        a.M10034 as AM10034,
        a.M10035 as AM10035,
        a.M10040 as AM10040,
        a.M10128 as AM10128,
        a.M10042 as AM10042,
        a.M10130 as AM10130,
        a.M10044 as AM10044,
        a.M10045 as AM10045,
        a.M10046 as AM10046,
        a.M10047 as AM10047,
        a.M10048 as AM10048,
        a.M10049 as AM10049,
        a.M10050 as AM10050,
        a.M10051 as AM10051,
        a.M10052 as AM10052,
        a.M10053 as AM10053,
        a.M10054 as AM10054,
        a.M10055 as AM10055,
        a.M10057 as AM10057,
        a.M10059 as AM10059,
        a.M10060 as AM10060,
        a.M10061 as AM10061,
        a.M10062 as AM10062,
        a.M10063 as AM10063,
        a.M10064 as AM10064,
        a.M10065 as AM10065,
        a.M10066 as AM10066,
        a.M10073 as AM10073,
        a.M10146 as AM10146,
        a.M10075 as AM10075,
        a.M10148 as AM10148,
        a.M10077 as AM10077,
        a.M10078 as AM10078,
        a.M10079 as AM10079,
        a.M10080 as AM10080,
        a.M10081 as AM10081,
        a.M10082 as AM10082,
        a.M10083 as AM10083,
        a.M10084 as AM10084,
        a.M10087 as AM10087,
        a.M10088 as AM10088,
        a.M10091 as AM10091,
        a.M10164 as AM10164,
        a.M10093 as AM10093,
        a.M10166 as AM10166,
        a.M10095 as AM10095,
        a.M10096 as AM10096,
        a.M10097 as AM10097,
        a.M10098 as AM10098,
        a.M10099 as AM10099,
        a.M10100 as AM10100,
        a.M10101 as AM10101,
        a.M10102 as AM10102,
        a.M10105 as AM10105,
        a.M10106 as AM10106,
        a.M10109 as AM10109,
        a.M10182 as AM10182,
        a.M10111 as AM10111,
        a.M10184 as AM10184,
        a.M10113 as AM10113,
        a.M10114 as AM10114,
        a.M10115 as AM10115,
        a.M10116 as AM10116,
        a.M10117 as AM10117,
        a.M10118 as AM10118,
        a.M10119 as AM10119,
        a.M10120 as AM10120,
        a.M10123 as AM10123,
        a.M10124 as AM10124,
        a.M10127 as AM10127,
        a.M10200 as AM10200,
        a.M10129 as AM10129,
        a.M10202 as AM10202,
        a.M10131 as AM10131,
        a.M10132 as AM10132,
        a.M10133 as AM10133,
        a.M10134 as AM10134,
        a.M10135 as AM10135,
        a.M10138 as AM10138,
        a.M10141 as AM10141,
        a.M10142 as AM10142,
        a.M10143 as AM10143,
        a.M10144 as AM10144,
        a.M10145 as AM10145,
        a.M10147 as AM10147,
        a.M10149 as AM10149,
        a.M10150 as AM10150,
        a.M10151 as AM10151,
        a.M10152 as AM10152,
        a.M10153 as AM10153,
        a.M10154 as AM10154,
        a.M10155 as AM10155,
        a.M10156 as AM10156,
        a.M10257 as AM10257,
        a.M10259 as AM10259,
        a.M10159 as AM10159,
        a.M10160 as AM10160,
        a.M10161 as AM10161,
        a.M10162 as AM10162,
        a.M10163 as AM10163,
        a.M10165 as AM10165,
        a.M10167 as AM10167,
        a.M10168 as AM10168,
        a.M10169 as AM10169,
        a.M10170 as AM10170,
        a.M10171 as AM10171,
        a.M10172 as AM10172,
        a.M10173 as AM10173,
        a.M10174 as AM10174,
        a.M10281 as AM10281,
        a.M10283 as AM10283,
        a.M10179 as AM10179,
        a.M10180 as AM10180,
        a.M10181 as AM10181,
        a.M10222 as AM10222,
        a.M10183 as AM10183,
        a.M10224 as AM10224,
        a.M10185 as AM10185,
        a.M10186 as AM10186,
        a.M10187 as AM10187,
        a.M10188 as AM10188,
        a.M10189 as AM10189,
        a.M10190 as AM10190,
        a.M10191 as AM10191,
        a.M10192 as AM10192,
        a.M10295 as AM10295,
        a.M10193 as AM10193,
        a.M10297 as AM10297,
        a.M10194 as AM10194,
        a.M10195 as AM10195,
        a.M10196 as AM10196,
        a.M10197 as AM10197,
        a.M10198 as AM10198,
        a.M10199 as AM10199,
        a.M10201 as AM10201,
        a.M10203 as AM10203,
        a.M10208 as AM10208,
        a.M10209 as AM10209,
        a.M10212 as AM10212,
        a.M10310 as AM10310,
        a.M10214 as AM10214,
        a.M10312 as AM10312,
        a.M10216 as AM10216,
        a.M10217 as AM10217,
        a.M10218 as AM10218,
        a.M10219 as AM10219,
        a.M10220 as AM10220,
        a.M10221 as AM10221,
        a.M10223 as AM10223,
        a.M10225 as AM10225,
        a.M10226 as AM10226,
        a.M10227 as AM10227,
        a.M10230 as AM10230,
        a.M10231 as AM10231,
        a.M10234 as AM10234,
        a.M10325 as AM10325,
        a.M10236 as AM10236,
        a.M10327 as AM10327,
        a.M10238 as AM10238,
        a.M10239 as AM10239,
        a.M10240 as AM10240,
        a.M10241 as AM10241,
        a.M10242 as AM10242,
        a.M10243 as AM10243,
        a.M10244 as AM10244,
        a.M10245 as AM10245,
        a.M10246 as AM10246,
        a.M10247 as AM10247,
        a.M10248 as AM10248,
        a.M10249 as AM10249,
        a.M10250 as AM10250,
        a.M10251 as AM10251,
        a.M10252 as AM10252,
        a.M10253 as AM10253,
        a.M10256 as AM10256,
        a.M10340 as AM10340,
        a.M10258 as AM10258,
        a.M10342 as AM10342,
        a.M10260 as AM10260,
        a.M10265 as AM10265,
        a.M10266 as AM10266,
        a.M10267 as AM10267,
        a.M10268 as AM10268,
        a.M10269 as AM10269,
        a.M10276 as AM10276,
        a.M10277 as AM10277,
        a.M10280 as AM10280,
        a.M10282 as AM10282,
        a.M10284 as AM10284,
        a.M10287 as AM10287,
        a.M10288 as AM10288,
        a.M10289 as AM10289,
        a.M10290 as AM10290,
        a.M10291 as AM10291,
        a.M10292 as AM10292,
        a.M10293 as AM10293,
        a.M10294 as AM10294,
        a.M10011 as AM10011,
        a.M10296 as AM10296,
        a.M10013 as AM10013,
        a.M10298 as AM10298,
        a.M10299 as AM10299,
        a.M10300 as AM10300,
        a.M10301 as AM10301,
        a.M10304 as AM10304,
        a.M10305 as AM10305,
        a.M10306 as AM10306,
        a.M10307 as AM10307,
        a.M10308 as AM10308,
        a.M10309 as AM10309,
        a.M10026 as AM10026,
        a.M10311 as AM10311,
        a.M10028 as AM10028,
        a.M10313 as AM10313,
        a.M10314 as AM10314,
        a.M10315 as AM10315,
        a.M10316 as AM10316,
        a.M10319 as AM10319,
        a.M10320 as AM10320,
        a.M10321 as AM10321,
        a.M10323 as AM10323,
        a.M10326 as AM10326,
        a.M10041 as AM10041,
        a.M10328 as AM10328,
        a.M10043 as AM10043,
        a.M10329 as AM10329,
        a.M10334 as AM10334,
        a.M10335 as AM10335,
        a.M10336 as AM10336,
        a.M10338 as AM10338,
        a.M10337 as AM10337,
        a.M10339 as AM10339,
        a.M10341 as AM10341,
        a.M10056 as AM10056,
        a.M10343 as AM10343,
        a.M10058 as AM10058,
        a.M10344 as AM10344,
        a.M10347 as AM10347,
        a.M10348 as AM10348,
        a.M10349 as AM10349,
        a.M10350 as AM10350,
        a.M10351 as AM10351,
        a.M10352 as AM10352,
        a.M10353 as AM10353,
        a.M10354 as AM10354,
        b.MPQW10U as BMPQW10U,
        b.MP81A2Z as BMP81A2Z,
        b.MS13DPL as BMS13DPL,
        b.M6TFKPL as BM6TFKPL,
        c.M10002 as CM10002,
        c.M10000 as CM10000,
        c.M10004 as CM10004,
        c.M10003 as CM10003,
        c.M10001 as CM10001
        FROM
        iufo_measure_data_qi0xy5nl a
        LEFT JOIN iufo_measure_data_v40w9co7 b on a.ALONE_ID = b.ALONE_ID
        LEFT JOIN iufo_measure_data_jz8zffdp c on a.ALONE_ID = c.ALONE_ID
        <trim prefix="where" prefixOverrides="and">
            <if test="aloneId != null and aloneId != ''"> and a.ALONE_ID = #{aloneId} </if>
        </trim>
    </select>
</mapper>

