insert into error_open_account
( id,branchName,branchCode,orgName,orgId,clientId,clientName,account,accountName,openDate,checkDate,closeDate,expireDate,moneyType,subjectId,businessCode,exchangeMark,accountState,accountProperty,safeAccountNature,addTime,folderTime)
values
(
#{item.id},
#{item.branchName},
#{item.branchCode},
#{item.orgName},
#{item.orgId},
#{item.clientId},
#{item.clientName},
#{item.account},
#{item.accountName},
#{item.openDate},
#{item.checkDate},
#{item.closeDate},
#{item.expireDate},
#{item.moneyType},
#{item.subjectId},
#{item.businessCode},
#{item.exchangeMark},
#{item.accountState},
#{item.accountProperty},
#{item.safeAccountNature},
#{item.addTime},
#{item.folderTime}
)
package mapper;
import java.util.List;
public interface ErrorAccountMapper {
int InsertList (List list);
}
List reList = new ArrayList<>();
ErrorAccount errorAccount=new ErrorAccount();
DataFormatter formatter=new DataFormatter();
errorAccount.setBranchName(formatter.formatCellValue(row.getCell(0)));
errorAccount.setBranchCode(formatter.formatCellValue(row.getCell(1)));
errorAccount.setOrgName(formatter.formatCellValue(row.getCell(2)));
errorAccount.setOrgId(formatter.formatCellValue(row.getCell(3)));
errorAccount.setClientId(formatter.formatCellValue(row.getCell(4)));
errorAccount.setClientName(formatter.formatCellValue(row.getCell(5)));
errorAccount.setAccount(formatter.formatCellValue(row.getCell(6)));
errorAccount.setAccountName(formatter.formatCellValue(row.getCell(7)));
errorAccount.setOpenDate(formatter.formatCellValue(row.getCell(8)));
errorAccount.setCheckDate(formatter.formatCellValue(row.getCell(9)));
errorAccount.setCloseDate(formatter.formatCellValue(row.getCell(10)));
errorAccount.setExpireDate(formatter.formatCellValue(row.getCell(11)));
errorAccount.setMoneyType(formatter.formatCellValue(row.getCell(12)));
errorAccount.setSubjectId(formatter.formatCellValue(row.getCell(13)));
errorAccount.setBusinessCode(formatter.formatCellValue(row.getCell(14)));
errorAccount.setExchangeMark(formatter.formatCellValue(row.getCell(15)));
errorAccount.setAccountState(formatter.formatCellValue(row.getCell(16)));
errorAccount.setAccountProperty(formatter.formatCellValue(row.getCell(17)));
errorAccount.setSafeAccountNature(formatter.formatCellValue(row.getCell(18)));
reList.add(errorAccount);
使用注解动态传入表名,实际上也可以封装成map的形式实现。
insert into ${tableName}
( id,orgName,orgId,accountName,account,accountProperty,openDate,closeDate,firstPaymentDate,remark,addTime,folderTime)
values
(
#{item.id},
#{item.orgName},
#{item.orgId},
#{item.accountName},
#{item.account},
#{item.accountProperty},
#{item.openDate},
#{item.closeDate},
#{item.firstPaymentDate},
#{item.remark},
#{item.addTime},
#{item.folderTime}
)
package mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface AllAccountMapper {
int InsertList (@Param("tableName") String tableName, @Param("list") List list);
}
程序完美运行哈哈哈~
日志打印采用了log4j。