forked from luyan/epmet-cloud-lingshan
17 changed files with 480 additions and 33 deletions
@ -0,0 +1,25 @@ |
|||
package com.epmet.dataaggre.dto.epmetuser.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 灵山代办,代办员列表 |
|||
* @Author wangxianzhang |
|||
* @Time 2023/5/9 4:26 PM |
|||
*/ |
|||
@Data |
|||
public class LingshanServiceAgentAgentList { |
|||
|
|||
private String gridId; |
|||
private String orgNamePath; |
|||
private String agentId; |
|||
private String agentName; |
|||
private Integer gender; |
|||
private String genderDisplay; |
|||
private Integer age; |
|||
private String cultureDisplay; |
|||
private Integer culture; |
|||
private String mobile; |
|||
private String idCard; |
|||
|
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.epmet.dataaggre.beans; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class LingShanAgentServiceStaffAndGrid { |
|||
private String staffId; |
|||
|
|||
private String gridId; |
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.epmet.dataaggre.beans; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class StaffInfoInGridOfRole { |
|||
private String staffId; |
|||
private String staffName; |
|||
private Integer gender; |
|||
private Integer age; |
|||
private Integer culture; |
|||
private String mobile; |
|||
private String idCard; |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.epmet.dataaggre.controller; |
|||
|
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dataaggre.dto.epmetuser.result.LingshanServiceAgentAgentList; |
|||
import com.epmet.dataaggre.service.LingShanServiceAgentService; |
|||
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; |
|||
|
|||
@RestController |
|||
@RequestMapping("lingshan/serviceAgent") |
|||
public class LingShanServiceAgentController { |
|||
|
|||
@Autowired |
|||
private LingShanServiceAgentService lingShanServiceAgentService; |
|||
|
|||
/** |
|||
* @description: 工作端pc,代办员列表 |
|||
* @param pageNo: |
|||
* @param pageSize: |
|||
* @param orgId: |
|||
* @param orgType: |
|||
* @param agentName: |
|||
* @param mobile: |
|||
* @param idCard: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/5/9 4:30 PM |
|||
*/ |
|||
@GetMapping("workpc/agentList") |
|||
public Result<PageData<LingshanServiceAgentAgentList>> workPcAgentList(@RequestParam("pageNo") Integer pageNo, |
|||
@RequestParam("pageSize") Integer pageSize, |
|||
@RequestParam("orgId") String orgId, |
|||
@RequestParam("orgType") String orgType, |
|||
@RequestParam("agentName") String agentName, |
|||
@RequestParam("mobile") Integer mobile, |
|||
@RequestParam("idCard") Integer idCard) { |
|||
|
|||
PageData<LingshanServiceAgentAgentList> pd = lingShanServiceAgentService.workPcAgentList(orgId, orgType, agentName, mobile, idCard, pageNo, pageSize); |
|||
return new Result<PageData<LingshanServiceAgentAgentList>>().ok(pd); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.epmet.dataaggre.service; |
|||
|
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dataaggre.dto.epmetuser.result.LingshanServiceAgentAgentList; |
|||
|
|||
public interface LingShanServiceAgentService { |
|||
PageData<LingshanServiceAgentAgentList> workPcAgentList(String orgId, String orgType, String agentName, Integer mobile, Integer idCard, Integer pageNo, Integer pageSize); |
|||
} |
@ -0,0 +1,128 @@ |
|||
package com.epmet.dataaggre.service.impl; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.enums.DictTypeEnum; |
|||
import com.epmet.commons.tools.enums.GenderEnum; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|||
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|||
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.utils.PidUtils; |
|||
import com.epmet.constant.OrgInfoConstant; |
|||
import com.epmet.constant.RoleKeyConstants; |
|||
import com.epmet.dataaggre.beans.LingShanAgentServiceStaffAndGrid; |
|||
import com.epmet.dataaggre.beans.StaffInfoInGridOfRole; |
|||
import com.epmet.dataaggre.dto.epmetuser.result.LingshanServiceAgentAgentList; |
|||
import com.epmet.dataaggre.service.LingShanServiceAgentService; |
|||
import com.epmet.dataaggre.service.epmetuser.EpmetUserService; |
|||
import com.epmet.dataaggre.service.govorg.GovOrgService; |
|||
import com.epmet.dto.SysDictDataDTO; |
|||
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.sql.Array; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class LingShanServiceAgentServiceImpl implements LingShanServiceAgentService, ResultDataResolver { |
|||
|
|||
@Autowired |
|||
private EpmetUserService epmetUserService; |
|||
|
|||
@Autowired |
|||
private GovOrgService govOrgService; |
|||
|
|||
@Autowired |
|||
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|||
|
|||
@Override |
|||
public PageData<LingshanServiceAgentAgentList> workPcAgentList(String orgId, String orgType, String agentName, Integer mobile, Integer idCard, |
|||
Integer pageNo, Integer pageSize) { |
|||
|
|||
// 1个人可能属于多个wangge
|
|||
Map<String, List<String>> staffIdAndGridIds = new HashMap<>(); |
|||
Set<String> staffIds = new HashSet<>(); |
|||
|
|||
// 得到staffIds和staffIdAndGridIds
|
|||
if (OrgInfoConstant.AGENCY.equals(orgType)) { |
|||
// agency
|
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(orgId); |
|||
List<LingShanAgentServiceStaffAndGrid> sags = govOrgService.getStaffAndItsBelongsGridByAgencyIdPath(PidUtils.convertPid2OrgIdPath(agencyInfo.getId(), agencyInfo.getPids())); |
|||
for (LingShanAgentServiceStaffAndGrid sag : sags) { |
|||
staffIds.add(sag.getStaffId()); |
|||
|
|||
List<String> gridIds = staffIdAndGridIds.get(sag.getStaffId()); |
|||
if (CollectionUtils.isEmpty(gridIds)) { |
|||
gridIds = new ArrayList<>(); |
|||
staffIdAndGridIds.put(sag.getStaffId(), gridIds); |
|||
} |
|||
|
|||
gridIds.add(sag.getGridId()); |
|||
} |
|||
} else if (OrgInfoConstant.GRID.equals(orgType)) { |
|||
// 网格
|
|||
staffIds = govOrgService.getStaffIdsInGrid(orgId); |
|||
for (String staffId : staffIds) { |
|||
staffIdAndGridIds.put(staffId, Arrays.asList(orgId)); |
|||
} |
|||
} |
|||
|
|||
// 开始查询staff列表
|
|||
PageData<StaffInfoInGridOfRole> pd = epmetUserService.staffListInGridsOfRole(RoleKeyConstants.ROLE_KEY_AGENT, staffIds, agentName, mobile, idCard, pageNo, pageSize); |
|||
|
|||
if (pd == null) { |
|||
return new PageData(new ArrayList(), 0); |
|||
} |
|||
|
|||
// 性别字典
|
|||
List<SysDictDataDTO> edus = getResultDataOrReturnNull(adminOpenFeignClient.dictDataList(DictTypeEnum.EDUCATION.getCode()), ServiceConstant.EPMET_ADMIN_SERVER); |
|||
Map<String, String> eduMap = edus.stream().collect(Collectors.toMap(SysDictDataDTO::getDictValue, SysDictDataDTO::getDictLabel)); |
|||
|
|||
// 转换为dto
|
|||
List<LingshanServiceAgentAgentList> rl = pd.getList().stream().map(e -> { |
|||
LingshanServiceAgentAgentList d = new LingshanServiceAgentAgentList(); |
|||
d.setAgentName(e.getStaffName()); |
|||
d.setAgentId(e.getStaffId()); |
|||
d.setGender(e.getGender()); |
|||
d.setGenderDisplay(GenderEnum.getName(e.getGender().toString())); |
|||
d.setAge(e.getAge()); |
|||
d.setCulture(e.getCulture()); |
|||
if (e.getCulture() != null) { |
|||
d.setCultureDisplay(eduMap.get(e.getCulture().toString())); |
|||
} |
|||
d.setMobile(e.getMobile()); |
|||
d.setIdCard(e.getIdCard()); |
|||
|
|||
// 组织名称
|
|||
d.setOrgNamePath(getOrgNamePath(staffIdAndGridIds.get(e.getStaffId()))); |
|||
return d; |
|||
}).collect(Collectors.toList()); |
|||
|
|||
return new PageData<>(rl, pd.getTotal()); |
|||
} |
|||
|
|||
/** |
|||
* 通过gridid列表,拼接处组织名称path,例如:开发者社区-Java第一网格,开发者社区-Python第一网格 |
|||
*/ |
|||
private String getOrgNamePath(List<String> gridIds) { |
|||
List<String> orgNames = gridIds.stream().map(gridId -> { |
|||
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(gridId); |
|||
if (gridInfo == null) { |
|||
return null; |
|||
} |
|||
|
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(gridInfo.getPid()); |
|||
String agencyName = agencyInfo.getOrganizationName(); |
|||
return agencyName.concat("-").concat(gridInfo.getGridName()); |
|||
}).filter(Objects::nonNull).collect(Collectors.toList()); |
|||
|
|||
return String.join(",", orgNames); |
|||
} |
|||
|
|||
|
|||
} |
Loading…
Reference in new issue