Commit 238fe62a authored by suhuiguang's avatar suhuiguang

1.性能优化数据预热,异步调用

parent 7146b2b5
...@@ -85,18 +85,18 @@ public class ControllerAop { ...@@ -85,18 +85,18 @@ public class ControllerAop {
urls.add("/api/user/save/curCompany"); urls.add("/api/user/save/curCompany");
urls.add("/jcs/command/lookHtmlText"); urls.add("/jcs/command/lookHtmlText");
urls.add("^/jcs/common/duty-person/findByDutyAreaId/[A-Za-z0-9]+$"); urls.add("^/jcs/common/duty-person/findByDutyAreaId/[A-Za-z0-9]+$");
urls.add("/tzs/wechatBack"); urls.add("/tcm/wechatBack");
urls.add("/tzs/elevator/getElevatorInfo"); urls.add("/elevator/elevator/getElevatorInfo");
urls.add("/openapi/bizToken/applyToken"); urls.add("/openapi/bizToken/applyToken");
urls.add("/tzs/flc-unit-info/region/tree"); urls.add("/tcm/flc-unit-info/region/tree");
urls.add("/tzs/reg-unit-info/management-unit/tree"); urls.add("/tcm/reg-unit-info/management-unit/tree");
urls.add("/tzs/reg-unit-info/unit-type/list"); urls.add("/tcm/reg-unit-info/unit-type/list");
urls.add("^/tzs/flc-unit-info/hasExistPhone/[0-9]+$"); urls.add("^/tcm/flc-unit-info/hasExistPhone/[0-9]+$");
urls.add("^/tzs/flc-unit-info/sendTelCode/[0-9]+$"); urls.add("^/tcm/flc-unit-info/sendTelCode/[0-9]+$");
urls.add("^/tzs/reg-unit-info/[A-Za-z0-9]+/check$"); urls.add("^/tcm/reg-unit-info/[A-Za-z0-9]+/check$");
urls.add("^/tzs/flc-unit-info/verifyTelCode/[A-Za-z0-9]+/[A-Za-z0-9]+"); urls.add("^/tcm/flc-unit-info/verifyTelCode/[A-Za-z0-9]+/[A-Za-z0-9]+");
urls.add("^/tzs/flc-unit-info/hasExistUser/[A-Za-z0-9_-]+"); urls.add("^/tcm/flc-unit-info/hasExistUser/[A-Za-z0-9_-]+");
urls.add("/tzs/reg-unit-info/save"); urls.add("/tcm/reg-unit-info/save");
// 获取请求路径 // 获取请求路径
for (String uri : urls) { for (String uri : urls) {
Pattern p = Pattern.compile(uri); Pattern p = Pattern.compile(uri);
......
...@@ -11,4 +11,9 @@ public interface BizCommonConstant { ...@@ -11,4 +11,9 @@ public interface BizCommonConstant {
* 所有平台企业数据redisKey * 所有平台企业数据redisKey
*/ */
String COMPANY_TREE_REDIS_KEY = "REGULATOR_UNIT_TREE"; String COMPANY_TREE_REDIS_KEY = "REGULATOR_UNIT_TREE";
/**
* 所有区划企业数据redisKey
*/
String REGION_TREE_REDIS_KEY = "REGION_TREE_TCM";
} }
...@@ -20,7 +20,7 @@ import java.util.List; ...@@ -20,7 +20,7 @@ import java.util.List;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value="RegUnitInfoDto", description="单位注册信息表") @ApiModel(value = "RegUnitInfoDto", description = "单位注册信息表")
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class RegUnitInfoDto extends BaseDto { public class RegUnitInfoDto extends BaseDto {
...@@ -51,6 +51,12 @@ public class RegUnitInfoDto extends BaseDto { ...@@ -51,6 +51,12 @@ public class RegUnitInfoDto extends BaseDto {
@ApiModelProperty(value = "管辖单位id") @ApiModelProperty(value = "管辖单位id")
private String managementUnitId; private String managementUnitId;
@ApiModelProperty(value = "管辖单位编码")
private String managementUnitCompanyCode;
@ApiModelProperty(value = "管辖单位orgCode")
private String managementUnitOrgCode;
@ApiModelProperty(value = "区域编码") @ApiModelProperty(value = "区域编码")
private String regionCode; private String regionCode;
......
...@@ -5,7 +5,9 @@ import com.yeejoin.amos.boot.module.tcm.flc.api.dto.UnitInfoApproveDto; ...@@ -5,7 +5,9 @@ import com.yeejoin.amos.boot.module.tcm.flc.api.dto.UnitInfoApproveDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.dto.UnitInfoDto; import com.yeejoin.amos.boot.module.tcm.flc.api.dto.UnitInfoDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.entity.UnitInfo; import com.yeejoin.amos.boot.module.tcm.flc.api.entity.UnitInfo;
import com.yeejoin.amos.boot.module.tcm.flc.api.entity.UnitInfoChange; import com.yeejoin.amos.boot.module.tcm.flc.api.entity.UnitInfoChange;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
...@@ -42,4 +44,10 @@ public interface IUnitInfoService { ...@@ -42,4 +44,10 @@ public interface IUnitInfoService {
List<UnitInfoDto> getUseUnit(String unitType, String address, String orgName, String organizationCode); List<UnitInfoDto> getUseUnit(String unitType, String address, String orgName, String organizationCode);
Boolean addQRcode(); Boolean addQRcode();
/**
* 单位树
* @return Collection<RegionModel>
*/
Collection<RegionModel> getRegionTree(Long parentId);
} }
package com.yeejoin.amos; package com.yeejoin.amos;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils; import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.amos.boot.module.tcm.biz.listener.BaseEnterpriseMqTtlListener; import com.yeejoin.amos.boot.module.tcm.biz.listener.BaseEnterpriseMqTtlListener;
import com.yeejoin.amos.boot.module.tcm.biz.listener.CarcylUnitInspectMqTtlListener; import com.yeejoin.amos.boot.module.tcm.biz.listener.CarcylUnitInspectMqTtlListener;
import com.yeejoin.amos.boot.module.tcm.biz.listener.PrivilegeCompanyDeleteListener; import com.yeejoin.amos.boot.module.tcm.biz.listener.PrivilegeCompanyDeleteListener;
import com.yeejoin.amos.boot.module.tcm.biz.listener.PrivilegeCompanyUpdateAddListener; import com.yeejoin.amos.boot.module.tcm.biz.listener.PrivilegeCompanyUpdateAddListener;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.EquipmentCategoryServiceImpl;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.StartPlatformTokenService; import com.yeejoin.amos.boot.module.tcm.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil;
import com.yeejoin.amos.boot.module.tcm.flc.api.service.IUnitInfoService;
import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.UnitInfoServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -30,6 +38,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; ...@@ -30,6 +38,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.List;
/** /**
* <pre> * <pre>
...@@ -76,6 +85,15 @@ public class AmosTcmApplication { ...@@ -76,6 +85,15 @@ public class AmosTcmApplication {
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String applicationName; private String applicationName;
@Autowired
RedisUtil redisUtil;
@Autowired
EquipmentCategoryServiceImpl equipmentCategoryService;
@Autowired
UnitInfoServiceImpl unitInfoService;
public static void main(String[] args) throws UnknownHostException { public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmosTcmApplication.class, args); ConfigurableApplicationContext context = SpringApplication.run(AmosTcmApplication.class, args);
...@@ -103,8 +121,17 @@ public class AmosTcmApplication { ...@@ -103,8 +121,17 @@ public class AmosTcmApplication {
} }
@Bean @Bean
public void initToken() { public void init() {
//1.登录
startPlatformTokenService.getToken(); startPlatformTokenService.getToken();
//2.角色数据放redis缓存(依赖1)
FeignClientResult<List<RoleModel>> roleListResult = Privilege.roleClient.queryRoleList(null, null);
List<RoleModel> roleModels = roleListResult.getResult();
redisUtil.set(RedisUtil.ROLE_REDIS_KEY, JSONObject.toJSONString(roleModels));
//3.管辖机构放redis缓存(依赖1)
equipmentCategoryService.creatTree();
//4.区域放redis缓存(依赖1)
unitInfoService.getAllRegionTree();
} }
......
package com.yeejoin.amos.boot.module.tcm.biz.service.impl; package com.yeejoin.amos.boot.module.tcm.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil; import com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.yeejoin.amos.component.robot.AmosRequestContext; import java.util.List;
import static com.alibaba.fastjson.JSON.parseArray;
/**
* requestContext设置
* @author Administrator
*/
@Service @Service
public class StartPlatformTokenService { public class StartPlatformTokenService {
@Value("${admin.product}") @Autowired
String product; AmosRequestContext amosRequestContext;
@Value("${admin.appkey}") @Autowired
String appkey; RedisUtil redisUtil;
@Value("${admin.user}")
String user;
@Value("${admin.password}") public void getToken() {
String password; RequestContext.setProduct(amosRequestContext.getProduct());
RequestContext.setAppKey(amosRequestContext.getAppKey());
RequestContext.setToken(amosRequestContext.getToken());
}
@Value("${amos.secret.key}")
String secretKey;
@Autowired public void setRequestContext() {
RedisUtil redisUtil; RequestContext.setProduct(amosRequestContext.getProduct());
RequestContext.setAppKey(amosRequestContext.getAppKey());
RequestContext.setToken(amosRequestContext.getToken());
}
@Autowired public List<RoleModel> getAllRole(){
AmosRequestContext amosRequestContext; List<RoleModel> roleModels;
if(redisUtil.hasKey(RedisUtil.ROLE_REDIS_KEY)){
roleModels = parseArray(redisUtil.get(RedisUtil.ROLE_REDIS_KEY).toString(),RoleModel.class);
return roleModels;
} else {
FeignClientResult<List<RoleModel>> roleListResult = Privilege.roleClient.queryRoleList(null, null);
roleModels = roleListResult.getResult();
redisUtil.set(RedisUtil.ROLE_REDIS_KEY, JSONObject.toJSONString(roleModels));
}
return roleModels;
}
public void getToken() {
RequestContext.setProduct(product);
RequestContext.setAppKey(appkey);
String token = amosRequestContext.getToken();
System.out.println("token:" + token);
RequestContext.setToken(token);
redisUtil.set("platform_token", token);
}
} }
...@@ -18,6 +18,13 @@ import java.util.concurrent.TimeUnit; ...@@ -18,6 +18,13 @@ import java.util.concurrent.TimeUnit;
**/ **/
@Component @Component
public class RedisUtil { public class RedisUtil {
/**
* 单位注册,角色key
*/
public static String ROLE_REDIS_KEY = "UNIT_REGISTER_ROLE_REDIS";
@Autowired @Autowired
private RedisTemplate<String, Object> redisTemplate; private RedisTemplate<String, Object> redisTemplate;
......
...@@ -102,32 +102,10 @@ public class UnitInfoController extends BaseController { ...@@ -102,32 +102,10 @@ public class UnitInfoController extends BaseController {
@GetMapping(value = "/region/tree") @GetMapping(value = "/region/tree")
@ApiOperation(httpMethod = "GET", value = "获取组织机构树", notes = "获取组织机构树") @ApiOperation(httpMethod = "GET", value = "获取组织机构树", notes = "获取组织机构树")
public ResponseModel<Collection<RegionModel>> getRegionTree(@RequestParam(value = "parentId",required = false) Long parentId) { public ResponseModel<Collection<RegionModel>> getRegionTree(@RequestParam(value = "parentId",required = false) Long parentId) {
tzsAuthServiceImpl.setRequestContext(); return ResponseHelper.buildResponse(unitInfoServiceImpl.getRegionTree(parentId));
Collection<RegionModel> result = null;
if(parentId == null) {
result = Systemctl.regionClient.queryForTree(null).getResult();
} else {
result = Systemctl.regionClient.querySubAgencyTree(parentId).getResult();
}
despace(result);
return ResponseHelper.buildResponse(result);
} }
/**
* 去区域树中level多余空格
* @param result
*/
public void despace(Collection<RegionModel> result){
Iterator<RegionModel> iterator = result.iterator();
while(iterator.hasNext()) {
RegionModel regionModel = iterator.next();
regionModel.setLevel(regionModel.getLevel().trim());
regionModel.setLevelName(regionModel.getLevelName().trim());
if(!ValidationUtil.isEmpty(regionModel.getChildren())) {
despace(regionModel.getChildren());
}
}
}
/** /**
* 获取管辖单位树 * 获取管辖单位树
......
...@@ -14,7 +14,6 @@ import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService; ...@@ -14,7 +14,6 @@ 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.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl; 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.common.BizCommonConstant;
import com.yeejoin.amos.boot.module.tcm.api.common.CommonException;
import com.yeejoin.amos.boot.module.tcm.api.dto.BaseUnitLicenceDto; 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.BaseUnitLicence;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzBaseEnterpriseInfo; import com.yeejoin.amos.boot.module.tcm.api.entity.TzBaseEnterpriseInfo;
...@@ -24,7 +23,6 @@ import com.yeejoin.amos.boot.module.tcm.biz.service.impl.BaseUnitLicenceServiceI ...@@ -24,7 +23,6 @@ import com.yeejoin.amos.boot.module.tcm.biz.service.impl.BaseUnitLicenceServiceI
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.EquipmentCategoryServiceImpl; import com.yeejoin.amos.boot.module.tcm.biz.service.impl.EquipmentCategoryServiceImpl;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.StartPlatformTokenService; import com.yeejoin.amos.boot.module.tcm.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.TzBaseEnterpriseInfoServiceImpl; import com.yeejoin.amos.boot.module.tcm.biz.service.impl.TzBaseEnterpriseInfoServiceImpl;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.TzsAuthServiceImpl;
import com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil; import com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil;
import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitIcDto; import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitIcDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitInfoDto; import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitInfoDto;
...@@ -49,10 +47,14 @@ import org.apache.logging.log4j.Logger; ...@@ -49,10 +47,14 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.StopWatch;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -69,6 +71,7 @@ import java.text.ParseException; ...@@ -69,6 +71,7 @@ import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask; import java.util.concurrent.FutureTask;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -98,10 +101,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -98,10 +101,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
RegUnitIcServiceImpl regUnitIcService; RegUnitIcServiceImpl regUnitIcService;
@Autowired @Autowired
private TzsAuthServiceImpl tzsAuthServiceImpl;
@Autowired
TzBaseEnterpriseInfoServiceImpl tzBaseEnterpriseInfoService; TzBaseEnterpriseInfoServiceImpl tzBaseEnterpriseInfoService;
@Autowired @Autowired
TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper; TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper;
...@@ -132,19 +133,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -132,19 +133,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
private final Logger logger = LogManager.getLogger(RegUnitInfoServiceImpl.class); private final Logger logger = LogManager.getLogger(RegUnitInfoServiceImpl.class);
/** /**
* 使用单位的类型,数据来源:cb_data_dictionary code = 1232
*/
private static String USE_UNIT_TYPE_CODE = "1232";
/**
* 生产单位的类型,数据来源:cb_data_dictionary code = 1230
*/
private static String PRODUCT_UNIT_TYPE_CODE = "1230";
/**
* 充装单位的类型,数据来源:cb_data_dictionary code = 1231
*/
private static String FILLING_UNIT_TYPE_CODE = "1231";
/**
* 单位类型,数据来源:cb_data_dictionary type = UNIT_TYPE * 单位类型,数据来源:cb_data_dictionary type = UNIT_TYPE
*/ */
private static String DICT_TYPE_UNIT_TYPE = "UNIT_TYPE_NEW"; private static String DICT_TYPE_UNIT_TYPE = "UNIT_TYPE_NEW";
...@@ -155,50 +143,32 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -155,50 +143,32 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Value("${is.ugp}") @Value("${is.ugp}")
private boolean isUgp; private boolean isUgp;
@Autowired
private ApplicationContext applicationContext;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public RegUnitInfoDto registerUnit(RegUnitInfoDto model) { public RegUnitInfoDto registerUnit(RegUnitInfoDto model) {
StopWatch watch = new StopWatch();
watch.start();
if(ValidationUtil.isEmpty(model.getUnitCode())){ if(ValidationUtil.isEmpty(model.getUnitCode())){
model.setUnitCode(model.getForm().getString("unitCode")); model.setUnitCode(model.getForm().getString("unitCode"));
} }
RegUnitInfo regUnitInfo = new RegUnitInfo(); RegUnitInfo regUnitInfo = new RegUnitInfo();
try { try {
tzsAuthServiceImpl.setRequestContext(); startPlatformTokenService.setRequestContext();
// 注册用统一信用码注册,默认证件类型为营业执照,数据来源:cb_data_dictionary code = 1060 // 注册用统一信用码注册,默认证件类型为营业执照,数据来源:cb_data_dictionary code = 1060
model.setUnitCodeType("1060"); model.setUnitCodeType("1060");
model.setUnitCodeTypeName("营业执照"); model.setUnitCodeTypeName("营业执照");
Bean.copyExistPropertis(model, regUnitInfo); Bean.copyExistPropertis(model, regUnitInfo);
regUnitInfo.setUnitType(StringUtils.join(model.getUnitTypeList(), ",")); regUnitInfo.setUnitType(StringUtils.join(model.getUnitTypeList(), ","));
regUnitInfo.setUnitTypeCode(StringUtils.join(model.getUnitTypeCodeList(), ",")); regUnitInfo.setUnitTypeCode(StringUtils.join(model.getUnitTypeCodeList(), ","));
// 1.调用平台进行创建单位、用户信息
// 3.2 自动创建:调用平台进行创建单位、用户信息
this.createCompanyAndUser(regUnitInfo); this.createCompanyAndUser(regUnitInfo);
//多线程同步ugp信息(tzs和ugp一起后放开) // 2.异步调用ugp,同步公司数据
FutureTask<ResponseModel<Boolean>> future = getResponseModelFutureTask(model);
FutureTask<ResponseModel<Boolean>> future = null; // 3.插入单位注册许可信息表:tz_base_unit_licence
if(isUgp) { List<BaseUnitLicence> baseUnitLicences = model.getUnitLicences().stream().map(s -> {
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);
}
};
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 -> {
s.setUnitCode(model.getUnitCode()); s.setUnitCode(model.getUnitCode());
s.setUnitName(model.getName()); s.setUnitName(model.getName());
BaseUnitLicence target = new BaseUnitLicence(); BaseUnitLicence target = new BaseUnitLicence();
...@@ -208,42 +178,45 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -208,42 +178,45 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
if (!baseUnitLicences.isEmpty()) { if (!baseUnitLicences.isEmpty()) {
baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences); baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences);
} }
// 2.插入工商单位信息表:tz_flc_reg_unit_ic // 4.插入工商单位信息表:tz_flc_reg_unit_ic
RegUnitIc regUnitIc = new RegUnitIc(); RegUnitIc regUnitIc = new RegUnitIc();
model.getRegUnitIc().setUnitCode(model.getUnitCode()); model.getRegUnitIc().setUnitCode(model.getUnitCode());
model.getRegUnitIc().setUnitName(model.getName()); model.getRegUnitIc().setUnitName(model.getName());
Bean.copyExistPropertis(model.getRegUnitIc(), regUnitIc); Bean.copyExistPropertis(model.getRegUnitIc(), regUnitIc);
regUnitIcService.saveOrUpdate(regUnitIc); regUnitIcService.saveOrUpdate(regUnitIc);
// 3.调用平台进行创建单位、用户信息,同步用户信息 // 5.创建企业信息
// if (UnitReviewStateEnum.NO_NEED_REVIEW.getCode().equals(model.getState())) {
// 3.1 创建企业信息
this.createBaseEnterpriseInfo(model); this.createBaseEnterpriseInfo(model);
// }
if (!ObjectUtils.isEmpty(regUnitInfo.getAdminName())){ if (!ObjectUtils.isEmpty(regUnitInfo.getAdminName())){
regUnitInfo.setContactPerson(regUnitInfo.getAdminName()); regUnitInfo.setContactPerson(regUnitInfo.getAdminName());
} }
if (!ObjectUtils.isEmpty(regUnitInfo.getAdminTel())){ if (!ObjectUtils.isEmpty(regUnitInfo.getAdminTel())){
regUnitInfo.setContactPersonTel(regUnitInfo.getAdminTel()); regUnitInfo.setContactPersonTel(regUnitInfo.getAdminTel());
} }
// 4.插入注册单位基本信息表:tz_flc_reg_unit_info // 6.插入注册单位基本信息表:tz_flc_reg_unit_info
this.save(regUnitInfo); this.save(regUnitInfo);
// 5.组织返回数据 // 7.组织返回数据
// 5.1企业基本信息 // 7.1企业基本信息
Bean.copyExistPropertis(regUnitInfo, model); Bean.copyExistPropertis(regUnitInfo, model);
// 5.2行政许可数据 // 7.2行政许可数据
model.setUnitLicences(Bean.toModels(baseUnitLicences, BaseUnitLicenceDto.class)); model.setUnitLicences(Bean.toModels(baseUnitLicences, BaseUnitLicenceDto.class));
// 5.3工商信息 // 7.3工商信息
model.setRegUnitIc(Bean.toModel(regUnitIc, new RegUnitIcDto())); model.setRegUnitIc(Bean.toModel(regUnitIc, new RegUnitIcDto()));
//8.获取多线程执行结果 true成功 false失败(tzs和ugp一起后放开)
//获取多线程执行结果 true成功 false失败(tzs和ugp一起后放开) if (isUgp && future != null && !Boolean.TRUE.equals(future.get().getResult())) {
if(isUgp) { throw new BadRequest("UGP信息同步失败");
if (!future.get().getResult()) {
throw new Exception("UGP信息同步失败");
} }
watch.stop();
if(log.isDebugEnabled()){
log.debug("注册总耗时:==》" + watch.getTotalTimeSeconds());
} }
//9.事务提交后,异步创建企业的二维码
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit(){
RegUnitInfoServiceImpl proxy = applicationContext.getBean(RegUnitInfoServiceImpl.class);
proxy.asyncSetQrCode(model);
}
});
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
// 失败后回滚:删除已经创建的企业信息 // 失败后回滚:删除已经创建的企业信息
...@@ -267,6 +240,38 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -267,6 +240,38 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
return model; return model;
} }
@Async
public void asyncSetQrCode(RegUnitInfoDto regUnitInfoDto){
TzBaseEnterpriseInfo useCodeResult = tzBaseEnterpriseInfoMapper.selectOne(new QueryWrapper<TzBaseEnterpriseInfo>().eq("use_code", regUnitInfoDto.getUnitCode()));
if (ObjectUtils.isEmpty(useCodeResult)) {
useCodeResult.setQrCode(createQRCode(regUnitInfoDto.getUnitCode()));
} else {
useCodeResult.setQrCode(ObjectUtils.isEmpty(useCodeResult.getQrCode()) ? createQRCode(regUnitInfoDto.getUnitCode()) : useCodeResult.getQrCode());
}
tzBaseEnterpriseInfoService.saveOrUpdate(useCodeResult);
}
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) { private static String createQRCode(String unitCode) {
String urlString = null; String urlString = null;
byte[] bytes = QRCodeUtil.generateQRCodeImageByteData(unitCode, 150); byte[] bytes = QRCodeUtil.generateQRCodeImageByteData(unitCode, 150);
...@@ -286,22 +291,16 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -286,22 +291,16 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
return urlString; return urlString;
} }
/**
* 创建企业信息
* @param regUnitInfo 提交对象
*/
public void createBaseEnterpriseInfo(RegUnitInfoDto regUnitInfo) { public void createBaseEnterpriseInfo(RegUnitInfoDto regUnitInfo) {
// 1.查询管辖公司的信息 // 1.填充数据
FeignClientResult<CompanyModel> feignClientResult = Privilege.companyClient
.seleteOne(Long.parseLong(regUnitInfo.getManagementUnitId()));
CompanyModel managementCompany = feignClientResult.getResult();
// 2.填充数据
TzBaseEnterpriseInfo baseEnterpriseInfo = new TzBaseEnterpriseInfo(); TzBaseEnterpriseInfo baseEnterpriseInfo = new TzBaseEnterpriseInfo();
baseEnterpriseInfo.setUseUnitCertificate(regUnitInfo.getUnitCodeTypeName()); baseEnterpriseInfo.setUseUnitCertificate(regUnitInfo.getUnitCodeTypeName());
baseEnterpriseInfo.setUnitType(StringUtils.join(regUnitInfo.getUnitTypeList(), "#")); baseEnterpriseInfo.setUnitType(StringUtils.join(regUnitInfo.getUnitTypeList(), "#"));
baseEnterpriseInfo.setUseCode(regUnitInfo.getUnitCode()); baseEnterpriseInfo.setUseCode(regUnitInfo.getUnitCode());
TzBaseEnterpriseInfo useCodeResult = tzBaseEnterpriseInfoMapper.selectOne(new QueryWrapper<TzBaseEnterpriseInfo>().eq("use_code", regUnitInfo.getUnitCode()));
if (ObjectUtils.isEmpty(useCodeResult)) {
baseEnterpriseInfo.setQrCode(createQRCode(regUnitInfo.getUnitCode()));
} else {
baseEnterpriseInfo.setQrCode(ObjectUtils.isEmpty(useCodeResult.getQrCode()) ? createQRCode(regUnitInfo.getUnitCode()) : useCodeResult.getQrCode());
}
baseEnterpriseInfo.setUseUnit(regUnitInfo.getName()); baseEnterpriseInfo.setUseUnit(regUnitInfo.getName());
baseEnterpriseInfo.setProvince(regUnitInfo.getProvince()); baseEnterpriseInfo.setProvince(regUnitInfo.getProvince());
baseEnterpriseInfo.setCity(regUnitInfo.getCity()); baseEnterpriseInfo.setCity(regUnitInfo.getCity());
...@@ -316,8 +315,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -316,8 +315,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
baseEnterpriseInfo.setLongitude(regUnitInfo.getLongitude()); baseEnterpriseInfo.setLongitude(regUnitInfo.getLongitude());
baseEnterpriseInfo.setLatitude(regUnitInfo.getLatitude()); baseEnterpriseInfo.setLatitude(regUnitInfo.getLatitude());
// 管辖机构信息 // 管辖机构信息
baseEnterpriseInfo.setSuperviseCode(managementCompany.getCompanyCode()); baseEnterpriseInfo.setSuperviseCode(regUnitInfo.getManagementUnitCompanyCode());
baseEnterpriseInfo.setSuperviseOrgCode(managementCompany.getOrgCode()); baseEnterpriseInfo.setSuperviseOrgCode(regUnitInfo.getManagementUnitOrgCode());
// 这个表有两个字段所以赋值两字段 // 这个表有两个字段所以赋值两字段
baseEnterpriseInfo.setSuperviseOrgName(regUnitInfo.getManagementUnit()); baseEnterpriseInfo.setSuperviseOrgName(regUnitInfo.getManagementUnit());
baseEnterpriseInfo.setGoverningBody(regUnitInfo.getManagementUnit()); baseEnterpriseInfo.setGoverningBody(regUnitInfo.getManagementUnit());
...@@ -335,7 +334,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -335,7 +334,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Override @Override
public RegUnitInfoDto unitCheck(String unitCode, String unitType,String companyName) { public RegUnitInfoDto unitCheck(String unitCode, String unitType,String companyName) {
tzsAuthServiceImpl.setRequestContext(); startPlatformTokenService.getToken();
RequestContext.setToken(RequestContext.getToken()); RequestContext.setToken(RequestContext.getToken());
RequestContext.setAppKey(RequestContext.getAppKey()); RequestContext.setAppKey(RequestContext.getAppKey());
RequestContext.setProduct(RequestContext.getProduct()); RequestContext.setProduct(RequestContext.getProduct());
...@@ -442,7 +441,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -442,7 +441,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
public Collection getManagementUnitTree(String orgCode) { public Collection getManagementUnitTree(String orgCode) {
List<LinkedHashMap> companyModels = (List<LinkedHashMap>) redisUtil.get(BizCommonConstant.COMPANY_TREE_REDIS_KEY); List<LinkedHashMap> companyModels = (List<LinkedHashMap>) redisUtil.get(BizCommonConstant.COMPANY_TREE_REDIS_KEY);
if (ValidationUtil.isEmpty(companyModels)) { if (ValidationUtil.isEmpty(companyModels)) {
tzsAuthServiceImpl.setRequestContext(); startPlatformTokenService.getToken();
companyModels = equipmentCategoryService.creatTree(); companyModels = equipmentCategoryService.creatTree();
} }
if (!ValidationUtil.isEmpty(orgCode)) { if (!ValidationUtil.isEmpty(orgCode)) {
...@@ -611,8 +610,13 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -611,8 +610,13 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
CompanyModel companyInfo = new CompanyModel(); CompanyModel companyInfo = new CompanyModel();
FeignClientResult<AgencyUserModel> userResult = null; FeignClientResult<AgencyUserModel> userResult = null;
try { try {
FeignClientResult<List<RoleModel>> roleListResult = Privilege.roleClient.queryRoleList(null, null); StopWatch watch1 = new StopWatch();
List<RoleModel> allRoleList = roleListResult.getResult(); watch1.start();
List<RoleModel> allRoleList = startPlatformTokenService.getAllRole();
watch1.stop();
if(log.isDebugEnabled()){
log.debug("平台查询角色接口耗时:==》" + watch1.getTotalTimeSeconds());
}
List<RoleModel> userRoleList = new ArrayList<>(); List<RoleModel> userRoleList = new ArrayList<>();
List<Long> roleIds = new ArrayList<>(); List<Long> roleIds = new ArrayList<>();
Set<String> roleNameSet = new HashSet<>(); Set<String> roleNameSet = new HashSet<>();
...@@ -629,7 +633,13 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -629,7 +633,13 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
companyInfo.setContact(regUnitInfo.getLegalPerson()); companyInfo.setContact(regUnitInfo.getLegalPerson());
companyInfo.setCompanyType(regUnitInfo.getUnitType()); companyInfo.setCompanyType(regUnitInfo.getUnitType());
companyInfo.setLandlinePhone(regUnitInfo.getLegalPersonTel()); companyInfo.setLandlinePhone(regUnitInfo.getLegalPersonTel());
StopWatch watch2 = new StopWatch();
watch2.start();
FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo); FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo);
watch2.stop();
if(log.isDebugEnabled()){
log.debug("创建amos公司耗时:==》" + watch2.getTotalTimeSeconds());
}
if (companyResult == null || companyResult.getResult() == null) { if (companyResult == null || companyResult.getResult() == null) {
throw new BadRequest("单位注册失败"); throw new BadRequest("单位注册失败");
} }
...@@ -653,19 +663,16 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -653,19 +663,16 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
Set<String> appCodesSet = new HashSet<>(); Set<String> appCodesSet = new HashSet<>();
Map<Long, List<Long>> roleSeqMap = new HashMap<>(); Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>(); Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
for (String TypeCode : units) { List<DataDictionary> unitTypeList = getUnitTypeList();
DataDictionary unitType = iDataDictionaryService Map<String, DataDictionary> dataDictionaryMap = unitTypeList.stream().collect(Collectors.toMap(DataDictionary::getCode, Function.identity(), (k1, k2) -> k1));
.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getCode, TypeCode)); for (String typeCode : units) {
DataDictionary unitType = dataDictionaryMap.get(typeCode);
String appCode = unitType.getTypeDesc() != null ? unitType.getTypeDesc() : ""; String appCode = unitType.getTypeDesc() != null ? unitType.getTypeDesc() : "";
String[] appCodes = appCode.split(","); String[] appCodes = appCode.split(",");
Collections.addAll(appCodesSet, appCodes); Collections.addAll(appCodesSet, appCodes);
roleNameSet.add(unitType.getName()); roleNameSet.add(unitType.getName());
// userRoleList = allRoleList.stream().filter(r -> r.getRoleName().equals(unitType.getName())) userRoleList.addAll(allRoleList.stream()
// .collect(Collectors.toList()); .filter(r -> unitType.getExtend().contains(r.getSequenceNbr().toString())).collect(Collectors.toList()));
for (RoleModel roleModel : allRoleList.stream()
.filter(r -> unitType.getExtend().contains(r.getSequenceNbr().toString())).collect(Collectors.toList())) {
userRoleList.add(roleModel);
}
userRoleList.forEach(r -> { userRoleList.forEach(r -> {
if (!roleIds.contains(r.getSequenceNbr())) { if (!roleIds.contains(r.getSequenceNbr())) {
roleIds.add(r.getSequenceNbr()); roleIds.add(r.getSequenceNbr());
...@@ -677,11 +684,16 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -677,11 +684,16 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
agencyUserModel.setAppCodes(new ArrayList<>(appCodesSet)); agencyUserModel.setAppCodes(new ArrayList<>(appCodesSet));
agencyUserModel.setOrgRoles(orgRoles); agencyUserModel.setOrgRoles(orgRoles);
agencyUserModel.setOrgRoleSeqs(roleSeqMap); agencyUserModel.setOrgRoleSeqs(roleSeqMap);
StopWatch watch3 = new StopWatch();
watch3.start();
userResult = Privilege.agencyUserClient.create(agencyUserModel); userResult = Privilege.agencyUserClient.create(agencyUserModel);
watch3.stop();
if(log.isDebugEnabled()){
log.debug("创建amos人员耗时:==》" + watch3.getTotalTimeSeconds());
}
if (userResult == null || userResult.getResult() == null) { if (userResult == null || userResult.getResult() == null) {
throw new BadRequest("单位注册失败"); throw new BadRequest("单位注册失败");
} }
String[] userIds = { userResult.getResult().getUserId() };
regUnitInfo.setAdminUserId(userResult.getResult().getUserId()); regUnitInfo.setAdminUserId(userResult.getResult().getUserId());
regUnitInfo.setAmosCompanySeq(companyInfo.getSequenceNbr().toString()); regUnitInfo.setAmosCompanySeq(companyInfo.getSequenceNbr().toString());
// 3.3 org_user 创建组织机构 // 3.3 org_user 创建组织机构
...@@ -695,9 +707,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -695,9 +707,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
org.setAmosOrgId(companyInfo.getSequenceNbr() + ""); org.setAmosOrgId(companyInfo.getSequenceNbr() + "");
org.setAmosOrgCode(companyInfo.getOrgCode()); org.setAmosOrgCode(companyInfo.getOrgCode());
iOrgUsrService.save(org); iOrgUsrService.save(org);
// if (groupSeq != null) {
// Privilege.groupUserClient.create(groupSeq, Arrays.asList(userIds));
// }
} catch (Exception e) { } catch (Exception e) {
// 删除已经创建的 企业信息 // 删除已经创建的 企业信息
if (companyInfo != null && companyInfo.getSequenceNbr() != null) { if (companyInfo != null && companyInfo.getSequenceNbr() != null) {
......
package com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl; package com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant; 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.entity.DataDictionary;
...@@ -12,12 +13,14 @@ import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr; ...@@ -12,12 +13,14 @@ import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.service.ISourceFileService; import com.yeejoin.amos.boot.module.common.api.service.ISourceFileService;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl;
import com.yeejoin.amos.boot.module.tcm.api.common.BizCommonConstant;
import com.yeejoin.amos.boot.module.tcm.api.dto.WechatMessageDto; import com.yeejoin.amos.boot.module.tcm.api.dto.WechatMessageDto;
import com.yeejoin.amos.boot.module.tcm.api.entity.WechatRelation; import com.yeejoin.amos.boot.module.tcm.api.entity.WechatRelation;
import com.yeejoin.amos.boot.module.tcm.api.enums.TzsCommonParam; import com.yeejoin.amos.boot.module.tcm.api.enums.TzsCommonParam;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.TzsAuthServiceImpl; import com.yeejoin.amos.boot.module.tcm.biz.service.impl.TzsAuthServiceImpl;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.WechatRelationServiceImpl; import com.yeejoin.amos.boot.module.tcm.biz.service.impl.WechatRelationServiceImpl;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.WechatServiceImpl; import com.yeejoin.amos.boot.module.tcm.biz.service.impl.WechatServiceImpl;
import com.yeejoin.amos.boot.module.tcm.biz.utils.RedisUtil;
import com.yeejoin.amos.boot.module.tcm.flc.api.dto.UnitInfoApproveDto; import com.yeejoin.amos.boot.module.tcm.flc.api.dto.UnitInfoApproveDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.dto.UnitInfoDto; import com.yeejoin.amos.boot.module.tcm.flc.api.dto.UnitInfoDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.entity.UnitInfo; import com.yeejoin.amos.boot.module.tcm.flc.api.entity.UnitInfo;
...@@ -32,6 +35,7 @@ import com.yeejoin.amos.feign.privilege.model.CompanyModel; ...@@ -32,6 +35,7 @@ import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel; import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil; import com.yeejoin.amos.feign.privilege.util.DesUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -43,17 +47,11 @@ import org.springframework.stereotype.Service; ...@@ -43,17 +47,11 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.utils.Bean; 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.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/** /**
* 企业信息表服务实现类 * 企业信息表服务实现类
...@@ -100,6 +98,9 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -100,6 +98,9 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
@Value("${tzs.wechat.tempId.kr}") @Value("${tzs.wechat.tempId.kr}")
private String CALLBACK_TEMP; private String CALLBACK_TEMP;
@Autowired
private RedisUtil redisUtil;
@Transactional @Transactional
...@@ -638,7 +639,49 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -638,7 +639,49 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
} }
@Override @Override
public Collection<RegionModel> getRegionTree(Long parentId) {
tzsAuthServiceImpl.setRequestContext();
Collection<RegionModel> result = null;
if(parentId == null) {
result = this.getAllRegionTree();
} else {
result = Systemctl.regionClient.querySubAgencyTree(parentId).getResult();
}
despace(result);
return result;
}
public Collection<RegionModel> getAllRegionTree(){
Collection<RegionModel> result = null;
if(redisUtil.hasKey(BizCommonConstant.REGION_TREE_REDIS_KEY)){
result = JSONObject.parseArray(redisUtil.get(BizCommonConstant.REGION_TREE_REDIS_KEY).toString(),RegionModel.class);
} else {
result = Systemctl.regionClient.queryForTree(null).getResult();
redisUtil.set(BizCommonConstant.REGION_TREE_REDIS_KEY,JSONObject.toJSONString(result));
}
return result;
}
/**
* 去区域树中level多余空格
* @param result
*/
public void despace(Collection<RegionModel> result){
Iterator<RegionModel> iterator = result.iterator();
while(iterator.hasNext()) {
RegionModel regionModel = iterator.next();
regionModel.setLevel(regionModel.getLevel().trim());
regionModel.setLevelName(regionModel.getLevelName().trim());
if(!ValidationUtil.isEmpty(regionModel.getChildren())) {
despace(regionModel.getChildren());
}
}
}
@Override
public List<UnitInfoDto> getAllUnit() { public List<UnitInfoDto> getAllUnit() {
return baseMapper.getAllUnit(); return baseMapper.getAllUnit();
} }
} }
\ No newline at end of file
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