forked from luyan/epmet-cloud-lingshan
42 changed files with 992 additions and 13 deletions
@ -0,0 +1,49 @@ |
|||||
|
package com.epmet.commons.tools.utils.net; |
||||
|
|
||||
|
import com.tencentcloudapi.ccc.v20200210.CccClient; |
||||
|
import com.tencentcloudapi.ccc.v20200210.models.CreateSDKLoginTokenRequest; |
||||
|
import com.tencentcloudapi.ccc.v20200210.models.CreateSDKLoginTokenResponse; |
||||
|
import com.tencentcloudapi.common.Credential; |
||||
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException; |
||||
|
import com.tencentcloudapi.common.profile.ClientProfile; |
||||
|
import com.tencentcloudapi.common.profile.HttpProfile; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
|
||||
|
|
||||
|
@Slf4j |
||||
|
public class TCCCClientUtils { |
||||
|
|
||||
|
private static String SDKAPPID = "1400801042"; |
||||
|
|
||||
|
private static String USERID = "286388969@qq.com"; |
||||
|
|
||||
|
private static String SECRETID = "AKIDynW4oQr6ED0a2dIn6EC3wgFlDVjrqIbg"; |
||||
|
|
||||
|
private static String SECRETKEY = "ymRuDJI8mCRUUPFvQqCPQME0c2MbfaM2"; |
||||
|
|
||||
|
public static String getToken() { |
||||
|
try { |
||||
|
Credential cred = new Credential(SECRETID, SECRETKEY); |
||||
|
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
|
HttpProfile httpProfile = new HttpProfile(); |
||||
|
httpProfile.setEndpoint("ccc.ap-shanghai.tencentcloudapi.com"); |
||||
|
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
|
ClientProfile clientProfile = new ClientProfile(); |
||||
|
clientProfile.setHttpProfile(httpProfile); |
||||
|
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
|
CccClient client = new CccClient(cred, "", clientProfile); |
||||
|
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
|
CreateSDKLoginTokenRequest req = new CreateSDKLoginTokenRequest(); |
||||
|
req.setSdkAppId(1400801042L); |
||||
|
req.setSeatUserId("286388969@qq.com"); |
||||
|
// 返回的resp是一个CreateSDKLoginTokenResponse的实例,与请求对象对应
|
||||
|
CreateSDKLoginTokenResponse resp = client.CreateSDKLoginToken(req); |
||||
|
// 输出json格式的字符串回包
|
||||
|
System.out.println(CreateSDKLoginTokenResponse.toJsonString(resp)); |
||||
|
return CreateSDKLoginTokenResponse.toJsonString(resp); |
||||
|
} catch (TencentCloudSDKException e) { |
||||
|
log.error(e.toString()); |
||||
|
return e.toString(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.controller.tccc; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.net.TCCCClientUtils; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@RequestMapping("tccc") |
||||
|
public class TCCCAuthController { |
||||
|
|
||||
|
@RequestMapping("getTcccAuth") |
||||
|
public String getTcccAuth() { |
||||
|
try { |
||||
|
String tcccAuth = TCCCClientUtils.getToken(); |
||||
|
System.out.println(tcccAuth); |
||||
|
return tcccAuth; |
||||
|
} catch (Exception e) { |
||||
|
log.error(e.toString()); |
||||
|
return e.toString(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.epmet.resi.partymember.dto.partymember.result; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: agencyId下的党组织活动数统计 |
||||
|
* @param null: |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 7:09 PM |
||||
|
*/ |
||||
|
@Data |
||||
|
public class LingShanScreenPartyActQtyStatsResultDTO { |
||||
|
|
||||
|
private String type; |
||||
|
|
||||
|
private Collection<StatsData> data; |
||||
|
|
||||
|
@Data |
||||
|
public static class StatsData { |
||||
|
@JsonIgnore |
||||
|
private String orgId; |
||||
|
private String name; |
||||
|
@JsonIgnore |
||||
|
private String actType; |
||||
|
private Integer value; |
||||
|
} |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.epmet.resi.partymember.dto.partymember.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* 灵山大屏,党建活动和数量 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class LingShanScreenPartyActTypeAndQtyResultDTO { |
||||
|
|
||||
|
private String actTypeKey; |
||||
|
private String name; |
||||
|
private Integer value; |
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.epmet.resi.partymember.dto.partymember.result; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
/** |
||||
|
* 灵山大屏,党组织和数量dto |
||||
|
*/ |
||||
|
@Data |
||||
|
public class LingShanScreenPartyOrgCategoryResultDTO { |
||||
|
|
||||
|
private String partyOrgType; |
||||
|
private String name; |
||||
|
private Integer value; |
||||
|
|
||||
|
} |
@ -0,0 +1,60 @@ |
|||||
|
package com.epmet.resi.partymember.dto.partymember.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 灵山大屏-党组织树 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class LingShanScreenPartyOrgTreeResultDTO { |
||||
|
|
||||
|
// 中共青岛市即墨区委灵山街道工作委员会
|
||||
|
private String title; |
||||
|
|
||||
|
private List<PartyOrg> list; |
||||
|
|
||||
|
private Integer num; |
||||
|
|
||||
|
@Data |
||||
|
public static class PartyOrg { |
||||
|
|
||||
|
private String id; |
||||
|
private String pid; |
||||
|
private String name; |
||||
|
private Integer num; |
||||
|
private Integer orgType; |
||||
|
|
||||
|
/** |
||||
|
* 子级组织列表 |
||||
|
*/ |
||||
|
private List<PartyOrg> children = new ArrayList<>(); |
||||
|
|
||||
|
/** |
||||
|
* 党员列表 |
||||
|
*/ |
||||
|
private List<Partymember> list = new ArrayList<>();; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 党员信息 |
||||
|
*/ |
||||
|
@Data |
||||
|
public static class Partymember { |
||||
|
private String name; |
||||
|
private String gender; |
||||
|
private String age; |
||||
|
private String phone; |
||||
|
private String orgname; |
||||
|
private String photo; |
||||
|
private String remarks; |
||||
|
private Integer workStatus; |
||||
|
private Integer isDby; |
||||
|
private Integer isLhdy; |
||||
|
private Integer worknumber; |
||||
|
private Integer workEvent; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,120 @@ |
|||||
|
package com.epmet.modules.partymember.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.enums.PartyOrgTypeEnum; |
||||
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
||||
|
import com.epmet.commons.tools.exception.EpmetException; |
||||
|
import com.epmet.commons.tools.utils.DateUtils; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.modules.partymember.service.LingShanScreenService; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActQtyStatsResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActTypeAndQtyResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgTreeResultDTO; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
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.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("lingshanScreen") |
||||
|
@Slf4j |
||||
|
public class LingShanScreenController { |
||||
|
|
||||
|
@Autowired |
||||
|
private LingShanScreenService lingShanScreenService; |
||||
|
|
||||
|
/** |
||||
|
* @description: 党建引领,党组织和数量 |
||||
|
* @param agencyId: 当前组织id |
||||
|
* @return com.epmet.commons.tools.utils.Result |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 10:57 AM |
||||
|
*/ |
||||
|
@GetMapping("partyOrgCategoryAndQuantity") |
||||
|
public Result<List<LingShanScreenPartyOrgCategoryResultDTO>> listPartyOrgCategoryAndQuantity(@RequestParam("agencyId") String agencyId) { |
||||
|
List<LingShanScreenPartyOrgCategoryResultDTO> l = lingShanScreenService.listPartyOrgCategoryAndQuantity(agencyId); |
||||
|
return new Result().ok(l); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 党建活动类型和数量 |
||||
|
* @param agencyId: 组织id |
||||
|
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO>> |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 12:03 PM |
||||
|
*/ |
||||
|
@GetMapping("partyActTypeAndQuantity") |
||||
|
public Result<List<LingShanScreenPartyActTypeAndQtyResultDTO>> partyActTypeAndQuantity(@RequestParam("agencyId") String agencyId) { |
||||
|
List<LingShanScreenPartyActTypeAndQtyResultDTO> l = lingShanScreenService.partyActTypeAndQuantity(agencyId); |
||||
|
return new Result().ok(l); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 党组织数(只到党支部,没有小组) |
||||
|
* @param agencyId: |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 1:00 PM |
||||
|
*/ |
||||
|
@GetMapping("partyOrgTree") |
||||
|
public Result<LingShanScreenPartyOrgTreeResultDTO> getPartyOrgTree(@RequestParam("agencyId") String agencyId) { |
||||
|
LingShanScreenPartyOrgTreeResultDTO l = lingShanScreenService.getPartyOrgTree(agencyId); |
||||
|
return new Result().ok(l); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 党员列表 |
||||
|
* @param partyOrgId: 党组织id |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 3:20 PM |
||||
|
*/ |
||||
|
@GetMapping("partymemberList") |
||||
|
public Result<List<LingShanScreenPartyOrgTreeResultDTO.Partymember>> partymemberList(@RequestParam("partyOrgId") String partyOrgId) { |
||||
|
List<LingShanScreenPartyOrgTreeResultDTO.Partymember> l = lingShanScreenService.partymemberListByPartyOrgId(partyOrgId); |
||||
|
return new Result().ok(l); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: agencyId下的党组织活动数统计 |
||||
|
* @param agencyId: 行政组织id |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 7:07 PM |
||||
|
*/ |
||||
|
@GetMapping("partyActStats/actQtyOfPartyOrg") |
||||
|
public Result<List<LingShanScreenPartyActQtyStatsResultDTO>> actQtyOfPartyOrgStats(@RequestParam("agencyId") String agencyId, |
||||
|
@RequestParam("holdTimeStart") String holdTimeStartStr, |
||||
|
@RequestParam("holdTimeEnd") String holdTimeEndStr) { |
||||
|
|
||||
|
Date holdTimeStart; |
||||
|
Date holdTimeEnd; |
||||
|
try { |
||||
|
holdTimeStart = DateUtils.parse(holdTimeStartStr, DateUtils.DATE_TIME_PATTERN); |
||||
|
holdTimeEnd = DateUtils.parse(holdTimeEndStr, DateUtils.DATE_TIME_PATTERN); |
||||
|
} catch (Exception e) { |
||||
|
log.error("日期解析失败,请按指定格式传输:yyyy-MM-dd HH:mm:ss"); |
||||
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "日期解析失败"); |
||||
|
} |
||||
|
List<LingShanScreenPartyActQtyStatsResultDTO> l = lingShanScreenService.actQtyOfPartyOrgStats(agencyId, holdTimeStart, holdTimeEnd); |
||||
|
return new Result<List<LingShanScreenPartyActQtyStatsResultDTO>>().ok(l); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 大屏地图-党员数 |
||||
|
* @param agencyId: |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/17 1:54 PM |
||||
|
*/ |
||||
|
@GetMapping("partymemberQty") |
||||
|
public Result<Integer> getPartymemberQtyOfOrg(@RequestParam("agencyId") String agencyId) { |
||||
|
return new Result<Integer>().ok(lingShanScreenService.getPartymemberQtyOfOrg(agencyId)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
package com.epmet.modules.partymember.service; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActQtyStatsResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActTypeAndQtyResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgTreeResultDTO; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface LingShanScreenService { |
||||
|
/** |
||||
|
* @description: 党建引领,党组织和数量 |
||||
|
* @param agencyId: 组织id |
||||
|
* @return java.util.List<com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO> |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 11:02 AM |
||||
|
*/ |
||||
|
List<LingShanScreenPartyOrgCategoryResultDTO> listPartyOrgCategoryAndQuantity(String agencyId); |
||||
|
|
||||
|
/** |
||||
|
* @description: 党建活动类型和数量 |
||||
|
* @param agencyId: 组织id |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 12:05 PM |
||||
|
*/ |
||||
|
List<LingShanScreenPartyActTypeAndQtyResultDTO> partyActTypeAndQuantity(String agencyId); |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @param agencyId: |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 1:09 PM |
||||
|
*/ |
||||
|
LingShanScreenPartyOrgTreeResultDTO getPartyOrgTree(String agencyId); |
||||
|
|
||||
|
/** |
||||
|
* @description: 党员列表 |
||||
|
* @param partyOrgId: |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 3:22 PM |
||||
|
*/ |
||||
|
List<LingShanScreenPartyOrgTreeResultDTO.Partymember> partymemberListByPartyOrgId(String partyOrgId); |
||||
|
|
||||
|
/** |
||||
|
* @description: agencyId下的党组织活动数统计 |
||||
|
* @param agencyId: |
||||
|
* @param holdTimeStart: |
||||
|
* @param holdTimeEnd: |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 7:27 PM |
||||
|
*/ |
||||
|
List<LingShanScreenPartyActQtyStatsResultDTO> actQtyOfPartyOrgStats(String agencyId, Date holdTimeStart, Date holdTimeEnd); |
||||
|
|
||||
|
/** |
||||
|
* @description: 大屏地图-党员数 |
||||
|
* @param agencyId: |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/17 1:55 PM |
||||
|
*/ |
||||
|
Integer getPartymemberQtyOfOrg(String agencyId); |
||||
|
} |
@ -0,0 +1,323 @@ |
|||||
|
package com.epmet.modules.partymember.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.epmet.commons.tools.constant.ServiceConstant; |
||||
|
import com.epmet.commons.tools.enums.GenderEnum; |
||||
|
import com.epmet.commons.tools.enums.PartyOrgTypeEnum; |
||||
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
||||
|
import com.epmet.commons.tools.exception.EpmetException; |
||||
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
||||
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
||||
|
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
||||
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
||||
|
import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; |
||||
|
import com.epmet.commons.tools.utils.DateUtils; |
||||
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
||||
|
import com.epmet.commons.tools.utils.PidUtils; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
||||
|
import com.epmet.modules.partyOrg.dao.IcPartyActDao; |
||||
|
import com.epmet.modules.partyOrg.dao.IcPartyActTypeDictDao; |
||||
|
import com.epmet.modules.partyOrg.dao.IcPartyOrgDao; |
||||
|
import com.epmet.modules.partyOrg.entity.IcPartyActTypeDictEntity; |
||||
|
import com.epmet.modules.partyOrg.entity.IcPartyOrgEntity; |
||||
|
import com.epmet.modules.partymember.dao.IcPartyMemberDao; |
||||
|
import com.epmet.modules.partymember.entity.IcPartyMemberEntity; |
||||
|
import com.epmet.modules.partymember.service.LingShanScreenService; |
||||
|
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActQtyStatsResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActTypeAndQtyResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO; |
||||
|
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgTreeResultDTO; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.util.*; |
||||
|
import java.util.function.Function; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
@Service |
||||
|
public class LingShanScreenServiceImpl implements LingShanScreenService, ResultDataResolver { |
||||
|
|
||||
|
@Autowired |
||||
|
private IcPartyOrgDao icPartyOrgDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private IcPartyActDao partyActDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private IcPartyMemberDao icPartyMemberDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private IcPartyActTypeDictDao partyActTypeDictDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private ResiGroupOpenFeignClient groupOpenFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
||||
|
|
||||
|
@Override |
||||
|
public List<LingShanScreenPartyOrgCategoryResultDTO> listPartyOrgCategoryAndQuantity(String agencyId) { |
||||
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
||||
|
if (agencyInfo == null) { |
||||
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
||||
|
} |
||||
|
|
||||
|
// 1.查询党组织
|
||||
|
List<LingShanScreenPartyOrgCategoryResultDTO> l = icPartyOrgDao |
||||
|
.listPartyOrgCategoryAndQuantity(EpmetRequestHolder.getLoginUserCustomerId(), agencyId, PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids())); |
||||
|
|
||||
|
// 给组织类型名字赋值
|
||||
|
l.forEach(i -> { |
||||
|
PartyOrgTypeEnum partyOrgTypeEnum = PartyOrgTypeEnum.getEnumByCode(i.getPartyOrgType()); |
||||
|
if (partyOrgTypeEnum != null) { |
||||
|
i.setName(partyOrgTypeEnum.getName()); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 2.查询党小组
|
||||
|
Integer groupQty = getResultDataOrReturnNull(groupOpenFeignClient.getPartyGroupQuantityByAgencyId(agencyId), ServiceConstant.RESI_GROUP_SERVER); |
||||
|
if (groupQty == null) { |
||||
|
logger.error("【灵山大屏】党建引领-查询党小组信息失败,agencyId:" + agencyId); |
||||
|
groupQty = 0; |
||||
|
} |
||||
|
|
||||
|
LingShanScreenPartyOrgCategoryResultDTO gq = new LingShanScreenPartyOrgCategoryResultDTO(); |
||||
|
gq.setName("党小组"); |
||||
|
gq.setPartyOrgType(null); |
||||
|
gq.setValue(groupQty); |
||||
|
l.add(gq); |
||||
|
|
||||
|
return l; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<LingShanScreenPartyActTypeAndQtyResultDTO> partyActTypeAndQuantity(String agencyId) { |
||||
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
||||
|
if (agencyInfo == null) { |
||||
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
||||
|
} |
||||
|
return partyActDao.getPartyActTypeAndQuantity(EpmetRequestHolder.getLoginUserCustomerId(), PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids())); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public LingShanScreenPartyOrgTreeResultDTO getPartyOrgTree(String agencyId) { |
||||
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
||||
|
if (agencyInfo == null) { |
||||
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
||||
|
} |
||||
|
|
||||
|
String orgIdpath = PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids()); |
||||
|
|
||||
|
// 1。查询组织
|
||||
|
// 先查党委以上级别的,含党委
|
||||
|
List<LingShanScreenPartyOrgTreeResultDTO.PartyOrg> l = icPartyOrgDao.getPartyOrgsLteDangwei(EpmetRequestHolder.getLoginUserCustomerId(), agencyId, orgIdpath); |
||||
|
// 再查党支部的。因为党委查询的时候使用pids和党支部的时候使用起来不一样,所以要分开
|
||||
|
List<LingShanScreenPartyOrgTreeResultDTO.PartyOrg> s = icPartyOrgDao.getPartyOrgsOfBranch(EpmetRequestHolder.getLoginUserCustomerId(), agencyId, orgIdpath); |
||||
|
|
||||
|
l.addAll(s); |
||||
|
|
||||
|
// 2.组装树了开始
|
||||
|
Map<String, LingShanScreenPartyOrgTreeResultDTO.PartyOrg> lMap = l.stream().collect(Collectors.toMap(e -> e.getId(), Function.identity())); |
||||
|
|
||||
|
// 树根组织的id
|
||||
|
String parentPartyOrgId = null; |
||||
|
// 最高的组织级别,用于找到树根。初始值给个100,大一点,不影响
|
||||
|
Integer maxLevel = 100; |
||||
|
// 将组织放入到父组织的children列表中
|
||||
|
for (Iterator<LingShanScreenPartyOrgTreeResultDTO.PartyOrg> it = l.iterator(); it.hasNext();) { |
||||
|
LingShanScreenPartyOrgTreeResultDTO.PartyOrg e = it.next(); |
||||
|
LingShanScreenPartyOrgTreeResultDTO.PartyOrg pOrg = lMap.get(e.getPid()); |
||||
|
|
||||
|
if (maxLevel > e.getOrgType()) { |
||||
|
maxLevel = e.getOrgType(); |
||||
|
parentPartyOrgId = e.getId(); |
||||
|
} |
||||
|
|
||||
|
if (pOrg != null) { |
||||
|
pOrg.getChildren().add(e); |
||||
|
// 修剪枝叶
|
||||
|
it.remove(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
LingShanScreenPartyOrgTreeResultDTO.PartyOrg parentOrg = lMap.get(parentPartyOrgId); |
||||
|
LingShanScreenPartyOrgTreeResultDTO r = new LingShanScreenPartyOrgTreeResultDTO(); |
||||
|
r.setTitle(parentOrg.getName()); |
||||
|
r.setNum(parentOrg.getNum()); |
||||
|
r.setList(parentOrg.getChildren()); |
||||
|
return r; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<LingShanScreenPartyOrgTreeResultDTO.Partymember> partymemberListByPartyOrgId(String partyOrgId) { |
||||
|
IcPartyOrgEntity partyOrg = icPartyOrgDao.selectById(partyOrgId); |
||||
|
LambdaQueryWrapper<IcPartyMemberEntity> query = null; |
||||
|
if (partyOrg == null) { |
||||
|
String baseErrorMsg = "【灵山大屏】党组织下的党员列表-未找到党组织信息。"; |
||||
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), String.format(baseErrorMsg + "partyOrgId:" + partyOrg), baseErrorMsg); |
||||
|
} else if (Integer.valueOf(partyOrg.getPartyOrgType()) >= 4) { |
||||
|
// 0省委,1市委,2区委,3党工委,4党委,5支部。党委以上,除了支部
|
||||
|
query = new LambdaQueryWrapper<>(); |
||||
|
query.eq(IcPartyMemberEntity::getOrgPids, PidUtils.convertPid2OrgIdPath(partyOrgId, partyOrg.getOrgPids())); |
||||
|
query.eq(IcPartyMemberEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
||||
|
} else { |
||||
|
// 5支部
|
||||
|
query = new LambdaQueryWrapper<>(); |
||||
|
query.eq(IcPartyMemberEntity::getOrgPids, partyOrg.getOrgPids()); |
||||
|
query.eq(IcPartyMemberEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
||||
|
} |
||||
|
|
||||
|
List<IcPartyMemberEntity> l = icPartyMemberDao.selectList(query); |
||||
|
|
||||
|
// 党员列表转化为需要的dto返回
|
||||
|
return l.stream().map(e -> { |
||||
|
// 查询支部
|
||||
|
IcPartyOrgEntity branch = icPartyOrgDao.selectById(e.getSszb()); |
||||
|
// 查询居民信息,用于显示年龄
|
||||
|
IcResiUserInfoCache resiInfo = CustomerResiUserRedis.getIcResiUserInfo(e.getIcResiUser()); |
||||
|
|
||||
|
LingShanScreenPartyOrgTreeResultDTO.Partymember t = new LingShanScreenPartyOrgTreeResultDTO.Partymember(); |
||||
|
|
||||
|
String birthDay; |
||||
|
if (resiInfo != null |
||||
|
&& StringUtils.isNotBlank(birthDay = resiInfo.getBirthday())) { |
||||
|
Date birthday = DateUtils.parse(birthDay, DateUtils.DATE_PATTERN); |
||||
|
Calendar ci = Calendar.getInstance(); |
||||
|
ci.setTime(birthday); |
||||
|
int birthYear = ci.get(Calendar.YEAR); |
||||
|
t.setAge((LocalDate.now().getYear() - birthYear) + ""); |
||||
|
} |
||||
|
|
||||
|
t.setName(e.getName()); |
||||
|
Integer gender = e.getGender(); |
||||
|
t.setGender(gender != null ? GenderEnum.getName(gender.toString()) : "未知"); |
||||
|
t.setOrgname(branch != null ? branch.getPartyOrgName() : null); |
||||
|
t.setPhone(e.getMobile()); |
||||
|
t.setRemarks(e.getRemark()); |
||||
|
t.setPhoto(e.getHeadPhoto()); |
||||
|
// t.setIsDby();
|
||||
|
// t.setIsLhdy();
|
||||
|
// t.setWorkStatus();
|
||||
|
// t.setWorknumber();
|
||||
|
// t.setWorkEvent();
|
||||
|
return t; |
||||
|
}).collect(Collectors.toList()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 这个方法其实有更容易实现,更容易阅读和理解的方式。循环活动类型,每个活动类型都查询一次统计数据即可。 |
||||
|
* 但是前期追求更少次数的数据库调用以提升效率,越写越复杂,既然已经这样了也懒得改了,就这样吧。 |
||||
|
* 如果后面有人感觉维护不了了,直接按照上述方式重写就行了,不要犹豫,不要徘徊,很容易改,没有暗雷!!! |
||||
|
* @param agencyId: 行政组织id |
||||
|
* @return |
||||
|
* @author: WangXianZhang |
||||
|
* @date: 2023/4/14 11:33 PM |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<LingShanScreenPartyActQtyStatsResultDTO> actQtyOfPartyOrgStats(String agencyId, Date holdTimeStart, Date holdTimeEnd) { |
||||
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
||||
|
if (agencyInfo == null) { |
||||
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
||||
|
} |
||||
|
|
||||
|
// String orgIdpath = PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids());
|
||||
|
|
||||
|
// 先查当前党组织信息
|
||||
|
LambdaQueryWrapper<IcPartyOrgEntity> currentPartyOrgQuery = new LambdaQueryWrapper<>(); |
||||
|
currentPartyOrgQuery.eq(IcPartyOrgEntity::getAgencyId, agencyId); |
||||
|
currentPartyOrgQuery.orderByAsc(IcPartyOrgEntity::getPartyOrgType); |
||||
|
currentPartyOrgQuery.last(" limit 1 "); |
||||
|
|
||||
|
IcPartyOrgEntity currentPartyOrg = icPartyOrgDao.selectOne(currentPartyOrgQuery); |
||||
|
|
||||
|
if (currentPartyOrg == null) { |
||||
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到党组织信息"); |
||||
|
} |
||||
|
|
||||
|
// ----------------------------要重写的话,上面建议保留噢,只重写下面就可以了,淦---------------------------------
|
||||
|
|
||||
|
// 找出当前党组织的下级党组织(全部),及其对应的活动数量
|
||||
|
List<LingShanScreenPartyActQtyStatsResultDTO.StatsData> l = partyActDao.actQtyOfPartyOrgStats(currentPartyOrg.getId(), holdTimeStart, holdTimeEnd); |
||||
|
|
||||
|
// 将结果遍历,分成2个纬度,分别建立地址引用
|
||||
|
// Map<actType, Map<orgId, LingShanScreenPartyActQtyStatsResultDTO.StatsData>>
|
||||
|
Map<String, Map<String, LingShanScreenPartyActQtyStatsResultDTO.StatsData>> orgDimMap = new HashMap<>(); |
||||
|
HashMap<String, String> orgIdAndName = new HashMap<>(); |
||||
|
|
||||
|
l.forEach(e -> { |
||||
|
orgIdAndName.put(e.getOrgId(), e.getName()); |
||||
|
String actType = e.getActType(); |
||||
|
if (StringUtils.isNotBlank(actType)) { |
||||
|
// 不为空,说明该类型有活动数据
|
||||
|
Map<String, LingShanScreenPartyActQtyStatsResultDTO.StatsData> m = orgDimMap.get(actType); |
||||
|
if (m == null) { |
||||
|
m = new HashMap<>(); |
||||
|
orgDimMap.put(actType, m); |
||||
|
} |
||||
|
m.put(e.getOrgId(), e); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 所有的活动类型,并且建立字典,供后续使用
|
||||
|
LambdaQueryWrapper<IcPartyActTypeDictEntity> actTypeQuery = new LambdaQueryWrapper<>(); |
||||
|
actTypeQuery.eq(IcPartyActTypeDictEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
||||
|
List<IcPartyActTypeDictEntity> actTypes = partyActTypeDictDao.selectList(actTypeQuery); |
||||
|
|
||||
|
Map<String, String> actTypeKeyAndName = actTypes.stream().collect(Collectors.toMap(IcPartyActTypeDictEntity::getTypeKey, IcPartyActTypeDictEntity::getTypeName)); |
||||
|
|
||||
|
// 二维遍历,外层活动类型,内层组织id。确保两个维度的坐标都是全的(哪怕value=0)
|
||||
|
for (IcPartyActTypeDictEntity actType : actTypes) { |
||||
|
// 补全外层活动类型
|
||||
|
Map<String, LingShanScreenPartyActQtyStatsResultDTO.StatsData> orgIdAndStats = orgDimMap.get(actType.getTypeKey()); |
||||
|
if (orgIdAndStats == null) { |
||||
|
orgIdAndStats = new HashMap<>(); |
||||
|
orgDimMap.put(actType.getTypeKey(), orgIdAndStats); |
||||
|
} |
||||
|
|
||||
|
// 为活动类型补全组织列表(没有活动的组织赋值0)
|
||||
|
for (Map.Entry<String, String> entry : orgIdAndName.entrySet()) { |
||||
|
String orgId = entry.getKey(); |
||||
|
LingShanScreenPartyActQtyStatsResultDTO.StatsData statsData = orgIdAndStats.get(orgId); |
||||
|
if (statsData == null) { |
||||
|
LingShanScreenPartyActQtyStatsResultDTO.StatsData e = new LingShanScreenPartyActQtyStatsResultDTO.StatsData(); |
||||
|
e.setOrgId(orgId); |
||||
|
e.setName(entry.getValue()); |
||||
|
e.setValue(0); |
||||
|
e.setActType(actType.getTypeKey()); |
||||
|
orgIdAndStats.put(orgId, e); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 将结果map转化为list,返回
|
||||
|
ArrayList<LingShanScreenPartyActQtyStatsResultDTO> rl = new ArrayList<>(); |
||||
|
|
||||
|
orgDimMap.forEach((actType, orgStatsMap) -> { |
||||
|
LingShanScreenPartyActQtyStatsResultDTO re = new LingShanScreenPartyActQtyStatsResultDTO(); |
||||
|
re.setType(actTypeKeyAndName.get(actType)); |
||||
|
re.setData(orgStatsMap.values()); |
||||
|
rl.add(re); |
||||
|
}); |
||||
|
|
||||
|
return rl; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Integer getPartymemberQtyOfOrg(String agencyId) { |
||||
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
||||
|
if (agencyInfo == null) { |
||||
|
logger.error("getPartymemberQtyOfOrg查询组织信息失败agencyId:{}", agencyId); |
||||
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
||||
|
} |
||||
|
|
||||
|
LambdaQueryWrapper<IcPartyMemberEntity> query = new LambdaQueryWrapper<>(); |
||||
|
query.likeRight(IcPartyMemberEntity::getAgencyPids, PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids())) |
||||
|
.or() |
||||
|
.eq(IcPartyMemberEntity::getAgencyId, agencyId); |
||||
|
return icPartyMemberDao.selectCount(query); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue