forked from luyan/epmet-cloud-lingshan
18 changed files with 482 additions and 6 deletions
@ -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,65 @@ |
|||||
|
package com.epmet.modules.partymember.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.enums.PartyOrgTypeEnum; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.modules.partymember.service.LingShanScreenService; |
||||
|
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.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); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.epmet.modules.partymember.service; |
||||
|
|
||||
|
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.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); |
||||
|
} |
@ -0,0 +1,130 @@ |
|||||
|
package com.epmet.modules.partymember.service.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.ServiceConstant; |
||||
|
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.bean.AgencyInfoCache; |
||||
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
||||
|
import com.epmet.commons.tools.utils.PidUtils; |
||||
|
import com.epmet.modules.partyOrg.dao.IcPartyActDao; |
||||
|
import com.epmet.modules.partyOrg.dao.IcPartyOrgDao; |
||||
|
import com.epmet.modules.partymember.service.LingShanScreenService; |
||||
|
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; |
||||
|
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.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Iterator; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
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 ResiGroupOpenFeignClient groupOpenFeignClient; |
||||
|
|
||||
|
@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())); |
||||
|
|
||||
|
String parentPartyOrgId = null; |
||||
|
|
||||
|
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; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue