Commit 2f8e3a67 authored by lisong's avatar lisong

更新

parent 58c43496
...@@ -17,7 +17,7 @@ import java.util.Date; ...@@ -17,7 +17,7 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("tzs_base_individuality") @TableName("tz_base_individuality")
public class TzsBaseIndividuality extends BaseEntity { public class TzsBaseIndividuality extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -17,7 +17,7 @@ import java.util.Date; ...@@ -17,7 +17,7 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("tzs_base_institution") @TableName("tz_base_institution")
public class TzsBaseInstitution extends BaseEntity { public class TzsBaseInstitution extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -67,52 +67,81 @@ public class TzsBaseInstitutionServiceImpl extends BaseService<TzsBaseInstitutio ...@@ -67,52 +67,81 @@ public class TzsBaseInstitutionServiceImpl extends BaseService<TzsBaseInstitutio
} }
@Transactional @Transactional
public void register(BaseInstitutionRegisterDto dto){ public void register(BaseInstitutionRegisterDto dto) {
dto.setUnitCodeType("1060"); try {
dto.setUnitCodeTypeName("营业执照"); dto.setUnitCodeType("1060");
String unitType = StringUtils.join(dto.getUnitTypeList(), ","); dto.setUnitCodeTypeName("营业执照");
String unitTypeCode = StringUtils.join(dto.getUnitTypeCodeList(), ","); String unitType = StringUtils.join(dto.getUnitTypeList(), ",");
CompanyModel companyInfo = new CompanyModel(); String unitTypeCode = StringUtils.join(dto.getUnitTypeCodeList(), ",");
companyInfo.setAddress(dealNull2EmptyString(dto.getProvince()) CompanyModel companyInfo = new CompanyModel();
+ dealNull2EmptyString(dto.getCity()) + dealNull2EmptyString(dto.getDistrict()) companyInfo.setAddress(dealNull2EmptyString(dto.getProvince())
+ dealNull2EmptyString(dto.getStree()) + dealNull2EmptyString(dto.getCommunity()) + dealNull2EmptyString(dto.getCity()) + dealNull2EmptyString(dto.getDistrict())
+ dealNull2EmptyString(dto.getAddress())); + dealNull2EmptyString(dto.getStree()) + dealNull2EmptyString(dto.getCommunity())
companyInfo.setAgencyCode("tzs"); + dealNull2EmptyString(dto.getAddress()));
companyInfo.setParentId(Long.parseLong(dto.getManagementUnitId())); companyInfo.setAgencyCode("tzs");
companyInfo.setLevel("company"); companyInfo.setParentId(Long.parseLong(dto.getManagementUnitId()));
companyInfo.setCompanyName(dto.getName()); companyInfo.setLevel("company");
companyInfo.setCompanyCode(dto.getUnitCode()); companyInfo.setCompanyName(dto.getName());
companyInfo.setContact(dto.getLegalPerson()); companyInfo.setCompanyCode(dto.getUnitCode());
companyInfo.setCompanyType(unitType); companyInfo.setContact(dto.getLegalPerson());
companyInfo.setLandlinePhone(dto.getLegalPersonTel()); companyInfo.setCompanyType(unitType);
FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo); companyInfo.setLandlinePhone(dto.getLegalPersonTel());
if (companyResult == null || companyResult.getResult() == null) { FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo);
throw new BadRequest("单位注册失败"); if (companyResult == null || companyResult.getResult() == null) {
} throw new BadRequest("单位注册失败");
CompanyModel company = companyResult.getResult(); }
AccountDto accountDto = new AccountDto(); CompanyModel company = companyResult.getResult();
accountDto.setCompanyId(company.getSequenceNbr()); dto.setAmosCompanySeq(company.getSequenceNbr().toString());
accountDto.setUnitTypeCode(unitTypeCode); AccountDto accountDto = new AccountDto();
regUnitInfoService.createUser(accountDto); accountDto.setCompanyId(company.getSequenceNbr());
RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto(); accountDto.setUnitTypeCode(unitTypeCode);
BeanUtils.copyProperties(dto, regUnitInfoDto); accountDto.setAdminTel(dto.getAdminTel());
TzBaseEnterpriseInfo baseEnterpriseInfo = regUnitInfoService.createBaseEnterpriseInfo(regUnitInfoDto); accountDto.setPwd(dto.getAdminLoginPwd());
TzsBaseInstitution tzsBaseInstitution = new TzsBaseInstitution(); accountDto.setLoginName(dto.getAdminLoginName());
BeanUtils.copyProperties(dto.getRegUnitIc(), tzsBaseInstitution); accountDto.setAdminUserName(dto.getAdminName());
tzsBaseInstitution.setEnterpriseId(baseEnterpriseInfo.getSequenceNbr()); AgencyUserModel user = regUnitInfoService.createUser(accountDto);
this.save(tzsBaseInstitution); dto.setAdminUserId(user.getUserId());
// 3.插入单位注册许可信息表:tz_base_unit_licence RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto();
List<BaseUnitLicence> baseUnitLicences = dto.getUnitLicences().stream().map(s -> { BeanUtils.copyProperties(dto, regUnitInfoDto);
s.setUnitCode(dto.getUnitCode()); TzBaseEnterpriseInfo baseEnterpriseInfo = regUnitInfoService.createBaseEnterpriseInfo(regUnitInfoDto);
s.setUnitName(dto.getName()); TzsBaseInstitution tzsBaseInstitution = new TzsBaseInstitution();
BaseUnitLicence target = new BaseUnitLicence(); BeanUtils.copyProperties(dto.getRegUnitIc(), tzsBaseInstitution);
Bean.copyExistPropertis(s, target); tzsBaseInstitution.setEnterpriseId(baseEnterpriseInfo.getSequenceNbr());
return target; this.save(tzsBaseInstitution);
}).collect(Collectors.toList()); // 3.插入单位注册许可信息表:tz_base_unit_licence
if (!baseUnitLicences.isEmpty()) { List<BaseUnitLicence> baseUnitLicences = dto.getUnitLicences().stream().map(s -> {
baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences); s.setUnitCode(dto.getUnitCode());
s.setUnitName(dto.getName());
BaseUnitLicence target = new BaseUnitLicence();
Bean.copyExistPropertis(s, target);
return target;
}).collect(Collectors.toList());
if (!baseUnitLicences.isEmpty()) {
baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
try {
// 失败后回滚:删除已经创建的企业信息
if (StringUtils.isNotEmpty(dto.getAmosCompanySeq())) {
FeignClientResult<CompanyModel> feignClientResult = Privilege.companyClient.seleteOne(Long.parseLong(dto.getAmosCompanySeq()));
if (feignClientResult != null && feignClientResult.getResult() != null) {
Privilege.companyClient.deleteCompany(dto.getAmosCompanySeq());
}
}
// 失败后回滚:删除已经创建的管理员账号
if (StringUtils.isNotEmpty(dto.getAdminUserId())) {
FeignClientResult<AgencyUserModel> feignClientResult = Privilege.agencyUserClient.queryByUserId(dto.getAdminUserId());
if (feignClientResult != null && feignClientResult.getResult() != null) {
Privilege.agencyUserClient.multDeleteUser(dto.getAdminUserId());
}
}
} catch (Exception rollbackException) {
log.error("回滚操作发生异常: {}", rollbackException.getMessage(), rollbackException);
}
throw new RuntimeException("事业单位注册失败,请联系管理员!");
} }
} }
......
...@@ -790,7 +790,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -790,7 +790,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
} }
} }
public void createUser(AccountDto dto) { public AgencyUserModel createUser(AccountDto dto) {
FeignClientResult<AgencyUserModel> userResult = null; FeignClientResult<AgencyUserModel> userResult = null;
try { try {
List<RoleModel> allRoleList = startPlatformTokenService.getAllRole(); List<RoleModel> allRoleList = startPlatformTokenService.getAllRole();
...@@ -842,6 +842,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -842,6 +842,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
if (userResult == null || userResult.getResult() == null) { if (userResult == null || userResult.getResult() == null) {
throw new BadRequest("单位注册失败"); throw new BadRequest("单位注册失败");
} }
return userResult.getResult();
} catch (Exception e) { } catch (Exception e) {
// 删除已经创建的 企业信息 // 删除已经创建的 企业信息
if (dto.getCompanyId() != null) { if (dto.getCompanyId() != null) {
...@@ -851,7 +852,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -851,7 +852,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
&& StringUtils.isNotEmpty(userResult.getResult().getUserId())) { && StringUtils.isNotEmpty(userResult.getResult().getUserId())) {
Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId()); Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId());
} }
logger.error(e.getMessage(),e); log.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage()); throw new RuntimeException(e.getMessage());
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment