|
@@ -2,7 +2,9 @@ package com.fs.company.service.impl;
|
|
|
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
+import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.*;
|
|
@@ -18,6 +20,7 @@ import com.fs.his.vo.CitysAreaVO;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
import com.fs.qw.vo.CompanyUserQwVO;
|
|
|
import com.fs.qw.vo.QwUserVO;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.wxUser.domain.CompanyWxUser;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -399,4 +402,78 @@ public class CompanyUserServiceImpl implements ICompanyUserService
|
|
|
public List<CompanyUser> selectCompanyUserByIds(Set<Long> ids) {
|
|
|
return companyUserMapper.selectCompanyUserByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String importUserInfoService(List<CompanyUser> userList,Long deptId,Long companyId) {
|
|
|
+ if (StringUtils.isNull(userList) || userList.size() == 0)
|
|
|
+ {
|
|
|
+ throw new ServiceException("导入用户数据不能为空!");
|
|
|
+ }
|
|
|
+ int successNum = 0;
|
|
|
+ int failureNum = 0;
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+
|
|
|
+ for (CompanyUser user : userList) {
|
|
|
+ if (user.getUserName() == null || "".equals(user.getUserName()))
|
|
|
+ {
|
|
|
+ throw new ServiceException("用户账号不能为空!");
|
|
|
+ }
|
|
|
+ if (user.getNickName() == null || "".equals(user.getNickName()))
|
|
|
+ {
|
|
|
+ throw new ServiceException("用户昵称不能为空!");
|
|
|
+ }
|
|
|
+ if (user.getPhonenumber() == null || "".equals(user.getPhonenumber()))
|
|
|
+ {
|
|
|
+ throw new ServiceException("手机号码不能为空!");
|
|
|
+ }
|
|
|
+ if (user.getSex() == null || "".equals(user.getSex()))
|
|
|
+ {
|
|
|
+ throw new ServiceException("用户性别不能为空!");
|
|
|
+ }
|
|
|
+ if (user.getPassword() == null || "".equals(user.getPassword()))
|
|
|
+ {
|
|
|
+ throw new ServiceException("密码不能为空!");
|
|
|
+ }
|
|
|
+ //通过账号校验账号是否存在
|
|
|
+ String userName = companyUserMapper.selectCompanyUserByUserName(user.getUserName());
|
|
|
+ if(userName != null){
|
|
|
+ throw new ServiceException(userName + ",账号已存在!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (CompanyUser user : userList)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
|
+ user.setToken("".equals(user.getToken())?null:user.getToken());
|
|
|
+ user.setIdCard("".equals(user.getIdCard())?null:user.getIdCard());
|
|
|
+ user.setCompanyId(companyId);
|
|
|
+ user.setDeptId(deptId);
|
|
|
+ user.setStatus("0");
|
|
|
+ user.setCreateTime(new Date());
|
|
|
+ this.insertUser(user);
|
|
|
+ successNum++;
|
|
|
+ successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ failureNum++;
|
|
|
+ String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
|
|
+ failureMsg.append(msg + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (failureNum > 0)
|
|
|
+ {
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
+ }
|
|
|
+ return successMsg.toString();
|
|
|
+ }
|
|
|
}
|