소스 검색

用户管理修改

master
yangpeilai 2 달 전
부모
커밋
455b138c0a

+ 1
- 1
gly-base-core/src/main/java/cn/com/taiji/core/repo/jpa/basic/QtkAgencyRepo.java 파일 보기

@Query("select agencyId from QtkAgency where name like ?1 ") @Query("select agencyId from QtkAgency where name like ?1 ")
public List<String> listByName(String agencyName); public List<String> listByName(String agencyName);


@Query("from QtkAgency where agencyId=?1 and status='1'")
@Query("from QtkAgency where agencyId=?1 and status='ENABLE'")
List<QtkAgency> listByAgencyIdAndStatus(String agencyId); List<QtkAgency> listByAgencyIdAndStatus(String agencyId);


} }

+ 23
- 10
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/manager/system/StaffManagerImpl.java 파일 보기

import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
copyProperties(dto, queryRequest); copyProperties(dto, queryRequest);
//渠道迷糊查出id //渠道迷糊查出id
if (hasText(dto.getAgencyName())) { if (hasText(dto.getAgencyName())) {
List<String> agencyIds = agencyRepo.listByName(dto.toLikeStr(dto.getAgencyName()));
List<String> agencyIds = agencyRepo.listByName("%"+dto.getAgencyName()+"%");
queryRequest.setAgencyIds(agencyIds); queryRequest.setAgencyIds(agencyIds);
} }
if (hasText(dto.getServiceHallName())) { if (hasText(dto.getServiceHallName())) {
List<String> serviceHallIds = qtkServiceHallRepo.listByName(dto.toLikeStr(dto.getServiceHallName()));
List<String> serviceHallIds = qtkServiceHallRepo.listByName("%"+dto.getServiceHallName()+"%");
queryRequest.setServiceHallIds(serviceHallIds); queryRequest.setServiceHallIds(serviceHallIds);
} }
return staffRepo.page(queryRequest).convertResult(this::conver); return staffRepo.page(queryRequest).convertResult(this::conver);
public String add(StaffAddRequestDTO dto) throws ManagerException { public String add(StaffAddRequestDTO dto) throws ManagerException {
AccountInfo accountInfo = accountInfoRepo.findByAccount(dto.getMobile()); AccountInfo accountInfo = accountInfoRepo.findByAccount(dto.getMobile());
if (accountInfo == null) throw new ManagerException("该手机号码未注册,无法进行用户账号与员工绑定!"); if (accountInfo == null) throw new ManagerException("该手机号码未注册,无法进行用户账号与员工绑定!");
valid(dto.getMobile(), dto.getAgencyId(), dto.getServiceHallId(), dto.getIdentityType());
valid(dto.getMobile(), dto.getAgencyId(), dto.getServiceHallId(), dto.getIdentityType(),null);
Staff staff = new Staff(); Staff staff = new Staff();
staff.setStaffName(dto.getStaffName()); staff.setStaffName(dto.getStaffName());
staff.setAgencyId(dto.getAgencyId()); staff.setAgencyId(dto.getAgencyId());
if (commonStaffId.equals(dto.getId())) throw new ManagerException("该员工不存在"); if (commonStaffId.equals(dto.getId())) throw new ManagerException("该员工不存在");
Staff staff = staffRepo.findById(dto.getId()).orElse(null); Staff staff = staffRepo.findById(dto.getId()).orElse(null);
if (staff == null) throw new ManagerException("员工不存在!"); if (staff == null) throw new ManagerException("员工不存在!");
valid(dto.getMobile(), dto.getAgencyId(), dto.getServiceHallId(), dto.getIdentityType());
valid(dto.getMobile(), dto.getAgencyId(), dto.getServiceHallId(), dto.getIdentityType(), staff.getId());
staff.setStaffName(dto.getStaffName()); staff.setStaffName(dto.getStaffName());
staff.setAgencyId(dto.getAgencyId()); staff.setAgencyId(dto.getAgencyId());
staff.setServiceHallId(dto.getServiceHallId()); staff.setServiceHallId(dto.getServiceHallId());
accountUserRole.setRoleId(userRole.getId()); accountUserRole.setRoleId(userRole.getId());
accountUserRole.setSystemType(userRole.getSystemType()); accountUserRole.setSystemType(userRole.getSystemType());
accountUserRole.setOpenId(accountInfo.getOpenId()); accountUserRole.setOpenId(accountInfo.getOpenId());
accountUserRole.setLoginSource(loginSource);
//修复登录来源
accountUserRole.setLoginSource(sourceType);
accountUserRole.setCreateTime(LocalDateTime.now()); accountUserRole.setCreateTime(LocalDateTime.now());
accountUserRoleList.add(accountUserRole); accountUserRoleList.add(accountUserRole);
} }


@Override @Override
public String registerFullBath(StaffRegisterFullBatchRequestDTO dto) throws ManagerException { public String registerFullBath(StaffRegisterFullBatchRequestDTO dto) throws ManagerException {
String[] str = dto.getExcelFileUrl().split("/");
InputStream is = minioUtil.fileDownload(str[str.length - 1], str[0]);
File tempFile = minioUtil.getFileByUrl(dto.getExcelFileUrl());
// File tempFile = new File("C:\\Users\\32258\\Desktop\\gy\\测试\\用户管理\\测试文件\\员工账号批量注册导入模板.xlsx");
InputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(tempFile);
} catch (FileNotFoundException e) {
throw new ManagerException("通过文件流失败!");
}
List<StaffRegisterData> dataList = Lists.newArrayList(); List<StaffRegisterData> dataList = Lists.newArrayList();
EasyExcel.read(is, StaffRegisterData.class, new StaffRegisterDataReadListener(dataList)).sheet().headRowNumber(2).doRead();
EasyExcel.read(fileInputStream, StaffRegisterData.class, new StaffRegisterDataReadListener(dataList)).sheet().headRowNumber(2).doRead();
return null; return null;
} }


} }




private void valid(String mobile, String agencyId, String serviceHallId, String identityType) throws ManagerException {
private void valid(String mobile, String agencyId, String serviceHallId, String identityType, String staffId) throws ManagerException {
//2、(手机号)账号是否已经被员工绑定校验 //2、(手机号)账号是否已经被员工绑定校验
if (staffRepo.findByMobile(mobile) != null)
//并且查询出来的员工不是本人
Staff byMobile = staffRepo.findByMobile(mobile);
if (byMobile != null && !byMobile.getId().equals(staffId)) {
throw new ManagerException("该手机号对应的用户账号已经被其他员工绑定!"); throw new ManagerException("该手机号对应的用户账号已经被其他员工绑定!");
}
/* /*
* 前三步,确保该手机号对应的用户账号没有绑定过员工 * 前三步,确保该手机号对应的用户账号没有绑定过员工
* 从而保证了: * 从而保证了:

+ 2
- 2
zhywpt-app-userw/src/main/java/cn/com/taiji/userw/tools/DictTypeUtil.java 파일 보기



public boolean checkLegalById(String dictTypeId, List<String> checkList) throws ManagerException { public boolean checkLegalById(String dictTypeId, List<String> checkList) throws ManagerException {
if (!hasText(dictTypeId)) return false; if (!hasText(dictTypeId)) return false;
if (!isEmpty(checkList)) return false;
if (isEmpty(checkList)) return false;
List<DictItem> dictItemList = dictItemRepo.findByTypeId(dictTypeId); List<DictItem> dictItemList = dictItemRepo.findByTypeId(dictTypeId);
if (!isEmpty(dictItemList)) throw new ManagerException("查询的数据字典类型的值列表为空!");
if (isEmpty(dictItemList)) throw new ManagerException("查询的数据字典类型的值列表为空!");
List<String> codeList = dictItemList.stream().map(DictItem::getCode).collect(Collectors.toList()); List<String> codeList = dictItemList.stream().map(DictItem::getCode).collect(Collectors.toList());
for (String data : checkList) { for (String data : checkList) {
if (!codeList.contains(data)) return false; if (!codeList.contains(data)) return false;

Loading…
취소
저장