Просмотр исходного кода

Merge branch 'fix/sync_master' into 'master'

Fix/sync master master上修改的内容同步到master

See merge request o2oa/o2oa!137
o2null 5 лет назад
Родитель
Сommit
568db94ca4

+ 1 - 0
.gitignore

@@ -151,3 +151,4 @@ typings/
 #vscode
 **/.factorypath
 **/.vscode/
+*.swp

+ 11 - 2
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/factory/BBSReplyInfoFactory.java

@@ -64,10 +64,14 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 		CriteriaQuery<Long> cq = cb.createQuery(Long.class);
 		Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class);
 		Predicate p = cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId );
+
 		if( !showSubReply ){
-			p = cb.and( p,cb.equal(root.get( BBSReplyInfo_.parentId ), ""));
+			Predicate p_showSubReply = cb.isNull( root.get( BBSReplyInfo_.parentId ));
+			p_showSubReply = cb.or( p_showSubReply, cb.equal( root.get( BBSReplyInfo_.parentId), ""));
+			p = cb.and( p, p_showSubReply);
 		}
 		cq.select( cb.count( root ) );
+//		System.out.println( ">>>>>SQL:" + em.createQuery(cq.where(p)).toString() );
 		return em.createQuery(cq.where(p)).getSingleResult();
 	}
 	
@@ -112,12 +116,17 @@ public class BBSReplyInfoFactory extends AbstractFactory {
 		Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class );
 		Predicate p = cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId );
 		if( !showSubReply ){
-			p = cb.and( p, cb.equal(root.get( BBSReplyInfo_.parentId ), ""));
+			Predicate p_showSubReply = cb.isNull( root.get( BBSReplyInfo_.parentId ));
+			p_showSubReply = cb.or( p_showSubReply, cb.equal( root.get( BBSReplyInfo_.parentId), ""));
+			p = cb.and( p, p_showSubReply);
 		}
+
 		cq.orderBy( cb.desc( root.get( BBSReplyInfo_.createTime ) ) );
 		if( maxCount == null ){
+//			System.out.println( ">>>>>SQL:" + em.createQuery(cq.where(p)).toString() );
 			return em.createQuery(cq.where(p)).getResultList();
 		}else{
+//			System.out.println( ">>>>>SQL:" + em.createQuery(cq.where(p)).setMaxResults( maxCount ).toString() );
 			return em.createQuery(cq.where(p)).setMaxResults( maxCount ).getResultList();
 		}
 	}

+ 1 - 0
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/service/BBSSubjectInfoService.java

