|
@@ -3,13 +3,11 @@ package com.hz.employmentsite.services.impl.baseSettings;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.hz.employmentsite.filter.exception.BaseException;
|
|
|
-import com.hz.employmentsite.mapper.PcSiteUserMapper;
|
|
|
-import com.hz.employmentsite.mapper.SysRoleMapper;
|
|
|
-import com.hz.employmentsite.mapper.SysUserMapper;
|
|
|
-import com.hz.employmentsite.mapper.SysUserSysRoleMapper;
|
|
|
+import com.hz.employmentsite.mapper.*;
|
|
|
import com.hz.employmentsite.mapper.cquery.UserInfoCQuery;
|
|
|
import com.hz.employmentsite.model.*;
|
|
|
import com.hz.employmentsite.services.service.baseSettings.SiteUserService;
|
|
|
+import com.hz.employmentsite.services.service.system.DictionaryService;
|
|
|
import com.hz.employmentsite.util.StringUtils;
|
|
|
import com.hz.employmentsite.vo.baseSettings.SiteUserVo;
|
|
|
import net.sourceforge.pinyin4j.PinyinHelper;
|
|
@@ -25,6 +23,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service("SiteUserService")
|
|
|
public class SiteUserImpl implements SiteUserService {
|
|
@@ -47,6 +46,12 @@ public class SiteUserImpl implements SiteUserService {
|
|
|
@Autowired
|
|
|
private SysUserSysRoleMapper sysUserSysRoleMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PcSiteMapper siteMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DictionaryService dictionaryService;
|
|
|
+
|
|
|
@Override
|
|
|
public PageInfo<SiteUserVo> getList(int pageIndex, int pageSize, List<String> siteUserIDList, String siteUserName, String siteID, String roleName, String regionCode, String userNo) {
|
|
|
PageHelper.startPage(pageIndex, pageSize);
|
|
@@ -193,7 +198,104 @@ public class SiteUserImpl implements SiteUserService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public String StrToPinYin(String chinese){
|
|
|
+ /**
|
|
|
+ * 数据导入
|
|
|
+ *
|
|
|
+ * @param dataList excel数据
|
|
|
+ * @param loginUserId 当前登录用户ID
|
|
|
+ * @return 导入结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<SiteUserVo> importSiteUser(List<SiteUserVo> dataList, String loginUserId) {
|
|
|
+ if (dataList.size() <= 0)
|
|
|
+ throw new BaseException("", "请添加导入数据!");
|
|
|
+ // 所属驿站
|
|
|
+ List<PcSite> siteList = siteMapper.selectByExample(null);
|
|
|
+ // 已存在的驿站工作人员
|
|
|
+ List<PcSiteUser> pcSiteUsers = pcSiteUserMapper.selectByExample(null);
|
|
|
+ // 用户类型字典数据
|
|
|
+ List<SysDictionaryItem> userTypeList = dictionaryService.getDictionaryItemList("UserType");
|
|
|
+ // 性别字典数据
|
|
|
+ List<SysDictionaryItem> genderList = dictionaryService.getDictionaryItemList("Gender");
|
|
|
+
|
|
|
+ // 最终结果
|
|
|
+ List<SiteUserVo> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ dataList.forEach(item -> {
|
|
|
+ String errorInfo = "";
|
|
|
+
|
|
|
+ // 数据内容为空判断
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.siteUserName)) {
|
|
|
+ errorInfo += "请填写姓名!";
|
|
|
+ }
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.userNo)) {
|
|
|
+ errorInfo += "请填写工号!";
|
|
|
+ } else {
|
|
|
+ String siteUserID = pcSiteUsers.stream().filter(it -> it.getUserNo() != null && it.getUserNo().equals(item.getUserNo().trim())).findFirst().orElse(new PcSiteUser()).getSiteUserID();
|
|
|
+ if (!stringUtils.IsNullOrEmpty(siteUserID)) {
|
|
|
+ errorInfo += "工号重复!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.genderName)) {
|
|
|
+ errorInfo += "请填写性别!";
|
|
|
+ } else {
|
|
|
+ item.gender = genderList.stream().filter(it -> it.getName().equals(item.getGenderName().trim()))
|
|
|
+ .findFirst().orElse(new SysDictionaryItem()).getValue();
|
|
|
+ if (item.gender == null) {
|
|
|
+ errorInfo += "性别不存在!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.mobile)) {
|
|
|
+ errorInfo += "请填写联系电话!";
|
|
|
+ } else {
|
|
|
+ String siteUserID = pcSiteUsers.stream().filter(it -> it.getMobile() != null && it.getMobile().equals(item.getMobile().trim())).findFirst().orElse(new PcSiteUser()).getSiteUserID();
|
|
|
+ if (!stringUtils.IsNullOrEmpty(siteUserID)) {
|
|
|
+ errorInfo += "联系电话重复!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.idCard)) {
|
|
|
+ errorInfo += "请填写身份证号码!";
|
|
|
+ }
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.roleName)) {
|
|
|
+ errorInfo += "请填写用户类型!";
|
|
|
+ } else {
|
|
|
+ item.roleID = userTypeList.stream().filter(it -> it.getName().equals(item.getRoleName().trim()))
|
|
|
+ .findFirst().orElse(new SysDictionaryItem()).getValue();
|
|
|
+ if (item.roleID == null) {
|
|
|
+ errorInfo += "用户类型不存在!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.siteName)) {
|
|
|
+ errorInfo += "请填写所属驿站!";
|
|
|
+ } else {
|
|
|
+ item.siteID = siteList.stream().filter(it -> it.getSiteName().equals(item.getSiteName().trim()))
|
|
|
+ .findFirst().orElse(new PcSite()).getSiteID();
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.siteID)) {
|
|
|
+ errorInfo += "驿站不存在!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查结果填充
|
|
|
+ if (stringUtils.IsNullOrEmpty(errorInfo)) {
|
|
|
+ item.setSiteUserID(UUID.randomUUID().toString());
|
|
|
+ resultList.add(item);
|
|
|
+ } else {
|
|
|
+ item.setErrorMessage(errorInfo);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 返回结果
|
|
|
+ if (dataList.stream().filter(it -> !stringUtils.IsNullOrEmpty(it.errorMessage)).collect(Collectors.toList()).size() > 0)
|
|
|
+ return dataList;
|
|
|
+
|
|
|
+ // 保存到数据
|
|
|
+ resultList.forEach(item -> {
|
|
|
+ save(item, loginUserId);
|
|
|
+ });
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String StrToPinYin(String chinese) {
|
|
|
String pinyinStr = "";
|
|
|
char[] newChar = chinese.toCharArray();
|
|
|
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
|