forked from luyan/epmet-cloud-lingshan
18 changed files with 303 additions and 1 deletions
@ -0,0 +1,25 @@ |
|||
package com.epmet.dto.result.lingshan; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class LingShanSpecialCrowdStatsByOrgResultDTO { |
|||
|
|||
private String orgId; |
|||
|
|||
private String orgIdPath; |
|||
/** |
|||
* 组织层级。agency:行政组织。grid:网格 |
|||
*/ |
|||
private String orgType; |
|||
/** |
|||
* 组织名称 |
|||
*/ |
|||
private String orgName; |
|||
/** |
|||
* 数量 |
|||
*/ |
|||
private Integer quantity = 0; |
|||
|
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.epmet.dto.result.lingshan; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@Data |
|||
public class LingShanSpecialCrowdStatsBySpecialTypeResultDTO { |
|||
|
|||
private String specialType; |
|||
private String specialTypeName; |
|||
private Integer quantity; |
|||
|
|||
} |
@ -0,0 +1,52 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.result.lingshan.LingShanSpecialCrowdStatsByOrgResultDTO; |
|||
import com.epmet.dto.result.lingshan.LingShanSpecialCrowdStatsBySpecialTypeResultDTO; |
|||
import com.epmet.service.LingShanScreenService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 灵山大屏 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("lingshanScreen") |
|||
public class LingShanScreenController { |
|||
|
|||
@Autowired |
|||
private LingShanScreenService lingShanScreenService; |
|||
|
|||
/** |
|||
* @description: 特殊人群-按组织分组统计数量 |
|||
* @param parentAgencyId: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/27 10:20 AM |
|||
*/ |
|||
@GetMapping("specialCrowdStats/qtyOfSubOrg") |
|||
public Result specialCrowdStatsCountBySubOrg(@RequestParam("parentAgencyId") String parentAgencyId) { |
|||
|
|||
List<LingShanSpecialCrowdStatsByOrgResultDTO> l = lingShanScreenService.specialCrowdStatsCountBySubOrg(parentAgencyId); |
|||
return new Result().ok(l); |
|||
} |
|||
|
|||
/** |
|||
* @description: 组织下每一类人群数量 |
|||
* @param parentAgencyId: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/27 12:16 PM |
|||
*/ |
|||
@GetMapping("specialCrowdStats/qtyOfSpecialType") |
|||
public Result specialCrowdStatsCountBySpecialType(@RequestParam("parentAgencyId") String parentAgencyId) { |
|||
List<LingShanSpecialCrowdStatsBySpecialTypeResultDTO> l = lingShanScreenService.specialCrowdStatsCountBySpecialType(parentAgencyId); |
|||
return new Result().ok(l); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.dto.result.lingshan.LingShanSpecialCrowdStatsByOrgResultDTO; |
|||
import com.epmet.dto.result.lingshan.LingShanSpecialCrowdStatsBySpecialTypeResultDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface LingShanScreenService { |
|||
|
|||
|
|||
List<LingShanSpecialCrowdStatsByOrgResultDTO> specialCrowdStatsCountBySubOrg(String parentAgencyId); |
|||
|
|||
List<LingShanSpecialCrowdStatsBySpecialTypeResultDTO> specialCrowdStatsCountBySpecialType(String parentAgencyId); |
|||
} |
@ -0,0 +1,108 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|||
import com.epmet.commons.tools.utils.PidUtils; |
|||
import com.epmet.constant.LevelConstant; |
|||
import com.epmet.dao.*; |
|||
import com.epmet.dto.result.SubOrgResDTO; |
|||
import com.epmet.dto.result.lingshan.LingShanSpecialCrowdStatsByOrgResultDTO; |
|||
import com.epmet.dto.result.lingshan.LingShanSpecialCrowdStatsBySpecialTypeResultDTO; |
|||
import com.epmet.entity.*; |
|||
import com.epmet.enums.LingShanSpecialCrowdTypeEnums; |
|||
import com.epmet.feign.GovOrgOpenFeignClient; |
|||
import com.epmet.service.LingShanScreenService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class LingShanScreenServiceImpl implements LingShanScreenService, ResultDataResolver { |
|||
|
|||
@Autowired |
|||
private LingshanSpecialCrowdDetailXfryDao xfryDao; |
|||
|
|||
@Autowired |
|||
private LingshanSpecialCrowdDetailAzbjDao azbjDao; |
|||
|
|||
@Autowired |
|||
private LingshanSpecialCrowdDetailJdryDao jdryDao; |
|||
|
|||
@Autowired |
|||
private LingshanSpecialCrowdDetailJzhzDao jzhzDao; |
|||
|
|||
@Autowired |
|||
private LingshanSpecialCrowdDetailSqjzDao sqjzDao; |
|||
|
|||
@Autowired |
|||
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|||
|
|||
@Override |
|||
public List<LingShanSpecialCrowdStatsByOrgResultDTO> specialCrowdStatsCountBySubOrg(String parentAgencyId) { |
|||
List<SubOrgResDTO> subOrgs = getResultDataOrThrowsException(govOrgOpenFeignClient.subOrgList(parentAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, null); |
|||
List<String> orgIdPaths = subOrgs.stream().map(sub -> PidUtils.convertPid2OrgIdPath(sub.getOrgId(), sub.getPids())).collect(Collectors.toList()); |
|||
|
|||
List<LingShanSpecialCrowdStatsByOrgResultDTO> rl = subOrgs.stream().map(sub -> { |
|||
LingShanSpecialCrowdStatsByOrgResultDTO t = new LingShanSpecialCrowdStatsByOrgResultDTO(); |
|||
t.setOrgId(sub.getOrgId()); |
|||
t.setOrgName(sub.getOrgName()); |
|||
t.setOrgType(sub.getOrgType()); |
|||
t.setOrgIdPath(PidUtils.convertPid2OrgIdPath(sub.getOrgId(), sub.getPids())); |
|||
return t; |
|||
}).collect(Collectors.toList()); |
|||
|
|||
|
|||
List<LingShanSpecialCrowdStatsByOrgResultDTO> ol = azbjDao.statsCountsByOrgIds(orgIdPaths); |
|||
ol.addAll(sqjzDao.statsCountsByOrgIds(orgIdPaths)); |
|||
ol.addAll(xfryDao.statsCountsByOrgIds(orgIdPaths)); |
|||
ol.addAll(jdryDao.statsCountsByOrgIds(orgIdPaths)); |
|||
ol.addAll(jzhzDao.statsCountsByOrgIds(orgIdPaths)); |
|||
|
|||
// 开始给rl++
|
|||
for (LingShanSpecialCrowdStatsByOrgResultDTO o : ol) { |
|||
for (LingShanSpecialCrowdStatsByOrgResultDTO r : rl) { |
|||
if (o.getOrgIdPath().contains(r.getOrgIdPath())) { |
|||
// 如果ol中的数据,orgIdPath包含了这个组织的orgIdPath,说明这条数据就是这个组织的数据,那就++把
|
|||
r.setQuantity(r.getQuantity() + o.getQuantity()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return rl; |
|||
} |
|||
|
|||
@Override |
|||
public List<LingShanSpecialCrowdStatsBySpecialTypeResultDTO> specialCrowdStatsCountBySpecialType(String parentAgencyId) { |
|||
String orgIdPath = CustomerOrgRedis.getOrgIdPath(parentAgencyId, LevelConstant.AGENCY); |
|||
|
|||
ArrayList<LingShanSpecialCrowdStatsBySpecialTypeResultDTO> l = new ArrayList<>(); |
|||
|
|||
LambdaQueryWrapper<LingshanSpecialCrowdDetailAzbjEntity> azbjq = new LambdaQueryWrapper<>(); |
|||
azbjq.likeRight(LingshanSpecialCrowdDetailAzbjEntity::getOrgIdPath, orgIdPath); |
|||
l.add(new LingShanSpecialCrowdStatsBySpecialTypeResultDTO(LingShanSpecialCrowdTypeEnums.AZBJ.getType(), LingShanSpecialCrowdTypeEnums.AZBJ.getName(), azbjDao.selectCount(azbjq))); |
|||
|
|||
LambdaQueryWrapper<LingshanSpecialCrowdDetailSqjzEntity> sqjzq = new LambdaQueryWrapper<>(); |
|||
sqjzq.likeRight(LingshanSpecialCrowdDetailSqjzEntity::getOrgIdPath, orgIdPath); |
|||
l.add(new LingShanSpecialCrowdStatsBySpecialTypeResultDTO(LingShanSpecialCrowdTypeEnums.SQJZ.getType(), LingShanSpecialCrowdTypeEnums.SQJZ.getName(), sqjzDao.selectCount(sqjzq))); |
|||
|
|||
LambdaQueryWrapper<LingshanSpecialCrowdDetailXfryEntity> xfryq = new LambdaQueryWrapper<>(); |
|||
xfryq.likeRight(LingshanSpecialCrowdDetailXfryEntity::getOrgIdPath, orgIdPath); |
|||
l.add(new LingShanSpecialCrowdStatsBySpecialTypeResultDTO(LingShanSpecialCrowdTypeEnums.XFRY.getType(), LingShanSpecialCrowdTypeEnums.XFRY.getName(), xfryDao.selectCount(xfryq))); |
|||
|
|||
LambdaQueryWrapper<LingshanSpecialCrowdDetailJdryEntity> jdryq = new LambdaQueryWrapper<>(); |
|||
jdryq.likeRight(LingshanSpecialCrowdDetailJdryEntity::getOrgIdPath, orgIdPath); |
|||
l.add(new LingShanSpecialCrowdStatsBySpecialTypeResultDTO(LingShanSpecialCrowdTypeEnums.JDRY.getType(), LingShanSpecialCrowdTypeEnums.JDRY.getName(), jdryDao.selectCount(jdryq))); |
|||
|
|||
LambdaQueryWrapper<LingshanSpecialCrowdDetailJzhzEntity> jzhzq = new LambdaQueryWrapper<>(); |
|||
jzhzq.likeRight(LingshanSpecialCrowdDetailJzhzEntity::getOrgIdPath, orgIdPath); |
|||
l.add(new LingShanSpecialCrowdStatsBySpecialTypeResultDTO(LingShanSpecialCrowdTypeEnums.JZHZ.getType(), LingShanSpecialCrowdTypeEnums.JZHZ.getName(), jzhzDao.selectCount(jzhzq))); |
|||
|
|||
return l; |
|||
} |
|||
} |
Loading…
Reference in new issue