@ -17,26 +17,43 @@
package com.epmet.service.impl ;
import com.alibaba.fastjson.JSON ;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl ;
import com.epmet.commons.tools.constant.NumConstant ;
import com.epmet.commons.tools.constant.StrConstant ;
import com.epmet.commons.tools.dto.form.FileCommonDTO ;
import com.epmet.commons.tools.exception.EpmetErrorCode ;
import com.epmet.commons.tools.exception.RenException ;
import com.epmet.commons.tools.scan.param.ImgScanParamDTO ;
import com.epmet.commons.tools.scan.param.ImgTaskDTO ;
import com.epmet.commons.tools.scan.param.TextScanParamDTO ;
import com.epmet.commons.tools.scan.param.TextTaskDTO ;
import com.epmet.commons.tools.scan.result.SyncScanResult ;
import com.epmet.commons.tools.utils.ConvertUtils ;
import com.epmet.commons.tools.utils.Result ;
import com.epmet.commons.tools.utils.ScanContentUtils ;
import com.epmet.constant.EventConstant ;
import com.epmet.dao.ResiEventDao ;
import com.epmet.dto.form.EventDetailFormDTO ;
import com.epmet.dto.form.EventListFormDTO ;
import com.epmet.dto.form.UpdateViewTimeFormDTO ;
import com.epmet.dto.result.EventDetailResultDTO ;
import com.epmet.dto.result.EventListResultDTO ;
import com.epmet.dto.form.ChooseResolveFormDTO ;
import com.epmet.dto.form.MyReportedFormDTO ;
import com.epmet.dto.form.ReCallEventFormDTO ;
import com.epmet.dto.form.ResiEventFormDTO ;
import com.epmet.dto.result.MyReportedResultDTO ;
import com.epmet.dto.result.ResiEventIdDTO ;
import com.epmet.entity.ResiEventEntity ;
import com.epmet.constant.ResiEventAction ;
import com.epmet.dao.* ;
import com.epmet.dto.form.* ;
import com.epmet.dto.result.* ;
import com.epmet.entity.* ;
import com.epmet.feign.EpmetUserOpenFeignClient ;
import com.epmet.feign.GovOrgOpenFeignClient ;
import com.epmet.service.ResiEventService ;
import com.github.pagehelper.PageHelper ;
import com.github.pagehelper.PageInfo ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.stereotype.Service ;
import org.springframework.util.CollectionUtils ;
import java.util.ArrayList ;
import java.util.Date ;
import java.util.List ;
import java.util.UUID ;
/ * *
* 居民报事表
@ -44,8 +61,27 @@ import java.util.List;
* @author generator generator @elink - cn . com
* @since v1 . 0 . 0 2021 - 08 - 03
* /
@Slf4j
@Service
public class ResiEventServiceImpl extends BaseServiceImpl < ResiEventDao , ResiEventEntity > implements ResiEventService {
@Value ( "${openapi.scan.server.url}" )
private String scanApiUrl ;
@Value ( "${openapi.scan.method.textSyncScan}" )
private String textSyncScanMethod ;
@Value ( "${openapi.scan.method.imgSyncScan}" )
private String imgSyncScanMethod ;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient ;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient ;
@Autowired
private ResiEventAttachmentDao resiEventAttachmentDao ;
@Autowired
private ResiEventReportOrgDao resiEventReportOrgDao ;
@Autowired
private ResiEventMentionDao resiEventMentionDao ;
@Autowired
private ResiEventOperationLogDao resiEventOperationLogDao ;
/ * *
* @Description 群众直报 ( 待处理 、 处理中 、 已办结 ) 列表
@ -58,15 +94,9 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven
* /
@Override
public List < EventListResultDTO > eventList ( EventListFormDTO formDTO ) {
// 处理中
if ( formDTO . getEventType ( ) . equals ( EventConstant . EVENT_PROCESSED ) ) {
// 待处理
} else if ( formDTO . getEventType ( ) . equals ( EventConstant . EVENT_UN_DISPOSED ) ) {
// 已办结
} else if ( formDTO . getEventType ( ) . equals ( EventConstant . EVENT_TRANSFERRED ) ) {
List < EventListResultDTO > result = baseDao . eventUnDisposedList ( formDTO . getOrgId ( ) , formDTO . getEventType ( ) ) ;
if ( ! CollectionUtils . isEmpty ( result ) ) {
return result ;
}
return new ArrayList < > ( ) ;
}
@ -102,18 +132,163 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven
* /
@Override
public ResiEventIdDTO report ( ResiEventFormDTO formDTO ) {
//todo
//1、事件内容审核
//2、图片审核
this . scanContent ( formDTO . getEventContent ( ) , formDTO . getAttachmentList ( ) ) ;
//3、查询当前所在网格的信息
Result < GridInfoResultDTO > gridInfoRes = govOrgOpenFeignClient . queryGridInfo ( formDTO . getGridId ( ) ) ;
if ( ! gridInfoRes . success ( ) | | null = = gridInfoRes . getData ( ) ) {
throw new RenException ( "网格信息查询异常" ) ;
}
ResiEventEntity resiEventEntity = ConvertUtils . sourceToTarget ( formDTO , ResiEventEntity . class ) ;
resiEventEntity . setAgencyId ( gridInfoRes . getData ( ) . getParentAgencyId ( ) ) ;
resiEventEntity . setPids ( gridInfoRes . getData ( ) . getPids ( ) ) ;
resiEventEntity . setReportUserId ( formDTO . getUserId ( ) ) ;
Result < Boolean > partyRes = epmetUserOpenFeignClient . selectIsPartyMemberByUserId ( formDTO . getUserId ( ) ) ;
if ( ! partyRes . success ( ) | | null = = partyRes . getData ( ) ) {
throw new RenException ( "查询用户是否是党员异常" ) ;
}
resiEventEntity . setIsParty ( partyRes . getData ( ) ) ;
resiEventEntity . setStatus ( EventConstant . EVENT_STATUS_PROCESSING ) ;
resiEventEntity . setShiftProject ( false ) ;
resiEventEntity . setProjectId ( StrConstant . EPMETY_STR ) ;
resiEventEntity . setRecallFlag ( false ) ;
resiEventEntity . setReadFlag ( false ) ;
resiEventEntity . setRedDot ( false ) ;
resiEventEntity . setLatestOperatedTime ( new Date ( ) ) ;
resiEventEntity . setCreatedTime ( resiEventEntity . getLatestOperatedTime ( ) ) ;
resiEventEntity . setUpdatedTime ( resiEventEntity . getLatestOperatedTime ( ) ) ;
//4、插入主表resi_event
baseDao . insert ( resiEventEntity ) ;
//5、插入附件表
List < ResiEventAttachmentEntity > attachmentEntityList = getAttList ( formDTO . getCustomerId ( ) , resiEventEntity . getId ( ) , formDTO . getAttachmentList ( ) ) ;
attachmentEntityList . forEach ( attachmentEntity - > {
resiEventAttachmentDao . insert ( attachmentEntity ) ;
} ) ;
//6、插入组织表
List < ResiEventReportOrgEntity > orgEntityList = getOrgList ( formDTO . getCustomerId ( ) , resiEventEntity . getId ( ) , formDTO . getOrgList ( ) ) ;
orgEntityList . forEach ( orgEntity - > {
resiEventReportOrgDao . insert ( orgEntity ) ;
} ) ;
//7、插入艾特人表
List < ResiEventMentionEntity > npcList = getNpcList ( formDTO . getCustomerId ( ) , resiEventEntity . getId ( ) , formDTO . getNpcUserList ( ) ) ;
npcList . forEach ( npc - > {
resiEventMentionDao . insert ( npc ) ;
} ) ;
//8、插入log日志
ResiEventOperationLogEntity publishLog = new ResiEventOperationLogEntity ( ) ;
publishLog . setCustomerId ( formDTO . getCustomerId ( ) ) ;
publishLog . setResiEventId ( resiEventEntity . getId ( ) ) ;
publishLog . setUserId ( formDTO . getUserId ( ) ) ;
publishLog . setUserIdentity ( EventConstant . REPORT_USER ) ;
publishLog . setActionCode ( ResiEventAction . PUBLISH . getCode ( ) ) ;
publishLog . setActionDesc ( ResiEventAction . PUBLISH . getDesc ( ) ) ;
publishLog . setOperateTime ( resiEventEntity . getCreatedTime ( ) ) ;
resiEventOperationLogDao . insert ( publishLog ) ;
//9、返回事件id
ResiEventIdDTO resiEventIdDTO = new ResiEventIdDTO ( ) ;
resiEventIdDTO . setResiEventId ( resiEventEntity . getId ( ) ) ;
return resiEventIdDTO ;
}
private List < ResiEventMentionEntity > getNpcList ( String customerId , String resiEventId , List < MentionUserFormDTO > npcUserList ) {
List < ResiEventMentionEntity > list = new ArrayList < > ( ) ;
npcUserList . forEach ( npc - > {
ResiEventMentionEntity mentionEntity = new ResiEventMentionEntity ( ) ;
mentionEntity . setCustomerId ( customerId ) ;
mentionEntity . setResiEventId ( resiEventId ) ;
mentionEntity . setUserType ( EventConstant . NPC_USER ) ;
mentionEntity . setUserId ( npc . getNpcUserId ( ) ) ;
mentionEntity . setGridId ( npc . getGridId ( ) ) ;
mentionEntity . setAgencyId ( npc . getAgencyId ( ) ) ;
mentionEntity . setPids ( npc . getPids ( ) ) ;
mentionEntity . setReadFlag ( EventConstant . UN_READ ) ;
mentionEntity . setRedDot ( true ) ;
list . add ( mentionEntity ) ;
} ) ;
return list ;
}
private List < ResiEventReportOrgEntity > getOrgList ( String customerId , String resiEventId , List < ReportOrgFormDTO > orgList ) {
List < ResiEventReportOrgEntity > list = new ArrayList < > ( ) ;
orgList . forEach ( org - > {
ResiEventReportOrgEntity entity = ConvertUtils . sourceToTarget ( org , ResiEventReportOrgEntity . class ) ;
entity . setCustomerId ( customerId ) ;
entity . setResiEventId ( resiEventId ) ;
//默认是未读
entity . setOrgRead ( EventConstant . UN_READ ) ;
entity . setRedDot ( true ) ;
list . add ( entity ) ;
} ) ;
return list ;
}
private List < ResiEventAttachmentEntity > getAttList ( String customerId , String resiEventId , List < FileCommonDTO > attachmentList ) {
List < ResiEventAttachmentEntity > list = new ArrayList < > ( ) ;
int sort = NumConstant . ONE ;
for ( FileCommonDTO img : attachmentList ) {
ResiEventAttachmentEntity entity = new ResiEventAttachmentEntity ( ) ;
entity . setCustomerId ( customerId ) ;
entity . setResiEventId ( resiEventId ) ;
entity . setAttachmentName ( img . getName ( ) ) ;
entity . setAttachmentFormat ( img . getFormat ( ) ) ;
entity . setAttachmentType ( img . getType ( ) ) ;
entity . setAttachmentUrl ( img . getUrl ( ) ) ;
entity . setSort ( sort ) ;
sort + + ;
list . add ( entity ) ;
}
return list ;
}
return null ;
private void scanContent ( String eventContent , List < FileCommonDTO > attachmentList ) {
//事件内容
if ( StringUtils . isNotBlank ( eventContent ) ) {
TextScanParamDTO textScanParamDTO = new TextScanParamDTO ( ) ;
TextTaskDTO taskDTO = new TextTaskDTO ( ) ;
taskDTO . setContent ( eventContent ) ;
taskDTO . setDataId ( UUID . randomUUID ( ) . toString ( ) . replace ( "-" , "" ) ) ;
textScanParamDTO . getTasks ( ) . add ( taskDTO ) ;
Result < SyncScanResult > textSyncScanResult = ScanContentUtils . textSyncScan ( scanApiUrl . concat ( textSyncScanMethod ) , textScanParamDTO ) ;
if ( ! textSyncScanResult . success ( ) ) {
throw new RenException ( EpmetErrorCode . SERVER_ERROR . getCode ( ) ) ;
} else {
if ( ! textSyncScanResult . getData ( ) . isAllPass ( ) ) {
throw new RenException ( EpmetErrorCode . TEXT_SCAN_FAILED . getCode ( ) , EpmetErrorCode . TEXT_SCAN_FAILED . getMsg ( ) ) ;
}
}
}
List < String > imgList = new ArrayList < > ( ) ;
for ( FileCommonDTO fileCommonDTO : attachmentList ) {
if ( "image" . equals ( fileCommonDTO . getType ( ) ) ) {
imgList . add ( fileCommonDTO . getUrl ( ) ) ;
}
}
//事件图片
if ( ! CollectionUtils . isEmpty ( imgList ) ) {
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO ( ) ;
imgList . forEach ( imgUrl - > {
ImgTaskDTO task = new ImgTaskDTO ( ) ;
task . setDataId ( UUID . randomUUID ( ) . toString ( ) . replace ( "-" , "" ) ) ;
task . setUrl ( imgUrl ) ;
imgScanParamDTO . getTasks ( ) . add ( task ) ;
} ) ;
Result < SyncScanResult > imgScanResult = ScanContentUtils . imgSyncScan ( scanApiUrl . concat ( imgSyncScanMethod ) , imgScanParamDTO ) ;
if ( ! imgScanResult . success ( ) ) {
throw new RenException ( EpmetErrorCode . SERVER_ERROR . getCode ( ) ) ;
} else {
if ( ! imgScanResult . getData ( ) . isAllPass ( ) ) {
throw new RenException ( EpmetErrorCode . IMG_SCAN_FAILED . getCode ( ) , EpmetErrorCode . IMG_SCAN_FAILED . getMsg ( ) ) ;
}
}
}
}
/ * *
* 撤回事件
*
* 需求描述 : 未处理状态中可撤回上报事件 , 撤回后不在展示列表内 、 @的人大代表或组织已读后按钮消失
* @param formDTO
* @return void
* @author yinzuomei
@ -121,9 +296,34 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven
* /
@Override
public void reCall ( ReCallEventFormDTO formDTO ) {
// todo
ResiEventEntity resiEventEntity = baseDao . selectById ( formDTO . getResiEventId ( ) ) ;
if ( null = = resiEventEntity ) {
throw new RenException ( String . format ( "根据事件id没有找到记录" , formDTO . getResiEventId ( ) ) ) ;
}
// 我自己的发布的才可以删除
if ( ! formDTO . getUserId ( ) . equals ( resiEventEntity . getReportUserId ( ) ) ) {
log . warn ( "撤回事件入参:" + JSON . toJSONString ( formDTO ) ) ;
throw new RenException ( EpmetErrorCode . RESI_EVENT_NOT_MY_REPORTED . getCode ( ) , EpmetErrorCode . RESI_EVENT_NOT_MY_REPORTED . getMsg ( ) ) ;
}
// 没有人看到过,才可以删除
if ( resiEventEntity . getReadFlag ( ) ) {
throw new RenException ( EpmetErrorCode . RESI_EVENT_READ . getCode ( ) , EpmetErrorCode . RESI_EVENT_READ . getMsg ( ) ) ;
}
resiEventEntity . setLatestOperatedTime ( new Date ( ) ) ;
resiEventEntity . setRecallFlag ( true ) ;
resiEventEntity . setRecallTime ( resiEventEntity . getLatestOperatedTime ( ) ) ;
//1、更新主表标记已撤回
baseDao . updateById ( resiEventEntity ) ;
//2、插入log日志
ResiEventOperationLogEntity reCallLog = new ResiEventOperationLogEntity ( ) ;
reCallLog . setCustomerId ( formDTO . getCustomerId ( ) ) ;
reCallLog . setResiEventId ( resiEventEntity . getId ( ) ) ;
reCallLog . setUserId ( formDTO . getUserId ( ) ) ;
reCallLog . setUserIdentity ( EventConstant . REPORT_USER ) ;
reCallLog . setActionCode ( ResiEventAction . RECALL . getCode ( ) ) ;
reCallLog . setActionDesc ( ResiEventAction . RECALL . getDesc ( ) ) ;
reCallLog . setOperateTime ( resiEventEntity . getLatestOperatedTime ( ) ) ;
resiEventOperationLogDao . insert ( reCallLog ) ;
}
@ -137,13 +337,30 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven
* /
@Override
public void chooseResolve ( ChooseResolveFormDTO formDTO ) {
// todo
ResiEventEntity resiEventEntity = baseDao . selectById ( formDTO . getResiEventId ( ) ) ;
if ( null = = resiEventEntity ) {
throw new RenException ( String . format ( "根据事件id没有找到记录" , formDTO . getResiEventId ( ) ) ) ;
}
// 我自己的发布的才可以
if ( ! formDTO . getUserId ( ) . equals ( resiEventEntity . getReportUserId ( ) ) ) {
throw new RenException ( EpmetErrorCode . RESI_EVENT_NOT_MY_REPORTED . getCode ( ) , EpmetErrorCode . RESI_EVENT_NOT_MY_REPORTED . getMsg ( ) ) ;
}
if ( ! EventConstant . EVENT_STATUS_CLOSED_CASE . equals ( resiEventEntity . getStatus ( ) ) ) {
throw new RenException ( "事件办结后,才可以选择是否解决,当前状态为:" + resiEventEntity . getStatus ( ) ) ;
}
resiEventEntity . setResolveStatus ( formDTO . getResolveStatus ( ) ) ;
resiEventEntity . setUpdatedTime ( new Date ( ) ) ;
baseDao . updateById ( resiEventEntity ) ;
//2、插入log日志
ResiEventOperationLogEntity reCallLog = new ResiEventOperationLogEntity ( ) ;
reCallLog . setCustomerId ( formDTO . getCustomerId ( ) ) ;
reCallLog . setResiEventId ( resiEventEntity . getId ( ) ) ;
reCallLog . setUserId ( formDTO . getUserId ( ) ) ;
reCallLog . setUserIdentity ( EventConstant . REPORT_USER ) ;
reCallLog . setActionCode ( ResiEventAction . CHOOSE_RESOLVE . getCode ( ) ) ;
reCallLog . setActionDesc ( ResiEventAction . CHOOSE_RESOLVE . getDesc ( ) ) ;
reCallLog . setOperateTime ( resiEventEntity . getUpdatedTime ( ) ) ;
resiEventOperationLogDao . insert ( reCallLog ) ;
}
/ * *
@ -156,11 +373,27 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven
* /
@Override
public List < MyReportedResultDTO > queryMyReported ( MyReportedFormDTO formDTO ) {
// todo
PageInfo < MyReportedResultDTO > result = PageHelper . startPage ( formDTO . getPageNo ( ) ,
formDTO . getPageSize ( ) ) . doSelectPageInfo ( ( ) - > baseDao . queryMyReported ( formDTO . getUserId ( ) ,
formDTO . getStatusCondition ( ) ) ) ;
return result . getList ( ) ;
}
/ * *
* 我要报事 - 人大代表未读 / 已读列表
*
* @param formDTO
* @return java . util . List < com . epmet . dto . result . UserMentionResultDTO >
* @author yinzuomei
* @date 2021 / 8 / 4 9 : 41
* /
@Override
public List < UserMentionResultDTO > mentionList ( UserMentionFormDTO formDTO ) {
PageInfo < UserMentionResultDTO > result = PageHelper . startPage ( formDTO . getPageNo ( ) ,
formDTO . getPageSize ( ) ) . doSelectPageInfo ( ( ) - > resiEventMentionDao . selectMentionList ( formDTO . getUserId ( ) ,
formDTO . getReadFlag ( ) ) ) ;
return result . getList ( ) ;
}
return null ;
}
}