作者 雷海东

工资信息导入bug

package org.jeecg.common.system.base.controller;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
@Configuration
@EnableTransactionManagement
public class AppConfig {
@Bean
public DataSource dataSource() {
// 配置数据源
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://rm-2zeiuncjm75qti641ho.mysql.rds.aliyuncs.com:3306/jeecg-boot");
dataSource.setUsername("ntsd_root");
dataSource.setPassword("L3bHRJwg6lJ2SC4WFfGA");
return dataSource;
}
@Bean
public PlatformTransactionManager transactionManager(DataSource dataSource) {
// 配置事务管理器
return new DataSourceTransactionManager(dataSource);
}
}
... ...
... ... @@ -313,7 +313,9 @@ public class JeecgController<T, S extends IService<T>> {
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
//update-end-author:taoyan date:20190528 for:批量插入数据
return Result.ok("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
}catch (ExcelImportException e) {
return Result.error("文件导入失败,导入数据格式错误");
}catch (Exception e) {
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
String msg = e.getMessage();
log.error(msg, e);
... ... @@ -378,7 +380,9 @@ public class JeecgController<T, S extends IService<T>> {
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
//update-end-author:taoyan date:20190528 for:批量插入数据
return Result.ok("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
}catch (ExcelImportException e) {
return Result.error("文件导入失败,导入数据格式错误");
}catch (Exception e) {
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
String msg = e.getMessage();
log.error(msg, e);
... ...
... ... @@ -302,7 +302,8 @@ public class JeecgController2<T, t, b, V extends IService<t>, S extends IService
//工资导入
protected Result<?> importExcelgz(HttpServletRequest request, HttpServletResponse response, Class<T> clazz, Class<b> base) {
@Transactional
public Result<?> importExcelgz(HttpServletRequest request, HttpServletResponse response, Class<T> clazz, Class<b> base) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
... ... @@ -314,6 +315,7 @@ public class JeecgController2<T, t, b, V extends IService<t>, S extends IService
// params.setKeyIndex(1);
params.setNeedSave(true);
try {
List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
... ... @@ -384,6 +386,8 @@ public class JeecgController2<T, t, b, V extends IService<t>, S extends IService
return Result.error("文件数据为空");
}
System.out.println("导入的数据:"+shuju);
System.out.println("数据库数据:"+service.list());
service.saveBatch(shuju);
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
//update-end-author:taoyan date:20190528 for:批量插入数据
... ...
... ... @@ -247,7 +247,7 @@ public class TblSalaryCalculationController extends JeecgController2<TblSalaryCa
return Result.OK("成功!");
}
// tblSalaryCalculationService.qi();
return Result.OK("计算失败,没有该月数据!");
return Result.error("计算失败,没有该月数据!");
}
... ...