forked from rongchao/epmet-cloud-rizhao
				
			
				 19 changed files with 352 additions and 5 deletions
			
			
		@ -0,0 +1,28 @@ | 
				
			|||||
 | 
					package com.epmet.dto.form; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import lombok.Data; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.io.Serializable; | 
				
			||||
 | 
					import java.util.List; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * @author zhaoqifeng | 
				
			||||
 | 
					 * @dscription | 
				
			||||
 | 
					 * @date 2020/4/23 15:45 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Data | 
				
			||||
 | 
					public class StaffsInAgencyFromDTO implements Serializable { | 
				
			||||
 | 
						private static final long serialVersionUID = 1L; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 客户ID | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private String customerId; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 机关ID | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private String agencyId; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 用户ID | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private List<String> staffList; | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,38 @@ | 
				
			|||||
 | 
					package com.epmet.dto.result; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import lombok.Data; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.io.Serializable; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * @author zhaoqifeng | 
				
			||||
 | 
					 * @dscription | 
				
			||||
 | 
					 * @date 2020/4/23 16:08 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Data | 
				
			||||
 | 
					public class StaffInfoResultDTO implements Serializable { | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 用户ID | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private String staffId; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 用户姓名 | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private String staffName; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 头像 | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private String staffHeadPhoto; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 性别 | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private Integer gender; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 是否禁用(未禁用enable,已禁用disabled) | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private String enableFlag; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 权限名 | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private String roleName; | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,27 @@ | 
				
			|||||
 | 
					package com.epmet.dto.result; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import lombok.Data; | 
				
			||||
 | 
					import lombok.NoArgsConstructor; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.io.Serializable; | 
				
			||||
 | 
					import java.util.List; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * @author zhaoqifeng | 
				
			||||
 | 
					 * @dscription | 
				
			||||
 | 
					 * @date 2020/4/23 15:58 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@NoArgsConstructor | 
				
			||||
 | 
					@Data | 
				
			||||
 | 
					public class StaffsInAgencyResultDTO implements Serializable { | 
				
			||||
 | 
						private static final long serialVersionUID = 1L; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 人员总数 | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private Integer staffCount; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 人员列表 | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						private List<StaffInfoResultDTO> staffList; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,36 @@ | 
				
			|||||
 | 
					package com.epmet.controller; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			||||
 | 
					import com.epmet.dto.form.StaffsInAgencyFromDTO; | 
				
			||||
 | 
					import com.epmet.dto.result.StaffInfoResultDTO; | 
				
			||||
 | 
					import com.epmet.dto.result.StaffsInAgencyResultDTO; | 
				
			||||
 | 
					import com.epmet.service.StaffService; | 
				
			||||
 | 
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			||||
 | 
					import org.springframework.web.bind.annotation.PostMapping; | 
				
			||||
 | 
					import org.springframework.web.bind.annotation.RequestMapping; | 
				
			||||
 | 
					import org.springframework.web.bind.annotation.RestController; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.util.List; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 组织结构-工作人员 | 
				
			||||
 | 
					 * @author zhaoqifeng | 
				
			||||
 | 
					 * @date 2020/4/23 17:59 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@RestController | 
				
			||||
 | 
					@RequestMapping("staff") | 
				
			||||
 | 
					public class StaffController { | 
				
			||||
 | 
						@Autowired | 
				
			||||
 | 
						private StaffService staffService; | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 组织首页-工作人员列表 | 
				
			||||
 | 
						 * @param fromDTO | 
				
			||||
 | 
						 * @return | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						@PostMapping("staffsinagency") | 
				
			||||
 | 
						public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { | 
				
			||||
 | 
							return staffService.getStaffInfoForHome(fromDTO); | 
				
			||||
 | 
						} | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,22 @@ | 
				
			|||||
 | 
					package com.epmet.service; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			||||
 | 
					import com.epmet.dto.form.StaffsInAgencyFromDTO; | 
				
			||||
 | 
					import com.epmet.dto.result.StaffsInAgencyResultDTO; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 组织结构-工作人员 | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * @author zhaoqifeng | 
				
			||||
 | 
					 * @date 2020/4/23 18:00 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					public interface StaffService { | 
				
			||||
 | 
						/** | 
				
			||||
 | 
						 * 组织首页-工作人员列表 | 
				
			||||
 | 
						 * | 
				
			||||
 | 
						 * @param fromDTO 参数 | 
				
			||||
 | 
						 * @return Result<StaffsInAgencyResultDTO> | 
				
			||||
 | 
						 * @author zhaoqifeng | 
				
			||||
 | 
						 */ | 
				
			||||
 | 
						Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,54 @@ | 
				
			|||||
 | 
					package com.epmet.service.impl; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			||||
 | 
					import com.epmet.dto.CustomerStaffAgencyDTO; | 
				
			||||
 | 
					import com.epmet.dto.form.StaffsInAgencyFromDTO; | 
				
			||||
 | 
					import com.epmet.dto.result.StaffInfoResultDTO; | 
				
			||||
 | 
					import com.epmet.dto.result.StaffsInAgencyResultDTO; | 
				
			||||
 | 
					import com.epmet.entity.CustomerAgencyEntity; | 
				
			||||
 | 
					import com.epmet.feign.EpmetUserFeignClient; | 
				
			||||
 | 
					import com.epmet.feign.OperCrmFeignClient; | 
				
			||||
 | 
					import com.epmet.service.CustomerAgencyService; | 
				
			||||
 | 
					import com.epmet.service.CustomerStaffAgencyService; | 
				
			||||
 | 
					import com.epmet.service.StaffService; | 
				
			||||
 | 
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			||||
 | 
					import org.springframework.stereotype.Service; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.util.List; | 
				
			||||
 | 
					import java.util.stream.Collectors; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * @author zhaoqifeng | 
				
			||||
 | 
					 * @dscription | 
				
			||||
 | 
					 * @date 2020/4/23 18:05 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Service | 
				
			||||
 | 
					public class StaffServiceImpl implements StaffService { | 
				
			||||
 | 
						@Autowired | 
				
			||||
 | 
						private EpmetUserFeignClient epmetUserFeignClient; | 
				
			||||
 | 
						@Autowired | 
				
			||||
 | 
						private OperCrmFeignClient operCrmFeignClient; | 
				
			||||
 | 
						@Autowired | 
				
			||||
 | 
						private CustomerAgencyService customerAgencyService; | 
				
			||||
 | 
						@Autowired | 
				
			||||
 | 
						private CustomerStaffAgencyService customerStaffAgencyService; | 
				
			||||
 | 
						@Override | 
				
			||||
 | 
						public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { | 
				
			||||
 | 
							StaffsInAgencyResultDTO resultDTO = new StaffsInAgencyResultDTO(); | 
				
			||||
 | 
							//获取机关所在客户ID和人员总数
 | 
				
			||||
 | 
							CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); | 
				
			||||
 | 
							resultDTO.setStaffCount(customerAgencyEntity.getTotalUser()); | 
				
			||||
 | 
							fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); | 
				
			||||
 | 
							List<CustomerStaffAgencyDTO> customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData(); | 
				
			||||
 | 
							if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) { | 
				
			||||
 | 
								return new Result<StaffsInAgencyResultDTO>().ok(null); | 
				
			||||
 | 
							} | 
				
			||||
 | 
							//提取所有userID
 | 
				
			||||
 | 
							List<String> staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList()); | 
				
			||||
 | 
							fromDTO.setStaffList(staffIds); | 
				
			||||
 | 
							//获取用户信息
 | 
				
			||||
 | 
							Result<List<StaffInfoResultDTO>> staffInfoListResult =  epmetUserFeignClient.getStaffInfoForHome(fromDTO); | 
				
			||||
 | 
							resultDTO.setStaffList(staffInfoListResult.getData()); | 
				
			||||
 | 
							return new Result<StaffsInAgencyResultDTO>().ok(resultDTO); | 
				
			||||
 | 
						} | 
				
			||||
 | 
					} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue