作者 钟来

修改bug

  1 +package com.ruoyi.common.annotation;
  2 +
  3 +import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
  4 +
  5 +import java.lang.annotation.ElementType;
  6 +import java.lang.annotation.Retention;
  7 +import java.lang.annotation.RetentionPolicy;
  8 +import java.lang.annotation.Target;
  9 +import java.math.BigDecimal;
  10 +
  11 +/**
  12 + * 自定义导出Excel数据注解
  13 + *
  14 + * @author ruoyi
  15 + */
  16 +@Retention(RetentionPolicy.RUNTIME)
  17 +@Target(ElementType.FIELD)
  18 +public @interface Excel
  19 +{
  20 + /**
  21 + * 导出时在excel中排序
  22 + */
  23 + public int sort() default Integer.MAX_VALUE;
  24 +
  25 + /**
  26 + * 导出到Excel中的名字.
  27 + */
  28 + public String name() default "";
  29 +
  30 + /**
  31 + * 日期格式, 如: yyyy-MM-dd
  32 + */
  33 + public String dateFormat() default "";
  34 +
  35 + /**
  36 + * 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
  37 + */
  38 + public String dictType() default "";
  39 +
  40 + /**
  41 + * 读取内容转表达式 (如: 0=男,1=女,2=未知)
  42 + */
  43 + public String readConverterExp() default "";
  44 +
  45 + /**
  46 + * 分隔符,读取字符串组内容
  47 + */
  48 + public String separator() default ",";
  49 +
  50 + /**
  51 + * BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
  52 + */
  53 + public int scale() default -1;
  54 +
  55 + /**
  56 + * BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
  57 + */
  58 + public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
  59 +
  60 + /**
  61 + * 导出类型(0数字 1字符串)
  62 + */
  63 + public ColumnType cellType() default ColumnType.STRING;
  64 +
  65 + /**
  66 + * 导出时在excel中每个列的高度 单位为字符
  67 + */
  68 + public double height() default 14;
  69 +
  70 + /**
  71 + * 导出时在excel中每个列的宽 单位为字符
  72 + */
  73 + public double width() default 16;
  74 +
  75 + /**
  76 + * 文字后缀,如% 90 变成90%
  77 + */
  78 + public String suffix() default "";
  79 +
  80 + /**
  81 + * 当值为空时,字段的默认值
  82 + */
  83 + public String defaultValue() default "";
  84 +
  85 + /**
  86 + * 提示信息
  87 + */
  88 + public String prompt() default "";
  89 +
  90 + /**
  91 + * 设置只能选择不能输入的列内容.
  92 + */
  93 + public String[] combo() default {};
  94 +
  95 + /**
  96 + * 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
  97 + */
  98 + public boolean isExport() default true;
  99 +
  100 + /**
  101 + * 另一个类中的属性名称,支持多级获取,以小数点隔开
  102 + */
  103 + public String targetAttr() default "";
  104 +
  105 + /**
  106 + * 是否自动统计数据,在最后追加一行统计数据总和
  107 + */
  108 + public boolean isStatistics() default false;
  109 +
  110 + /**
  111 + * 导出字段对齐方式(0:默认;1:靠左;2:居中;3:靠右)
  112 + */
  113 + public Align align() default Align.AUTO;
  114 +
  115 + /**
  116 + * 自定义数据处理器
  117 + */
  118 + public Class<?> handler() default ExcelHandlerAdapter.class;
  119 +
  120 + /**
  121 + * 自定义数据处理器参数
  122 + */
  123 + public String[] args() default {};
  124 +
  125 + public enum Align
  126 + {
  127 + AUTO(0), LEFT(1), CENTER(2), RIGHT(3);
  128 + private final int value;
  129 +
  130 + Align(int value)
  131 + {
  132 + this.value = value;
  133 + }
  134 +
  135 + public int value()
  136 + {
  137 + return this.value;
  138 + }
  139 + }
  140 +
  141 + /**
  142 + * 字段类型(0:导出导入;1:仅导出;2:仅导入)
  143 + */
  144 + Type type() default Type.ALL;
  145 +
  146 + public enum Type
  147 + {
  148 + ALL(0), EXPORT(1), IMPORT(2);
  149 + private final int value;
  150 +
  151 + Type(int value)
  152 + {
  153 + this.value = value;
  154 + }
  155 +
  156 + public int value()
  157 + {
  158 + return this.value;
  159 + }
  160 + }
  161 +
  162 + public enum ColumnType
  163 + {
  164 + NUMERIC(0), STRING(1), IMAGE(2);
  165 + private final int value;
  166 +
  167 + ColumnType(int value)
  168 + {
  169 + this.value = value;
  170 + }
  171 +
  172 + public int value()
  173 + {
  174 + return this.value;
  175 + }
  176 + }
  177 +}
  1 +package com.ruoyi.common.annotation;
  2 +
  3 +import java.lang.annotation.ElementType;
  4 +import java.lang.annotation.Retention;
  5 +import java.lang.annotation.RetentionPolicy;
  6 +import java.lang.annotation.Target;
  7 +
  8 +/**
  9 + * Excel注解集
  10 + *
  11 + * @author ruoyi
  12 + */
  13 +@Target(ElementType.FIELD)
  14 +@Retention(RetentionPolicy.RUNTIME)
  15 +public @interface Excels
  16 +{
  17 + public Excel[] value();
  18 +}
@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject; @@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
5 import okhttp3.*; 5 import okhttp3.*;
6 6
7 import java.io.IOException; 7 import java.io.IOException;
  8 +import java.net.InetSocketAddress;
  9 +import java.net.Proxy;
8 import java.util.concurrent.TimeUnit; 10 import java.util.concurrent.TimeUnit;
9 11
10 public class HttpUtils { 12 public class HttpUtils {
@@ -30,9 +32,9 @@ public class HttpUtils { @@ -30,9 +32,9 @@ public class HttpUtils {
30 } 32 }
31 33
32 private static OkHttpClient okHttpClient = new OkHttpClient.Builder() 34 private static OkHttpClient okHttpClient = new OkHttpClient.Builder()
33 - .connectTimeout(10, TimeUnit.SECONDS)  
34 - .readTimeout(10, TimeUnit.SECONDS)  
35 - .writeTimeout(20, TimeUnit.SECONDS) 35 + .connectTimeout(600, TimeUnit.SECONDS)
  36 + .readTimeout(30, TimeUnit.SECONDS)
  37 + .writeTimeout(30, TimeUnit.SECONDS)
36 .build(); 38 .build();
37 39
38 public static String getResponseString(Response response) 40 public static String getResponseString(Response response)
  1 +package com.ruoyi.common.utils.poi;
  2 +
  3 +/**
  4 + * Excel数据格式处理适配器
  5 + *
  6 + * @author ruoyi
  7 + */
  8 +public interface ExcelHandlerAdapter
  9 +{
  10 + /**
  11 + * 格式化
  12 + *
  13 + * @param value 单元格数据值
  14 + * @param args excel注解args参数组
  15 + *
  16 + * @return 处理后的值
  17 + */
  18 + Object format(Object value, String[] args);
  19 +}