|
@@ -236,7 +236,7 @@ public class VppTeamServiceImpl implements VppTeamService {
|
|
|
if (!CollectionUtils.isEmpty(dto.getProductList())) {
|
|
|
vppLicenseCodeList = vppLicenseCodeService.getByCompanyAndTeamId(member.getCompanyId(), vppTeam.getId());
|
|
|
for (CreateTeamDTO.Product product : dto.getProductList()) {
|
|
|
- List<LicenseCodes> collect = vppLicenseCodeList.stream().filter(c -> c.getProductId().equals(product.getProductId()) && c.getValidFlag() == 1).collect(Collectors.toList());
|
|
|
+ List<LicenseCodes> collect = vppLicenseCodeList.stream().filter(c -> c.getProductId().equals(product.getProductId()) && (c.getValidFlag() == 1 || c.getValidFlag() == 4)).collect(Collectors.toList());
|
|
|
if (collect.size() < product.getLicenseNumber()) {
|
|
|
throw new BackendRuntimeException(VppMemberConstant.INSUFFICIENT_QUANTITY_TO_ALLOCATE);
|
|
|
}
|
|
@@ -258,7 +258,7 @@ public class VppTeamServiceImpl implements VppTeamService {
|
|
|
if (!CollectionUtils.isEmpty(dto.getProductList())) {
|
|
|
// 从默认团队分配序列码到此团队
|
|
|
for (CreateTeamDTO.Product product : dto.getProductList()) {
|
|
|
- List<LicenseCodes> collect = vppLicenseCodeList.stream().filter(c -> c.getProductId().equals(product.getProductId()) && c.getValidFlag() == 1).collect(Collectors.toList());
|
|
|
+ List<LicenseCodes> collect = vppLicenseCodeList.stream().filter(c -> c.getProductId().equals(product.getProductId()) && (c.getValidFlag() == 1 || c.getValidFlag() == 4)).collect(Collectors.toList());
|
|
|
for (int i = 0; i < product.getLicenseNumber(); i++) {
|
|
|
LicenseCodes vppLicenseCode = collect.get(i);
|
|
|
vppLicenseCode.setTeamId(newVppTeam.getId());
|
|
@@ -604,32 +604,7 @@ public class VppTeamServiceImpl implements VppTeamService {
|
|
|
// 删除团队,返还未授权序列码到默认团队,移动团队成员到默认团队
|
|
|
vppTeam.setValidFlag("0");
|
|
|
vppTeamMapper.updateByPrimaryKeySelective(vppTeam);
|
|
|
- // 获取团队所有序列码
|
|
|
- List<LicenseCodes> byCompanyAndTeamId = vppLicenseCodeService.getByCompanyAndTeamId(vppTeam.getCompanyId(), vppTeam.getId());
|
|
|
- // 获取公司默认团队
|
|
|
- VppTeamExample example = new VppTeamExample();
|
|
|
- example.createCriteria().andCompanyIdEqualTo(member.getCompanyId()).andTypeEqualTo(1);
|
|
|
- VppTeam defaultVppTeam = vppTeamMapper.selectByExample(example).get(0);
|
|
|
- List<String> cdKeys = new ArrayList<>();
|
|
|
- for (LicenseCodes vppLicenseCode : byCompanyAndTeamId) {
|
|
|
- // 已授权or已激活
|
|
|
- if (2 == vppLicenseCode.getValidFlag() || 3 == vppLicenseCode.getValidFlag()) {
|
|
|
- vppLicenseCode.setMemberId(null);
|
|
|
- vppLicenseCode.setVppMemberId(null);
|
|
|
- vppLicenseCode.setValidFlag(4);
|
|
|
- vppLicenseCode.setUpdatedAt(new Date());
|
|
|
- vppLicenseCode.setUsedTimes(Short.valueOf("0"));
|
|
|
- if (3 == vppLicenseCode.getValidFlag() && null != vppLicenseCode.getCdkey()) {
|
|
|
- // 解绑激活设备
|
|
|
- cdKeys.add(vppLicenseCode.getCdkey());
|
|
|
- }
|
|
|
- }
|
|
|
- vppLicenseCode.setTeamId(defaultVppTeam.getId());
|
|
|
- vppLicenseCodeService.updateByPrimaryKey(vppLicenseCode);
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(cdKeys)) {
|
|
|
- vppDeviceService.unBindByMemberId(null, cdKeys);
|
|
|
- }
|
|
|
+ VppTeam defaultVppTeam = unbindDeviceANDCDKey(vppTeam, member);
|
|
|
// 团队成员移到默认团队
|
|
|
vppRTeamMemberRoleService.changeTeamMember(vppTeam.getId(), defaultVppTeam.getId());
|
|
|
// 获取团队所有关联数据
|
|
@@ -671,6 +646,42 @@ public class VppTeamServiceImpl implements VppTeamService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * cdkey解绑 设备解绑
|
|
|
+ * @param vppTeam 团队
|
|
|
+ * @param member 用户
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private VppTeam unbindDeviceANDCDKey(VppTeam vppTeam, VppMember member) {
|
|
|
+ // 获取公司默认团队
|
|
|
+ VppTeamExample example = new VppTeamExample();
|
|
|
+ example.createCriteria().andCompanyIdEqualTo(member.getCompanyId()).andTypeEqualTo(1);
|
|
|
+ VppTeam defaultVppTeam = vppTeamMapper.selectByExample(example).get(0);
|
|
|
+ // 获取团队所有序列码
|
|
|
+ List<LicenseCodes> byCompanyAndTeamId = vppLicenseCodeService.getByCompanyAndTeamId(vppTeam.getCompanyId(), vppTeam.getId());
|
|
|
+ List<String> cdKeys = new ArrayList<>();
|
|
|
+ for (LicenseCodes vppLicenseCode : byCompanyAndTeamId) {
|
|
|
+ // 已授权or已激活
|
|
|
+ if (2 == vppLicenseCode.getValidFlag() || 3 == vppLicenseCode.getValidFlag()) {
|
|
|
+ if (3 == vppLicenseCode.getValidFlag() && null != vppLicenseCode.getCdkey()) {
|
|
|
+ // 解绑激活设备
|
|
|
+ cdKeys.add(vppLicenseCode.getCdkey());
|
|
|
+ }
|
|
|
+ vppLicenseCode.setMemberId(null);
|
|
|
+ vppLicenseCode.setVppMemberId(null);
|
|
|
+ vppLicenseCode.setValidFlag(4);
|
|
|
+ vppLicenseCode.setUpdatedAt(new Date());
|
|
|
+ vppLicenseCode.setUsedTimes(Short.valueOf("0"));
|
|
|
+ }
|
|
|
+ vppLicenseCode.setTeamId(defaultVppTeam.getId());
|
|
|
+ vppLicenseCodeService.updateByPrimaryKey(vppLicenseCode);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(cdKeys)) {
|
|
|
+ vppDeviceService.unBindByMemberId(null, cdKeys);
|
|
|
+ }
|
|
|
+ return defaultVppTeam;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void sendEmailForAddTeamAdmin(List<String> teamIds, String account) {
|
|
|
//判断用户存不存在,若被添加管理员暂未注册,则先发送邀请注册邮件,注册成功后直接加入团队
|
|
@@ -941,4 +952,19 @@ public class VppTeamServiceImpl implements VppTeamService {
|
|
|
return vppTeamMapper.selectByExample(example).get(0);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void deleteDirectoryTeam(String teamId) {
|
|
|
+ // 删除团队
|
|
|
+ VppTeam vppTeam = vppTeamMapper.selectByPrimaryKey(teamId);
|
|
|
+ vppTeam.setValidFlag(ValidStatusEnum.INVALID.value());
|
|
|
+ vppTeamMapper.updateByPrimaryKeySelective(vppTeam);
|
|
|
+ // 解绑设备
|
|
|
+ // 归还序列码
|
|
|
+ VppMember member = vppMemberService.getCurrentUser();
|
|
|
+ unbindDeviceANDCDKey(vppTeam, member);
|
|
|
+ // 删除团队所有关联关系
|
|
|
+ vppRTeamMemberRoleService.cleanTeamMember(teamId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|