|
|
|
@ -1,22 +1,29 @@ |
|
|
|
|
package org.jeecg.modules.demo.expert.controller; |
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
import java.net.URLDecoder; |
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat; |
|
|
|
|
import io.swagger.annotations.ApiModelProperty; |
|
|
|
|
import org.apache.commons.beanutils.BeanUtils; |
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.common.aspect.annotation.Dict; |
|
|
|
|
import org.jeecg.common.constant.CommonConstant; |
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
|
import org.jeecg.common.util.ImportExcelUtil; |
|
|
|
|
import org.jeecg.common.util.PasswordUtil; |
|
|
|
|
import org.jeecg.common.util.oConvertUtils; |
|
|
|
|
import org.jeecg.config.JeecgBaseConfig; |
|
|
|
|
import org.jeecg.modules.base.service.BaseCommonService; |
|
|
|
|
import org.jeecg.modules.demo.annualcomp.entity.AnnualComp; |
|
|
|
|
import org.jeecg.modules.demo.annualcomp.service.IAnnualCompService; |
|
|
|
@ -24,6 +31,7 @@ import org.jeecg.modules.demo.annualcompgroup.service.IAnnualCompGroupService; |
|
|
|
|
import org.jeecg.modules.demo.compexp.entity.CompExp; |
|
|
|
|
import org.jeecg.modules.demo.compexp.service.ICompExpService; |
|
|
|
|
import org.jeecg.modules.demo.expert.entity.Expert; |
|
|
|
|
import org.jeecg.modules.demo.expert.entity.UserExpertExcel; |
|
|
|
|
import org.jeecg.modules.demo.expert.service.IExpertService; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
@ -34,14 +42,21 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.jeecg.modules.demo.expgroup.entity.ExpGroup; |
|
|
|
|
import org.jeecg.modules.demo.expgroup.service.IExpGroupService; |
|
|
|
|
import org.jeecg.modules.system.entity.SysUser; |
|
|
|
|
import org.jeecg.modules.system.entity.SysUserDepart; |
|
|
|
|
import org.jeecg.modules.system.entity.SysUserRole; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserDepartService; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserRoleService; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserService; |
|
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil; |
|
|
|
|
import org.jeecgframework.poi.excel.annotation.Excel; |
|
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
|
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams; |
|
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams; |
|
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.format.annotation.DateTimeFormat; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest; |
|
|
|
@ -84,9 +99,19 @@ public class ExpertController extends JeecgController<Expert, IExpertService> { |
|
|
|
|
@Autowired |
|
|
|
|
private IExpGroupService expGroupService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private JeecgBaseConfig jeecgBaseConfig; |
|
|
|
|
|
|
|
|
|
@Value("${jeecg.path.upload}") |
|
|
|
|
private String upLoadPath; |
|
|
|
|
|
|
|
|
|
//角色
|
|
|
|
|
@Autowired |
|
|
|
|
private ISysUserRoleService sysUserRoleService; |
|
|
|
|
|
|
|
|
|
//用户部门
|
|
|
|
|
@Autowired |
|
|
|
|
private ISysUserDepartService sysUserDepartService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
@ -209,17 +234,22 @@ public class ExpertController extends JeecgController<Expert, IExpertService> { |
|
|
|
|
QueryWrapper<Expert> queryWrapper = QueryGenerator.initQueryWrapper(expert, req.getParameterMap()); |
|
|
|
|
queryWrapper.eq("user_id",id); |
|
|
|
|
List<Expert> list = expertService.list(queryWrapper); |
|
|
|
|
if(list.size()==0) { |
|
|
|
|
return Result.error("未找到对应数据"); |
|
|
|
|
} |
|
|
|
|
Expert model=list.get(0); |
|
|
|
|
|
|
|
|
|
CompExp compExp = new CompExp(); |
|
|
|
|
QueryWrapper<CompExp> queryWrapper1 = QueryGenerator.initQueryWrapper(compExp, req.getParameterMap()); |
|
|
|
|
queryWrapper1.eq("expid",list.get(0).getId()); |
|
|
|
|
queryWrapper1.eq("expid",model.getId()); |
|
|
|
|
List<CompExp> list1 = compExpService.list(queryWrapper1); |
|
|
|
|
if(list.size()==0) { |
|
|
|
|
return Result.error("未找到对应数据"); |
|
|
|
|
if(list1.size()>0) { |
|
|
|
|
CompExp compExpModel=list1.get(0); |
|
|
|
|
model.setCompid(compExpModel.getCompid()); |
|
|
|
|
model.setStat(compExpModel.getStat()); |
|
|
|
|
model.setCompName(compExpModel.getCompName()); |
|
|
|
|
} |
|
|
|
|
list.get(0).setCompid(list1.get(0).getCompid()); |
|
|
|
|
list.get(0).setStat(list1.get(0).getStat()); |
|
|
|
|
list.get(0).setCompName(list1.get(0).getCompName()); |
|
|
|
|
return Result.OK(list.get(0)); |
|
|
|
|
return Result.OK(model); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -246,7 +276,8 @@ public class ExpertController extends JeecgController<Expert, IExpertService> { |
|
|
|
|
@RequestMapping(value = "/addZJ", method = RequestMethod.POST) |
|
|
|
|
public Result<SysUser> addZJ(@RequestBody JSONObject jsonObject) { |
|
|
|
|
Result<SysUser> result = new Result<SysUser>(); |
|
|
|
|
String selectedRoles = jsonObject.getString("selectedroles"); |
|
|
|
|
// String selectedRoles = jsonObject.getString("selectedroles");
|
|
|
|
|
String selectedRoles = "1731948288626339841"; |
|
|
|
|
String selectedDeparts = jsonObject.getString("selecteddeparts"); |
|
|
|
|
String expSc = jsonObject.getString("expSc"); |
|
|
|
|
String expResume = jsonObject.getString("expResume");//简介
|
|
|
|
@ -380,28 +411,256 @@ public class ExpertController extends JeecgController<Expert, IExpertService> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出excel |
|
|
|
|
* 导出excel模板 |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param expert |
|
|
|
|
*/ |
|
|
|
|
//@RequiresPermissions("expert:expert:exportXls")
|
|
|
|
|
@RequestMapping(value = "/exportXls") |
|
|
|
|
public ModelAndView exportXls(HttpServletRequest request, Expert expert) { |
|
|
|
|
return super.exportXls(request, expert, Expert.class, "专家表"); |
|
|
|
|
@RequestMapping(value = "/exportXlsMb") |
|
|
|
|
public ModelAndView exportXlsMb(HttpServletRequest request, Expert expert) { |
|
|
|
|
//return super.exportXls(request, expert, Expert.class, "专家表");
|
|
|
|
|
|
|
|
|
|
//LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
|
// Step.2 获取导出数据
|
|
|
|
|
List<UserExpertExcel> exportList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// Step.3 AutoPoi 导出Excel
|
|
|
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
|
|
|
|
//此处设置的filename无效 ,前端会重更新设置一下
|
|
|
|
|
mv.addObject(NormalExcelConstants.FILE_NAME, "专家表导入模板"); |
|
|
|
|
mv.addObject(NormalExcelConstants.CLASS, UserExpertExcel.class); |
|
|
|
|
//update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
|
|
|
|
|
ExportParams exportParams=new ExportParams("专家表导入模板", "仅允许专家导入" , "专家表导入模板"); |
|
|
|
|
exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload()); |
|
|
|
|
//update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
|
|
|
|
|
mv.addObject(NormalExcelConstants.PARAMS,exportParams); |
|
|
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, exportList); |
|
|
|
|
return mv; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通过excel导入数据 |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param response |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
//@RequiresPermissions("expert:expert:importExcel")
|
|
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
|
return super.importExcel(request, response, Expert.class); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 导出excel |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param sysUser |
|
|
|
|
*/ |
|
|
|
|
//@RequiresPermissions("system:user:export")
|
|
|
|
|
@RequestMapping(value = "/exportXls") |
|
|
|
|
public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) { |
|
|
|
|
// Step.1 组装查询条件
|
|
|
|
|
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap()); |
|
|
|
|
//Step.2 AutoPoi 导出Excel
|
|
|
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
|
|
|
|
//update-begin--Author:kangxiaolin Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据--------------------
|
|
|
|
|
String selections = request.getParameter("selections"); |
|
|
|
|
if(!oConvertUtils.isEmpty(selections)){ |
|
|
|
|
queryWrapper.in("id",selections.split(",")); |
|
|
|
|
} |
|
|
|
|
//角色
|
|
|
|
|
String rolesIds = "1731948288626339841"; |
|
|
|
|
if (oConvertUtils.isNotEmpty(rolesIds)) { |
|
|
|
|
List<String> roleIds = Arrays.asList(rolesIds.split(",")); |
|
|
|
|
// 使用 exists 子查询方式查询
|
|
|
|
|
// 注意:MyBatis-Plus 不直接支持 exists 语法,因此我们使用 inSql 来模拟这个行为
|
|
|
|
|
queryWrapper.inSql( |
|
|
|
|
"id", |
|
|
|
|
"SELECT user_id FROM sys_user_role WHERE role_id IN (" |
|
|
|
|
+ StringUtils.join(roleIds.stream().map(id -> "'" + id + "'").collect(Collectors.toList()), ",") |
|
|
|
|
+ ")" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//update-end--Author:kangxiaolin Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据----------------------
|
|
|
|
|
List<SysUser> pageList = sysUserService.list(queryWrapper); |
|
|
|
|
//批量查询用户的所属部门
|
|
|
|
|
//step.1 先拿到全部的 useids
|
|
|
|
|
List<String> userIds = pageList.stream().map(SysUser::getId).collect(Collectors.toList()); |
|
|
|
|
//step.2 通过 useids,一次性查询用户的所属部门名字
|
|
|
|
|
if (!userIds.isEmpty()) { |
|
|
|
|
Map<String, String> depNames = sysUserService.getDepNamesByUserIds(userIds); |
|
|
|
|
// 更新 SysUser 对象,添加部门名称
|
|
|
|
|
pageList.forEach(user -> user.setDepartIds(depNames.get(user.getId()))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<UserExpertExcel> exportList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// 遍历 SysUser 列表
|
|
|
|
|
for (SysUser item : pageList) { |
|
|
|
|
// 创建 UserExpertExcel 实例
|
|
|
|
|
UserExpertExcel excelItem = new UserExpertExcel(); |
|
|
|
|
|
|
|
|
|
// 复制 SysUser 的信息
|
|
|
|
|
try { |
|
|
|
|
excelItem.setUsername(item.getUsername());//登录账号
|
|
|
|
|
excelItem.setWorkNo(item.getWorkNo());//工号
|
|
|
|
|
excelItem.setRealname(item.getRealname());//真实姓名
|
|
|
|
|
excelItem.setBirthday(item.getBirthday());//生日
|
|
|
|
|
excelItem.setSex(item.getSex());//
|
|
|
|
|
excelItem.setEmail(item.getEmail());//电子邮件
|
|
|
|
|
excelItem.setPhone(item.getPhone());//电话
|
|
|
|
|
excelItem.setDepartIds(item.getDepartIds());//负责部门
|
|
|
|
|
excelItem.setStatus(item.getStatus());//状态
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 处理异常,比如属性类型不匹配
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
// 创建 QueryWrapper 实例
|
|
|
|
|
QueryWrapper<Expert> queryWrapperExpert = new QueryWrapper<>(); |
|
|
|
|
queryWrapperExpert.eq("user_id", item.getId()); |
|
|
|
|
|
|
|
|
|
// 执行查询
|
|
|
|
|
Expert exp = expertService.getOne(queryWrapperExpert); |
|
|
|
|
// 如果 Expert 存在,则复制 Expert 的信息
|
|
|
|
|
if (exp != null) { |
|
|
|
|
try { |
|
|
|
|
excelItem.setName(exp.getName());//专家名称
|
|
|
|
|
excelItem.setExpTitle(exp.getExpTitle());//专家学历
|
|
|
|
|
excelItem.setExpZc(exp.getExpZc());//职称
|
|
|
|
|
excelItem.setExpXw(exp.getExpXw());//学位
|
|
|
|
|
excelItem.setExpCsgz(exp.getExpCsgz());//从事工作
|
|
|
|
|
excelItem.setExpYjfx(exp.getExpYjfx());//研究方向
|
|
|
|
|
excelItem.setExpSc(exp.getExpSc());//专家毕业院校
|
|
|
|
|
excelItem.setExpResume(exp.getExpResume());//简介
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 处理异常,比如属性类型不匹配
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 将 UserExpertExcel 添加到列表中
|
|
|
|
|
exportList.add(excelItem); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//导出文件名称
|
|
|
|
|
mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表"); |
|
|
|
|
mv.addObject(NormalExcelConstants.CLASS, UserExpertExcel.class); |
|
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
ExportParams exportParams = new ExportParams("专家列表数据", "导出人:"+user.getRealname(), "导出信息"); |
|
|
|
|
exportParams.setImageBasePath(upLoadPath); |
|
|
|
|
mv.addObject(NormalExcelConstants.PARAMS, exportParams); |
|
|
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, exportList); |
|
|
|
|
|
|
|
|
|
return mv; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通过excel导入数据 |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param response |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response)throws IOException { |
|
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
|
|
|
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
|
|
|
|
// 错误信息
|
|
|
|
|
List<String> errorMessage = new ArrayList<>(); |
|
|
|
|
int successLines = 0, errorLines = 0; |
|
|
|
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
|
|
|
|
MultipartFile file = entity.getValue();// 获取上传文件对象
|
|
|
|
|
ImportParams params = new ImportParams(); |
|
|
|
|
params.setTitleRows(2); |
|
|
|
|
params.setHeadRows(1); |
|
|
|
|
params.setNeedSave(true); |
|
|
|
|
try { |
|
|
|
|
List<UserExpertExcel> listSysUsers = ExcelImportUtil.importExcel(file.getInputStream(), UserExpertExcel.class, params); |
|
|
|
|
for (int i = 0; i < listSysUsers.size(); i++) { |
|
|
|
|
SysUserRole sysUserRole = new SysUserRole(); |
|
|
|
|
UserExpertExcel userExpertExcel = listSysUsers.get(i); |
|
|
|
|
SysUser user=new SysUser(); |
|
|
|
|
|
|
|
|
|
user.setUsername(userExpertExcel.getUsername());//登录账号
|
|
|
|
|
user.setWorkNo(userExpertExcel.getWorkNo());//工号
|
|
|
|
|
user.setRealname(userExpertExcel.getRealname());//真实姓名
|
|
|
|
|
user.setBirthday(userExpertExcel.getBirthday());//生日
|
|
|
|
|
user.setSex(userExpertExcel.getSex());//
|
|
|
|
|
user.setEmail(userExpertExcel.getEmail());//电子邮件
|
|
|
|
|
user.setPhone(userExpertExcel.getPhone());//电话
|
|
|
|
|
user.setDepartIds(userExpertExcel.getDepartIds());//负责部门
|
|
|
|
|
user.setStatus(userExpertExcel.getStatus());//状态
|
|
|
|
|
user.setPassword("Admin123."); |
|
|
|
|
// 密码加密加盐
|
|
|
|
|
String salt = oConvertUtils.randomGen(8); |
|
|
|
|
user.setSalt(salt); |
|
|
|
|
String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), salt); |
|
|
|
|
user.setPassword(passwordEncode); |
|
|
|
|
try { |
|
|
|
|
if (user.getUsername()=="" || user.getUsername().isEmpty() || user.getUsername()==null) { |
|
|
|
|
}else { |
|
|
|
|
user.setDelFlag(0); |
|
|
|
|
sysUserService.save(user); |
|
|
|
|
sysUserRole.setUserId(user.getId()); |
|
|
|
|
sysUserRole.setRoleId("1731948288626339841"); |
|
|
|
|
sysUserRoleService.save(sysUserRole); |
|
|
|
|
//专家表
|
|
|
|
|
// 执行查询
|
|
|
|
|
Expert exp = new Expert(); |
|
|
|
|
// 如果 Expert 存在,则复制 Expert 的信息
|
|
|
|
|
try { |
|
|
|
|
exp.setUserId(user.getId());//
|
|
|
|
|
exp.setName(userExpertExcel.getName());//专家名称
|
|
|
|
|
exp.setExpTitle(userExpertExcel.getExpTitle());//专家学历
|
|
|
|
|
exp.setExpZc(userExpertExcel.getExpZc());//职称
|
|
|
|
|
exp.setExpXw(userExpertExcel.getExpXw());//学位
|
|
|
|
|
exp.setExpCsgz(userExpertExcel.getExpCsgz());//从事工作
|
|
|
|
|
exp.setExpYjfx(userExpertExcel.getExpYjfx());//研究方向
|
|
|
|
|
exp.setExpSc(userExpertExcel.getExpSc());//专家毕业院校
|
|
|
|
|
exp.setExpResume(userExpertExcel.getExpResume());//简介
|
|
|
|
|
expertService.save(exp); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 处理异常,比如属性类型不匹配
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
successLines++; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
errorLines++; |
|
|
|
|
String message = e.getMessage().toLowerCase(); |
|
|
|
|
int lineNumber = i + 1; |
|
|
|
|
// 通过索引名判断出错信息
|
|
|
|
|
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER_USERNAME)) { |
|
|
|
|
errorMessage.add("第 " + lineNumber + " 行:用户名已经存在,忽略导入。"); |
|
|
|
|
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER_WORK_NO)) { |
|
|
|
|
errorMessage.add("第 " + lineNumber + " 行:工号已经存在,忽略导入。"); |
|
|
|
|
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER_PHONE)) { |
|
|
|
|
errorMessage.add("第 " + lineNumber + " 行:手机号已经存在,忽略导入。"); |
|
|
|
|
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER_EMAIL)) { |
|
|
|
|
errorMessage.add("第 " + lineNumber + " 行:电子邮件已经存在,忽略导入。"); |
|
|
|
|
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER)) { |
|
|
|
|
errorMessage.add("第 " + lineNumber + " 行:违反表唯一性约束。"); |
|
|
|
|
} else { |
|
|
|
|
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入"); |
|
|
|
|
log.error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 批量将部门和用户信息建立关联关系
|
|
|
|
|
String departIds = userExpertExcel.getDepartIds(); |
|
|
|
|
if (StringUtils.isNotBlank(departIds)) { |
|
|
|
|
String userId = user.getId(); |
|
|
|
|
String[] departIdArray = departIds.split(","); |
|
|
|
|
List<SysUserDepart> userDepartList = new ArrayList<>(departIdArray.length); |
|
|
|
|
for (String departId : departIdArray) { |
|
|
|
|
userDepartList.add(new SysUserDepart(userId, departId)); |
|
|
|
|
} |
|
|
|
|
sysUserDepartService.saveBatch(userDepartList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
errorMessage.add("发生异常:" + e.getMessage()); |
|
|
|
|
log.error(e.getMessage(), e); |
|
|
|
|
} finally { |
|
|
|
|
try { |
|
|
|
|
file.getInputStream().close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
log.error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|