Sfoglia il codice sorgente

Merge branch 'wrdp' into 'develop'

Wrdp

See merge request o2oa/o2oa!2945
o2null 5 anni fa
parent
commit
3274512918

+ 8 - 0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ApplicationServer.java

@@ -22,6 +22,7 @@ public class ApplicationServer extends ConfigObject {
 	private static final Integer DEFAULT_MAXFORMCONTENT = 20;
 	private static final Boolean DEFAULT_EXPOSEJEST = true;
 	private static final Boolean DEFAULT_PERSISTENTCONNECTIONSENABLE = true;
+	private static final Integer DEFAULT_MAXTHREAD = 500;
 
 	public ApplicationServer() {
 		this.enable = true;
@@ -40,6 +41,7 @@ public class ApplicationServer extends ConfigObject {
 		this.maxFormContent = DEFAULT_MAXFORMCONTENT;
 		this.exposeJest = DEFAULT_EXPOSEJEST;
 		this.persistentConnectionsEnable = DEFAULT_PERSISTENTCONNECTIONSENABLE;
+		this.maxThread = DEFAULT_MAXTHREAD;
 	}
 
 	@FieldDescribe("是否启用")
@@ -72,6 +74,8 @@ public class ApplicationServer extends ConfigObject {
 	private Integer maxFormContent;
 	@FieldDescribe("暴露jest接口.")
 	private Boolean exposeJest;
+	@FieldDescribe("最大http线程数.")
+	private Integer maxThread;
 
 	@FieldDescribe("是否启用长连接,默认true.")
 	private Boolean persistentConnectionsEnable;
@@ -240,4 +244,8 @@ public class ApplicationServer extends ConfigObject {
 		this.excludes = excludes;
 	}
 
+	public Integer getMaxThread() {
+		return (null == this.maxThread || this.maxThread < 1) ? DEFAULT_MAXTHREAD : this.maxThread;
+	}
+
 }

+ 2 - 60
o2server/x_console/src/main/java/com/x/server/console/NodeAgent.java

@@ -480,65 +480,7 @@ public class NodeAgent extends Thread {
 	private void storeJar(String simpleName, byte[] bytes) throws Exception {
 		File jar = new File(Config.dir_store_jars(true), simpleName + ".jar");
 		FileUtils.writeByteArrayToFile(jar, bytes, false);
-		List<ClassInfo> classInfos = this.listModuleDependencyWith(simpleName);
-		List<String> contextPaths = new ArrayList<>();
-		for (ClassInfo info : classInfos) {
-			contextPaths.add("/" + info.getSimpleName());
-		}
 
-		if (Servers.applicationServerIsRunning()) {
-			GzipHandler gzipHandler = (GzipHandler) Servers.applicationServer.getHandler();
-			HandlerList hanlderList = (HandlerList) gzipHandler.getHandler();
-			for (Handler handler : hanlderList.getHandlers()) {
-				if (QuickStartWebApp.class.isAssignableFrom(handler.getClass())) {
-					QuickStartWebApp app = (QuickStartWebApp) handler;
-					if (contextPaths.contains(app.getContextPath())) {
-						logger.print("{} need restart because {} redeployed.", app.getDisplayName(), simpleName);
-						app.stop();
-					}
-				}
-			}
-		}
-		if (Servers.centerServerIsRunning()) {
-			GzipHandler gzipHandler = (GzipHandler) Servers.centerServer.getHandler();
-			HandlerList hanlderList = (HandlerList) gzipHandler.getHandler();
-			for (Handler handler : hanlderList.getHandlers()) {
-				if (QuickStartWebApp.class.isAssignableFrom(handler.getClass())) {
-					QuickStartWebApp app = (QuickStartWebApp) handler;
-					if (contextPaths.contains(app.getContextPath())) {
-						logger.print("{} need restart because {} redeployed.", app.getDisplayName(), simpleName);
-						app.stop();
-					}
-				}
-			}
-		}
-
-		if (Servers.applicationServerIsRunning()) {
-			GzipHandler gzipHandler = (GzipHandler) Servers.applicationServer.getHandler();
-			HandlerList hanlderList = (HandlerList) gzipHandler.getHandler();
-			for (Handler handler : hanlderList.getHandlers()) {
-				if (QuickStartWebApp.class.isAssignableFrom(handler.getClass())) {
-					QuickStartWebApp app = (QuickStartWebApp) handler;
-					if (contextPaths.contains(app.getContextPath())) {
-						logger.print("{} need restart because {} redeployed.", app.getDisplayName(), simpleName);
-						app.start();
-					}
-				}
-			}
-		}
-		if (Servers.centerServerIsRunning()) {
-			GzipHandler gzipHandler = (GzipHandler) Servers.centerServer.getHandler();
-			HandlerList hanlderList = (HandlerList) gzipHandler.getHandler();
-			for (Handler handler : hanlderList.getHandlers()) {
-				if (QuickStartWebApp.class.isAssignableFrom(handler.getClass())) {
-					QuickStartWebApp app = (QuickStartWebApp) handler;
-					if (contextPaths.contains(app.getContextPath())) {
-						logger.print("{} need restart because {} redeployed.", app.getDisplayName(), simpleName);
-						app.start();
-					}
-				}
-			}
-		}
 	}
 
 	private boolean customWarUninstall(String simpleName) throws Exception {
@@ -638,11 +580,11 @@ public class NodeAgent extends Thread {
 	private void customJar(String simpleName, byte[] bytes, boolean rebootApp) throws Exception {
 		File jar = new File(Config.dir_custom_jars(true), simpleName + ".jar");
 		FileUtils.writeByteArrayToFile(jar, bytes, false);
-		if (rebootApp) {
+		/*if (rebootApp) {
 			Servers.stopApplicationServer();
 			Thread.sleep(3000);
 			Servers.startApplicationServer();
-		}
+		}*/
 	}
 
 	private void customZip(String simpleName, byte[] bytes, boolean rebootApp) throws Exception {

+ 1 - 1
o2server/x_console/src/main/java/com/x/server/console/server/application/ApplicationServerTools.java

@@ -123,7 +123,7 @@ public class ApplicationServerTools extends JettySeverTools {
 
 		QueuedThreadPool threadPool = new QueuedThreadPool();
 		threadPool.setMinThreads(APPLICATIONSERVER_THREAD_POOL_SIZE_MIN);
-		threadPool.setMaxThreads(APPLICATIONSERVER_THREAD_POOL_SIZE_MAX);
+		threadPool.setMaxThreads(applicationServer.getMaxThread());
 		Server server = new Server(threadPool);
 		server.setAttribute("maxFormContentSize", applicationServer.getMaxFormContent() * 1024 * 1024);
 

+ 5 - 2
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionInputAll.java

@@ -10,6 +10,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Random;
+import java.util.concurrent.locks.ReentrantLock;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -65,12 +66,11 @@ import com.x.organization.core.entity.PersonAttribute;
 import com.x.organization.core.entity.Role;
 import com.x.organization.core.entity.Unit;
 import com.x.organization.core.entity.UnitDuty;
-import com.x.base.core.project.cache.Cache.CacheKey;
 
 class ActionInputAll extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionInputAll.class);
-	
+	private static ReentrantLock lock = new ReentrantLock();
 	private  boolean dutyFlag = false;
 	
 	private  boolean wholeFlag = false;
@@ -92,6 +92,7 @@ class ActionInputAll extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, byte[] bytes, FormDataContentDisposition disposition)
 			throws Exception {
+		lock.lock();
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create();
 				InputStream is = new ByteArrayInputStream(bytes);
 				XSSFWorkbook workbook = new XSSFWorkbook(is);
@@ -113,6 +114,8 @@ class ActionInputAll extends BaseAction {
 			wo.setFlag(flag);
 			result.setData(wo);
 			return result;
+		}finally {
+			lock.unlock();
 		}
 	}
 

+ 17 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/content/JobFactory.java

@@ -2,6 +2,7 @@ package com.x.processplatform.assemble.surface.factory.content;
 
 import java.util.List;
 
+import com.x.base.core.entity.JpaObject;
 import com.x.base.core.project.tools.ListTools;
 import com.x.processplatform.assemble.surface.AbstractFactory;
 import com.x.processplatform.assemble.surface.Business;
@@ -63,4 +64,20 @@ public class JobFactory extends AbstractFactory {
 			return false;
 		}
 	}
+
+	public String findAWorkOrWorkCompleted(String job) throws Exception {
+		String id = "";
+		List<Work> ws = this.entityManagerContainer().fetchEqualAscPaging(Work.class,
+				ListTools.toList(Work.id_FIELDNAME), Work.job_FIELDNAME, job, 1, 1, JpaObject.sequence_FIELDNAME);
+		if (ListTools.isNotEmpty(ws)) {
+			id = ws.get(0).getId();
+		}else {
+			List<WorkCompleted> wcs = this.entityManagerContainer().fetchEqualAscPaging(WorkCompleted.class,
+					ListTools.toList(WorkCompleted.id_FIELDNAME), WorkCompleted.job_FIELDNAME, job, 1, 1, JpaObject.sequence_FIELDNAME);
+			if (ListTools.isNotEmpty(wcs)) {
+				id = wcs.get(0).getId();
+			}
+		}
+		return id;
+	}
 }

+ 132 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionListWithJob.java

@@ -0,0 +1,132 @@
+package com.x.processplatform.assemble.surface.jaxrs.attachment;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.entity.JpaObject;
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.bean.WrapCopier;
+import com.x.base.core.project.bean.WrapCopierFactory;
+import com.x.base.core.project.exception.ExceptionAccessDenied;
+import com.x.base.core.project.gson.GsonPropertyObject;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.processplatform.assemble.surface.Business;
+import com.x.processplatform.core.entity.content.Attachment;
+import org.apache.commons.lang3.BooleanUtils;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+class ActionListWithJob extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ActionListWithJob.class);
+
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String job) throws Exception {
+
+		ActionResult<List<Wo>> result = new ActionResult<>();
+		CompletableFuture<List<Wo>> listFuture = listFuture(effectivePerson, job);
+		CompletableFuture<Boolean> checkControlFuture = checkJobControlFuture(effectivePerson, job);
+		result.setData(listFuture.get(10, TimeUnit.SECONDS));
+		if (BooleanUtils.isFalse(checkControlFuture.get(10, TimeUnit.SECONDS))) {
+			throw new ExceptionAccessDenied(effectivePerson, job);
+		}
+		return result;
+
+	}
+
+	private CompletableFuture<List<Wo>> listFuture(EffectivePerson effectivePerson, String flag) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<Wo> wos = new ArrayList<>();
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				List<String> identities = business.organization().identity().listWithPerson(effectivePerson);
+				List<String> units = business.organization().unit().listWithPerson(effectivePerson);
+				final String job = flag;
+				for (Attachment attachment : business.entityManagerContainer().listEqual(Attachment.class,
+						Attachment.job_FIELDNAME, job)) {
+					Wo wo = Wo.copier.copy(attachment);
+					boolean canControl = this.control(attachment, effectivePerson, identities, units, business);
+					boolean canEdit = this.edit(attachment, effectivePerson, identities, units, business);
+					boolean canRead = this.read(attachment, effectivePerson, identities, units, business);
+					if (canRead) {
+						wo.getControl().setAllowRead(true);
+						wo.getControl().setAllowEdit(canEdit);
+						wo.getControl().setAllowControl(canControl);
+						wos.add(wo);
+					}
+				}
+				wos = wos.stream()
+						.sorted(Comparator.comparing(Wo::getOrderNumber, Comparator.nullsLast(Integer::compareTo))
+								.thenComparing(
+										Comparator.comparing(Wo::getCreateTime, Comparator.nullsLast(Date::compareTo))))
+						.collect(Collectors.toList());
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return wos;
+		});
+
+	}
+
+	public static class Wo extends Attachment {
+
+		private static final long serialVersionUID = -7666329770246726197L;
+
+		static WrapCopier<Attachment, Wo> copier = WrapCopierFactory.wo(Attachment.class, Wo.class, null,
+				JpaObject.FieldsInvisible);
+
+		private WoControl control = new WoControl();
+
+		public WoControl getControl() {
+			return control;
+		}
+
+		public void setControl(WoControl control) {
+			this.control = control;
+		}
+
+	}
+
+	public static class WoControl extends GsonPropertyObject {
+		private static final long serialVersionUID = -7283783148043076205L;
+		@FieldDescribe("可读")
+		private Boolean allowRead = false;
+		@FieldDescribe("可写")
+		private Boolean allowEdit = false;
+		@FieldDescribe("可控制")
+		private Boolean allowControl = false;
+
+		public Boolean getAllowRead() {
+			return allowRead;
+		}
+
+		public void setAllowRead(Boolean allowRead) {
+			this.allowRead = allowRead;
+		}
+
+		public Boolean getAllowEdit() {
+			return allowEdit;
+		}
+
+		public void setAllowEdit(Boolean allowEdit) {
+			this.allowEdit = allowEdit;
+		}
+
+		public Boolean getAllowControl() {
+			return allowControl;
+		}
+
+		public void setAllowControl(Boolean allowControl) {
+			this.allowControl = allowControl;
+		}
+
+	}
+
+}

