提交 c418ecd0 编写于 作者: O o2null

Merge branch 'fix/rollback' into 'develop'

update access with threadPool

See merge request o2oa/o2oa!452
......@@ -20,6 +20,7 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.MD5Tool;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.ThisApplication;
import com.x.query.core.entity.View;
import com.x.query.core.express.plan.CmsPlan;
import com.x.query.core.express.plan.FilterEntry;
......@@ -41,18 +42,20 @@ class ActionBundle extends BaseAction {
}
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Runtime runtime = this.runtime(effectivePerson, business, view, wi.getFilterList(), wi.getParameter(), wi.getCount(), true);
Runtime runtime = this.runtime(effectivePerson, business, view, wi.getFilterList(), wi.getParameter(),
wi.getCount(), true);
List<String> os = null;
switch (StringUtils.trimToEmpty(view.getType())) {
case View.TYPE_CMS:
CmsPlan cmsPlan = gson.fromJson(view.getData(), CmsPlan.class);
cmsPlan.runtime = runtime;
cmsPlan.init(runtime, ThisApplication.threadPool());
os = cmsPlan.fetchBundles();
break;
case View.TYPE_PROCESSPLATFORM:
ProcessPlatformPlan processPlatformPlan = gson.fromJson(view.getData(), ProcessPlatformPlan.class);
processPlatformPlan.init(runtime, ThisApplication.threadPool());
this.setProcessEdition(business, processPlatformPlan);
processPlatformPlan.runtime = runtime;
os = processPlatformPlan.fetchBundles();
......@@ -62,7 +65,7 @@ class ActionBundle extends BaseAction {
}
Wo wo = new Wo();
wo.setValueList(os);
wo.setKey(MD5Tool.getMD5Str(effectivePerson.getDistinguishedName()+ Config.token().getCipher()));
wo.setKey(MD5Tool.getMD5Str(effectivePerson.getDistinguishedName() + Config.token().getCipher()));
result.setData(wo);
return result;
}
......
......@@ -21,6 +21,7 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.MD5Tool;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.ThisApplication;
import com.x.query.core.entity.View;
import com.x.query.core.express.plan.CmsPlan;
import com.x.query.core.express.plan.FilterEntry;
......@@ -45,19 +46,20 @@ class ActionSimulate extends BaseAction {
if (wi == null) {
wi = new Wi();
}
if (ListTools.isNotEmpty(wi.getBundleList())){
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName()+ Config.token().getCipher());
if (ListTools.isNotEmpty(wi.getBundleList())) {
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName() + Config.token().getCipher());
if (!curKey.equals(wi.key)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
}
Runtime runtime = this.runtime(effectivePerson, business, view, wi.getFilterList(), wi.getParameter(), wi.getCount(), false);
Runtime runtime = this.runtime(effectivePerson, business, view, wi.getFilterList(), wi.getParameter(),
wi.getCount(), false);
runtime.bundleList = wi.getBundleList();
switch (StringUtils.trimToEmpty(view.getType())) {
case View.TYPE_CMS:
CmsPlan cmsPlan = gson.fromJson(view.getData(), CmsPlan.class);
cmsPlan.runtime = runtime;
cmsPlan.init(runtime, ThisApplication.threadPool());
cmsPlan.access();
result.setData(cmsPlan);
break;
......@@ -65,7 +67,7 @@ class ActionSimulate extends BaseAction {
case View.TYPE_PROCESSPLATFORM:
ProcessPlatformPlan processPlatformPlan = gson.fromJson(view.getData(), ProcessPlatformPlan.class);
this.setProcessEdition(business, processPlatformPlan);
processPlatformPlan.runtime = runtime;
processPlatformPlan.init(runtime, ThisApplication.threadPool());
processPlatformPlan.access();
result.setData(processPlatformPlan);
break;
......
......@@ -50,14 +50,15 @@ abstract class BaseAction extends StandardJaxrsAction {
}
protected Runtime runtime(EffectivePerson effectivePerson, Business business, View view,
List<FilterEntry> filterList, Map<String, String> parameter, Integer count, boolean isBundle) throws Exception {
List<FilterEntry> filterList, Map<String, String> parameter, Integer count, boolean isBundle)
throws Exception {
Runtime runtime = new Runtime();
runtime.person = effectivePerson.getDistinguishedName();
runtime.identityList = business.organization().identity().listWithPerson(effectivePerson);
List<String> list = new ArrayList<>();
if(runtime.identityList!=null){
for(String identity : runtime.identityList){
if(identity.indexOf("@")>-1) {
if (runtime.identityList != null) {
for (String identity : runtime.identityList) {
if (identity.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(identity, "@"));
}
}
......@@ -65,9 +66,9 @@ abstract class BaseAction extends StandardJaxrsAction {
list.clear();
}
runtime.unitList = business.organization().unit().listWithPerson(effectivePerson);
if(runtime.unitList!=null){
for(String item : runtime.unitList){
if(item.indexOf("@")>-1) {
if (runtime.unitList != null) {
for (String item : runtime.unitList) {
if (item.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(item, "@"));
}
}
......@@ -75,20 +76,20 @@ abstract class BaseAction extends StandardJaxrsAction {
list.clear();
}
runtime.unitAllList = business.organization().unit().listWithPersonSupNested(effectivePerson);
if(runtime.unitAllList!=null){
for(String item : runtime.unitAllList){
if(item.indexOf("@")>-1) {
if (runtime.unitAllList != null) {
for (String item : runtime.unitAllList) {
if (item.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(item, "@"));
}
}
runtime.unitAllList.addAll(list);
list.clear();
}
runtime.groupList = business.organization().group().listWithPersonReference(
ListTools.toList(effectivePerson.getDistinguishedName()), true, true, true);
if(runtime.groupList!=null){
for(String item : runtime.groupList){
if(item.indexOf("@")>-1) {
runtime.groupList = business.organization().group()
.listWithPersonReference(ListTools.toList(effectivePerson.getDistinguishedName()), true, true, true);
if (runtime.groupList != null) {
for (String item : runtime.groupList) {
if (item.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(item, "@"));
}
}
......@@ -96,9 +97,9 @@ abstract class BaseAction extends StandardJaxrsAction {
list.clear();
}
runtime.roleList = business.organization().role().listWithPerson(effectivePerson);
if(runtime.roleList!=null){
for(String item : runtime.roleList){
if(item.indexOf("@")>-1) {
if (runtime.roleList != null) {
for (String item : runtime.roleList) {
if (item.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(item, "@"));
}
}
......@@ -113,26 +114,26 @@ abstract class BaseAction extends StandardJaxrsAction {
protected Integer getCount(View view, Integer count, boolean isBundle) {
Integer viewCount = view.getCount();
if(isBundle) {
if(viewCount==null || viewCount < 1){
if (isBundle) {
if (viewCount == null || viewCount < 1) {
viewCount = View.MAX_COUNT;
}
Integer wiCount = ((count == null) || (count < 1)) ? viewCount : count;
return wiCount;
}else{
return ((count == null) || (count < 1)) ? viewCount : count;
} else {
Integer wiCount = ((count == null) || (count < 1) || (count > View.MAX_COUNT)) ? View.MAX_COUNT : count;
return NumberUtils.min(viewCount, wiCount);
}
}
protected void setProcessEdition(Business business, ProcessPlatformPlan processPlatformPlan) throws Exception {
if(!processPlatformPlan.where.processList.isEmpty()){
List<String> _process_ids = ListTools.extractField(processPlatformPlan.where.processList, Process.id_FIELDNAME, String.class,
true, true);
List<Process> processList = business.process().listObjectWithProcess(_process_ids, true);
if (!processPlatformPlan.where.processList.isEmpty()) {
List<String> processIds = ListTools.extractField(processPlatformPlan.where.processList,
Process.id_FIELDNAME, String.class, true, true);
List<Process> processList = business.process().listObjectWithProcess(processIds, true);
List<ProcessPlatformPlan.WhereEntry.ProcessEntry> listProcessEntry = gson.fromJson(gson.toJson(processList),
new TypeToken<List<ProcessPlatformPlan.WhereEntry.ProcessEntry>>(){}.getType());
if(!listProcessEntry.isEmpty()) {
new TypeToken<List<ProcessPlatformPlan.WhereEntry.ProcessEntry>>() {
}.getType());
if (!listProcessEntry.isEmpty()) {
processPlatformPlan.where.processList = listProcessEntry;
}
}
......
......@@ -22,6 +22,7 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.MD5Tool;
import com.x.query.assemble.surface.Business;
import com.x.query.assemble.surface.ThisApplication;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.View;
import com.x.query.core.express.plan.FilterEntry;
......@@ -60,10 +61,10 @@ class ActionBundle extends BaseAction {
runtime = this.runtime(effectivePerson, business, view, wi.getFilterList(), wi.getParameter(),
wi.getCount(), true);
}
List<String> os = this.fetchBundle(business, view, runtime);
List<String> os = this.fetchBundle(business, view, runtime, ThisApplication.threadPool());
Wo wo = new Wo();
wo.setValueList(os);
wo.setKey(MD5Tool.getMD5Str(effectivePerson.getDistinguishedName()+ Config.token().getCipher()));
wo.setKey(MD5Tool.getMD5Str(effectivePerson.getDistinguishedName() + Config.token().getCipher()));
result.setData(wo);
return result;
}
......@@ -71,9 +72,7 @@ class ActionBundle extends BaseAction {
public static class Wi extends GsonPropertyObject {
@FieldDescribe("过滤")
@FieldTypeDescribe(fieldType="class",fieldTypeName = "com.x.query.core.express.plan.FilterEntry",
fieldValue="{value='',otherValue='',path='',formatType='',logic='',comparison=''}",
fieldSample="{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
@FieldTypeDescribe(fieldType = "class", fieldTypeName = "com.x.query.core.express.plan.FilterEntry", fieldValue = "{value='',otherValue='',path='',formatType='',logic='',comparison=''}", fieldSample = "{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
private List<FilterEntry> filterList = new TreeList<>();
......
......@@ -20,6 +20,7 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapStringList;
import com.x.base.core.project.tools.MD5Tool;
import com.x.query.assemble.surface.Business;
import com.x.query.assemble.surface.ThisApplication;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.View;
import com.x.query.core.express.plan.FilterEntry;
......@@ -58,14 +59,16 @@ class ActionBundleWithQuery extends BaseAction {
wi.getCount(), true);
}
Wo wo = new Wo();
wo.setValueList(this.fetchBundle(business, view, runtime));
wo.setKey(MD5Tool.getMD5Str(effectivePerson.getDistinguishedName()+ Config.token().getCipher()));
wo.setValueList(this.fetchBundle(business, view, runtime, ThisApplication.threadPool()));
wo.setKey(MD5Tool.getMD5Str(effectivePerson.getDistinguishedName() + Config.token().getCipher()));
result.setData(wo);
return result;
}
public static class Wo extends WrapStringList {
private static final long serialVersionUID = 5605585771471176727L;
@FieldDescribe("访问execute秘钥串.")
private String key;
......@@ -80,10 +83,11 @@ class ActionBundleWithQuery extends BaseAction {
}
public static class Wi extends GsonPropertyObject {
private static final long serialVersionUID = 6425066184455473281L;
@FieldDescribe("过滤")
@FieldTypeDescribe(fieldType="class",fieldTypeName = "com.x.query.core.express.plan.FilterEntry",
fieldValue="{value='',otherValue='',path='',formatType='',logic='',comparison=''}",
fieldSample="{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
@FieldTypeDescribe(fieldType = "class", fieldTypeName = "com.x.query.core.express.plan.FilterEntry", fieldValue = "{value='',otherValue='',path='',formatType='',logic='',comparison=''}", fieldSample = "{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
private List<FilterEntry> filterList = new TreeList<>();
......
......@@ -23,6 +23,7 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.MD5Tool;
import com.x.query.assemble.surface.Business;
import com.x.query.assemble.surface.ThisApplication;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.View;
import com.x.query.core.express.plan.FilterEntry;
......@@ -36,8 +37,8 @@ class ActionExcel extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
if (ListTools.isNotEmpty(wi.getBundleList())){
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName()+ Config.token().getCipher());
if (ListTools.isNotEmpty(wi.getBundleList())) {
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName() + Config.token().getCipher());
if (!curKey.equals(wi.key)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
......@@ -65,7 +66,7 @@ class ActionExcel extends BaseAction {
wi.getCount(), false);
runtime.bundleList = wi.getBundleList();
}
Plan plan = this.accessPlan(business, view, runtime);
Plan plan = this.accessPlan(business, view, runtime, ThisApplication.threadPool());
String excelFlag = this.girdWriteToExcel(effectivePerson, business, plan, view, wi.getExcelName());
Wo wo = new Wo();
wo.setId(excelFlag);
......@@ -75,11 +76,16 @@ class ActionExcel extends BaseAction {
public static class Wo extends WoId {
private static final long serialVersionUID = -3109718021928716742L;
}
public static class Wi extends GsonPropertyObject {
private static final long serialVersionUID = 137649837114991882L;
@FieldDescribe("过滤")
@FieldTypeDescribe(fieldType="class",fieldTypeName = "com.x.query.core.express.plan.FilterEntry",fieldValue="{title='',value='',otherValue='',path='',formatType='',logic='',comparison=''}")
@FieldTypeDescribe(fieldType = "class", fieldTypeName = "com.x.query.core.express.plan.FilterEntry", fieldValue = "{title='',value='',otherValue='',path='',formatType='',logic='',comparison=''}")
private List<FilterEntry> filterList = new TreeList<>();
@FieldDescribe("参数")
......
......@@ -21,6 +21,7 @@ import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.MD5Tool;
import com.x.query.assemble.surface.Business;
import com.x.query.assemble.surface.ThisApplication;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.View;
import com.x.query.core.express.plan.FilterEntry;
......@@ -33,8 +34,8 @@ class ActionExcelWithQuery extends BaseAction {
throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
if (ListTools.isNotEmpty(wi.getBundleList())){
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName()+ Config.token().getCipher());
if (ListTools.isNotEmpty(wi.getBundleList())) {
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName() + Config.token().getCipher());
if (!curKey.equals(wi.key)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
......@@ -63,7 +64,7 @@ class ActionExcelWithQuery extends BaseAction {
wi.getCount(), false);
runtime.bundleList = wi.getBundleList();
}
Plan plan = this.accessPlan(business, view, runtime);
Plan plan = this.accessPlan(business, view, runtime, ThisApplication.threadPool());
String excelFlag = this.girdWriteToExcel(effectivePerson, business, plan, view, wi.getExcelName());
Wo wo = new Wo();
wo.setId(excelFlag);
......@@ -77,8 +78,7 @@ class ActionExcelWithQuery extends BaseAction {
public static class Wi extends GsonPropertyObject {
@FieldDescribe("过滤")
@FieldTypeDescribe(fieldType="class",fieldValue="{value='',otherValue='',path='',formatType='',logic='',comparison=''}",fieldTypeName = "com.x.query.core.express.plan.FilterEntry",
fieldSample="{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
@FieldTypeDescribe(fieldType = "class", fieldValue = "{value='',otherValue='',path='',formatType='',logic='',comparison=''}", fieldTypeName = "com.x.query.core.express.plan.FilterEntry", fieldSample = "{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
private List<FilterEntry> filterList = new TreeList<>();
......
......@@ -22,6 +22,7 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.MD5Tool;
import com.x.query.assemble.surface.Business;
import com.x.query.assemble.surface.ThisApplication;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.View;
import com.x.query.core.express.plan.FilterEntry;
......@@ -58,8 +59,8 @@ class ActionExecute extends BaseAction {
if (null == wi) {
wi = new Wi();
}
if (ListTools.isNotEmpty(wi.getBundleList())){
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName()+ Config.token().getCipher());
if (ListTools.isNotEmpty(wi.getBundleList())) {
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName() + Config.token().getCipher());
if (!curKey.equals(wi.key)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
......@@ -68,16 +69,14 @@ class ActionExecute extends BaseAction {
wi.getCount(), false);
runtime.bundleList = wi.getBundleList();
}
Plan plan = this.accessPlan(business, view, runtime);
Plan plan = this.accessPlan(business, view, runtime, ThisApplication.threadPool());
result.setData(plan);
return result;
}
public static class Wi extends GsonPropertyObject {
@FieldDescribe("过滤")
@FieldTypeDescribe(fieldType="class",fieldTypeName = "com.x.query.core.express.plan.FilterEntry",
fieldValue="{value='',otherValue='',path='',formatType='',logic='',comparison=''}",
fieldSample="{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
@FieldTypeDescribe(fieldType = "class", fieldTypeName = "com.x.query.core.express.plan.FilterEntry", fieldValue = "{value='',otherValue='',path='',formatType='',logic='',comparison=''}", fieldSample = "{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
private List<FilterEntry> filterList = new TreeList<>();
......
......@@ -21,6 +21,7 @@ import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.MD5Tool;
import com.x.query.assemble.surface.Business;
import com.x.query.assemble.surface.ThisApplication;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.View;
import com.x.query.core.express.plan.FilterEntry;
......@@ -56,8 +57,8 @@ class ActionExecuteWithQuery extends BaseAction {
if (null == wi) {
wi = new Wi();
}
if (ListTools.isNotEmpty(wi.getBundleList())){
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName()+ Config.token().getCipher());
if (ListTools.isNotEmpty(wi.getBundleList())) {
String curKey = MD5Tool.getMD5Str(effectivePerson.getDistinguishedName() + Config.token().getCipher());
if (!curKey.equals(wi.key)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
......@@ -66,7 +67,7 @@ class ActionExecuteWithQuery extends BaseAction {
wi.getCount(), false);
runtime.bundleList = wi.getBundleList();
}
Plan plan = this.accessPlan(business, view, runtime);
Plan plan = this.accessPlan(business, view, runtime, ThisApplication.threadPool());
result.setData(plan);
return result;
}
......@@ -77,10 +78,8 @@ class ActionExecuteWithQuery extends BaseAction {
public static class Wi extends GsonPropertyObject {
@FieldDescribe("过滤")
@FieldTypeDescribe(fieldType="class",fieldTypeName = "com.x.query.core.express.plan.FilterEntry",
fieldValue="{value='',otherValue='',path='',formatType='',logic='',comparison=''}",
fieldSample="{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
private List<FilterEntry> filterList = new TreeList<>();
@FieldTypeDescribe(fieldType = "class", fieldTypeName = "com.x.query.core.express.plan.FilterEntry", fieldValue = "{value='',otherValue='',path='',formatType='',logic='',comparison=''}", fieldSample = "{'logic':'逻辑运算:and|or','path':'data数据的路径:$work.title','comparison':'比较运算符:equals|notEquals|like|notLike|greaterThan|greaterThanOrEqualTo|lessThan|lessThanOrEqualTo|range','value':'7月','formatType':'textValue|numberValue|dateTimeValue|booleanValue'}")
private List<FilterEntry> filterList = new TreeList<>();
@FieldDescribe("参数")
private Map<String, String> parameter = new HashMap<>();
......
......@@ -7,6 +7,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -43,37 +44,37 @@ import com.x.query.core.express.plan.SelectEntry;
abstract class BaseAction extends StandardJaxrsAction {
protected Plan accessPlan(Business business, View view, Runtime runtime) throws Exception {
protected Plan accessPlan(Business business, View view, Runtime runtime, ExecutorService threadPool)
throws Exception {
Plan plan = null;
if (BooleanUtils.isTrue(view.getCacheAccess())) {
CacheKey cacheKey = new CacheKey("accessPlan", view.getId(),
StringTools.sha(gson.toJson(runtime)));
CacheKey cacheKey = new CacheKey("accessPlan", view.getId(), StringTools.sha(gson.toJson(runtime)));
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
plan = (Plan) optional.get();
} else {
plan = this.dealPlan(view, runtime);
plan = this.dealPlan(view, runtime, threadPool);
CacheManager.put(business.cache(), cacheKey, plan);
}
} else {
plan = this.dealPlan(view, runtime);
plan = this.dealPlan(view, runtime, threadPool);
}
return plan;
}
private Plan dealPlan(View view, Runtime runtime) throws Exception {
private Plan dealPlan(View view, Runtime runtime, ExecutorService threadPool) throws Exception {
Plan plan = null;
switch (StringUtils.trimToEmpty(view.getType())) {
case View.TYPE_CMS:
CmsPlan cmsPlan = gson.fromJson(view.getData(), CmsPlan.class);
cmsPlan.runtime = runtime;
cmsPlan.init(runtime, threadPool);
cmsPlan.access();
plan = cmsPlan;
break;
default:
ProcessPlatformPlan processPlatformPlan = gson.fromJson(view.getData(), ProcessPlatformPlan.class);
this.setProcessEdition(processPlatformPlan);
processPlatformPlan.runtime = runtime;
processPlatformPlan.init(runtime, threadPool);
processPlatformPlan.access();
plan = processPlatformPlan;
break;
......@@ -85,54 +86,56 @@ abstract class BaseAction extends StandardJaxrsAction {
}
private void setProcessEdition(ProcessPlatformPlan processPlatformPlan) throws Exception {
if(!processPlatformPlan.where.processList.isEmpty()){
List<String> _process_ids = ListTools.extractField(processPlatformPlan.where.processList, Process.id_FIELDNAME, String.class,
true, true);
if (!processPlatformPlan.where.processList.isEmpty()) {
List<String> processIds = ListTools.extractField(processPlatformPlan.where.processList,
Process.id_FIELDNAME, String.class, true, true);
List<Process> processList;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
processList = business.process().listObjectWithProcess(_process_ids, true);
processList = business.process().listObjectWithProcess(processIds, true);
}
List<ProcessPlatformPlan.WhereEntry.ProcessEntry> listProcessEntry = gson.fromJson(gson.toJson(processList),
new TypeToken<List<ProcessPlatformPlan.WhereEntry.ProcessEntry>>(){}.getType());
if(!listProcessEntry.isEmpty()) {
new TypeToken<List<ProcessPlatformPlan.WhereEntry.ProcessEntry>>() {
}.getType());
if (!listProcessEntry.isEmpty()) {
processPlatformPlan.where.processList = listProcessEntry;
}
}
}
private List<String> dealBundle(Business business, View view, Runtime runtime) throws Exception {
private List<String> dealBundle(Business business, View view, Runtime runtime, ExecutorService threadPool)
throws Exception {
List<String> os = null;
switch (StringUtils.trimToEmpty(view.getType())) {
case View.TYPE_CMS:
CmsPlan cmsPlan = gson.fromJson(view.getData(), CmsPlan.class);
cmsPlan.runtime = runtime;
cmsPlan.init(runtime, threadPool);
os = cmsPlan.fetchBundles();
break;
default:
ProcessPlatformPlan processPlatformPlan = gson.fromJson(view.getData(), ProcessPlatformPlan.class);
this.setProcessEdition(processPlatformPlan);
processPlatformPlan.runtime = runtime;
processPlatformPlan.init(runtime, threadPool);
os = processPlatformPlan.fetchBundles();
break;
}
return os;
}
protected List<String> fetchBundle(Business business, View view, Runtime runtime) throws Exception {
protected List<String> fetchBundle(Business business, View view, Runtime runtime, ExecutorService threadPool)
throws Exception {
List<String> os = null;
if (BooleanUtils.isTrue(view.getCacheAccess())) {
CacheKey cacheKey = new CacheKey("fetchBundle", view.getId(),
StringTools.sha(gson.toJson(runtime)));
CacheKey cacheKey = new CacheKey("fetchBundle", view.getId(), StringTools.sha(gson.toJson(runtime)));
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
os = (List<String>) optional.get();
} else {
os = this.dealBundle(business, view, runtime);
os = this.dealBundle(business, view, runtime, threadPool);
CacheManager.put(business.cache(), cacheKey, os);
}
} else {
os = this.dealBundle(business, view, runtime);
os = this.dealBundle(business, view, runtime, threadPool);
}
return os;
}
......@@ -169,8 +172,8 @@ abstract class BaseAction extends StandardJaxrsAction {
}
protected String girdWriteToExcel(EffectivePerson effectivePerson, Business business, Plan plan, View view, String excelName)
throws Exception {
protected String girdWriteToExcel(EffectivePerson effectivePerson, Business business, Plan plan, View view,
String excelName) throws Exception {
try (XSSFWorkbook workbook = new XSSFWorkbook(); ByteArrayOutputStream os = new ByteArrayOutputStream()) {
XSSFSheet sheet = workbook.createSheet("grid");
if (ListTools.isNotEmpty(plan.selectList)) {
......@@ -194,60 +197,60 @@ abstract class BaseAction extends StandardJaxrsAction {
i = 0;
for (SelectEntry o : plan.selectList) {
c = r.createCell(i);
//c.setCellValue(Objects.toString(row.find(o.column)));
c.setCellValue(objectToString(row.find(o.column)));
i++;
}
}
}
if(StringUtils.isEmpty(excelName)) {
if (StringUtils.isEmpty(excelName)) {
excelName = view.getName() + ".xlsx";
}
if(!excelName.toLowerCase().endsWith(".xlsx")){
if (!excelName.toLowerCase().endsWith(".xlsx")) {
excelName = excelName + ".xlsx";
}
workbook.write(os);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
StorageMapping gfMapping = ThisApplication.context().storageMappings().random(GeneralFile.class);
GeneralFile generalFile = new GeneralFile(gfMapping.getName(), excelName, effectivePerson.getDistinguishedName());
GeneralFile generalFile = new GeneralFile(gfMapping.getName(), excelName,
effectivePerson.getDistinguishedName());
generalFile.saveContent(gfMapping, os.toByteArray(), excelName);
emc.beginTransaction(GeneralFile.class);
emc.persist(generalFile, CheckPersistType.all);
emc.commit();
String key = generalFile.getId();
return key;
return generalFile.getId();
}
}
}
protected String objectToString(Object object) {
String str = "";
String str = "";
if (object instanceof Integer) {
str = object.toString();
}else if (object instanceof Double) {
} else if (object instanceof Double) {
str = object.toString();
}else if (object instanceof Float) {
} else if (object instanceof Float) {
str = object.toString();
}else if (object instanceof Boolean) {
} else if (object instanceof Boolean) {
str = String.valueOf(object);
} else if (object instanceof Date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
str= formatter.format(object);
}else {
str = formatter.format(object);
} else {
str = object.toString();
}
return str;
}
protected Runtime runtime(EffectivePerson effectivePerson, Business business, View view,
List<FilterEntry> filterList, Map<String, String> parameter, Integer count, boolean isBundle) throws Exception {
List<FilterEntry> filterList, Map<String, String> parameter, Integer count, boolean isBundle)
throws Exception {
Runtime runtime = new Runtime();
runtime.person = effectivePerson.getDistinguishedName();
runtime.identityList = business.organization().identity().listWithPerson(effectivePerson);
List<String> list = new ArrayList<>();
if(runtime.identityList!=null){
for(String identity : runtime.identityList){
if(identity.indexOf("@")>-1) {
if (runtime.identityList != null) {
for (String identity : runtime.identityList) {
if (identity.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(identity, "@"));
}
}
......@@ -255,9 +258,9 @@ abstract class BaseAction extends StandardJaxrsAction {
list.clear();
}
runtime.unitList = business.organization().unit().listWithPerson(effectivePerson);
if(runtime.unitList!=null){
for(String item : runtime.unitList){
if(item.indexOf("@")>-1) {
if (runtime.unitList != null) {
for (String item : runtime.unitList) {
if (item.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(item, "@"));
}
}
......@@ -265,20 +268,20 @@ abstract class BaseAction extends StandardJaxrsAction {
list.clear();
}
runtime.unitAllList = business.organization().unit().listWithPersonSupNested(effectivePerson);
if(runtime.unitAllList!=null){
for(String item : runtime.unitAllList){
if(item.indexOf("@")>-1) {
if (runtime.unitAllList != null) {
for (String item : runtime.unitAllList) {
if (item.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(item, "@"));
}
}
runtime.unitAllList.addAll(list);
list.clear();
}
runtime.groupList = business.organization().group().listWithPersonReference(
ListTools.toList(effectivePerson.getDistinguishedName()), true, true, true);
if(runtime.groupList!=null){
for(String item : runtime.groupList){
if(item.indexOf("@")>-1) {
runtime.groupList = business.organization().group()
.listWithPersonReference(ListTools.toList(effectivePerson.getDistinguishedName()), true, true, true);
if (runtime.groupList != null) {
for (String item : runtime.groupList) {
if (item.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(item, "@"));
}
}
......@@ -286,9 +289,9 @@ abstract class BaseAction extends StandardJaxrsAction {
list.clear();
}
runtime.roleList = business.organization().role().listWithPerson(effectivePerson);
if(runtime.roleList!=null){
for(String item : runtime.roleList){
if(item.indexOf("@")>-1) {
if (runtime.roleList != null) {
for (String item : runtime.roleList) {
if (item.indexOf("@") > -1) {
list.add(StringUtils.substringAfter(item, "@"));
}
}
......@@ -303,13 +306,12 @@ abstract class BaseAction extends StandardJaxrsAction {
protected Integer getCount(View view, Integer count, boolean isBundle) {
Integer viewCount = view.getCount();
if(isBundle) {
if(viewCount==null || viewCount < 1){
if (isBundle) {
if (viewCount == null || viewCount < 1) {
viewCount = View.MAX_COUNT;
}
Integer wiCount = ((count == null) || (count < 1)) ? viewCount : count;
return wiCount;
}else{
return ((count == null) || (count < 1)) ? viewCount : count;
} else {
Integer wiCount = ((count == null) || (count < 1) || (count > View.MAX_COUNT)) ? View.MAX_COUNT : count;
return NumberUtils.min(viewCount, wiCount);
}
......
......@@ -38,9 +38,9 @@ import com.x.query.core.entity.Item_;
public class CmsPlan extends Plan {
public CmsPlan(Runtime runtime, ExecutorService threadPool) {
super(threadPool);
this.runtime = runtime;
private static final long serialVersionUID = -752841556895959631L;
public CmsPlan() {
this.selectList = new SelectEntries();
this.where = new WhereEntry();
this.filterList = new TreeList<FilterEntry>();
......
......@@ -45,6 +45,8 @@ import com.x.query.core.entity.Item_;
public abstract class Plan extends GsonPropertyObject {
private static final long serialVersionUID = -4281507899642115426L;
public static final String SCOPE_WORK = "work";
public static final String SCOPE_CMS_INFO = "cms_info";
public static final String SCOPE_CMS_DATA = "cms_data";
......@@ -55,12 +57,13 @@ public abstract class Plan extends GsonPropertyObject {
public static final String CALCULATE_AVERAGE = "average";
public static final String CALCULATE_COUNT = "count";
protected Plan(ExecutorService threadPool) {
protected transient ExecutorService threadPool;
public void init(Runtime runtime, ExecutorService threadPool) {
this.runtime = runtime;
this.threadPool = threadPool;
}
protected ExecutorService threadPool;
public Runtime runtime;
public SelectEntries selectList = new SelectEntries();
......
......@@ -45,9 +45,7 @@ public class ProcessPlatformPlan extends Plan {
private static final Logger LOGGER = LoggerFactory.getLogger(ProcessPlatformPlan.class);
public ProcessPlatformPlan(Runtime runtime, ExecutorService threadPool) {
super(threadPool);
this.runtime = runtime;
public ProcessPlatformPlan() {
this.selectList = new SelectEntries();
this.where = new WhereEntry();
this.filterList = new TreeList<FilterEntry>();
......
......@@ -10,9 +10,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.BooleanUtils;
......@@ -30,6 +28,8 @@ import com.x.query.core.entity.View;
public class StatPlan extends GsonPropertyObject {
private static final long serialVersionUID = -5053000443343214766L;
protected ExecutorService threadPool;
private static final Logger LOGGER = LoggerFactory.getLogger(StatPlan.class);
......@@ -50,21 +50,15 @@ public class StatPlan extends GsonPropertyObject {
this.findPlan(plans);
}
// 添加运行时状态
plans.values().forEach(o -> o.runtime = runtime);
List<CompletableFuture<Void>> futures = new ArrayList<>();
plans.values().stream().forEach(o -> {
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
try {
o.access();
} catch (Exception e) {
e.printStackTrace();
}
}, threadPool);
futures.add(future);
plans.values().forEach(o -> o.init(runtime, threadPool));
plans.values().forEach(o -> {
try {
o.access();
} catch (Exception e) {
LOGGER.error(e);
}
});
for (CompletableFuture<Void> future : futures) {
future.get(300, TimeUnit.SECONDS);
}
if (BooleanUtils.isTrue(calculate.isGroup)) {
this.setCalculateGrid(this.mergeGroup(plans));
} else {
......@@ -158,7 +152,7 @@ public class StatPlan extends GsonPropertyObject {
} else if (StringUtils.equals((view.getType()), View.TYPE_PROCESSPLATFORM)) {
ProcessPlatformPlan processPlatformPlan = gson.fromJson(view.getData(),
ProcessPlatformPlan.class);
/* 非分类视图或者分类视图都可以 */
// 非分类视图或者分类视图都可以
List<SelectEntry> uselessSelectList = new ArrayList<>();
processPlatformPlan.selectList.stream().forEachOrdered(s -> {
if (!StringUtils.equals(s.column, o.column)) {
......@@ -220,7 +214,7 @@ public class StatPlan extends GsonPropertyObject {
for (Entry<String, Plan> en : plans.entrySet()) {
if ((null != en.getValue().group) && BooleanUtils.isTrue(en.getValue().group.available())) {
en.getValue().selectList.stream().forEach(o -> {
/* 分类统计只能统计分类视图 */
// 分类统计只能统计分类视图
if (!StringUtils.equals(o.column, en.getValue().group.column)) {
CalculateEntry calculateEntry = calculate.find(en.getKey());
if (null != calculateEntry) {
......@@ -234,7 +228,7 @@ public class StatPlan extends GsonPropertyObject {
r.list.stream().forEach(c -> {
values.add(c.getAsDouble(o.column));
});
/* 如果有添加的分类值,有可能取得的是null */
// 如果有添加的分类值,有可能取得的是null
if (StringUtils.equals(calculateEntry.calculateType, Plan.CALCULATE_AVERAGE)) {
cell.value = numberFormat
.format(values.stream().mapToDouble(d -> d).average().orElse(0));
......@@ -254,9 +248,9 @@ public class StatPlan extends GsonPropertyObject {
}
if (StringUtils.equalsIgnoreCase(SelectEntry.ORDER_DESC, calculate.orderType)
|| StringUtils.equalsIgnoreCase(SelectEntry.ORDER_ASC, calculate.orderType)) {
/* 需要进行排序如果为空则对标题进行排序 */
// 需要进行排序如果为空则对标题进行排序
if (StringUtils.isEmpty(calculate.orderColumn)) {
/* 按分类值进行排序 */
// 按分类值进行排序
if (StringUtils.equalsIgnoreCase(SelectEntry.ORDER_ASC, calculate.orderType)) {
table.sort(new GroupComparator());
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册