InputInvoiceExtendsMapper.xml 13.1 KB
Newer Older
sherlock's avatar
sherlock committed
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
<?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="pwc.taxtech.atms.invoice.InputInvoiceMapper">

    <select id="getInputVATInvoiceCountByCondition" parameterType="pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam" resultType="java.lang.Long">
        SELECT
        COUNT (
        1
        )
        FROM
        INPUT_VAT_INVOICE
        WHERE
        1=1
        <if test="paras.periodStart">
            AND PERIOD_ID &gt;= #{paras.periodStart,jdbcType=VARCHAR}
        </if>
        <if test="paras.periodEnd">
            AND PERIOD_ID &lt;= #{paras.periodEnd,jdbcType=VARCHAR}
        </if>
        <if test="paras.certificationDateStart != null">
            AND CERTIFICATION_DATE &gt;= #{paras.certificationDateStart,jdbcType=VARCHAR}
        </if>
        <if test="paras.certificationDateEnd != null">
            AND CERTIFICATION_DATE &lt;= #{paras.certificationDateEnd,jdbcType=VARCHAR}
        </if>
        <if test="paras.invoiceCode != null and paras.invoiceCode!=''">
            AND INVOICE_CODE LIKE concat (
            '%',
            #{paras.invoiceCode,jdbcType=VARCHAR},
            '%'
            )
        </if>
        <if test="paras.invoiceNumber!=null and paras.invoiceNumber!=''">
            AND INVOICE_NUMBER LIKE concat (
            '%',
            #{paras.invoiceNumber,jdbcType=VARCHAR},
            '%'
            )
        </if>
        <if test="paras.sellerTaxNumber!=null and paras.sellerTaxNumber!=''">
            AND SELLER_TAX_NUMBER LIKE concat (
            '%',
            #{paras.sellerTaxNumber,jdbcType=VARCHAR},
            '%'
            )
        </if>
        <if test="paras.amountStart != null">
            AND AMOUNT &gt;= #{paras.amountStart,jdbcType=DECIMAL}
        </if>
        <if test="paras.amountEnd != null">
            AND AMOUNT &lt;= #{paras.amountEnd,jdbcType=DECIMAL}
        </if>
        <if test="paras.taxAmountStart != null">
            AND TAX_AMOUNT &gt;= #{paras.taxAmountStart,jdbcType=DECIMAL}
        </if>
        <if test="paras.taxAmountEnd != null">
            AND TAX_AMOUNT &lt;= #{paras.taxAmountEnd,jdbcType=DECIMAL}
        </if>
        <if test="paras.invoiceType!=null and paras.invoiceType!=999">
            AND INVOICE_TYPE_= #{param.invoiceType,jdbcType=INTEGER}
        </if>
        <if test="paras.certificationStatus==1">
            AND CERTIFICATION_RESULT LIKE '%1%'
        </if>
        <if test="paras.certificationStatus==2">
            AND CERTIFICATION_RESULT LIKE '%2%'
        </if>
    </select>

    <select id="getInputVATInvoiceCountByConditionWithPaging" resultMap="BaseResultMap">
        SELECT
        *
        FROM
        INPUT_VAT_INVOICE
        WHERE
        1=1
        <if test="paras.periodStart">
            AND PERIOD_ID &gt;= #{paras.periodStart,jdbcType=VARCHAR}
        </if>
        <if test="paras.periodEnd">
            AND PERIOD_ID &lt;= #{paras.periodEnd,jdbcType=VARCHAR}
        </if>
        <if test="paras.certificationDateStart != null">
            AND CERTIFICATION_DATE &gt;= #{paras.certificationDateStart,jdbcType=VARCHAR}
        </if>
        <if test="paras.certificationDateEnd != null">
            AND CERTIFICATION_DATE &lt;= #{paras.certificationDateEnd,jdbcType=VARCHAR}
        </if>
        <if test="paras.invoiceCode != null and paras.invoiceCode!=''">
            AND INVOICE_CODE LIKE concat (
            '%',
            #{paras.invoiceCode,jdbcType=VARCHAR},
            '%'
            )
        </if>
        <if test="paras.invoiceNumber!=null and paras.invoiceNumber!=''">
            AND INVOICE_NUMBER LIKE concat (
            '%',
            #{paras.invoiceNumber,jdbcType=VARCHAR},
            '%'
            )
        </if>
        <if test="paras.sellerTaxNumber!=null and paras.sellerTaxNumber!=''">
            AND SELLER_TAX_NUMBER LIKE concat (
            '%',
            #{paras.sellerTaxNumber,jdbcType=VARCHAR},
            '%'
            )
        </if>
        <if test="paras.amountStart != null">
            AND AMOUNT &gt;= #{paras.amountStart,jdbcType=DECIMAL}
        </if>
        <if test="paras.amountEnd != null">
            AND AMOUNT &lt;= #{paras.amountEnd,jdbcType=DECIMAL}
        </if>
        <if test="paras.taxAmountStart != null">
            AND TAX_AMOUNT &gt;= #{paras.taxAmountStart,jdbcType=DECIMAL}
        </if>
        <if test="paras.taxAmountEnd != null">
            AND TAX_AMOUNT &lt;= #{paras.taxAmountEnd,jdbcType=DECIMAL}
        </if>
        <if test="paras.invoiceType!=null and paras.invoiceType!=999">
            AND INVOICE_TYPE_= #{param.invoiceType,jdbcType=INTEGER}
        </if>
        <if test="paras.certificationStatus==1">
            AND CERTIFICATION_RESULT LIKE '%1%'
        </if>
        <if test="paras.certificationStatus==2">
            AND CERTIFICATION_RESULT LIKE '%2%'
        </if>
        ORDER BY
        InvoiceDate
        <if test="paras.pageInfo!=null and paras.pageInfo.pageSize!=null and limitFrom!=null">
            LIMIT #{limitFrom,jdbcType=INTEGER},
            #{paras.pageInfo.pageSize,jdbcType=INTEGER}
        </if>
    </select>

sherlock's avatar
sherlock committed
139
    <resultMap id="inputInvoiceResultDto" type="pwc.taxtech.atms.vat.dpo.InputInvoiceResultDto">
sherlock's avatar
sherlock committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
        <id property="invoiceID" column="invoice_id"/>
        <association property="inputVATInvoice" javaType="pwc.taxtech.atms.vat.entity.InputVatInvoice">
            <id column="ID" jdbcType="VARCHAR" property="id"/>
            <result column="PERIOD_ID" jdbcType="INTEGER" property="periodId"/>
            <result column="INVOICE_CODE" jdbcType="VARCHAR" property="invoiceCode"/>
            <result column="INVOICE_NUMBER" jdbcType="VARCHAR" property="invoiceNumber"/>
            <result column="INVOICE_DATE" jdbcType="TIMESTAMP" property="invoiceDate"/>
            <result column="SELLER_TAX_NUMBER" jdbcType="VARCHAR" property="sellerTaxNumber"/>
            <result column="AMOUNT" jdbcType="DECIMAL" property="amount"/>
            <result column="TAX_AMOUNT" jdbcType="DECIMAL" property="taxAmount"/>
            <result column="INVOICE_TYPE" jdbcType="INTEGER" property="invoiceType"/>
            <result column="CERTIFICATION_RESULT" jdbcType="VARCHAR" property="certificationResult"/>
            <result column="CERTIFICATION_DATE" jdbcType="TIMESTAMP" property="certificationDate"/>
            <result column="CREATOR_ID" jdbcType="VARCHAR" property="creatorId"/>
            <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
            <result column="STATUS" jdbcType="INTEGER" property="status"/>
            <result column="PART_ACCNTED_PERIOD" jdbcType="INTEGER" property="partAccntedPeriod"/>
            <result column="ACCNTED_PERIOD" jdbcType="INTEGER" property="accntedPeriod"/>
        </association>
        <association property="inputVATInvoiceItem" javaType="pwc.taxtech.atms.vat.entity.InputVatInvoiceItem">
            <id column="ID" jdbcType="VARCHAR" property="id"/>
            <result column="INPUT_VAT_INVOICE_ID" jdbcType="VARCHAR" property="inputVATInvoiceId"/>
            <result column="PERIOD_ID" jdbcType="INTEGER" property="periodId"/>
            <result column="INVOICE_CODE" jdbcType="VARCHAR" property="invoiceCode"/>
            <result column="INVOICE_NUMBER" jdbcType="VARCHAR" property="invoiceNumber"/>
            <result column="AMOUNT" jdbcType="DECIMAL" property="amount"/>
            <result column="TAX_AMOUNT" jdbcType="DECIMAL" property="taxAmount"/>
            <result column="TAX_RATE" jdbcType="DECIMAL" property="taxRate"/>
            <result column="PRODUCTION_NAME" jdbcType="VARCHAR" property="productionName"/>
            <result column="CREATOR_ID" jdbcType="VARCHAR" property="creatorId"/>
            <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
            <result column="PRODUCTION_CODE" jdbcType="VARCHAR" property="productionCode"/>
        </association>
        <association property="goodsMapping" javaType="pwc.taxtech.atms.vat.entity.GoodsMapping">
            <id column="ID" jdbcType="VARCHAR" property="id"/>
            <result column="CUST_GOODS_NAME" jdbcType="VARCHAR" property="custGoodsName"/>
            <result column="STD_GOODS_NAME" jdbcType="VARCHAR" property="stdGoodsName"/>
            <result column="CREATOR_ID" jdbcType="VARCHAR" property="creatorId"/>
            <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
            <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/>
        </association>
    </resultMap>

