Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
wangjiahao
2021-06-01 10:21:42 +08:00
20 changed files with 294 additions and 107 deletions

View File

@@ -6,8 +6,6 @@ import io.dataease.base.mapper.ext.AuthMapper;
import io.dataease.auth.service.AuthUserService;
import io.dataease.commons.constants.AuthConstants;
import io.dataease.plugins.common.dto.PluginSysMenu;
import io.dataease.plugins.common.service.PluginMenuService;
import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.plugins.util.PluginUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -15,10 +13,8 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service

View File

@@ -31,6 +31,7 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
//增加插件中的菜单
List<PluginSysMenu> pluginSysMenus = PluginUtils.pluginMenus();
if (CollectionUtils.isNotEmpty(pluginSysMenus) ) {
pluginSysMenus = pluginSysMenus.stream().filter(menu -> menu.getType() <= 1).collect(Collectors.toList());
List<DynamicMenuDto> pluginDtos = pluginSysMenus.stream().map(this::convert).collect(Collectors.toList());
dynamicMenuDtos.addAll(pluginDtos);
}

View File

@@ -0,0 +1,7 @@
package io.dataease.base.mapper.ext;
public interface UtilMapper {
Long currentTimestamp();
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.dataease.base.mapper.ext.UtilMapper">
<select id="currentTimestamp" resultType="java.lang.Long">
select unix_timestamp(current_timestamp()) * 1000 as c_timestamp
</select>
</mapper>

View File

@@ -41,18 +41,6 @@ public class DefaultLicenseService {
f2CLicenseResponse.setMessage("The license is unavailable for this product.");
return f2CLicenseResponse;
}
// 检查每个模块的PLU限制
// if(!Arrays.asList(NO_PLU_LIMIT_MODULES).contains(moduleId)){
// AuthorizationUnit authorizationUnit= CommonBeanFactory.getBean(AuthorizationUnit.class);
// try{
// authorizationUnit.calculateAssets(f2CLicenseResponse.getLicense().getCount());
// return f2CLicenseResponse;
// }catch (Exception e){
// f2CLicenseResponse.setStatus(F2CLicenseResponse.Status.invalid);
// f2CLicenseResponse.setMessage(e.getMessage());
// }
// }
return f2CLicenseResponse;
}catch (Exception e){
return F2CLicenseResponse.invalid(e.getMessage());
@@ -79,16 +67,10 @@ public class DefaultLicenseService {
License license = readLicense();
return validateLicense(product, license.getLicense());
} catch (Exception e) {
return F2CLicenseResponse.invalid(e.getMessage());
return F2CLicenseResponse.noRecord();
}
}
public void validateF2cLicense(){
License license = readLicense();
F2CLicenseResponse f2CLicenseResponse = validateLicense(product, license.getLicense());
writeLicense(license.getLicense(), f2CLicenseResponse);
}
public F2CLicenseResponse updateLicense(String product, String licenseKey) {
// 验证license
F2CLicenseResponse response = validateLicense(product, licenseKey);
@@ -104,12 +86,10 @@ public class DefaultLicenseService {
public License readLicense() {
License license = innerLicenseService.getLicense(LICENSE_ID);
if (license == null) {
/*DEException.throwException(Translator.get("i18n_no_license_record"));*/
DEException.throwException("i18n_no_license_record");
}
if (StringUtils.isBlank(license.getLicense())) {
DEException.throwException("i18n_license_is_empty");
//F2CException.throwException(Translator.get("i18n_license_is_empty"));
}
return license;
}
@@ -117,9 +97,7 @@ public class DefaultLicenseService {
// 创建或更新License
private void writeLicense(String licenseKey, F2CLicenseResponse response) {
if (StringUtils.isBlank(licenseKey)) {
DEException.throwException("i18n_license_is_empty");
}
License license = new License();
license.setId(LICENSE_ID);

View File

@@ -31,6 +31,7 @@ public class F2CLicenseResponse {
}
public static enum Status {
no_record,
valid,
invalid,
expired;
@@ -43,4 +44,12 @@ public class F2CLicenseResponse {
f2CLicenseResponse.setMessage(a);
return f2CLicenseResponse;
}
public static F2CLicenseResponse noRecord() {
F2CLicenseResponse f2CLicenseResponse = new F2CLicenseResponse();
f2CLicenseResponse.setStatus(Status.no_record);
f2CLicenseResponse.setLicense(null);
f2CLicenseResponse.setMessage("No license record");
return f2CLicenseResponse;
}
}

View File

@@ -2,6 +2,7 @@ package io.dataease.controller;
import com.google.gson.Gson;
import io.dataease.commons.license.DefaultLicenseService;
import io.dataease.commons.license.F2CLicenseResponse;
import org.springframework.beans.factory.annotation.Value;
@@ -22,16 +23,14 @@ public class LicenseController {
@GetMapping(value = "anonymous/license/validate")
public ResultHolder validateLicense() throws Exception {
if (!need_validate_lic) {
return ResultHolder.success(null);
}
/* License license = defaultLicenseService.readLicense();
if(StringUtils.isEmpty(license.getF2cLicense())){
throw new Exception("Invalid License.");
}
F2CLicenseResponse f2CLicenseResponse = new Gson().fromJson(license.getF2cLicense(), F2CLicenseResponse.class);*/
// if (!need_validate_lic) {
// return ResultHolder.success(null);
// }
F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense();
System.out.println(new Gson().toJson(f2CLicenseResponse));
switch (f2CLicenseResponse.getStatus()) {
case no_record:
return ResultHolder.success(f2CLicenseResponse);
case valid:
return ResultHolder.success(null);
case expired:

View File

@@ -6,6 +6,7 @@ import com.google.gson.Gson;
import io.dataease.base.domain.*;
import io.dataease.base.mapper.*;
import io.dataease.base.mapper.ext.ExtDataSetTableMapper;
import io.dataease.base.mapper.ext.UtilMapper;
import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.utils.*;
import io.dataease.controller.request.dataset.DataSetTableRequest;
@@ -880,12 +881,14 @@ public class DataSetTableService {
return CollectionUtils.isNotEmpty(data);
}
@Resource
private UtilMapper utilMapper;
@QuartzScheduled(cron = "0 0/3 * * * ?")
public void updateDatasetTableStatus(){
List<QrtzSchedulerState> qrtzSchedulerStates = qrtzSchedulerStateMapper.selectByExample(null);
List<String> activeQrtzInstances = qrtzSchedulerStates.stream().filter(qrtzSchedulerState -> qrtzSchedulerState.getLastCheckinTime() + qrtzSchedulerState.getCheckinInterval() + 1000 > System.currentTimeMillis()).map(QrtzSchedulerStateKey::getInstanceName).collect(Collectors.toList());
List<String> activeQrtzInstances = qrtzSchedulerStates.stream().filter(qrtzSchedulerState -> qrtzSchedulerState.getLastCheckinTime() + qrtzSchedulerState.getCheckinInterval() + 1000 > utilMapper.currentTimestamp()).map(QrtzSchedulerStateKey::getInstanceName).collect(Collectors.toList());
List<DatasetTable> jobStoppeddDatasetTables = new ArrayList<>();
DatasetTableExample example = new DatasetTableExample();
example.createCriteria().andSyncStatusEqualTo(JobStatus.Underway.name());