package cn.huge.module.ctuser.service;
|
|
import cn.huge.base.common.constant.GzRegionBaseEnum;
|
import cn.huge.base.common.dto.SelectTermDTO;
|
import cn.huge.base.common.exception.ServiceException;
|
import cn.huge.base.common.utils.DateUtils;
|
import cn.huge.base.common.utils.IdUtils;
|
import cn.huge.base.common.utils.ObjectUtils;
|
import cn.huge.base.common.utils.SelectTermUtils;
|
import cn.huge.module.client.api.impl.UtilsClientImpl;
|
import cn.huge.module.constant.BaseConsts;
|
import cn.huge.module.ctuser.dao.mapper.CtUnitMapper;
|
import cn.huge.module.ctuser.domain.po.*;
|
import cn.huge.module.ctuser.dto.CtUnitWeChatCountDTO;
|
import cn.huge.module.cust.constant.RoleBaseEnum;
|
import cn.huge.module.cust.constant.UserBaseConsts;
|
import cn.huge.module.cust.dto.CtUnitDTO;
|
import cn.huge.module.cust.dto.CtUserDTO;
|
import cn.huge.module.kind.domain.po.SyRegion;
|
import cn.huge.module.kind.service.SyRegionService;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.lang3.StringUtils;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageRequest;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.util.DigestUtils;
|
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
import java.io.InputStream;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* @author liyj
|
* @version 1.0.0
|
* @title: Excel表格操作业务逻辑处理
|
* @Description Excel表格操作业务逻辑处理
|
* @company hugeinfo
|
* @Time 2024-08-19 20:04:19
|
*/
|
@Slf4j
|
@Service
|
public class ExcelOperCtunitService {
|
|
@Autowired
|
private UtilsClientImpl utilsClient;
|
@Autowired
|
private CtUnitService ctUnitService;
|
@Autowired
|
private CtDeptService ctDeptService;
|
@Autowired
|
private CtUserService ctUserService;
|
@Autowired
|
private CtAccountService ctAccountService;
|
@Autowired
|
private CtUseroleService ctUseroleService;
|
@Autowired
|
private SyRegionService syRegionService;
|
|
/**
|
* 获取单元格数据
|
*
|
* @param sheet 表示Excel工作表对象,从中获取指定单元格的数据
|
* @param r 表示单元格所在的行索引,从0开始计数
|
* @param c 表示单元格所在的列索引,从0开始计数
|
* @return 返回指定单元格中的数据,如果单元格为空或者工作表为空则返回null
|
*/
|
public String transform(Sheet sheet, int r, int c) {
|
// 检查工作表是否为空
|
if (ObjectUtils.isNotEmpty(sheet)) {
|
// 获取指定行和列的单元格
|
Cell cell = sheet.getRow(r).getCell(c);
|
// 检查单元格是否为空
|
if (ObjectUtils.isNotEmpty(cell)) {
|
// 注意:setCellType方法已弃用,可考虑使用其他替代方法
|
cell.setCellType(CellType.STRING);
|
// 获取单元格中的字符串值
|
String val = cell.getStringCellValue();
|
// 去除字符串中的空格并返回
|
return val.replace(" ", "");
|
} else {
|
// 单元格为空,返回null
|
return null;
|
}
|
} else {
|
// 工作表为空,返回null
|
return null;
|
}
|
}
|
|
/**
|
* 通过Excel创建单位和账号
|
*
|
* @param request
|
*/
|
public void inputByExcel241124(MultipartHttpServletRequest request) {
|
try {
|
Iterator<String> itr = request.getFileNames();
|
while (itr.hasNext()) {
|
MultipartFile file = request.getFile(itr.next());
|
String fileSuffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
if (".xls".equals(fileSuffix) || ".xlsx".equals(fileSuffix) || "xls".equals(fileSuffix) || "xlsx".equals(fileSuffix)) {
|
InputStream inputStream = file.getInputStream();
|
Workbook wb = null;
|
//当excel是2003时
|
if (".xls".equals(fileSuffix)) {
|
wb = new HSSFWorkbook(inputStream);
|
} else {
|
wb = new XSSFWorkbook(inputStream);
|
}
|
//得到第一个shell
|
Sheet sheet = wb.getSheetAt(0);
|
//得到Excel的行数
|
int totalRows = sheet.getPhysicalNumberOfRows();
|
//人员信息
|
Date nowDate = DateUtils.getNowDate();
|
for (int r = 1; r < totalRows; r++) {
|
try {
|
// 获取数据
|
String area = this.transform(sheet, r, 0);
|
String areaName = this.transform(sheet, r, 1);
|
String road = this.transform(sheet, r, 2);
|
String roadName = this.transform(sheet, r, 3);
|
String village = this.transform(sheet, r, 4);
|
String villageName = this.transform(sheet, r, 5);
|
String id = this.transform(sheet, r, 6);
|
String unitName = this.transform(sheet, r, 7);
|
String parentId = this.transform(sheet, r, 8);
|
String level = this.transform(sheet, r, 9);
|
String unitGrade = this.transform(sheet, r, 10);
|
String unitType = this.transform(sheet, r, 11);
|
String trueName = this.transform(sheet, r, 12);
|
String mobile = this.transform(sheet, r, 13);
|
String idcard = this.transform(sheet, r, 14);
|
String cipher = this.transform(sheet, r, 15);
|
if (StringUtils.isBlank(cipher)) {
|
// 默认密码
|
cipher = UserBaseConsts.MR_CIPHER_GZ;
|
}
|
// 新增单位
|
CtUnit ctUnit = new CtUnit();
|
ctUnit.setId(id);
|
ctUnit.setLevel(Integer.parseInt(level));
|
ctUnit.setParentId(parentId);
|
ctUnit.setUnitGrade(Integer.parseInt(unitGrade));
|
ctUnit.setUnitFun(UserBaseConsts.UNIT_FUN_1);
|
ctUnit.setUnitType(Integer.parseInt(unitType));
|
ctUnit.setCourtStatus(UserBaseConsts.COURT_STATUS_0);
|
ctUnit.setUnitName(unitName);
|
if (UserBaseConsts.UNIT_GRADE_2 == ctUnit.getUnitGrade()) {
|
ctUnit.setUnitDes(unitName);
|
} else {
|
ctUnit.setUnitDes(roadName + "-" + unitName);
|
}
|
ctUnit.setJoinWay(UserBaseConsts.JOIN_WAY_1);
|
ctUnit.setProv(GzRegionBaseEnum.PROV_1.getIndex());
|
ctUnit.setProvName(GzRegionBaseEnum.PROV_1.getDes());
|
ctUnit.setCity(GzRegionBaseEnum.CITY_1.getIndex());
|
ctUnit.setCityName(GzRegionBaseEnum.CITY_1.getDes());
|
ctUnit.setArea(area);
|
ctUnit.setAreaName(areaName);
|
ctUnit.setRoad(road);
|
ctUnit.setRoadName(roadName);
|
ctUnit.setVillage(village);
|
ctUnit.setVillageName(villageName);
|
ctUnit.setAddr(ctUnit.getUnitDes());
|
ctUnit.setFindStatus(UserBaseConsts.FIND_STATUS_0);
|
ctUnit.setDispStatus(UserBaseConsts.DISP_STATUS_0);
|
ctUnit.setDeleteStatus(BaseConsts.DELETE_STATUS_0);
|
ctUnit.setCreateTime(nowDate);
|
ctUnit.setUpdateTime(nowDate);
|
try {
|
ctUnitService.save(ctUnit);
|
} catch (Exception e) {
|
log.error("已存在");
|
}
|
// 新增人员
|
CtUser ctUser = new CtUser();
|
ctUser.setId(utilsClient.getNewTimeId());
|
ctUser.setTrueName(trueName);
|
ctUser.setAcc(mobile);
|
if (StringUtils.isNotBlank(idcard)) {
|
ctUser.setMobile(mobile);
|
}
|
ctUser.setIdcard(idcard);
|
ctUser.setUnitId(ctUnit.getId());
|
ctUser.setUnitName(ctUnit.getUnitName());
|
ctUser.setCreateTime(nowDate);
|
ctUser.setJoinWay(UserBaseConsts.JOIN_WAY_1);
|
ctUser.setRealStatus(UserBaseConsts.REAL_STATUS_0);
|
ctUser.setStatus(UserBaseConsts.USER_STATUS_1);
|
ctUser.setFindStatus(UserBaseConsts.FIND_STATUS_0);
|
ctUser.setDispStatus(UserBaseConsts.DISP_STATUS_0);
|
ctUser.setDeleteStatus(BaseConsts.DELETE_STATUS_0);
|
ctUser.setCustId("-1");
|
ctUser.setCreateTime(nowDate);
|
ctUser.setUpdateTime(nowDate);
|
ctUserService.save(ctUser);
|
// 新增人员账号
|
CtAccount ctAccount = new CtAccount();
|
ctAccount.setId(utilsClient.getNewTimeId());
|
ctAccount.setCustId(ctUser.getCustId());
|
ctAccount.setUserId(ctUser.getId());
|
ctAccount.setAccType(UserBaseConsts.ACC_TYPE_1);
|
ctAccount.setAcc(ctUser.getAcc());
|
ctAccount.setCipher(DigestUtils.md5DigestAsHex(cipher.getBytes()));
|
ctAccount.setCipherOpen(cipher);
|
ctAccount.setDeleteStatus(BaseConsts.DELETE_STATUS_0);
|
ctAccount.setCustId("-1");
|
ctAccount.setCreateTime(nowDate);
|
ctAccount.setCipherTime(nowDate);
|
ctAccount.setUpdateTime(nowDate);
|
ctAccountService.save(ctAccount);
|
// 新增人员角色关系-单位管理员
|
CtUserole ctUserole1 = new CtUserole();
|
ctUserole1.setId(utilsClient.getNewTimeId());
|
ctUserole1.setUserId(ctUser.getId());
|
ctUserole1.setRoleId(RoleBaseEnum.ROLE_3.getIndex());
|
ctUserole1.setRoleCode(RoleBaseEnum.ROLE_3.getIndex());
|
ctUserole1.setRoleName(RoleBaseEnum.ROLE_3.getDes());
|
ctUserole1.setCustId("-1");
|
ctUserole1.setCreateTime(nowDate);
|
ctUserole1.setUpdateTime(nowDate);
|
ctUseroleService.save(ctUserole1);
|
// 新增人员角色关系-纠纷化解人员
|
CtUserole ctUserole2 = new CtUserole();
|
ctUserole2.setId(utilsClient.getNewTimeId());
|
ctUserole2.setUserId(ctUser.getId());
|
ctUserole2.setRoleId(RoleBaseEnum.ROLE_4.getIndex());
|
ctUserole2.setRoleCode(RoleBaseEnum.ROLE_4.getIndex());
|
ctUserole2.setRoleName(RoleBaseEnum.ROLE_4.getDes());
|
ctUserole2.setCustId("-1");
|
ctUserole2.setCreateTime(nowDate);
|
ctUserole2.setUpdateTime(nowDate);
|
ctUseroleService.save(ctUserole2);
|
} catch (Exception e) {
|
log.error(e.getMessage(), e);
|
continue;
|
}
|
}
|
}
|
}
|
} catch (Exception e) {
|
log.error("[ExcelOperCtunitService.inputByExcel241124]调用失败,异常信息:" + e, e);
|
throw new ServiceException("ExcelOperCtunitService.inputByExcel241124", e);
|
}
|
}
|
|
/**
|
* 通过Excel创建单位和账号
|
*
|
* @param request
|
*/
|
public void inputByExcel250304(MultipartHttpServletRequest request) {
|
String errorInfo = "";
|
try {
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
String custId = sdf.format(new Date());
|
Iterator<String> itr = request.getFileNames();
|
while (itr.hasNext()) {
|
MultipartFile file = request.getFile(itr.next());
|
String fileSuffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
if (".xls".equals(fileSuffix) || ".xlsx".equals(fileSuffix) || "xls".equals(fileSuffix) || "xlsx".equals(fileSuffix)) {
|
InputStream inputStream = file.getInputStream();
|
Workbook wb = null;
|
//当excel是2003时
|
if (".xls".equals(fileSuffix)) {
|
wb = new HSSFWorkbook(inputStream);
|
} else {
|
wb = new XSSFWorkbook(inputStream);
|
}
|
//得到第一个shell
|
Sheet sheet = wb.getSheetAt(0);
|
//得到Excel的行数
|
int totalRows = sheet.getPhysicalNumberOfRows();
|
//人员信息
|
Date nowDate = DateUtils.getNowDate();
|
// 调解组织所属区名称
|
String areaName = this.transform(sheet, 0, 0);
|
// 调解组织所属区
|
String area = GzRegionBaseEnum.getIndex(areaName);
|
for (int r = 2; r < totalRows; r++) {
|
try {
|
// 调解组织所属街道名称
|
String roadName = this.transform(sheet, r, 0);
|
// 调解组织名称
|
String unitName = this.transform(sheet, r, 1);
|
// 调解组织类型
|
String unitGradeStr = this.transform(sheet, r, 2);
|
int unitGrade = Integer.parseInt(unitGradeStr);
|
// 调解组织类型
|
String unitTypeStr = this.transform(sheet, r, 3);
|
int unitType = Integer.parseInt(unitTypeStr);
|
// 人员姓名
|
String trueName = this.transform(sheet, r, 4);
|
// 人员联系方式
|
String mobile = this.transform(sheet, r, 5);
|
// 人员身份证号
|
String idcard = this.transform(sheet, r, 6);
|
// 调解组织地址
|
String addr = this.transform(sheet, r, 7);
|
// 默认密码
|
String cipher = "Gzs@2025";
|
if (GzRegionBaseEnum.AREA_1.getIndex().equals(area)) {
|
cipher = "Gzth@2025";
|
} else if(GzRegionBaseEnum.AREA_2.getIndex().equals(area)) {
|
cipher = "Gzhz@2025";
|
}else if(GzRegionBaseEnum.AREA_3.getIndex().equals(area)) {
|
cipher = "Gzlw@2025";
|
}else if(GzRegionBaseEnum.AREA_4.getIndex().equals(area)) {
|
cipher = "Gzyx@2025";
|
}else if(GzRegionBaseEnum.AREA_5.getIndex().equals(area)) {
|
cipher = "Gzpy@2025";
|
}else if(GzRegionBaseEnum.AREA_6.getIndex().equals(area)) {
|
cipher = "Gzhd@2025";
|
}else if(GzRegionBaseEnum.AREA_7.getIndex().equals(area)) {
|
cipher = "Gzby@2025";
|
}else if(GzRegionBaseEnum.AREA_8.getIndex().equals(area)) {
|
cipher = "Gzns@2025";
|
}else if(GzRegionBaseEnum.AREA_9.getIndex().equals(area)) {
|
cipher = "Gzhp@2025";
|
}else if(GzRegionBaseEnum.AREA_10.getIndex().equals(area)) {
|
cipher = "Gzzc@2025";
|
}else if(GzRegionBaseEnum.AREA_11.getIndex().equals(area)) {
|
cipher = "Gzch@2025";
|
}
|
|
QueryWrapper<SyRegion> syRegionQueryWrapper = new QueryWrapper<>();
|
syRegionQueryWrapper.eq("parent_id", area).like("name", roadName);
|
SyRegion roadSyRegion = syRegionService.getOne(syRegionQueryWrapper);
|
// 查询是否存在该单位
|
QueryWrapper<CtUnit> ctUnitQueryWrapper = new QueryWrapper<>();
|
ctUnitQueryWrapper.eq("area", area)
|
.eq("unit_grade", unitGrade)
|
.eq("unit_type", unitType)
|
.eq("unit_name", unitName);
|
if (UserBaseConsts.UNIT_GRADE_3 == unitGrade || UserBaseConsts.UNIT_GRADE_4 == unitGrade) {
|
ctUnitQueryWrapper.eq("road", roadSyRegion.getId());
|
}
|
List<CtUnit> ctUnitList = ctUnitService.list(ctUnitQueryWrapper);
|
CtUnit ctUnit = null;
|
if (CollectionUtils.isEmpty(ctUnitList)) {
|
// 新增单位
|
ctUnit = new CtUnit();
|
// 主键
|
ctUnit.setId(utilsClient.getNewTimeId());
|
// 层级
|
ctUnit.setLevel(unitGrade);
|
// 父级组织 todo
|
if (UserBaseConsts.UNIT_GRADE_2 == unitGrade) {
|
if (UserBaseConsts.UNIT_TYPE_101 == unitType){
|
// 综治中心,父级是广州市综治中心
|
ctUnitQueryWrapper.clear();
|
ctUnitQueryWrapper.eq("city", GzRegionBaseEnum.CITY_1.getIndex())
|
.eq("unit_type", UserBaseConsts.UNIT_TYPE_101)
|
.eq("unit_grade", UserBaseConsts.UNIT_GRADE_1);
|
List<CtUnit> zzzxList = ctUnitService.list(ctUnitQueryWrapper);
|
ctUnit.setParentId(zzzxList.get(0).getId());
|
}else {
|
// 其他,父级是区综治中心
|
ctUnitQueryWrapper.clear();
|
ctUnitQueryWrapper.eq("area", area)
|
.eq("unit_type", UserBaseConsts.UNIT_TYPE_101)
|
.eq("unit_grade", UserBaseConsts.UNIT_GRADE_2);
|
List<CtUnit> zzzxList = ctUnitService.list(ctUnitQueryWrapper);
|
ctUnit.setParentId(zzzxList.get(0).getId());
|
}
|
}else if (UserBaseConsts.UNIT_GRADE_3 == unitGrade) {
|
if (UserBaseConsts.UNIT_TYPE_101 == unitType){
|
// 综治中心,父级是区综治中心
|
ctUnitQueryWrapper.clear();
|
ctUnitQueryWrapper.eq("area", area)
|
.eq("unit_type", UserBaseConsts.UNIT_TYPE_101)
|
.eq("unit_grade", UserBaseConsts.UNIT_GRADE_2);
|
List<CtUnit> zzzxList = ctUnitService.list(ctUnitQueryWrapper);
|
ctUnit.setParentId(zzzxList.get(0).getId());
|
}else {
|
// 其他,父级是街道综治中心
|
ctUnitQueryWrapper.clear();
|
ctUnitQueryWrapper.eq("area", area)
|
.eq("unit_type", UserBaseConsts.UNIT_TYPE_101)
|
.eq("unit_grade", UserBaseConsts.UNIT_GRADE_3)
|
.eq("road", roadSyRegion.getId());
|
List<CtUnit> zzzxList = ctUnitService.list(ctUnitQueryWrapper);
|
ctUnit.setParentId(zzzxList.get(0).getId());
|
}
|
}else if (UserBaseConsts.UNIT_GRADE_4 == unitGrade){
|
ctUnitQueryWrapper.clear();
|
ctUnitQueryWrapper.eq("area", area)
|
.eq("unit_type", UserBaseConsts.UNIT_TYPE_101)
|
.eq("unit_grade", UserBaseConsts.UNIT_GRADE_3)
|
.eq("road", roadSyRegion.getId());
|
List<CtUnit> zzzxList = ctUnitService.list(ctUnitQueryWrapper);
|
ctUnit.setParentId(zzzxList.get(0).getId());
|
|
}
|
// 组织级别
|
ctUnit.setUnitGrade(unitGrade);
|
// 组织职能
|
ctUnit.setUnitFun(UserBaseConsts.UNIT_FUN_1);
|
// 组织职能
|
ctUnit.setUnitType(unitType);
|
// 是否是法院
|
if (UserBaseConsts.UNIT_TYPE_104 == unitType) {
|
ctUnit.setCourtStatus(UserBaseConsts.COURT_STATUS_1);
|
}else {
|
ctUnit.setCourtStatus(UserBaseConsts.COURT_STATUS_0);
|
}
|
// 组织名称
|
ctUnit.setUnitName(unitName);
|
// 组织描述
|
if (UserBaseConsts.UNIT_GRADE_3 == unitGrade && UserBaseConsts.UNIT_TYPE_102 == unitType) {
|
ctUnit.setUnitName(roadName+unitName);
|
ctUnit.setUnitDes(roadName + "-" + unitName);
|
} else if (UserBaseConsts.UNIT_GRADE_3 == unitGrade && UserBaseConsts.UNIT_TYPE_106 == unitType) {
|
ctUnit.setUnitName(roadName+unitName);
|
ctUnit.setUnitDes(roadName + "-" + unitName);
|
} else if (UserBaseConsts.UNIT_GRADE_2 == unitGrade && UserBaseConsts.UNIT_TYPE_102 == unitType) {
|
ctUnit.setUnitName(roadName+unitName);
|
ctUnit.setUnitDes(roadName + "-" + unitName);
|
} else if (UserBaseConsts.UNIT_GRADE_2 == unitGrade && UserBaseConsts.UNIT_TYPE_104 == unitType) {
|
ctUnit.setUnitName(roadName+unitName);
|
ctUnit.setUnitDes(roadName + "-" + unitName);
|
} else if (UserBaseConsts.UNIT_GRADE_2 == unitGrade && UserBaseConsts.UNIT_TYPE_105 == unitType) {
|
ctUnit.setUnitName(roadName+unitName);
|
ctUnit.setUnitDes(roadName + "-" + unitName);
|
} else {
|
ctUnit.setUnitDes(unitName);
|
}
|
ctUnit.setJoinWay(UserBaseConsts.JOIN_WAY_1);
|
ctUnit.setProv(GzRegionBaseEnum.PROV_1.getIndex());
|
ctUnit.setProvName(GzRegionBaseEnum.PROV_1.getDes());
|
ctUnit.setCity(GzRegionBaseEnum.CITY_1.getIndex());
|
ctUnit.setCityName(GzRegionBaseEnum.CITY_1.getDes());
|
ctUnit.setArea(area);
|
ctUnit.setAreaName(areaName);
|
// 查询街道编码
|
if (UserBaseConsts.UNIT_GRADE_3 == unitGrade || UserBaseConsts.UNIT_GRADE_4 == unitGrade) {
|
ctUnit.setRoad(roadSyRegion.getId());
|
ctUnit.setRoadName(roadName);
|
// 村级编码
|
if (UserBaseConsts.UNIT_GRADE_4 == unitGrade) {
|
syRegionQueryWrapper.clear();
|
syRegionQueryWrapper.eq("parent_id", ctUnit.getRoad()).like("name", unitName.replace("居委会", ""));
|
SyRegion villageSyRegion = syRegionService.getOne(syRegionQueryWrapper);
|
if (ObjectUtils.isNotEmpty(villageSyRegion)) {
|
ctUnit.setVillage(villageSyRegion.getId());
|
ctUnit.setVillageName(villageSyRegion.getName());
|
}
|
}
|
}
|
ctUnit.setAddr(addr);
|
ctUnit.setFindStatus(UserBaseConsts.FIND_STATUS_0);
|
ctUnit.setDispStatus(UserBaseConsts.DISP_STATUS_0);
|
ctUnit.setDeleteStatus(BaseConsts.DELETE_STATUS_0);
|
ctUnit.setCustId(custId);
|
ctUnit.setCreateTime(nowDate);
|
ctUnit.setUpdateTime(nowDate);
|
try {
|
ctUnitService.save(ctUnit);
|
} catch (Exception e) {
|
errorInfo = errorInfo+unitName+";";
|
log.error("liyj添加单位报错", e);
|
}
|
}else {
|
ctUnit = ctUnitList.get(0);
|
}
|
// 新增人员
|
if (StringUtils.isEmpty(trueName)) {
|
QueryWrapper<CtUser> ctUserQueryWrapper = new QueryWrapper<>();
|
ctUserQueryWrapper.eq("true_name", trueName)
|
.eq("idcard", idcard);
|
List<CtUser> ctUserList = ctUserService.list(ctUserQueryWrapper);
|
if (CollectionUtils.isEmpty(ctUserList)) {
|
CtUser ctUser = new CtUser();
|
ctUser.setId(utilsClient.getNewTimeId());
|
ctUser.setTrueName(trueName);
|
ctUser.setAcc(mobile);
|
if (StringUtils.isNotBlank(idcard)) {
|
ctUser.setMobile(mobile);
|
}
|
ctUser.setIdcard(idcard);
|
ctUser.setUnitId(ctUnit.getId());
|
ctUser.setUnitName(ctUnit.getUnitName());
|
ctUser.setCreateTime(nowDate);
|
ctUser.setJoinWay(UserBaseConsts.JOIN_WAY_1);
|
ctUser.setRealStatus(UserBaseConsts.REAL_STATUS_0);
|
ctUser.setStatus(UserBaseConsts.USER_STATUS_1);
|
ctUser.setFindStatus(UserBaseConsts.FIND_STATUS_0);
|
ctUser.setDispStatus(UserBaseConsts.DISP_STATUS_0);
|
ctUser.setDeleteStatus(BaseConsts.DELETE_STATUS_0);
|
ctUser.setCustId(custId);
|
ctUser.setCreateTime(nowDate);
|
ctUser.setUpdateTime(nowDate);
|
ctUserService.save(ctUser);
|
// 新增人员账号
|
CtAccount ctAccount = new CtAccount();
|
ctAccount.setId(utilsClient.getNewTimeId());
|
ctAccount.setCustId(ctUser.getCustId());
|
ctAccount.setUserId(ctUser.getId());
|
ctAccount.setAccType(UserBaseConsts.ACC_TYPE_1);
|
ctAccount.setAcc(ctUser.getAcc());
|
ctAccount.setCipher(DigestUtils.md5DigestAsHex(cipher.getBytes()));
|
ctAccount.setCipherOpen(cipher);
|
ctAccount.setDeleteStatus(BaseConsts.DELETE_STATUS_0);
|
ctAccount.setCustId(custId);
|
ctAccount.setCreateTime(nowDate);
|
ctAccount.setCipherTime(nowDate);
|
ctAccount.setUpdateTime(nowDate);
|
ctAccountService.save(ctAccount);
|
// 新增人员角色关系-单位管理员
|
CtUserole ctUserole1 = new CtUserole();
|
ctUserole1.setId(utilsClient.getNewTimeId());
|
ctUserole1.setUserId(ctUser.getId());
|
ctUserole1.setRoleId(RoleBaseEnum.ROLE_3.getIndex());
|
ctUserole1.setRoleCode(RoleBaseEnum.ROLE_3.getIndex());
|
ctUserole1.setRoleName(RoleBaseEnum.ROLE_3.getDes());
|
ctUserole1.setCustId(custId);
|
ctUserole1.setCreateTime(nowDate);
|
ctUserole1.setUpdateTime(nowDate);
|
ctUseroleService.save(ctUserole1);
|
// 新增人员角色关系-纠纷化解人员
|
CtUserole ctUserole2 = new CtUserole();
|
ctUserole2.setId(utilsClient.getNewTimeId());
|
ctUserole2.setUserId(ctUser.getId());
|
ctUserole2.setRoleId(RoleBaseEnum.ROLE_4.getIndex());
|
ctUserole2.setRoleCode(RoleBaseEnum.ROLE_4.getIndex());
|
ctUserole2.setRoleName(RoleBaseEnum.ROLE_4.getDes());
|
ctUserole2.setCustId(custId);
|
ctUserole2.setCreateTime(nowDate);
|
ctUserole2.setUpdateTime(nowDate);
|
ctUseroleService.save(ctUserole2);
|
}
|
}
|
} catch (Exception e) {
|
errorInfo = errorInfo+r+"行,";
|
log.error("liyj解析报错1", e);
|
continue;
|
}
|
}
|
}
|
}
|
} catch (Exception e) {
|
log.error("liyj解析报错2", e);
|
throw new ServiceException("ExcelOperCtunitService.inputByExcel250304", e);
|
}finally {
|
log.info("报错数据:"+errorInfo);
|
}
|
}
|
|
}
|