Commit c9e2b923 authored by zhangyingbin's avatar zhangyingbin

ugp同步tzs企业注册

parent 148227f3
package com.yeejoin.amos.boot.module.tzs.flc.api.feign;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.feign.MultipartSupportConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
@FeignClient(name = "UGP-ZYB", path = "/ugp", configuration =
{MultipartSupportConfig.class})
public interface UgpServiceFeignClient {
/**
* 调用ugp的接口
* @param object 公司信息
* @return
*/
@RequestMapping(value = "/company/syncCompany", method = RequestMethod.POST)
ResponseModel<Boolean> syncCompany(@RequestBody Object object);
}
......@@ -11,16 +11,21 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.flc.api.feign.AccessFeignService;
import com.yeejoin.amos.boot.module.tzs.flc.api.feign.UgpServiceFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -53,6 +58,7 @@ 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 org.typroject.tyboot.core.restful.utils.ResponseModel;
/**
* 单位注册信息表服务实现类
......@@ -89,6 +95,9 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
AccessFeignService accessFeignService;
@Autowired
UgpServiceFeignClient ugpServiceFeignClient;
@Autowired
StartPlatformTokenService startPlatformTokenService;
/**
* 使用单位的类型,数据来源:cb_data_dictionary code = 1232
......@@ -123,6 +132,28 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
Bean.copyExistPropertis(model, regUnitInfo);
regUnitInfo.setUnitType(StringUtils.join(model.getUnitTypeList(), ","));
regUnitInfo.setUnitTypeCode(StringUtils.join(model.getUnitTypeCodeList(), ","));
// 3.2 自动创建:调用平台进行创建单位、用户信息
this.createCompanyAndUser(regUnitInfo);
//多线程同步ugp信息
String token = RequestContext.getToken();
String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct();
Callable callable = new Callable(){
@Override
public Object call() throws Exception {
RequestContext.setToken(token);
RequestContext.setAppKey(appKey);
RequestContext.setProduct(product);
//同步企业至ugp,成功返回true,失败返回false
return ugpServiceFeignClient.syncCompany(model);
}
};
FutureTask<ResponseModel<Boolean>> future = new FutureTask(callable);
Thread thread = new Thread(future);
thread.start();
// 1.插入单位注册许可信息表:tz_base_unit_licence
List<BaseUnitLicenceDto> unitLicenceDtos = model.getUnitLicences();
List<BaseUnitLicence> baseUnitLicences = unitLicenceDtos.stream().map(s -> {
......@@ -145,8 +176,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
// if (UnitReviewStateEnum.NO_NEED_REVIEW.getCode().equals(model.getState())) {
// 3.1 创建企业信息
this.createBaseEnterpriseInfo(model);
// 3.2 自动创建:调用平台进行创建单位、用户信息
this.createCompanyAndUser(regUnitInfo);
// }
// 4.插入注册单位基本信息表:tz_flc_reg_unit_info
this.save(regUnitInfo);
......@@ -157,6 +188,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
model.setUnitLicences(Bean.toModels(baseUnitLicences, BaseUnitLicenceDto.class));
// 5.3工商信息
model.setRegUnitIc(Bean.toModel(regUnitIc, new RegUnitIcDto()));
//获取多线程执行结果 true成功 false失败
if(!future.get().getResult()){
throw new Exception("UGP信息同步失败");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
// 失败后回滚:删除已经创建的企业信息
......@@ -180,6 +217,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
return model;
}
public void createBaseEnterpriseInfo(RegUnitInfoDto regUnitInfo) {
// 1.查询管辖公司的信息
FeignClientResult<CompanyModel> feignClientResult = Privilege.companyClient
......
......@@ -9,19 +9,19 @@ import java.util.HashMap;
@Getter
@AllArgsConstructor
public enum OrgEnum {
公司("COMPANY", "244", "公司",1,"studio_normalapp_4403119"),
部门("DEPARTMENT", "245", "部门",2,"studio_normalapp_4403119"),
普通人员("PERSON", "246", "普通人员",3,"studio_normalapp_4403119"),
焊工("WELDER","247","焊工",3,"studio_normalapp_4403119"),
管理员("USER","945","管理员",3,"ddd"),
建设单位负责人("CHARGE","254","建设单位负责人",3,"studio_normalapp_4403119"),
企业管理员("ADMIN","248","企业管理员",3,"studio_normalapp_4403119"),
建设单位("CONSTRUCTION","249","建设单位",1,"studio_normalapp_4403119,studio_normalapp_4760213"),
安装单位("INSTALL","250","安装单位",1,"studio_normalapp_4403119,studio_normalapp_4760213"),
设计单位("DESIGN","251","设计单位",1,"studio_normalapp_4403119,studio_normalapp_4760213"),
监察部门("SUPERVISION","252","监察部门",1,"studio_normalapp_4403119,studio_normalapp_4761616"),
监检机构("MONITORING","253","监检机构",1,"studio_normalapp_4403119,studio_normalapp_4761616"),
监理单位("SUPERVISOR","254","监理单位",1,"");
公司("COMPANY", "244", "公司",1,"studio_normalapp_4403119",""),
部门("DEPARTMENT", "245", "部门",2,"studio_normalapp_4403119",""),
普通人员("PERSON", "246", "普通人员",3,"studio_normalapp_4403119",""),
焊工("WELDER","247","焊工",3,"studio_normalapp_4403119",""),
管理员("USER","945","管理员",3,"ddd",""),
建设单位负责人("CHARGE","254","建设单位负责人",3,"studio_normalapp_4403119",""),
企业管理员("ADMIN","248","企业管理员",3,"studio_normalapp_4403119",""),
建设单位("CONSTRUCTION","249","建设单位",1,"studio_normalapp_4403119,studio_normalapp_4760213","1232"),
安装单位("INSTALL","250","安装单位",1,"studio_normalapp_4403119,studio_normalapp_4760213","1234"),
设计单位("DESIGN","251","设计单位",1,"studio_normalapp_4403119,studio_normalapp_4760213","1235"),
监察部门("SUPERVISION","252","监察部门",1,"studio_normalapp_4403119,studio_normalapp_4761616",""),
监检机构("MONITORING","253","监检机构",1,"studio_normalapp_4403119,studio_normalapp_4761616","1233"),
监理单位("SUPERVISOR","254","监理单位",1,"","1237");
private String key;
private String code;
......@@ -31,13 +31,20 @@ public enum OrgEnum {
*/
private Integer type;
private String appCode;
/**
* tzs服务字典对应code
*/
private String dictionaryCode;
public static HashMap<String,String> map= new HashMap();
public static HashMap<String, String> codeMap = new HashMap();
public static HashMap<String, String> dictionaryCodeMap = new HashMap();
static {
for(OrgEnum orgPersonEnum:OrgEnum.values()){
map.put(orgPersonEnum.getKey(),orgPersonEnum.getName());
codeMap.put(orgPersonEnum.getKey(),orgPersonEnum.getAppCode());
dictionaryCodeMap.put(orgPersonEnum.getDictionaryCode(),orgPersonEnum.getKey());
}
}
}
......@@ -106,6 +106,26 @@ public class CompanyController extends BaseController {
@Autowired
SuperviseRuleServiceImpl superviseRuleService;
/**
* tzs注册时同步ugp库
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PostMapping(value = "/syncCompany")
@ApiOperation(httpMethod = "POST", value = "tzs注册时同步ugp库", notes = "tzs注册时同步ugp库")
public ResponseModel<Boolean> syncCompany(@RequestBody Object object) {
Boolean bool = true;
try {
companyServiceImpl.syncCompany(object);
} catch (Exception e) {
e.printStackTrace();
bool = false;
}
return ResponseHelper.buildResponse(bool);
}
/**
* 新增企业信息表
......
......@@ -249,7 +249,11 @@ public class OrgServiceImpl {
* 用户单位信息redis获取
**/
public ReginParams getReginParams() {
try {
return JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
} catch (Exception e) {
return null;
}
}
/**
......@@ -542,7 +546,16 @@ public class OrgServiceImpl {
orgUsrServiceImpl.deleteBySeq(Long.valueOf(sequencenNbr));
}
/**
* 根据OrgUsr表的bizOrgName 查询
* @param bizOrgName
* @return
*/
public OrgUsr getInfoByName(String bizOrgName) {
LambdaQueryWrapper<OrgUsr> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(OrgUsr :: getBizOrgName,bizOrgName);
return orgUsrServiceImpl.getOne(wrapper);
}
/**
......
......@@ -24,6 +24,11 @@
<artifactId>amos-feign-workflow</artifactId>
<version>1.7.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-privilege</artifactId>
<version>1.8.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fakepath</groupId>
......
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