|
|
@@ -39,6 +39,9 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
@@ -84,11 +87,11 @@ public class StaffManagerImpl extends RedisCacheManager implements StaffManager |
|
|
|
copyProperties(dto, queryRequest); |
|
|
|
//渠道迷糊查出id |
|
|
|
if (hasText(dto.getAgencyName())) { |
|
|
|
List<String> agencyIds = agencyRepo.listByName(dto.toLikeStr(dto.getAgencyName())); |
|
|
|
List<String> agencyIds = agencyRepo.listByName("%"+dto.getAgencyName()+"%"); |
|
|
|
queryRequest.setAgencyIds(agencyIds); |
|
|
|
} |
|
|
|
if (hasText(dto.getServiceHallName())) { |
|
|
|
List<String> serviceHallIds = qtkServiceHallRepo.listByName(dto.toLikeStr(dto.getServiceHallName())); |
|
|
|
List<String> serviceHallIds = qtkServiceHallRepo.listByName("%"+dto.getServiceHallName()+"%"); |
|
|
|
queryRequest.setServiceHallIds(serviceHallIds); |
|
|
|
} |
|
|
|
return staffRepo.page(queryRequest).convertResult(this::conver); |
|
|
@@ -117,7 +120,7 @@ public class StaffManagerImpl extends RedisCacheManager implements StaffManager |
|
|
|
public String add(StaffAddRequestDTO dto) throws ManagerException { |
|
|
|
AccountInfo accountInfo = accountInfoRepo.findByAccount(dto.getMobile()); |
|
|
|
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.setStaffName(dto.getStaffName()); |
|
|
|
staff.setAgencyId(dto.getAgencyId()); |
|
|
@@ -145,7 +148,7 @@ public class StaffManagerImpl extends RedisCacheManager implements StaffManager |
|
|
|
if (commonStaffId.equals(dto.getId())) throw new ManagerException("该员工不存在"); |
|
|
|
Staff staff = staffRepo.findById(dto.getId()).orElse(null); |
|
|
|
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.setAgencyId(dto.getAgencyId()); |
|
|
|
staff.setServiceHallId(dto.getServiceHallId()); |
|
|
@@ -363,7 +366,8 @@ public class StaffManagerImpl extends RedisCacheManager implements StaffManager |
|
|
|
accountUserRole.setRoleId(userRole.getId()); |
|
|
|
accountUserRole.setSystemType(userRole.getSystemType()); |
|
|
|
accountUserRole.setOpenId(accountInfo.getOpenId()); |
|
|
|
accountUserRole.setLoginSource(loginSource); |
|
|
|
//修复登录来源 |
|
|
|
accountUserRole.setLoginSource(sourceType); |
|
|
|
accountUserRole.setCreateTime(LocalDateTime.now()); |
|
|
|
accountUserRoleList.add(accountUserRole); |
|
|
|
} |
|
|
@@ -391,10 +395,16 @@ public class StaffManagerImpl extends RedisCacheManager implements StaffManager |
|
|
|
|
|
|
|
@Override |
|
|
|
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(); |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
@@ -410,10 +420,13 @@ public class StaffManagerImpl extends RedisCacheManager implements StaffManager |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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、(手机号)账号是否已经被员工绑定校验 |
|
|
|
if (staffRepo.findByMobile(mobile) != null) |
|
|
|
//并且查询出来的员工不是本人 |
|
|
|
Staff byMobile = staffRepo.findByMobile(mobile); |
|
|
|
if (byMobile != null && !byMobile.getId().equals(staffId)) { |
|
|
|
throw new ManagerException("该手机号对应的用户账号已经被其他员工绑定!"); |
|
|
|
} |
|
|
|
/* |
|
|
|
* 前三步,确保该手机号对应的用户账号没有绑定过员工 |
|
|
|
* 从而保证了: |