master
gcii 7 years ago
parent c86d0bebae
commit dc1f7e24e5

@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=RuoYi3.4-SqlServer
url: jdbc:sqlserver://sql.guochao.vip:1433;SelectMethod=cursor;DatabaseName=RuoYi3.4-SqlServer
username: sa
password: 123456
password: Aa13386446138
# 从库数据源
slave:
# 从数据源开关/默认关闭

@ -170,7 +170,7 @@
}
.skin-blue .content-tabs {
border-bottom: solid 2px #e7eaec;
border-bottom: 1px solid #e5e5e5;
}
.skin-blue.layout-top-nav>.logo {
@ -189,7 +189,7 @@
}
.skin-green .content-tabs {
border-bottom: solid 2px #e7eaec;
border-bottom: 1px solid #e5e5e5;
}
.skin-green .navbar .nav>li>a {
@ -436,7 +436,7 @@
}
.skin-red .content-tabs {
border-bottom: solid 2px #e7eaec;
border-bottom: 1px solid #e5e5e5;
}
.skin-red .nav>li>.treeview-menu {
@ -595,8 +595,7 @@
}
.skin-yellow .content-tabs {
border-bottom: solid 2px #e7eaec;
border-bottom: 1px solid #e5e5e5;
}
.skin-yellow .nav>li>.treeview-menu {
@ -755,8 +754,7 @@
}
.skin-purple .content-tabs {
border-bottom: solid 2px #e7eaec;
border-bottom: 1px solid #e5e5e5;
}
.skin-purple .nav>li>.treeview-menu {

@ -3247,15 +3247,15 @@ body.body-small .footer.fixed {
/*CONTENTTABS*/
.content-tabs {
position: relative;
height: 42px;
height: 39px;
background: #fafafa;
line-height: 40px;
line-height: 38px;
}
.content-tabs .roll-nav, .page-tabs-list {
position: absolute;
width: 40px;
height: 40px;
width: 30px;
height: 38px;
text-align: center;
color: #999;
z-index: 2;
@ -3285,9 +3285,9 @@ body.body-small .footer.fixed {
}
nav.page-tabs {
margin-left: 40px;
margin-left: 30px;
width: 100000px;
height: 40px;
height: 38px;
overflow: hidden;
}
@ -3328,7 +3328,7 @@ nav.page-tabs .page-tabs-content {
.roll-right.tabReload {
background: #fff;
height: 40px;
height: 38px;
width: 60px;
outline: none;
}

@ -146,6 +146,11 @@
margin-right: 5px
}
.nav-tabs-custom>.nav-tabs>li.header {
padding-left: 5px;
font-size: 16px;
line-height: 30px;
}
.nav-tabs-custom>.nav-tabs>li.disabled>a {
color: #777
}

@ -216,6 +216,8 @@ $(function() {
dataIndex = $(this).data('index'),
menuName = $.trim($(this).text()),
flag = true;
$(".nav ul li").removeClass("active");
$(this).parent("li").addClass("active");
if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
// 选项卡菜单已存在

@ -271,8 +271,7 @@
},
// 导入数据
importExcel: function(formId) {
var currentId = $.common.isEmpty(formId) ? 'importForm' : formId;
$.form.reset(currentId);
var currentId = $.common.isEmpty(formId) ? 'importTpl' : formId;
layer.open({
type: 1,
area: ['400px', '230px'],
@ -281,7 +280,7 @@
maxmin: true,
shade: 0.3,
title: '导入' + $.table._option.modalName + '数据',
content: $('#' + currentId),
content: $('#' + currentId).html(),
btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
// 弹层外区域关闭
shadeClose: true,

@ -108,7 +108,8 @@
</script>
</body>
<!-- 导入区域 -->
<form id="importForm" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
<script id="importTpl" type="text/template">
<form enctype="multipart/form-data" class="mt20 mb10">
<div class="col-xs-offset-1">
<input type="file" id="file" name="file"/>
<div class="mt10 pt5">
@ -120,4 +121,5 @@
</font>
</div>
</form>
</script>
</html>

@ -243,7 +243,9 @@
}
</script>
</body>
<form id="importForm" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
<form enctype="multipart/form-data" class="mt20 mb10">
<div class="col-xs-offset-1">
<input type="file" id="file" name="file"/>
<div class="mt10 pt5">
@ -255,4 +257,5 @@
</font>
</div>
</form>
</script>
</html>

@ -17,7 +17,7 @@ public @interface Excel
/**
* Excel.
*/
public String name();
public String name() default "";
/**
* , : yyyy-MM-dd

@ -1,6 +1,7 @@
package com.ruoyi.common.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
*
@ -90,7 +91,7 @@ public class Arith
{
return BigDecimal.ZERO.doubleValue();
}
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
}
/**
@ -108,6 +109,6 @@ public class Arith
}
BigDecimal b = new BigDecimal(Double.toString(v));
BigDecimal one = new BigDecimal("1");
return b.divide(one, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
}
}

@ -1,7 +1,47 @@
package com.ruoyi.common.utils.poi;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint;
import org.apache.poi.ss.usermodel.DataValidationHelper;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.annotation.Excels;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.text.Convert;
@ -9,21 +49,6 @@ import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.reflect.ReflectUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
/**
* Excel
@ -153,7 +178,6 @@ public class ExcelUtil<T>
cellMap.put(null, i);
}
}
// 有数据时才处理 得到类的所有field.
Field[] allFields = clazz.getDeclaredFields();
// 定义一个map用于存放列的序号和field.
@ -289,65 +313,31 @@ public class ExcelUtil<T>
for (int index = 0; index <= sheetNo; index++)
{
createSheet(sheetNo, index);
Cell cell = null; // 产生单元格
// 产生一行
Row row = sheet.createRow(0);
int excelsNo = 0;
// 写入各个字段的列头名称
for (int i = 0; i < fields.size(); i++)
for (int column = 0; column < fields.size(); column++)
{
Field field = fields.get(i);
Excel attr = field.getAnnotation(Excel.class);
// 创建列
cell = row.createCell(i);
// 设置列中写入内容为String类型
cell.setCellType(CellType.STRING);
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
if (attr.name().indexOf("注:") >= 0)
Field field = fields.get(column);
if (field.isAnnotationPresent(Excel.class))
{
Font font = wb.createFont();
font.setColor(HSSFFont.COLOR_RED);
cellStyle.setFont(font);
cellStyle.setFillForegroundColor(HSSFColorPredefined.YELLOW.getIndex());
sheet.setColumnWidth(i, 6000);
Excel excel = field.getAnnotation(Excel.class);
createCell(excel, row, column);
}
else
if (field.isAnnotationPresent(Excels.class))
{
Font font = wb.createFont();
// 粗体显示
font.setBold(true);
// 选择需要用到的字体格式
cellStyle.setFont(font);
cellStyle.setFillForegroundColor(HSSFColorPredefined.LIGHT_YELLOW.getIndex());
// 设置列宽
sheet.setColumnWidth(i, (int) ((attr.width() + 0.72) * 256));
row.setHeight((short) (attr.height() * 20));
}
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setWrapText(true);
cell.setCellStyle(cellStyle);
Excels attrs = field.getAnnotation(Excels.class);
Excel[] excels = attrs.value();
// 写入列名
cell.setCellValue(attr.name());
// 如果设置了提示信息则鼠标放上去提示.
if (StringUtils.isNotEmpty(attr.prompt()))
{
// 这里默认设了2-101列提示.
setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, i, i);
}
// 如果设置了combo属性则本列只能选择不能输入
if (attr.combo().length > 0)
{
// 这里默认设了2-101列只能选择不能输入.
setXSSFValidation(sheet, attr.combo(), 1, 100, i, i);
Excel excel = excels[excelsNo++];
createCell(excel, row, column);
}
}
if (Type.EXPORT.equals(type))
{
fillExcelData(index, row, cell);
fillExcelData(index, row);
}
}
String filename = encodingFilename(sheetName);
@ -394,7 +384,7 @@ public class ExcelUtil<T>
* @param row
* @param cell
*/
public void fillExcelData(int index, Row row, Cell cell)
public void fillExcelData(int index, Row row)
{
int startNo = index * sheetSize;
int endNo = Math.min(startNo + sheetSize, list.size());
@ -407,13 +397,95 @@ public class ExcelUtil<T>
row = sheet.createRow(i + 1 - startNo);
// 得到导出对象.
T vo = (T) list.get(i);
for (int j = 0; j < fields.size(); j++)
int excelsNo = 0;
for (int column = 0; column < fields.size(); column++)
{
// 获得field.
Field field = fields.get(j);
Field field = fields.get(column);
// 设置实体类私有属性可访问
field.setAccessible(true);
Excel attr = field.getAnnotation(Excel.class);
if (field.isAnnotationPresent(Excel.class))
{
addCell(field.getAnnotation(Excel.class), row, vo, field, column, cs);
}
if (field.isAnnotationPresent(Excels.class))
{
Excels attrs = field.getAnnotation(Excels.class);
Excel[] excels = attrs.value();
Excel excel = excels[excelsNo++];
addCell(excel, row, vo, field, column, cs);
}
}
}
}
/**
*
*/
public Cell createCell(Excel attr, Row row, int column)
{
// 创建列
Cell cell = row.createCell(column);
// 设置列中写入内容为String类型
cell.setCellType(CellType.STRING);
// 写入列名
cell.setCellValue(attr.name());
CellStyle cellStyle = createStyle(attr, row, column);
cell.setCellStyle(cellStyle);
return cell;
}
/**
*
*/
public CellStyle createStyle(Excel attr, Row row, int column)
{
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
if (attr.name().indexOf("注:") >= 0)
{
Font font = wb.createFont();
font.setColor(HSSFFont.COLOR_RED);
cellStyle.setFont(font);
cellStyle.setFillForegroundColor(HSSFColorPredefined.YELLOW.getIndex());
sheet.setColumnWidth(column, 6000);
}
else
{
Font font = wb.createFont();
// 粗体显示
font.setBold(true);
// 选择需要用到的字体格式
cellStyle.setFont(font);
cellStyle.setFillForegroundColor(HSSFColorPredefined.LIGHT_YELLOW.getIndex());
// 设置列宽
sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
row.setHeight((short) (attr.height() * 20));
}
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setWrapText(true);
// 如果设置了提示信息则鼠标放上去提示.
if (StringUtils.isNotEmpty(attr.prompt()))
{
// 这里默认设了2-101列提示.
setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
}
// 如果设置了combo属性则本列只能选择不能输入
if (attr.combo().length > 0)
{
// 这里默认设了2-101列只能选择不能输入.
setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
}
return cellStyle;
}
/**
*
*/
public Cell addCell(Excel attr, Row row, T vo, Field field, int column, CellStyle cs)
{
Cell cell = null;
try
{
// 设置行高
@ -422,14 +494,8 @@ public class ExcelUtil<T>
if (attr.isExport())
{
// 创建cell
cell = row.createCell(j);
cell = row.createCell(column);
cell.setCellStyle(cs);
if (vo == null)
{
// 如果数据存在就填入,不存在填入空格.
cell.setCellValue("");
continue;
}
// 用于读取对象中的属性
Object value = getTargetValue(vo, field, attr);
@ -455,8 +521,7 @@ public class ExcelUtil<T>
{
log.error("导出Excel失败{}", e);
}
}
}
return cell;
}
/**
@ -657,33 +722,39 @@ public class ExcelUtil<T>
{
this.fields = new ArrayList<Field>();
List<Field> tempFields = new ArrayList<>();
Class<?> tempClass = clazz;
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
while (tempClass != null)
for (Field field : tempFields)
{
tempClass = tempClass.getSuperclass();
if (tempClass != null)
// 单注解
if (field.isAnnotationPresent(Excel.class))
{
tempFields.addAll(Arrays.asList(tempClass.getDeclaredFields()));
putToField(field, field.getAnnotation(Excel.class));
}
// 多注解
if (field.isAnnotationPresent(Excels.class))
{
Excels attrs = field.getAnnotation(Excels.class);
Excel[] excels = attrs.value();
for (Excel excel : excels)
{
putToField(field, excel);
}
}
}
putToFields(tempFields);
}
/**
*
*/
private void putToFields(List<Field> fields)
private void putToField(Field field, Excel attr)
{
for (Field field : fields)
{
Excel attr = field.getAnnotation(Excel.class);
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
{
this.fields.add(field);
}
}
}
/**
* 簿

@ -26,6 +26,8 @@ public class AsyncManager
/**
*
*/
private AsyncManager(){}
private static AsyncManager me = new AsyncManager();
public static AsyncManager me()

@ -237,5 +237,6 @@ public class GenUtils
javaTypeMap.put("date", "Date");
javaTypeMap.put("datetime", "Date");
javaTypeMap.put("timestamp", "Date");
javaTypeMap.put("nvarchar", "String");
}
}

@ -30,8 +30,8 @@ public class SysRole extends BaseEntity
@Excel(name = "角色排序")
private String roleSort;
/** 数据范围1所有数据权限2自定数据权限) */
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限")
/** 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限) */
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
private String dataScope;
/** 角色状态0正常 1停用 */

@ -1,12 +1,14 @@
package com.ruoyi.system.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.annotation.Excels;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* sys_user
@ -76,7 +78,10 @@ public class SysUser extends BaseEntity
private Date loginDate;
/** 部门对象 */
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT)
@Excels({
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
})
private SysDept dept;
private List<SysRole> roles;

@ -33,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="parentId" column="parent_id" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="status" column="dept_status" />
</resultMap>
@ -175,8 +176,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
<if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
update_time = GETDATE()
<if test="remark != null">remark = #{remark},</if>
update_time = sysdate()
</set>
where user_id = #{userId}
</update>

@ -16,17 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="startTimestamp" column="start_timestamp" />
<result property="lastAccessTime" column="last_access_time" />
<result property="expireTime" column="expire_time" />
<!--<association property="session" javaType="OnlineSession" resultMap="OnlineSessionResult" />-->
</resultMap>
<!--<resultMap type="OnlineSession" id="OnlineSessionResult">-->
<!--<result property="host" column="ipaddr" />-->
<!--<result property="browser" column="browser" />-->
<!--<result property="os" column="os" />-->
<!--<result property="status" column="status" />-->
<!--</resultMap>-->
<sql id="selectOnlineVo">
select sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time
from sys_user_online

Loading…
Cancel
Save