Commit 55dc0ca0 authored by lisong's avatar lisong

更新

parent 6d151f96
package com.yeejoin.amos.boot.module.tcm.api.dto;
import lombok.Data;
@Data
public class AccountDto {
String adminUserName;
String loginName;
String pwd;
String adminTel;
String unitTypeCode;
Long companyId;
}
package com.yeejoin.amos.boot.module.tcm.api.dto;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitIcDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.List;
/**
* 事业单位注册
*/
@Data
@EqualsAndHashCode(callSuper = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BaseInstitutionRegisterDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "单位名称")
private String name;
@ApiModelProperty(value = "证件code")
private String unitCode;
@ApiModelProperty(value = "证件类型")
private String unitCodeType;
@ApiModelProperty(value = "证件类型名称")
private String unitCodeTypeName;
@ApiModelProperty(value = "单位类型")
private List<String> unitTypeList;
@ApiModelProperty(value = "单位类型code")
private List<String> unitTypeCodeList;
@ApiModelProperty(value = "管辖机构")
private String managementUnit;
@ApiModelProperty(value = "管辖单位id")
private String managementUnitId;
@ApiModelProperty(value = "管辖单位编码")
private String managementUnitCompanyCode;
@ApiModelProperty(value = "管辖单位orgCode")
private String managementUnitOrgCode;
@ApiModelProperty(value = "区域编码")
private String regionCode;
@ApiModelProperty(value = "国家")
private String country;
@ApiModelProperty(value = "省")
private String province;
@ApiModelProperty(value = "市")
private String city;
@ApiModelProperty(value = "县区")
private String district;
@ApiModelProperty(value = "街道")
private String stree;
@ApiModelProperty(value = "小区")
private String community;
@ApiModelProperty(value = "详细地址")
private String address;
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "纬度")
private String latitude;
@ApiModelProperty(value = "单位法人")
private String legalPerson;
@ApiModelProperty(value = "法人电话")
private String legalPersonTel;
@ApiModelProperty(value = "单位联系人")
private String contactPerson;
@ApiModelProperty(value = "联系人电话")
private String contactPersonTel;
@ApiModelProperty(value = "管理员姓名")
private String adminName;
@ApiModelProperty(value = "管理员用户名")
private String adminLoginName;
@ApiModelProperty(value = "管理员密码")
private String adminLoginPwd;
@ApiModelProperty(value = "管理员手机号")
private String adminTel;
@ApiModelProperty(value = "管理员身份证号")
private String adminIdNumber;
@ApiModelProperty(value = "工商信息")
private TzsBaseInstitutionDto regUnitIc;
@ApiModelProperty(value = "行政许可")
private List<BaseUnitLicenceDto> unitLicences = new ArrayList<>();
@ApiModelProperty(value = "平台公司id,平台创建公司后更新")
private String amosCompanySeq;
@ApiModelProperty(value = "平台用户id,平台创建用户后更新")
private String adminUserId;
}
package com.yeejoin.amos.boot.module.tcm.biz.controller;
import com.yeejoin.amos.boot.module.tcm.api.dto.BaseInstitutionRegisterDto;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
......@@ -113,4 +114,13 @@ public class TzsBaseInstitutionController extends BaseController {
public ResponseModel<List<TzsBaseInstitutionDto>> selectForList() {
return ResponseHelper.buildResponse(tzsBaseInstitutionServiceImpl.queryForTzsBaseInstitutionList());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/register")
@ApiOperation(httpMethod = "POST", value = "事业单位注册", notes = "事业单位注册")
public ResponseModel<Object> register(@RequestBody BaseInstitutionRegisterDto dto) {
tzsBaseInstitutionServiceImpl.register(dto);
return ResponseHelper.buildResponse("ok");
}
}
package com.yeejoin.amos.boot.module.tcm.biz.service.impl;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.tcm.api.dto.AccountDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.BaseInstitutionRegisterDto;
import com.yeejoin.amos.boot.module.tcm.api.entity.BaseUnitLicence;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzsBaseInstitution;
import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsBaseInstitutionMapper;
import com.yeejoin.amos.boot.module.tcm.api.service.ITzsBaseInstitutionService;
import com.yeejoin.amos.boot.module.tcm.api.dto.TzsBaseInstitutionDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitInfoDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.entity.RegUnitInfo;
import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.RegUnitInfoServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 服务实现类
......@@ -15,8 +42,16 @@ import java.util.List;
* @author system_generator
* @date 2023-08-31
*/
@Slf4j
@Service
public class TzsBaseInstitutionServiceImpl extends BaseService<TzsBaseInstitutionDto,TzsBaseInstitution,TzsBaseInstitutionMapper> implements ITzsBaseInstitutionService {
@Autowired
RegUnitInfoServiceImpl regUnitInfoService;
@Autowired
BaseUnitLicenceServiceImpl baseUnitLicenceService;
/**
* 分页查询
*/
......@@ -30,4 +65,60 @@ public class TzsBaseInstitutionServiceImpl extends BaseService<TzsBaseInstitutio
public List<TzsBaseInstitutionDto> queryForTzsBaseInstitutionList() {
return this.queryForList("" , false);
}
@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);
}
}
private String dealNull2EmptyString(String t) {
return StringUtils.isEmpty(t) ? "" : t;
}
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.tcm.api.common.BizCommonConstant;
import com.yeejoin.amos.boot.module.tcm.api.dto.AccountDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.BaseUnitLicenceDto;
import com.yeejoin.amos.boot.module.tcm.api.entity.BaseUnitLicence;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzBaseEnterpriseInfo;
......@@ -307,7 +308,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
* 创建企业信息
* @param regUnitInfo 提交对象
*/
public void createBaseEnterpriseInfo(RegUnitInfoDto regUnitInfo) {
public TzBaseEnterpriseInfo createBaseEnterpriseInfo(RegUnitInfoDto regUnitInfo) {
// 1.填充数据
TzBaseEnterpriseInfo baseEnterpriseInfo = new TzBaseEnterpriseInfo();
baseEnterpriseInfo.setUseUnitCertificate(regUnitInfo.getUnitCodeTypeName());
......@@ -342,6 +343,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
LambdaQueryWrapper<TzBaseEnterpriseInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TzBaseEnterpriseInfo::getUseCode,regUnitInfo.getUnitCode());
tzBaseEnterpriseInfoService.saveOrUpdate(baseEnterpriseInfo,wrapper);
return baseEnterpriseInfo;
}
@Override
......@@ -788,6 +790,71 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
}
public void createUser(AccountDto dto) {
FeignClientResult<AgencyUserModel> userResult = null;
try {
List<RoleModel> allRoleList = startPlatformTokenService.getAllRole();
List<RoleModel> userRoleList = new ArrayList<>();
List<Long> roleIds = new ArrayList<>();
Set<String> roleNameSet = new HashSet<>();
// 3.2 创建平台用户
AgencyUserModel agencyUserModel = new AgencyUserModel();
agencyUserModel.setUserName(dto.getLoginName());
agencyUserModel.setRealName(dto.getAdminUserName());
agencyUserModel.setLockStatus("UNLOCK");
agencyUserModel.setPassword(dto.getPwd());
agencyUserModel.setRePassword(dto.getPwd());
agencyUserModel.setAgencyCode("tzs");
agencyUserModel.setMobile(dto.getAdminTel());
// 根据unitTypeCode 获取应用和角色 数据字典配置
String[] units = dto.getUnitTypeCode().split(",");
Set<String> appCodesSet = new HashSet<>();
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
List<DataDictionary> unitTypeList = setAndGetUnitTypeList();
Map<String, DataDictionary> dataDictionaryMap = unitTypeList.stream().collect(Collectors.toMap(DataDictionary::getCode, Function.identity(), (k1, k2) -> k1));
for (String typeCode : units) {
DataDictionary unitType = dataDictionaryMap.get(typeCode);
String appCode = unitType.getTypeDesc() != null ? unitType.getTypeDesc() : "";
String[] appCodes = appCode.split(",");
Collections.addAll(appCodesSet, appCodes);
roleNameSet.add(unitType.getName());
userRoleList.addAll(allRoleList.stream()
.filter(r -> unitType.getExtend().contains(r.getSequenceNbr().toString())).collect(Collectors.toList()));
userRoleList.forEach(r -> {
if (!roleIds.contains(r.getSequenceNbr())) {
roleIds.add(r.getSequenceNbr());
}
});
roleSeqMap.put(dto.getCompanyId(), roleIds);
orgRoles.put(dto.getCompanyId(), userRoleList);
}
agencyUserModel.setAppCodes(new ArrayList<>(appCodesSet));
agencyUserModel.setOrgRoles(orgRoles);
agencyUserModel.setOrgRoleSeqs(roleSeqMap);
StopWatch watch3 = new StopWatch();
watch3.start();
userResult = Privilege.agencyUserClient.create(agencyUserModel);
watch3.stop();
if(logger.isDebugEnabled()){
logger.debug("创建amos人员耗时:==>{}",watch3.getTotalTimeSeconds());
}
if (userResult == null || userResult.getResult() == null) {
throw new BadRequest("单位注册失败");
}
} catch (Exception e) {
// 删除已经创建的 企业信息
if (dto.getCompanyId() != null) {
Privilege.companyClient.deleteCompany(dto.getCompanyId() + "");
}
if (userResult != null && userResult.getResult() != null
&& StringUtils.isNotEmpty(userResult.getResult().getUserId())) {
Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId());
}
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage());
}
}
@Override
public String submit(Long pageId, String taskId, String planInstanceId, String topic, String tableName, Map<String, Object> objectMap) throws Exception {
......
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