Commit e9645190 authored by tianbo's avatar tianbo

refactor(tcm): 移除异步调用逻辑并优化企业信息查询

- 删除与UGP同步相关的多线程调用代码 - 简化企业信息查询条件,优化SQL逻辑-修复SQL中参数引用错误问题 - 在异常处理中增加堆栈跟踪打印
parent 0db6da1a
......@@ -111,9 +111,9 @@
<when test="( tzBaseEnterpriseInfoDto.unitType == '检验机构'
or tzBaseEnterpriseInfoDto.unitType == '检测机构'
or tzBaseEnterpriseInfoDto.unitType == ''
or tzBaseEnterpriseInfoDto.unitType == null ) and tzBaseEnterpriseInfoDto.orgCode!= '' ">
or tzBaseEnterpriseInfoDto.unitType == null ) and orgCode!= '' ">
and ((supervise_org_code != '50' and supervise_org_code LIKE CONCAT (#{orgCode}, '%'))
or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{regionCode}, '%')))
or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{officeRegion}, '%')))
</when>
<otherwise>
and supervise_org_code LIKE CONCAT(#{orgCode}, '%')
......@@ -157,13 +157,12 @@
or tzBaseEnterpriseInfoDto.unitType == ''
or tzBaseEnterpriseInfoDto.unitType == null">
and ((supervise_org_code != '50' and supervise_org_code LIKE CONCAT (#{tzBaseEnterpriseInfoDto.superviseOrgCode}, '%'))
or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{tzBaseEnterpriseInfoDto.OfficeRegionStr}, '%')))
or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{tzBaseEnterpriseInfoDto.officeRegionStr}, '%')))
</when>
<otherwise>
and supervise_org_code LIKE CONCAT(#{orgCode}, '%')
AND supervise_org_code LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.superviseOrgCode},'%')
</otherwise>
</choose>
AND supervise_org_code LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.superviseOrgCode},'%')
</if>
<if test="tzBaseEnterpriseInfoDto.address!=null and tzBaseEnterpriseInfoDto.address!='' ">
AND address LIKE CONCAT('%',#{tzBaseEnterpriseInfoDto.address},'%')
......@@ -188,16 +187,8 @@
)
</if>
<if test="orgCodeList != null and ! orgCodeList.isEmpty() and orgCodeList.size() > 0">
<foreach collection="orgCodeList" item="item" index="index" >
<if test="index==0">
AND
</if>
<if test="index!= 0">
OR
</if>
supervise_org_code LIKE CONCAT('%', #{item}, '%')
</foreach>
<if test="orgCode != null and orgCode != ''">
AND supervise_org_code LIKE CONCAT('%', #{orgCode}, '%')
</if>
AND is_delete = 0
</where>
......
......@@ -242,6 +242,7 @@ public class TzBaseEnterpriseInfoServiceImpl
|| msg.contains("decrypt error, code: -65")) {
throw new BadRequest("数据完整性被破坏(解密失败),请联系管理员。");
}
ex.printStackTrace();
throw new BadRequest("系统内部错误,请联系管理员。");
}
}
......
......@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
......@@ -75,19 +76,15 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StopWatch;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
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;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -204,8 +201,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
regUnitInfo.setUnitTypeCode(StringUtils.join(model.getUnitTypeCodeList(), ","));
// 1.调用平台进行创建单位、用户信息
this.createCompanyAndUser(regUnitInfo);
// 2.异步调用ugp,同步公司数据
FutureTask<ResponseModel<Boolean>> future = getResponseModelFutureTask(model);
//添加不在字典中的登记机关
List<String> approvedOrganList = Stream.concat(
model.getUnitLicences() == null ? Stream.empty() :
......@@ -268,10 +263,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
model.setUnitLicences(Bean.toModels(baseUnitLicences, BaseUnitLicenceDto.class));
// 7.3工商信息
model.setRegUnitIc(Bean.toModel(regUnitIc, new RegUnitIcDto()));
//8.获取多线程执行结果 true成功 false失败(tzs和ugp一起后放开)
if (isUgp && future != null && !Boolean.TRUE.equals(future.get().getResult())) {
throw new BadRequest("UGP信息同步失败");
}
watch.stop();
if (logger.isDebugEnabled()) {
logger.debug("注册总耗时:==》{}", watch.getTotalTimeSeconds());
......@@ -376,27 +367,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
}
private FutureTask<ResponseModel<Boolean>> getResponseModelFutureTask(RegUnitInfoDto model) {
//多线程同步ugp信息(tzs和ugp一起后放开)
FutureTask<ResponseModel<Boolean>> future = null;
if (isUgp) {
String token = RequestContext.getToken();
String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct();
Callable callable = () -> {
RequestContext.setToken(token);
RequestContext.setAppKey(appKey);
RequestContext.setProduct(product);
//同步企业至ugp,成功返回true,失败返回false
return ugpServiceFeignClient.syncCompany(model);
};
future = new FutureTask(callable);
Thread thread = new Thread(future);
thread.start();
}
return future;
}
private static String createQRCode(String unitCode) {
String urlString = null;
byte[] bytes = QRCodeUtil.generateQRCodeImageByteData(unitCode, 150);
......@@ -602,7 +572,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
if (!ValidationUtil.isEmpty(orgCode)) {
companyModels = findNodesByCondition(companyModels, "orgCode", orgCode, "children");
companyModels = (List<LinkedHashMap>) companyModels.get(0).get("children");
companyModels = Lists.newArrayList(companyModels.get(0));
}
return companyModels;
}
......
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