Execl导入功能(两种方式)
来源:互联网 发布:mac 邮件 qq企业邮箱 编辑:程序博客网 时间:2024/06/03 20:24
- (1)系统默认一种:配置数据源:oracle 物理表:**主键字段:UUID(API)
- (2)ImportExcelAction
- excelModelId 配个id
- startRow 1
- 建一个Excel导入处理类(InsureRiskPRExeclProcess)每次导入表都会在表里插入数据,每次都需要先清空再插入
- 添加excel展示类(列名)
InsureRiskPRExeclProcess类代码:
/**
*
*/
package com.hyf.marketRisk.provider;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import com.bstek.bdf2.core.orm.jdbc.JdbcDao;
import com.bstek.bdf2.importexcel.model.CellWrapper;
import com.bstek.bdf2.importexcel.model.ExcelDataWrapper;
import com.bstek.bdf2.importexcel.model.RowWrapper;
import com.bstek.bdf2.importexcel.processor.IExcelProcessor;
import com.hyf.utils.CommUtils;
/**
* @param 保费和风险数据导入
* @author chenbin
* @date 2016-12-9上午11:49:57
*/
@Controller
public class InsureRiskPRExeclProcess extends JdbcDao implements
IExcelProcessor {
/* (non-Javadoc)
* @see com.bstek.bdf2.importexcel.processor.IExcelProcessor#execute(com.bstek.bdf2.importexcel.model.ExcelDataWrapper)
*/
@Override
@Transactional
public int execute(ExcelDataWrapper arg0) throws Exception {
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
List<RowWrapper> listRow = (List<RowWrapper>) arg0.rowWrappers;
for(int i=0;i<listRow.size();i++){
RowWrapper row = listRow.get(i);
List<CellWrapper> listCell = (List<CellWrapper>) row.getCellWrappers();
if(i==0){
}else if(i>=0){
Map<String,Object> map = new HashMap<String,Object>();
for(CellWrapper cell : listCell){
Object value = cell.getValue();
if(cell.getName().equals("类型")){
map.put("type", CommUtils.getStr(value));
}else if(cell.getName().equals("过去12个月非比例分保分出保费")){
map.put("chubaofei", CommUtils.getStr(value));
}else if(cell.getName().equals("过去12个月非比例分保分入保费")){
map.put("rubaofei", value==null ? null : CommUtils.getDouble(value));
}else if(cell.getName().equals("过去12个月非比例分保净分出保费")){
map.put("baojingfen", value==null ? null : CommUtils.getDouble(value));
}else if(cell.getName().equals("过去12个月自留保费")){
map.put("ziliubaofei", value==null ? null : CommUtils.getDouble(value));
}else if(cell.getName().equals("再保后未决赔款准备金")){
map.put("peikuanjin", value==null ? null : CommUtils.getDouble(value));
}else if(cell.getName().equals("综合成本率")){
map.put("chengbenlv", value==null ? null : CommUtils.getDouble(value));
}else if(cell.getName().equals("综合成本率变动")){
map.put("change", value==null ? null : CommUtils.getDouble(value));
}else if(cell.getName().equals("未决赔款准备金回溯偏差率的算术平均数")){
map.put("average", value==null ? null : CommUtils.getDouble(value));
}else if(cell.getName().equals("备注")){
map.put("remark", value==null ? null : CommUtils.getDouble(value));
}
}
list.add(map);
}
}
//删除已经存在的数据
String sql = "delete from SC_UNLISTINSURANCE_CLR_DATA where 1=1";
this.getJdbcTemplate().execute(sql);
for(Map<String,Object> map : list){
//类型
String type = CommUtils.getStr(map.get("type"));
//过去12个月非比例分保分出保费
Double chubaofei = CommUtils.getDouble(map.get("chubaofei"));
//过去12个月非比例分保分入保费
Double rubaofei = CommUtils.getDouble(map.get("rubaofei"));
//过去12个月非比例分保净分出保费
Double baojingfen = CommUtils.getDouble(map.get("baojingfen"));
//过去12个月自留保费
Double ziliubaofei = CommUtils.getDouble(map.get("ziliubaofei"));
//再保后未决赔款准备金
Double peikuanjin = CommUtils.getDouble(map.get("peikuanjin"));
//综合成本率
Double chengbenlv = CommUtils.getDouble(map.get("chengbenlv"));
//综合成本率变动
Double change = CommUtils.getDouble(map.get("change"));
//未决赔款准备金回溯偏差率的算术平均数
Double average = CommUtils.getDouble(map.get("average"));
//备注
String remark = CommUtils.getStr(map.get("remark"));
if(!remark.equals("")){
sql = "insert into SC_UNLISTINSURANCE_CLR_DATA (ID_,type,chubaofei,rubaofei,baojingfen,ziliubaofei,peikuanjin,chengbenlv,change,average,remark) " +
"values('"+CommUtils.getUUID()+"','"+type+"',"+chubaofei+",'"+rubaofei+"','"+baojingfen+"',"+ziliubaofei+","+peikuanjin+","+chengbenlv+","+change+","+average+","+remark+") ";
this.getJdbcTemplate().execute(sql);
}else{
sql = "insert into SC_UNLISTINSURANCE_CLR_DATA (ID_,type,chubaofei,rubaofei,baojingfen,ziliubaofei,peikuanjin,chengbenlv,change,average,remark) " +
"values('"+CommUtils.getUUID()+"','"+type+"',"+chubaofei+",'"+rubaofei+"','"+baojingfen+"',"+ziliubaofei+","+peikuanjin+","+chengbenlv+","+change+","+average+",null) ";
this.getJdbcTemplate().execute(sql);
}
}
return list.size();
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
}
0 0
- Execl导入功能(两种方式)
- asp.net中把有图片的execl导入到数据库(以二进制流的方式存放图片)中的两种方法
- flex3导入php编辑功能的两种方式
- Execl (转)导入导出execl 全
- 将ASP.net中的Table中的数据导入到Execl的两种方法
- C# 导入Excel数据的方式(两种)
- C#导入Excel数据的方式(两种)
- 导入Ext的两种方式
- DLL 导入的两种方式
- DLL 导入的两种方式
- JSP的两种导入方式
- JSP的两种导入方式
- Mysql 导入导出文件两种方式
- Spring 导入配置文件的两种方式
- Eclipse导入git工程(HTTP与SSH两种导入方式)
- Eclipse导入git工程(HTTP与SSH两种导入方式)
- jQuery扩展功能的两种方式
- 两种方式实现checkBox readonly功能
- Codeforces748D-Santa Claus and a Palindrome(贪心,构造)
- 【BZOJ3529】数表,莫比乌斯反演+BIT
- File类工具
- MVC封装(十)medoo数据类
- 我的框架--QiCai(加载控制器)
- Execl导入功能(两种方式)
- Oracle 快速卸载数据到文本文件
- LinPhone 导入 Android Studio 实现二次开发
- map erase 内存释放问题
- Servlet高级编程
- 可信执行环境(TEE)介绍 与应用
- C/C++函数参数传递机制
- xcode8回车缩进问题
- AndroidStudio常用设置,适合新手使用