diff --git a/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index d168e9f7..a5e49599 100644 --- a/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -2,6 +2,7 @@ package com.ruoyi.common.utils.poi; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Field; @@ -53,22 +54,46 @@ public class ExcelUtil this.clazz = clazz; } + /** + * 对excel表单默认第一个索引名转换成list + * + * @param input 输入流 + * @return 转换后集合 + */ + public List importExcel(InputStream input) throws Exception + { + return importExcel(StringUtils.EMPTY, input); + } + + /** + * 对excel表单指定表格索引名转换成list + * + * @param sheetName 表格索引名 + * @param input 输入流 + * @return 转换后集合 + */ public List importExcel(String sheetName, InputStream input) throws Exception { List list = new ArrayList(); Workbook workbook = WorkbookFactory.create(input); - Sheet sheet = workbook.getSheet(sheetName); + Sheet sheet = null; if (StringUtils.isNotEmpty(sheetName)) { // 如果指定sheet名,则取指定sheet中的内容. sheet = workbook.getSheet(sheetName); } - if (sheet == null) + else { // 如果传入的sheet名不存在则默认指向第1个sheet. sheet = workbook.getSheetAt(0); } + + if (sheet == null) + { + throw new IOException("文件sheet不存在"); + } + int rows = sheet.getPhysicalNumberOfRows(); if (rows > 0) @@ -117,7 +142,7 @@ public class ExcelUtil // 如果不存在实例则新建. entity = (entity == null ? clazz.newInstance() : entity); // 从map中得到对应列的field. - Field field = fieldsMap.get(j); + Field field = fieldsMap.get(j + 1); // 取得类型,并根据对象类型设置值. Class fieldType = field.getType(); if (String.class == fieldType) diff --git a/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java b/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java index 8d507c45..8bac132f 100644 --- a/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java +++ b/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java @@ -92,14 +92,15 @@ public class AsyncFactory public static TimerTask recordLogininfor(final String username, final String status, final String message, final Object... args) { final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); + final String ip = ShiroUtils.getIp(); return new TimerTask() { @Override public void run() { StringBuilder s = new StringBuilder(); - s.append(LogUtils.getBlock(ShiroUtils.getIp())); - s.append(AddressUtils.getRealAddressByIP(ShiroUtils.getIp())); + s.append(LogUtils.getBlock(ip)); + s.append(AddressUtils.getRealAddressByIP(ip)); s.append(LogUtils.getBlock(username)); s.append(LogUtils.getBlock(status)); s.append(LogUtils.getBlock(message)); @@ -112,8 +113,8 @@ public class AsyncFactory // 封装对象 Logininfor logininfor = new Logininfor(); logininfor.setLoginName(username); - logininfor.setIpaddr(ShiroUtils.getIp()); - logininfor.setLoginLocation(AddressUtils.getRealAddressByIP(ShiroUtils.getIp())); + logininfor.setIpaddr(ip); + logininfor.setLoginLocation(AddressUtils.getRealAddressByIP(ip)); logininfor.setBrowser(browser); logininfor.setOs(os); logininfor.setMsg(message); diff --git a/src/main/java/com/ruoyi/project/system/config/domain/Config.java b/src/main/java/com/ruoyi/project/system/config/domain/Config.java index bc7f806e..219b3c79 100644 --- a/src/main/java/com/ruoyi/project/system/config/domain/Config.java +++ b/src/main/java/com/ruoyi/project/system/config/domain/Config.java @@ -82,4 +82,10 @@ public class Config extends BaseEntity this.configType = configType; } + public String toString() + { + return "Config [configId=" + configId + ", configName=" + configName + ", configKey=" + configKey + + ", configValue=" + configValue + ", configType=" + configType + "]"; + } + } diff --git a/src/main/resources/mybatis/monitor/JobLogMapper.xml b/src/main/resources/mybatis/monitor/JobLogMapper.xml index 64710cca..11b64f6c 100644 --- a/src/main/resources/mybatis/monitor/JobLogMapper.xml +++ b/src/main/resources/mybatis/monitor/JobLogMapper.xml @@ -32,10 +32,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND method_name like concat('%', #{methodName}, '%') - + and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - + and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') diff --git a/src/main/resources/mybatis/monitor/LogininforMapper.xml b/src/main/resources/mybatis/monitor/LogininforMapper.xml index 4ccf013f..c45fcca4 100644 --- a/src/main/resources/mybatis/monitor/LogininforMapper.xml +++ b/src/main/resources/mybatis/monitor/LogininforMapper.xml @@ -33,10 +33,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND login_name like concat('%', #{loginName}, '%') - + and date_format(login_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - + and date_format(login_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') diff --git a/src/main/resources/mybatis/monitor/OperLogMapper.xml b/src/main/resources/mybatis/monitor/OperLogMapper.xml index 16970e3f..4033bd86 100644 --- a/src/main/resources/mybatis/monitor/OperLogMapper.xml +++ b/src/main/resources/mybatis/monitor/OperLogMapper.xml @@ -45,10 +45,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND oper_name like concat('%', #{operName}, '%') - + and date_format(oper_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - + and date_format(oper_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') diff --git a/src/main/resources/mybatis/system/ConfigMapper.xml b/src/main/resources/mybatis/system/ConfigMapper.xml index e042f8df..32fdb6f4 100644 --- a/src/main/resources/mybatis/system/ConfigMapper.xml +++ b/src/main/resources/mybatis/system/ConfigMapper.xml @@ -49,10 +49,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND config_key like concat('%', #{configKey}, '%') - + and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - + and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') diff --git a/src/main/resources/mybatis/system/DictTypeMapper.xml b/src/main/resources/mybatis/system/DictTypeMapper.xml index 15862135..60f4cab5 100644 --- a/src/main/resources/mybatis/system/DictTypeMapper.xml +++ b/src/main/resources/mybatis/system/DictTypeMapper.xml @@ -31,10 +31,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND dict_type like concat('%', #{dictType}, '%') - + and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - + and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') diff --git a/src/main/resources/mybatis/system/RoleMapper.xml b/src/main/resources/mybatis/system/RoleMapper.xml index 3733bd9e..e4c98bbd 100644 --- a/src/main/resources/mybatis/system/RoleMapper.xml +++ b/src/main/resources/mybatis/system/RoleMapper.xml @@ -33,10 +33,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND role_key like concat('%', #{roleKey}, '%') - + and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - + and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') diff --git a/src/main/resources/mybatis/system/UserMapper.xml b/src/main/resources/mybatis/system/UserMapper.xml index 9825b5cc..29e33550 100644 --- a/src/main/resources/mybatis/system/UserMapper.xml +++ b/src/main/resources/mybatis/system/UserMapper.xml @@ -56,10 +56,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND u.phonenumber like concat('%', #{phonenumber}, '%') - + AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - + AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') diff --git a/src/main/resources/mybatis/tool/GenMapper.xml b/src/main/resources/mybatis/tool/GenMapper.xml index 5a60835a..bed2e418 100644 --- a/src/main/resources/mybatis/tool/GenMapper.xml +++ b/src/main/resources/mybatis/tool/GenMapper.xml @@ -30,10 +30,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND table_comment like concat('%', #{tableComment}, '%') - + and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') - + and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')