上传excel,比对后批量修改(临时表)
大概思路
- 读取excel信息
- 将该数据保存在临时表中
- 比对临时表与客户表的数据,得出结果
- 根据比对结果批量修改客户表数据
- 将比对不成功的结果导出
- 删除临时表
具体思路
- 获取excel信息 List<List< Object>> listob = UploadExcelUtil.ExcelOfUpload(request, response);
- 将listob 对象转换为List< TemporaryClient> listofTemporaryClient_1 对象
- 批量导入listofTemporaryClient_1 数据进临时表temporary_client
- 将临时表(temporary_client)中的客户姓名,手机号与客户表(client)中的客户姓名,手机号相匹配,再加上客户表中的created_time小于等于临时表中的check_time。将比对后的结果查询出来为listofTemporaryClient
- 根据上面比对的结果listofTemporaryClient,根据c_id批量修改数据库里的checkTime,state=1
- 查询出在临时表中比对不成功的数据listofTemporaryClient_2
- 删除临时表里的数据
- 导出listofTemporaryClient_2的数据,方便管理查询
控制层 SpringMVC
@RequestMapping(value = "BankDataUpload.do", produces = "application/text; charset=utf-8")
public void BankDataUpload(HttpServletRequest request, HttpServletResponse response){
List<TemporaryClient> list=new ArrayList<TemporaryClient>();
try {
list = sysUploadServiceimpl.BankDataUpload(request, response);
} catch (Exception e) {
e.printStackTrace();
}
try {
ExportExcel<TemporaryClient> ee = new ExportExcel<TemporaryClient>();
String[] headers = { "申请日期", "核准日期", "客户称谓", "手机号码"};
String fileName = "比对失败的表格";
ee.exportExcel(headers, list, fileName, response);
} catch (Exception e) {
System.out.println("导出excel表异常");
}
}
mapper层(Dao层)
与数据库操作有关,插入临时表,比对数据,批量修改客户表,找出比对不成功的数据,删除临时表
//将数据批量插入临时表TemporaryClient
int insertListofTemporaryClient(List<TemporaryClient> listofTemporaryClient_1);
//找出临时表与client表中关联的数据,即成功的数