sherlock's avatar
sherlock committed
183
    <select id="getInputInvoiceResultDto" resultMap="inputInvoiceResultDto">
sherlock's avatar
sherlock committed
184 185 186
        SELECT
        INPUT_INVOICE.ID AS INVOICE_ID,
        INPUTINVOICE.ID,
sherlock's avatar
sherlock committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
--         INPUTINVOICE.PERIOD_ID,
        INPUTINVOICE.FPDM,
        INPUTINVOICE.FPHM,
        INPUTINVOICE.KPRQ,
        INPUTINVOICE.XFSH,
        INPUTVATINVOICE.HJJE,
        INPUTVATINVOICE.HJSE,
        INPUTVATINVOICE.FPLX,
        INPUTVATINVOICE.RZJG,
        INPUTVATINVOICE.RJSJ,
--         INPUTVATINVOICE.CREATOR_ID,
        INPUTVATINVOICE.CJSJ,
--         INPUTVATINVOICE.`_S_T_A_T_U_S_`,
--         INPUTVATINVOICE.PART_ACCNTED_PERIOD,
--         INPUTVATINVOICE.ACCNTED_PERIOD,
        INPUTINVOICEDETAIL.ID,
        INPUTINVOICEDETAIL.FPID,
--         INPUTINVOICEDETAIL.PERIOD_ID,
        INPUTINVOICEDETAIL.FPDM,
        INPUTVATINVOICEITEM.FPHM,
        INPUTVATINVOICEITEM.JE,
        INPUTVATINVOICEITEM.SE,
        INPUTVATINVOICEITEM.SLV,
        INPUTVATINVOICEITEM.SPMC,
--         INPUTVATINVOICEITEM.CREATOR_ID,
--         INPUTVATINVOICEITEM.CREATE_TIME,
        INPUTVATINVOICEITEM.GGXH
sherlock's avatar
sherlock committed
214
        FROM
sherlock's avatar
sherlock committed
215
          INPUT_INVOICE INPUTINVOICE
sherlock's avatar
sherlock committed
216
        JOIN
sherlock's avatar
sherlock committed
217
          INPUT_INVOICE_DETAIL INPUTINVOICEDETAIL
sherlock's avatar
sherlock committed
218 219 220
        ON
        INPUTINVOICE.ID = INPUTINVOICEDETAIL.FPID
        AND INPUT_INVOICE.PERIOD_ID = INPUTVATINVOICEITEM.PERIOD_ID
