senline

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

在一个项目的工程里看到如下的一个java文件。不懂mybatis,貌似是实现从一个表中复制数据到另外一个表。由于不懂mybatis ,看到的代码就是一坨。

mybatis 实现了一堆复杂的代码来替代原本并不复杂的代码,这种用法,简直是把ibatis用到沟里去了。

每一个技术都有他的使用范围,生搬硬套,会弄巧成拙。

 

package com.pansoft.wd.spring.dao.mappers;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface IMBSMeesageMapper {

    @Select("SELECT * FROM V_MBS_MSG_PUB")//视图
    Map getMBSMessagePub();

    @Select("SELECT * FROM V_MBS_BANKSTATEMENT_MSG_HEAD")//视图
    Map getMBSBankStatementMessageHead();

    @Select("SELECT * FROM V_MBS_BANKBALANCE_MSG_HEAD")//视图
    Map getMBSBankBalanceMessageHead();

    @Insert("<script>MERGE INTO WC_MBS_RESULT A USING(<foreach collection='list' item='record' separator=' UNION ALL '> SELECT SYS_GUID() AS F_PKEY,#{record.urid,jdbcType=VARCHAR} AS URID,#{record.orgcode,jdbcType=VARCHAR} AS ORGCODE,#{record.ourbankaccountnumber,jdbcType=VARCHAR} AS OURBANKACCOUNTNUMBER,#{record.ourbankaccountname,jdbcType=VARCHAR} AS OURBANKACCOUNTNAME,#{record.tradedate,jdbcType=VARCHAR} AS TRADEDATE," +
            "#{record.tradedatetime,jdbcType=VARCHAR} AS TRADEDATETIME,#{record.valuedate,jdbcType=VARCHAR} AS VALUEDATE,#{record.moneyway,jdbcType=VARCHAR} AS MONEYWAY,#{record.amount,jdbcType=VARCHAR} AS AMOUNT,#{record.currentbalance,jdbcType=VARCHAR} AS CURRENTBALANCE,#{record.isreconciliation,jdbcType=VARCHAR} AS ISRECONCILIATION,#{record.reconciliationno,jdbcType=VARCHAR} AS RECONCILIATIONNO,#{record.checkcode,jdbcType=VARCHAR} AS CHECKCODE," +
            "#{record.purpose,jdbcType=VARCHAR} AS PURPOSE,#{record.comments,jdbcType=VARCHAR} AS COMMENTS,#{record.oppositeaccountnumber,jdbcType=VARCHAR} AS OPPOSITEACCOUNTNUMBER,#{record.oppositeaccountname,jdbcType=VARCHAR} AS OPPOSITEACCOUNTNAME,#{record.oppositebank,jdbcType=VARCHAR} AS OPPOSITEBANK,#{record.billcode,jdbcType=VARCHAR} AS BILLCODE,#{record.billtype,jdbcType=VARCHAR} AS BILLTYPE,#{record.bankserialnumber,jdbcType=VARCHAR} AS BANKSERIALNUMBER, " +
            "#{record.bustype,jdbcType=VARCHAR} AS BUSTYPE,#{record.curcode,jdbcType=VARCHAR} AS CURCODE,#{record.mactibkn,jdbcType=VARCHAR} AS MACTIBKN,#{record.mactacn,jdbcType=VARCHAR} AS MACTACN,#{record.mactname,jdbcType=VARCHAR} AS MACTNAME,#{record.mactbank,jdbcType=VARCHAR} AS MACTBANK "+
            "FROM DUAL </foreach>) B ON (A.URID = B.URID) WHEN MATCHED THEN UPDATE SET A.ORGCODE = B.ORGCODE,A.OURBANKACCOUNTNUMBER= B.OURBANKACCOUNTNUMBER,A.OURBANKACCOUNTNAME = B.OURBANKACCOUNTNAME,A.TRADEDATE = B.TRADEDATE,A.TRADEDATETIME = B.TRADEDATETIME,A.VALUEDATE = B.VALUEDATE,A.MONEYWAY = B.MONEYWAY,A.AMOUNT = B.AMOUNT,A.CURRENTBALANCE = B.CURRENTBALANCE,A.ISRECONCILIATION = B.ISRECONCILIATION,A.RECONCILIATIONNO = B.RECONCILIATIONNO,A.CHECKCODE = B.CHECKCODE,"+
            "A.PURPOSE = B.PURPOSE,A.COMMENTS = B.COMMENTS,A.OPPOSITEACCOUNTNUMBER = B.OPPOSITEACCOUNTNUMBER,A.OPPOSITEACCOUNTNAME = B.OPPOSITEACCOUNTNAME,A.OPPOSITEBANK = B.OPPOSITEBANK,A.BILLCODE = B.BILLCODE,A.BILLTYPE = B.BILLTYPE,A.BANKSERIALNUMBER = B.BANKSERIALNUMBER,A.UPDATETIME=TO_CHAR(SYSDATE,'yyyyMMddhh24miss'), "+
            "A.BUSTYPE=B.BUSTYPE,A.CURCODE=B.CURCODE,A.MACTIBKN=B.MACTIBKN,A.MACTACN=B.MACTACN,A.MACTNAME=B.MACTNAME,A.MACTBANK=B.MACTBANK "+
            "WHEN NOT MATCHED THEN INSERT"+
            "(A.F_PKEY,A.URID,A.ORGCODE,A.OURBANKACCOUNTNUMBER,A.OURBANKACCOUNTNAME,A.TRADEDATE,"+
            "A.TRADEDATETIME,A.VALUEDATE,A.MONEYWAY,A.AMOUNT,A.CURRENTBALANCE,A.ISRECONCILIATION,A.RECONCILIATIONNO,A.CHECKCODE,"+
            "A.PURPOSE,A.COMMENTS,A.OPPOSITEACCOUNTNUMBER,A.OPPOSITEACCOUNTNAME,A.OPPOSITEBANK,A.BILLCODE,A.BILLTYPE,A.BANKSERIALNUMBER,A.UPDATETIME,"+
            "A.BUSTYPE,A.CURCODE,A.MACTIBKN,A.MACTACN,A.MACTNAME,A.MACTBANK)"+
            "VALUES(B.F_PKEY,B.URID,B.ORGCODE,B.OURBANKACCOUNTNUMBER,B.OURBANKACCOUNTNAME,B.TRADEDATE," +
            "B.TRADEDATETIME,B.VALUEDATE,B.MONEYWAY,B.AMOUNT,B.CURRENTBALANCE,B.ISRECONCILIATION,B.RECONCILIATIONNO,B.CHECKCODE," +
            "B.PURPOSE,B.COMMENTS,B.OPPOSITEACCOUNTNUMBER,B.OPPOSITEACCOUNTNAME,B.OPPOSITEBANK,B.BILLCODE,B.BILLTYPE,B.BANKSERIALNUMBER,TO_CHAR(SYSDATE,'yyyyMMddhh24miss'),"+
            "B.BUSTYPE,B.CURCODE,B.MACTIBKN,B.MACTACN,B.MACTNAME,B.MACTBANK)"+
            "</script>")
    int insertWcBmsResult(@Param("list") List<Map> list);

    @Insert("<script>"+
            "INSERT ALL <foreach collection='list' item='record' separator=' '> "+
            "INTO WC_MBS_BANKBALANCE(PKEY,BANKACCOUNTNUMBER,CURRENTBALANCE,ENTERPRISEBALANCE,BALANCEDATE,QUERYTIME)"+
            "VALUES(SYS_GUID(),#{record.bankaccountnumber,jdbcType=VARCHAR},#{record.currentbalance,jdbcType=NUMERIC},"+
            "#{record.enterprisebalance,jdbcType=NUMERIC},#{record.balancedate,jdbcType=VARCHAR},"+
            "TO_CHAR(SYSDATE,'yyyyMMddhh24miss'))"+
            "</foreach> SELECT * FROM DUAL"+
            "</script>")
    int insertWcBmsBankBalance(@Param("list") List<Map> list);

    @Insert("<script>MERGE INTO WC_YHYEB A USING(" +
            "<foreach collection='list' item='record' separator=' UNION ALL '> " +
            "SELECT SYS_GUID() AS F_PKEY,#{record.bankaccountnumber,jdbcType=VARCHAR} AS BANKACCOUNTNUMBER," +
            "#{record.currentbalance,jdbcType=NUMERIC} AS CURRENTBALANCE,#{record.enterprisebalance,jdbcType=NUMERIC} AS ENTERPRISEBALANCE," +
            "#{record.balancedate,jdbcType=VARCHAR} AS BALANCEDATE,TO_CHAR(SYSDATE,'yyyyMMdd') AS CURRENTDATE FROM DUAL " +
            "</foreach>) B " +
            "ON (A.F_YHZH = B.BANKACCOUNTNUMBER AND A.F_JZRQ = B.CURRENTDATE) " +
            "WHEN MATCHED THEN UPDATE SET A.F_ZHYE = B.ENTERPRISEBALANCE,A.F_KYYE = B.CURRENTBALANCE,A.F_ZJJYRQ = B.BALANCEDATE,A.F_YEGXSJ = TO_CHAR(SYSDATE,'yyyyMMddhh24miss') " +
            "WHEN NOT MATCHED THEN INSERT(A.F_PKEY,A.F_YHZH,A.F_JZRQ,A.F_ZHYE,A.F_KYYE,A.F_ZJJYRQ,A.F_YEGXSJ) " +
            "VALUES(SYS_GUID(),B.BANKACCOUNTNUMBER,B.CURRENTDATE,B.ENTERPRISEBALANCE,B.CURRENTBALANCE,B.BALANCEDATE,TO_CHAR(SYSDATE,'yyyyMMddhh24miss'))</script>")
    int insertWcYhYebTable(@Param("list") List<Map> list);
}

 

posted on 2022-03-25 21:53  森蓝2010  阅读(37)  评论(0编辑  收藏  举报