@@ -245,6 +245,7 @@ public class BBSSubjectInfoService {
 		emc.beginTransaction( BBSSectionInfo.class );
 		emc.beginTransaction( BBSSubjectInfo.class );
 		emc.beginTransaction( BBSSubjectContent.class );
+		emc.beginTransaction( BBSReplyInfo.class );
 		emc.beginTransaction( BBSVoteOption.class );
 		emc.beginTransaction( BBSVoteOptionGroup.class );
 		emc.beginTransaction( BBSVoteRecord.class );

+ 1 - 1
o2server/x_bbs_assemble_control/src/main/java/com/x/bbs/assemble/control/service/BBSSubjectInfoServiceAdv.java

@@ -114,7 +114,7 @@ public class BBSSubjectInfoServiceAdv {
 	 * 3、论坛主题数量-1
 	 * 4、版块回复数量-n,如果有主版块,主版块回复数量-n
 	 * 5、论坛回复数量-n
-	 * @param id
+	 * @param subjectId
 	 * @throws Exception
 	 */
 	public void delete( String subjectId ) throws Exception {

+ 24 - 12
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistPublishByWorkFlow.java

@@ -167,18 +167,31 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
 		}
 
 		if (check) {
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				if ( StringUtils.isNotEmpty( wi.getCreatorIdentity() )) {
-					wi.setCreatorPerson( userManagerService.getPersonNameWithIdentity( wi.getCreatorIdentity() ) );
-					wi.setCreatorUnitName( userManagerService.getUnitNameByIdentity( wi.getCreatorIdentity() ) );
-					wi.setCreatorTopUnitName( userManagerService.getTopUnitNameByIdentity( wi.getCreatorIdentity() ) );
-				} else {
-					if ("xadmin".equalsIgnoreCase( effectivePerson.getDistinguishedName()) ) {
+			try {
+				if (StringUtils.isEmpty( wi.getCreatorIdentity() )) {
+					if( "cipher".equalsIgnoreCase( effectivePerson.getDistinguishedName() )) {
+						wi.setCreatorIdentity("cipher");
+						wi.setCreatorPerson("cipher");
+						wi.setCreatorUnitName("cipher");
+						wi.setCreatorTopUnitName("cipher");
+					}else if ("xadmin".equalsIgnoreCase(effectivePerson.getDistinguishedName())) {
 						wi.setCreatorIdentity("xadmin");
 						wi.setCreatorPerson("xadmin");
 						wi.setCreatorUnitName("xadmin");
 						wi.setCreatorTopUnitName("xadmin");
-					} else {
+					}else {
+						//尝试一下根据当前用户获取用户的第一个身份
+						wi.setCreatorIdentity(userManagerService.getMajorIdentityWithPerson( effectivePerson.getDistinguishedName()) );
+					}
+				}
+
+				if ( !StringUtils.equals(  "cipher", wi.getCreatorIdentity() ) && !StringUtils.equals(  "xadmin", wi.getCreatorIdentity() )) {
+					//说明是指定的发布者,并不使用cipher和xadmin代替
+					if (StringUtils.isNotEmpty( wi.getCreatorIdentity() )) {
+						wi.setCreatorPerson( userManagerService.getPersonNameWithIdentity( wi.getCreatorIdentity() ) );
+						wi.setCreatorUnitName( userManagerService.getUnitNameByIdentity( wi.getCreatorIdentity() ) );
+						wi.setCreatorTopUnitName( userManagerService.getTopUnitNameByIdentity( wi.getCreatorIdentity() ) );
+					}else {
 						Exception exception = new ExceptionPersonHasNoIdentity(wi.getCreatorIdentity());
 						result.error(exception);
 					}
@@ -191,9 +204,6 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
 
 		if (check) {
 			if ( StringUtils.isEmpty(wi.getTitle())) {
-//				check = false;
-//				Exception exception = new ExceptionDocumentTitleEmpty();
-//				result.error(exception);
 				wi.setTitle( appInfo.getAppName() + " - " + categoryInfo.getCategoryName() + " - 无标题文档" );
 			}
 		}
@@ -212,6 +222,7 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
 			}
 		}
 
+		//从流程管理中复制所有的附件到CMS
 		if (check) {
 			if ( wi.getWf_attachmentIds() != null && wi.getWf_attachmentIds().length > 0 ) {
 				FileInfo fileInfo = null;
@@ -267,11 +278,12 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
 				throw exception;
 			}
 		}
+
 		if (check) {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				logService.log(emc, wi.getCreatorIdentity(),
 						document.getCategoryAlias() + ":" + document.getTitle(), document.getAppId(),
-						document.getCategoryId(), document.getId(), "", "DOCUMENT", "发布");
+						document.getCategoryId(), document.getId(), "", "DOCUMENT", "发布" );
 			} catch (Throwable th) {
 				th.printStackTrace();
 				result.error(th);

+ 86 - 5
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/ActionPersistPublishContent.java

@@ -1,12 +1,16 @@
 package com.x.cms.assemble.control.jaxrs.document;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.*;
 
 import javax.servlet.http.HttpServletRequest;
 
+import com.x.base.core.entity.annotation.CheckPersistType;
+import com.x.base.core.project.config.StorageMapping;
+import com.x.base.core.project.exception.ExceptionWhen;
+import com.x.processplatform.core.entity.content.Attachment;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.google.gson.JsonElement;
@@ -228,6 +232,48 @@ public class ActionPersistPublishContent extends BaseAction {
 			}
 		}
 
+		//从流程管理中复制所有的附件到CMS
+		if (check) {
+			if ( wi.getWf_attachmentIds() != null && wi.getWf_attachmentIds().length > 0 ) {
+				FileInfo fileInfo = null;
+				Attachment attachment = null;
+				StorageMapping mapping_attachment = null;
+				StorageMapping mapping_fileInfo = null;
+				InputStream input = null;
+				byte[] attachment_content = null;
+				for (String attachmentId : wi.getWf_attachmentIds()) {
+					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+						document = emc.find(document.getId(), Document.class, ExceptionWhen.not_found);
+						attachment = emc.find(attachmentId, Attachment.class, ExceptionWhen.not_found);
+						if (attachment != null) {
+							emc.beginTransaction(FileInfo.class);
+							emc.beginTransaction(Document.class);
+
+							mapping_attachment = ThisApplication.context().storageMappings().get(Attachment.class, attachment.getStorage());
+							attachment_content = attachment.readContent(mapping_attachment);
+
+							mapping_fileInfo = ThisApplication.context().storageMappings().random(FileInfo.class);
+							fileInfo = concreteFileInfo(effectivePerson.getDistinguishedName(), document, mapping_fileInfo, attachment.getName(), attachment.getSite());
+							input = new ByteArrayInputStream(attachment_content);
+							fileInfo.saveContent(mapping_fileInfo, input, attachment.getName());
+							fileInfo.setName(attachment.getName());
+							emc.check(document, CheckPersistType.all);
+							emc.persist(fileInfo, CheckPersistType.all);
+
+							emc.commit();
+						}
+					} catch (Throwable th) {
+						th.printStackTrace();
+						result.error(th);
+					} finally {
+						if (input != null) {
+							input.close();
+						}
+					}
+				}
+			}
+		}
+
 		if (check) {
 			try {				
 				Wo wo = new Wo();
@@ -240,6 +286,7 @@ public class ActionPersistPublishContent extends BaseAction {
 				throw exception;
 			}
 		}
+
 		if (check) {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				logService.log(emc, wi.getCreatorIdentity(),
@@ -358,11 +405,45 @@ public class ActionPersistPublishContent extends BaseAction {
 				logger.error( e, effectivePerson, request, null);
 			}
 		}
-				
+
+		ApplicationCache.notify(FileInfo.class);
 		ApplicationCache.notify(Document.class);
 		return result;
 	}
 
+	private FileInfo concreteFileInfo(String person, Document document, StorageMapping storage, String name, String site) throws Exception {
+		String fileName = UUID.randomUUID().toString();
+		String extension = FilenameUtils.getExtension(name);
+		FileInfo attachment = new FileInfo();
+		if (StringUtils.isEmpty(extension)) {
+			throw new Exception("file extension is empty.");
+		} else {
+			fileName = fileName + "." + extension;
+		}
+		if (name.indexOf("\\") > 0) {
+			name = StringUtils.substringAfterLast(name, "\\");
+		}
+		if (name.indexOf("/") > 0) {
+			name = StringUtils.substringAfterLast(name, "/");
+		}
+		attachment.setCreateTime(new Date());
+		attachment.setLastUpdateTime(new Date());
+		attachment.setExtension(extension);
+		attachment.setName(name);
+		attachment.setFileName(fileName);
+		attachment.setStorage(storage.getName());
+		attachment.setAppId(document.getAppId());
+		attachment.setCategoryId(document.getCategoryId());
+		attachment.setDocumentId(document.getId());
+		attachment.setCreatorUid(person);
+		attachment.setSite(site);
+		attachment.setFileHost("");
+		attachment.setFilePath("");
+		attachment.setFileType("ATTACHMENT");
+
+		return attachment;
+	}
+
 	public static class Wi {
 		
 		public static WrapCopier<Wi, Document> copier = WrapCopierFactory.wi( Wi.class, Document.class, null, null);

+ 8 - 1
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/BaseAction.java

@@ -3,11 +3,13 @@ package com.x.cms.assemble.control.jaxrs.document;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.UUID;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.annotation.CheckPersistType;
 import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.base.core.project.tools.ListTools;
 import com.x.cms.assemble.control.Business;
@@ -29,7 +31,10 @@ import com.x.cms.core.entity.AppInfo;
 import com.x.cms.core.entity.CategoryInfo;
 import com.x.cms.core.entity.Document;
 
+import com.x.cms.core.entity.FileInfo;
 import net.sf.ehcache.Ehcache;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.StringUtils;
 
 public class BaseAction extends StandardJaxrsAction {
 	protected Ehcache cache = ApplicationCache.instance().getCache( Document.class);
@@ -215,7 +220,9 @@ public class BaseAction extends StandardJaxrsAction {
 		}		
 		return false;
 	}
-	
+
+
+
 //	/**
 //	 * 将权限组,组织为一个整体集合
 //	 * @param personName

+ 3 - 1
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/document/DocumentCipherAction.java

@@ -11,6 +11,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 
 import com.google.gson.JsonElement;
+import com.x.base.core.project.annotation.JaxrsDescribe;
 import com.x.base.core.project.annotation.JaxrsMethodDescribe;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -21,6 +22,7 @@ import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 
 @Path("document/cipher")
+@JaxrsDescribe("信息发布信息文档管理(Cipher)")
 public class DocumentCipherAction extends StandardJaxrsAction{
 	
 	private static  Logger logger = LoggerFactory.getLogger( DocumentCipherAction.class );
@@ -30,7 +32,7 @@ public class DocumentCipherAction extends StandardJaxrsAction{
 	@Path("publish/content")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void publishContent( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement ) {		
+	public void publishContentByWorkFlow( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement ) {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<ActionPersistPublishByWorkFlow.Wo> result = new ActionResult<>();
 		Boolean check = true;

+ 4 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/permission/ActionRefreshDocumentPermission.java

@@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.project.annotation.AuditLog;
 import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.cache.ApplicationCache;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoId;
@@ -82,6 +83,9 @@ public class ActionRefreshDocumentPermission extends BaseAction {
 			}
 
 		}
+
+		ApplicationCache.notify( Document.class );
+
 		return result;
 	}
 

+ 6 - 0
o2web/source/x_component_process_FormDesigner/Module/Log/log.html

@@ -56,6 +56,12 @@
 
 		<table id="text{$.pid}handwritingSize" style=""
 			   width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
+			<tr>
+				<td class="editTableValue"><b>展开手写意见:</b>
+					<input class="editTableRadio" name="handwritingExpanded" text{($.handwritingExpanded)?'checked':''} type="radio" value="true"/>是
+					<input class="editTableRadio" name="handwritingExpanded" text{(!$.handwritingExpanded)?'checked':''} type="radio" value="false"/>否
+				</td>
+			</tr>
 			<tr>
 				<td class="editTableValue"><b>手写意见宽度:</b>
 					<input type="text" name="handwritingWidth" value="text{$.handwritingWidth}" class="editTableInputNoWidth" style="width: 50px;;margin-right:5px;" />px

+ 1 - 1
o2web/source/x_component_process_TaskCenter/ProcessStarter.js

@@ -40,7 +40,7 @@ MWF.xApplication.process.TaskCenter.ProcessStarter = new Class({
                             if (this.identitys.length==1){
                                 var data = {
                                     "title": this.data.name+"-"+this.lp.unnamed,
-                                    "identity": this.identitys[0].name,
+                                    "identity": this.identitys[0].distinguishedName,
                                     "latest": this.options.latest
                                 };
                                 if( this.options.workData ){

+ 10 - 6
o2web/source/x_component_process_Xform/Log.js

@@ -1044,7 +1044,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class({
                         imgNode.setStyles(size);
                     }else{
                         var x = Math.min(nw, width);
-                        img.setStyles({"width": ""+ x +"px"}); //���յĿ��
+                        img.setStyles({"width": ""+ x +"px"});
                         imgNode.setStyles({"width": ""+ x +"px"});
                     }
                 }.bind(this)
@@ -1550,7 +1550,9 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class({
         atts.each(function(att){
             if (!att.type) att.type = "image";
             if (att.type.indexOf("image")!==-1){
-                if( type === "table" && !layout.mobile ){
+                if( this.json.handwritingExpanded ){
+                    this.loadMediaOpinion_image_show(att, null, node, true)
+                }else if( type === "table" && !layout.mobile ){
                     this.loadMediaOpinion_image_tooltip(att, node);
                 }else{
                     this.loadMediaOpinion_image(att, node);
@@ -1559,8 +1561,10 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class({
                 this.loadMediaOpinion_video(att, node);
             }else if(att.type.indexOf("audio")!==-1){
                 this.loadMediaOpinion_voice(att, node);
-            }else{
-                if( type === "table" && !layout.mobile ){
+            }else {
+                if (this.json.handwritingExpanded){
+                    this.loadMediaOpinion_image_show(att, null, node, true)
+                }else if( type === "table" && !layout.mobile ){
                     this.loadMediaOpinion_image_tooltip(att, node);
                 }else{
                     this.loadMediaOpinion_image(att, node);
@@ -1651,7 +1655,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class({
 
                 var img = new Element("img", {
                     "src": url,
-                    "styles" : { width : width+"px" }, //�ʼ�޶�һ�¿�ȣ���Ҫ��ҳ�涶��
+                    "styles" : { width : width+"px" },
                     "events" : {
                         load : function(ev){
                             var nh = ev.target.naturalHeight;
@@ -1662,7 +1666,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class({
                                 imgNode.setStyles(size);
                             }else{
                                 var x = Math.min(nw, width);
-                                img.setStyles({"width": ""+ x +"px"}); //���յĿ��
+                                img.setStyles({"width": ""+ x +"px"});
                                 imgNode.setStyles({"width": ""+ x +"px"});
                             }
                         }.bind(this)