|
|
@ -21,19 +21,43 @@ 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.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
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.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.OrgInfoConstant; |
|
|
|
import com.epmet.dao.GuideDao; |
|
|
|
import com.epmet.dto.GuideDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.GuideDetailResultDTO; |
|
|
|
import com.epmet.dto.result.GuideListResultDTO; |
|
|
|
import com.epmet.dto.result.OrgResultDTO; |
|
|
|
import com.epmet.entity.GuideAttachmentEntity; |
|
|
|
import com.epmet.entity.GuideEntity; |
|
|
|
import com.epmet.entity.GuideExternalLinkEntity; |
|
|
|
import com.epmet.entity.GuideModuleEntity; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.service.GuideAttachmentService; |
|
|
|
import com.epmet.service.GuideExternalLinkService; |
|
|
|
import com.epmet.service.GuideModuleService; |
|
|
|
import com.epmet.service.GuideService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 办事指南表 |
|
|
@ -44,6 +68,14 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class GuideServiceImpl extends BaseServiceImpl<GuideDao, GuideEntity> implements GuideService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
@Resource |
|
|
|
private GuideModuleService guideModuleService; |
|
|
|
@Resource |
|
|
|
private GuideAttachmentService guideAttachmentService; |
|
|
|
@Resource |
|
|
|
private GuideExternalLinkService guideExternalLinkService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<GuideDTO> page(Map<String, Object> params) { |
|
|
@ -81,6 +113,7 @@ public class GuideServiceImpl extends BaseServiceImpl<GuideDao, GuideEntity> imp |
|
|
|
public void save(GuideDTO dto) { |
|
|
|
GuideEntity entity = ConvertUtils.sourceToTarget(dto, GuideEntity.class); |
|
|
|
insert(entity); |
|
|
|
ConvertUtils.sourceToTarget(entity, GuideDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -97,4 +130,253 @@ public class GuideServiceImpl extends BaseServiceImpl<GuideDao, GuideEntity> imp |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 办事指南列表 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @Param formDTO |
|
|
|
* @Return {@link PageData< GuideListResultDTO >} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/9/7 14:00 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<GuideListResultDTO> guideList(TokenDto tokenDto, GuideListFormDTO formDTO) { |
|
|
|
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); |
|
|
|
List<GuideListResultDTO> list = baseDao.getGuideList(formDTO); |
|
|
|
list.forEach(item -> { |
|
|
|
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), item.getCreatedId()); |
|
|
|
if (null == staffInfoCache) { |
|
|
|
item.setCategoryName(""); |
|
|
|
} else { |
|
|
|
item.setCreatedName(staffInfoCache.getRealName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
PageInfo<GuideListResultDTO> pageInfo = new PageInfo<>(list); |
|
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 添加指南 |
|
|
|
* |
|
|
|
* @param tokenDto |
|
|
|
* @Param formDTO |
|
|
|
* @Return |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/9/7 14:12 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void guideAdd(TokenDto tokenDto, GuideAddFormDTO formDTO) { |
|
|
|
if (CollectionUtils.isEmpty(formDTO.getModuleList()) && CollectionUtils.isEmpty(formDTO.getAttachmentList()) && |
|
|
|
CollectionUtils.isEmpty(formDTO.getExternalLinks())) { |
|
|
|
throw new RenException(EpmetErrorCode.GUIDE_IS_NULL.getCode()); |
|
|
|
} |
|
|
|
//保存办事指南表
|
|
|
|
GuideDTO guideDTO = new GuideDTO(); |
|
|
|
guideDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
guideDTO.setOrgId(formDTO.getOrgId()); |
|
|
|
guideDTO.setOrgType(formDTO.getOrgType()); |
|
|
|
guideDTO.setOrgName(formDTO.getOrgName()); |
|
|
|
guideDTO.setCategoryCode(formDTO.getCategoryCode()); |
|
|
|
guideDTO.setTitle(formDTO.getTitle()); |
|
|
|
OrgFormDTO orgFormDTO = new OrgFormDTO(); |
|
|
|
orgFormDTO.setOrgId(formDTO.getOrgId()); |
|
|
|
orgFormDTO.setOrgType(formDTO.getOrgType()); |
|
|
|
//获取组织的pId和pIds
|
|
|
|
Result<OrgResultDTO> result = govOrgOpenFeignClient.getAgencyInfo(orgFormDTO); |
|
|
|
if (!result.success() || null == result.getData()) { |
|
|
|
throw new RenException(result.getCode(), result.getMsg()); |
|
|
|
} |
|
|
|
if (OrgInfoConstant.AGENCY.equals(formDTO.getOrgType())) { |
|
|
|
guideDTO.setPid(result.getData().getPid()); |
|
|
|
} else { |
|
|
|
guideDTO.setPid(result.getData().getAgencyId()); |
|
|
|
} |
|
|
|
guideDTO.setPids(result.getData().getPids().concat(":").concat(result.getData().getAgencyId())); |
|
|
|
save(guideDTO); |
|
|
|
//保存办事指南内容模块
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getModuleList())) { |
|
|
|
List<GuideModuleEntity> guideModuleList = formDTO.getModuleList().stream().map(item -> { |
|
|
|
GuideModuleEntity entity = new GuideModuleEntity(); |
|
|
|
entity.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
entity.setGuideId(guideDTO.getId()); |
|
|
|
entity.setModuleId(item.getModuleId()); |
|
|
|
entity.setModuleContent(item.getModuleContent()); |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
guideModuleService.insertBatch(guideModuleList); |
|
|
|
} |
|
|
|
//保存附件
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getAttachmentList())) { |
|
|
|
AtomicInteger i = new AtomicInteger(1); |
|
|
|
List<GuideAttachmentEntity> attachmentList = formDTO.getAttachmentList().stream().map(item -> { |
|
|
|
GuideAttachmentEntity entity = new GuideAttachmentEntity(); |
|
|
|
entity.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
entity.setGuideId(guideDTO.getId()); |
|
|
|
entity.setAttachmentName(item.getName()); |
|
|
|
entity.setAttachmentFormat(item.getFormat()); |
|
|
|
entity.setAttachmentSize(item.getSize()); |
|
|
|
entity.setAttachmentType(item.getType()); |
|
|
|
entity.setAttachmentUrl(item.getUrl()); |
|
|
|
entity.setDuration(item.getDuration()); |
|
|
|
entity.setSort(i.getAndIncrement()); |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
guideAttachmentService.insertBatch(attachmentList); |
|
|
|
} |
|
|
|
//保存外链地址
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getExternalLinks())) { |
|
|
|
AtomicInteger i = new AtomicInteger(1); |
|
|
|
List<GuideExternalLinkEntity> linkList = formDTO.getExternalLinks().stream().map(item -> { |
|
|
|
GuideExternalLinkEntity entity = new GuideExternalLinkEntity(); |
|
|
|
entity.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
entity.setGuideId(guideDTO.getId()); |
|
|
|
entity.setExternalLink(item.getExternalLink()); |
|
|
|
entity.setDescription(item.getDescription()); |
|
|
|
entity.setSort(i.getAndIncrement()); |
|
|
|
return entity; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
guideExternalLinkService.insertBatch(linkList); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改指南 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @Param formDTO |
|
|
|
* @Return |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/9/7 14:12 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void guideEdit(GuideEditFormDTO formDTO) { |
|
|
|
if (CollectionUtils.isEmpty(formDTO.getModuleList()) && CollectionUtils.isEmpty(formDTO.getAttachmentList()) && |
|
|
|
CollectionUtils.isEmpty(formDTO.getExternalLinks())) { |
|
|
|
throw new RenException(EpmetErrorCode.GUIDE_IS_NULL.getCode()); |
|
|
|
} |
|
|
|
//保存办事指南表
|
|
|
|
GuideDTO guideDTO = get(formDTO.getGuideId()); |
|
|
|
if (!formDTO.getStaffId().equals(guideDTO.getCreatedBy())) { |
|
|
|
throw new RenException(EpmetErrorCode.GUIDE_IS_NOT_YOURS.getCode()); |
|
|
|
} |
|
|
|
guideDTO.setOrgId(formDTO.getOrgId()); |
|
|
|
guideDTO.setOrgType(formDTO.getOrgType()); |
|
|
|
guideDTO.setCategoryCode(formDTO.getCategoryCode()); |
|
|
|
guideDTO.setTitle(formDTO.getTitle()); |
|
|
|
OrgFormDTO orgFormDTO = new OrgFormDTO(); |
|
|
|
orgFormDTO.setOrgId(formDTO.getOrgId()); |
|
|
|
orgFormDTO.setOrgType(formDTO.getOrgType()); |
|
|
|
guideDTO.setOrgName(formDTO.getOrgName()); |
|
|
|
//获取组织的pId和pIds
|
|
|
|
Result<OrgResultDTO> result = govOrgOpenFeignClient.getAgencyInfo(orgFormDTO); |
|
|
|
if (!result.success() || null == result.getData()) { |
|
|
|
throw new RenException(result.getCode(), result.getMsg()); |
|
|
|
} |
|
|
|
if (OrgInfoConstant.AGENCY.equals(formDTO.getOrgType())) { |
|
|
|
guideDTO.setPid(result.getData().getPid()); |
|
|
|
} else { |
|
|
|
guideDTO.setPid(result.getData().getAgencyId()); |
|
|
|
} |
|
|
|
guideDTO.setPids(result.getData().getPids().concat(":").concat(result.getData().getAgencyId())); |
|
|
|
update(guideDTO); |
|
|
|
//保存办事指南内容模块
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getModuleList())) { |
|
|
|
List<GuideModuleEntity> guideModuleList = formDTO.getModuleList().stream().map(item -> { |
|
|
|
GuideModuleEntity entity = new GuideModuleEntity(); |
|
|
|
entity.setCustomerId(guideDTO.getCustomerId()); |
|
|
|
entity.setId(item.getGuideModuleId()); |
|
|
|
entity.setGuideId(guideDTO.getId()); |
|
|
|
entity.setModuleId(item.getModuleId()); |
|
|
|
entity.setModuleContent(item.getModuleContent()); |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
guideModuleService.insertBatch(guideModuleList.stream().filter(item -> null == item.getId()).collect(Collectors.toList())); |
|
|
|
guideModuleService.updateBatchById(guideModuleList.stream().filter(item -> null != item.getId()).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
//保存附件
|
|
|
|
guideAttachmentService.deleteByGuideId(formDTO.getGuideId()); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getAttachmentList())) { |
|
|
|
AtomicInteger i = new AtomicInteger(1); |
|
|
|
List<GuideAttachmentEntity> attachmentList = formDTO.getAttachmentList().stream().map(item -> { |
|
|
|
GuideAttachmentEntity entity = new GuideAttachmentEntity(); |
|
|
|
entity.setCustomerId(guideDTO.getCustomerId()); |
|
|
|
entity.setGuideId(guideDTO.getId()); |
|
|
|
entity.setAttachmentName(item.getName()); |
|
|
|
entity.setAttachmentFormat(item.getFormat()); |
|
|
|
entity.setAttachmentSize(item.getSize()); |
|
|
|
entity.setAttachmentType(item.getType()); |
|
|
|
entity.setAttachmentUrl(item.getUrl()); |
|
|
|
entity.setDuration(item.getDuration()); |
|
|
|
entity.setSort(i.getAndIncrement()); |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
guideAttachmentService.insertBatch(attachmentList); |
|
|
|
} |
|
|
|
//保存外链地址
|
|
|
|
guideExternalLinkService.deleteByGuideId(formDTO.getGuideId()); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getExternalLinks())) { |
|
|
|
AtomicInteger i = new AtomicInteger(1); |
|
|
|
List<GuideExternalLinkEntity> linkList = formDTO.getExternalLinks().stream().map(item -> { |
|
|
|
GuideExternalLinkEntity entity = new GuideExternalLinkEntity(); |
|
|
|
entity.setCustomerId(guideDTO.getCustomerId()); |
|
|
|
entity.setGuideId(guideDTO.getId()); |
|
|
|
entity.setExternalLink(item.getExternalLink()); |
|
|
|
entity.setDescription(item.getDescription()); |
|
|
|
entity.setSort(i.getAndIncrement()); |
|
|
|
return entity; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
guideExternalLinkService.insertBatch(linkList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除指南 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @Param formDTO |
|
|
|
* @Return |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/9/7 14:12 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void guideDel(GuideFormDTO formDTO) { |
|
|
|
GuideDTO guide = get(formDTO.getGuideId()); |
|
|
|
if (!formDTO.getStaffId().equals(guide.getCreatedBy())) { |
|
|
|
throw new RenException(EpmetErrorCode.GUIDE_IS_NOT_YOURS.getCode()); |
|
|
|
} |
|
|
|
//删除主表
|
|
|
|
baseDao.deleteById(formDTO.getGuideId()); |
|
|
|
//删除内容模块
|
|
|
|
guideModuleService.deleteByGuideId(formDTO.getGuideId()); |
|
|
|
//删除附件
|
|
|
|
guideAttachmentService.deleteByGuideId(formDTO.getGuideId()); |
|
|
|
//删除外链
|
|
|
|
guideExternalLinkService.deleteByGuideId(formDTO.getGuideId()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 指南详情 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @Param formDTO |
|
|
|
* @Return {@link GuideDetailResultDTO} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/9/7 14:12 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public GuideDetailResultDTO guideDetail(GuideFormDTO formDTO) { |
|
|
|
//获取指南详情
|
|
|
|
GuideDetailResultDTO result = baseDao.getGuideDetail(formDTO.getGuideId()); |
|
|
|
//获取指南内容模块
|
|
|
|
result.setModuleList(guideModuleService.getByGuideId(formDTO.getCustomerId(), formDTO.getGuideId())); |
|
|
|
//获取指南附件
|
|
|
|
result.setAttachmentList(guideAttachmentService.getByGuideId(formDTO.getGuideId())); |
|
|
|
//获取指南外链地址
|
|
|
|
result.setExternalLinks(guideExternalLinkService.getByGuideId(formDTO.getGuideId())); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
} |