+ 19 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java

@@ -173,6 +173,25 @@ public class AttachmentAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
+	@JaxrsMethodDescribe(value = "根据工作的job获取Attachment列表.", action = ActionListWithJob.class)
+	@GET
+	@Path("list/job/{job}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void listWithJob(@Suspended final AsyncResponse asyncResponse,
+											@Context HttpServletRequest request,
+											@JaxrsParameterDescribe("工作的job") @PathParam("job") String job) {
+		ActionResult<List<ActionListWithJob.Wo>> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionListWithJob().execute(effectivePerson, job);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
 	@JaxrsMethodDescribe(value = "删除指定work下的附件.", action = ActionDeleteWithWork.class)
 	@DELETE
 	@Path("{id}/work/{workId}")

+ 17 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java

@@ -235,6 +235,23 @@ abstract class BaseAction extends StandardJaxrsAction {
 		return value;
 	}
 
+	protected CompletableFuture<Boolean> checkJobControlFuture(EffectivePerson effectivePerson, String job) {
+		return CompletableFuture.supplyAsync(() -> {
+			Boolean value = false;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				String flag = business.job().findAWorkOrWorkCompleted(job);
+				if(StringUtils.isNotEmpty(flag)){
+					value = business.readableWithWorkOrWorkCompleted(effectivePerson, flag,
+							new ExceptionEntityNotExist(job));
+				}
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return value;
+		});
+	}
+
 	protected CompletableFuture<Boolean> checkControlFuture(EffectivePerson effectivePerson, String flag) {
 		return CompletableFuture.supplyAsync(() -> {
 			Boolean value = false;

+ 1 - 1
o2web/source/x_component_Setting/lp/zh-cn.js

@@ -219,7 +219,7 @@ MWF.xApplication.Setting.LP = {
     "service_ctl":"命令名称",
     "service_node":"服务器节点",
     "service_allNode":"全部节点",
-    "service_success":"部署成功,app应用会自动重启,请稍候操作,大概一分钟。。",
+    "service_success":"部署成功,需要重启服务后生效",
 
     "on": "开",
     "off": "关",