Commit 2f8e3a67 authored by lisong's avatar lisong

更新

parent 58c43496
......@@ -17,7 +17,7 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tzs_base_individuality")
@TableName("tz_base_individuality")
public class TzsBaseIndividuality extends BaseEntity {
private static final long serialVersionUID = 1L;
......
......@@ -17,7 +17,7 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tzs_base_institution")
@TableName("tz_base_institution")
public class TzsBaseInstitution extends BaseEntity {
private static final long serialVersionUID = 1L;
......
......@@ -67,52 +67,81 @@ public class TzsBaseInstitutionServiceImpl extends BaseService<TzsBaseInstitutio
}
@Transactional
public void register(BaseInstitutionRegisterDto dto){
dto.setUnitCodeType("1060");
dto.setUnitCodeTypeName("营业执照");
String unitType = StringUtils.join(dto.getUnitTypeList(), ",");
String unitTypeCode = StringUtils.join(dto.getUnitTypeCodeList(), ",");
CompanyModel companyInfo = new CompanyModel();
companyInfo.setAddress(dealNull2EmptyString(dto.getProvince())
+ dealNull2EmptyString(dto.getCity()) + dealNull2EmptyString(dto.getDistrict())
+ dealNull2EmptyString(dto.getStree()) + dealNull2EmptyString(dto.getCommunity())
+ dealNull2EmptyString(dto.getAddress()));
companyInfo.setAgencyCode("tzs");
companyInfo.setParentId(Long.parseLong(dto.getManagementUnitId()));
companyInfo.setLevel("company");
companyInfo.setCompanyName(dto.getName());
companyInfo.setCompanyCode(dto.getUnitCode());
companyInfo.setContact(dto.getLegalPerson());
companyInfo.setCompanyType(unitType);
companyInfo.setLandlinePhone(dto.getLegalPersonTel());
FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo);
if (companyResult == null || companyResult.getResult() == null) {
throw new BadRequest("单位注册失败");
}
CompanyModel company = companyResult.getResult();
AccountDto accountDto = new AccountDto();
accountDto.setCompanyId(company.getSequenceNbr());
accountDto.setUnitTypeCode(unitTypeCode);
regUnitInfoService.createUser(accountDto);
RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto();
BeanUtils.copyProperties(dto, regUnitInfoDto);
TzBaseEnterpriseInfo baseEnterpriseInfo = regUnitInfoService.createBaseEnterpriseInfo(regUnitInfoDto);
TzsBaseInstitution tzsBaseInstitution = new TzsBaseInstitution();
BeanUtils.copyProperties(dto.getRegUnitIc(), tzsBaseInstitution);
tzsBaseInstitution.setEnterpriseId(baseEnterpriseInfo.getSequenceNbr());
this.save(tzsBaseInstitution);
// 3.插入单位注册许可信息表:tz_base_unit_licence
List<BaseUnitLicence> baseUnitLicences = dto.getUnitLicences().stream().map(s -> {
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);
public void register(BaseInstitutionRegisterDto dto) {
try {
dto.setUnitCodeType("1060");
dto.setUnitCodeTypeName("营业执照");
String unitType = StringUtils.join(dto.getUnitTypeList(), ",");
String unitTypeCode = StringUtils.join(dto.getUnitTypeCodeList(), ",");
CompanyModel companyInfo = new CompanyModel();
companyInfo.setAddress(dealNull2EmptyString(dto.getProvince())
+ dealNull2EmptyString(dto.getCity()) + dealNull2EmptyString(dto.getDistrict())
+ dealNull2EmptyString(dto.getStree()) + dealNull2EmptyString(dto.getCommunity())
+ dealNull2EmptyString(dto.getAddress()));
companyInfo.setAgencyCode("tzs");
companyInfo.setParentId(Long.parseLong(dto.getManagementUnitId()));
companyInfo.setLevel("company");
companyInfo.setCompanyName(dto.getName());
companyInfo.setCompanyCode(dto.getUnitCode());
companyInfo.setContact(dto.getLegalPerson());
companyInfo.setCompanyType(unitType);
companyInfo.setLandlinePhone(dto.getLegalPersonTel());
FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo);
if (companyResult == null || companyResult.getResult() == null) {
throw new BadRequest("单位注册失败");
}
CompanyModel company = companyResult.getResult();
dto.setAmosCompanySeq(company.getSequenceNbr().toString());
AccountDto accountDto = new AccountDto();
accountDto.setCompanyId(company.getSequenceNbr());
accountDto.setUnitTypeCode(unitTypeCode);
accountDto.setAdminTel(dto.getAdminTel());
accountDto.setPwd(dto.getAdminLoginPwd());
accountDto.setLoginName(dto.getAdminLoginName());
accountDto.setAdminUserName(dto.getAdminName());
AgencyUserModel user = regUnitInfoService.createUser(accountDto);
dto.setAdminUserId(user.getUserId());
RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto();
BeanUtils.copyProperties(dto, regUnitInfoDto);
TzBaseEnterpriseInfo baseEnterpriseInfo = regUnitInfoService.createBaseEnterpriseInfo(regUnitInfoDto);
TzsBaseInstitution tzsBaseInstitution = new TzsBaseInstitution();
BeanUtils.copyProperties(dto.getRegUnitIc(), tzsBaseInstitution);
tzsBaseInstitution.setEnterpriseId(baseEnterpriseInfo.getSequenceNbr());
this.save(tzsBaseInstitution);
// 3.插入单位注册许可信息表:tz_base_unit_licence
List<BaseUnitLicence> baseUnitLicences = dto.getUnitLicences().stream().map(s -> {
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
}
}
public void createUser(AccountDto dto) {
public AgencyUserModel createUser(AccountDto dto) {
FeignClientResult<AgencyUserModel> userResult = null;
try {
List<RoleModel> allRoleList = startPlatformTokenService.getAllRole();
......@@ -842,6 +842,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
if (userResult == null || userResult.getResult() == null) {
throw new BadRequest("单位注册失败");
}
return userResult.getResult();
} catch (Exception e) {
// 删除已经创建的 企业信息
if (dto.getCompanyId() != null) {
......@@ -851,7 +852,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
&& StringUtils.isNotEmpty(userResult.getResult().getUserId())) {
Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId());
}
logger.error(e.getMessage(),e);
log.error(e.getMessage(),e);
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