sherlock's avatar
sherlock committed
221 222 223 224
--         LEFT JOIN
--           ${dbName}.INPUT_MATERIAL_ITEM MATERIALITEM
--         ON
--         INPUTVATINVOICEITEM.PRODUCTION_NAME = MATERIALITEM.CUST_GOODS_NAME
sherlock's avatar
sherlock committed
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
    </select>

    <resultMap id="cellInvoiceDto" type="pwc.taxtech.atms.vat.dpo.CellInvoiceDto">
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <result column="INVOICE_DATE" jdbcType="VARCHAR" property="invoiceDate"/>
        <result column="INVOICE_NUMBER" jdbcType="VARCHAR" property="invoiceNumber"/>
        <result column="INVOICE_CODE" jdbcType="VARCHAR" property="invoiceCode"/>
        <result column="AMOUNT" jdbcType="VARCHAR" property="amount"/>
        <result column="TAX_AMOUNT" jdbcType="VARCHAR" property="taxAmount"/>
        <result column="RATE" jdbcType="VARCHAR" property="rate"/>
        <result column="PRODUCTION_NAME" jdbcType="VARCHAR" property="productionName"/>
        <result column="DATA_SOURCE_ID" jdbcType="VARCHAR" property="dataSourceId"/>
        <result column="DATA_SOURCE_NAME" jdbcType="VARCHAR" property="dataSourceName"/>
        <result column="OPERATION_TYPE" jdbcType="VARCHAR" property="operationType"/>
        <result column="INVOICE_TYPE" jdbcType="VARCHAR" property="invoiceType"/>
    </resultMap>

    <select id="selectInputInvoiceWithItem" resultMap="cellInvoiceDto">
        SELECT
        III.ID AS ID,
        ii.FPRQ AS INVOICE_DATE,
        iii.FPHM AS INVOICE_NUMBER,
        iii.FPDM AS INVOICE_CODE,
        iii.JE AS AMOUNT,
        iii.SE AS TAX_AMOUNT,
        iii.SLV AS RATE,
        iii.SPMC AS PRODUCTION_NAME,
        ii.FPLX AS INVOICE_TYPE
        FROM
        INPUT_INVOICE_DETAIL iii
        JOIN
        INPUT_INVOICE ii
        ON
        iii.FPID = ii.ID
    </select>

    <resultMap id="inputVATInvoiceItemExtendDto" type="pwc.taxtech.atms.dto.vatdto.InputVATInvoiceItemExtendDto">
        <id column="invoiceId" jdbcType="VARCHAR" property="invoiceId"/>
        <result column="INVOICE_ITEM_ID" jdbcType="VARCHAR" property="invoiceItemId"/>
        <result column="PERIOD" jdbcType="INTEGER" property="period"/>
        <result column="CERTIFICATION_DATE" jdbcType="TIMESTAMP" property="certificationDate"/>
        <result column="SELLER_TAX_NUMBER" jdbcType="VARCHAR" property="sellerTaxNumber"/>
        <result column="INVOICE_CODE" jdbcType="VARCHAR" property="invoiceCode"/>
        <result column="INVOICE_NUMBER" jdbcType="VARCHAR" property="invoiceNumber"/>
        <result column="AMOUNT" jdbcType="DECIMAL" property="amount"/>
        <result column="INVOICE_TYPE" jdbcType="INTEGER" property="invoiceType"/>
        <result column="TAX_AMOUNT" jdbcType="DECIMAL" property="taxAmount"/>
    </resultMap>

    <select id="selectInvoiceExtendDto" resultMap="inputVATInvoiceItemExtendDto">
        SELECT
        B.ID AS INVOICE_ID,
        A.ID AS INVOICE_ITEM_ID,
        A.PERIOD_ID AS PERIOD,
        B.CERTIFICATION_DATE AS CERTIFICATION_DATE,
        B.SELLER_TAX_NUMBER AS SELLER_TAX_NUMBER,
        B.INVOICE_CODE AS INVOICE_CODE,
        B.INVOICE_NUMBER AS INVOICE_NUMBER,
        B.AMOUNT AS AMOUNT,
        B.INVOICE_TYPE AS INVOICE_TYPE,
        A.TAX_AMOUNT AS TAX_AMOUNT
        FROM
        INPUT_INVOICE_DETAIL A
        JOIN
        INPUT_INVOICE B
        ON
        A.FPID = B.ID
        WHERE
        A.ID = #{invoiceItemId,jdbcType=VARCHAR}
    </select>

</mapper>