CitJournalAdjustExtendsMapper.xml 23.9 KB
Newer Older
1 2 3 4
<?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.dao.CitJournalEntryAdjustMapper">

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
    <insert id="insertBatch" parameterType="java.util.List">
        insert into cit_journal_entry_adjust
        (<include refid="Base_Column_List"/>)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <choose>
                    <when test="item.id != null">#{item.id,jdbcType=BIGINT},</when>
                    <otherwise>0,</otherwise>
                </choose>
                <choose>
                    <when test="item.organizationId != null">#{item.organizationId,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.projectId != null">#{item.projectId,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.period != null">#{item.period,jdbcType=INTEGER},</when>
                    <otherwise>0,</otherwise>
                </choose>
                <choose>
                    <when test="item.date != null">#{item.date,jdbcType=TIMESTAMP},</when>
                    <otherwise>CURRENT_TIMESTAMP,</otherwise>
                </choose>
                <choose>
                    <when test="item.source != null">#{item.source,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.ledgerId != null">#{item.ledgerId,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.ledgerName != null">#{item.ledgerName,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.currencyCode != null">#{item.currencyCode,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.status != null">#{item.status,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.headerId != null">#{item.headerId,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.lineNum != null">#{item.lineNum,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.approvalStatus != null">#{item.approvalStatus,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.postedStatus != null">#{item.postedStatus,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.accountPeriod != null">#{item.accountPeriod,jdbcType=INTEGER},</when>
                    <otherwise>0,</otherwise>
                </choose>
                <choose>
                    <when test="item.accountingDate != null">#{item.accountingDate,jdbcType=TIMESTAMP},</when>
                    <otherwise>CURRENT_TIMESTAMP,</otherwise>
                </choose>
                <choose>
                    <when test="item.journalSource != null">#{item.journalSource,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.category != null">#{item.category,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.name != null">#{item.name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.voucherNum != null">#{item.voucherNum,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.description != null">#{item.description,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.orgCode != null">#{item.orgCode,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
99 100 101 102
                <choose>
                    <when test="item.segment2 != null">#{item.segment2,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
103 104 105 106
                <choose>
                    <when test="item.subjectCode != null">#{item.subjectCode,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
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
                <choose>
                    <when test="item.segment4 != null">#{item.segment4,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment5 != null">#{item.segment5,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment6 != null">#{item.segment6,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment7 != null">#{item.segment7,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment8 != null">#{item.segment8,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment9 != null">#{item.segment9,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment10 != null">#{item.segment10,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
135 136 137 138
                <choose>
                    <when test="item.orgName != null">#{item.orgName,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
139 140 141 142
                <choose>
                    <when test="item.segment2Name != null">#{item.segment2Name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
143 144 145 146
                <choose>
                    <when test="item.subjectName != null">#{item.subjectName,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
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
                <choose>
                    <when test="item.segment4Name != null">#{item.segment4Name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment5Name != null">#{item.segment5Name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment6Name != null">#{item.segment6Name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment7Name != null">#{item.segment7Name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment8Name != null">#{item.segment8Name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment9Name != null">#{item.segment9Name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.segment10Name != null">#{item.segment10Name,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.journalCurrencyCode != null">#{item.journalCurrencyCode,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.sobCurrencyCode != null">#{item.sobCurrencyCode,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
183 184 185 186 187 188 189 190
                <choose>
                    <when test="item.accountedDr != null">#{item.accountedDr,jdbcType=DECIMAL},</when>
                    <otherwise>0,</otherwise>
                </choose>
                <choose>
                    <when test="item.accountedCr != null">#{item.accountedCr,jdbcType=DECIMAL},</when>
                    <otherwise>0,</otherwise>
                </choose>
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 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
                <choose>
                    <when test="item.enteredDr != null">#{item.enteredDr,jdbcType=DECIMAL},</when>
                    <otherwise>0,</otherwise>
                </choose>
                <choose>
                    <when test="item.enteredCr != null">#{item.enteredCr,jdbcType=DECIMAL},</when>
                    <otherwise>0,</otherwise>
                </choose>
                <choose>
                    <when test="item.cfItem != null">#{item.cfItem,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute1 != null">#{item.attribute1,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute2 != null">#{item.attribute2,jdbcType=TIMESTAMP},</when>
                    <otherwise>CURRENT_TIMESTAMP,</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute3 != null">#{item.attribute3,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute4 != null">#{item.attribute4,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute5 != null">#{item.attribute5,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute6 != null">#{item.attribute6,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute7 != null">#{item.attribute7,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute8 != null">#{item.attribute8,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute9 != null">#{item.attribute9,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute10 != null">#{item.attribute10,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute11 != null">#{item.attribute11,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute12 != null">#{item.attribute12,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute13 != null">#{item.attribute13,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute14 != null">#{item.attribute14,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute15 != null">#{item.attribute15,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.attribute16 != null">#{item.attribute16,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
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
                <choose>
                    <when test="item.createdBy != null">#{item.createdBy,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.createdDate != null">#{item.createdDate,jdbcType=TIMESTAMP},</when>
                    <otherwise>CURRENT_TIMESTAMP,</otherwise>
                </choose>
                <choose>
                    <when test="item.lateUpdatedBy != null">#{item.lateUpdatedBy,jdbcType=VARCHAR},</when>
                    <otherwise>'',</otherwise>
                </choose>
                <choose>
                    <when test="item.lateUpdatedDate != null">#{item.lateUpdatedDate,jdbcType=TIMESTAMP},</when>
                    <otherwise>CURRENT_TIMESTAMP,</otherwise>
                </choose>
                <choose>
                    <when test="item.createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</when>
                    <otherwise>CURRENT_TIMESTAMP,</otherwise>
                </choose>
                <choose>
                    <when test="item.updateTime != null">#{item.updateTime,jdbcType=TIMESTAMP},</when>
                    <otherwise>CURRENT_TIMESTAMP,</otherwise>
                </choose>
            </trim>
        </foreach>
        ;
        SELECT 1 FROM DUAL;
    </insert>
