fix 部门导入
This commit is contained in:
+2
@@ -239,6 +239,8 @@ public interface CommonConstant {
|
|||||||
public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code";
|
public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code";
|
||||||
/** sys_depart 表 code 唯一键索引 */
|
/** sys_depart 表 code 唯一键索引 */
|
||||||
public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code";
|
public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code";
|
||||||
|
/** sys_depart 表 部门名称 唯一键索引 */
|
||||||
|
public static final String SQL_INDEX_UNIQ_DEPART_DEPART_NAME = "uniq_depart_depart_name";
|
||||||
/**
|
/**
|
||||||
* 在线聊天 是否为默认分组
|
* 在线聊天 是否为默认分组
|
||||||
*/
|
*/
|
||||||
|
|||||||
+4
-3
@@ -1,6 +1,7 @@
|
|||||||
package com.jero.common.system.vo;
|
package com.jero.common.system.vo;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -41,7 +42,7 @@ public class SysDepartTreeModel implements Serializable{
|
|||||||
|
|
||||||
private String departNameAbbr;
|
private String departNameAbbr;
|
||||||
|
|
||||||
private Integer departOrder;
|
private BigDecimal departOrder;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@@ -224,11 +225,11 @@ public class SysDepartTreeModel implements Serializable{
|
|||||||
this.departNameAbbr = departNameAbbr;
|
this.departNameAbbr = departNameAbbr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDepartOrder() {
|
public BigDecimal getDepartOrder() {
|
||||||
return departOrder;
|
return departOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDepartOrder(Integer departOrder) {
|
public void setDepartOrder(BigDecimal departOrder) {
|
||||||
this.departOrder = departOrder;
|
this.departOrder = departOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -69,10 +69,7 @@ public class ImportExcelUtil {
|
|||||||
public static List<String> importDateSaveOne(Object obj, Class serviceClass,List<String> errorMessage,int i,String errorFlag) {
|
public static List<String> importDateSaveOne(Object obj, Class serviceClass,List<String> errorMessage,int i,String errorFlag) {
|
||||||
IService bean =(IService) SpringContextUtils.getBean(serviceClass);
|
IService bean =(IService) SpringContextUtils.getBean(serviceClass);
|
||||||
try {
|
try {
|
||||||
boolean save = bean.save(obj);
|
bean.save(obj);
|
||||||
if(!save){
|
|
||||||
throw new Exception(errorFlag);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String message = e.getMessage().toLowerCase();
|
String message = e.getMessage().toLowerCase();
|
||||||
int lineNumber = i + 1;
|
int lineNumber = i + 1;
|
||||||
@@ -85,6 +82,8 @@ public class ImportExcelUtil {
|
|||||||
errorMessage.add("第 " + lineNumber + " 行:职务编码已经存在,忽略导入。");
|
errorMessage.add("第 " + lineNumber + " 行:职务编码已经存在,忽略导入。");
|
||||||
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
|
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
|
||||||
errorMessage.add("第 " + lineNumber + " 行:部门编码已经存在,忽略导入。");
|
errorMessage.add("第 " + lineNumber + " 行:部门编码已经存在,忽略导入。");
|
||||||
|
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_DEPART_NAME)) {
|
||||||
|
errorMessage.add("第 " + lineNumber + " 行:部门名称已经存在,忽略导入。");
|
||||||
}else {
|
}else {
|
||||||
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
|
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
|||||||
+16
-3
@@ -25,6 +25,7 @@ import com.jero.modules.system.service.ISysDepartService;
|
|||||||
import com.jero.modules.system.service.ISysUserDepartService;
|
import com.jero.modules.system.service.ISysUserDepartService;
|
||||||
import com.jero.modules.system.service.ISysUserService;
|
import com.jero.modules.system.service.ISysUserService;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportCheckUtil;
|
||||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
@@ -133,8 +134,15 @@ public class SysDepartController {
|
|||||||
// FindsDepartsChildrenUtil.clearDepartIdModel();
|
// FindsDepartsChildrenUtil.clearDepartIdModel();
|
||||||
result.success("添加成功!");
|
result.success("添加成功!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(),e);
|
String message = e.getMessage().toLowerCase();
|
||||||
result.error500("操作失败");
|
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
|
||||||
|
result.error500("部门编码已经存在");
|
||||||
|
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_DEPART_NAME)) {
|
||||||
|
result.error500("部门名称已经存在");
|
||||||
|
}else {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
result.error500("操作失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -326,7 +334,7 @@ public class SysDepartController {
|
|||||||
@RequiresPermissions("sys:depart:import")
|
@RequiresPermissions("sys:depart:import")
|
||||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException{
|
||||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
List<String> errorMessageList = new ArrayList<>();
|
List<String> errorMessageList = new ArrayList<>();
|
||||||
List<SysDepart> listSysDeparts = null;
|
List<SysDepart> listSysDeparts = null;
|
||||||
@@ -337,6 +345,11 @@ public class SysDepartController {
|
|||||||
params.setTitleRows(1);
|
params.setTitleRows(1);
|
||||||
params.setHeadRows(1);
|
params.setHeadRows(1);
|
||||||
params.setNeedSave(true);
|
params.setNeedSave(true);
|
||||||
|
//导入Excel格式校验,看匹配的字段文本概率
|
||||||
|
Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), SysDepart.class, params);
|
||||||
|
if(!t){
|
||||||
|
return Result.error("导入Excel校验失败 !");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// orgCode编码长度
|
// orgCode编码长度
|
||||||
int codeLength = YouBianCodeUtil.zhanweiLength;
|
int codeLength = YouBianCodeUtil.zhanweiLength;
|
||||||
|
|||||||
+3
-2
@@ -22,6 +22,7 @@ import com.jero.modules.system.model.TreeModel;
|
|||||||
import com.jero.modules.system.service.*;
|
import com.jero.modules.system.service.*;
|
||||||
import com.jero.modules.system.util.PermissionDataUtil;
|
import com.jero.modules.system.util.PermissionDataUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -250,7 +251,7 @@ public class SysPermissionController {
|
|||||||
*/
|
*/
|
||||||
//@RequiresRoles({ "admin" })
|
//@RequiresRoles({ "admin" })
|
||||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||||
public Result<SysPermission> add(@RequestBody SysPermission permission) {
|
public Result<SysPermission> add(@RequestBody @Validated SysPermission permission) {
|
||||||
Result<SysPermission> result = new Result<SysPermission>();
|
Result<SysPermission> result = new Result<SysPermission>();
|
||||||
try {
|
try {
|
||||||
permission = PermissionDataUtil.intelligentProcessData(permission);
|
permission = PermissionDataUtil.intelligentProcessData(permission);
|
||||||
@@ -270,7 +271,7 @@ public class SysPermissionController {
|
|||||||
*/
|
*/
|
||||||
//@RequiresRoles({ "admin" })
|
//@RequiresRoles({ "admin" })
|
||||||
@RequestMapping(value = "/edit", method = { RequestMethod.POST, RequestMethod.POST })
|
@RequestMapping(value = "/edit", method = { RequestMethod.POST, RequestMethod.POST })
|
||||||
public Result<SysPermission> edit(@RequestBody SysPermission permission) {
|
public Result<SysPermission> edit(@RequestBody @Validated SysPermission permission) {
|
||||||
Result<SysPermission> result = new Result<>();
|
Result<SysPermission> result = new Result<>();
|
||||||
try {
|
try {
|
||||||
permission = PermissionDataUtil.intelligentProcessData(permission);
|
permission = PermissionDataUtil.intelligentProcessData(permission);
|
||||||
|
|||||||
+6
-5
@@ -51,6 +51,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -603,12 +604,12 @@ public class SysUserController {
|
|||||||
params.setTitleRows(1);
|
params.setTitleRows(1);
|
||||||
params.setHeadRows(1);
|
params.setHeadRows(1);
|
||||||
params.setNeedSave(true);
|
params.setNeedSave(true);
|
||||||
|
//导入Excel格式校验,看匹配的字段文本概率
|
||||||
|
Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), SysUser.class, params);
|
||||||
|
if(!t){
|
||||||
|
return Result.error("导入Excel校验失败 !");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
//导入Excel格式校验,看匹配的字段文本概率
|
|
||||||
Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), SysUser.class, params);
|
|
||||||
if(!t){
|
|
||||||
return Result.error("导入Excel校验失败 !");
|
|
||||||
}
|
|
||||||
List<SysUser> listSysUsers = ExcelImportUtil.importExcel(file.getInputStream(), SysUser.class, params);
|
List<SysUser> listSysUsers = ExcelImportUtil.importExcel(file.getInputStream(), SysUser.class, params);
|
||||||
for (int i = 0; i < listSysUsers.size(); i++) {
|
for (int i = 0; i < listSysUsers.size(); i++) {
|
||||||
int lineNumber = i + 3;
|
int lineNumber = i + 3;
|
||||||
|
|||||||
+14
-7
@@ -8,8 +8,12 @@ import lombok.Data;
|
|||||||
import com.jero.common.aspect.annotation.Dict;
|
import com.jero.common.aspect.annotation.Dict;
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.springframework.format.annotation.NumberFormat;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Max;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -30,6 +34,7 @@ public class SysDepart implements Serializable {
|
|||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
private String id;
|
private String id;
|
||||||
/**父机构ID*/
|
/**父机构ID*/
|
||||||
|
@Excel(name="上级部门",width=15,orderNum = "1",dictTable = "sys_depart",dicText = "depart_name",dicCode = "id")
|
||||||
private String parentId;
|
private String parentId;
|
||||||
/**机构/部门名称*/
|
/**机构/部门名称*/
|
||||||
@Excel(name="机构/部门名称",width=15)
|
@Excel(name="机构/部门名称",width=15)
|
||||||
@@ -39,29 +44,31 @@ public class SysDepart implements Serializable {
|
|||||||
/**缩写*/
|
/**缩写*/
|
||||||
private String departNameAbbr;
|
private String departNameAbbr;
|
||||||
/**排序*/
|
/**排序*/
|
||||||
@Excel(name="排序",width=15)
|
@Excel(name="排序",width=15,orderNum = "4")
|
||||||
private Integer departOrder;
|
@Min(value = 1,message = "排序最小为1,最大为99999")
|
||||||
|
@Max(value = 99999,message = "排序最小为1,最大为99999")
|
||||||
|
private BigDecimal departOrder;
|
||||||
/**描述*/
|
/**描述*/
|
||||||
@Excel(name="描述",width=15)
|
@Excel(name="描述",width=15)
|
||||||
private String description;
|
private String description;
|
||||||
/**机构类别 1公司,2组织机构,2岗位*/
|
/**机构类别 1公司,2组织机构,2岗位*/
|
||||||
@Excel(name="机构类别",width=15,dicCode="org_category",orderNum = "1")
|
@Excel(name="机构类别",width=15,dicCode="org_category",orderNum = "3")
|
||||||
private String orgCategory;
|
private String orgCategory;
|
||||||
/**机构类型*/
|
/**机构类型*/
|
||||||
private String orgType;
|
private String orgType;
|
||||||
/**机构编码*/
|
/**机构编码*/
|
||||||
@Excel(name="机构编码",width=15)
|
@Excel(name="机构编码",width=15,orderNum = "2")
|
||||||
private String orgCode;
|
private String orgCode;
|
||||||
/**手机号*/
|
/**手机号*/
|
||||||
@Excel(name="电话",width=15,orderNum = "2")
|
@Excel(name="电话",width=15,orderNum = "5")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
/**传真*/
|
/**传真*/
|
||||||
private String fax;
|
private String fax;
|
||||||
/**地址*/
|
/**地址*/
|
||||||
@Excel(name="地址",width=15,orderNum = "3")
|
@Excel(name="地址",width=15,orderNum = "6")
|
||||||
private String address;
|
private String address;
|
||||||
/**备注*/
|
/**备注*/
|
||||||
@Excel(name="备注",width=15,orderNum = "4")
|
@Excel(name="备注",width=15,orderNum = "7")
|
||||||
private String memo;
|
private String memo;
|
||||||
/**状态(1启用,0不启用)*/
|
/**状态(1启用,0不启用)*/
|
||||||
@Dict(dicCode = "depart_status")
|
@Dict(dicCode = "depart_status")
|
||||||
|
|||||||
+4
-1
@@ -14,6 +14,8 @@ import com.jero.common.aspect.annotation.Dict;
|
|||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
import javax.validation.constraints.Digits;
|
import javax.validation.constraints.Digits;
|
||||||
|
import javax.validation.constraints.Max;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -63,7 +65,8 @@ public class SysDictItem implements Serializable {
|
|||||||
* 排序
|
* 排序
|
||||||
*/
|
*/
|
||||||
@Excel(name = "排序", width = 15,type=4)
|
@Excel(name = "排序", width = 15,type=4)
|
||||||
@Digits(integer = 5,fraction = 2, message = "排序:最大为99999.99")
|
@Min(value = 1,message = "排序最小为1,最大为99999")
|
||||||
|
@Max(value = 99999,message = "排序最小为1,最大为99999")
|
||||||
private BigDecimal sortOrder;
|
private BigDecimal sortOrder;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7
@@ -10,6 +10,10 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import com.jero.common.aspect.annotation.Dict;
|
import com.jero.common.aspect.annotation.Dict;
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.NumberFormat;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Max;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -78,6 +82,9 @@ public class SysPermission implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 菜单排序
|
* 菜单排序
|
||||||
*/
|
*/
|
||||||
|
@Min(value = 1,message = "排序最小为1,最大为99999")
|
||||||
|
@Max(value = 99999,message = "排序最小为1,最大为99999")
|
||||||
|
@NumberFormat(pattern = "#.00")
|
||||||
private Double sortNo;
|
private Double sortNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
-3
@@ -76,7 +76,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
|||||||
/**
|
/**
|
||||||
* queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
|
* queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
|
||||||
*/
|
*/
|
||||||
@Cacheable(value = CacheConstant.SYS_DEPARTS_CACHE)
|
//@Cacheable(value = CacheConstant.SYS_DEPARTS_CACHE)
|
||||||
@Override
|
@Override
|
||||||
public List<SysDepartTreeModel> queryTreeList() {
|
public List<SysDepartTreeModel> queryTreeList() {
|
||||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||||
@@ -88,7 +88,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
|||||||
return listResult;
|
return listResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(value = CacheConstant.SYS_DEPART_IDS_CACHE)
|
//@Cacheable(value = CacheConstant.SYS_DEPART_IDS_CACHE)
|
||||||
@Override
|
@Override
|
||||||
public List<DepartIdModel> queryDepartIdTreeList() {
|
public List<DepartIdModel> queryDepartIdTreeList() {
|
||||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||||
@@ -104,7 +104,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
|||||||
* saveDepartData 对应 add 保存用户在页面添加的新的部门对象数据
|
* saveDepartData 对应 add 保存用户在页面添加的新的部门对象数据
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveDepartData(SysDepart sysDepart, String username) {
|
public void saveDepartData(SysDepart sysDepart, String username) {
|
||||||
if (sysDepart != null && username != null) {
|
if (sysDepart != null && username != null) {
|
||||||
if (sysDepart.getParentId() == null) {
|
if (sysDepart.getParentId() == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user