|
|
@ -21,19 +21,35 @@ 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.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.dao.SpecialSubjectDao; |
|
|
|
import com.epmet.dto.SpecialSubjectDTO; |
|
|
|
import com.epmet.dto.TagCustomerDTO; |
|
|
|
import com.epmet.dto.form.AddSpecialSubjectFormDTO; |
|
|
|
import com.epmet.dto.form.DelSpecialSubjectFormDTO; |
|
|
|
import com.epmet.dto.form.QuerySpecialSubFormDTO; |
|
|
|
import com.epmet.dto.result.AddSpecialSubjectResultDTO; |
|
|
|
import com.epmet.dto.result.WorkSpecialSubjectResultDTO; |
|
|
|
import com.epmet.entity.SpecialSubjectEntity; |
|
|
|
import com.epmet.service.SpecialSubjectService; |
|
|
|
import com.epmet.service.TagCustomerService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 专题表 |
|
|
@ -41,8 +57,11 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2021-07-15 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao, SpecialSubjectEntity> implements SpecialSubjectService { |
|
|
|
@Autowired |
|
|
|
private TagCustomerService tagCustomerService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<SpecialSubjectDTO> page(Map<String, Object> params) { |
|
|
@ -96,4 +115,99 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 添加专题 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return void |
|
|
|
* @author yinzuomei |
|
|
|
* @date 2021-07-15 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AddSpecialSubjectResultDTO addSpecialSubject(AddSpecialSubjectFormDTO formDTO) { |
|
|
|
// 1、标签是否存在
|
|
|
|
TagCustomerDTO tagCustomerDTO=tagCustomerService.get(formDTO.getTagId()); |
|
|
|
if(null==tagCustomerDTO){ |
|
|
|
throw new RenException(EpmetErrorCode.TAG_NOT_EXIST.getCode(), EpmetErrorCode.TAG_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
//2、校验当前组织是否添加过此专题
|
|
|
|
SpecialSubjectEntity havedEntity = baseDao.selectByOrgIdAndTagId(formDTO.getOrgId(), formDTO.getTagId()); |
|
|
|
if (null != havedEntity) { |
|
|
|
throw new RenException(EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getCode(), EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getMsg()); |
|
|
|
} |
|
|
|
// 3、保存
|
|
|
|
SpecialSubjectEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, SpecialSubjectEntity.class); |
|
|
|
insertEntity.setAddOrgId(formDTO.getOrgId()); |
|
|
|
baseDao.insert(insertEntity); |
|
|
|
return new AddSpecialSubjectResultDTO(insertEntity.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 【专题管理】删除专题 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return void |
|
|
|
* @author yinzuomei |
|
|
|
* @date 2021-07-15 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void delSpecialSubject(DelSpecialSubjectFormDTO formDTO) { |
|
|
|
SpecialSubjectEntity original = baseDao.selectById(formDTO.getSpecialSubjectId()); |
|
|
|
if (null != original) { |
|
|
|
if (!original.getAddOrgId().equals(formDTO.getOrgId())) { |
|
|
|
throw new RenException(EpmetErrorCode.CAN_NOT_DEL_SPECIAL_PROJECT.getCode(), EpmetErrorCode.CAN_NOT_DEL_SPECIAL_PROJECT.getMsg()); |
|
|
|
} |
|
|
|
baseDao.delSpecialSubject(formDTO.getSpecialSubjectId(), formDTO.getUserId()); |
|
|
|
} |
|
|
|
log.warn(String.format("special_subject is null id=%s", formDTO.getSpecialSubjectId())); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 【专题管理】已有专题列表 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return void |
|
|
|
* @author yinzuomei |
|
|
|
* @date 2021-07-15 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<WorkSpecialSubjectResultDTO> queryExistedList(QuerySpecialSubFormDTO formDTO) { |
|
|
|
List<WorkSpecialSubjectResultDTO> resultDTOList = new ArrayList<>(); |
|
|
|
List<String> notList = new ArrayList<>(); |
|
|
|
//当前组织或者网格自己建立的
|
|
|
|
List<WorkSpecialSubjectResultDTO> currentOrgList = new ArrayList<>(); |
|
|
|
List<SpecialSubjectDTO> currentOrgCreatedList = baseDao.queryExistedList(formDTO.getOrgId(), notList); |
|
|
|
currentOrgCreatedList.forEach(dto -> { |
|
|
|
WorkSpecialSubjectResultDTO result = new WorkSpecialSubjectResultDTO(); |
|
|
|
result.setSpecialSubjectId(dto.getId()); |
|
|
|
result.setTagId(dto.getTagId()); |
|
|
|
result.setTagName(dto.getTagName()); |
|
|
|
result.setCanDel(true); |
|
|
|
currentOrgList.add(result); |
|
|
|
}); |
|
|
|
if (CollectionUtils.isNotEmpty(currentOrgList)) { |
|
|
|
notList = currentOrgList.stream().map(WorkSpecialSubjectResultDTO::getSpecialSubjectId).distinct().collect(Collectors.toList()); |
|
|
|
} |
|
|
|
if (!NumConstant.ZERO_STR.equals(formDTO.getPids())) { |
|
|
|
//存在上级组织...,从上往下查
|
|
|
|
List<String> pidList = Arrays.asList(formDTO.getPids().split(StrConstant.COLON)); |
|
|
|
for (String pid : pidList) { |
|
|
|
//优先展示自己的,所以要排除掉 领导们给我建立的专题
|
|
|
|
List<SpecialSubjectDTO> list = baseDao.queryExistedList(pid, notList); |
|
|
|
list.forEach(dto -> { |
|
|
|
WorkSpecialSubjectResultDTO result = new WorkSpecialSubjectResultDTO(); |
|
|
|
result.setSpecialSubjectId(dto.getId()); |
|
|
|
result.setTagId(dto.getTagId()); |
|
|
|
result.setTagName(dto.getTagName()); |
|
|
|
result.setCanDel(false); |
|
|
|
resultDTOList.add(result); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
//自己建立的在最后面
|
|
|
|
if (CollectionUtils.isNotEmpty(currentOrgList)) { |
|
|
|
resultDTOList.addAll(currentOrgList); |
|
|
|
} |
|
|
|
return resultDTOList; |
|
|
|
} |
|
|
|
} |