@ -15,6 +15,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis ;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis ;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache ;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache ;
import com.epmet.commons.tools.security.dto.TokenDto ;
import com.epmet.commons.tools.utils.ConvertUtils ;
import com.epmet.commons.tools.utils.ExcelPoiUtils ;
@ -22,14 +23,18 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.constants.ImportTaskConstants ;
import com.epmet.dao.IcEpidemicSpecialAttentionDao ;
import com.epmet.dto.IcEpidemicSpecialAttentionDTO ;
import com.epmet.dto.SysDictDataDTO ;
import com.epmet.dto.form.* ;
import com.epmet.dto.result.HouseInfoDTO ;
import com.epmet.dto.result.NatPieResultDTO ;
import com.epmet.dto.result.UploadImgResultDTO ;
import com.epmet.dto.result.VaccinationListResultDTO ;
import com.epmet.entity.IcEpidemicSpecialAttentionEntity ;
import com.epmet.enums.ChannelEnum ;
import com.epmet.enums.NatPieColorEnum ;
import com.epmet.excel.ImportEpidemicSpecialAttention ;
import com.epmet.excel.error.EpidemicSpecialAttentionErrorModel ;
import com.epmet.feign.EpmetAdminOpenFeignClient ;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient ;
import com.epmet.feign.GovOrgOpenFeignClient ;
import com.epmet.feign.OssFeignClient ;
@ -76,6 +81,8 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
private IcNoticeService noticeService ;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient ;
@Autowired
private EpmetAdminOpenFeignClient epmetAdminOpenFeignClient ;
@Override
public PageData < IcEpidemicSpecialAttentionDTO > page ( Map < String , Object > params ) {
@ -155,6 +162,9 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
result . setTotal ( list . size ( ) ) ;
}
} else if ( formDTO . getAttentionType ( ) . equals ( NumConstant . TWO ) ) {
if ( StringUtils . isBlank ( formDTO . getIsHistory ( ) ) ) {
formDTO . setIsHistory ( NumConstant . ZERO_STR ) ;
}
if ( formDTO . getIsPage ( ) ) {
PageInfo < VaccinationListResultDTO > pageInfo = PageHelper . startPage ( formDTO . getPageNo ( ) , formDTO . getPageSize ( ) ) . doSelectPageInfo ( ( ) - > baseDao . natList ( formDTO ) ) ;
result . setList ( pageInfo . getList ( ) ) ;
@ -164,6 +174,65 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
result . setList ( list ) ;
result . setTotal ( list . size ( ) ) ;
}
if ( CollectionUtils . isNotEmpty ( result . getList ( ) ) ) {
result . getList ( ) . forEach ( r - > {
if ( StringUtils . isNotBlank ( r . getGridId ( ) ) ) {
GridInfoCache gridInfo = CustomerOrgRedis . getGridInfo ( r . getGridId ( ) ) ;
if ( null = = gridInfo ) {
throw new EpmetException ( "查询网格失败:" + r . getGridId ( ) ) ;
}
r . setGridName ( gridInfo . getGridNamePath ( ) ) ;
}
} ) ;
}
}
if ( CollectionUtils . isNotEmpty ( result . getList ( ) ) ) {
result . getList ( ) . forEach ( v - > {
v . setSex ( ) ;
} ) ;
}
//需求调整 列表和导出增加所属房屋(小区+楼栋+单元+房间)一列值 sun
Map < String , HouseInfoDTO > houseInfoMap = new HashMap < > ( ) ;
//查询房屋信息
if ( result . getList ( ) . size ( ) > NumConstant . ZERO ) {
Set < String > houseIds = result . getList ( ) . stream ( ) . filter ( l - > StringUtils . isNotBlank ( l . getHomeId ( ) ) ) . map ( m - > m . getHomeId ( ) ) . collect ( Collectors . toSet ( ) ) ;
Result < List < HouseInfoDTO > > houseInfoRes = govOrgOpenFeignClient . queryListHouseInfo ( houseIds , formDTO . getCustomerId ( ) ) ;
List < HouseInfoDTO > houseInfoDTOList = houseInfoRes . success ( ) & & ! CollectionUtils . isEmpty ( houseInfoRes . getData ( ) ) ? houseInfoRes . getData ( ) : new ArrayList < > ( ) ;
houseInfoMap = houseInfoDTOList . stream ( ) . collect ( Collectors . toMap ( HouseInfoDTO : : getHomeId , Function . identity ( ) ) ) ;
}
int i = ( formDTO . getPageNo ( ) - NumConstant . ONE ) * formDTO . getPageSize ( ) ;
for ( VaccinationListResultDTO v : result . getList ( ) ) {
i + = 1 ;
v . setSort ( i ) ;
if ( null ! = houseInfoMap & & houseInfoMap . containsKey ( v . getHomeId ( ) ) ) {
v . setVillageName ( houseInfoMap . get ( v . getHomeId ( ) ) . getNeighborHoodName ( ) ) ;
v . setBuildName ( houseInfoMap . get ( v . getHomeId ( ) ) . getBuildingName ( ) ) ;
v . setUnitName ( houseInfoMap . get ( v . getHomeId ( ) ) . getUnitName ( ) ) ;
v . setHomeName ( houseInfoMap . get ( v . getHomeId ( ) ) . getDoorName ( ) ) ;
v . setAllName ( houseInfoMap . get ( v . getHomeId ( ) ) . getAllName ( ) ) ;
}
}
return result ;
}
@Override
public PageData historyList ( VaccinationListFormDTO formDTO ) {
PageData < VaccinationListResultDTO > result = new PageData ( new ArrayList ( ) , NumConstant . ZERO_L ) ;
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis . getStaffInfo ( formDTO . getCustomerId ( ) , formDTO . getUserId ( ) ) ;
if ( null = = staffInfo ) {
throw new EpmetException ( "未查询到工作人员信息" + formDTO . getUserId ( ) ) ;
}
formDTO . setOrgId ( staffInfo . getAgencyId ( ) ) ;
formDTO . setIsHistory ( NumConstant . ONE_STR ) ;
if ( formDTO . getIsPage ( ) ) {
PageInfo < VaccinationListResultDTO > pageInfo = PageHelper . startPage ( formDTO . getPageNo ( ) , formDTO . getPageSize ( ) ) . doSelectPageInfo ( ( ) - > baseDao . natList ( formDTO ) ) ;
result . setList ( pageInfo . getList ( ) ) ;
result . setTotal ( Integer . valueOf ( String . valueOf ( pageInfo . getTotal ( ) ) ) ) ;
} else {
List < VaccinationListResultDTO > list = baseDao . natList ( formDTO ) ;
result . setList ( list ) ;
result . setTotal ( list . size ( ) ) ;
}
if ( CollectionUtils . isNotEmpty ( result . getList ( ) ) ) {
result . getList ( ) . forEach ( v - > {
@ -212,19 +281,26 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
if ( null = = agencyInfo ) {
throw new EpmetException ( "未查询到组织信息" + staffInfo . getAgencyId ( ) ) ;
}
/ * *
* 一条改多条 , 取消关注就成为历史 , 再次关注即新增 , 不操作历史数据
* 新增关注列表已存在时 , 覆盖旧数据
* /
List < IcEpidemicSpecialAttentionEntity > entities = ConvertUtils . sourceToTarget ( formDTO . getList ( ) , IcEpidemicSpecialAttentionEntity . class ) ;
List < String > idCards = entities . stream ( ) . map ( m - > m . getIdCard ( ) ) . collect ( Collectors . toList ( ) ) ;
Integer attentionType = entities . get ( NumConstant . ZERO ) . getAttentionType ( ) ;
List < String > existList = baseDao . getExistList ( attentionType , idCards ) ;
List < IcEpidemicSpecialAttentionEntity > existsEntities = new ArrayList < > ( ) ;
if ( CollectionUtils . isNotEmpty ( existList ) ) {
for ( String s : existList ) {
for ( int i = NumConstant . ZERO ; i < entities . size ( ) ; i + + ) {
if ( s . equals ( entities . get ( i ) . getIdCard ( ) ) ) {
existsEntities . add ( entities . get ( i ) ) ;
entities . remove ( i ) ;
continue ;
}
}
}
baseDao . addExistAttention ( existsEntities , attentionType ) ;
}
entities . forEach ( e - > {
e . setIsAttention ( NumConstant . ONE ) ;
@ -232,9 +308,7 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
e . setPid ( agencyInfo . getPid ( ) ) ;
e . setPids ( agencyInfo . getPids ( ) ) ;
e . setCustomerId ( formDTO . getCustomerId ( ) ) ;
if ( e . getAttentionType ( ) . equals ( NumConstant . TWO ) ) {
e . setReason ( "有重点区域行程" ) ;
}
e . setIsHistory ( NumConstant . ZERO_STR ) ;
} ) ;
insertBatch ( entities ) ;
//新增通知表信息
@ -265,11 +339,12 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
public void vaccinationUpdate ( IcEpidemicSpecialAttentionDTO formDTO , TokenDto tokenDto ) {
LambdaQueryWrapper < IcEpidemicSpecialAttentionEntity > w = new LambdaQueryWrapper < > ( ) ;
IcEpidemicSpecialAttentionEntity e = new IcEpidemicSpecialAttentionEntity ( ) ;
w . eq ( IcEpidemicSpecialAttentionEntity : : getIdCard , formDTO . getIdCar d ( ) )
w . eq ( IcEpidemicSpecialAttentionEntity : : getId , formDTO . getId ( ) )
. eq ( IcEpidemicSpecialAttentionEntity : : getAttentionType , formDTO . getAttentionType ( ) ) ;
e . setMobile ( formDTO . getMobile ( ) ) ;
e . setReason ( formDTO . getReason ( ) ) ;
e . setRemark ( formDTO . getRemark ( ) ) ;
e . setIsolatedState ( formDTO . getIsolatedState ( ) ) ;
update ( e , w ) ;
if ( CollectionUtils . isNotEmpty ( formDTO . getChannel ( ) ) ) {
SendNoticeFormDTO dto = new SendNoticeFormDTO ( ) ;
@ -311,7 +386,6 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
@Async
public void importFile ( TokenDto tokenDto , InputStream inputStream , Integer attentionType , String taskId ) {
List < EpidemicSpecialAttentionErrorModel > errorInfo = new ArrayList < > ( ) ;
try {
List < ImportEpidemicSpecialAttention > list = ExcelPoiUtils . importExcel ( inputStream , 0 , 1 , ImportEpidemicSpecialAttention . class ) ;
if ( CollectionUtils . isEmpty ( list ) ) {
@ -336,7 +410,7 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
continue ;
}
if ( StringUtils . isBlank ( list . get ( i ) . getIdCard ( ) ) & & ! list . get ( i ) . getAddStatus ( ) ) {
errorInfo . add ( getErrorInfo ( list . get ( i ) , "身份 证号不能为空" , i + 1 ) ) ;
errorInfo . add ( getErrorInfo ( list . get ( i ) , "证件 号不能为空" , i + 1 ) ) ;
list . get ( i ) . setAddStatus ( true ) ;
continue ;
}
@ -345,9 +419,19 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
list . get ( i ) . setAddStatus ( true ) ;
continue ;
}
if ( attentionType . compareTo ( NumConstant . TWO ) = = NumConstant . ZERO & & StringUtils . isBlank ( list . get ( i ) . getIsolatedState ( ) ) & & ! list . get ( i ) . getAddStatus ( ) ) {
errorInfo . add ( getErrorInfo ( list . get ( i ) , "隔离状态不能为空" , i + 1 ) ) ;
list . get ( i ) . setAddStatus ( true ) ;
continue ;
}
}
Result < List < SysDictDataDTO > > isolatedState = epmetAdminOpenFeignClient . dictDataList ( "isolatedState" ) ;
if ( ! isolatedState . success ( ) ) {
throw new EpmetException ( "查询字典表数据失败..." + "isolatedState" ) ;
}
Map < String , String > dictMap = isolatedState . getData ( ) . stream ( ) . collect ( Collectors . toMap ( SysDictDataDTO : : getDictLabel , SysDictDataDTO : : getDictValue ) ) ;
if ( list . size ( ) > errorInfo . size ( ) ) {
Map < String , Long > groupByIdCard = list . stream ( ) . collect ( Collectors . groupingBy ( ImportEpidemicSpecialAttention : : getIdCard , Collectors . counting ( ) ) ) ;
Map < String , Long > groupByIdCard = list . stream ( ) . filter ( l - > StringUtils . isNotBlank ( l . getIdCard ( ) ) ) . collect ( Collectors . groupingBy ( ImportEpidemicSpecialAttention : : getIdCard , Collectors . counting ( ) ) ) ;
groupByIdCard . forEach ( ( idCard , count ) - > {
if ( Integer . valueOf ( count . toString ( ) ) . compareTo ( 1 ) ! = 0 ) {
for ( ImportEpidemicSpecialAttention i : list ) {
@ -359,6 +443,7 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
}
} ) ;
List < String > idCards = list . stream ( ) . map ( m - > m . getIdCard ( ) ) . collect ( Collectors . toList ( ) ) ;
List < IcEpidemicSpecialAttentionEntity > existsEntities = new ArrayList < > ( ) ;
List < String > existList = baseDao . getExistList ( attentionType , idCards ) ;
if ( CollectionUtils . isNotEmpty ( existList ) ) {
for ( String s : existList ) {
@ -367,10 +452,17 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
// 按照产品指示,去除提示错误信息,并不做操作
// errorInfo.add(getErrorInfo(list.get(i),"数据已存在",list.get(i).getNum()));
list . get ( i ) . setAddStatus ( true ) ;
if ( attentionType . compareTo ( NumConstant . TWO ) = = NumConstant . ZERO ) {
list . get ( i ) . setIsolatedState ( dictMap . get ( list . get ( i ) . getIsolatedState ( ) ) ) ;
existsEntities . add ( ConvertUtils . sourceToTarget ( list . get ( i ) , IcEpidemicSpecialAttentionEntity . class ) ) ;
}
continue ;
}
}
}
if ( attentionType . compareTo ( NumConstant . TWO ) = = NumConstant . ZERO & & CollectionUtils . isNotEmpty ( existsEntities ) ) {
baseDao . addExistAttention ( existsEntities , attentionType ) ;
}
}
}
Map < Boolean , List < ImportEpidemicSpecialAttention > > groupByStatus = list . stream ( ) . collect ( Collectors . groupingBy ( ImportEpidemicSpecialAttention : : getAddStatus ) ) ;
@ -378,6 +470,9 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
if ( CollectionUtils . isNotEmpty ( needInsert ) ) {
List < IcEpidemicSpecialAttentionEntity > entities = ConvertUtils . sourceToTarget ( needInsert , IcEpidemicSpecialAttentionEntity . class ) ;
entities . forEach ( e - > {
if ( attentionType . compareTo ( NumConstant . TWO ) = = NumConstant . ZERO ) {
e . setIsolatedState ( dictMap . get ( e . getIsolatedState ( ) ) ) ;
}
e . setIsAttention ( NumConstant . ONE ) ;
e . setOrgId ( agencyInfo . getId ( ) ) ;
e . setPid ( agencyInfo . getPid ( ) ) ;
@ -482,6 +577,41 @@ public class IcEpidemicSpecialAttentionServiceImpl extends BaseServiceImpl<IcEpi
return baseDao . nat ( formDTO ) ;
}
@Override
public NatPieResultDTO pie ( TokenDto tokenDto ) {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis . getStaffInfo ( tokenDto . getCustomerId ( ) , tokenDto . getUserId ( ) ) ;
if ( null = = staffInfo ) {
throw new EpmetException ( "未查询到工作人员信息" + tokenDto . getUserId ( ) ) ;
}
NatPieResultDTO result = new NatPieResultDTO ( ) ;
Result < List < SysDictDataDTO > > isolatedState = epmetAdminOpenFeignClient . dictDataList ( "isolatedState" ) ;
if ( ! isolatedState . success ( ) ) {
throw new EpmetException ( "查询字典表数据失败..." + "isolatedState" ) ;
}
List < SysDictDataDTO > data = isolatedState . getData ( ) ;
if ( CollectionUtils . isEmpty ( data ) ) {
return result ;
}
List < NatPieResultDTO . IsolatedList > conResult = new ArrayList < > ( ) ;
data . forEach ( d - > {
NatPieResultDTO . IsolatedList dto = new NatPieResultDTO . IsolatedList ( ) ;
dto . setCategoryCode ( d . getDictValue ( ) ) ;
dto . setCategoryName ( d . getDictLabel ( ) ) ;
dto . setColor ( NatPieColorEnum . getValueByKey ( d . getDictValue ( ) ) ) ;
conResult . add ( dto ) ;
} ) ;
List < NatPieResultDTO . IsolatedList > isolatedLists = baseDao . isolatedList ( staffInfo . getAgencyId ( ) ) ;
conResult . forEach ( c - > isolatedLists . stream ( ) . filter ( i - > i . getCategoryCode ( ) . equals ( c . getCategoryCode ( ) ) ) . forEach ( i - > c . setTotal ( i . getTotal ( ) ) ) ) ;
NatPieResultDTO . IsolatedList dto = new NatPieResultDTO . IsolatedList ( ) ;
dto . setCategoryCode ( "" ) ;
dto . setCategoryName ( "历史关注人数" ) ;
dto . setColor ( NatPieColorEnum . getValueByKey ( NumConstant . ONE_HUNDRED_STR ) ) ;
dto . setTotal ( baseDao . getHistoryCount ( staffInfo . getAgencyId ( ) ) ) ;
result . setIsolatedList ( conResult ) ;
result . setHistoryList ( Arrays . asList ( dto ) ) ;
return result ;
}
/ * *
* Desc : 文件上传并返回url
* @param errorRows