296

297 298 299
    <select id="sumAmountByCondition" parameterType="map" resultMap="BaseResultMap">
        SELECT
        subject_code as subject_code,
300
        max(jfinal.subject_name) as subject_name,
301 302 303 304 305 306 307
        sum(jfinal.accounted_dr) as accounted_dr,
        sum(jfinal.accounted_cr) as accounted_cr
        from
        (
        select
        cj.accounted_dr as accounted_dr,
        cj.accounted_cr as accounted_cr ,
308 309
        cj.subject_code as subject_code,
        cj.subject_name as subject_name
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
        from
        cit_journal_entry_adjust cj
        where
        cj.period like #{period}
        <if test="orgList != null and orgList.size > 0">
            AND organization_id in
            <foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        UNION ALL

        select
        j.accounted_dr as accounted_dr,
        j.accounted_cr as accounted_cr,
325 326
        j.segment3 as subject_code,
        j.segment3_name as subject_name
327 328 329 330 331 332 333 334 335 336 337 338 339
        from
        journal_entry j
        where
        j.period like #{period}
        <if test="orgList != null and orgList.size > 0">
            AND organization_id in
            <foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        ) as jfinal
        group by jfinal.subject_code
    </select>
340 341 342 343 344 345

    <select id="getJournalMerge" parameterType="map" resultMap="BaseResultMap">
        select
        id, organization_id, project_id, period, date, source, ledger_id, ledger_name, currency_code,
        status, header_id, line_num, approval_status, posted_status, account_period, accounting_date,
        journal_source, category, name, voucher_num, description, org_code, subject_code,
zhkwei's avatar
zhkwei committed
346 347 348 349 350
        org_name, segment2_name, subject_name, segment4_name, segment5_name, segment6_name, segment7_name, segment8_name,
        segment9_name, segment10_name, journal_currency_code, sob_currency_code, accounted_dr, accounted_cr,
        entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5,
        attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15,
        attribute16,
351
        created_by, created_date, late_updated_by,
kevin's avatar
kevin committed
352 353
        late_updated_date, create_time, update_time,is_select
        from cit_journal_entry_adjust where project_id = #{projectId,jdbcType=VARCHAR}
354
        <if test="orgCode != null and orgCode != ''">
355 356
            and org_code = #{orgCode,jdbcType=VARCHAR}
        </if>
357
        <if test="subjectCode != null and subjectCode != ''">
