提交 c5e6d021 编写于 作者: O o2null

Merge branch '流程正文签批' into 'develop'

流程正文签批后端接口

See merge request o2oa/o2oa!406
......@@ -1050,7 +1050,7 @@
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.10.0</version>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
......@@ -1093,4 +1093,4 @@
<url>http://maven.o2oa.net/repository/o2oa-release/</url>
</repository>
</distributionManagement>
</project>
\ No newline at end of file
</project>
......@@ -13,7 +13,8 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.processplatform.core.entity.content.Task", "com.x.processplatform.core.entity.content.TaskCompleted",
"com.x.processplatform.core.entity.content.Work", "com.x.processplatform.core.entity.content.WorkCompleted",
"com.x.processplatform.core.entity.content.WorkLog", "com.x.processplatform.core.entity.content.Record",
"com.x.processplatform.core.entity.content.KeyLock",
"com.x.processplatform.core.entity.content.KeyLock", "com.x.processplatform.core.entity.content.DocSign",
"com.x.processplatform.core.entity.content.DocSignScrawl",
"com.x.processplatform.core.entity.content.DocumentVersion", "com.x.processplatform.core.entity.element.Agent",
"com.x.processplatform.core.entity.element.Application",
"com.x.processplatform.core.entity.element.ApplicationDict",
......@@ -30,7 +31,7 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.processplatform.core.entity.element.QueryView", "com.x.processplatform.core.entity.element.QueryStat",
"com.x.processplatform.core.entity.element.Mapping", "com.x.query.core.entity.Item",
"com.x.cms.core.entity.element.Script", "com.x.portal.core.entity.Script",
"com.x.general.core.entity.GeneralFile" }, storageTypes = { StorageType.processPlatform,
"com.x.general.core.entity.GeneralFile"}, storageTypes = { StorageType.processPlatform,
StorageType.general }, storeJars = { "x_organization_core_entity", "x_organization_core_express",
"x_processplatform_core_entity", "x_processplatform_core_express", "x_query_core_entity",
"x_cms_core_entity", "x_portal_core_entity", "x_general_core_entity" })
......
......@@ -15,6 +15,7 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.processplatform.core.entity.content.Task", "com.x.processplatform.core.entity.content.Work",
"com.x.processplatform.core.entity.content.Read", "com.x.processplatform.core.entity.content.DocumentVersion",
"com.x.processplatform.core.entity.content.SerialNumber", "com.x.processplatform.core.entity.element.End",
"com.x.processplatform.core.entity.content.DocSign", "com.x.processplatform.core.entity.content.DocSignScrawl",
"com.x.processplatform.core.entity.element.Application",
"com.x.processplatform.core.entity.element.ApplicationDict",
"com.x.processplatform.core.entity.element.ApplicationDictItem",
......
......@@ -27,6 +27,7 @@ import com.x.processplatform.assemble.surface.jaxrs.route.RouteAction;
import com.x.processplatform.assemble.surface.jaxrs.script.ScriptAction;
import com.x.processplatform.assemble.surface.jaxrs.serialnumber.SerialNumberAction;
import com.x.processplatform.assemble.surface.jaxrs.service.ServiceAction;
import com.x.processplatform.assemble.surface.jaxrs.sign.SignAction;
import com.x.processplatform.assemble.surface.jaxrs.snap.SnapAction;
import com.x.processplatform.assemble.surface.jaxrs.task.TaskAction;
import com.x.processplatform.assemble.surface.jaxrs.taskcompleted.TaskCompletedAction;
......@@ -67,6 +68,7 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(DraftAction.class);
classes.add(SnapAction.class);
classes.add(AnonymousAction.class);
classes.add(SignAction.class);
return classes;
}
}
package com.x.processplatform.assemble.surface.jaxrs;
import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
import javax.servlet.annotation.WebFilter;
@WebFilter(urlPatterns = "/jaxrs/sign/*", asyncSupported = true)
public class SignJaxrsFilter extends CipherManagerUserJaxrsFilter {
}
......@@ -240,14 +240,12 @@ class ActionHtmlToImage extends BaseAction {
try (Browser browser = browserType.launch(options)) {
BrowserContext context = browser.newContext();
Page page = context.newPage();
page.navigate("file:///Users/chengjian/dev/tmp/html2Image.html");
//page.setContent("<html><body>测试一下</body></html>");
//Thread.sleep(1000);
page.navigate("file:///Users/chengjian/dev/temp/test.html");
Page.ScreenshotOptions screenshotOptions = new Page.ScreenshotOptions();
screenshotOptions.setFullPage(true);
screenshotOptions.setQuality(80);
screenshotOptions.setClip(0,0, 800, 2310);
//screenshotOptions.setQuality(2);
screenshotOptions.setPath(Paths.get("/Users/chengjian/dev/tmp/screenshot-" + browserType.name() + ".jpg"));
screenshotOptions.setPath(Paths.get("/Users/chengjian/dev/temp/screenshot-" + browserType.name() + ".png"));
page.screenshot(screenshotOptions);
break;
} catch (Exception e) {
......
package com.x.processplatform.assemble.surface.jaxrs.sign;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.annotation.ActionLogger;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.assemble.surface.ThisApplication;
import com.x.processplatform.core.entity.content.DocSign;
import com.x.processplatform.core.entity.content.DocSignScrawl;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
class ActionDelete extends BaseAction {
@ActionLogger
private static Logger logger = LoggerFactory.getLogger(ActionDelete.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
logger.debug(effectivePerson.getDistinguishedName());
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
DocSign docSign = emc.find(id, DocSign.class);
if (null == docSign) {
throw new ExceptionEntityNotExist(id, DocSign.class);
}
if(!business.canManageApplication(effectivePerson, null) &&
!docSign.getPerson().equals(effectivePerson.getDistinguishedName())){
throw new ExceptionAccessDenied(effectivePerson, id);
}
List<DocSignScrawl> signScrawlList = emc.listEqual(DocSignScrawl.class, DocSignScrawl.signId_FIELDNAME, docSign.getId());
if(ListTools.isNotEmpty(signScrawlList)) {
emc.beginTransaction(DocSignScrawl.class);
for (DocSignScrawl signScrawl : signScrawlList) {
if(StringUtils.isNotBlank(signScrawl.getStorage())) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class, signScrawl.getStorage());
signScrawl.deleteContent(mapping);
}
emc.remove(signScrawl);
}
}
emc.beginTransaction(DocSign.class);
emc.remove(docSign);
emc.commit();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
package com.x.processplatform.assemble.surface.jaxrs.sign;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.annotation.ActionLogger;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.assemble.surface.ThisApplication;
import com.x.processplatform.core.entity.content.DocSign;
import com.x.processplatform.core.entity.content.DocSignScrawl;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
class ActionDeleteByTask extends BaseAction {
@ActionLogger
private static Logger logger = LoggerFactory.getLogger(ActionDeleteByTask.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String taskId) throws Exception {
logger.debug(effectivePerson.getDistinguishedName());
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
Business business = new Business(emc);
wo.setValue(true);
DocSign docSign = emc.firstEqual(DocSign.class, DocSign.taskId_FIELDNAME, taskId);
if (null != docSign) {
if(!business.canManageApplication(effectivePerson, null) &&
!docSign.getPerson().equals(effectivePerson.getDistinguishedName())){
throw new ExceptionAccessDenied(effectivePerson, taskId);
}
List<DocSignScrawl> signScrawlList = emc.listEqual(DocSignScrawl.class, DocSignScrawl.signId_FIELDNAME, docSign.getId());
if(ListTools.isNotEmpty(signScrawlList)) {
emc.beginTransaction(DocSignScrawl.class);
for (DocSignScrawl signScrawl : signScrawlList) {
if(StringUtils.isNotBlank(signScrawl.getStorage())) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class, signScrawl.getStorage());
signScrawl.deleteContent(mapping);
}
emc.remove(signScrawl);
}
}
emc.beginTransaction(DocSign.class);
emc.remove(docSign);
emc.commit();
}
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
package com.x.processplatform.assemble.surface.jaxrs.sign;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoFile;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.assemble.surface.ThisApplication;
import com.x.processplatform.core.entity.content.DocSignScrawl;
import org.apache.commons.lang3.StringUtils;
class ActionDownload extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String scrawlId)
throws Exception {
ActionResult<Wo> result = new ActionResult<>();
DocSignScrawl signScrawl = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
signScrawl = emc.find(scrawlId, DocSignScrawl.class);
if (null == signScrawl) {
throw new ExceptionEntityNotExist(scrawlId, DocSignScrawl.class);
}
if(StringUtils.isBlank(signScrawl.getStorage())){
throw new IllegalStateException(scrawlId+"附件不存在!");
}
if(!business.readableWithJob(effectivePerson, signScrawl.getJob())){
throw new ExceptionAccessDenied(effectivePerson, scrawlId);
}
}
String fileName = signScrawl.getName();
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class,
signScrawl.getStorage());
byte[] bytes = signScrawl.readContent(mapping);
Wo wo = new Wo(bytes, this.contentType(false, fileName), this.contentDisposition(false, fileName));
result.setData(wo);
return result;
}
public static class Wo extends WoFile {
public Wo(byte[] bytes, String contentType, String contentDisposition) {
super(bytes, contentType, contentDisposition);
}
}
}
package com.x.processplatform.assemble.surface.jaxrs.sign;
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.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
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.DocSign;
class ActionGet extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionGet.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
logger.debug(effectivePerson.getDistinguishedName());
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
DocSign docSign = emc.find(id, DocSign.class);
if (null == docSign) {
throw new ExceptionEntityNotExist(id, DocSign.class);
}
if(!business.readableWithJob(effectivePerson, docSign.getJob())){
throw new ExceptionAccessDenied(effectivePerson, id);
}
Wo wo = Wo.copier.copy(docSign);
result.setData(wo);
return result;
}
}
public static class Wo extends DocSign {
static WrapCopier<DocSign, Wo> copier = WrapCopierFactory.wo(DocSign.class, Wo.class,
null, JpaObject.FieldsInvisible);
}
}
package com.x.processplatform.assemble.surface.jaxrs.sign;
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.ActionLogger;
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.exception.ExceptionEntityNotExist;
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 com.x.processplatform.core.entity.content.DocSign;
class ActionGetByTask extends BaseAction {
@ActionLogger
private static Logger logger = LoggerFactory.getLogger(ActionGetByTask.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String taskId) throws Exception {
logger.debug(effectivePerson.getDistinguishedName());
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
DocSign docSign = emc.firstEqual(DocSign.class, DocSign.taskId_FIELDNAME, taskId);
if (null == docSign) {
throw new ExceptionEntityNotExist(taskId, DocSign.class);
}
if(!business.readableWithJob(effectivePerson, docSign.getJob())){
throw new ExceptionAccessDenied(effectivePerson, taskId);
}
Wo wo = Wo.copier.copy(docSign);
result.setData(wo);
return result;
}
}
public static class Wo extends DocSign {
static WrapCopier<DocSign, Wo> copier = WrapCopierFactory.wo(DocSign.class, Wo.class,
null, JpaObject.FieldsInvisible);
}
}
package com.x.processplatform.assemble.surface.jaxrs.sign;
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.config.Config;
import com.x.base.core.project.exception.ExceptionAccessDenied;
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.base.core.project.tools.SortTools;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.core.entity.content.DocSign;
import com.x.processplatform.core.entity.content.DocSignStatus;
import org.apache.commons.lang3.BooleanUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
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(job);
CompletableFuture<Boolean> checkControlFuture = checkJobControlFuture(effectivePerson, job);
result.setData(listFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS));
if (BooleanUtils
.isFalse(checkControlFuture.get(Config.processPlatform().getAsynchronousTimeout(), TimeUnit.SECONDS))) {
throw new ExceptionAccessDenied(effectivePerson, job);
}
return result;
}
private CompletableFuture<List<Wo>> listFuture(String flag) {
return CompletableFuture.supplyAsync(() -> {
List<Wo> wos = new ArrayList<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
final String job = flag;
List<DocSign> docSignList = emc.listEqualAndNotEqual(DocSign.class, DocSign.job_FIELDNAME, job,
DocSign.status_FIELDNAME, DocSignStatus.STATUS_1.getValue());
for (DocSign docSign : docSignList) {
Wo wo = Wo.copier.copy(docSign);
wo.setInputList(wo.getProperties().getInputList());
wo.setScrawlList(wo.getProperties().getScrawlList());
wo.setProperties(null);
wos.add(wo);
}
SortTools.asc(wos, DocSign.createTime_FIELDNAME);
} catch (Exception e) {
logger.error(e);
}
return wos;
});
}
private CompletableFuture<Boolean> checkJobControlFuture(EffectivePerson effectivePerson, String job) {
return CompletableFuture.supplyAsync(() -> {
Boolean value = false;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
value = business.readableWithJob(effectivePerson, job);
} catch (Exception e) {
logger.error(e);
}
return value;
});
}
public static class Wo extends DocSign {
static WrapCopier<DocSign, Wo> copier = WrapCopierFactory.wo(DocSign.class, Wo.class, null,
JpaObject.FieldsInvisible);
@FieldDescribe("输入框列表.")
private List<String> inputList = new ArrayList<>();
@FieldDescribe("涂鸦列表.")
private List<String> scrawlList = new ArrayList<>();
public List<String> getInputList() {
return inputList;
}
public void setInputList(List<String> inputList) {
this.inputList = inputList;
}
public List<String> getScrawlList() {
return scrawlList;
}
public void setScrawlList(List<String> scrawlList) {
this.scrawlList = scrawlList;
}
}
}
package com.x.processplatform.assemble.surface.jaxrs.sign;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.microsoft.playwright.*;
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.annotation.FieldDescribe;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.exception.ExceptionFieldEmpty;
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.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.FileTools;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.surface.ThisApplication;
import com.x.processplatform.core.entity.content.DocSign;
import com.x.processplatform.core.entity.content.DocSignScrawl;
import com.x.processplatform.core.entity.content.DocSignStatus;
import com.x.processplatform.core.entity.content.Task;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
class ActionSave extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionSave.class);
private static final String SCRAWL_SRC = "src";
ActionResult<Wo> execute(EffectivePerson effectivePerson, String taskId, JsonElement jsonElement) throws Exception {
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
if (wi.getStatus() == null) {
throw new ExceptionFieldEmpty(DocSign.status_FIELDNAME);
}
if (wi.getStatus().equals(DocSignStatus.STATUS_3.getValue()) && StringUtils.isBlank(wi.getHtmlContent())) {
throw new ExceptionFieldEmpty("htmlContent");
}
Task task = null;
Wo wo = new Wo();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
task = emc.fetch(taskId, Task.class);
if (task == null) {
throw new ExceptionEntityNotExist(taskId, Task.class);
}
if (!task.getPerson().equals(effectivePerson.getDistinguishedName())) {
throw new ExceptionAccessDenied(effectivePerson);
}
}
wo.setId(this.saveDocSign(wi, task));
ActionResult<Wo> result = new ActionResult<>();
result.setData(wo);
return result;
}
private String saveDocSign(Wi wi, Task task) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
boolean flag = true;
emc.beginTransaction(DocSign.class);
DocSign docSign = emc.firstEqual(DocSign.class, DocSign.taskId_FIELDNAME, task.getId());
if (docSign == null) {
flag = false;
docSign = new DocSign(task);
}
docSign.setStatus(wi.getStatus());
docSign.getProperties().setInputList(wi.getInputList());
docSign.getProperties().setScrawlList(wi.getScrawlList());
emc.beginTransaction(DocSignScrawl.class);
if (flag) {
List<DocSignScrawl> signScrawlList = emc.listEqual(DocSignScrawl.class, DocSignScrawl.signId_FIELDNAME, docSign.getId());
for (DocSignScrawl signScrawl : signScrawlList) {
if (StringUtils.isNotBlank(signScrawl.getStorage())) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class, signScrawl.getStorage());
signScrawl.deleteContent(mapping);
}
emc.remove(signScrawl);
}
}
if (wi.getStatus().equals(DocSignStatus.STATUS_2.getValue())) {
List<String> list = new ArrayList<>();
docSign.setCommitTime(new Date());
if (ListTools.isNotEmpty(wi.getScrawlList())) {
for (String data : wi.getScrawlList()) {
DocSignScrawl signScrawl = this.base642Img(docSign, data);
list.add(gson.toJson(signScrawl));
emc.persist(signScrawl, CheckPersistType.all);
}
}
docSign.getProperties().setScrawlList(list);
} else if (wi.getStatus().equals(DocSignStatus.STATUS_3.getValue())) {
docSign.setCommitTime(new Date());
DocSignScrawl signScrawl = this.html2Img(docSign, wi, emc);
emc.persist(signScrawl, CheckPersistType.all);
docSign.setSignScrawlId(signScrawl.getId());
}
if (!flag) {
emc.persist(docSign, CheckPersistType.all);
}
emc.commit();
return docSign.getId();
}
}
private DocSignScrawl base642Img(DocSign docSign, String data) throws Exception {
JsonObject jsonObject = gson.fromJson(data, JsonObject.class);
DocSignScrawl signScrawl = new DocSignScrawl(docSign, null);
if (jsonObject.has(SCRAWL_SRC)) {
String base64String = jsonObject.get(SCRAWL_SRC).getAsString();
if (StringUtils.isNotBlank(base64String)) {
byte[] bytes = Base64.decodeBase64(base64String);
String name = StringUtils.split(docSign.getPerson(), "@")[0] + signScrawl.getId() + ".png";
signScrawl.setType(DocSignScrawl.SCRAWL_TYPE_BASE64);
signScrawl.setName(name);
StorageMapping mapping = ThisApplication.context().storageMappings().random(DocSignScrawl.class);
signScrawl.saveContent(mapping, bytes, name);
}
}
if (jsonObject.has(DocSignScrawl.width_FIELDNAME)) {
signScrawl.setWidth(jsonObject.get(DocSignScrawl.width_FIELDNAME).getAsString());
}
if (jsonObject.has(DocSignScrawl.height_FIELDNAME)) {
signScrawl.setHeight(jsonObject.get(DocSignScrawl.height_FIELDNAME).getAsString());
}
return signScrawl;
}
private DocSignScrawl html2Img(DocSign docSign, Wi wi, EntityManagerContainer emc) throws Exception {
String html = wi.getHtmlContent();
if (html.toLowerCase().indexOf("<html") == -1) {
html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>" + html + "</body></html>";
}
String name = StringUtils.split(docSign.getPerson(), "@")[0] + docSign.getTaskId() + ".png";
byte[] bytes = null;
try (Playwright playwright = Playwright.create()) {
List<BrowserType> browserTypes = Arrays.asList(
playwright.chromium(),
playwright.firefox(),
playwright.webkit()
);
for (BrowserType browserType : browserTypes) {
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
options.setHeadless(true);
try (Browser browser = browserType.launch(options)) {
BrowserContext context = browser.newContext();
Page page = context.newPage();
page.setContent(html);
Page.ScreenshotOptions screenshotOptions = new Page.ScreenshotOptions();
screenshotOptions.setFullPage(true);
if (wi.getHtmlWidth() != null && wi.getHtmlHeight() != null) {
screenshotOptions.setClip(0, 0, wi.getHtmlWidth(), wi.getHtmlHeight());
}
File tempDir = Config.dir_local_temp();
FileTools.forceMkdir(tempDir);
File file = new File(tempDir, name);
screenshotOptions.setPath(file.toPath());
page.screenshot(screenshotOptions);
bytes = FileUtils.readFileToByteArray(file);
break;
} catch (Exception e) {
logger.warn("Playwright user browser:{} error:{}", browserType.name(), e.getMessage());
}
}
}
if (bytes == null) {
throw new IllegalStateException("签批转图片异常!");
}
DocSignScrawl signScrawl = new DocSignScrawl(docSign, name);
signScrawl.setType(DocSignScrawl.SCRAWL_TYPE_IMAGE);
StorageMapping mapping = ThisApplication.context().storageMappings().random(DocSignScrawl.class);
signScrawl.saveContent(mapping, bytes, name);
return signScrawl;
}
public static class Wi extends GsonPropertyObject {
@FieldDescribe("状态:1(暂存)|2(签批正文不可以修改)|3(签批正文可以修改,正文保存为图片).")
private Integer status;
@FieldDescribe("包含签批的html正文后内容,状态为3时必传.")
private String htmlContent;
@FieldDescribe("html正文宽度,允许为空.")
private Double htmlWidth;
@FieldDescribe("html正文高度,允许为空.")
private Double htmlHeight;
@FieldDescribe("输入框列表.")
private List<String> inputList = new ArrayList<>();
@FieldDescribe("涂鸦列表,示例[\"{'src':'base64图片','width':'100','height':'100'}\"].")
private List<String> scrawlList = new ArrayList<>();
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getHtmlContent() {
return htmlContent;
}
public void setHtmlContent(String htmlContent) {
this.htmlContent = htmlContent;
}
public Double getHtmlWidth() {
return htmlWidth;
}
public void setHtmlWidth(Double htmlWidth) {
this.htmlWidth = htmlWidth;
}
public Double getHtmlHeight() {
return htmlHeight;
}
public void setHtmlHeight(Double htmlHeight) {
this.htmlHeight = htmlHeight;
}
public List<String> getInputList() {
return inputList;
}
public void setInputList(List<String> inputList) {
this.inputList = inputList;
}
public List<String> getScrawlList() {
return scrawlList;
}
public void setScrawlList(List<String> scrawlList) {
this.scrawlList = scrawlList;
}
}
public static class Wo extends WoId {
}
}
package com.x.processplatform.assemble.surface.jaxrs.sign;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.StringTools;
import com.x.processplatform.assemble.surface.Business;
import com.x.processplatform.core.entity.content.Snap;
import com.x.processplatform.core.entity.content.Snap_;
import com.x.processplatform.core.entity.element.Application;
import com.x.processplatform.core.entity.element.Process;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.List;
abstract class BaseAction extends StandardJaxrsAction {
protected Predicate manageFilter(Business business, FilterWi wi) throws Exception {
EntityManager em = business.entityManagerContainer().get(Snap.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Snap> cq = cb.createQuery(Snap.class);
Root<Snap> root = cq.from(Snap.class);
Predicate p = cb.conjunction();
if (ListTools.isNotEmpty(wi.getApplicationList())) {
p = cb.and(p, root.get(Snap_.application).in(wi.getApplicationList()));
}
if (ListTools.isNotEmpty(wi.getProcessList())) {
p = cb.and(p, root.get(Snap_.process).in(business.process().listEditionProcess(wi.getProcessList())));
}
if (ListTools.isNotEmpty(wi.getPersonList())) {
p = cb.and(p, root.get(Snap_.person).in(business.organization().person().list(wi.getPersonList())));
}
if (StringUtils.isNoneBlank(wi.getKey())) {
String key = StringTools.escapeSqlLikeKey(wi.getKey());
p = cb.and(p,
cb.or(cb.like(root.get(Snap_.title), "%" + key + "%", StringTools.SQL_ESCAPE_CHAR),
cb.like(root.get(Snap_.creatorPerson), "%" + key + "%", StringTools.SQL_ESCAPE_CHAR),
cb.like(root.get(Snap_.creatorUnit), "%" + key + "%", StringTools.SQL_ESCAPE_CHAR)));
}
return p;
}
protected Predicate filter(EffectivePerson effectivePerson, Business business, FilterWi wi) throws Exception {
EntityManager em = business.entityManagerContainer().get(Snap.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Snap> cq = cb.createQuery(Snap.class);
Root<Snap> root = cq.from(Snap.class);
Predicate p = cb.equal(root.get(Snap_.person), effectivePerson.getDistinguishedName());
if (ListTools.isNotEmpty(wi.getApplicationList())) {
p = cb.and(p, root.get(Snap_.application).in(wi.getApplicationList()));
}
if (ListTools.isNotEmpty(wi.getProcessList())) {
p = cb.and(p, root.get(Snap_.process).in(business.process().listEditionProcess(wi.getProcessList())));
}
if (StringUtils.isNoneBlank(wi.getKey())) {
String key = StringTools.escapeSqlLikeKey(wi.getKey());
p = cb.and(p,
cb.or(cb.like(root.get(Snap_.title), "%" + key + "%", StringTools.SQL_ESCAPE_CHAR),
cb.like(root.get(Snap_.creatorPerson), "%" + key + "%", StringTools.SQL_ESCAPE_CHAR),
cb.like(root.get(Snap_.creatorUnit), "%" + key + "%", StringTools.SQL_ESCAPE_CHAR)));
}
return p;
}
protected Predicate myFilter(EffectivePerson effectivePerson, Business business) throws Exception {
EntityManager em = business.entityManagerContainer().get(Snap.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Snap> cq = cb.createQuery(Snap.class);
Root<Snap> root = cq.from(Snap.class);
return cb.equal(root.get(Snap_.person), effectivePerson.getDistinguishedName());
}
protected Predicate myApplicationFilter(EffectivePerson effectivePerson, Business business, Application application)
throws Exception {
EntityManager em = business.entityManagerContainer().get(Snap.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Snap> cq = cb.createQuery(Snap.class);
Root<Snap> root = cq.from(Snap.class);
Predicate p = cb.equal(root.get(Snap_.person), effectivePerson.getDistinguishedName());
p = cb.and(p, cb.equal(root.get(Snap_.application), application.getId()));
return p;
}
protected Predicate myProcessFilter(EffectivePerson effectivePerson, Business business, Process process)
throws Exception {
EntityManager em = business.entityManagerContainer().get(Snap.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Snap> cq = cb.createQuery(Snap.class);
Root<Snap> root = cq.from(Snap.class);
Predicate p = cb.equal(root.get(Snap_.person), effectivePerson.getDistinguishedName());
p = cb.and(p, cb.equal(root.get(Snap_.process), process.getId()));
return p;
}
protected class FilterWi {
@FieldDescribe("应用id")
private List<String> applicationList;
@FieldDescribe("流程")
private List<String> processList;
@FieldDescribe("创建人")
private List<String> personList;
@FieldDescribe("匹配关键字")
private String key;
public List<String> getApplicationList() {
return applicationList;
}
public void setApplicationList(List<String> applicationList) {
this.applicationList = applicationList;
}
public List<String> getProcessList() {
return processList;
}
public void setProcessList(List<String> processList) {
this.processList = processList;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public List<String> getPersonList() {
return personList;
}
public void setPersonList(List<String> personList) {
this.personList = personList;
}
}
}
package com.x.processplatform.assemble.surface.jaxrs.sign;
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.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.List;
/**
* @author sword
*/
@Path("sign")
@JaxrsDescribe("文档签批")
public class SignAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(SignAction.class);
@JaxrsMethodDescribe(value = "获取签批信息.", action = ActionGet.class)
@GET
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionGet.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGet().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据task获取签批信息.", action = ActionGetByTask.class)
@GET
@Path("task/{taskId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void getByTask(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("任务ID") @PathParam("taskId") String taskId) {
ActionResult<ActionGetByTask.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionGetByTask().execute(effectivePerson, taskId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据工作的job获取签批列表.", 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 = "删除签批", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除签批", action = ActionDelete.class)
@GET
@Path("{id}/mockdeletetoget")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void deleteMockGet2Delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据task删除签批", action = ActionDeleteByTask.class)
@DELETE
@Path("task/{taskId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void deleteByTask(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("待办标识") @PathParam("taskId") String taskId) {
ActionResult<ActionDeleteByTask.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDeleteByTask().execute(effectivePerson, taskId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "根据task删除签批mockdeletetoget", action = ActionDeleteByTask.class)
@GET
@Path("task/{taskId}/mockdeletetoget")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void deleteByTaskMockGet2Delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("待办标识") @PathParam("taskId") String taskId) {
ActionResult<ActionDeleteByTask.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDeleteByTask().execute(effectivePerson, taskId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "保存签批.", action = ActionSave.class)
@POST
@Path("save/task/{taskId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void save(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("待办ID") @PathParam("taskId") String taskId, JsonElement jsonElement) {
ActionResult<ActionSave.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionSave().execute(effectivePerson, taskId, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "下载签批涂鸦附件", action = ActionDownload.class)
@GET
@Path("download/{scrawlId}")
@Consumes(MediaType.APPLICATION_JSON)
public void download(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("签批涂鸦附件标志") @PathParam("scrawlId") String scrawlId) {
ActionResult<ActionDownload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDownload().execute(effectivePerson, scrawlId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
......@@ -17,6 +17,14 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
public static final String table = "PP_C_DRAFT";
}
public static class DocSign {
public static final String table = "PP_C_DOC_SIGN";
}
public static class DocSignScrawl {
public static final String table = "PP_C_DOC_SIGN_SCRAWL";
}
public static class TaskCompleted {
public static final String table = "PP_C_TASKCOMPLETED";
}
......@@ -237,4 +245,4 @@ public final class PersistenceProperties extends AbstractPersistenceProperties {
public static final String table = "PP_T_SERVICEVALUE";
}
}
}
\ No newline at end of file
}
......@@ -51,10 +51,12 @@ public class Attachment extends StorageObject {
private static final long serialVersionUID = -6564254194819206271L;
private static final String TABLE = PersistenceProperties.Content.Attachment.table;
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
......@@ -66,6 +68,7 @@ public class Attachment extends StorageObject {
/* 以上为 JpaObject 默认字段 */
@Override
public void onPersist() throws Exception {
this.extension = StringUtils.trimToEmpty(this.extension);
this.site = StringUtils.trimToEmpty(this.site);
......
package com.x.processplatform.core.entity.content;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.entity.annotation.ContainerEntity;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.tools.StringTools;
import com.x.processplatform.core.entity.PersistenceProperties;
import org.apache.commons.lang3.StringUtils;
import org.apache.openjpa.persistence.Persistent;
import org.apache.openjpa.persistence.jdbc.Index;
import org.apache.openjpa.persistence.jdbc.Strategy;
import javax.persistence.*;
import java.util.Date;
/**
* 签批信息
* @author sword
*/
@Entity
@ContainerEntity(dumpSize = 5, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
@Table(name = PersistenceProperties.Content.DocSign.table, uniqueConstraints = {
@UniqueConstraint(name = PersistenceProperties.Content.DocSign.table + JpaObject.IndexNameMiddle
+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class DocSign extends SliceJpaObject {
private static final long serialVersionUID = -6321354875403866277L;
private static final String TABLE = PersistenceProperties.Content.DocSign.table;
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
@FieldDescribe("数据库主键,自动生成.")
@Id
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
@Override
public void onPersist() throws Exception {
if (StringTools.utf8Length(this.getProperties().getTitle()) > length_255B) {
this.title = StringTools.utf8SubString(this.getProperties().getTitle(), length_255B - 3) + "...";
}
}
@PostLoad
public void postLoad() {
if ((null != this.properties) && StringUtils.isNotEmpty(this.getProperties().getTitle())) {
this.title = this.getProperties().getTitle();
}
}
public void setTitle(String title) {
this.title = title;
this.getProperties().setTitle(title);
}
public String getTitle() {
if ((null != this.properties) && StringUtils.isNotEmpty(this.properties.getTitle())) {
return this.properties.getTitle();
} else {
return this.title;
}
}
public DocSign() {
}
public DocSign(Task task) {
this.setTitle(task.getTitle());
this.application = task.getApplication();
this.process = task.getProcess();
this.job = task.getJob();
this.activity = task.getActivity();
this.activityName = task.getActivityName();
this.person = task.getPerson();
this.taskId = task.getId();
}
public DocSignProperties getProperties() {
if (null == this.properties) {
this.properties = new DocSignProperties();
}
return this.properties;
}
public void setProperties(DocSignProperties properties) {
this.properties = properties;
}
public static final String title_FIELDNAME = "title";
@FieldDescribe("标题.")
@Column(length = length_255B, name = ColumnNamePrefix + title_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String title;
public static final String application_FIELDNAME = "application";
@FieldDescribe("应用.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + application_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + application_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String application;
public static final String process_FIELDNAME = "process";
@FieldDescribe("流程ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + process_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + process_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String process;
public static final String job_FIELDNAME = "job";
@FieldDescribe("工单ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + job_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + job_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String job;
public static final String taskId_FIELDNAME = "taskId";
@FieldDescribe("待办ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + taskId_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + taskId_FIELDNAME, unique = true)
@CheckPersist(allowEmpty = false)
private String taskId;
public static final String activity_FIELDNAME = "activity";
@FieldDescribe("活动ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + activity_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String activity;
public static final String activityName_FIELDNAME = "activityName";
@FieldDescribe("活动名称.")
@Column(length = length_255B, name = ColumnNamePrefix + activityName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String activityName;
public static final String person_FIELDNAME = "person";
@FieldDescribe("当前处理人")
@Column(length = length_255B, name = ColumnNamePrefix + person_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + person_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String person;
public static final String signScrawlId_FIELDNAME = "signScrawlId";
@FieldDescribe("正文签批转存为图片的ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + signScrawlId_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String signScrawlId;
public static final String status_FIELDNAME = "status";
@FieldDescribe("状态:1(暂存)|2(签批正文不可以修改)|3(签批正文可以修改).")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + status_FIELDNAME)
@CheckPersist(allowEmpty = false)
private Integer status;
public static final String commitTime_FIELDNAME = "commitTime";
@Temporal(TemporalType.TIME)
@FieldDescribe("提交时间.")
@Column(name = ColumnNamePrefix + commitTime_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + commitTime_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Date commitTime;
public static final String properties_FIELDNAME = "properties";
@FieldDescribe("属性对象存储字段.")
@Persistent
@Strategy(JsonPropertiesValueHandler)
@Column(length = JpaObject.length_20M, name = ColumnNamePrefix + properties_FIELDNAME)
@CheckPersist(allowEmpty = true)
private DocSignProperties properties;
public String getProcess() {
return process;
}
public void setProcess(String process) {
this.process = process;
}
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application;
}
public String getPerson() {
return person;
}
public void setPerson(String person) {
this.person = person;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public String getActivity() {
return activity;
}
public void setActivity(String activity) {
this.activity = activity;
}
public String getActivityName() {
return activityName;
}
public void setActivityName(String activityName) {
this.activityName = activityName;
}
public Date getCommitTime() {
return commitTime;
}
public void setCommitTime(Date commitTime) {
this.commitTime = commitTime;
}
public String getSignScrawlId() {
return signScrawlId;
}
public void setSignScrawlId(String signScrawlId) {
this.signScrawlId = signScrawlId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
}
package com.x.processplatform.core.entity.content;
import com.x.base.core.entity.JsonProperties;
import com.x.base.core.project.annotation.FieldDescribe;
import java.util.ArrayList;
import java.util.List;
/**
* 文件签批扩展信息
* @author sword
*/
public class DocSignProperties extends JsonProperties {
private Data data = new Data();
private String title;
@FieldDescribe("输入框列表.")
private List<String> inputList = new ArrayList<>();
@FieldDescribe("涂鸦列表.")
private List<String> scrawlList = new ArrayList<>();
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<String> getInputList() {
return inputList;
}
public void setInputList(List<String> inputList) {
this.inputList = inputList;
}
public List<String> getScrawlList() {
return scrawlList;
}
public void setScrawlList(List<String> scrawlList) {
this.scrawlList = scrawlList;
}
}
package com.x.processplatform.core.entity.content;
import com.x.base.core.entity.*;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.entity.annotation.ContainerEntity;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.tools.DateTools;
import com.x.processplatform.core.entity.PersistenceProperties;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.openjpa.persistence.jdbc.Index;
import javax.persistence.*;
import java.util.Date;
import static com.x.base.core.entity.StorageType.processPlatform;
/**
* 签批涂鸦信息
* @author sword
*/
@Entity
@ContainerEntity(dumpSize = 5, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
@Table(name = PersistenceProperties.Content.DocSignScrawl.table, uniqueConstraints = {
@UniqueConstraint(name = PersistenceProperties.Content.DocSignScrawl.table + JpaObject.IndexNameMiddle
+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Storage(type = processPlatform)
public class DocSignScrawl extends StorageObject {
private static final long serialVersionUID = 3335030367719974674L;
private static final String TABLE = PersistenceProperties.Content.DocSignScrawl.table;
public static String SCRAWL_TYPE_PLACEHOLDER = "placeholder";
public static String SCRAWL_TYPE_BASE64 = "base64";
public static String SCRAWL_TYPE_IMAGE = "image";
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
this.id = id;
}
@FieldDescribe("数据库主键,自动生成.")
@Id
@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
private String id = createId();
@Override
public void onPersist() throws Exception {
if(StringUtils.isNotBlank(this.name)){
this.extension = StringUtils.lowerCase(FilenameUtils.getExtension(name));
}
}
public DocSignScrawl() {
// nothing
}
public DocSignScrawl(DocSign docSign, String name) {
this.signId = docSign.getId();
this.job = docSign.getJob();
this.activity = docSign.getActivity();
this.activityName = docSign.getActivityName();
this.person = docSign.getPerson();
this.type = SCRAWL_TYPE_PLACEHOLDER;
this.name = name;
this.setCreateTime(new Date());
}
@Override
public String path() {
String str = DateTools.format(this.getCreateTime(), DateTools.formatCompact_yyyyMMdd);
str += PATHSEPARATOR;
str += this.job;
str += PATHSEPARATOR;
str += this.id;
str += StringUtils.isEmpty(this.extension) ? "" : ("." + this.extension);
return str;
}
public static final String name_FIELDNAME = "name";
@FieldDescribe("文件名称,带扩展名的文件名.")
@Column(length = AbstractPersistenceProperties.processPlatform_name_length, name = ColumnNamePrefix
+ name_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + name_FIELDNAME)
@CheckPersist(allowEmpty = true, fileNameString = true)
private String name;
public static final String extension_FIELDNAME = "extension";
@FieldDescribe("扩展名。")
@Column(length = JpaObject.length_16B, name = ColumnNamePrefix + extension_FIELDNAME)
@CheckPersist(allowEmpty = true, fileNameString = true)
private String extension;
public static final String storage_FIELDNAME = "storage";
@FieldDescribe("关联的存储名称.")
@Column(length = JpaObject.length_64B, name = ColumnNamePrefix + storage_FIELDNAME)
@CheckPersist(allowEmpty = true, simplyString = true)
@Index(name = TABLE + IndexNameMiddle + storage_FIELDNAME)
private String storage;
public static final String length_FIELDNAME = "length";
@FieldDescribe("文件大小.")
@Column(name = ColumnNamePrefix + length_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + length_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Long length;
public static final String lastUpdateTime_FIELDNAME = "lastUpdateTime";
@FieldDescribe("最后更新时间")
@Column(name = ColumnNamePrefix + lastUpdateTime_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + lastUpdateTime_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Date lastUpdateTime;
public static final String deepPath_FIELDNAME = "deepPath";
@FieldDescribe("是否使用更深的路径.")
@CheckPersist(allowEmpty = true)
@Column(name = ColumnNamePrefix + deepPath_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + deepPath_FIELDNAME)
private Boolean deepPath;
@Override
public String getStorage() {
return storage;
}
@Override
public void setStorage(String storage) {
this.storage = storage;
}
@Override
public Long getLength() {
return length;
}
@Override
public void setLength(Long length) {
this.length = length;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getExtension() {
return extension;
}
@Override
public void setExtension(String extension) {
this.extension = extension;
}
@Override
public Date getLastUpdateTime() {
return lastUpdateTime;
}
@Override
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
@Override
public Boolean getDeepPath() {
return BooleanUtils.isTrue(this.deepPath);
}
@Override
public void setDeepPath(Boolean deepPath) {
this.deepPath = deepPath;
}
public static final String signId_FIELDNAME = "signId";
@FieldDescribe("签批ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + signId_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + signId_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String signId;
public static final String job_FIELDNAME = "job";
@FieldDescribe("任务.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + job_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + job_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String job;
public static final String activity_FIELDNAME = "activity";
@FieldDescribe("活动ID.")
@Column(length = JpaObject.length_id, name = ColumnNamePrefix + activity_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String activity;
public static final String activityName_FIELDNAME = "activityName";
@FieldDescribe("活动名称.")
@Column(length = length_255B, name = ColumnNamePrefix + activityName_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String activityName;
public static final String person_FIELDNAME = "person";
@FieldDescribe("签批人")
@Column(length = length_255B, name = ColumnNamePrefix + person_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + person_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String person;
public static final String commitTime_FIELDNAME = "commitTime";
@Temporal(TemporalType.TIME)
@FieldDescribe("提交时间.")
@Column(name = ColumnNamePrefix + commitTime_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + commitTime_FIELDNAME)
@CheckPersist(allowEmpty = true)
private Date commitTime;
public static final String type_FIELDNAME = "type";
@FieldDescribe("涂鸦类型:placeholder(占位符)|base64(图片base64存储在data字段中)|image(图片存储在附件中)")
@Column(length = length_64B, name = ColumnNamePrefix + type_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String type;
public static final String width_FIELDNAME = "width";
@FieldDescribe("宽")
@Column(length = length_64B, name = ColumnNamePrefix + width_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String width;
public static final String height_FIELDNAME = "height";
@FieldDescribe("高")
@Column(length = length_64B, name = ColumnNamePrefix + height_FIELDNAME)
@CheckPersist(allowEmpty = true)
private String height;
public String getPerson() {
return person;
}
public void setPerson(String person) {
this.person = person;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public String getActivity() {
return activity;
}
public void setActivity(String activity) {
this.activity = activity;
}
public String getActivityName() {
return activityName;
}
public void setActivityName(String activityName) {
this.activityName = activityName;
}
public Date getCommitTime() {
return commitTime;
}
public void setCommitTime(Date commitTime) {
this.commitTime = commitTime;
}
public String getSignId() {
return signId;
}
public void setSignId(String signId) {
this.signId = signId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getWidth() {
return width;
}
public void setWidth(String width) {
this.width = width;
}
public String getHeight() {
return height;
}
public void setHeight(String height) {
this.height = height;
}
}
package com.x.processplatform.core.entity.content;
public enum DocSignStatus {
STATUS_1(1, "暂存"),
STATUS_2(2, "签批正文不可以修改"),
STATUS_3(3, "签批正文可以修改");
private Integer value;
private String name;
private DocSignStatus(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
}
......@@ -54,6 +54,12 @@ public class SnapProperties extends JsonProperties {
@FieldDescribe("版式文件版本")
private List<DocumentVersion> documentVersionList = new ArrayList<DocumentVersion>();
@FieldDescribe("文档签批信息")
private List<DocSign> docSignList = new ArrayList<>();
@FieldDescribe("文档签批附件信息")
private List<DocSignScrawl> docSignScrawlList = new ArrayList<>();
private Map<String, String> attachmentContentMap = new HashMap<>();
public Data getData() {
......@@ -206,4 +212,25 @@ public class SnapProperties extends JsonProperties {
this.attachmentContentMap = attachmentContentMap;
}
public List<DocSign> getDocSignList() {
if(docSignList == null){
docSignList = new ArrayList<>();
}
return docSignList;
}
public void setDocSignList(List<DocSign> docSignList) {
this.docSignList = docSignList;
}
public List<DocSignScrawl> getDocSignScrawlList() {
if(docSignScrawlList == null){
this.docSignScrawlList = new ArrayList<>();
}
return docSignScrawlList;
}
public void setDocSignScrawlList(List<DocSignScrawl> docSignScrawlList) {
this.docSignScrawlList = docSignScrawlList;
}
}
......@@ -35,6 +35,8 @@ public class ActionDelete extends BaseAction {
deleteItem(business, job);
deleteDocumentVersion(business, job);
deleteRecord(business, job);
deleteSignScrawl(business, job);
deleteSign(business, job);
emc.beginTransaction(Work.class);
for (Work o : emc.listEqual(Work.class, Work.job_FIELDNAME, job)) {
emc.remove(o);
......
......@@ -9,6 +9,7 @@ import com.x.processplatform.service.processing.Business;
import com.x.processplatform.service.processing.MessageFactory;
import com.x.processplatform.service.processing.ThisApplication;
import com.x.query.core.entity.Item;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
......@@ -119,4 +120,33 @@ abstract class BaseAction extends StandardJaxrsAction {
business.entityManagerContainer().delete(Record.class, ids);
}
}
protected void deleteSign(Business business, String job) throws Exception {
List<String> ids = business.entityManagerContainer().idsEqual(DocSign.class, DocSign.job_FIELDNAME, job);
if (ListTools.isNotEmpty(ids)) {
business.entityManagerContainer().beginTransaction(DocSign.class);
business.entityManagerContainer().delete(DocSign.class, ids);
}
}
protected void deleteSignScrawl(Business business, String job) throws Exception {
List<String> ids = business.entityManagerContainer().idsEqual(DocSignScrawl.class, DocSignScrawl.job_FIELDNAME, job);
if (ListTools.isNotEmpty(ids)) {
business.entityManagerContainer().beginTransaction(DocSignScrawl.class);
DocSignScrawl obj;
for (String id : ids) {
obj = business.entityManagerContainer().find(id, DocSignScrawl.class);
if (null != obj) {
if(StringUtils.isNotBlank(obj.getStorage())) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class,
obj.getStorage());
if (null != mapping) {
obj.deleteContent(mapping);
}
}
business.entityManagerContainer().remove(obj, CheckRemoveType.all);
}
}
}
}
}
......@@ -21,6 +21,7 @@ class ActionDelete extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionDelete.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
logger.debug(effectivePerson.getDistinguishedName());
String job = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Snap snap = emc.fetch(id, Snap.class, ListTools.toList(Snap.job_FIELDNAME));
......@@ -40,6 +41,7 @@ class ActionDelete extends BaseAction {
this.id = id;
}
@Override
public ActionResult<Wo> call() throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
......@@ -47,26 +49,6 @@ class ActionDelete extends BaseAction {
if (null == snap) {
throw new ExceptionEntityNotExist(id, Snap.class);
}
// // 已经没有work,workCompleted以及snap所以附件可以删除了
// if ((emc.countEqual(Work.class, Work.job_FIELDNAME, snap.getJob()) == 0)
// && (emc.countEqual(WorkCompleted.class, WorkCompleted.job_FIELDNAME, snap.getJob()) == 0)
// && (emc.countEqualAndNotEqual(Snap.class, Snap.job_FIELDNAME, snap.getJob(),
// JpaObject.id_FIELDNAME, snap.getId()) == 0)) {
// emc.beginTransaction(Attachment.class);
// emc.listEqual(Attachment.class, Attachment.job_FIELDNAME, snap.getJob()).forEach(o -> {
// try {
// StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
// o.getStorage());
// if (null != mapping) {
// o.deleteContent(mapping);
// }
// emc.remove(o, CheckRemoveType.all);
// } catch (Exception e) {
// logger.error(e);
// }
// });
// emc.commit();
// }
emc.beginTransaction(Snap.class);
emc.remove(snap, CheckRemoveType.all);
emc.commit();
......
......@@ -5,6 +5,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import com.x.processplatform.core.entity.content.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -22,18 +23,6 @@ import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.DocumentVersion;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.Snap;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.content.WorkCompleted;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.service.processing.Business;
import com.x.processplatform.service.processing.MessageFactory;
import com.x.processplatform.service.processing.ThisApplication;
......@@ -64,6 +53,7 @@ class ActionRestore extends BaseAction {
this.id = id;
}
@Override
public ActionResult<Wo> call() throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
......@@ -79,7 +69,8 @@ class ActionRestore extends BaseAction {
deleteTaskCompleted(business, snap.getJob()), deleteRead(business, snap.getJob()),
deleteReadCompleted(business, snap.getJob()), deleteReview(business, snap.getJob()),
deleteWorkLog(business, snap.getJob()), deleteRecord(business, snap.getJob()),
deleteAttachment(business, snap.getJob()), deleteDocumentVersion(business, snap.getJob()))
deleteAttachment(business, snap.getJob()), deleteDocumentVersion(business, snap.getJob()),
deleteDocSign(business, snap.getJob()), deleteDocSignScrawl(business, snap.getJob()))
.get();
} else {
CompletableFuture.allOf(deleteItem(business, snap.getJob()), deleteWork(business, snap.getJob()),
......@@ -87,7 +78,8 @@ class ActionRestore extends BaseAction {
deleteRead(business, snap.getJob()), deleteReadCompleted(business, snap.getJob()),
deleteReview(business, snap.getJob()), deleteWorkLog(business, snap.getJob()),
deleteRecord(business, snap.getJob()), deleteAttachment(business, snap.getJob()),
deleteDocumentVersion(business, snap.getJob())).get();
deleteDocumentVersion(business, snap.getJob()),
deleteDocSign(business, snap.getJob()), deleteDocSignScrawl(business, snap.getJob())).get();
}
emc.commit();
if (Objects.equals(Snap.TYPE_ABANDONEDWORKCOMPLETED, snap.getType())
......@@ -120,6 +112,8 @@ class ActionRestore extends BaseAction {
emc.beginTransaction(DocumentVersion.class);
emc.beginTransaction(Item.class);
emc.beginTransaction(Attachment.class);
emc.beginTransaction(DocSign.class);
emc.beginTransaction(DocSignScrawl.class);
restoreTask(emc, snap);
restoreTaskCompleted(emc, snap);
restoreRead(emc, snap);
......@@ -129,6 +123,8 @@ class ActionRestore extends BaseAction {
restoreRecord(emc, snap);
restoreDocumentVersion(emc, snap);
restoreAttachment(emc, snap);
restoreDocSign(emc, snap);
restoreDocSignScrawl(emc, snap);
if (ListTools.isNotEmpty(snap.getProperties().getWorkList())) {
WorkDataHelper workDataHelper = new WorkDataHelper(emc, snap.getProperties().getWorkList().get(0));
for (Work o : snap.getProperties().getWorkList()) {
......@@ -150,6 +146,8 @@ class ActionRestore extends BaseAction {
emc.beginTransaction(Record.class);
emc.beginTransaction(Item.class);
emc.beginTransaction(Attachment.class);
emc.beginTransaction(DocSign.class);
emc.beginTransaction(DocSignScrawl.class);
restoreTaskCompleted(emc, snap);
restoreRead(emc, snap);
restoreReadCompleted(emc, snap);
......@@ -157,6 +155,8 @@ class ActionRestore extends BaseAction {
restoreWorkLog(emc, snap);
restoreRecord(emc, snap);
restoreAttachment(emc, snap);
restoreDocSign(emc, snap);
restoreDocSignScrawl(emc, snap);
emc.persist(snap.getProperties().getWorkCompleted(), CheckPersistType.all);
if (BooleanUtils.isNotTrue(snap.getProperties().getWorkCompleted().getMerged())) {
WorkDataHelper workDataHelper = new WorkDataHelper(emc, snap.getProperties().getWorkCompleted());
......@@ -235,6 +235,30 @@ class ActionRestore extends BaseAction {
MessageFactory.readCompleted_create(o);
}
}
private void restoreDocSign(EntityManagerContainer emc, Snap snap) throws Exception {
for (DocSign o : snap.getProperties().getDocSignList()) {
emc.persist(o, CheckPersistType.all);
}
}
private void restoreDocSignScrawl(EntityManagerContainer emc, Snap snap) throws Exception {
for (DocSignScrawl o : snap.getProperties().getDocSignScrawlList()) {
String content = snap.getProperties().getAttachmentContentMap().get(o.getId());
if (StringUtils.isNotEmpty(content)) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class,
o.getStorage());
if (null == mapping) {
mapping = ThisApplication.context().storageMappings().random(DocSignScrawl.class);
}
if (null != mapping) {
byte[] bytes = Base64.decodeBase64(content);
o.updateContent(mapping, bytes);
}
}
emc.persist(o, CheckPersistType.all);
}
}
}
public static class Wo extends WoId {
......@@ -243,4 +267,4 @@ class ActionRestore extends BaseAction {
}
}
\ No newline at end of file
}
......@@ -17,17 +17,7 @@ import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.DocumentVersion;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.Snap;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.core.entity.content.*;
import com.x.processplatform.service.processing.Business;
import com.x.query.core.entity.Item;
......@@ -75,14 +65,17 @@ class ActionTypeAbandoned extends BaseAction {
List<Record> records = new ArrayList<>();
List<Attachment> attachments = new ArrayList<>();
List<DocumentVersion> documentVersions = new ArrayList<>();
List<DocSign> docSigns = new ArrayList<>();
List<DocSignScrawl> docSignScrawls = new ArrayList<>();
snap.setProperties(snap(business, work.getJob(), items, works, tasks, taskCompleteds, reads,
readCompleteds, reviews, workLogs, records, attachments, documentVersions));
readCompleteds, reviews, workLogs, records, attachments, documentVersions,
docSigns, docSignScrawls));
snap.setType(Snap.TYPE_ABANDONED);
emc.beginTransaction(Snap.class);
emc.persist(snap, CheckPersistType.all);
emc.commit();
clean(business, items, works, tasks, taskCompleteds, reads, readCompleteds, reviews, workLogs, records,
attachments, documentVersions);
attachments, documentVersions, docSigns, docSignScrawls);
emc.commit();
Wo wo = new Wo();
wo.setId(snap.getId());
......
......@@ -15,15 +15,7 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.Snap;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.WorkCompleted;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.core.entity.content.*;
import com.x.processplatform.service.processing.Business;
import com.x.query.core.entity.Item;
......@@ -69,14 +61,16 @@ class ActionTypeAbandonedWorkCompleted extends BaseAction {
List<WorkLog> workLogs = new ArrayList<>();
List<Record> records = new ArrayList<>();
List<Attachment> attachments = new ArrayList<>();
List<DocSign> docSigns = new ArrayList<>();
List<DocSignScrawl> docSignScrawls = new ArrayList<>();
snap.setProperties(snap(business, workCompleted.getJob(), items, workCompleted, taskCompleteds, reads,
readCompleteds, reviews, workLogs, records, attachments));
readCompleteds, reviews, workLogs, records, attachments, docSigns, docSignScrawls));
snap.setType(Snap.TYPE_ABANDONEDWORKCOMPLETED);
emc.beginTransaction(Snap.class);
emc.persist(snap, CheckPersistType.all);
emc.commit();
clean(business, items, workCompleted, taskCompleteds, reads, readCompleteds, reviews, workLogs, records,
attachments);
attachments, docSigns, docSignScrawls);
emc.commit();
Wo wo = new Wo();
wo.setId(snap.getId());
......
......@@ -16,17 +16,7 @@ import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.DocumentVersion;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.Snap;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.core.entity.content.*;
import com.x.processplatform.service.processing.Business;
import com.x.query.core.entity.Item;
......@@ -54,6 +44,7 @@ class ActionTypeSnap extends BaseAction {
this.id = id;
}
@Override
public ActionResult<Wo> call() throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
......@@ -73,10 +64,12 @@ class ActionTypeSnap extends BaseAction {
List<Record> records = new ArrayList<>();
List<Attachment> attachments = new ArrayList<>();
List<DocumentVersion> documentVersions = new ArrayList<>();
List<DocSign> docSigns = new ArrayList<>();
List<DocSignScrawl> docSignScrawls = new ArrayList<>();
Snap snap = new Snap(work);
snap.setProperties(snap(business, work.getJob(), items, works, tasks, taskCompleteds, reads,
readCompleteds, reviews, workLogs, records, attachments, documentVersions));
readCompleteds, reviews, workLogs, records, attachments, documentVersions, docSigns, docSignScrawls));
snap.setType(Snap.TYPE_SNAP);
emc.beginTransaction(Snap.class);
emc.persist(snap, CheckPersistType.all);
......
......@@ -15,15 +15,7 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.Snap;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.WorkCompleted;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.core.entity.content.*;
import com.x.processplatform.service.processing.Business;
import com.x.query.core.entity.Item;
......@@ -69,8 +61,10 @@ class ActionTypeSnapWorkCompleted extends BaseAction {
List<WorkLog> workLogs = new ArrayList<>();
List<Record> records = new ArrayList<>();
List<Attachment> attachments = new ArrayList<>();
List<DocSign> docSigns = new ArrayList<>();
List<DocSignScrawl> docSignScrawls = new ArrayList<>();
snap.setProperties(snap(business, workCompleted.getJob(), items, workCompleted, taskCompleteds, reads,
readCompleteds, reviews, workLogs, records, attachments));
readCompleteds, reviews, workLogs, records, attachments, docSigns, docSignScrawls));
snap.setType(Snap.TYPE_SNAPWORKCOMPLETED);
emc.beginTransaction(Snap.class);
emc.persist(snap, CheckPersistType.all);
......
......@@ -17,17 +17,7 @@ import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.DocumentVersion;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.Snap;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.core.entity.content.*;
import com.x.processplatform.service.processing.Business;
import com.x.query.core.entity.Item;
......@@ -75,14 +65,17 @@ class ActionTypeSuspend extends BaseAction {
List<Record> records = new ArrayList<>();
List<Attachment> attachments = new ArrayList<>();
List<DocumentVersion> documentVersions = new ArrayList<>();
List<DocSign> docSigns = new ArrayList<>();
List<DocSignScrawl> docSignScrawls = new ArrayList<>();
snap.setProperties(snap(business, work.getJob(), items, works, tasks, taskCompleteds, reads,
readCompleteds, reviews, workLogs, records, attachments, documentVersions));
readCompleteds, reviews, workLogs, records, attachments, documentVersions,
docSigns, docSignScrawls));
snap.setType(Snap.TYPE_SUSPEND);
emc.beginTransaction(Snap.class);
emc.persist(snap, CheckPersistType.all);
emc.commit();
clean(business, items, works, tasks, taskCompleteds, reads, readCompleteds, reviews, workLogs, records,
attachments, documentVersions);
attachments, documentVersions, docSigns, docSignScrawls);
emc.commit();
Wo wo = new Wo();
wo.setId(snap.getId());
......
......@@ -8,6 +8,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import com.x.processplatform.core.entity.content.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.BooleanUtils;
......@@ -20,23 +21,13 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.Data;
import com.x.processplatform.core.entity.content.DocumentVersion;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.SnapProperties;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.content.WorkCompleted;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.service.processing.Business;
import com.x.processplatform.service.processing.MessageFactory;
import com.x.processplatform.service.processing.ThisApplication;
import com.x.query.core.entity.Item;
import org.apache.commons.lang3.StringUtils;
import javax.print.Doc;
abstract class BaseAction extends StandardJaxrsAction {
......@@ -45,7 +36,7 @@ abstract class BaseAction extends StandardJaxrsAction {
protected SnapProperties snap(Business business, String job, List<Item> items, List<Work> works, List<Task> tasks,
List<TaskCompleted> taskCompleteds, List<Read> reads, List<ReadCompleted> readCompleteds,
List<Review> reviews, List<WorkLog> workLogs, List<Record> records, List<Attachment> attachments,
List<DocumentVersion> documentVersions) throws InterruptedException, ExecutionException {
List<DocumentVersion> documentVersions, List<DocSign> docSigns, List<DocSignScrawl> docSignScrawls) throws InterruptedException, ExecutionException {
SnapProperties properties = new SnapProperties();
properties.setJob(job);
CompletableFuture.allOf(mergeItem(business, job, properties, items),
......@@ -56,7 +47,9 @@ abstract class BaseAction extends StandardJaxrsAction {
mergeReview(business, job, properties, reviews), mergeWorkLog(business, job, properties, workLogs),
mergeRecord(business, job, properties, records),
mergeAttachment(business, job, properties, attachments),
mergeDocumentVersion(business, job, properties, documentVersions)).get();
mergeDocumentVersion(business, job, properties, documentVersions),
mergeDocSign(business, job, properties, docSigns),
mergeDocSignScrawl(business, job, properties, docSignScrawls)).get();
if (ListTools.isNotEmpty(works)) {
properties.setTitle(works.get(0).getTitle());
}
......@@ -65,7 +58,8 @@ abstract class BaseAction extends StandardJaxrsAction {
protected SnapProperties snap(Business business, String job, List<Item> items, WorkCompleted workCompleted,
List<TaskCompleted> taskCompleteds, List<Read> reads, List<ReadCompleted> readCompleteds,
List<Review> reviews, List<WorkLog> workLogs, List<Record> records, List<Attachment> attachments)
List<Review> reviews, List<WorkLog> workLogs, List<Record> records, List<Attachment> attachments,
List<DocSign> docSigns, List<DocSignScrawl> docSignScrawls)
throws InterruptedException, ExecutionException {
SnapProperties properties = new SnapProperties();
properties.setJob(job);
......@@ -79,6 +73,8 @@ abstract class BaseAction extends StandardJaxrsAction {
futures.add(mergeWorkLog(business, job, properties, workLogs));
futures.add(mergeRecord(business, job, properties, records));
futures.add(mergeAttachment(business, job, properties, attachments));
futures.add(mergeDocSign(business, job, properties, docSigns));
futures.add(mergeDocSignScrawl(business, job, properties, docSignScrawls));
if (BooleanUtils.isNotTrue(workCompleted.getMerged())) {
futures.add(mergeItem(business, job, properties, items));
}
......@@ -90,25 +86,29 @@ abstract class BaseAction extends StandardJaxrsAction {
protected void clean(Business business, List<Item> items, List<Work> works, List<Task> tasks,
List<TaskCompleted> taskCompleteds, List<Read> reads, List<ReadCompleted> readCompleteds,
List<Review> reviews, List<WorkLog> workLogs, List<Record> records, List<Attachment> attachments,
List<DocumentVersion> documentVersions) throws InterruptedException, ExecutionException {
List<DocumentVersion> documentVersions, List<DocSign> docSigns, List<DocSignScrawl> docSignScrawls)
throws InterruptedException, ExecutionException {
CompletableFuture
.allOf(deleteItem(business, items), deleteWork(business, works), deleteTask(business, tasks),
deleteTaskCompleted(business, taskCompleteds), deleteRead(business, reads),
deleteReadCompleted(business, readCompleteds), deleteReview(business, reviews),
deleteWorkLog(business, workLogs), deleteRecord(business, records),
deleteAttachment(business, attachments), deleteDocumentVersion(business, documentVersions))
deleteAttachment(business, attachments), deleteDocumentVersion(business, documentVersions),
deleteDocSign(business, docSigns), deleteDocSignScrawl(business, docSignScrawls))
.get();
}
protected void clean(Business business, List<Item> items, WorkCompleted workCompleted,
List<TaskCompleted> taskCompleteds, List<Read> reads, List<ReadCompleted> readCompleteds,
List<Review> reviews, List<WorkLog> workLogs, List<Record> records, List<Attachment> attachments)
List<Review> reviews, List<WorkLog> workLogs, List<Record> records, List<Attachment> attachments,
List<DocSign> docSigns, List<DocSignScrawl> docSignScrawls)
throws InterruptedException, ExecutionException {
CompletableFuture.allOf(deleteItem(business, items), deleteWork(business, workCompleted),
deleteTaskCompleted(business, taskCompleteds), deleteRead(business, reads),
deleteReadCompleted(business, readCompleteds), deleteReview(business, reviews),
deleteWorkLog(business, workLogs), deleteRecord(business, records),
deleteAttachment(business, attachments)).get();
deleteAttachment(business, attachments),
deleteDocSign(business, docSigns), deleteDocSignScrawl(business, docSignScrawls)).get();
}
private CompletableFuture<Void> mergeItem(Business business, String job, SnapProperties snapProperties,
......@@ -296,6 +296,48 @@ abstract class BaseAction extends StandardJaxrsAction {
});
}
private CompletableFuture<Void> mergeDocSign(Business business, String job, SnapProperties snapProperties,
List<DocSign> docSigns) {
return CompletableFuture.runAsync(() -> {
try {
List<DocSign> os = business.entityManagerContainer().listEqual(DocSign.class, DocSign.job_FIELDNAME, job)
.stream().sorted(Comparator.comparing(DocSign::getCreateTime, Comparator.nullsLast(Date::compareTo)))
.collect(Collectors.toList());
snapProperties.setDocSignList(os);
docSigns.addAll(os);
} catch (Exception e) {
logger.error(e);
}
});
}
private CompletableFuture<Void> mergeDocSignScrawl(Business business, String job, SnapProperties snapProperties,
List<DocSignScrawl> docSignScrawls) {
return CompletableFuture.runAsync(() -> {
try {
List<DocSignScrawl> os = business.entityManagerContainer()
.listEqual(DocSignScrawl.class, DocSignScrawl.job_FIELDNAME, job).stream()
.sorted(Comparator.comparing(DocSignScrawl::getCreateTime, Comparator.nullsLast(Date::compareTo)))
.collect(Collectors.toList());
snapProperties.setDocSignScrawlList(os);
docSignScrawls.addAll(os);
for (DocSignScrawl docSignScrawl : os) {
if(StringUtils.isNotBlank(docSignScrawl.getStorage())) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(Attachment.class,
docSignScrawl.getStorage());
if (null != mapping) {
byte[] bytes = docSignScrawl.readContent(mapping);
snapProperties.getAttachmentContentMap().put(docSignScrawl.getId(),
Base64.encodeBase64URLSafeString(bytes));
}
}
}
} catch (Exception e) {
logger.error(e);
}
});
}
private CompletableFuture<Void> deleteItem(Business business, List<Item> items) {
return CompletableFuture.runAsync(() -> {
try {
......@@ -462,6 +504,39 @@ abstract class BaseAction extends StandardJaxrsAction {
});
}
private CompletableFuture<Void> deleteDocSign(Business business, List<DocSign> docSigns) {
return CompletableFuture.runAsync(() -> {
try {
business.entityManagerContainer().beginTransaction(DocSign.class);
for (DocSign o : docSigns) {
business.entityManagerContainer().remove(o);
}
} catch (Exception e) {
logger.error(e);
}
});
}
private CompletableFuture<Void> deleteDocSignScrawl(Business business, List<DocSignScrawl> docSignScrawls) {
return CompletableFuture.runAsync(() -> {
try {
business.entityManagerContainer().beginTransaction(DocSignScrawl.class);
for (DocSignScrawl o : docSignScrawls) {
if(StringUtils.isNotBlank(o.getStorage())) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class,
o.getStorage());
if (null != mapping) {
o.deleteContent(mapping);
}
}
business.entityManagerContainer().remove(o);
}
} catch (Exception e) {
logger.error(e);
}
});
}
protected CompletableFuture<Void> deleteItem(Business business, String job) {
return CompletableFuture.runAsync(() -> {
try {
......@@ -635,4 +710,39 @@ abstract class BaseAction extends StandardJaxrsAction {
}
});
}
protected CompletableFuture<Void> deleteDocSign(Business business, String job) {
return CompletableFuture.runAsync(() -> {
try {
business.entityManagerContainer().beginTransaction(DocSign.class);
for (DocSign o : business.entityManagerContainer().listEqual(DocSign.class,
DocSign.job_FIELDNAME, job)) {
business.entityManagerContainer().remove(o);
}
} catch (Exception e) {
logger.error(e);
}
});
}
protected CompletableFuture<Void> deleteDocSignScrawl(Business business, String job) {
return CompletableFuture.runAsync(() -> {
try {
business.entityManagerContainer().beginTransaction(DocSignScrawl.class);
for (DocSignScrawl o : business.entityManagerContainer().listEqual(DocSignScrawl.class,
DocSignScrawl.job_FIELDNAME, job)) {
if(StringUtils.isNotBlank(o.getStorage())) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class,
o.getStorage());
if (null != mapping) {
o.deleteContent(mapping);
}
}
business.entityManagerContainer().remove(o);
}
} catch (Exception e) {
logger.error(e);
}
});
}
}
......@@ -6,20 +6,12 @@ import com.x.base.core.entity.annotation.CheckRemoveType;
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.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.DocumentVersion;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.core.entity.content.*;
import com.x.processplatform.service.processing.Business;
import com.x.processplatform.service.processing.MessageFactory;
import com.x.processplatform.service.processing.ThisApplication;
import com.x.query.core.entity.Item;
import org.apache.commons.lang3.StringUtils;
abstract class BaseAction extends StandardJaxrsAction {
......@@ -49,6 +41,8 @@ abstract class BaseAction extends StandardJaxrsAction {
deleteDocumentVersion(business, work.getJob());
deleteRecord(business, work.getJob());
deleteWork(business, work);
deleteSignScrawl(business, work.getJob());
deleteSign(business, work.getJob());
return true;
}
}
......@@ -173,4 +167,33 @@ abstract class BaseAction extends StandardJaxrsAction {
}
}
protected void deleteSign(Business business, String job) throws Exception {
List<String> ids = business.entityManagerContainer().idsEqual(DocSign.class, DocSign.job_FIELDNAME, job);
if (ListTools.isNotEmpty(ids)) {
business.entityManagerContainer().beginTransaction(DocSign.class);
business.entityManagerContainer().delete(DocSign.class, ids);
}
}
protected void deleteSignScrawl(Business business, String job) throws Exception {
List<String> ids = business.entityManagerContainer().idsEqual(DocSignScrawl.class, DocSignScrawl.job_FIELDNAME, job);
if (ListTools.isNotEmpty(ids)) {
business.entityManagerContainer().beginTransaction(DocSignScrawl.class);
DocSignScrawl obj;
for (String id : ids) {
obj = business.entityManagerContainer().find(id, DocSignScrawl.class);
if (null != obj) {
if(StringUtils.isNotBlank(obj.getStorage())) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(DocSignScrawl.class,
obj.getStorage());
if (null != mapping) {
obj.deleteContent(mapping);
}
}
business.entityManagerContainer().remove(obj, CheckRemoveType.all);
}
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册