|
@ -17,38 +17,35 @@ |
|
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.dao.SpecialSubjectDao; |
|
|
import com.epmet.dao.SpecialSubjectDao; |
|
|
import com.epmet.dto.SpecialSubjectDTO; |
|
|
import com.epmet.dto.SpecialSubjectDTO; |
|
|
import com.epmet.dto.TagCustomerDTO; |
|
|
import com.epmet.dto.TagCustomerDTO; |
|
|
import com.epmet.dto.form.AddSpecialSubjectFormDTO; |
|
|
import com.epmet.dto.form.AddSpecialSubjectFormDTO; |
|
|
import com.epmet.dto.form.DelSpecialSubjectFormDTO; |
|
|
import com.epmet.dto.form.DelSpecialSubjectFormDTO; |
|
|
import com.epmet.dto.form.QuerySpecialSubFormDTO; |
|
|
import com.epmet.dto.form.QuerySpecialSubFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.StaffInfoFromDTO; |
|
|
import com.epmet.dto.result.AddSpecialSubjectResultDTO; |
|
|
import com.epmet.dto.result.AddSpecialSubjectResultDTO; |
|
|
|
|
|
import com.epmet.dto.result.MineResultDTO; |
|
|
import com.epmet.dto.result.WorkSpecialSubjectResultDTO; |
|
|
import com.epmet.dto.result.WorkSpecialSubjectResultDTO; |
|
|
import com.epmet.entity.SpecialSubjectEntity; |
|
|
import com.epmet.entity.SpecialSubjectEntity; |
|
|
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.service.SpecialSubjectService; |
|
|
import com.epmet.service.SpecialSubjectService; |
|
|
import com.epmet.service.TagCustomerService; |
|
|
import com.epmet.service.TagCustomerService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -62,58 +59,8 @@ import java.util.stream.Collectors; |
|
|
public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao, SpecialSubjectEntity> implements SpecialSubjectService { |
|
|
public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao, SpecialSubjectEntity> implements SpecialSubjectService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private TagCustomerService tagCustomerService; |
|
|
private TagCustomerService tagCustomerService; |
|
|
|
|
|
@Autowired |
|
|
@Override |
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
public PageData<SpecialSubjectDTO> page(Map<String, Object> params) { |
|
|
|
|
|
IPage<SpecialSubjectEntity> page = baseDao.selectPage( |
|
|
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
|
|
getWrapper(params) |
|
|
|
|
|
); |
|
|
|
|
|
return getPageData(page, SpecialSubjectDTO.class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<SpecialSubjectDTO> list(Map<String, Object> params) { |
|
|
|
|
|
List<SpecialSubjectEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, SpecialSubjectDTO.class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private QueryWrapper<SpecialSubjectEntity> getWrapper(Map<String, Object> params){ |
|
|
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<SpecialSubjectEntity> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
|
|
|
|
return wrapper; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public SpecialSubjectDTO get(String id) { |
|
|
|
|
|
SpecialSubjectEntity entity = baseDao.selectById(id); |
|
|
|
|
|
return ConvertUtils.sourceToTarget(entity, SpecialSubjectDTO.class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void save(SpecialSubjectDTO dto) { |
|
|
|
|
|
SpecialSubjectEntity entity = ConvertUtils.sourceToTarget(dto, SpecialSubjectEntity.class); |
|
|
|
|
|
insert(entity); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void update(SpecialSubjectDTO dto) { |
|
|
|
|
|
SpecialSubjectEntity entity = ConvertUtils.sourceToTarget(dto, SpecialSubjectEntity.class); |
|
|
|
|
|
updateById(entity); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void delete(String[] ids) { |
|
|
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 添加专题 |
|
|
* 添加专题 |
|
@ -131,13 +78,27 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
throw new RenException(EpmetErrorCode.TAG_NOT_EXIST.getCode(), EpmetErrorCode.TAG_NOT_EXIST.getMsg()); |
|
|
throw new RenException(EpmetErrorCode.TAG_NOT_EXIST.getCode(), EpmetErrorCode.TAG_NOT_EXIST.getMsg()); |
|
|
} |
|
|
} |
|
|
//2、校验当前组织是否添加过此专题
|
|
|
//2、校验当前组织是否添加过此专题
|
|
|
SpecialSubjectEntity havedEntity = baseDao.selectByOrgIdAndTagId(formDTO.getOrgId(), formDTO.getTagId()); |
|
|
QuerySpecialSubFormDTO querySpecialSubFormDTO=new QuerySpecialSubFormDTO(); |
|
|
if (null != havedEntity) { |
|
|
querySpecialSubFormDTO.setOrgId(formDTO.getOrgId()); |
|
|
throw new RenException(EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getCode(), EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getMsg()); |
|
|
querySpecialSubFormDTO.setPids(formDTO.getPids()); |
|
|
} |
|
|
List<WorkSpecialSubjectResultDTO> havedList=this.queryExistedList(querySpecialSubFormDTO); |
|
|
|
|
|
List<String> haveTagIds=havedList.stream().map(WorkSpecialSubjectResultDTO::getTagId).distinct().collect(Collectors.toList()); |
|
|
|
|
|
haveTagIds.forEach(tagId->{ |
|
|
|
|
|
if(tagId.equals(formDTO.getTagId())){ |
|
|
|
|
|
throw new RenException(EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getCode(), EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
// 3、保存
|
|
|
// 3、保存
|
|
|
SpecialSubjectEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, SpecialSubjectEntity.class); |
|
|
SpecialSubjectEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, SpecialSubjectEntity.class); |
|
|
|
|
|
StaffInfoFromDTO staffInfoFromDTO = new StaffInfoFromDTO(); |
|
|
|
|
|
staffInfoFromDTO.setStaffId(formDTO.getAddUserId()); |
|
|
|
|
|
Result<MineResultDTO> result = govOrgOpenFeignClient.queryStaffProfile(staffInfoFromDTO); |
|
|
|
|
|
if(result.success()&&null!=result.getData()){ |
|
|
|
|
|
insertEntity.setAddUserAgencyId(result.getData().getAgencyId()); |
|
|
|
|
|
} |
|
|
insertEntity.setAddOrgId(formDTO.getOrgId()); |
|
|
insertEntity.setAddOrgId(formDTO.getOrgId()); |
|
|
|
|
|
insertEntity.setAddOrgPid(formDTO.getPid()); |
|
|
|
|
|
insertEntity.setAddOrgPids(formDTO.getPids()); |
|
|
baseDao.insert(insertEntity); |
|
|
baseDao.insert(insertEntity); |
|
|
return new AddSpecialSubjectResultDTO(insertEntity.getId()); |
|
|
return new AddSpecialSubjectResultDTO(insertEntity.getId()); |
|
|
} |
|
|
} |
|
@ -183,16 +144,21 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
result.setTagId(dto.getTagId()); |
|
|
result.setTagId(dto.getTagId()); |
|
|
result.setTagName(dto.getTagName()); |
|
|
result.setTagName(dto.getTagName()); |
|
|
result.setCanDel(true); |
|
|
result.setCanDel(true); |
|
|
|
|
|
result.setAddOrgId(dto.getAddOrgId()); |
|
|
|
|
|
result.setOrgLevel(dto.getOrgLevel()); |
|
|
currentOrgList.add(result); |
|
|
currentOrgList.add(result); |
|
|
}); |
|
|
}); |
|
|
if (CollectionUtils.isNotEmpty(currentOrgList)) { |
|
|
if (CollectionUtils.isNotEmpty(currentOrgList)) { |
|
|
notList = currentOrgList.stream().map(WorkSpecialSubjectResultDTO::getSpecialSubjectId).distinct().collect(Collectors.toList()); |
|
|
notList = currentOrgList.stream().map(WorkSpecialSubjectResultDTO::getTagId).distinct().collect(Collectors.toList()); |
|
|
} |
|
|
} |
|
|
if (!NumConstant.ZERO_STR.equals(formDTO.getPids())) { |
|
|
if (!NumConstant.ZERO_STR.equals(formDTO.getPids())) { |
|
|
//存在上级组织...,从上往下查
|
|
|
|
|
|
List<String> pidList = Arrays.asList(formDTO.getPids().split(StrConstant.COLON)); |
|
|
List<String> pidList = Arrays.asList(formDTO.getPids().split(StrConstant.COLON)); |
|
|
for (String pid : pidList) { |
|
|
for (String pid : pidList) { |
|
|
//优先展示自己的,所以要排除掉 领导们给我建立的专题
|
|
|
if(CollectionUtils.isNotEmpty(resultDTOList)){ |
|
|
|
|
|
List<String> parentAddList=resultDTOList.stream().map(WorkSpecialSubjectResultDTO::getTagId).distinct().collect(Collectors.toList()); |
|
|
|
|
|
notList.addAll(parentAddList); |
|
|
|
|
|
} |
|
|
|
|
|
//优先展示自己的,所以要排除掉自己的,自上向下查,优先展示上层领导们给我建立的专题
|
|
|
List<SpecialSubjectDTO> list = baseDao.queryExistedList(pid, notList); |
|
|
List<SpecialSubjectDTO> list = baseDao.queryExistedList(pid, notList); |
|
|
list.forEach(dto -> { |
|
|
list.forEach(dto -> { |
|
|
WorkSpecialSubjectResultDTO result = new WorkSpecialSubjectResultDTO(); |
|
|
WorkSpecialSubjectResultDTO result = new WorkSpecialSubjectResultDTO(); |
|
@ -200,6 +166,8 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
result.setTagId(dto.getTagId()); |
|
|
result.setTagId(dto.getTagId()); |
|
|
result.setTagName(dto.getTagName()); |
|
|
result.setTagName(dto.getTagName()); |
|
|
result.setCanDel(false); |
|
|
result.setCanDel(false); |
|
|
|
|
|
result.setAddOrgId(dto.getAddOrgId()); |
|
|
|
|
|
result.setOrgLevel(dto.getOrgLevel()); |
|
|
resultDTOList.add(result); |
|
|
resultDTOList.add(result); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|