Commit d504558e authored by 刘林's avatar 刘林

fix(tcm):企业及事业单位注册,发证机关增加可录入的功能

parent 15c3430d
...@@ -129,6 +129,8 @@ public class TzsBaseInstitutionServiceImpl extends BaseService<TzsBaseInstitutio ...@@ -129,6 +129,8 @@ public class TzsBaseInstitutionServiceImpl extends BaseService<TzsBaseInstitutio
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (!baseUnitLicences.isEmpty()) { if (!baseUnitLicences.isEmpty()) {
baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences); baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences);
//添加不在字典中的登记机关
regUnitInfoService.addNotInDJJGDictionary(baseUnitLicences);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
......
...@@ -148,14 +148,13 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -148,14 +148,13 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
* 单位类型,数据来源: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";
private static final String DICT_TYPE_DJJG = "DJJG";
/** /**
* 个体类型,数据来源:cb_data_dictionary type = PERSON_REGISTER_TYPE * 个体类型,数据来源:cb_data_dictionary type = PERSON_REGISTER_TYPE
*/ */
private static String PERSON_REGISTER_TYPE = "PERSON_REGISTER_TYPE"; private static String PERSON_REGISTER_TYPE = "PERSON_REGISTER_TYPE";
@Value("${org.filter.group.seq}") @Value("${org.filter.group.seq}")
private Long groupSeq; private Long groupSeq;
...@@ -170,7 +169,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -170,7 +169,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
public RegUnitInfoDto registerUnit(RegUnitInfoDto model) { public RegUnitInfoDto registerUnit(RegUnitInfoDto model) {
StopWatch watch = new StopWatch(); StopWatch watch = new StopWatch();
watch.start(); 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();
...@@ -202,6 +201,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -202,6 +201,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (!baseUnitLicences.isEmpty()) { if (!baseUnitLicences.isEmpty()) {
baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences); baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences);
//添加不在字典中的登记机关
this.addNotInDJJGDictionary(baseUnitLicences);
} }
// 4.插入工商单位信息表:tz_flc_reg_unit_ic // 4.插入工商单位信息表:tz_flc_reg_unit_ic
RegUnitIc regUnitIc = new RegUnitIc(); RegUnitIc regUnitIc = new RegUnitIc();
...@@ -211,10 +212,10 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -211,10 +212,10 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
regUnitIcService.saveOrUpdate(regUnitIc); regUnitIcService.saveOrUpdate(regUnitIc);
// 5.创建企业信息 // 5.创建企业信息
this.createBaseEnterpriseInfo(model, EnterpriseEnums.QY_DW.getType()); this.createBaseEnterpriseInfo(model, EnterpriseEnums.QY_DW.getType());
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());
} }
// 6.插入注册单位基本信息表:tz_flc_reg_unit_info // 6.插入注册单位基本信息表:tz_flc_reg_unit_info
...@@ -231,10 +232,10 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -231,10 +232,10 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
throw new BadRequest("UGP信息同步失败"); throw new BadRequest("UGP信息同步失败");
} }
watch.stop(); watch.stop();
if(logger.isDebugEnabled()){ if (logger.isDebugEnabled()) {
logger.debug("注册总耗时:==》{}", watch.getTotalTimeSeconds()); logger.debug("注册总耗时:==》{}", watch.getTotalTimeSeconds());
} }
}catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
try { try {
// 失败后回滚:删除已经创建的企业信息 // 失败后回滚:删除已经创建的企业信息
...@@ -260,7 +261,42 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -260,7 +261,42 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
return model; return model;
} }
@SchedulerLock(name="asyncSetQrCodeTask",lockAtMostFor = "PT30M") /**
* 添加不在字典中的登记机关
* @param baseUnitLicences baseUnitLicences
*/
public void addNotInDJJGDictionary(List<BaseUnitLicence> baseUnitLicences) {
List<String> approvedOrganList = baseUnitLicences.stream()
.map(BaseUnitLicence::getApprovedOrgan)
.collect(Collectors.toList());
List<DataDictionary> allDictionaryList = this.initAllDataDictionaryList();
Set<String> existingNames = allDictionaryList.stream()
.filter(d -> d.getType().equals(DICT_TYPE_DJJG))
.map(DataDictionary::getName)
.collect(Collectors.toSet());
// 过滤出不在已存在的数据字典中的机构名,并转换为相应的数据字典对象
List<DataDictionary> notInDataDictionaryList = approvedOrganList.stream()
.filter(approvedOrgan -> !existingNames.contains(approvedOrgan))
.map(approvedOrgan -> {
DataDictionary dictionary = new DataDictionary();
dictionary.setName(approvedOrgan);
dictionary.setType(DICT_TYPE_DJJG);
dictionary.setCode(UUID.randomUUID().toString().replace("-", "").substring(0, 16));
return dictionary;
})
.collect(Collectors.toList());
if (!notInDataDictionaryList.isEmpty()) {
iDataDictionaryService.saveBatch(notInDataDictionaryList);
// 更新缓存
allDictionaryList.addAll(notInDataDictionaryList);
redisUtil.set(BizCommonConstant.TCM_ALL_DATA_DICT_REDIS_KEY, JSONObject.toJSONString(allDictionaryList));
}
}
@SchedulerLock(name = "asyncSetQrCodeTask", lockAtMostFor = "PT30M")
@Scheduled(cron = "${async.set.qr-code.cron:0 0/1 * * * ?}") @Scheduled(cron = "${async.set.qr-code.cron:0 0/1 * * * ?}")
public void asyncSetQrCode() { public void asyncSetQrCode() {
// 给所有新注册的企业创建二维码,每次处理1000个,不排序 // 给所有新注册的企业创建二维码,每次处理1000个,不排序
...@@ -287,7 +323,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -287,7 +323,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
private FutureTask<ResponseModel<Boolean>> getResponseModelFutureTask(RegUnitInfoDto model) { private FutureTask<ResponseModel<Boolean>> getResponseModelFutureTask(RegUnitInfoDto model) {
//多线程同步ugp信息(tzs和ugp一起后放开) //多线程同步ugp信息(tzs和ugp一起后放开)
FutureTask<ResponseModel<Boolean>> future = null; FutureTask<ResponseModel<Boolean>> future = null;
if(isUgp) { if (isUgp) {
String token = RequestContext.getToken(); String token = RequestContext.getToken();
String appKey = RequestContext.getAppKey(); String appKey = RequestContext.getAppKey();
String product = RequestContext.getProduct(); String product = RequestContext.getProduct();
...@@ -310,12 +346,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -310,12 +346,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
byte[] bytes = QRCodeUtil.generateQRCodeImageByteData(unitCode, 150); byte[] bytes = QRCodeUtil.generateQRCodeImageByteData(unitCode, 150);
InputStream inputStream = new ByteArrayInputStream(bytes); InputStream inputStream = new ByteArrayInputStream(bytes);
try { try {
MultipartFile file = new MockMultipartFile(unitCode+".png",unitCode+".png", ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream); MultipartFile file = new MockMultipartFile(unitCode + ".png", unitCode + ".png", ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFileFree(file, "tzs/qrcode"); FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFileFree(file, "tzs/qrcode");
if (date != null) { if (date != null) {
Map<String, String> map = date.getResult(); Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator(); Iterator<String> it = map.keySet().iterator();
urlString=it.next(); urlString = it.next();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -326,6 +362,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -326,6 +362,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
/** /**
* 创建企业信息 * 创建企业信息
*
* @param regUnitInfo 提交对象 * @param regUnitInfo 提交对象
*/ */
public TzBaseEnterpriseInfo createBaseEnterpriseInfo(RegUnitInfoDto regUnitInfo, String type) { public TzBaseEnterpriseInfo createBaseEnterpriseInfo(RegUnitInfoDto regUnitInfo, String type) {
...@@ -335,7 +372,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -335,7 +372,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
baseEnterpriseInfo.setUseCode(regUnitInfo.getUnitCode()); baseEnterpriseInfo.setUseCode(regUnitInfo.getUnitCode());
baseEnterpriseInfo.setUseUnit(regUnitInfo.getName()); baseEnterpriseInfo.setUseUnit(regUnitInfo.getName());
if(type.equals(EnterpriseEnums.GR_ZT.getType())){ if (type.equals(EnterpriseEnums.GR_ZT.getType())) {
baseEnterpriseInfo.setUseUnitCode(regUnitInfo.getUnitCode().split("_")[1]); baseEnterpriseInfo.setUseUnitCode(regUnitInfo.getUnitCode().split("_")[1]);
} else { } else {
baseEnterpriseInfo.setProvince(regUnitInfo.getProvince()); baseEnterpriseInfo.setProvince(regUnitInfo.getProvince());
...@@ -366,7 +403,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -366,7 +403,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
} }
baseEnterpriseInfo.setRegisterType(Objects.requireNonNull(EnterpriseEnums.getEnumByType(type).getTypeName())); baseEnterpriseInfo.setRegisterType(Objects.requireNonNull(EnterpriseEnums.getEnumByType(type).getTypeName()));
if (type.equals(EnterpriseEnums.QY_DW.getType())){ if (type.equals(EnterpriseEnums.QY_DW.getType())) {
baseEnterpriseInfo.setIndustry(regUnitInfo.getRegUnitIc().getIndustryName()); baseEnterpriseInfo.setIndustry(regUnitInfo.getRegUnitIc().getIndustryName());
baseEnterpriseInfo.setRegistrationAuthority(regUnitInfo.getRegUnitIc().getRegisteredOrgan()); baseEnterpriseInfo.setRegistrationAuthority(regUnitInfo.getRegUnitIc().getRegisteredOrgan());
baseEnterpriseInfo.setApprovalTime(regUnitInfo.getRegUnitIc().getApprovedDate()); baseEnterpriseInfo.setApprovalTime(regUnitInfo.getRegUnitIc().getApprovedDate());
...@@ -375,13 +412,13 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -375,13 +412,13 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
baseEnterpriseInfo.setSyncDate(new Date()); baseEnterpriseInfo.setSyncDate(new Date());
baseEnterpriseInfo.setSyncState(0); baseEnterpriseInfo.setSyncState(0);
LambdaQueryWrapper<TzBaseEnterpriseInfo> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TzBaseEnterpriseInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TzBaseEnterpriseInfo::getUseCode,regUnitInfo.getUnitCode()); wrapper.eq(TzBaseEnterpriseInfo::getUseCode, regUnitInfo.getUnitCode());
tzBaseEnterpriseInfoService.saveOrUpdate(baseEnterpriseInfo,wrapper); tzBaseEnterpriseInfoService.saveOrUpdate(baseEnterpriseInfo, wrapper);
return baseEnterpriseInfo; return baseEnterpriseInfo;
} }
@Override @Override
public RegUnitInfoDto unitCheck(String unitCode,String companyName,String registerType, String cardType) { public RegUnitInfoDto unitCheck(String unitCode, String companyName, String registerType, String cardType) {
RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto(); RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto();
startPlatformTokenService.getToken(); startPlatformTokenService.getToken();
// if (!ValidationUtil.isEmpty(companyName)) { // if (!ValidationUtil.isEmpty(companyName)) {
...@@ -390,8 +427,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -390,8 +427,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
// throw new BadRequest("重复的公司名称"); // throw new BadRequest("重复的公司名称");
// } // }
// } // }
if("6600".equals(cardType)){ if ("6600".equals(cardType)) {
boolean b =IdcardUtil.isValidCard(unitCode); boolean b = IdcardUtil.isValidCard(unitCode);
if (!b) { if (!b) {
throw new BadRequest("非法的证件号码"); throw new BadRequest("非法的证件号码");
} }
...@@ -411,21 +448,21 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -411,21 +448,21 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
// throw new RuntimeException("该单位已注册,请联系企业管理员!"); // throw new RuntimeException("该单位已注册,请联系企业管理员!");
// } // }
// 2.组织返回数据 // 2.组织返回数据
if(ObjectUtils.isEmpty(registerType)){ if (ObjectUtils.isEmpty(registerType)) {
//2.1 工商信息查询 //2.1 工商信息查询
Map<String, Object> resultMap = accessFeignService.getData(unitCode).getResult(); Map<String, Object> resultMap = accessFeignService.getData(unitCode).getResult();
if (resultMap == null){ if (resultMap == null) {
throw new BadRequest("工商信息接口查询失败,请稍后再试!"); throw new BadRequest("工商信息接口查询失败,请稍后再试!");
} }
if (ObjectUtils.isEmpty(resultMap)) { if (ObjectUtils.isEmpty(resultMap)) {
throw new BadRequest("未查询到企业信息,请核对!"); throw new BadRequest("未查询到企业信息,请核对!");
} }
if(!ValidationUtil.isEmpty(resultMap)){ if (!ValidationUtil.isEmpty(resultMap)) {
// 2.2 工商信息组装 // 2.2 工商信息组装
String area = String.valueOf(resultMap.get("area")); String area = String.valueOf(resultMap.get("area"));
String city = area.substring(0,area.indexOf("市")+1); String city = area.substring(0, area.indexOf("市") + 1);
String district = area.substring(city.length()); String district = area.substring(city.length());
if("高新区".equals(district)){ if ("高新区".equals(district)) {
district = "雁塔区"; district = "雁塔区";
} }
regUnitInfoDto.setCity(city); regUnitInfoDto.setCity(city);
...@@ -437,23 +474,23 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -437,23 +474,23 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
regUnitInfoDto.setName(String.valueOf(resultMap.get("unitName"))); regUnitInfoDto.setName(String.valueOf(resultMap.get("unitName")));
regUnitInfoDto.setLegalPerson(String.valueOf(resultMap.get("legalPeople"))); regUnitInfoDto.setLegalPerson(String.valueOf(resultMap.get("legalPeople")));
String industryName = ""; String industryName = "";
if(ObjectUtils.isNotEmpty(resultMap.get("industryCode"))){ if (ObjectUtils.isNotEmpty(resultMap.get("industryCode"))) {
List<DataDictionary> dictionaries = this.initAllDataDictionaryList(); List<DataDictionary> dictionaries = this.initAllDataDictionaryList();
Optional<DataDictionary> op = dictionaries.stream().filter(d->d.getCode() != null && d.getType() !=null && d.getCode().equals(String.valueOf(resultMap.get("industryCode")))&& "HYXLDM".equals(d.getType())).findFirst(); Optional<DataDictionary> op = dictionaries.stream().filter(d -> d.getCode() != null && d.getType() != null && d.getCode().equals(String.valueOf(resultMap.get("industryCode"))) && "HYXLDM".equals(d.getType())).findFirst();
if(op.isPresent()) { if (op.isPresent()) {
DataDictionary dataDictionary = op.get(); DataDictionary dataDictionary = op.get();
industryName = dataDictionary.getName(); industryName = dataDictionary.getName();
} }
} }
String approveDate = String.valueOf(resultMap.get("approval_time")); String approveDate = String.valueOf(resultMap.get("approval_time"));
approveDate = approveDate.contains("年")?approveDate.replace("年","-"):approveDate; approveDate = approveDate.contains("年") ? approveDate.replace("年", "-") : approveDate;
approveDate = approveDate.contains("月")?approveDate.replace("月","-"):approveDate; approveDate = approveDate.contains("月") ? approveDate.replace("月", "-") : approveDate;
approveDate = approveDate.contains("日")?approveDate.replace("日","-"):approveDate; approveDate = approveDate.contains("日") ? approveDate.replace("日", "-") : approveDate;
RegUnitIcDto regUnitIcDto = new RegUnitIcDto(); RegUnitIcDto regUnitIcDto = new RegUnitIcDto();
regUnitIcDto.setUnitCode(regUnitInfoDto.getUnitCode()); regUnitIcDto.setUnitCode(regUnitInfoDto.getUnitCode());
try { try {
regUnitIcDto.setApprovedDate(DateUtils.dateParse(approveDate,"yyyy-MM-dd")); regUnitIcDto.setApprovedDate(DateUtils.dateParse(approveDate, "yyyy-MM-dd"));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -472,10 +509,10 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -472,10 +509,10 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
} else { } else {
regUnitInfoDto.setRegUnitIc(new RegUnitIcDto()); regUnitInfoDto.setRegUnitIc(new RegUnitIcDto());
} }
} else if("6598".equals(registerType)){ } else if ("6598".equals(registerType)) {
TzsBaseInstitution regUnitMessage = tzsBaseInstitutionMapper.selectOne(new LambdaQueryWrapper<TzsBaseInstitution>().eq(TzsBaseInstitution::getUseCode, unitCode)); TzsBaseInstitution regUnitMessage = tzsBaseInstitutionMapper.selectOne(new LambdaQueryWrapper<TzsBaseInstitution>().eq(TzsBaseInstitution::getUseCode, unitCode));
TzsBaseInstitutionDto institutionDto = new TzsBaseInstitutionDto(); TzsBaseInstitutionDto institutionDto = new TzsBaseInstitutionDto();
if(!ObjectUtils.isEmpty(regUnitMessage)){ if (!ObjectUtils.isEmpty(regUnitMessage)) {
BeanUtils.copyProperties(regUnitMessage, institutionDto); BeanUtils.copyProperties(regUnitMessage, institutionDto);
} }
regUnitInfoDto.setRegUnitMessage(institutionDto); regUnitInfoDto.setRegUnitMessage(institutionDto);
...@@ -498,17 +535,17 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -498,17 +535,17 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
public List<DataDictionary> setAndGetUnitTypeList() { public List<DataDictionary> setAndGetUnitTypeList() {
List<DataDictionary> dataDictionaries; List<DataDictionary> dataDictionaries;
// 先从Redis缓存中获取值 // 先从Redis缓存中获取值
if(redisUtil.hasKey(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY)){ if (redisUtil.hasKey(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY)) {
dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY).toString(),DataDictionary.class); dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY).toString(), DataDictionary.class);
return dataDictionaries; return dataDictionaries;
} }
// 在同步块内再次检查缓存,以避免多个线程同时查不到缓存时重复查询数据库 // 在同步块内再次检查缓存,以避免多个线程同时查不到缓存时重复查询数据库
synchronized (this){ synchronized (this) {
if(redisUtil.hasKey(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY)){ if (redisUtil.hasKey(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY)) {
dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY).toString(),DataDictionary.class); dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY).toString(), DataDictionary.class);
} else{ } else {
dataDictionaries = iDataDictionaryService.getByType(DICT_TYPE_UNIT_TYPE); dataDictionaries = iDataDictionaryService.getByType(DICT_TYPE_UNIT_TYPE);
redisUtil.set(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY,JSONObject.toJSONString(dataDictionaries)); redisUtil.set(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY, JSONObject.toJSONString(dataDictionaries));
} }
} }
return dataDictionaries; return dataDictionaries;
...@@ -522,17 +559,17 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -522,17 +559,17 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
public List<DataDictionary> setAndGetPersonRegisterTypeList() { public List<DataDictionary> setAndGetPersonRegisterTypeList() {
List<DataDictionary> dataDictionaries; List<DataDictionary> dataDictionaries;
// 先从Redis缓存中获取值 // 先从Redis缓存中获取值
if(redisUtil.hasKey(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY)){ if (redisUtil.hasKey(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY)) {
dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY).toString(),DataDictionary.class); dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY).toString(), DataDictionary.class);
return dataDictionaries; return dataDictionaries;
} }
// 在同步块内再次检查缓存,以避免多个线程同时查不到缓存时重复查询数据库 // 在同步块内再次检查缓存,以避免多个线程同时查不到缓存时重复查询数据库
synchronized (this){ synchronized (this) {
if(redisUtil.hasKey(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY)){ if (redisUtil.hasKey(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY)) {
dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY).toString(),DataDictionary.class); dataDictionaries = JSONObject.parseArray(redisUtil.get(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY).toString(), DataDictionary.class);
} else{ } else {
dataDictionaries = iDataDictionaryService.getByType(PERSON_REGISTER_TYPE); dataDictionaries = iDataDictionaryService.getByType(PERSON_REGISTER_TYPE);
redisUtil.set(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY,JSONObject.toJSONString(dataDictionaries)); redisUtil.set(BizCommonConstant.PERSON_REGISTER_TYPE_LIST_REDIS_KEY, JSONObject.toJSONString(dataDictionaries));
} }
} }
return dataDictionaries; return dataDictionaries;
...@@ -541,18 +578,18 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -541,18 +578,18 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Override @Override
public List<DataDictionary> getChildList(String type, String group) { public List<DataDictionary> getChildList(String type, String group) {
List<DataDictionary> dictionaries = this.initAllDataDictionaryList(); List<DataDictionary> dictionaries = this.initAllDataDictionaryList();
return dictionaries.stream().parallel().filter(d->d.getType().equals(type) && d.getTypeDesc().equals(group)).collect(Collectors.toList()); return dictionaries.stream().parallel().filter(d -> d.getType().equals(type) && d.getTypeDesc().equals(group)).collect(Collectors.toList());
} }
@Override @Override
public void setAllDataDictionaryList(){ public void setAllDataDictionaryList() {
this.initAllDataDictionaryList(); this.initAllDataDictionaryList();
} }
@Override @Override
public List<Menu> getDictionaryWithTreeFillId(String type) throws Exception { public List<Menu> getDictionaryWithTreeFillId(String type) throws Exception {
List<DataDictionary> dictionaries = this.initAllDataDictionaryList(); List<DataDictionary> dictionaries = this.initAllDataDictionaryList();
List<DataDictionary> temp = dictionaries.stream().parallel().filter(d->d.getType().equals(type)).collect(Collectors.toList()); List<DataDictionary> temp = dictionaries.stream().parallel().filter(d -> d.getType().equals(type)).collect(Collectors.toList());
return TreeParser.getTree(null, temp, DataDictionary.class.getName(), "getSequenceNbr", 2, return TreeParser.getTree(null, temp, DataDictionary.class.getName(), "getSequenceNbr", 2,
"getName", "getParent", null, "getCode"); "getName", "getParent", null, "getCode");
} }
...@@ -560,7 +597,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -560,7 +597,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Override @Override
public List<DataDictionary> getDictionaryListByType(String type) throws Exception { public List<DataDictionary> getDictionaryListByType(String type) throws Exception {
List<DataDictionary> dictionaries = this.initAllDataDictionaryList(); List<DataDictionary> dictionaries = this.initAllDataDictionaryList();
return dictionaries.stream().parallel().filter(d->d.getType().equals(type)).collect(Collectors.toList()); return dictionaries.stream().parallel().filter(d -> d.getType().equals(type)).collect(Collectors.toList());
} }
public List<DataDictionary> initAllDataDictionaryList() { public List<DataDictionary> initAllDataDictionaryList() {
...@@ -575,8 +612,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -575,8 +612,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
if (redisUtil.hasKey(BizCommonConstant.TCM_ALL_DATA_DICT_REDIS_KEY)) { if (redisUtil.hasKey(BizCommonConstant.TCM_ALL_DATA_DICT_REDIS_KEY)) {
String json = redisUtil.get(BizCommonConstant.TCM_ALL_DATA_DICT_REDIS_KEY).toString(); String json = redisUtil.get(BizCommonConstant.TCM_ALL_DATA_DICT_REDIS_KEY).toString();
dictionaries = JSONObject.parseArray(json, DataDictionary.class); dictionaries = JSONObject.parseArray(json, DataDictionary.class);
} else{ } else {
dictionaries = dataDictionaryService.list(new LambdaQueryWrapper<DataDictionary>().eq(BaseEntity::getIsDelete,false)); dictionaries = dataDictionaryService.list(new LambdaQueryWrapper<DataDictionary>().eq(BaseEntity::getIsDelete, false));
redisUtil.set(BizCommonConstant.TCM_ALL_DATA_DICT_REDIS_KEY, JSONObject.toJSONString(dictionaries)); redisUtil.set(BizCommonConstant.TCM_ALL_DATA_DICT_REDIS_KEY, JSONObject.toJSONString(dictionaries));
} }
} }
...@@ -584,7 +621,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -584,7 +621,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
} }
@Override @Override
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);
...@@ -697,7 +733,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -697,7 +733,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Override @Override
public void updateAdminInfo(JSONObject dataResult) { public void updateAdminInfo(JSONObject dataResult) {
RegUnitInfo regUnitInfo = regUnitInfoMapper.selectOne(new QueryWrapper<RegUnitInfo>().eq("admin_user_id", dataResult.get("userId"))); RegUnitInfo regUnitInfo = regUnitInfoMapper.selectOne(new QueryWrapper<RegUnitInfo>().eq("admin_user_id", dataResult.get("userId")));
if(!ObjectUtils.isEmpty(regUnitInfo)){ if (!ObjectUtils.isEmpty(regUnitInfo)) {
regUnitInfo.setAdminTel(String.valueOf(dataResult.get("mobile"))); regUnitInfo.setAdminTel(String.valueOf(dataResult.get("mobile")));
regUnitInfo.setAdminName(String.valueOf(dataResult.get("realName"))); regUnitInfo.setAdminName(String.valueOf(dataResult.get("realName")));
regUnitInfoMapper.updateById(regUnitInfo); regUnitInfoMapper.updateById(regUnitInfo);
...@@ -762,8 +798,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -762,8 +798,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
watch1.start(); watch1.start();
List<RoleModel> allRoleList = startPlatformTokenService.getAllRole(); List<RoleModel> allRoleList = startPlatformTokenService.getAllRole();
watch1.stop(); watch1.stop();
if(logger.isDebugEnabled()){ if (logger.isDebugEnabled()) {
logger.debug("平台查询角色接口耗时:==>{}",watch1.getTotalTimeSeconds()); logger.debug("平台查询角色接口耗时:==>{}", watch1.getTotalTimeSeconds());
} }
List<RoleModel> userRoleList = new ArrayList<>(); List<RoleModel> userRoleList = new ArrayList<>();
List<Long> roleIds = new ArrayList<>(); List<Long> roleIds = new ArrayList<>();
...@@ -785,8 +821,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -785,8 +821,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
watch2.start(); watch2.start();
FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo); FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo);
watch2.stop(); watch2.stop();
if(logger.isDebugEnabled()){ if (logger.isDebugEnabled()) {
logger.debug("创建amos公司耗时:==>{}",watch2.getTotalTimeSeconds()); logger.debug("创建amos公司耗时:==>{}", watch2.getTotalTimeSeconds());
} }
if (companyResult == null || companyResult.getResult() == null) { if (companyResult == null || companyResult.getResult() == null) {
throw new BadRequest("单位注册失败"); throw new BadRequest("单位注册失败");
...@@ -836,8 +872,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -836,8 +872,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
watch3.start(); watch3.start();
userResult = Privilege.agencyUserClient.create(agencyUserModel); userResult = Privilege.agencyUserClient.create(agencyUserModel);
watch3.stop(); watch3.stop();
if(logger.isDebugEnabled()){ if (logger.isDebugEnabled()) {
logger.debug("创建amos人员耗时:==>{}",watch3.getTotalTimeSeconds()); logger.debug("创建amos人员耗时:==>{}", watch3.getTotalTimeSeconds());
} }
if (userResult == null || userResult.getResult() == null) { if (userResult == null || userResult.getResult() == null) {
throw new BadRequest("单位注册失败"); throw new BadRequest("单位注册失败");
...@@ -878,12 +914,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -878,12 +914,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
&& StringUtils.isNotEmpty(userResult.getResult().getUserId())) { && StringUtils.isNotEmpty(userResult.getResult().getUserId())) {
Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId()); Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId());
} }
logger.error(e.getMessage(),e); logger.error(e.getMessage(), e);
throw new RuntimeException(e.getMessage()); throw new RuntimeException(e.getMessage());
} }
} }
public AgencyUserModel createUser(AccountDto dto,String type) { public AgencyUserModel createUser(AccountDto dto, String type) {
FeignClientResult<AgencyUserModel> userResult = null; FeignClientResult<AgencyUserModel> userResult = null;
try { try {
List<RoleModel> allRoleList = startPlatformTokenService.getAllRole(); List<RoleModel> allRoleList = startPlatformTokenService.getAllRole();
...@@ -904,7 +940,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -904,7 +940,7 @@ 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<>();
List<DataDictionary> unitTypeList = EnterpriseEnums.GR_ZT.getType().equals(type)? setAndGetPersonRegisterTypeList() : setAndGetUnitTypeList(); List<DataDictionary> unitTypeList = EnterpriseEnums.GR_ZT.getType().equals(type) ? setAndGetPersonRegisterTypeList() : setAndGetUnitTypeList();
Map<String, DataDictionary> dataDictionaryMap = unitTypeList.stream().collect(Collectors.toMap(DataDictionary::getCode, Function.identity(), (k1, k2) -> k1)); Map<String, DataDictionary> dataDictionaryMap = unitTypeList.stream().collect(Collectors.toMap(DataDictionary::getCode, Function.identity(), (k1, k2) -> k1));
for (String typeCode : units) { for (String typeCode : units) {
DataDictionary unitType = dataDictionaryMap.get(typeCode); DataDictionary unitType = dataDictionaryMap.get(typeCode);
...@@ -929,8 +965,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -929,8 +965,8 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
watch3.start(); watch3.start();
userResult = Privilege.agencyUserClient.create(agencyUserModel); userResult = Privilege.agencyUserClient.create(agencyUserModel);
watch3.stop(); watch3.stop();
if(logger.isDebugEnabled()){ if (logger.isDebugEnabled()) {
logger.debug("创建amos人员耗时:==>{}",watch3.getTotalTimeSeconds()); logger.debug("创建amos人员耗时:==>{}", watch3.getTotalTimeSeconds());
} }
if (userResult == null || userResult.getResult() == null) { if (userResult == null || userResult.getResult() == null) {
throw new BadRequest("单位注册失败"); throw new BadRequest("单位注册失败");
...@@ -945,7 +981,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -945,7 +981,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
&& StringUtils.isNotEmpty(userResult.getResult().getUserId())) { && StringUtils.isNotEmpty(userResult.getResult().getUserId())) {
Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId()); Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId());
} }
log.error(e.getMessage(),e); log.error(e.getMessage(), e);
throw new RuntimeException(e.getMessage()); throw new RuntimeException(e.getMessage());
} }
} }
...@@ -994,12 +1030,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -994,12 +1030,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
logger.info("向privilege发送参数roleId,companyId,{},{}", roleId, sequenceNbr); logger.info("向privilege发送参数roleId,companyId,{},{}", roleId, sequenceNbr);
FeignClientResult<List<AgencyUserModel>> listFeignClientResult = Privilege.agencyUserClient.queryByCompanyRoles(sequenceNbr, roleId, null, null); FeignClientResult<List<AgencyUserModel>> listFeignClientResult = Privilege.agencyUserClient.queryByCompanyRoles(sequenceNbr, roleId, null, null);
logger.info("privilege返回用户信息,{}", JSONObject.toJSONString(listFeignClientResult)); logger.info("privilege返回用户信息,{}", JSONObject.toJSONString(listFeignClientResult));
if (!ObjectUtils.isEmpty(listFeignClientResult) && !ObjectUtils.isEmpty(listFeignClientResult.getResult())){ if (!ObjectUtils.isEmpty(listFeignClientResult) && !ObjectUtils.isEmpty(listFeignClientResult.getResult())) {
listFeignClientResult.getResult().forEach(item ->{ listFeignClientResult.getResult().forEach(item -> {
flow.add(item.getUserName()); flow.add(item.getUserName());
task.add(item.getUserId()); task.add(item.getUserId());
}); });
}else { } else {
throw new BadRequest("没有对应企业整改执行人!"); throw new BadRequest("没有对应企业整改执行人!");
} }
...@@ -1017,7 +1053,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -1017,7 +1053,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
objectMap.put("CHECKED_COMPANY_USERS", userIds); objectMap.put("CHECKED_COMPANY_USERS", userIds);
objectMap.put("CHECKED_COMPANY_USER_ids", userIdsTask); objectMap.put("CHECKED_COMPANY_USER_ids", userIdsTask);
// 表单信息提交 // 表单信息提交
FeignClientResult<String> submit = idxFeignService.submit(pageId, taskId, planInstanceId,"CHECKED_COMPANY_USER_ids", topic, tableName, objectMap); FeignClientResult<String> submit = idxFeignService.submit(pageId, taskId, planInstanceId, "CHECKED_COMPANY_USER_ids", topic, tableName, objectMap);
// if ("200".equals(String.valueOf(submit.getStatus()))) { // if ("200".equals(String.valueOf(submit.getStatus()))) {
// JSONObject jsonObject = new JSONObject(); // JSONObject jsonObject = new JSONObject();
// jsonObject.put("title", "企业整改"); // jsonObject.put("title", "企业整改");
...@@ -1038,10 +1074,11 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -1038,10 +1074,11 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
* @throws InterruptedException * @throws InterruptedException
*/ */
void updateAmosTask(String taskId, JSONObject object) throws InterruptedException { void updateAmosTask(String taskId, JSONObject object) throws InterruptedException {
Thread.sleep(1000*2); Thread.sleep(1000 * 2);
FeignClientResult<JSONObject> jsonObjectFeignClientResult = idxFeignService.updateAmosTask(taskId, object); FeignClientResult<JSONObject> jsonObjectFeignClientResult = idxFeignService.updateAmosTask(taskId, object);
logger.info("idx执行任务更新任务返回参数,{}", JSONObject.toJSONString(jsonObjectFeignClientResult)); logger.info("idx执行任务更新任务返回参数,{}", JSONObject.toJSONString(jsonObjectFeignClientResult));
} }
private String dealNull2EmptyString(String t) { private String dealNull2EmptyString(String t) {
return StringUtils.isEmpty(t) ? "" : t; return StringUtils.isEmpty(t) ? "" : t;
} }
...@@ -1049,6 +1086,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -1049,6 +1086,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Override @Override
public List<DataDictionary> getXkItemList(String type) { public List<DataDictionary> getXkItemList(String type) {
List<DataDictionary> dictionaries = this.initAllDataDictionaryList(); List<DataDictionary> dictionaries = this.initAllDataDictionaryList();
return dictionaries.stream().parallel().filter(d->("XK-"+type).equals(d.getExtend())).collect(Collectors.toList()); return dictionaries.stream().parallel().filter(d -> ("XK-" + type).equals(d.getExtend())).collect(Collectors.toList());
} }
} }
\ 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