|
@@ -2,20 +2,22 @@ package com.ozs.base.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.ozs.base.domain.BaseExpert;
|
|
|
+import com.ozs.base.domain.BaseProfessional;
|
|
|
import com.ozs.base.domain.BaseUnitInformation;
|
|
|
import com.ozs.base.domain.vo.BaseExpertVo;
|
|
|
import com.ozs.base.mapper.BaseExpertMapper;
|
|
|
import com.ozs.base.service.BaseExpertService;
|
|
|
+import com.ozs.base.service.BaseProfessionalService;
|
|
|
import com.ozs.common.core.domain.AjaxResult;
|
|
|
import com.ozs.common.core.domain.entity.SysUser;
|
|
|
import com.ozs.common.core.domain.model.LoginUser;
|
|
|
import com.ozs.common.enums.*;
|
|
|
+import com.ozs.common.exception.ServiceException;
|
|
|
import com.ozs.common.utils.PageUtils;
|
|
|
import com.ozs.common.utils.SecurityUtils;
|
|
|
import com.ozs.common.utils.StringUtils;
|
|
@@ -26,12 +28,15 @@ import com.ozs.pm.doman.vo.responseVo.PmDemandResVo;
|
|
|
import com.ozs.pm.mapper.PmDemandExpertRefMapper;
|
|
|
import com.ozs.pm.service.IPmDemandService;
|
|
|
import com.ozs.pm.service.PmDemandExpertRefService;
|
|
|
+import com.ozs.system.domain.vo.SysRegionVO;
|
|
|
import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
|
|
|
import com.ozs.system.service.ISysDeptService;
|
|
|
import com.ozs.system.service.ISysDictDataService;
|
|
|
import com.ozs.system.service.ISysDictTypeService;
|
|
|
+import com.ozs.system.service.SysRegionService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.*;
|
|
@@ -54,6 +59,10 @@ public class BaseExpertServiceImpl extends ServiceImpl<BaseExpertMapper, BaseExp
|
|
|
private ISysDictDataService dictDataService;
|
|
|
@Autowired
|
|
|
private ISysDictTypeService dictTypeService;
|
|
|
+ @Autowired
|
|
|
+ private BaseProfessionalService baseProfessionalService;
|
|
|
+ @Autowired
|
|
|
+ private SysRegionService sysRegionService;
|
|
|
|
|
|
@Override
|
|
|
public int insertExpert(BaseExpertVo baseExpertVo) {
|
|
@@ -171,6 +180,159 @@ public class BaseExpertServiceImpl extends ServiceImpl<BaseExpertMapper, BaseExp
|
|
|
return baseUnitInformationList;
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public String importBaseExpert(List<BaseExpertVo> expertVos, LoginUser loginUser) {
|
|
|
+ //获取字典数据
|
|
|
+ HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAbouteExpertEnums();
|
|
|
+ //专家类型
|
|
|
+ HashMap<String, String> expertTypeMap = planEnums.get("expertTypes");
|
|
|
+ //职称
|
|
|
+ HashMap<String, String> professionalTitleMap = planEnums.get("professionalTitles");
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(expertVos) || expertVos.size() < 1) {
|
|
|
+ throw new ServiceException("导入专家信息不能为空!");
|
|
|
+ }
|
|
|
+ //转实体类
|
|
|
+ List<BaseExpert> experts = new ArrayList<>();
|
|
|
+ for (BaseExpertVo expertVo : expertVos) {
|
|
|
+ BaseExpert expert = new BaseExpert();
|
|
|
+ BeanUtils.copyProperties(expertVo, expert);
|
|
|
+ expert.setMajorType(expertVo.getMajorTypeName());
|
|
|
+ experts.add(expert);
|
|
|
+ }
|
|
|
+ int successNum = 0;
|
|
|
+ int failureNum = 0;
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+ ////deptService
|
|
|
+ for (BaseExpert expert : experts) {
|
|
|
+ try {
|
|
|
+ //专家类型,专家状态
|
|
|
+ if (!StringUtils.isEmpty(expertTypeMap.get(expert.getExpertType()))) {
|
|
|
+ expert.setExpertType(expertTypeMap.get(expert.getExpertType()));
|
|
|
+ expert.setStatus("0");
|
|
|
+ } else {
|
|
|
+ ++failureNum;
|
|
|
+ failureMsg.append(failureNum + "、专家类型“" + expert.getExpertType() + "”不存在");
|
|
|
+ }
|
|
|
+ //专业类型
|
|
|
+ LambdaQueryWrapper<BaseProfessional> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(BaseProfessional::getProfessionalName, expert.getMajorType());
|
|
|
+ List<BaseProfessional> list = baseProfessionalService.list(wrapper);
|
|
|
+ //专家信息中存的是专业的code
|
|
|
+ if (!StringUtils.isEmpty(list)) {
|
|
|
+ expert.setMajorType(list.get(0).getProfessionalCode());
|
|
|
+ } else {
|
|
|
+ ++failureNum;
|
|
|
+ failureMsg.append(failureNum + "、专业类型“" + expert.getExpertType() + "”不存在");
|
|
|
+ }
|
|
|
+ //职称
|
|
|
+ if (!StringUtils.isEmpty(professionalTitleMap.get(expert.getProfessionalTitle()))) {
|
|
|
+ expert.setProfessionalTitle(professionalTitleMap.get(expert.getProfessionalTitle()));
|
|
|
+ } else {
|
|
|
+ ++failureNum;
|
|
|
+ failureMsg.append(failureNum + "、职称“" + expert.getProfessionalTitle() + "”不存在");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotNull(expert.getUnitInformation())) {
|
|
|
+ List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(expert.getUnitInformation());
|
|
|
+ if (baseUnitInformationList.size() <= 0) {
|
|
|
+ BaseUnitInformation baseUnitInformation = new BaseUnitInformation();
|
|
|
+ baseUnitInformation.setUnitName(expert.getUnitInformation());
|
|
|
+ baseUnitInformation.setCreated(loginUser.getUserId().toString());
|
|
|
+ baseUnitInformation.setCreateTime(new Date());
|
|
|
+ Integer i = baseExpertMapper.insertBaseUnitInformation(baseUnitInformation);
|
|
|
+ expert.setUnitInformation(i + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //地区
|
|
|
+ if (StringUtils.isEmpty(expert.getLocalArea()) || expert.getLocalArea().split("/").length < 2) {
|
|
|
+ ++failureNum;
|
|
|
+ failureMsg.append(failureNum + "、地区“" + expert.getLocalArea() + "”不存在");
|
|
|
+ } else {
|
|
|
+ //大部分地区是三级
|
|
|
+ String[] localAreas = expert.getLocalArea().split("/");
|
|
|
+ if (localAreas.length == 3) {
|
|
|
+ List<SysRegionVO> sysRegionVO = sysRegionService.selectInfoByName(localAreas[0]);
|
|
|
+ List<SysRegionVO> sysRegionVO1 = sysRegionService.selectInfoByName(localAreas[1]);
|
|
|
+ List<SysRegionVO> sysRegionVO2 = sysRegionService.selectInfoByName(localAreas[2]);
|
|
|
+ if (ObjectUtils.isEmpty(sysRegionVO2) || ObjectUtils.isEmpty(sysRegionVO1) || ObjectUtils.isEmpty(sysRegionVO)) {
|
|
|
+ ++failureNum;
|
|
|
+ failureMsg.append(failureNum + "、地区“" + expert.getLocalArea() + "”信息有误");
|
|
|
+ } else {
|
|
|
+ //是否成立上下级关系
|
|
|
+ boolean isLea = false;
|
|
|
+ for (SysRegionVO vo : sysRegionVO2) {
|
|
|
+ for (SysRegionVO regionVO : sysRegionVO1) {
|
|
|
+ if (vo.getPid().equals(regionVO.getId())) {
|
|
|
+ for (SysRegionVO sysRegionVO3 : sysRegionVO) {
|
|
|
+ if (regionVO.getPid().equals(sysRegionVO3.getId())) {
|
|
|
+ //保存行政编码
|
|
|
+ isLea = true;
|
|
|
+ expert.setLocalArea(vo.getCode());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isLea == false) {
|
|
|
+ ++failureNum;
|
|
|
+ failureMsg.append(failureNum + "、地区“" + expert.getLocalArea() + "”非上下级关系");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //香港等少数地区是二级
|
|
|
+ } else if (localAreas.length == 2) {
|
|
|
+ List<SysRegionVO> sysRegionVO = sysRegionService.selectInfoByName(localAreas[0]);
|
|
|
+ List<SysRegionVO> sysRegionVO1 = sysRegionService.selectInfoByName(localAreas[1]);
|
|
|
+ if (ObjectUtils.isEmpty(sysRegionVO1) || ObjectUtils.isEmpty(sysRegionVO)) {
|
|
|
+ ++failureNum;
|
|
|
+ failureMsg.append(failureNum + "、地区“" + expert.getLocalArea() + "”信息有误");
|
|
|
+ } else {
|
|
|
+ //是否成立上下级关系
|
|
|
+ boolean isLea = false;
|
|
|
+ for (SysRegionVO regionVO : sysRegionVO) {
|
|
|
+ for (SysRegionVO vo : sysRegionVO1) {
|
|
|
+ if (vo.getPid().equals(regionVO.getId())) {
|
|
|
+ //保存行政编码
|
|
|
+ isLea = true;
|
|
|
+ expert.setLocalArea(vo.getCode());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isLea == false) {
|
|
|
+ ++failureNum;
|
|
|
+ failureMsg.append(failureNum + "、地区“" + expert.getLocalArea() + "”非上下级关系");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ expert.setCreated(String.valueOf(loginUser.getUserId()));
|
|
|
+ expert.setCreateTime(new Date());
|
|
|
+ expert.setUpdated(String.valueOf(loginUser.getUserId()));
|
|
|
+ expert.setUpdateTime(new Date());
|
|
|
+ baseExpertMapper.insert(expert);
|
|
|
+ successNum++;
|
|
|
+ successMsg.append(successNum + "、专家【" + expert.getExpertName() + "】导入成功!");
|
|
|
+ } catch (Exception exc) {
|
|
|
+ failureNum++;
|
|
|
+ String msg = successNum + "、专家【" + expert.getExpertName() + "】导入失败";
|
|
|
+ failureMsg.append(msg + exc.getMessage());
|
|
|
+ log.error(msg, exc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (failureNum > 0) {
|
|
|
+ failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确:");
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
+ } else {
|
|
|
+ successMsg.insert(0, "导入成功!共 " + successNum + " 条。");
|
|
|
+ }
|
|
|
+ return successMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private List<PmDemandResVo> changTo(List<PmDemand> pmDemandList) {
|
|
|
List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
|