358
            and subject_code  LIKE CONCAT('%' ,#{subjectCode},'%')
359
        </if>
360
        <if test="orgName != null and orgName != ''">
361 362
            and org_name = #{orgName,jdbcType=VARCHAR}
        </if>
363
        <if test="subjectName != null and subjectName != ''">
364
            and subject_name LIKE CONCAT('%' ,#{subjectName},'%')
365
        </if>
366 367 368
        <if test="description != null and description != ''">
            and description LIKE CONCAT('%' ,#{description},'%')
        </if>
zhkwei's avatar
zhkwei committed
369 370 371 372
        <if test="periodStart!=null">
            AND account_period >= #{periodStart,jdbcType=INTEGER}
        </if>
        <if test="periodEnd!=null">
zhkwei's avatar
zhkwei committed
373
            AND account_period &lt;= #{periodEnd,jdbcType=INTEGER}
zhkwei's avatar
zhkwei committed
374
        </if>
375 376 377
        UNION ALL
        select
        id, organization_id, project_id, tms_period as period ,date,source, ledger_id, ledger_name, currency_code,
kevin's avatar
kevin committed
378 379
        status, header_id, line_num, approval_status, posted_status, period as account_period, accounting_date,
        journal_source, category, name, voucher_num, description, segment1 as org_code, segment3 as subject_code,
zhkwei's avatar
zhkwei committed
380 381 382 383 384
        segment1_name as org_name, segment2_name, segment3_name as subject_name,  segment4_name, segment5_name, segment6_name,
        segment7_name, segment8_name, segment9_name, segment10_name, journal_currency_code, sob_currency_code,
        accounted_dr, accounted_cr, entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5,
        attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15,
        attribute16, created_by, created_date, late_updated_by, late_updated_date, create_time, update_time, is_select
kevin's avatar
kevin committed
385
        from journal_entry where project_id = #{projectId,jdbcType=VARCHAR}
386
        <if test="orgCode != null and orgCode != ''">
387 388
            and segment1 = #{orgCode,jdbcType=VARCHAR}
        </if>
389
        <if test="subjectCode != null and subjectCode != ''">
390
            and segment3 LIKE CONCAT('%' ,#{subjectCode},'%')
391
        </if>
392
        <if test="orgName != null and orgName != ''">
393 394
            and segment1_name = #{orgName,jdbcType=VARCHAR}
        </if>
395
        <if test="subjectName != null and subjectName != ''">
396
            and segment3_name LIKE CONCAT('%' ,#{subjectName},'%')
397
        </if>
398 399 400
        <if test="description != null and description != ''">
            and description LIKE CONCAT('%' ,#{description},'%')
        </if>
zhkwei's avatar
zhkwei committed
401 402 403 404 405 406
        <if test="periodStart!=null">
            AND period &gt;= #{periodStart,jdbcType=INTEGER}
        </if>
        <if test="periodEnd!=null">
            AND period &lt;= #{periodEnd,jdbcType=INTEGER}
        </if>
407 408
    </select>

409 410 411 412 413 414 415 416 417 418 419 420
    <select id="getJournalMergeByOrgList" parameterType="map" resultMap="BaseResultMap">
        select
        id, organization_id, project_id, period, date, source, ledger_id, ledger_name, currency_code,
        status, header_id, line_num, approval_status, posted_status, account_period, accounting_date,
        journal_source, category, name, voucher_num, description, org_code, subject_code,
        org_name, segment2_name, subject_name, segment4_name, segment5_name, segment6_name, segment7_name, segment8_name,
        segment9_name, segment10_name, journal_currency_code, sob_currency_code, accounted_dr, accounted_cr,
        entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5,
        attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15,
        attribute16,
        created_by, created_date, late_updated_by,
        late_updated_date, create_time, update_time,is_select
421
        from cit_journal_entry_adjust where period = #{record.period}
422 423 424 425 426 427 428 429 430 431 432 433 434
        <if test="orgList != null and orgList.size > 0">
            AND organization_id in
            <foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="record.subjectCode != null and record.subjectCode != ''">
            and subject_code  LIKE CONCAT('%' ,#{record.subjectCode},'%')
        </if>
        <if test="record.subjectName != null and record.subjectName != ''">
            and subject_name LIKE CONCAT('%' ,#{record.subjectName},'%')
        </if>
        <if test="record.description != null and record.description != ''">
435
            and description LIKE CONCAT('%' ,#{record.description},'%')
436
        </if>
437 438 439
        <if test="record.source != null and record.source != ''">
            and source LIKE CONCAT('%' ,#{record.source},'%')
        </if>
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
        <if test="record.periodStart!=null">
            AND account_period >= #{record.periodStart,jdbcType=INTEGER}
        </if>
        <if test="record.periodEnd!=null">
            AND account_period &lt;= #{record.periodEnd,jdbcType=INTEGER}
        </if>
        UNION ALL
        select
        id, organization_id, project_id, tms_period as period ,date,source, ledger_id, ledger_name, currency_code,
        status, header_id, line_num, approval_status, posted_status, period as account_period, accounting_date,
        journal_source, category, name, voucher_num, description, segment1 as org_code, segment3 as subject_code,
        segment1_name as org_name, segment2_name, segment3_name as subject_name,  segment4_name, segment5_name, segment6_name,
        segment7_name, segment8_name, segment9_name, segment10_name, journal_currency_code, sob_currency_code,
        accounted_dr, accounted_cr, entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5,
        attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15,
        attribute16, created_by, created_date, late_updated_by, late_updated_date, create_time, update_time, is_select
456
        from journal_entry where tms_period like CONCAT(#{record.period},'%')
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
        <if test="orgList != null and orgList.size > 0">
            AND organization_id in
            <foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="record.subjectCode != null and record.subjectCode != ''">
            and segment3 LIKE CONCAT('%' ,#{record.subjectCode},'%')
        </if>
        <if test="record.subjectName != null and record.subjectName != ''">
            and segment3_name LIKE CONCAT('%' ,#{record.subjectName},'%')
        </if>
        <if test="record.description != null and record.description != ''">
            and description LIKE CONCAT('%' ,#{record.description},'%')
        </if>
472 473 474 475

        <if test="record.source != null and record.source != ''">
            and source LIKE CONCAT('%' ,#{record.source},'%')
        </if>
476 477 478 479 480 481 482 483
        <if test="record.periodStart!=null">
            AND period &gt;= #{record.periodStart,jdbcType=INTEGER}
        </if>
        <if test="record.periodEnd!=null">
            AND period &lt;= #{record.periodEnd,jdbcType=INTEGER}
        </if>
    </select>

484
</mapper>