Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

tjf 3 lat temu
rodzic
commit
55967c8cb6

+ 185 - 127
boman-api/boman-domain/src/main/java/com.boman.domain/SysUser.java

@@ -5,6 +5,7 @@ import java.util.List;
 import javax.validation.constraints.Email;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.Size;
+
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -16,89 +17,186 @@ import com.boman.domain.BaseEntity;
 
 /**
  * 用户对象 sys_user
- * 
+ *
  * @author ruoyi
  */
-public class SysUser extends BaseEntity
-{
+public class SysUser/* extends BaseEntity*/ {
     private static final long serialVersionUID = 1L;
 
-    /** 用户ID */
+    /**
+     * 用户ID
+     */
     @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
     private Long id;
 
-    /** 部门ID */
+    /**
+     * 部门ID
+     */
     @Excel(name = "部门编号", type = Type.IMPORT)
     private Long deptId;
 
-    /** 用户账号 */
+    /**
+     * 用户账号
+     */
     @Excel(name = "登录名称")
     private String userName;
 
-    /** 用户昵称 */
+    /**
+     * 用户昵称
+     */
     @Excel(name = "用户名称")
     private String nickName;
 
-    /** 用户邮箱 */
+    /**
+     * 用户邮箱
+     */
     @Excel(name = "用户邮箱")
     private String email;
 
-    /** 手机号码 */
+    /**
+     * 手机号码
+     */
     @Excel(name = "手机号码")
     private String phonenumber;
 
-    /** 用户性别 */
+    /**
+     * 用户性别
+     */
     @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
     private String sex;
 
-    /** 用户头像 */
+    /**
+     * 用户头像
+     */
     private String avatar;
 
-    /** 密码 */
+    /**
+     * 密码
+     */
     private String password;
 
-    /** 盐加密 */
+    /**
+     * 盐加密
+     */
     private String salt;
 
-    /** 帐号状态(0正常 1停用) */
+    /**
+     * 帐号状态(0正常 1停用)
+     */
     @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
     private String status;
 
-    /** 删除标志(0代表存在 2代表删除) */
+    /**
+     * 删除标志(0代表存在 2代表删除)
+     */
     private String delFlag;
 
-    /** 最后登录IP */
+    /**
+     * 最后登录IP
+     */
     @Excel(name = "最后登录IP", type = Type.EXPORT)
     private String loginIp;
 
-    /** 最后登录时间 */
+    /**
+     * 最后登录时间
+     */
     @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
     private Date loginDate;
 
-    /** 部门对象 */
+    /**
+     * 部门对象
+     */
     @Excels({
-        @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
-        @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
+            @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
+            @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
     })
     private SysDept dept;
 
-    /** 角色对象 */
+    /**
+     * 角色对象
+     */
     private List<SysRole> roles;
 
-    /** 角色组 */
+    /**
+     * 角色组
+     */
     private Long[] roleIds;
 
-    /** 岗位组 */
+    /**
+     * 岗位组
+     */
     private Long[] postIds;
     /**
      * 小程序唯一标识
      */
     private String unionId;
     /**
-     *登陆后的唯一标识
+     * 登陆后的唯一标识
      */
     private String openId;
 
+    private String remark;
+
+    /**
+     * 创建者
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 更新者
+     */
+    private String updateBy;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getCreateBy() {
+        return createBy;
+    }
+
+    public void setCreateBy(String createBy) {
+        this.createBy = createBy;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateBy() {
+        return updateBy;
+    }
+
+    public void setUpdateBy(String updateBy) {
+        this.updateBy = updateBy;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
     public String getUnionId() {
         return unionId;
     }
@@ -115,236 +213,196 @@ public class SysUser extends BaseEntity
         this.openId = openId;
     }
 
-    public SysUser()
-    {
+    public SysUser() {
 
     }
 
-    public SysUser(Long id)
-    {
+    public SysUser(Long id) {
         this.id = id;
     }
 
-    public Long getId()
-    {
+    public Long getId() {
         return id;
     }
 
-    public void setId(Long id)
-    {
+    public void setId(Long id) {
         this.id = id;
     }
 
-    public boolean isAdmin()
-    {
+    public boolean isAdmin() {
         return isAdmin(this.id);
     }
 
-    public static boolean isAdmin(Long id)
-    {
+    public static boolean isAdmin(Long id) {
         return id != null && 1L == id;
     }
 
-    public Long getDeptId()
-    {
+    public Long getDeptId() {
         return deptId;
     }
 
-    public void setDeptId(Long deptId)
-    {
+    public void setDeptId(Long deptId) {
         this.deptId = deptId;
     }
 
     @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
-    public String getNickName()
-    {
+    public String getNickName() {
         return nickName;
     }
 
-    public void setNickName(String nickName)
-    {
+    public void setNickName(String nickName) {
         this.nickName = nickName;
     }
 
     @NotBlank(message = "用户账号不能为空")
     @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
-    public String getUserName()
-    {
+    public String getUserName() {
         return userName;
     }
 
-    public void setUserName(String userName)
-    {
+    public void setUserName(String userName) {
         this.userName = userName;
     }
 
     @Email(message = "邮箱格式不正确")
     @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
-    public String getEmail()
-    {
+    public String getEmail() {
         return email;
     }
 
-    public void setEmail(String email)
-    {
+    public void setEmail(String email) {
         this.email = email;
     }
 
     @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
-    public String getPhonenumber()
-    {
+    public String getPhonenumber() {
         return phonenumber;
     }
 
-    public void setPhonenumber(String phonenumber)
-    {
+    public void setPhonenumber(String phonenumber) {
         this.phonenumber = phonenumber;
     }
 
-    public String getSex()
-    {
+    public String getSex() {
         return sex;
     }
 
-    public void setSex(String sex)
-    {
+    public void setSex(String sex) {
         this.sex = sex;
     }
 
-    public String getAvatar()
-    {
+    public String getAvatar() {
         return avatar;
     }
 
-    public void setAvatar(String avatar)
-    {
+    public void setAvatar(String avatar) {
         this.avatar = avatar;
     }
 
     @JsonProperty
-    public String getPassword()
-    {
+    public String getPassword() {
         return password;
     }
 
-    public void setPassword(String password)
-    {
+    public void setPassword(String password) {
         this.password = password;
     }
 
-    public String getSalt()
-    {
+    public String getSalt() {
         return salt;
     }
 
-    public void setSalt(String salt)
-    {
+    public void setSalt(String salt) {
         this.salt = salt;
     }
 
-    public String getStatus()
-    {
+    public String getStatus() {
         return status;
     }
 
-    public void setStatus(String status)
-    {
+    public void setStatus(String status) {
         this.status = status;
     }
 
-    public String getDelFlag()
-    {
+    public String getDelFlag() {
         return delFlag;
     }
 
-    public void setDelFlag(String delFlag)
-    {
+    public void setDelFlag(String delFlag) {
         this.delFlag = delFlag;
     }
 
-    public String getLoginIp()
-    {
+    public String getLoginIp() {
         return loginIp;
     }
 
-    public void setLoginIp(String loginIp)
-    {
+    public void setLoginIp(String loginIp) {
         this.loginIp = loginIp;
     }
 
-    public Date getLoginDate()
-    {
+    public Date getLoginDate() {
         return loginDate;
     }
 
-    public void setLoginDate(Date loginDate)
-    {
+    public void setLoginDate(Date loginDate) {
         this.loginDate = loginDate;
     }
 
-    public SysDept getDept()
-    {
+    public SysDept getDept() {
         return dept;
     }
 
-    public void setDept(SysDept dept)
-    {
+    public void setDept(SysDept dept) {
         this.dept = dept;
     }
 
-    public List<SysRole> getRoles()
-    {
+    public List<SysRole> getRoles() {
         return roles;
     }
 
-    public void setRoles(List<SysRole> roles)
-    {
+    public void setRoles(List<SysRole> roles) {
         this.roles = roles;
     }
 
-    public Long[] getRoleIds()
-    {
+    public Long[] getRoleIds() {
         return roleIds;
     }
 
-    public void setRoleIds(Long[] roleIds)
-    {
+    public void setRoleIds(Long[] roleIds) {
         this.roleIds = roleIds;
     }
 
-    public Long[] getPostIds()
-    {
+    public Long[] getPostIds() {
         return postIds;
     }
 
-    public void setPostIds(Long[] postIds)
-    {
+    public void setPostIds(Long[] postIds) {
         this.postIds = postIds;
     }
-    
+
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("deptId", getDeptId())
-            .append("userName", getUserName())
-            .append("nickName", getNickName())
-            .append("email", getEmail())
-            .append("phonenumber", getPhonenumber())
-            .append("sex", getSex())
-            .append("avatar", getAvatar())
-            .append("password", getPassword())
-            .append("salt", getSalt())
-            .append("status", getStatus())
-            .append("delFlag", getDelFlag())
-            .append("loginIp", getLoginIp())
-            .append("loginDate", getLoginDate())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .append("dept", getDept())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("deptId", getDeptId())
+                .append("userName", getUserName())
+                .append("nickName", getNickName())
+                .append("email", getEmail())
+                .append("phonenumber", getPhonenumber())
+                .append("sex", getSex())
+                .append("avatar", getAvatar())
+                .append("password", getPassword())
+                .append("salt", getSalt())
+                .append("status", getStatus())
+                .append("delFlag", getDelFlag())
+                .append("loginIp", getLoginIp())
+                .append("loginDate", getLoginDate())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .append("dept", getDept())
+                .toString();
     }
 }

+ 158 - 321
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/poi/ExcelUtil.java

@@ -48,8 +48,7 @@ import static com.boman.domain.constant.FormDataConstant.NEED_CONVERT_DATE_LIST;
  *
  * @author ruoyi
  */
-public class ExcelUtil<T>
-{
+public class ExcelUtil<T> {
     private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
 
     /**
@@ -117,15 +116,12 @@ public class ExcelUtil<T>
      */
     public Class<T> clazz;
 
-    public ExcelUtil(Class<T> clazz)
-    {
+    public ExcelUtil(Class<T> clazz) {
         this.clazz = clazz;
     }
 
-    public void init(List<T> list, String sheetName, Type type)
-    {
-        if (list == null)
-        {
+    public void init(List<T> list, String sheetName, Type type) {
+        if (list == null) {
             list = new ArrayList<T>();
         }
         this.list = list;
@@ -135,8 +131,7 @@ public class ExcelUtil<T>
         createWorkbook();
     }
 
-    public void initJSONObject(List<Map<String, Object>> list, String sheetName, Type type)
-    {
+    public void initJSONObject(List<Map<String, Object>> list, String sheetName, Type type) {
         this.jsonObjectList = list;
         this.sheetName = sheetName;
         this.type = type;
@@ -150,8 +145,7 @@ public class ExcelUtil<T>
      * @param is 输入流
      * @return 转换后集合
      */
-    public List<T> importExcel(InputStream is) throws Exception
-    {
+    public List<T> importExcel(InputStream is) throws Exception {
         return importExcel(StringUtils.EMPTY, is);
     }
 
@@ -159,63 +153,52 @@ public class ExcelUtil<T>
      * 对excel表单指定表格索引名转换成list
      *
      * @param sheetName 表格索引名
-     * @param is 输入流
+     * @param is        输入流
      * @return 转换后集合
      */
-    public List<T> importExcel(String sheetName, InputStream is) throws Exception
-    {
+    public List<T> importExcel(String sheetName, InputStream is) throws Exception {
         this.type = Type.IMPORT;
         this.wb = WorkbookFactory.create(is);
         List<T> list = new ArrayList<T>();
         Sheet sheet = null;
-        if (StringUtils.isNotEmpty(sheetName))
-        {
+        if (StringUtils.isNotEmpty(sheetName)) {
             // 如果指定sheet名,则取指定sheet中的内容.
             sheet = wb.getSheet(sheetName);
-        }
-        else
-        {
+        } else {
             // 如果传入的sheet名不存在则默认指向第1个sheet.
             sheet = wb.getSheetAt(0);
         }
 
-        if (sheet == null)
-        {
+        if (sheet == null) {
             throw new IOException("文件sheet不存在");
         }
 
         int rows = sheet.getPhysicalNumberOfRows();
 
-        if (rows > 0)
-        {
+        if (rows > 0) {
             // 定义一个map用于存放excel列的序号和field.
             Map<String, Integer> cellMap = getHead(sheet);
             // 有数据时才处理 得到类的所有field.
             Field[] allFields = clazz.getDeclaredFields();
             // 定义一个map用于存放列的序号和field.
             Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>();
-            for (int col = 0; col < allFields.length; col++)
-            {
+            for (int col = 0; col < allFields.length; col++) {
                 Field field = allFields[col];
                 Excel attr = field.getAnnotation(Excel.class);
-                if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
-                {
+                if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) {
                     // 设置类的私有字段属性可访问.
                     field.setAccessible(true);
                     Integer column = cellMap.get(attr.name());
-                    if (column != null)
-                    {
+                    if (column != null) {
                         fieldsMap.put(column, field);
                     }
                 }
             }
-            for (int i = 1; i < rows; i++)
-            {
+            for (int i = 1; i < rows; i++) {
                 // 从第2行开始取数据,默认第一行是表头.
                 Row row = sheet.getRow(i);
                 T entity = null;
-                for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet())
-                {
+                for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet()) {
                     Object val = this.getCellValue(row, entry.getKey());
 
                     // 如果不存在实例则新建.
@@ -224,71 +207,43 @@ public class ExcelUtil<T>
                     Field field = fieldsMap.get(entry.getKey());
                     // 取得类型,并根据对象类型设置值.
                     Class<?> fieldType = field.getType();
-                    if (String.class == fieldType)
-                    {
+                    if (String.class == fieldType) {
                         String s = Convert.toStr(val);
-                        if (StringUtils.endsWith(s, ".0"))
-                        {
+                        if (StringUtils.endsWith(s, ".0")) {
                             val = StringUtils.substringBefore(s, ".0");
-                        }
-                        else
-                        {
+                        } else {
                             String dateFormat = field.getAnnotation(Excel.class).dateFormat();
-                            if (StringUtils.isNotEmpty(dateFormat))
-                            {
+                            if (StringUtils.isNotEmpty(dateFormat)) {
                                 val = DateUtils.parseDateToStr(dateFormat, (Date) val);
-                            }
-                            else
-                            {
+                            } else {
                                 val = Convert.toStr(val);
                             }
                         }
-                    }
-                    else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val)))
-                    {
+                    } else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val))) {
                         val = Convert.toInt(val);
-                    }
-                    else if (Long.TYPE == fieldType || Long.class == fieldType)
-                    {
+                    } else if (Long.TYPE == fieldType || Long.class == fieldType) {
                         val = Convert.toLong(val);
-                    }
-                    else if (Double.TYPE == fieldType || Double.class == fieldType)
-                    {
+                    } else if (Double.TYPE == fieldType || Double.class == fieldType) {
                         val = Convert.toDouble(val);
-                    }
-                    else if (Float.TYPE == fieldType || Float.class == fieldType)
-                    {
+                    } else if (Float.TYPE == fieldType || Float.class == fieldType) {
                         val = Convert.toFloat(val);
-                    }
-                    else if (BigDecimal.class == fieldType)
-                    {
+                    } else if (BigDecimal.class == fieldType) {
                         val = Convert.toBigDecimal(val);
-                    }
-                    else if (Date.class == fieldType)
-                    {
-                        if (val instanceof String)
-                        {
+                    } else if (Date.class == fieldType) {
+                        if (val instanceof String) {
                             val = DateUtils.parseDate(val);
-                        }
-                        else if (val instanceof Double)
-                        {
+                        } else if (val instanceof Double) {
                             val = DateUtil.getJavaDate((Double) val);
                         }
-                    }
-                    else if (Boolean.TYPE == fieldType || Boolean.class == fieldType)
-                    {
+                    } else if (Boolean.TYPE == fieldType || Boolean.class == fieldType) {
                         val = Convert.toBool(val, false);
                     }
-                    if (StringUtils.isNotNull(fieldType))
-                    {
+                    if (StringUtils.isNotNull(fieldType)) {
                         Excel attr = field.getAnnotation(Excel.class);
                         String propertyName = field.getName();
-                        if (StringUtils.isNotEmpty(attr.targetAttr()))
-                        {
+                        if (StringUtils.isNotEmpty(attr.targetAttr())) {
                             propertyName = field.getName() + "." + attr.targetAttr();
-                        }
-                        else if (StringUtils.isNotEmpty(attr.readConverterExp()))
-                        {
+                        } else if (StringUtils.isNotEmpty(attr.readConverterExp())) {
                             val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
                         }
                         ReflectUtils.invokeSetter(entity, propertyName, val);
@@ -430,14 +385,13 @@ public class ExcelUtil<T>
     /**
      * 对list数据源将其里面的数据导入到excel表单
      *
-     * @param response 返回数据
-     * @param list 导出数据集合
+     * @param response  返回数据
+     * @param list      导出数据集合
      * @param sheetName 工作表的名称
      * @return 结果
      * @throws IOException
      */
-    public void exportExcel(HttpServletResponse response, List<T> list, String sheetName) throws IOException
-    {
+    public void exportExcel(HttpServletResponse response, List<T> list, String sheetName) throws IOException {
         response.setContentType("application/vnd.ms-excel");
         response.setCharacterEncoding("utf-8");
         this.init(list, sheetName, Type.EXPORT);
@@ -564,7 +518,7 @@ public class ExcelUtil<T>
     }
 
     private String covertHead(String columnName) {
-        switch (columnName){
+        switch (columnName) {
             case "userName":
                 return "用户名";
             case "deptName":
@@ -605,8 +559,7 @@ public class ExcelUtil<T>
      * @param sheetName 工作表的名称
      * @return 结果
      */
-    public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException
-    {
+    public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException {
         response.setContentType("application/vnd.ms-excel");
         response.setCharacterEncoding("utf-8");
         this.init(null, sheetName, Type.IMPORT);
@@ -618,39 +571,30 @@ public class ExcelUtil<T>
      *
      * @return 结果
      */
-    public void exportExcel(OutputStream outputStream)
-    {
-        try
-        {
+    public void exportExcel(OutputStream outputStream) {
+        try {
             // 取出一共有多少个sheet.
             double sheetNo = Math.ceil(list.size() / sheetSize);
-            for (int index = 0; index <= sheetNo; index++)
-            {
+            for (int index = 0; index <= sheetNo; index++) {
                 createSheet(sheetNo, index);
 
                 // 产生一行
                 Row row = sheet.createRow(0);
                 int column = 0;
                 // 写入各个字段的列头名称
-                for (Object[] os : fields)
-                {
+                for (Object[] os : fields) {
                     Excel excel = (Excel) os[1];
                     this.createCell(excel, row, column++);
                 }
-                if (Type.EXPORT.equals(type))
-                {
+                if (Type.EXPORT.equals(type)) {
                     fillExcelData(index, row);
                     addStatisticsRow();
                 }
             }
             wb.write(outputStream);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("导出Excel异常{}", e.getMessage());
-        }
-        finally
-        {
+        } finally {
             close(outputStream);
         }
     }
@@ -659,20 +603,17 @@ public class ExcelUtil<T>
      * 填充excel数据
      *
      * @param index 序号
-     * @param row 单元格行
+     * @param row   单元格行
      */
-    public void fillExcelData(int index, Row row)
-    {
+    public void fillExcelData(int index, Row row) {
         int startNo = index * sheetSize;
         int endNo = Math.min(startNo + sheetSize, list.size());
-        for (int i = startNo; i < endNo; i++)
-        {
+        for (int i = startNo; i < endNo; i++) {
             row = sheet.createRow(i + 1 - startNo);
             // 得到导出对象.
             T vo = (T) list.get(i);
             int column = 0;
-            for (Object[] os : fields)
-            {
+            for (Object[] os : fields) {
                 Field field = (Field) os[0];
                 Excel excel = (Excel) os[1];
                 // 设置实体类私有属性可访问
@@ -703,8 +644,8 @@ public class ExcelUtil<T>
 
     /**
      * 填充excel数据
-     *  @param index 序号
      *
+     * @param index 序号
      */
     public void fillDataByListMap(int index) {
         int startNo = index * sheetSize;
@@ -722,8 +663,7 @@ public class ExcelUtil<T>
      * @param wb 工作薄对象
      * @return 样式列表
      */
-    private Map<String, CellStyle> createStyles(Workbook wb)
-    {
+    private Map<String, CellStyle> createStyles(Workbook wb) {
         // 写入各条记录,每条记录对应excel表中的一行
         Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
         CellStyle style = wb.createCellStyle();
@@ -787,8 +727,7 @@ public class ExcelUtil<T>
     /**
      * 创建单元格
      */
-    public Cell createCell(Excel attr, Row row, int column)
-    {
+    public Cell createCell(Excel attr, Row row, int column) {
         // 创建列
         Cell cell = row.createCell(column);
         // 写入列信息
@@ -855,26 +794,19 @@ public class ExcelUtil<T>
      * 设置单元格信息
      *
      * @param value 单元格值
-     * @param attr 注解相关
-     * @param cell 单元格信息
+     * @param attr  注解相关
+     * @param cell  单元格信息
      */
-    public void setCellVo(Object value, Excel attr, Cell cell)
-    {
-        if (ColumnType.STRING == attr.cellType())
-        {
+    public void setCellVo(Object value, Excel attr, Cell cell) {
+        if (ColumnType.STRING == attr.cellType()) {
             cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
-        }
-        else if (ColumnType.NUMERIC == attr.cellType())
-        {
+        } else if (ColumnType.NUMERIC == attr.cellType()) {
             cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
-        }
-        else if (ColumnType.IMAGE == attr.cellType())
-        {
+        } else if (ColumnType.IMAGE == attr.cellType()) {
             ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1),
                     cell.getRow().getRowNum() + 1);
             String imagePath = Convert.toStr(value);
-            if (StringUtils.isNotEmpty(imagePath))
-            {
+            if (StringUtils.isNotEmpty(imagePath)) {
                 byte[] data = ImageUtils.getImage(imagePath);
                 getDrawingPatriarch(cell.getSheet()).createPicture(anchor,
                         cell.getSheet().getWorkbook().addPicture(data, getImageType(data)));
@@ -885,10 +817,8 @@ public class ExcelUtil<T>
     /**
      * 获取画布
      */
-    public static Drawing<?> getDrawingPatriarch(Sheet sheet)
-    {
-        if (sheet.getDrawingPatriarch() == null)
-        {
+    public static Drawing<?> getDrawingPatriarch(Sheet sheet) {
+        if (sheet.getDrawingPatriarch() == null) {
             sheet.createDrawingPatriarch();
         }
         return sheet.getDrawingPatriarch();
@@ -897,15 +827,11 @@ public class ExcelUtil<T>
     /**
      * 获取图片类型,设置图片插入类型
      */
-    public int getImageType(byte[] value)
-    {
+    public int getImageType(byte[] value) {
         String type = FileTypeUtils.getFileExtendName(value);
-        if ("JPG".equalsIgnoreCase(type))
-        {
+        if ("JPG".equalsIgnoreCase(type)) {
             return Workbook.PICTURE_TYPE_JPEG;
-        }
-        else if ("PNG".equalsIgnoreCase(type))
-        {
+        } else if ("PNG".equalsIgnoreCase(type)) {
             return Workbook.PICTURE_TYPE_PNG;
         }
         return Workbook.PICTURE_TYPE_JPEG;
@@ -914,26 +840,20 @@ public class ExcelUtil<T>
     /**
      * 创建表格样式
      */
-    public void setDataValidation(Excel attr, Row row, int column)
-    {
-        if (attr.name().indexOf("注:") >= 0)
-        {
+    public void setDataValidation(Excel attr, Row row, int column) {
+        if (attr.name().indexOf("注:") >= 0) {
             sheet.setColumnWidth(column, 6000);
-        }
-        else
-        {
+        } else {
             // 设置列宽
             sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
         }
         // 如果设置了提示信息则鼠标放上去提示.
-        if (StringUtils.isNotEmpty(attr.prompt()))
-        {
+        if (StringUtils.isNotEmpty(attr.prompt())) {
             // 这里默认设了2-101列提示.
             setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
         }
         // 如果设置了combo属性则本列只能选择不能输入
-        if (attr.combo().length > 0)
-        {
+        if (attr.combo().length > 0) {
             // 这里默认设了2-101列只能选择不能输入.
             setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
         }
@@ -962,17 +882,17 @@ public class ExcelUtil<T>
             sheet.setColumnWidth(columnIndex, (int) ((16 + 0.72) * 256));
         }
     }
-        // 如果设置了提示信息则鼠标放上去提示.
+    // 如果设置了提示信息则鼠标放上去提示.
 //        if (StringUtils.isNotEmpty(attr.prompt())) {
 //            // 这里默认设了2-101列提示.
 //            setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, columnIndex, columnIndex);
 //        }
-        // 如果设置了combo属性则本列只能选择不能输入
+    // 如果设置了combo属性则本列只能选择不能输入
 //        if (attr.combo().length > 0) {
 //            // 这里默认设了2-101列只能选择不能输入.
 //            setXSSFValidation(sheet, attr.combo(), 1, 100, columnIndex, columnIndex);
 //        }
-    
+
 
     /**
      * 添加单元格
@@ -1068,16 +988,13 @@ public class ExcelUtil<T>
     /**
      * 添加单元格
      */
-    public Cell addCell(Excel attr, Row row, T vo, Field field, int column)
-    {
+    public Cell addCell(Excel attr, Row row, T vo, Field field, int column) {
         Cell cell = null;
-        try
-        {
+        try {
             // 设置行高
             row.setHeight(maxHeight);
             // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
-            if (attr.isExport())
-            {
+            if (attr.isExport()) {
                 // 创建cell
                 cell = row.createCell(column);
                 int align = attr.align().value();
@@ -1088,28 +1005,19 @@ public class ExcelUtil<T>
                 String dateFormat = attr.dateFormat();
                 String readConverterExp = attr.readConverterExp();
                 String separator = attr.separator();
-                if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
-                {
+                if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) {
                     cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
-                }
-                else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
-                {
+                } else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) {
                     cell.setCellValue(convertByExp(Convert.toStr(value), readConverterExp, separator));
-                }
-                else if (value instanceof BigDecimal && -1 != attr.scale())
-                {
+                } else if (value instanceof BigDecimal && -1 != attr.scale()) {
                     cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
-                }
-                else
-                {
+                } else {
                     // 设置列类型
                     setCellVo(value, attr, cell);
                 }
                 addStatisticsData(column, Convert.toStr(value), attr);
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("导出Excel失败{}", e);
         }
         return cell;
@@ -1118,17 +1026,16 @@ public class ExcelUtil<T>
     /**
      * 设置 POI XSSFSheet 单元格提示
      *
-     * @param sheet 表单
-     * @param promptTitle 提示标题
+     * @param sheet         表单
+     * @param promptTitle   提示标题
      * @param promptContent 提示内容
-     * @param firstRow 开始行
-     * @param endRow 结束行
-     * @param firstCol 开始列
-     * @param endCol 结束列
+     * @param firstRow      开始行
+     * @param endRow        结束行
+     * @param firstCol      开始列
+     * @param endCol        结束列
      */
     public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
-            int firstCol, int endCol)
-    {
+                              int firstCol, int endCol) {
         DataValidationHelper helper = sheet.getDataValidationHelper();
         DataValidationConstraint constraint = helper.createCustomConstraint("DD1");
         CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
@@ -1141,16 +1048,15 @@ public class ExcelUtil<T>
     /**
      * 设置某些列的值只能输入预制的数据,显示下拉框.
      *
-     * @param sheet 要设置的sheet.
+     * @param sheet    要设置的sheet.
      * @param textlist 下拉框显示的内容
      * @param firstRow 开始行
-     * @param endRow 结束行
+     * @param endRow   结束行
      * @param firstCol 开始列
-     * @param endCol 结束列
+     * @param endCol   结束列
      * @return 设置好的sheet.
      */
-    public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol)
-    {
+    public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) {
         DataValidationHelper helper = sheet.getDataValidationHelper();
         // 加载下拉列表内容
         DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist);
@@ -1159,13 +1065,10 @@ public class ExcelUtil<T>
         // 数据有效性对象
         DataValidation dataValidation = helper.createValidation(constraint, regions);
         // 处理Excel兼容性问题
-        if (dataValidation instanceof XSSFDataValidation)
-        {
+        if (dataValidation instanceof XSSFDataValidation) {
             dataValidation.setSuppressDropDownArrow(true);
             dataValidation.setShowErrorBox(true);
-        }
-        else
-        {
+        } else {
             dataValidation.setSuppressDropDownArrow(false);
         }
 
@@ -1176,32 +1079,24 @@ public class ExcelUtil<T>
      * 解析导出值 0=男,1=女,2=未知
      *
      * @param propertyValue 参数值
-     * @param converterExp 翻译注解
-     * @param separator 分隔符
+     * @param converterExp  翻译注解
+     * @param separator     分隔符
      * @return 解析后值
      */
-    public static String convertByExp(String propertyValue, String converterExp, String separator)
-    {
+    public static String convertByExp(String propertyValue, String converterExp, String separator) {
         StringBuilder propertyString = new StringBuilder();
         String[] convertSource = converterExp.split(",");
-        for (String item : convertSource)
-        {
+        for (String item : convertSource) {
             String[] itemArray = item.split("=");
-            if (StringUtils.containsAny(separator, propertyValue))
-            {
-                for (String value : propertyValue.split(separator))
-                {
-                    if (itemArray[0].equals(value))
-                    {
+            if (StringUtils.containsAny(separator, propertyValue)) {
+                for (String value : propertyValue.split(separator)) {
+                    if (itemArray[0].equals(value)) {
                         propertyString.append(itemArray[1] + separator);
                         break;
                     }
                 }
-            }
-            else
-            {
-                if (itemArray[0].equals(propertyValue))
-                {
+            } else {
+                if (itemArray[0].equals(propertyValue)) {
                     return itemArray[1];
                 }
             }
@@ -1213,32 +1108,24 @@ public class ExcelUtil<T>
      * 反向解析值 男=0,女=1,未知=2
      *
      * @param propertyValue 参数值
-     * @param converterExp 翻译注解
-     * @param separator 分隔符
+     * @param converterExp  翻译注解
+     * @param separator     分隔符
      * @return 解析后值
      */
-    public static String reverseByExp(String propertyValue, String converterExp, String separator)
-    {
+    public static String reverseByExp(String propertyValue, String converterExp, String separator) {
         StringBuilder propertyString = new StringBuilder();
         String[] convertSource = converterExp.split(",");
-        for (String item : convertSource)
-        {
+        for (String item : convertSource) {
             String[] itemArray = item.split("=");
-            if (StringUtils.containsAny(separator, propertyValue))
-            {
-                for (String value : propertyValue.split(separator))
-                {
-                    if (itemArray[1].equals(value))
-                    {
+            if (StringUtils.containsAny(separator, propertyValue)) {
+                for (String value : propertyValue.split(separator)) {
+                    if (itemArray[1].equals(value)) {
                         propertyString.append(itemArray[0] + separator);
                         break;
                     }
                 }
-            }
-            else
-            {
-                if (itemArray[1].equals(propertyValue))
-                {
+            } else {
+                if (itemArray[1].equals(propertyValue)) {
                     return itemArray[0];
                 }
             }
@@ -1249,21 +1136,15 @@ public class ExcelUtil<T>
     /**
      * 合计统计信息
      */
-    private void addStatisticsData(Integer index, String text, Excel entity)
-    {
-        if (entity != null && entity.isStatistics())
-        {
+    private void addStatisticsData(Integer index, String text, Excel entity) {
+        if (entity != null && entity.isStatistics()) {
             Double temp = 0D;
-            if (!statistics.containsKey(index))
-            {
+            if (!statistics.containsKey(index)) {
                 statistics.put(index, temp);
             }
-            try
-            {
+            try {
                 temp = Double.valueOf(text);
-            }
-            catch (NumberFormatException e)
-            {
+            } catch (NumberFormatException e) {
             }
             statistics.put(index, statistics.get(index) + temp);
         }
@@ -1272,10 +1153,8 @@ public class ExcelUtil<T>
     /**
      * 创建统计行
      */
-    public void addStatisticsRow()
-    {
-        if (statistics.size() > 0)
-        {
+    public void addStatisticsRow() {
+        if (statistics.size() > 0) {
             Cell cell = null;
             Row row = sheet.createRow(sheet.getLastRowNum() + 1);
             Set<Integer> keys = statistics.keySet();
@@ -1283,8 +1162,7 @@ public class ExcelUtil<T>
             cell.setCellStyle(styles.get("total"));
             cell.setCellValue("合计");
 
-            for (Integer key : keys)
-            {
+            for (Integer key : keys) {
                 cell = row.createCell(key);
                 cell.setCellStyle(styles.get("total"));
                 cell.setCellValue(DOUBLE_FORMAT.format(statistics.get(key)));
@@ -1321,28 +1199,22 @@ public class ExcelUtil<T>
     /**
      * 获取bean中的属性值
      *
-     * @param vo 实体对象
+     * @param vo    实体对象
      * @param field 字段
      * @param excel 注解
      * @return 最终的属性值
      * @throws Exception
      */
-    private Object getTargetValue(T vo, Field field, Excel excel) throws Exception
-    {
+    private Object getTargetValue(T vo, Field field, Excel excel) throws Exception {
         Object o = field.get(vo);
-        if (StringUtils.isNotEmpty(excel.targetAttr()))
-        {
+        if (StringUtils.isNotEmpty(excel.targetAttr())) {
             String target = excel.targetAttr();
-            if (target.indexOf(".") > -1)
-            {
+            if (target.indexOf(".") > -1) {
                 String[] targets = target.split("[.]");
-                for (String name : targets)
-                {
+                for (String name : targets) {
                     o = getValue(o, name);
                 }
-            }
-            else
-            {
+            } else {
                 o = getValue(o, target);
             }
         }
@@ -1357,10 +1229,8 @@ public class ExcelUtil<T>
      * @return value
      * @throws Exception
      */
-    private Object getValue(Object o, String name) throws Exception
-    {
-        if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name))
-        {
+    private Object getValue(Object o, String name) throws Exception {
+        if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name)) {
             Class<?> clazz = o.getClass();
             Field field = clazz.getDeclaredField(name);
             field.setAccessible(true);
@@ -1372,27 +1242,22 @@ public class ExcelUtil<T>
     /**
      * 得到所有定义字段
      */
-    private void createExcelField()
-    {
+    private void createExcelField() {
         this.fields = new ArrayList<Object[]>();
         List<Field> tempFields = new ArrayList<>();
         tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
         tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
-        for (Field field : tempFields)
-        {
+        for (Field field : tempFields) {
             // 单注解
-            if (field.isAnnotationPresent(Excel.class))
-            {
+            if (field.isAnnotationPresent(Excel.class)) {
                 putToField(field, field.getAnnotation(Excel.class));
             }
 
             // 多注解
-            if (field.isAnnotationPresent(Excels.class))
-            {
+            if (field.isAnnotationPresent(Excels.class)) {
                 Excels attrs = field.getAnnotation(Excels.class);
                 Excel[] excels = attrs.value();
-                for (Excel excel : excels)
-                {
+                for (Excel excel : excels) {
                     putToField(field, excel);
                 }
             }
@@ -1404,11 +1269,9 @@ public class ExcelUtil<T>
     /**
      * 根据注解获取最大行高
      */
-    public short getRowHeight()
-    {
+    public short getRowHeight() {
         double maxHeight = 0;
-        for (Object[] os : this.fields)
-        {
+        for (Object[] os : this.fields) {
             Excel excel = (Excel) os[1];
             maxHeight = maxHeight > excel.height() ? maxHeight : excel.height();
         }
@@ -1418,19 +1281,16 @@ public class ExcelUtil<T>
     /**
      * 放到字段集合中
      */
-    private void putToField(Field field, Excel attr)
-    {
-        if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
-        {
-            this.fields.add(new Object[] { field, attr });
+    private void putToField(Field field, Excel attr) {
+        if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) {
+            this.fields.add(new Object[]{field, attr});
         }
     }
 
     /**
      * 创建一个工作簿
      */
-    public void createWorkbook()
-    {
+    public void createWorkbook() {
         this.wb = new SXSSFWorkbook(500);
     }
 
@@ -1438,19 +1298,15 @@ public class ExcelUtil<T>
      * 创建工作表
      *
      * @param sheetNo sheet数量
-     * @param index 序号
+     * @param index   序号
      */
-    public void createSheet(double sheetNo, int index)
-    {
+    public void createSheet(double sheetNo, int index) {
         this.sheet = wb.createSheet();
         this.styles = createStyles(wb);
         // 设置工作表的名称.
-        if (sheetNo == 0)
-        {
+        if (sheetNo == 0) {
             wb.setSheetName(index, sheetName);
-        }
-        else
-        {
+        } else {
             wb.setSheetName(index, sheetName + index);
         }
     }
@@ -1458,58 +1314,39 @@ public class ExcelUtil<T>
     /**
      * 获取单元格值
      *
-     * @param row 获取的行
+     * @param row    获取的行
      * @param column 获取单元格列号
      * @return 单元格值
      */
-    public Object getCellValue(Row row, int column)
-    {
-        if (row == null)
-        {
+    public Object getCellValue(Row row, int column) {
+        if (row == null) {
             return row;
         }
         Object val = "";
-        try
-        {
+        try {
             Cell cell = row.getCell(column);
-            if (StringUtils.isNotNull(cell))
-            {
-                if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA)
-                {
+            if (StringUtils.isNotNull(cell)) {
+                if (cell.getCellType() == CellType.NUMERIC || cell.getCellType() == CellType.FORMULA) {
                     val = cell.getNumericCellValue();
-                    if (DateUtil.isCellDateFormatted(cell))
-                    {
+                    if (DateUtil.isCellDateFormatted(cell)) {
                         val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
-                    }
-                    else
-                    {
-                        if ((Double) val % 1 != 0)
-                        {
+                    } else {
+                        if ((Double) val % 1 != 0) {
                             val = new BigDecimal(val.toString());
-                        }
-                        else
-                        {
+                        } else {
                             val = new DecimalFormat("0").format(val);
                         }
                     }
-                }
-                else if (cell.getCellType() == CellType.STRING)
-                {
+                } else if (cell.getCellType() == CellType.STRING) {
                     val = cell.getStringCellValue();
-                }
-                else if (cell.getCellType() == CellType.BOOLEAN)
-                {
+                } else if (cell.getCellType() == CellType.BOOLEAN) {
                     val = cell.getBooleanCellValue();
-                }
-                else if (cell.getCellType() == CellType.ERROR)
-                {
+                } else if (cell.getCellType() == CellType.ERROR) {
                     val = cell.getErrorCellValue();
                 }
 
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             return val;
         }
         return val;
@@ -1519,7 +1356,7 @@ public class ExcelUtil<T>
      * 功能描述: 把新增可见或者修改可见或者.....的列过滤出来
      *
      * @param allColumns 所有的列
-     * @param maskIndex       那六个1的顺序 [1,1,1,1,1,1]
+     * @param maskIndex  那六个1的顺序 [1,1,1,1,1,1]
      *                   sort=0  =>  新增可见
      *                   sort=1  =>  新增可修改
      *                   sort=2  =>  修改可见

+ 13 - 15
boman-common/boman-common-security/src/main/java/com/boman/common/security/feign/FeignRequestInterceptor.java

@@ -12,41 +12,39 @@ import feign.RequestTemplate;
 
 /**
  * feign 请求拦截器
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class FeignRequestInterceptor implements RequestInterceptor
-{
+public class FeignRequestInterceptor implements RequestInterceptor {
+
     @Override
-    public void apply(RequestTemplate requestTemplate)
-    {
+    public void apply(RequestTemplate requestTemplate) {
         HttpServletRequest httpServletRequest = ServletUtils.getRequest();
-        if (StringUtils.isNotNull(httpServletRequest))
-        {
+        if (StringUtils.isNotNull(httpServletRequest)) {
             Map<String, String> headers = ServletUtils.getHeaders(httpServletRequest);
             // 传递用户信息请求头,防止丢失
             String userId = headers.get(CacheConstants.DETAILS_USER_ID);
-            if (StringUtils.isNotEmpty(userId))
-            {
+            if (StringUtils.isNotEmpty(userId)) {
                 requestTemplate.header(CacheConstants.DETAILS_USER_ID, userId);
             }
+
             String token = headers.get(CacheConstants.HEADER);
             if (StringUtils.isEmpty(token)) {
                 token = headers.get(CacheConstants.HEADER.toLowerCase());
             }
-            if (StringUtils.isNotEmpty(token))
-            {
+
+            if (StringUtils.isNotEmpty(token)) {
                 requestTemplate.header(CacheConstants.HEADER, token);
             }
+
             String userName = headers.get(CacheConstants.DETAILS_USERNAME);
-            if (StringUtils.isNotEmpty(userName))
-            {
+            if (StringUtils.isNotEmpty(userName)) {
                 requestTemplate.header(CacheConstants.DETAILS_USERNAME, userName);
             }
+
             String authentication = headers.get(CacheConstants.AUTHORIZATION_HEADER);
-            if (StringUtils.isNotEmpty(authentication))
-            {
+            if (StringUtils.isNotEmpty(authentication)) {
                 requestTemplate.header(CacheConstants.AUTHORIZATION_HEADER, authentication);
             }
 

+ 3 - 0
boman-modules/boman-file/src/main/java/com/boman/file/controller/ExcelController.java

@@ -122,13 +122,16 @@ public class ExcelController {
 
         File file = new File(fileAbsPath);
         if (!file.exists()) {
+            // 还没有生成文件,可能还在查询的过程中,无法下载
             return AjaxResult.success(false);
         }
 
         long length = file.length();
         if (length == 0) {
+            // 生成文件中,内容还未写进excel,此时文件的大小为0
             return AjaxResult.success(false);
         } else {
+            // todo 需要优化,删除了用户只可以下载一次
             redisService.deleteObject(redisKey);
             return AjaxResult.success(fileStaticPath, true);
         }

+ 29 - 35
boman-modules/boman-file/src/main/java/com/boman/file/service/LocalSysFileServiceImpl.java

@@ -1,22 +1,20 @@
 package com.boman.file.service;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.TypeReference;
 import com.boman.common.core.utils.SecurityUtils;
-import com.boman.common.core.utils.ServletUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.core.utils.poi.ExcelUtil;
 import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
-import com.boman.domain.*;
+import com.boman.domain.GenTable;
+import com.boman.domain.GenTableColumn;
+import com.boman.domain.SysDept;
+import com.boman.domain.VaccineInfoOperation;
 import com.boman.domain.constant.CacheConstants;
-import com.boman.domain.constant.MaskConstant;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.dto.ExportExcelDto;
 import com.boman.domain.dto.FormDataDto;
 import com.boman.domain.dto.ImportExcelDto;
-import com.boman.domain.utils.CamelLowerUnderScore;
 import com.boman.domain.utils.ThreadPoolService;
 import com.boman.file.utils.FileUploadUtils;
 import com.boman.system.api.RemoteDeptService;
@@ -24,29 +22,26 @@ import com.boman.system.api.model.LoginUser;
 import com.boman.web.core.api.RemoteAttendanceService;
 import com.boman.web.core.api.RemoteObjService;
 import com.boman.web.core.api.RemoteVaccineInfoService;
-import com.google.common.base.CaseFormat;
-import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.lang3.BooleanUtils;
-import org.apache.http.impl.client.HttpClients;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartFile;
+
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
 import java.util.*;
-import java.util.concurrent.TimeUnit;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
+import static com.boman.common.core.utils.poi.ExcelUtil.filterData;
+import static com.boman.domain.constant.MaskConstant.LIST_VISIBLE;
 
 /**
  * 本地文件存储
@@ -174,7 +169,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
 
         GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
         List<GenTableColumn> columns = genTable.getColumns();
-        columns = ExcelUtil.filterData(columns, 4, MaskConstant.LIST_VISIBLE::equals);
+        columns = filterData(columns, 4, LIST_VISIBLE::equals);
         ExcelUtil<JSONObject> util = new ExcelUtil<>(JSONObject.class);
         List<Map<String, Object>> list;
         if (BooleanUtils.isTrue(empty)) {
@@ -210,7 +205,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
 
         GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
         List<GenTableColumn> allColumn = genTable.getColumns();
-        List<GenTableColumn> columns = ExcelUtil.filterData(allColumn, 4, MaskConstant.LIST_VISIBLE::equals);
+        List<GenTableColumn> columns = filterData(allColumn, 4, LIST_VISIBLE::equals);
 
         String filename = UUID.randomUUID() + ".xlsx";
         String fileAbsPath = localFilePath + "/" + filename;
@@ -262,10 +257,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
 //                }
 
                 String key = RedisKey.ASYNC_DOWNLOAD_YMJZ + username;
-                JSONObject jsonObject = new JSONObject();
-                jsonObject.put("fileStaticPath", fileStaticPath);
-                jsonObject.put("fileAbsPath", fileAbsPath);
-                redisService.setCacheObject(key, jsonObject);
+                saveIntoRedis(fileAbsPath, fileStaticPath, key);
             } catch (IOException e) {
                 LOGGER.error("导出失败", e);
                 e.printStackTrace();
@@ -287,26 +279,29 @@ public class LocalSysFileServiceImpl implements ISysFileService
     @Override
     public AjaxResult asyncExportYmjzExcel(HttpServletResponse response, VaccineInfoOperation info) throws IOException {
         GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + "vaccine_info");
-        List<GenTableColumn> allColumn = genTable.getColumns();
-        List<GenTableColumn> columns = ExcelUtil.filterData(allColumn, 4, MaskConstant.LIST_VISIBLE::equals);
+        List<GenTableColumn> columns = filterData(genTable.getColumns(), 4, LIST_VISIBLE::equals);
 
         String filename = UUID.randomUUID() + ".xlsx";
         String fileAbsPath = localFilePath + "/" + filename;
         String fileStaticPath = domain + localFilePrefix + "/" + filename;
-        File file = new File(fileAbsPath);
 
-        ExcelUtil<JSONObject> util = new ExcelUtil<>(JSONObject.class);
-        String username = SecurityUtils.getUsername();
+        asyncHandle(info, columns, fileAbsPath, fileStaticPath);
+        return AjaxResult.success("成功", fileStaticPath);
+    }
+
+    private void asyncHandle(VaccineInfoOperation info, List<GenTableColumn> columns, String fileAbsPath, String fileStaticPath) {
+        final String username = SecurityUtils.getUsername();
+        final ExcelUtil<JSONObject> util = new ExcelUtil<>(JSONObject.class);
+        final File file = new File(fileAbsPath);
 
         ThreadPoolService.execute(() -> {
             List<Map<String, Object>> list;
             LOGGER.info("开始查询, 线程名称: {}", Thread.currentThread().getName());
             long currentTimeMillis = System.currentTimeMillis();
+
             String key = RedisKey.ASYNC_DOWNLOAD_YMJZ + username;
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("fileStaticPath", fileStaticPath);
-            jsonObject.put("fileAbsPath", fileAbsPath);
-            redisService.setCacheObject(key, jsonObject);
+            saveIntoRedis(fileAbsPath, fileStaticPath, key);
+
             list = listYmjz(info, columns);
             boolean empty = isEmpty(list);
             int size = BooleanUtils.isFalse(empty) ? 0 : list.size();
@@ -314,20 +309,19 @@ public class LocalSysFileServiceImpl implements ISysFileService
 
             try {
                 util.asyncExportExcelCommon(new FileOutputStream(file), list, "sheet1", columns, empty, false);
-                long timeout = 2L;
-                if (size > 100000 && size < 500000) {
-                    timeout = 5L;
-                } else if (size > 500000) {
-                    timeout = 10L;
-                }
             } catch (IOException e) {
                 LOGGER.error("导出失败", e);
+                redisService.deleteObject(key);
                 e.printStackTrace();
             }
         });
+    }
 
-
-        return AjaxResult.success("成功", fileStaticPath);
+    private void saveIntoRedis(String fileAbsPath, String fileStaticPath, String key) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("fileStaticPath", fileStaticPath);
+        jsonObject.put("fileAbsPath", fileAbsPath);
+        redisService.setCacheObject(key, jsonObject);
     }
 
     private List<Map<String, Object>> getData(ExportExcelDto dto, String tableName, List<GenTableColumn> columns) {

+ 23 - 30
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysUserServiceImpl.java

@@ -66,7 +66,7 @@ public class SysUserServiceImpl implements ISysUserService
      * @return 用户信息集合信息
      */
     @Override
-    @DataScope(deptAlias = "d", userAlias = "u")
+//    @DataScope(deptAlias = "d", userAlias = "u")
     public List<SysUser> selectUserList(SysUser user)
     {
         return userMapper.selectUserList(user);
@@ -409,10 +409,8 @@ public class SysUserServiceImpl implements ISysUserService
      * @return 结果
      */
     @Override
-    public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
-    {
-        if (StringUtils.isNull(userList) || userList.size() == 0)
-        {
+    public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
+        if (StringUtils.isNull(userList) || userList.size() == 0) {
             throw new CustomException("导入用户数据不能为空!");
         }
         int successNum = 0;
@@ -420,50 +418,45 @@ public class SysUserServiceImpl implements ISysUserService
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
         String password = configService.selectConfigByKey("sys.user.initPassword");
-        for (SysUser user : userList)
-        {
-            try
-            {
+        for (SysUser user : userList) {
+            // 防止有空行,username是必须要有的
+            if (StringUtils.isEmpty(user.getUserName())) {
+                continue;
+            }
+
+            try {
                 // 验证是否存在这个用户
                 SysUser u = userMapper.selectUserByUserName(user.getUserName());
-                if (StringUtils.isNull(u))
-                {
+                if (StringUtils.isNull(u)) {
                     user.setPassword(SecurityUtils.encryptPassword(password));
                     user.setCreateBy(operName);
                     this.insertUser(user);
                     successNum++;
-                    successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
-                }
-                else if (isUpdateSupport)
-                {
+                    successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
+                } else if (isUpdateSupport) {
                     user.setUpdateBy(operName);
                     this.updateUser(user);
                     successNum++;
-                    successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
-                }
-                else
-                {
+                    successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
+                } else {
                     failureNum++;
-                    failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
+                    failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(user.getUserName()).append(" 已存在");
                 }
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
                 failureNum++;
                 String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
-                failureMsg.append(msg + e.getMessage());
+                failureMsg.append(msg)/*.append(e.getMessage())*/;
                 log.error(msg, e);
             }
         }
-        if (failureNum > 0)
-        {
+
+        if (failureNum > 0) {
             failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
-            throw new CustomException(failureMsg.toString());
-        }
-        else
-        {
+            return failureMsg.toString();
+        } else {
             successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
         }
+
         return successMsg.toString();
     }
 

+ 7 - 7
boman-modules/boman-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -70,17 +70,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="phonenumber != null and phonenumber != ''">
 			AND u.phonenumber like concat('%', #{phonenumber}, '%')
 		</if>
-		<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-			AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-		</if>
-		<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-			AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
-		</if>
+<!--		<if test="params.beginTime != null and params.beginTime != ''">&lt;!&ndash; 开始时间检索 &ndash;&gt;-->
+<!--			AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')-->
+<!--		</if>-->
+<!--		<if test="params.endTime != null and params.endTime != ''">&lt;!&ndash; 结束时间检索 &ndash;&gt;-->
+<!--			AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')-->
+<!--		</if>-->
 		<if test="deptId != null and deptId != 0">
 			AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
 		</if>
 		<!-- 数据范围过滤 -->
-		${params.dataScope}
+		<!--${params.dataScope}-->
 	</select>
 	
 	<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">

+ 41 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/AnkangMaController.java

@@ -0,0 +1,41 @@
+package com.boman.web.core.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.boman.domain.dto.AjaxResult;
+import com.boman.web.core.service.vaccineInfo.IVaccineInfoService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * @author shiqian
+ * @date 2021年11月18日 15:39
+ **/
+@RequestMapping("/akm")
+@RestController
+public class AnkangMaController {
+
+    @Resource
+    private IVaccineInfoService vaccineInfoService;
+
+    /**
+     * 功能描述: 安康码根据身份证号码查询信息
+     *
+     * @param idCard idCard
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @GetMapping("/info/{idCard}")
+    public AjaxResult getByIdCard(@PathVariable("idCard") String idCard) {
+        final JSONObject info = vaccineInfoService.getByIdCard(idCard);
+        if (info == null) {
+            return AjaxResult.error("档案库中无此人,身份证:" + idCard);
+        }
+
+        return AjaxResult.success("成功", info);
+    }
+
+
+}

+ 8 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/VaccineInfoMapper.java

@@ -91,4 +91,12 @@ public interface VaccineInfoMapper
     public String selectSysDictDataByDictLabel(String vaccineName);
 
     List<VaccineInfoOperation> listByTotalTaskCnt();
+
+    /**
+     * 功能描述: 安康码根据身份证号码查询信息
+     *
+     * @param idCard idCard
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    VaccineInfoOperation getByIdCard(String idCard);
 }

+ 8 - 0
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/IVaccineInfoService.java

@@ -77,4 +77,12 @@ public interface IVaccineInfoService
     AjaxResult statistic();
 
     List<JSONObject> list();
+
+    /**
+     * 功能描述: 安康码根据身份证号码查询信息
+     *
+     * @param idCard idCard
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    JSONObject getByIdCard(String idCard);
 }

+ 21 - 0
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -1011,4 +1011,25 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
 
         return standardlyMapper.list1(deptName);
     }
+
+    /**
+     * 功能描述: 安康码根据身份证号码查询信息
+     *
+     * @param idCard idCard
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    @Override
+    public JSONObject getByIdCard(String idCard) {
+        VaccineInfoOperation info = vaccineInfoMapper.getByIdCard(idCard);
+        JSONObject result = new JSONObject(2);
+        if (info == null) {
+            return result;
+        }
+
+        // 姓名
+        result.put("userName", info.getUserName());
+        // 家庭住址
+        result.put("domicile", info.getDomicile());
+        return result;
+    }
 }

+ 5 - 1
boman-web-core/src/main/resources/mapper/VaccineInfoMapper.xml

@@ -378,7 +378,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM vaccine_info
         WHERE age > 18
     </select>
-<!--    AND (-->
+
+    <select id="getByIdCard" resultMap="VaccineInfoResult">
+        select * from vaccine_info where id_card = #{idCard} limit 1;
+    </select>
+    <!--    AND (-->
 <!--    contraindication IS NULL-->
 <!--    OR suspend IS NULL-->
 <!--    OR other IS NULL-->