Commit f0ad8f26 authored by yangyang's avatar yangyang

refactor(amos-boot-module-tcm): 重构企业信息更新逻辑- 异步处理公司信息更新,提高系统稳定性

- 优化错误处理和日志记录,增强系统可追踪性 - 采用CompletableFuture实现异步更新公司信息 - 保留当前请求上下文,确保异步任务执行环境一致
parent 77863923
...@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
...@@ -67,6 +68,7 @@ import org.typroject.tyboot.core.restful.exception.instance.TooManyRequests; ...@@ -67,6 +68,7 @@ import org.typroject.tyboot.core.restful.exception.instance.TooManyRequests;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -1063,33 +1065,45 @@ public class TzBaseEnterpriseInfoServiceImpl ...@@ -1063,33 +1065,45 @@ public class TzBaseEnterpriseInfoServiceImpl
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public TzBaseEnterpriseInfoDto updateCompanyInfoById(Map<String, Object> map, ReginParams reginParams2) { public TzBaseEnterpriseInfoDto updateCompanyInfoById(Map<String, Object> map, ReginParams reginParams) {
log.info("根据ID修改企业信息 => {}, 更新人 => {}", map, RequestContext.getExeUserId()); log.info("根据ID修改企业信息 => {}, 更新人 => {}", map, RequestContext.getExeUserId());
try {
TzBaseEnterpriseInfo tzBaseEnterpriseInfo = new TzBaseEnterpriseInfo(); TzBaseEnterpriseInfo tzBaseEnterpriseInfo = new TzBaseEnterpriseInfo();
tzBaseEnterpriseInfo.setSequenceNbr(Long.valueOf(map.get("sequenceNbr").toString())); tzBaseEnterpriseInfo.setSequenceNbr(Long.valueOf(map.get("sequenceNbr").toString()));
tzBaseEnterpriseInfo = tzBaseEnterpriseInfoService.getById(tzBaseEnterpriseInfo.getSequenceNbr()); tzBaseEnterpriseInfo = tzBaseEnterpriseInfoService.getById(tzBaseEnterpriseInfo.getSequenceNbr());
String superviseOrgCode = ObjectUtils.isEmpty(map.get("superviseOrgCode")) ? null : String.valueOf(map.get("superviseOrgCode"));
if (!tzBaseEnterpriseInfo.getSuperviseCode().equals(superviseOrgCode)) {
System.out.println("监管单位变更");
}
//修改基本信息 //修改基本信息
tzBaseEnterpriseInfo.setEquipCategory(JSON.toJSONString(map.get("equipCategory"))); tzBaseEnterpriseInfo.setEquipCategory(JSON.toJSONString(map.get("equipCategory")));
Map<String, String> map1 = (Map<String, String>) map.get("longitudeLatitude"); Map<String, String> locationMap = (Map<String, String>) map.get("longitudeLatitude");
tzBaseEnterpriseInfo.setAddress(ObjectUtils.isEmpty(map1.get("address")) ? null : map1.get("address")); if (locationMap != null) {
tzBaseEnterpriseInfo.setLongitude(ObjectUtils.isEmpty(map1.get("longitude")) ? null : String.valueOf(map1.get("longitude"))); tzBaseEnterpriseInfo.setAddress(locationMap.get("address"));
tzBaseEnterpriseInfo.setLatitude(ObjectUtils.isEmpty(map1.get("latitude")) ? null : String.valueOf(map1.get("latitude"))); tzBaseEnterpriseInfo.setLongitude(locationMap.get("longitude"));
tzBaseEnterpriseInfo.setLatitude(locationMap.get("latitude"));
}
tzBaseEnterpriseInfo.setUseContact(ObjectUtils.isEmpty(map.get("useContact")) ? null : String.valueOf(map.get("useContact"))); tzBaseEnterpriseInfo.setUseContact(ObjectUtils.isEmpty(map.get("useContact")) ? null : String.valueOf(map.get("useContact")));
tzBaseEnterpriseInfo.setContactPhone(ObjectUtils.isEmpty(map.get("contactPhone")) ? null : String.valueOf(map.get("contactPhone"))); tzBaseEnterpriseInfo.setContactPhone(ObjectUtils.isEmpty(map.get("contactPhone")) ? null : String.valueOf(map.get("contactPhone")));
tzBaseEnterpriseInfo.setUnitBusinessLicense(ObjectUtils.isEmpty(map.get("unitBusinessLicense")) ? null : JSON.toJSONString(map.get("unitBusinessLicense"))); tzBaseEnterpriseInfo.setUnitBusinessLicense(ObjectUtils.isEmpty(map.get("unitBusinessLicense")) ? null : JSON.toJSONString(map.get("unitBusinessLicense")));
tzBaseEnterpriseInfo.setIndustrySupervisor(ObjectUtils.isEmpty(map.get("industrySupervisor")) ? null : String.valueOf(map.get("industrySupervisor"))); tzBaseEnterpriseInfo.setIndustrySupervisor(ObjectUtils.isEmpty(map.get("industrySupervisor")) ? null : String.valueOf(map.get("industrySupervisor")));
tzBaseEnterpriseInfo.setSuperviseOrgCode(ObjectUtils.isEmpty(map.get("superviseOrgCode")) ? null : String.valueOf(map.get("superviseOrgCode"))); tzBaseEnterpriseInfo.setSuperviseOrgCode(superviseOrgCode);
tzBaseEnterpriseInfo.setSuperviseOrgName(ObjectUtils.isEmpty(map.get("superviseOrgName")) ? null : String.valueOf(map.get("superviseOrgName"))); tzBaseEnterpriseInfo.setSuperviseOrgName(ObjectUtils.isEmpty(map.get("superviseOrgName")) ? null : String.valueOf(map.get("superviseOrgName")));
tzBaseEnterpriseInfo.setOtherAccessories(ObjectUtils.isEmpty(map.get("otherAccessories")) ? null : JSON.toJSONString(map.get("otherAccessories"))); tzBaseEnterpriseInfo.setOtherAccessories(ObjectUtils.isEmpty(map.get("otherAccessories")) ? null : JSON.toJSONString(map.get("otherAccessories")));
tzBaseEnterpriseInfo.setLegalPerson(ObjectUtils.isEmpty(map.get("legalPerson")) ? null : (String)map.get("legalPerson")); tzBaseEnterpriseInfo.setLegalPerson(ObjectUtils.isEmpty(map.get("legalPerson")) ? null : (String)map.get("legalPerson"));
String officeRegion = null; String officeRegion = null;
if(!ObjectUtils.isEmpty(map.get("officeRegion"))){ if(!ObjectUtils.isEmpty(map.get("officeRegion"))){
List list = (List<Object>) map.get("officeRegion"); List<?> list = (List<?>) map.get("officeRegion");
officeRegion = list.stream().map(String::valueOf).collect(Collectors.joining("#")).toString(); officeRegion = list.stream().map(String::valueOf).collect(Collectors.joining("#")).toString();
} }
tzBaseEnterpriseInfo.setOfficeRegion(officeRegion); tzBaseEnterpriseInfo.setOfficeRegion(officeRegion);
tzBaseEnterpriseInfo.setOfficeAddress(ObjectUtils.isEmpty(map.get("officeAddress")) ? null : (String)map.get("officeAddress")); tzBaseEnterpriseInfo.setOfficeAddress(ObjectUtils.isEmpty(map.get("officeAddress")) ? null : (String)map.get("officeAddress"));
// 修改事业单位信息 // 修改事业单位信息
if (map.containsKey("regUnitMessage")) {
TzsBaseInstitutionDto baseInstitutionDto = JSON.toJavaObject(JSON.parseObject(JSON.toJSONString(map.get("regUnitMessage"))), TzsBaseInstitutionDto.class); TzsBaseInstitutionDto baseInstitutionDto = JSON.toJavaObject(JSON.parseObject(JSON.toJSONString(map.get("regUnitMessage"))), TzsBaseInstitutionDto.class);
if (!ValidationUtil.isEmpty(baseInstitutionDto)) { if (!ValidationUtil.isEmpty(baseInstitutionDto)) {
TzsBaseInstitution baseInstitution = new TzsBaseInstitution(); TzsBaseInstitution baseInstitution = new TzsBaseInstitution();
...@@ -1102,6 +1116,8 @@ public class TzBaseEnterpriseInfoServiceImpl ...@@ -1102,6 +1116,8 @@ public class TzBaseEnterpriseInfoServiceImpl
tzsBaseInstitutionService.saveOrUpdate(baseInstitution); tzsBaseInstitutionService.saveOrUpdate(baseInstitution);
} }
}
// 修改tz_flc_reg_unit_info表信息 // 修改tz_flc_reg_unit_info表信息
LambdaQueryWrapper<RegUnitInfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RegUnitInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RegUnitInfo::getUnitCode, tzBaseEnterpriseInfo.getUseCode()); queryWrapper.eq(RegUnitInfo::getUnitCode, tzBaseEnterpriseInfo.getUseCode());
...@@ -1125,54 +1141,11 @@ public class TzBaseEnterpriseInfoServiceImpl ...@@ -1125,54 +1141,11 @@ public class TzBaseEnterpriseInfoServiceImpl
regUnitInfo.setContactPerson(tzBaseEnterpriseInfo.getUseContact()); regUnitInfo.setContactPerson(tzBaseEnterpriseInfo.getUseContact());
// 处理单位信息 // 处理单位信息
handleUnitType(map, regUnitInfo, agencyUserModel); handleUnitType(map, regUnitInfo, agencyUserModel);
String[] unitTypes = regUnitInfo.getUnitType().split(","); String[] unitTypes = regUnitInfo.getUnitType().split(",");
regUnitInfoService.saveOrUpdate(regUnitInfo); regUnitInfoService.saveOrUpdate(regUnitInfo);
// -- 20250627 调整为监管单位不能修改工商信息和资质 // -- 20250627 调整为监管单位不能修改工商信息和资质
//修改工商信息
// RegUnitIc regUnitIc = new RegUnitIc();
// RegUnitIcDto regUnitIcDto = JSON.parseObject(JSON.toJSONString(map.get("regUnitIcDto")), new TypeReference<RegUnitIcDto>() {
// });
// if (!ValidationUtil.isEmpty(regUnitIcDto.getSequenceNbr())) {
// List<String> addressList = (List<String>) map.get("registerAddressList");
// tzBaseEnterpriseInfo.setProvince(addressList.get(0));
// tzBaseEnterpriseInfo.setCity(addressList.get(1));
// tzBaseEnterpriseInfo.setDistrict(addressList.get(2));
// tzBaseEnterpriseInfo.setCommunity(ObjectUtils.isEmpty(map.get("community")) ? null : String.valueOf(map.get("community")));
// tzBaseEnterpriseInfo.setStreet(ObjectUtils.isEmpty(map.get("street")) ? null : String.valueOf(map.get("street")));
// // tzBaseEnterpriseInfo.setAddress(ObjectUtils.isEmpty(map.get("regAddress")) ? null : String.valueOf(map.get("regAddress")));
// tzBaseEnterpriseInfo.setLegalPerson(ObjectUtils.isEmpty(map.get("legalPerson")) ? null : String.valueOf(map.get("legalPerson")));
// regUnitIc.setIndustryName(ObjectUtils.isEmpty(map.get("industryName")) ? null : String.valueOf(map.get("industryName")));
// DataDictionary regOrganCodeDict = iDataDictionaryService.getByCode(String.valueOf(map.get("registeredOrganCode")),"DJJG");
// regUnitIc.setRegisteredOrgan(ObjectUtils.isEmpty(regOrganCodeDict) ? null : String.valueOf(regOrganCodeDict.getName()));
// regUnitIc.setRegisteredOrganCode(ObjectUtils.isEmpty(map.get("registeredOrganCode")) ? null : String.valueOf(map.get("registeredOrganCode")));
// Date approvedDate;
// try {
// approvedDate = DateUtils.dateParse(String.valueOf(map.get("approvedDate")), "yyyy-MM-dd");
// } catch (ParseException e) {
// throw new RuntimeException(e);
// }
// regUnitIc.setBusinessStateCode(ObjectUtils.isEmpty(map.get("businessState")) ? null : String.valueOf(map.get("businessState")));
// DataDictionary businessStateDict = iDataDictionaryService.getByCode(String.valueOf(map.get("businessState")),"jyzt");
// regUnitIc.setBusinessState(ObjectUtils.isEmpty(businessStateDict) ? null : businessStateDict.getName());
// regUnitIc.setApprovedDate(ObjectUtils.isEmpty(map.get("approvedDate")) ? null : approvedDate);
//
// regUnitIcService.update(regUnitIc, new QueryWrapper<RegUnitIc>().eq("unit_code", regUnitIcDto.getUnitCode()));
// }
//许可信息先登录人选择的身份删除相应的许可信息,原因前端列表对数据可增减
// String useCode = tzBaseEnterpriseInfo.getUseCode();
// String certTypeCodes = Arrays.stream(unitTypes).map(e -> COMPANY_TYPE_CERT_TYPE_MAP.getOrDefault(e, "")).collect(Collectors.joining(","));
// if (useCode != null && !certTypeCodes.isEmpty()) {
// LambdaQueryWrapper<BaseUnitLicence> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(BaseUnitLicence::getUnitCode, useCode);
// wrapper.and(w -> Arrays.stream(certTypeCodes.split(","))
// .forEach(certTypeCode -> w.or().likeRight(BaseUnitLicence::getCertTypeCode, certTypeCode)));
// baseUnitLicenceService.remove(wrapper);
// }
// //报错许可许可信息
// saveLicenceData(map);
// 企业信息变更-同步修改企业下人员绑定设备类型 // 企业信息变更-同步修改企业下人员绑定设备类型
ArrayList<String> newData = new ArrayList<>(); ArrayList<String> newData = new ArrayList<>();
JSONArray objects = JSON.parseArray(tzBaseEnterpriseInfo.getEquipCategory()); JSONArray objects = JSON.parseArray(tzBaseEnterpriseInfo.getEquipCategory());
...@@ -1181,19 +1154,36 @@ public class TzBaseEnterpriseInfoServiceImpl ...@@ -1181,19 +1154,36 @@ public class TzBaseEnterpriseInfoServiceImpl
tzBaseEnterpriseInfo.setAppId(regUnitInfo.getAppId()); tzBaseEnterpriseInfo.setAppId(regUnitInfo.getAppId());
tzBaseEnterpriseInfo.setUnitType(String.join("#", unitTypes)); tzBaseEnterpriseInfo.setUnitType(String.join("#", unitTypes));
boolean b = tzBaseEnterpriseInfoService.updateById(tzBaseEnterpriseInfo); boolean updateResult = tzBaseEnterpriseInfoService.updateById(tzBaseEnterpriseInfo);
if (b) { if (updateResult) {
CompanyModel updateModel = updateCompany(map, regUnitInfo, agencyUserModel); log.info("更新企业信息, 单位类型 => {}", tzBaseEnterpriseInfo.getUseUnitCode());
updateUnit(map, regUnitInfo, agencyUserModel, updateModel);// slow String useCode = String.valueOf(map.get("useCode"));
updateUserInfo(newData, String.valueOf(map.get("useCode"))); CompanyModel updateModel = Privilege.companyClient.queryByCompanyCode(useCode).getResult();
asyncPlatformCompany(map, agencyUserModel);// slow HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(String.valueOf(map.get("superviseOrgCode"))).getResult();
redisUtil.del(RedisKey.buildReginRoleKey(agencyUserModel.getUserId())); // 目前平台返回key为compnay(存在拼写错误)
CompanyModel parentModel = JSON.parseObject(JSON.toJSONString(parentMessage.get("compnay")), CompanyModel.class);
updateModel.setParentId(parentModel.getSequenceNbr());// 更新单位的上下级
updateModel.setCompanyType(regUnitInfo.getUnitType());// 更新单位类型
updateCompanyInfo(tzBaseEnterpriseInfo, updateModel);
log.info("更新企业信息, 单位 => {}", tzBaseEnterpriseInfo.getUseUnitCode());
updateUnit(map, regUnitInfo, agencyUserModel, updateModel);
log.info("更新企业信息, 注册用户 => {}", tzBaseEnterpriseInfo.getUseUnitCode());
updateUserInfo(newData, useCode);
// 同步平台并且刷新历史数据
asyncPlatformAndRefreshHistoricalData(useCode);
TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto = new TzBaseEnterpriseInfoDto(); TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto = new TzBaseEnterpriseInfoDto();
BeanUtils.copyProperties(tzBaseEnterpriseInfo, tzBaseEnterpriseInfoDto); BeanUtils.copyProperties(tzBaseEnterpriseInfo, tzBaseEnterpriseInfoDto);
// 更新完成后清理缓存
redisUtil.del(RedisKey.buildReginRoleKey(agencyUserModel.getUserId()));
return tzBaseEnterpriseInfoDto; return tzBaseEnterpriseInfoDto;
} else { } else {
return null; return null;
} }
} catch (Exception e) {
log.error("更新企业信息失败: ", e);
throw new BadRequest("更新企业信息失败!");
}
} }
@Transactional (rollbackFor = Exception.class) @Transactional (rollbackFor = Exception.class)
...@@ -1202,25 +1192,19 @@ public class TzBaseEnterpriseInfoServiceImpl ...@@ -1202,25 +1192,19 @@ public class TzBaseEnterpriseInfoServiceImpl
return userInfoService.personalInfoUpdateById((Map<String, Object>) map.get("raw")); return userInfoService.personalInfoUpdateById((Map<String, Object>) map.get("raw"));
} }
private CompanyModel updateCompany(Map<String, Object> map, RegUnitInfo regUnitInfo, AgencyUserModel agencyUserModel) { private void updateCompanyInfo(TzBaseEnterpriseInfo tzBaseEnterpriseInfo, CompanyModel updateModel) {
CompanyModel updateModel;
try {
updateModel = Privilege.companyClient.queryByCompanyCode(String.valueOf(map.get("useCode"))).getResult();
HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(String.valueOf(map.get("superviseOrgCode"))).getResult();
// 目前平台返回key为compnay(存在拼写错误)
CompanyModel parentModel = JSON.parseObject(JSON.toJSONString(parentMessage.get("compnay")), CompanyModel.class);
updateModel.setParentId(parentModel.getSequenceNbr());
updateModel.setCompanyType(regUnitInfo.getUnitType());// 更新单位类型
FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.update(updateModel, updateModel.getSequenceNbr()); FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.update(updateModel, updateModel.getSequenceNbr());
log.info("更新单位类型结果:{}", companyResult);
if (companyResult == null || companyResult.getStatus() != 200) { if (companyResult == null || companyResult.getStatus() != 200) {
throw new BadRequest("更新单位类型失败!"); log.error("更新单位错误: {}", companyResult);
} throw new BadRequest("更新单位失败!");
return updateModel;
} catch (Exception e) {
throw new BadRequest("更新单位类型失败!");
} }
String orgCode = Optional.ofNullable(companyResult.getResult()).map(CompanyModel::getOrgCode).orElse(null);
updateModel.setOrgCode(orgCode);
// 更新企业的org_code
UpdateWrapper<TzBaseEnterpriseInfo> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("org_code", orgCode);
updateWrapper.eq("sequence_nbr", tzBaseEnterpriseInfo.getSequenceNbr());
tzBaseEnterpriseInfoService.update(updateWrapper);
} }
private void handleUnitType(Map<String, Object> map, RegUnitInfo regUnitInfo, AgencyUserModel agencyUserModel) { private void handleUnitType(Map<String, Object> map, RegUnitInfo regUnitInfo, AgencyUserModel agencyUserModel) {
...@@ -1257,10 +1241,9 @@ public class TzBaseEnterpriseInfoServiceImpl ...@@ -1257,10 +1241,9 @@ public class TzBaseEnterpriseInfoServiceImpl
// 省内充装单位1231:生成对接数据账号 // 省内充装单位1231:生成对接数据账号
// final String FILLING_UNIT_TYPE = RegUnitInfoServiceImpl.FILLING_UNIT_TYPE; // final String FILLING_UNIT_TYPE = RegUnitInfoServiceImpl.FILLING_UNIT_TYPE;
// 20250701 改为全部企业类型生成对接数据账号@tianbo // 20250701 改为全部企业类型生成对接数据账号@tianbo
if (ValidationUtil.isEmpty(regUnitInfo.getIsNationwide()) || "0".equals(regUnitInfo.getIsNationwide())) {
// if (unitTypeCodes.contains(FILLING_UNIT_TYPE) // if (unitTypeCodes.contains(FILLING_UNIT_TYPE)
// && (ValidationUtil.isEmpty(regUnitInfo.getIsNationwide()) || "0".equals(regUnitInfo.getIsNationwide()))) { // && (ValidationUtil.isEmpty(regUnitInfo.getIsNationwide()) || "0".equals(regUnitInfo.getIsNationwide()))) {
if (ValidationUtil.isEmpty(regUnitInfo.getIsNationwide()) || "0".equals(regUnitInfo.getIsNationwide())) {
if (ValidationUtil.isEmpty(regUnitInfo.getAppId())) { if (ValidationUtil.isEmpty(regUnitInfo.getAppId())) {
String appId = DesUtil.encode(regUnitInfo.getAdminUserId(), RegUnitInfoServiceImpl.SECRETKEY); String appId = DesUtil.encode(regUnitInfo.getAdminUserId(), RegUnitInfoServiceImpl.SECRETKEY);
...@@ -1328,35 +1311,51 @@ public class TzBaseEnterpriseInfoServiceImpl ...@@ -1328,35 +1311,51 @@ public class TzBaseEnterpriseInfoServiceImpl
} }
} }
private void asyncPlatformCompany(Map<String, Object> map, AgencyUserModel agencyUserModel) { /**
String useCode = String.valueOf(map.get("useCode")); * 同步平台并且刷新历史数据
*
*
* @param useCode useCode
* @author yangyang
* @date 2025/7/1 14:50
*/
private void asyncPlatformAndRefreshHistoricalData(String useCode) {
// 同步平台ORG_CODE // 同步平台ORG_CODE
System.out.println(map);
// Privilege.companyClient.update();
LambdaQueryWrapper<TzsUserInfo> lambda = new QueryWrapper<TzsUserInfo>().lambda(); LambdaQueryWrapper<TzsUserInfo> lambda = new QueryWrapper<TzsUserInfo>().lambda();
lambda.eq(TzsUserInfo::getUnitCode, useCode); lambda.eq(TzsUserInfo::getUnitCode, useCode);
lambda.isNotNull(TzsUserInfo::getAmosUserId); lambda.isNotNull(TzsUserInfo::getAmosUserId);
List<TzsUserInfo> tzsUserInfos = tzsUserInfoMapper.selectList(lambda); List<TzsUserInfo> tzsUserInfos = tzsUserInfoMapper.selectList(lambda);
if (!ValidationUtil.isEmpty(tzsUserInfos)) {
String userIds = tzsUserInfos.stream().map(TzsUserInfo::getAmosUserId).collect(Collectors.joining(","));
FeignClientResult<List<AgencyUserModel>> agencyUserClientResult = Privilege.agencyUserClient.queryByIds(userIds, false);
List<AgencyUserModel> agencyUserModels = agencyUserClientResult.getResult();
for (AgencyUserModel userModel : agencyUserModels) {
FeignClientResult<AgencyUserModel> userResult = Privilege.agencyUserClient.update(userModel, userModel.getUserId());
System.out.println(userResult);
}
}
// 异步刷新历史数据 // 异步刷新历史数据
String token = RequestContext.getToken(); String token = RequestContext.getToken();
String appKey = RequestContext.getAppKey(); String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct(); String product = RequestContext.getProduct();
threadPoolTaskExecutor.execute(() -> { threadPoolTaskExecutor.execute(() -> {
RequestContext.setToken(token); RequestContext.setToken(token);
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
RequestContext.setProduct(product); RequestContext.setProduct(product);
// todo 调用刷新历史数据接口
try {
// 刷新平台的企业下面用户的super_org_code
if (!ValidationUtil.isEmpty(tzsUserInfos)) {
String userIds = tzsUserInfos.stream().map(TzsUserInfo::getAmosUserId).collect(Collectors.joining(","));
FeignClientResult<List<AgencyUserModel>> agencyUserClientResult = Privilege.agencyUserClient.queryByIds(userIds, false);
if (agencyUserClientResult != null && agencyUserClientResult.getResult() != null) {
List<AgencyUserModel> agencyUserModels = agencyUserClientResult.getResult();
for (AgencyUserModel userModel : agencyUserModels) {
// 更新, 刷新企业下用户的super_org_code
try { try {
Privilege.agencyUserClient.update(userModel, userModel.getUserId());
} catch (Exception e) {
log.error("更新用户 {} 的 super_org_code 失败", userModel.getUserId(), e);
}
}
}
}
// todo 调用刷新历史数据接口
} catch (Exception e) {
log.error("异步刷新企业用户信息发生异常", e);
} finally { } finally {
RequestContext.clean(); RequestContext.clean();
} }
......
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