Browse Source

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

4.0
lip 2 years ago
parent
commit
e9fa7ed868
100 changed files with 1888 additions and 2555 deletions
  1. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmApplication.java
  2. +7
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmAutoConfiguration.java
  3. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmConfigBean.java
  4. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/config/FileConfig.java
  5. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/config/FileConfigProperties.java
  6. +61
    -64
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/AttachController.java
  7. +151
    -142
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/FileDownloadController.java
  8. +118
    -118
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/FileUploadController.java
  9. +44
    -44
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/dao/ImageAttachDao.java
  10. +71
    -71
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/dao/SysAttachDao.java
  11. +11
    -11
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/dataCacheInit/AttachFolderEntityBuffer.java
  12. +6
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/entity/AttachPathPO.java
  13. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/entity/FileDataVO.java
  14. +8
    -8
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/entity/UploadDataVO.java
  15. +6
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachFileWork.java
  16. +4
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachFtpWork.java
  17. +49
    -46
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachHelper.java
  18. +17
    -16
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachUtil.java
  19. +4
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/IAttachWorkIntf.java
  20. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/initPlugin/RunDataInit.java
  21. +81
    -81
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/BeanUtil.java
  22. +1
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java
  23. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/FileDynPath.java
  24. +63
    -62
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/FilePathGenerator.java
  25. +32
    -32
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/FilePathInfo.java
  26. +37
    -29
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ITreeDataHandler.java
  27. +3
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ITreeDataLevelHandler.java
  28. +4
    -7
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/IdeaUtil.java
  29. +56
    -56
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/MemMultipartFile.java
  30. +88
    -87
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ThumbImage.java
  31. +166
    -164
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/TreeDataUtil.java
  32. +8
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilFile.java
  33. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilLogger.java
  34. +0
    -465
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilMath.java
  35. +0
    -504
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilString.java
  36. +59
    -58
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/XmlUtil.java
  37. +79
    -79
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/YamlUtil.java
  38. +9
    -8
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/FtpTaskManager.java
  39. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/FtpUtil.java
  40. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/IFtpServerConfig.java
  41. +5
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/IFtpUtil.java
  42. +5
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/SFtpUtil.java
  43. +1
    -10
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/BpmStartedListener.java
  44. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogCache.java
  45. +4
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java
  46. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java
  47. +9
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelProjectCache.java
  48. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/FlowConst.java
  49. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProc.java
  50. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcCache.java
  51. +4
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcHelper.java
  52. +0
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcLoadHandler.java
  53. +3
    -7
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcService.java
  54. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/define/ProcInfo.java
  55. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/define/Sign.java
  56. +3
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java
  57. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelForm.java
  58. +4
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java
  59. +10
    -7
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  60. +2
    -9
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java
  61. +0
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormService.java
  62. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/BaseDatasetField.java
  63. +4
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java
  64. +2
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/BaseModelWorker.java
  65. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcLtMsWorker.java
  66. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcLtWorker.java
  67. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcMsWorker.java
  68. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcNormalWorker.java
  69. +4
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java
  70. +6
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/flow/FlowSingleWorker.java
  71. +42
    -42
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/MenuVO.java
  72. +5
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/PreviewMenuTreeService.java
  73. +3
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java
  74. +5
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java
  75. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageListHandler.java
  76. +11
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageLoadHandler.java
  77. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java
  78. +9
    -9
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageService.java
  79. +3
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageTreeHandler.java
  80. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynRetBean.java
  81. +0
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/IBuildSqlListener.java
  82. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowHelper.java
  83. +2
    -29
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java
  84. +17
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowListener.java
  85. +0
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowProvider.java
  86. +76
    -23
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/Comment.java
  87. +62
    -19
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/FlowLog.java
  88. +103
    -30
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/ProcInst.java
  89. +139
    -40
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/Task.java
  90. +27
    -8
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/TaskRel.java
  91. +2
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowDelHandler.java
  92. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowListHandler.java
  93. +2
    -11
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java
  94. +1
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java
  95. +3
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java
  96. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java
  97. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java
  98. +7
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java
  99. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java
  100. +8
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmApplication.java View File

@@ -9,6 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class BpmApplication {
public static void main(String[] args) {
SpringApplication.run(BpmApplication.class, args);
SpringApplication.run(BpmApplication.class, args);
}
}

+ 7
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmAutoConfiguration.java View File

@@ -11,9 +11,11 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan
public class BpmAutoConfiguration {
/** 配置自定义service扫描路径 {module}/{service}/{method} */
@Bean
public ControllerConfig bpmControllerConfig() {
return new ControllerConfig("bpm", "cc.smtweb.system.bpm.web", null);
}
/**
* 配置自定义service扫描路径 {module}/{service}/{method}
*/
@Bean
public ControllerConfig bpmControllerConfig() {
return new ControllerConfig("bpm", "cc.smtweb.system.bpm.web", null);
}
}

+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmConfigBean.java View File

@@ -8,6 +8,6 @@ import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "smtweb.bpm")
@Data
public class BpmConfigBean {
private String codeJavaPath;
private int mode;
private String codeJavaPath;
private int mode;
}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/config/FileConfig.java View File

@@ -1,10 +1,10 @@
package cc.smtweb.system.bpm.spring.config;

import cc.smtweb.framework.core.db.jdbc.IdGenerator;
import cc.smtweb.system.bpm.util.FilePathGenerator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cc.smtweb.framework.core.db.jdbc.IdGenerator;

/**
* 微服务框架封装自动配置类


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/config/FileConfigProperties.java View File

@@ -13,7 +13,7 @@ public class FileConfigProperties {
/**
* 系统底层附件保存路径和访问路径
*/
private String localPath;
private String localPath;
private String url;

/**


+ 61
- 64
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/AttachController.java View File

@@ -4,14 +4,14 @@ import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.util.Consts;
import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.NumberUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.spring.config.FileConfigProperties;
import cc.smtweb.system.bpm.spring.file.attach.AttachHelper;
import cc.smtweb.system.bpm.spring.file.attach.AttachUtil;
import cc.smtweb.system.bpm.util.UtilDownloadFile;
import cc.smtweb.system.bpm.util.UtilFile;
import cc.smtweb.system.bpm.util.UtilLogger;
import cc.smtweb.system.bpm.util.UtilMath;
import cc.smtweb.system.bpm.web.sys.base.attach.AttachInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
@@ -48,7 +48,7 @@ import java.util.Map;
@RestController
@RequestMapping("/api/attach")
public class AttachController {
private static Logger logger = LoggerFactory.getLogger(AttachController.class);
private static Logger logger = LoggerFactory.getLogger(AttachController.class);
@Autowired
private FileConfigProperties properties;
@Autowired
@@ -60,14 +60,13 @@ public class AttachController {
private BASE64Decoder decoder = new BASE64Decoder();

/**
*
* @param request
* @param type 类型,如idcard:身份证、headImg:头像
* @param ownerId 拥有者ID
* @param path 存储目录路径名,如:idcard
* @param type 类型,如idcard:身份证、headImg:头像
* @param ownerId 拥有者ID
* @param path 存储目录路径名,如:idcard
* @param attachIsTemp 是否临时文件:true/false 字符串
* @param attachName 附件名称,如:XXXXX.jpg
* @param savePath 保存路径,指定文件保存目录,可为空
* @param attachName 附件名称,如:XXXXX.jpg
* @param savePath 保存路径,指定文件保存目录,可为空
* @return
* @throws Exception
*/
@@ -91,23 +90,22 @@ public class AttachController {
AttachInfo attach = new AttachInfo();
attach.setId(dbEngine.nextId());
attach.setType(type);//附件类别
if(null !=ownerId) {
if (null != ownerId) {
attach.setOwnerId(ownerId);//附件拥有者id
}
attach.setPath(path);//附件路径
attach.setPartyId(-1l);
attach.setTime(PubUtil.getLastTime());
attach.setTime(DateUtil.nowDateTimeLong());
attach.setUserId(-1l);
attach.setIsTemp("true".equals(attachIsTemp) ? 1 : 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件
attach.setIsTemp("true".equals(attachIsTemp) ? 1: 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件
// 上传文件名
final int i = file.getOriginalFilename().lastIndexOf(".");
if (i >= 0) {
attach.setSuffix(file.getOriginalFilename().substring(i));
}
if (PubUtil.isEmptyStr(attachName)) {
if (StringUtil.isEmpty(attachName)) {
attachName = file.getOriginalFilename();
}
else {
} else {
attachName = attachName + attach.getSuffix();
}
attach.setName(attachName);
@@ -116,7 +114,7 @@ public class AttachController {
// 上传文件域对象
File upload = new File(attachHelper.getAttachTmpPath() + attach.getId() + attach.getSuffix());
attach.setSize((long) FileCopyUtils.copy(file.getInputStream(), new BufferedOutputStream(new FileOutputStream(upload))));
if (PubUtil.isEmpty(savePath)) {
if (StringUtil.isEmpty(savePath)) {
localSaveAttach(attach, upload);
} else {//复制到指定目录
String filePath;
@@ -138,18 +136,17 @@ public class AttachController {
}

/**
*
* @param request
* @param response
* @param base64File 文件base64编码
* @param attachId 附件ID,可为空,如果有,则替换此附件ID对应数据
* @param type 类型,如idcard:身份证、headImg:头像
* @param ownerId 拥有者ID
* @param path 存储目录路径名,如:idcard
* @param base64File 文件base64编码
* @param attachId 附件ID,可为空,如果有,则替换此附件ID对应数据
* @param type 类型,如idcard:身份证、headImg:头像
* @param ownerId 拥有者ID
* @param path 存储目录路径名,如:idcard
* @param attachIsTemp 是否临时文件:true/false 字符串
* @param attachName 附件名称,如:XXXXX.jpg
* @param savePath 保存路径,指定文件保存目录,可为空
* @param suffix 文件后缀,如.jpg
* @param attachName 附件名称,如:XXXXX.jpg
* @param savePath 保存路径,指定文件保存目录,可为空
* @param suffix 文件后缀,如.jpg
* @return
* @throws Exception
*/
@@ -164,23 +161,22 @@ public class AttachController {
@RequestParam(value = "attachName", required = false) String attachName,
@RequestParam(value = "savePath", required = false) String savePath,
@RequestParam(value = "suffix", required = false) String suffix
) throws Exception {
) throws Exception {
// UtilLogger.error("上传文件接收base64", base64File);
if (null == base64File || "".equals(base64File)){
if (null == base64File || "".equals(base64File)) {
return R.error("文件不能为空");
}
String str[]=base64File.split(",");
if(str.length>1){
base64File=str[1];
String str[] = base64File.split(",");
if (str.length > 1) {
base64File = str[1];
}
// 上传文件类型
//String uploadContentType = file.getContentType();
AttachInfo attach = null;
boolean isNew = PubUtil.isEmpty(attachId+"");
boolean isNew = StringUtil.isEmpty(attachId + "");
if (isNew) {
attach = new AttachInfo();
}
else {
} else {
attach = dbEngine.findDao(AttachInfo.class).queryEntity(attachId);
if (attach == null) {
attach = new AttachInfo();
@@ -188,19 +184,19 @@ public class AttachController {
} else isNew = attach.isNew();
}
attach.setId(attachId);
if (PubUtil.isEmpty(attachId+"")) attach.setId(dbEngine.nextId());
if (StringUtil.isEmpty(attachId + "")) attach.setId(dbEngine.nextId());

attach.setType(type);//附件类别
if(null !=ownerId) {
if (null != ownerId) {
attach.setOwnerId(ownerId);//附件拥有者id
}
attach.setPath(path);//附件路径
attach.setPartyId(-1l);
attach.setTime(PubUtil.getLastTime());
attach.setTime(DateUtil.nowDateTimeLong());
attach.setUserId(-1l);
attach.setIsTemp("true".equals(attachIsTemp) ? 1 : 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件
attach.setIsTemp("true".equals(attachIsTemp) ? 1: 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件
attach.setTime(DateUtil.nowDateTimeLong());
attach.setIsTemp("true".equals(attachIsTemp) ? 1 : 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件
attach.setIsTemp("true".equals(attachIsTemp) ? 1: 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件
// 上传文件名
attach.setSuffix(suffix);
attach.setName(attachName);
@@ -219,7 +215,7 @@ public class AttachController {
File upload = new File(attachHelper.getAttachTmpPath() + attach.getId() + attach.getSuffix());
FileUtils.writeByteArrayToFile(upload, byt);
attach.setSize(upload.length());
if (PubUtil.isEmpty(savePath)) {
if (StringUtil.isEmpty(savePath)) {
localSaveAttach(attach, upload);
} else {//复制到指定目录
String filePath;
@@ -235,42 +231,43 @@ public class AttachController {
}
return R.success(attach.getId());
}

@PostMapping({"/copyupload"})
public R copyupload(HttpServletRequest request) throws Exception {
String type=request.getParameter("type");
String attachId=request.getParameter("attachId");
if(PubUtil.isEmpty(attachId)){
String type = request.getParameter("type");
String attachId = request.getParameter("attachId");
if (StringUtil.isEmpty(attachId)) {
return R.success("");
}
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId));
if(null ==attach){
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId));
if (null == attach) {
return R.success("");
}
String remoteName =attach.getId()+attach.getName().substring(attach.getName().lastIndexOf("."));
String remoteName = attach.getId() + attach.getName().substring(attach.getName().lastIndexOf("."));
String remotePath = attach.getPath();
String filePath =attachHelper.getAttachTmpPath()+"tempFiles/";
String filePath = attachHelper.getAttachTmpPath() + "tempFiles/";
UtilFile.makeDir(filePath);
Map<String, String> map = null;
try {
attachUtil.downloadAttach(remotePath, remoteName, filePath);
String filePaths=filePath+remoteName;
String filePaths = filePath + remoteName;

attach.setId(dbEngine.nextId());
attach.setType(type);//附件类别
attach.setOwnerId(-1l);//附件拥有者id
attach.setPartyId(-1l);
attach.setTime(PubUtil.getLastTime());
attach.setTime(DateUtil.nowDateTimeLong());
attach.setUserId(-1l);
attach.setName(attach.getId()+attach.getSuffix());
attach.setName(attach.getId() + attach.getSuffix());
// 上传文件域对象
File upload = new File(filePaths);
// attach.setSize((long) FileCopyUtils.copy(file.getInputStream(), new BufferedOutputStream(new FileOutputStream(upload))));
localSaveAttach(attach, upload);
}catch (Exception e){
} catch (Exception e) {
logger.error("上传文件失败", e);
return R.error("上传文件失败");
}
return R.success(attach.getId());
return R.success(attach.getId());
}


@@ -291,7 +288,7 @@ public class AttachController {
//附件下载
@RequestMapping(value = "/download", method = {RequestMethod.GET, RequestMethod.POST})
public R down(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "attachId", required = false) Long attachId) throws Exception {
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class,attachId);
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, attachId);
if (null == attach) {
return R.error("附件不存在");
}
@@ -302,9 +299,9 @@ public class AttachController {
try {
attachUtil.downloadAttach(remotePath, remoteFileName, fileName, response);
attach.setCount(attach.getCount() + 1);
dbEngine.updateEntity(attach,"attach_count");
dbEngine.updateEntity(attach, "attach_count");
} catch (Exception e) {
logger.error("附件下载失败",e);
logger.error("附件下载失败", e);
R.error("附件下载失败");

}
@@ -314,21 +311,21 @@ public class AttachController {
//图片附件显示路径
@GetMapping(value = "/showImg")
public R showImg(HttpServletResponse response, @RequestParam(value = "attachId", required = false) Long attachId) throws Exception {
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class,attachId);
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, attachId);
if (null == attach) {
return R.error("附件不存在");
}
// attachUtil.showImg(attach.getPath(),attach.getName(),response);
attachUtil.downloadAttach(attach.getPath(),attach.getName(),attach.getName(),response);
attachUtil.downloadAttach(attach.getPath(), attach.getName(), attach.getName(), response);
return null;
}

//图片附件显示路径
@RequestMapping(value = "/showImgThumb", method = {RequestMethod.GET, RequestMethod.POST})
public R showImgThumb(HttpServletResponse response, @RequestParam(value = "attachId", required = false) Long attachId,
@RequestParam(value = "width", required = false,defaultValue = "200") String width,
@RequestParam(value = "height", required = false,defaultValue = "120") String height) throws Exception {
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class,attachId);
@RequestParam(value = "width", required = false, defaultValue = "200") String width,
@RequestParam(value = "height", required = false, defaultValue = "120") String height) throws Exception {
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, attachId);
if (null == attach) {
return R.error("附件不存在");
}
@@ -339,8 +336,8 @@ public class AttachController {
String lfo = tempPath + "/" + remoteFileName;
String lfd = tempPath + "/thumb_" + attach.getId() + attach.getSuffix();
attachUtil.downloadAttach(remotePath, remoteFileName, tempPath);
int w=Integer.valueOf(width);
int h=Integer.valueOf(height);
int w = Integer.valueOf(width);
int h = Integer.valueOf(height);
if (w <= 0) w = 100;
if (h <= 0) h = 100;
getImgThumb(lfo, lfd, w, h);
@@ -350,7 +347,7 @@ public class AttachController {
UtilDownloadFile.downfileEx(response, lfo, attach.getName());
}
} catch (Exception e) {
logger.error("附件下载失败",e);
logger.error("附件下载失败", e);
R.error("附件下载失败");
}
return null;
@@ -372,7 +369,7 @@ public class AttachController {
if (h > height) {
r = Math.min(1.0 * height / h, r);
}
if (!UtilMath.isEqualsZero(r - 1)) {
if (!NumberUtil.isEqualsZero(r - 1)) {
w = (int) Math.round(w * r);
h = (int) Math.round(h * r);
}
@@ -419,7 +416,7 @@ public class AttachController {
//图片附件显示路径
@GetMapping(value = "/loadAttachBean")
public R loadAttachBean(@RequestParam(value = "attachIds") String attachIds) throws Exception {
List<AttachInfo> beans = dbEngine.queryWhere(AttachInfo.class, "attach_id in ("+attachIds+")");
List<AttachInfo> beans = dbEngine.queryWhere(AttachInfo.class, "attach_id in (" + attachIds + ")");
return R.success(beans);
}
}

+ 151
- 142
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/FileDownloadController.java View File

@@ -9,7 +9,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
@@ -22,164 +25,170 @@ import java.util.concurrent.TimeUnit;

@RestController
public class FileDownloadController {
private static final MediaType APPLICATION_JAVASCRIPT = new MediaType("application", "javascript");
@Value("${smtweb.static.local-path:}")
private String staticLocalPath;

@Autowired
private FilePathGenerator filePathGenerator;

@Autowired
private RedisManager redisManager;

/** path方式下载文件 */
@GetMapping("/fs/files/**")
public ResponseEntity<InputStreamResource> files(@RequestParam(value="name", required=false) String name,
@RequestParam(value="noCache", required=false) Boolean noCache,
HttpServletRequest request
) throws FileNotFoundException {
String filePath = request.getRequestURI().substring(10);
return download(filePath, name, noCache, request);
}

/** 参数方式下载文件 */
@GetMapping("/fs/download")
public ResponseEntity<InputStreamResource> download(@RequestParam(value="path") String path,
@RequestParam(value="name", required=false) String name,
@RequestParam(value="noCache", required=false) Boolean noCache,
HttpServletRequest request
) throws FileNotFoundException {
SessionUtil.checkSession(request, redisManager);

File file = new File(filePathGenerator.getFileDiskPath(path));

if (!file.exists()) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
private static final MediaType APPLICATION_JAVASCRIPT = new MediaType("application", "javascript");
@Value("${smtweb.static.local-path:}")
private String staticLocalPath;

@Autowired
private FilePathGenerator filePathGenerator;

@Autowired
private RedisManager redisManager;

/**
* path方式下载文件
*/
@GetMapping("/fs/files/**")
public ResponseEntity<InputStreamResource> files(@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "noCache", required = false) Boolean noCache,
HttpServletRequest request
) throws FileNotFoundException {
String filePath = request.getRequestURI().substring(10);
return download(filePath, name, noCache, request);
}

if (StringUtils.isBlank(name)) {
name = file.getName();
}

HttpHeaders headers = new HttpHeaders();
if (Boolean.TRUE.equals(noCache)) {
headers.setCacheControl("no-cache, no-store, must-revalidate");
headers.setPragma("no-cache");
headers.setExpires(0);
}

headers.setLastModified(file.lastModified());
headers.add("Content-Disposition",
String.format("attachment; filename=\"%s\"", new String(name.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1)));

return ResponseEntity.ok()
.headers(headers)
.contentLength(file.length())
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(new InputStreamResource(new FileInputStream(file)));
}

/** path方式读取静态目录文件 */
@GetMapping("/fs/static/**")
public ResponseEntity<InputStreamResource> resource(@RequestParam(value="default", required=false) String defaultPath,
@RequestParam(value="noCache", required=false) Boolean noCache,
@RequestHeader(value="If-Modified-Since", required = false) String ifModifiedSince,
HttpServletRequest request) throws FileNotFoundException {
String filePath = request.getRequestURI().substring(11);

HttpHeaders headers = new HttpHeaders();

if (Boolean.TRUE.equals(noCache)) {
headers.setCacheControl("no-cache, no-store, must-revalidate");
headers.setPragma("no-cache");
headers.setExpires(0);
} else {
// 暂时缓存1天
headers.setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS));
headers.setExpires(Instant.ofEpochMilli(System.currentTimeMillis() + DateUtils.MILLIS_PER_DAY));
}

String name = getFileName(filePath);
headers.add("Content-Disposition",
String.format("attachment; filename=\"%s\"", new String(name.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1)));

MediaType contentType = getContentType(filePath);
// 先找文件
if (StringUtils.isNotBlank(staticLocalPath)) {
File file = new File(staticLocalPath + filePath);
/**
* 参数方式下载文件
*/
@GetMapping("/fs/download")
public ResponseEntity<InputStreamResource> download(@RequestParam(value = "path") String path,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "noCache", required = false) Boolean noCache,
HttpServletRequest request
) throws FileNotFoundException {
SessionUtil.checkSession(request, redisManager);

File file = new File(filePathGenerator.getFileDiskPath(path));

if (!file.exists()) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}

if (StringUtils.isBlank(name)) {
name = file.getName();
}

HttpHeaders headers = new HttpHeaders();
if (Boolean.TRUE.equals(noCache)) {
headers.setCacheControl("no-cache, no-store, must-revalidate");
headers.setPragma("no-cache");
headers.setExpires(0);
}

if (file.exists()) {
headers.setLastModified(file.lastModified());
headers.add("Content-Disposition",
String.format("attachment; filename=\"%s\"", new String(name.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)));

return ResponseEntity.ok()
.headers(headers)
.contentLength(file.length())
.contentType(contentType)
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(new InputStreamResource(new FileInputStream(file)));
}
}

// 再找资源目录
InputStream inputStream = getClass().getResourceAsStream("/static/" + filePath);
if (inputStream != null) {
return buildResource(inputStream, contentType, headers);
} else if (StringUtils.isNotBlank(defaultPath)) {
inputStream = getClass().getResourceAsStream("/static/" + defaultPath);
if (inputStream != null) {
return buildResource(inputStream, contentType, headers);
}
/**
* path方式读取静态目录文件
*/
@GetMapping("/fs/static/**")
public ResponseEntity<InputStreamResource> resource(@RequestParam(value = "default", required = false) String defaultPath,
@RequestParam(value = "noCache", required = false) Boolean noCache,
@RequestHeader(value = "If-Modified-Since", required = false) String ifModifiedSince,
HttpServletRequest request) throws FileNotFoundException {
String filePath = request.getRequestURI().substring(11);

HttpHeaders headers = new HttpHeaders();

if (Boolean.TRUE.equals(noCache)) {
headers.setCacheControl("no-cache, no-store, must-revalidate");
headers.setPragma("no-cache");
headers.setExpires(0);
} else {
// 暂时缓存1天
headers.setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS));
headers.setExpires(Instant.ofEpochMilli(System.currentTimeMillis() + DateUtils.MILLIS_PER_DAY));
}

String name = getFileName(filePath);
headers.add("Content-Disposition",
String.format("attachment; filename=\"%s\"", new String(name.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)));

MediaType contentType = getContentType(filePath);
// 先找文件
if (StringUtils.isNotBlank(staticLocalPath)) {
File file = new File(staticLocalPath + filePath);

if (file.exists()) {
headers.setLastModified(file.lastModified());

return ResponseEntity.ok()
.headers(headers)
.contentLength(file.length())
.contentType(contentType)
.body(new InputStreamResource(new FileInputStream(file)));
}
}

// 再找资源目录
InputStream inputStream = getClass().getResourceAsStream("/static/" + filePath);
if (inputStream != null) {
return buildResource(inputStream, contentType, headers);
} else if (StringUtils.isNotBlank(defaultPath)) {
inputStream = getClass().getResourceAsStream("/static/" + defaultPath);
if (inputStream != null) {
return buildResource(inputStream, contentType, headers);
}
}

return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}

return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}
private String getFileName(String filePath) {
int pos = filePath.lastIndexOf("/");
if (pos >= 0) {
return filePath.substring(pos + 1);
}

private String getFileName(String filePath) {
int pos = filePath.lastIndexOf("/");
if (pos >= 0) {
return filePath.substring(pos + 1);
return filePath;
}

return filePath;
}

private ResponseEntity<InputStreamResource> buildResource(InputStream inputStream, MediaType contentType, HttpHeaders headers) {
return ResponseEntity.ok()
.headers(headers)
private ResponseEntity<InputStreamResource> buildResource(InputStream inputStream, MediaType contentType, HttpHeaders headers) {
return ResponseEntity.ok()
.headers(headers)
// .contentLength(file.length())
.contentType(contentType)
.body(new InputStreamResource(inputStream));
}

private static MediaType getContentType(String filePath) {
int pos = filePath.lastIndexOf(".");

if (pos >= 0) {
String fileExt = filePath.substring(pos + 1).toLowerCase();
switch (fileExt) {
case "htm":
case "html":
case "css":
return MediaType.TEXT_HTML;
case "js":
return APPLICATION_JAVASCRIPT;
case "txt":
return MediaType.TEXT_PLAIN;
case "pdf":
return MediaType.APPLICATION_PDF;
case "xml":
return MediaType.TEXT_XML;
case "gif":
return MediaType.IMAGE_GIF;
case "jpeg":
case "jpg":
return MediaType.IMAGE_JPEG;
case "png":
return MediaType.IMAGE_PNG;
default:
return MediaType.APPLICATION_OCTET_STREAM;
}
.contentType(contentType)
.body(new InputStreamResource(inputStream));
}

return MediaType.APPLICATION_OCTET_STREAM;
}
private static MediaType getContentType(String filePath) {
int pos = filePath.lastIndexOf(".");

if (pos >= 0) {
String fileExt = filePath.substring(pos + 1).toLowerCase();
switch (fileExt) {
case "htm":
case "html":
case "css":
return MediaType.TEXT_HTML;
case "js":
return APPLICATION_JAVASCRIPT;
case "txt":
return MediaType.TEXT_PLAIN;
case "pdf":
return MediaType.APPLICATION_PDF;
case "xml":
return MediaType.TEXT_XML;
case "gif":
return MediaType.IMAGE_GIF;
case "jpeg":
case "jpg":
return MediaType.IMAGE_JPEG;
case "png":
return MediaType.IMAGE_PNG;
default:
return MediaType.APPLICATION_OCTET_STREAM;
}
}

return MediaType.APPLICATION_OCTET_STREAM;
}
}

+ 118
- 118
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/FileUploadController.java View File

@@ -1,10 +1,12 @@
package cc.smtweb.system.bpm.spring.controller;

import cc.smtweb.framework.core.cache.redis.RedisManager;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.cache.redis.RedisManager;
import cc.smtweb.framework.core.session.SessionUtil;
import cc.smtweb.system.bpm.spring.dao.ImageAttachDao;
import cc.smtweb.system.bpm.spring.entity.FileDataVO;
import cc.smtweb.system.bpm.spring.entity.UploadDataVO;
import cc.smtweb.system.bpm.util.FilePathGenerator;
import cc.smtweb.system.bpm.util.FilePathInfo;
import cc.smtweb.system.bpm.util.MemMultipartFile;
@@ -13,8 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import cc.smtweb.system.bpm.spring.entity.FileDataVO;
import cc.smtweb.system.bpm.spring.entity.UploadDataVO;

import javax.servlet.http.HttpServletRequest;
import java.io.*;
@@ -23,135 +23,135 @@ import java.text.SimpleDateFormat;

@RestController
public class FileUploadController {
@Autowired
private FilePathGenerator filePathGenerator;

@Autowired
private DbEngine dbEngine;

@Autowired
private RedisManager redisManager;

@Autowired
private ImageAttachDao imageAttachDao;

// TODO: 权限处理,临时文件处理
@PostMapping("/fs/upload/{path}")
public R upload(@RequestParam("file") MultipartFile file, @PathVariable("path") String path,
@RequestParam(value="thumb", required=false) String thumb,
@RequestParam(value="thumbHeight", required=false) Integer thumbHeight,
@RequestParam(value="commit", required=false) Boolean insert,
@RequestParam(value="keepName", required=false) Boolean keepName,
HttpServletRequest request
) {
SessionUtil.checkSession(request, redisManager);
return uploadFile(path, file, ThumbImage.type(thumb), thumbHeight, insert, keepName);
}

@PostMapping("/fs/uploadImage/{path}")
public R upload(@RequestBody FileDataVO data, @PathVariable("path") String path,
@RequestParam(value="thumb", required=false) String thumb,
@RequestParam(value="thumbHeight", required=false) Integer thumbHeight,
@RequestParam(value="commit", required=false) Boolean insert,
HttpServletRequest request) {
SessionUtil.checkSession(request, redisManager);

MultipartFile file = MemMultipartFile.build(data.getData());
if (file == null) {
return R.error("数据内容格式有错");
@Autowired
private FilePathGenerator filePathGenerator;

@Autowired
private DbEngine dbEngine;

@Autowired
private RedisManager redisManager;

@Autowired
private ImageAttachDao imageAttachDao;

// TODO: 权限处理,临时文件处理
@PostMapping("/fs/upload/{path}")
public R upload(@RequestParam("file") MultipartFile file, @PathVariable("path") String path,
@RequestParam(value = "thumb", required = false) String thumb,
@RequestParam(value = "thumbHeight", required = false) Integer thumbHeight,
@RequestParam(value = "commit", required = false) Boolean insert,
@RequestParam(value = "keepName", required = false) Boolean keepName,
HttpServletRequest request
) {
SessionUtil.checkSession(request, redisManager);
return uploadFile(path, file, ThumbImage.type(thumb), thumbHeight, insert, keepName);
}

return uploadFile(path, file, ThumbImage.type(thumb), thumbHeight, insert, false);
}

@PostMapping("/fs/uploadAvatar/{path}")
public R uploadAvatar(@RequestParam("file") MultipartFile file, @PathVariable("path") String path,
@RequestParam(value="size", required=false) Integer size,
@RequestParam(value="commit", required=false) Boolean insert,
@RequestParam(value="keepName", required=false) Boolean keepName,
HttpServletRequest request) {
SessionUtil.checkSession(request, redisManager);
return uploadFile(path, file, ThumbImage.TYPE_AVATAR, size, insert, keepName);
}

// 保存文件和插入数据库数据
@PostMapping("/fs/commit/{path}")
public R commit(@RequestParam("file") MultipartFile file, @PathVariable("path") String path,
@RequestParam(value="thumb", required=false) String thumb,
@RequestParam(value="thumbHeight", required=false) Integer thumbHeight,
@RequestParam(value="keepName", required=false) Boolean keepName,
HttpServletRequest request) {
SessionUtil.checkSession(request, redisManager);
return uploadFile(path, file, ThumbImage.type(thumb), thumbHeight, true, keepName);
}

private R uploadFile(String path, MultipartFile file, int type, Integer size, Boolean insert, Boolean keepName) {
//获取上传时的文件名
String fileName = file.getOriginalFilename();

//判断文件是否为空
if(file.isEmpty() && fileName != null){
return R.error("文件为空");
}
@PostMapping("/fs/uploadImage/{path}")
public R upload(@RequestBody FileDataVO data, @PathVariable("path") String path,
@RequestParam(value = "thumb", required = false) String thumb,
@RequestParam(value = "thumbHeight", required = false) Integer thumbHeight,
@RequestParam(value = "commit", required = false) Boolean insert,
HttpServletRequest request) {
SessionUtil.checkSession(request, redisManager);

// 判断保持文件名不变
FilePathInfo fileInfo = filePathGenerator.make(path, fileName, Boolean.TRUE.equals(keepName));
MultipartFile file = MemMultipartFile.build(data.getData());
if (file == null) {
return R.error("数据内容格式有错");
}

// 注意是路径+文件名
File targetFile = new File(fileInfo.getFullFileName());
return uploadFile(path, file, ThumbImage.type(thumb), thumbHeight, insert, false);
}

try(InputStream inputStream = file.getInputStream(); OutputStream outputStream = new FileOutputStream(targetFile)) {
// 最后使用资源访问器FileCopyUtils的copy方法拷贝文件
FileCopyUtils.copy(inputStream, outputStream);
} catch (IOException e) {
//出现异常,则告诉页面失败
return R.error("上传失败", e);
@PostMapping("/fs/uploadAvatar/{path}")
public R uploadAvatar(@RequestParam("file") MultipartFile file, @PathVariable("path") String path,
@RequestParam(value = "size", required = false) Integer size,
@RequestParam(value = "commit", required = false) Boolean insert,
@RequestParam(value = "keepName", required = false) Boolean keepName,
HttpServletRequest request) {
SessionUtil.checkSession(request, redisManager);
return uploadFile(path, file, ThumbImage.TYPE_AVATAR, size, insert, keepName);
}

// 生成缩略图
// String contentType = file.getContentType();
UploadDataVO data = new UploadDataVO();

data.setPath(fileInfo.getMysqlFilePath());
data.setName(fileName);
data.setSize(file.getSize());
data.setContentType(file.getContentType());
data.setUrl(filePathGenerator.getFileUrl(fileInfo.getMysqlFilePath()));

if (type == ThumbImage.TYPE_THUMB || type == ThumbImage.TYPE_AVATAR) {
try {
imageAttachDao.makeThumb(data, type == ThumbImage.TYPE_THUMB, targetFile, size);
} catch (IOException e) {
return R.error("生成缩略图失败", e);
}
// 保存文件和插入数据库数据
@PostMapping("/fs/commit/{path}")
public R commit(@RequestParam("file") MultipartFile file, @PathVariable("path") String path,
@RequestParam(value = "thumb", required = false) String thumb,
@RequestParam(value = "thumbHeight", required = false) Integer thumbHeight,
@RequestParam(value = "keepName", required = false) Boolean keepName,
HttpServletRequest request) {
SessionUtil.checkSession(request, redisManager);
return uploadFile(path, file, ThumbImage.type(thumb), thumbHeight, true, keepName);
}

if (Boolean.TRUE.equals(insert)) {
Long id = dbEngine.nextId();
Timestamp now = new Timestamp(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
private R uploadFile(String path, MultipartFile file, int type, Integer size, Boolean insert, Boolean keepName) {
//获取上传时的文件名
String fileName = file.getOriginalFilename();

dbEngine.update("insert into sw_user.sys_attach(attach_id, attach_name, attach_path, attach_content_type, attach_size, attach_create_time) values(?, ?, ?, ?, ?, ?)",
id, data.getName(), data.getPath(), data.getContentType(), data.getSize(), sdf.format(now));
//判断文件是否为空
if (file.isEmpty() && fileName != null) {
return R.error("文件为空");
}

data.setId(id);
}
// 判断保持文件名不变
FilePathInfo fileInfo = filePathGenerator.make(path, fileName, Boolean.TRUE.equals(keepName));

return R.success(data);
}
// 注意是路径+文件名
File targetFile = new File(fileInfo.getFullFileName());

// TODO: 修改为安全的后台删除方式
@PostMapping("/fs/remove")
public R remove(@RequestParam(value="filePath") String filePath, HttpServletRequest request) {
SessionUtil.checkSession(request, redisManager);
try (InputStream inputStream = file.getInputStream(); OutputStream outputStream = new FileOutputStream(targetFile)) {
// 最后使用资源访问器FileCopyUtils的copy方法拷贝文件
FileCopyUtils.copy(inputStream, outputStream);
} catch (IOException e) {
//出现异常,则告诉页面失败
return R.error("上传失败", e);
}

File file = new File(filePathGenerator.getFileDiskPath(filePath));
if (file.exists() && file.isFile()) {
if (file.delete()) {
R.success(filePath);
}
// 生成缩略图
// String contentType = file.getContentType();
UploadDataVO data = new UploadDataVO();

data.setPath(fileInfo.getMysqlFilePath());
data.setName(fileName);
data.setSize(file.getSize());
data.setContentType(file.getContentType());
data.setUrl(filePathGenerator.getFileUrl(fileInfo.getMysqlFilePath()));

if (type == ThumbImage.TYPE_THUMB || type == ThumbImage.TYPE_AVATAR) {
try {
imageAttachDao.makeThumb(data, type == ThumbImage.TYPE_THUMB, targetFile, size);
} catch (IOException e) {
return R.error("生成缩略图失败", e);
}
}

if (Boolean.TRUE.equals(insert)) {
Long id = dbEngine.nextId();
Timestamp now = new Timestamp(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");

dbEngine.update("insert into sw_user.sys_attach(attach_id, attach_name, attach_path, attach_content_type, attach_size, attach_create_time) values(?, ?, ?, ?, ?, ?)",
id, data.getName(), data.getPath(), data.getContentType(), data.getSize(), sdf.format(now));

data.setId(id);
}

return R.success(data);
}

return R.success();
}
// TODO: 修改为安全的后台删除方式
@PostMapping("/fs/remove")
public R remove(@RequestParam(value = "filePath") String filePath, HttpServletRequest request) {
SessionUtil.checkSession(request, redisManager);

File file = new File(filePathGenerator.getFileDiskPath(filePath));
if (file.exists() && file.isFile()) {
if (file.delete()) {
R.success(filePath);
}
}

return R.success();
}
}

+ 44
- 44
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/dao/ImageAttachDao.java View File

@@ -1,63 +1,63 @@
package cc.smtweb.system.bpm.spring.dao;

import cc.smtweb.system.bpm.spring.entity.UploadDataVO;
import cc.smtweb.system.bpm.util.ThumbImage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import cc.smtweb.system.bpm.spring.entity.UploadDataVO;

import java.io.File;
import java.io.IOException;

@Service
public class ImageAttachDao {
public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";

public void makeThumb(UploadDataVO data, boolean isThumb, File targetFile, Integer size) throws IOException {
boolean imageType = false;
String fileName = data.getName();
String contentType = data.getContentType();

if (contentType.startsWith("image/")) {
imageType = true;
} else if (contentType.equals(APPLICATION_OCTET_STREAM)) {
String fileExt = fileName.substring(fileName.lastIndexOf("."));

if (StringUtils.isNotEmpty(fileExt)) {
switch (fileExt.toLowerCase()) {
case ".jpg":
case ".jpeg":
contentType = "image/jpg";
imageType = true;
break;
case ".gif":
contentType = "image/gif";
imageType = true;
break;
case ".png":
contentType = "image/png";
public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";

public void makeThumb(UploadDataVO data, boolean isThumb, File targetFile, Integer size) throws IOException {
boolean imageType = false;
String fileName = data.getName();
String contentType = data.getContentType();

if (contentType.startsWith("image/")) {
imageType = true;
break;
default:
break;
} else if (contentType.equals(APPLICATION_OCTET_STREAM)) {
String fileExt = fileName.substring(fileName.lastIndexOf("."));

if (StringUtils.isNotEmpty(fileExt)) {
switch (fileExt.toLowerCase()) {
case ".jpg":
case ".jpeg":
contentType = "image/jpg";
imageType = true;
break;
case ".gif":
contentType = "image/gif";
imageType = true;
break;
case ".png":
contentType = "image/png";
imageType = true;
break;
default:
break;
}

if (imageType) {
data.setContentType(contentType);
}
}
}

if (imageType) {
data.setContentType(contentType);
}
}
}
int thumbHeight = 80;
if (size != null) {
thumbHeight = (size > 500) ? 500: size;
}

if (imageType) {
int thumbHeight = 80;
if (size != null) {
thumbHeight = (size > 500) ? 500 : size;
}
ThumbImage thumbImage = new ThumbImage();

ThumbImage thumbImage = new ThumbImage();

thumbImage.makeThumb(isThumb, targetFile, thumbHeight);
data.setWidth(thumbImage.getImageWidth());
data.setHeight(thumbImage.getImageHeight());
thumbImage.makeThumb(isThumb, targetFile, thumbHeight);
data.setWidth(thumbImage.getImageWidth());
data.setHeight(thumbImage.getImageHeight());
}
}
}
}

+ 71
- 71
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/dao/SysAttachDao.java View File

@@ -14,101 +14,101 @@ import java.util.Map;

@Service
public class SysAttachDao {
@Autowired
private FilePathGenerator filePathGenerator;

@Autowired
private DbEngine dbEngine;

/**
* 获取文件本地文件路径
*
* @param filePath 相对路径
* @return 本地文件全路径
*/
public String getDiskPath(String filePath) {
return filePathGenerator.getFileDiskPath(filePath);
}

/**
* 获取访问文件的URL地址
*
* @param filePath 文件相对路径
* @return 文件URL地址
*/
public String getFileUrl(String filePath) {
return filePathGenerator.getFileUrl(filePath);
}

/**
* 获取访问文件的URL地址
*
* @param filePath 文件相对路径
* @param filePath 文件名
* @return 文件URL地址
*/
public String getFileUrl(String filePath, String fileName) {
return "/fs/download?path=" + UriEncoder.encode(filePath) + "&name=" + UriEncoder.encode(fileName);
}

public AttachPathPO get(Long id) {
if (id != null) {
return dbEngine.queryEntity("select attach_id, attach_name, attach_path, attach_content_type, attach_size, attach_create_time from sw_user.sys_attach where attach_id=?",
AttachPathPO.class, id);
@Autowired
private FilePathGenerator filePathGenerator;

@Autowired
private DbEngine dbEngine;

/**
* 获取文件本地文件路径
*
* @param filePath 相对路径
* @return 本地文件全路径
*/
public String getDiskPath(String filePath) {
return filePathGenerator.getFileDiskPath(filePath);
}

return null;
}
/**
* 获取访问文件的URL地址
*
* @param filePath 文件相对路径
* @return 文件URL地址
*/
public String getFileUrl(String filePath) {
return filePathGenerator.getFileUrl(filePath);
}

/**
* 获取访问文件的URL地址
*
* @param filePath 文件相对路径
* @param filePath 文件名
* @return 文件URL地址
*/
public String getFileUrl(String filePath, String fileName) {
return "/fs/download?path=" + UriEncoder.encode(filePath) + "&name=" + UriEncoder.encode(fileName);
}

public AttachPathPO get(Long id) {
if (id != null) {
return dbEngine.queryEntity("select attach_id, attach_name, attach_path, attach_content_type, attach_size, attach_create_time from sw_user.sys_attach where attach_id=?",
AttachPathPO.class, id);
}

return null;
}

// 删除文件记录和文件
public void remove(Long fileId) {
// 删除文件记录和文件
public void remove(Long fileId) {
// if (id != null) {
// return dbEngine.queryEntity("select attach_id, attach_name, attach_path, attach_content_type, attach_size, attach_create_time from sw_user.sys_attach where attach_id=?",
// AttachPathPO.class, id);
// }
//
// return null;
}
}

// 删除文件
public void remove(String filePath) {
// 删除文件
public void remove(String filePath) {
// if (id != null) {
// return dbEngine.queryEntity("select attach_id, attach_name, attach_path, attach_content_type, attach_size, attach_create_time from sw_user.sys_attach where attach_id=?",
// AttachPathPO.class, id);
// }
//
// return null;
}
}

public List<AttachPathPO> list(Long[] ids) {
if (ids != null && ids.length > 0) {
return dbEngine.query("select attach_id, attach_name, attach_path, attach_content_type, attach_size, attach_create_time from sw_user.sys_attach where attach_id in( "
+ StringUtils.join(ids, ",") + ")",
AttachPathPO.class);
}

public List<AttachPathPO> list(Long[] ids) {
if (ids != null && ids.length > 0) {
return dbEngine.query("select attach_id, attach_name, attach_path, attach_content_type, attach_size, attach_create_time from sw_user.sys_attach where attach_id in( "
+ StringUtils.join(ids, ",") + ")",
AttachPathPO.class);
return null;
}

return null;
}
public Map<Long, AttachPathPO> map(Long[] ids) {
List<AttachPathPO> list = list(ids);
if (list != null && !list.isEmpty()) {
Map<Long, AttachPathPO> map = new HashMap<>(list.size());
list.forEach((item) -> map.put(item.getAttachId(), item));

public Map<Long, AttachPathPO> map(Long[] ids) {
List<AttachPathPO> list = list(ids);
if (list != null && !list.isEmpty()) {
Map<Long, AttachPathPO> map = new HashMap<>(list.size());
list.forEach((item) -> map.put(item.getAttachId(), item));
return map;
}

return map;
return null;
}

return null;
}
// 保持文件,删除临时文件记录,避免被定时删除
public void retain(String filePath) {

// 保持文件,删除临时文件记录,避免被定时删除
public void retain(String filePath) {

}
}

// 保持文件,删除临时文件记录,避免被定时删除
public void retain(Long fileId) {
// 保持文件,删除临时文件记录,避免被定时删除
public void retain(Long fileId) {

}
}
}

+ 11
- 11
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/dataCacheInit/AttachFolderEntityBuffer.java View File

@@ -20,13 +20,13 @@ public final class AttachFolderEntityBuffer {
@Autowired
private DbEngine dbEngine;

public static final String cacheKey="attach_folder_";
public static final String cacheKey = "attach_folder_";


//根据附件路径和期间获取对象
public AttachFolderPojo getByPath(String attachPath, String period) {

return redisManager.get(cacheKey+attachPath + "_" + period, AttachFolderPojo.class);
return redisManager.get(cacheKey + attachPath + "_" + period, AttachFolderPojo.class);

}

@@ -45,27 +45,27 @@ public final class AttachFolderEntityBuffer {
}

//初始化数据
public void initData(){
public void initData() {
//查询所有数据
String sql="select folder_id,folder_path,folder_period,folder_max_seq,folder_file_count from "+ AttachFolder.ENTITY_NAME;
List<AttachFolder> returnList = dbEngine.query(sql,AttachFolder.class);
if(null !=returnList && returnList.size()>0){
for(AttachFolder pojo:returnList){
AttachFolderPojo p=new AttachFolderPojo();
String sql = "select folder_id,folder_path,folder_period,folder_max_seq,folder_file_count from " + AttachFolder.ENTITY_NAME;
List<AttachFolder> returnList = dbEngine.query(sql, AttachFolder.class);
if (null != returnList && returnList.size() > 0) {
for (AttachFolder pojo : returnList) {
AttachFolderPojo p = new AttachFolderPojo();
p.setFolderId(pojo.getId());
p.setFolderAttachPath(pojo.getPath());
p.setFolderFileCount(pojo.getFileCount());
p.setFolderPeriod(pojo.getPeriod());
p.setFolderMaxSeq(pojo.getMaxSeq());
redisManager.set(cacheKey+pojo.getPath()+"_"+pojo.getPeriod(),p,0);
redisManager.set(cacheKey + pojo.getPath() + "_" + pojo.getPeriod(), p, 0);
}
}
}

//写入一个数据
public void putOneData(AttachFolderPojo pojo){
public void putOneData(AttachFolderPojo pojo) {
//查询所有数据
redisManager.set(cacheKey+pojo.getFolderAttachPath()+"_"+pojo.getFolderPeriod(),pojo,0);
redisManager.set(cacheKey + pojo.getFolderAttachPath() + "_" + pojo.getFolderPeriod(), pojo, 0);
}

}

+ 6
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/entity/AttachPathPO.java View File

@@ -4,10 +4,10 @@ import lombok.Data;

@Data
public class AttachPathPO {
private Long attachId;
private String attachName;
private String attachPath;
private String attachContentType;
private Long attachSize;
private Long attachCreate;
private Long attachId;
private String attachName;
private String attachPath;
private String attachContentType;
private Long attachSize;
private Long attachCreate;
}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/entity/FileDataVO.java View File

@@ -4,5 +4,5 @@ import lombok.Data;

@Data
public class FileDataVO {
private String data;
private String data;
}

+ 8
- 8
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/entity/UploadDataVO.java View File

@@ -4,12 +4,12 @@ import lombok.Data;

@Data
public class UploadDataVO {
private Long id;
private Integer height;
private Integer width;
private long size;
private String path;
private String name;
private String contentType;
private String url;
private Long id;
private Integer height;
private Integer width;
private long size;
private String path;
private String name;
private String contentType;
private String url;
}

+ 6
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachFileWork.java View File

@@ -1,6 +1,6 @@
package cc.smtweb.system.bpm.spring.file.attach;

import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.spring.config.FileConfigProperties;
import cc.smtweb.system.bpm.util.UtilDownloadFile;
import cc.smtweb.system.bpm.util.UtilFile;
@@ -19,12 +19,13 @@ import java.util.List;
public final class AttachFileWork implements IAttachWorkIntf {
@Autowired
private FileConfigProperties properties;

private String getPath(String remoteFolderPath) {
String path =properties.getAttachPath();
if (PubUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/"))
String path = properties.getAttachPath();
if (StringUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/"))
path = path + "/" + remoteFolderPath;
else path = path + remoteFolderPath;
path = path.replaceAll("-","");
path = path.replaceAll("-", "");
UtilFile.makeDir(path);
if (!path.endsWith("/")) path = path + "/";
return path;
@@ -37,7 +38,7 @@ public final class AttachFileWork implements IAttachWorkIntf {
public void saveAttach(String remoteAttachName, String remoteFolderPath, String localAttach, boolean isDelLocal) throws Exception {
String dstFile = getFileName(remoteFolderPath, remoteAttachName);
if (isDelLocal) UtilFile.renameTo(localAttach, dstFile);
else UtilFile.copy(localAttach,dstFile);
else UtilFile.copy(localAttach, dstFile);
}

@Override


+ 4
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachFtpWork.java View File

@@ -1,6 +1,6 @@
package cc.smtweb.system.bpm.spring.file.attach;

import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.spring.config.FileConfigProperties;
import cc.smtweb.system.bpm.util.UtilDownloadFile;
import cc.smtweb.system.bpm.util.UtilFile;
@@ -31,9 +31,10 @@ public final class AttachFtpWork implements IAttachWorkIntf {
Logger logger = LoggerFactory.getLogger(AttachFtpWork.class);
@Autowired
private FileConfigProperties properties;

private String getPath(String remoteFolderPath) {
String path = properties.getAttachPath();
if (PubUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/"))
if (StringUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/"))
path = path + "/" + remoteFolderPath;
else path = path + remoteFolderPath;
path = path.replaceAll("-", "");
@@ -169,7 +170,7 @@ public final class AttachFtpWork implements IAttachWorkIntf {
getFtpManager().execute(new FtpTask() {
public Object execute(IFtpUtil ftp) throws Exception {
try {
ftp.downloadFileEx(getPath(remotePath), remoteName,localPath + File.separator + localName );
ftp.downloadFileEx(getPath(remotePath), remoteName, localPath + File.separator + localName);
} catch (Exception e) {
e.printStackTrace();
}


+ 49
- 46
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachHelper.java View File

@@ -1,10 +1,12 @@
package cc.smtweb.system.bpm.spring.file.attach;

import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.framework.core.util.NumberUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.spring.config.FileConfigProperties;
import cc.smtweb.system.bpm.util.UtilFile;
import cc.smtweb.system.bpm.util.UtilMath;
import cc.smtweb.system.bpm.web.sys.base.attach.AttachInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,8 +31,9 @@ public final class AttachHelper {
private DbEngine dbEngine;
@Autowired
private AttachUtil attachUtil;

//得到附件临时目录
public String getAttachTmpPath() {
public String getAttachTmpPath() {
String tmp_attach = properties.getAttachTempPath();
if (!tmp_attach.endsWith("/")) tmp_attach += "/";
File file = new File(tmp_attach);
@@ -41,10 +44,10 @@ public final class AttachHelper {
}

//删除ftp服务器的文件
public boolean deleteOneAttach(String attachId) throws Exception {
if (PubUtil.isEmpty(attachId)) return true;
public boolean deleteOneAttach(String attachId) throws Exception {
if (StringUtil.isEmpty(attachId)) return true;
AttachInfo attachInfo = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId));
if(null == attachInfo){
if (null == attachInfo) {
return true;
}
boolean deleteSuccess = deleteAttachInFtpServer(attachInfo.getPath(), attachInfo.getName());
@@ -55,7 +58,7 @@ public final class AttachHelper {
}

//删除ftp服务器的文件
public boolean deleteOneAttach(AttachInfo bean) {
public boolean deleteOneAttach(AttachInfo bean) {
boolean deleteSuccess = deleteAttachInFtpServer(bean.getPath(), bean.getName());
if (deleteSuccess) {
dbEngine.deleteEntity(bean);
@@ -64,41 +67,41 @@ public final class AttachHelper {
}

//删除ftp服务器的文件夹
public void deleteFolder(final String remotePath) throws Exception {
public void deleteFolder(final String remotePath) throws Exception {
attachUtil.deletePath(remotePath);
}

public List<AttachInfo> getAttachListByOwnerId(String ownerId) throws Exception {
return dbEngine.query("select * from "+AttachInfo.ENTITY_NAME+" where attach_owner_id=? ",AttachInfo.class,ownerId);
public List<AttachInfo> getAttachListByOwnerId(String ownerId) throws Exception {
return dbEngine.query("select * from " + AttachInfo.ENTITY_NAME + " where attach_owner_id=? ", AttachInfo.class, ownerId);
}

public List<AttachInfo> listAttachListByOwnerIdAndType(String ownerId, String attach_type) throws Exception {
return dbEngine.query("select * from "+AttachInfo.ENTITY_NAME+" where attach_owner_id=? and attach_type=? ",AttachInfo.class,ownerId,attach_type);
public List<AttachInfo> listAttachListByOwnerIdAndType(String ownerId, String attach_type) throws Exception {
return dbEngine.query("select * from " + AttachInfo.ENTITY_NAME + " where attach_owner_id=? and attach_type=? ", AttachInfo.class, ownerId, attach_type);
}

public int getAttachCountByOwnerId(String ownerId) throws Exception {
return dbEngine.queryInt("select count(0) from "+AttachInfo.ENTITY_NAME+" where attach_owner_id=? ",ownerId);
public int getAttachCountByOwnerId(String ownerId) throws Exception {
return dbEngine.queryInt("select count(0) from " + AttachInfo.ENTITY_NAME + " where attach_owner_id=? ", ownerId);
}

//根据附件拥有者和附件类型删除
public boolean deleteAttachByOwnerIdAndType(String ownerId, String attachType) throws Exception {
public boolean deleteAttachByOwnerIdAndType(String ownerId, String attachType) throws Exception {
final List<AttachInfo> list = listAttachListByOwnerIdAndType(ownerId, attachType);
return deleteAttachListEx(list);
}

public boolean deleteAttachByOwnerId(String ownerId) throws Exception {
public boolean deleteAttachByOwnerId(String ownerId) throws Exception {
final List<AttachInfo> list = getAttachListByOwnerId(ownerId);
return deleteAttachListEx(list);
}

//批量删除
public boolean deleteAttachList(List<String> attachIdList) throws Exception {
if (PubUtil.isEmpty(attachIdList)) return false;
dbEngine.update("delete from "+AttachInfo.ENTITY_NAME+" where attach_id in(" + PubUtil.getSqlInIds(attachIdList) + ")");
public boolean deleteAttachList(List<String> attachIdList) throws Exception {
if (CommUtil.isEmpty(attachIdList)) return false;
dbEngine.update("delete from " + AttachInfo.ENTITY_NAME + " where attach_id in(" + CommUtil.getSqlInStr(attachIdList) + ")");
return true;
}

public boolean deleteAttachListEx(List<AttachInfo> list) throws Exception {
public boolean deleteAttachListEx(List<AttachInfo> list) throws Exception {
boolean result = true;
for (AttachInfo bean : list) {
if (!deleteAttachInFtpServer(bean.getPath(), bean.getName())) {
@@ -115,7 +118,7 @@ public final class AttachHelper {
}

//删除在ftp服务器上的附件
public boolean deleteAttachInFtpServer(String remotePath, String remoteName) {
public boolean deleteAttachInFtpServer(String remotePath, String remoteName) {
try {
attachUtil.deleteAttach(remotePath, remoteName);
} catch (Exception e) {
@@ -133,7 +136,7 @@ public final class AttachHelper {
* @return 返回文件名
* @throws Exception
*/
public String getAttachFromFtp(final String attachId, final String localPath) throws Exception {
public String getAttachFromFtp(final String attachId, final String localPath) throws Exception {
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId));
if (null == attach) throw new Exception("附件不存在!");

@@ -153,7 +156,7 @@ public final class AttachHelper {
* @return 返回文件名
* @throws Exception
*/
public String getAttachFromFtp(final String attachId, final String localPath, String localName) throws Exception {
public String getAttachFromFtp(final String attachId, final String localPath, String localName) throws Exception {
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId));
if (null == attach) throw new Exception("附件不存在!");
final String remoteFileName = attach.getName();
@@ -172,7 +175,7 @@ public final class AttachHelper {
* @return 返回文件名列表,本地有此文件将不再下载
* @throws Exception
*/
private List<String> getAttachListFromFtp(final List<AttachInfo> attachlist, final String ownerType) throws Exception {
private List<String> getAttachListFromFtp(final List<AttachInfo> attachlist, final String ownerType) throws Exception {
return attachUtil.getAttachListFromFtp(attachlist, ownerType, getAttachTmpPath());
}

@@ -184,7 +187,7 @@ public final class AttachHelper {
* @return 返回文件名列表,本地有此文件将不再下载
* @throws Exception
*/
public List<String> getAttachsFromFtp(final String ownerId, final String ownerType) throws Exception {
public List<String> getAttachsFromFtp(final String ownerId, final String ownerType) throws Exception {
final List<AttachInfo> attachlist = getAttachListByOwnerId(ownerId);

return getAttachListFromFtp(attachlist, ownerType);
@@ -199,20 +202,20 @@ public final class AttachHelper {
* @return 返回文件名列表,本地有此文件将不再下载
* @throws Exception
*/
public List<String> getAttachsFromFtp(final List<String> attachIds, final String ownerType) throws Exception {
public List<String> getAttachsFromFtp(final List<String> attachIds, final String ownerType) throws Exception {
List<Object> paras = new ArrayList<Object>();
if (PubUtil.isNotEmpty(attachIds)) {
if (!CommUtil.isEmpty(attachIds)) {
StringBuilder sb = new StringBuilder(128);
for(int i=0;i<attachIds.size();i++){
if(i==0){
for (int i = 0; i < attachIds.size(); i++) {
if (i == 0) {
sb.append(" attach_id=? ");
}else{
} else {
sb.append(" or attach_id=? ");
}
paras.add(attachIds.get(i));
}
final List<AttachInfo> attachlist =dbEngine.queryWhere(AttachInfo.class,sb.toString(),paras.toArray());
if (null == attachlist || attachlist.size()<1) throw new Exception("附件不存在!");
final List<AttachInfo> attachlist = dbEngine.queryWhere(AttachInfo.class, sb.toString(), paras.toArray());
if (null == attachlist || attachlist.size() < 1) throw new Exception("附件不存在!");
return getAttachListFromFtp(attachlist, ownerType);
}
return new ArrayList<>();
@@ -223,12 +226,12 @@ public final class AttachHelper {
*
* @return
*/
public String getSizeStr(long fileSize) {
public String getSizeStr(long fileSize) {
if (fileSize < 1024) return fileSize + "B";
double n = fileSize * 1.0 / 1024;
if (UtilMath.compare(n, 1024) < 0) return UtilMath.toStdNumberString(n, 0) + "KB";
if (NumberUtil.compare(n, 1024) < 0) return NumberUtil.toStdNumberString(n, 0) + "KB";
n = n / 1024;
return UtilMath.toStdNumberString(n) + "MB";
return NumberUtil.toStdNumberString(n) + "MB";
}

/**
@@ -237,31 +240,31 @@ public final class AttachHelper {
* @param attach_owner_id 拥有者
* @throws Exception
*/
public void removeTempTag(String attach_owner_id) throws Exception {
dbEngine.update("update "+AttachInfo.ENTITY_NAME+" set attach_is_temp=0 WHERE attach_owner_id=? AND attach_is_temp=1 ",attach_owner_id);
public void removeTempTag(String attach_owner_id) throws Exception {
dbEngine.update("update " + AttachInfo.ENTITY_NAME + " set attach_is_temp=0 WHERE attach_owner_id=? AND attach_is_temp=1 ", attach_owner_id);
}

public String copyupload(String type,Long attachId) {
public String copyupload(String type, Long attachId) {
AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, attachId);
if(attach==null){
if (attach == null) {
return "";
}
String remoteName =attach.getId()+attach.getName().substring(attach.getName().lastIndexOf("."));
String remoteName = attach.getId() + attach.getName().substring(attach.getName().lastIndexOf("."));
String remotePath = attach.getPath();
String filePath =getAttachTmpPath()+"tempFiles/";
String filePath = getAttachTmpPath() + "tempFiles/";
UtilFile.makeDir(filePath);
Map<String, String> map = null;
try {
attachUtil.downloadAttach(remotePath, remoteName, filePath);
String filePaths=filePath+remoteName;
String filePaths = filePath + remoteName;

attach.setId(dbEngine.nextId());
attach.setType(type);//附件类别
attach.setOwnerId(-1l);//附件拥有者id
attach.setPartyId(-1l);
attach.setTime(PubUtil.getLastTime());
attach.setTime(DateUtil.nowDateTimeLong());
attach.setUserId(-1l);
attach.setName(attach.getId()+attach.getSuffix());
attach.setName(attach.getId() + attach.getSuffix());
// 上传文件域对象
File upload = new File(filePaths);
// attach.setAttachSize((long) FileCopyUtils.copy(file.getInputStream(), new BufferedOutputStream(new FileOutputStream(upload))));
@@ -274,10 +277,10 @@ public final class AttachHelper {
} finally {
UtilFile.delFile(upload.getAbsolutePath());
}
}catch (Exception e){
} catch (Exception e) {
logger.error("复制文件失败", e);
return "";
}
return attach.getId()+"";
return attach.getId() + "";
}
}

+ 17
- 16
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachUtil.java View File

@@ -3,7 +3,7 @@ package cc.smtweb.system.bpm.spring.file.attach;

import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.spring.config.FileConfigProperties;
import cc.smtweb.system.bpm.spring.dataCacheInit.AttachFolderEntityBuffer;
import cc.smtweb.system.bpm.web.sys.base.attach.AttachInfo;
@@ -24,7 +24,7 @@ import java.util.List;
public final class AttachUtil {
//一个文件夹下最多允许多少文件
private final static int MAX_FILE_COUNT = 1000;
private static IAttachWorkIntf worker;
private static IAttachWorkIntf worker;
@Autowired
private FileConfigProperties properties;
@Autowired
@@ -35,22 +35,23 @@ public final class AttachUtil {
private AttachFtpWork attachFtpWork;
@Autowired
private AttachFileWork attachFileWork;

static {
// init();
}

public void init() {
final String at = PubUtil.checkNull(properties.getAttachType()).toLowerCase();
public void init() {
final String at = StringUtil.checkNull(properties.getAttachType()).toLowerCase();
if ("ftp".equals(at) || "sftp".equals(at))
worker = attachFtpWork;
else worker = attachFileWork;
}

private void checkAttachFolder(final AttachInfo attach) throws Exception {
private void checkAttachFolder(final AttachInfo attach) throws Exception {
final String period = DateUtil.getNowYm();
AttachFolderPojo folder = attachFolderEntityBuffer.getByPath(attach.getPath(), period);

AttachFolder entity=new AttachFolder();
AttachFolder entity = new AttachFolder();
boolean isNew = false;
if (folder == null) {
isNew = true;
@@ -92,43 +93,43 @@ public final class AttachUtil {
}
}

public void saveAttach(String remoteAttachName, String remoteFolderPath, String localAttach, boolean isDelLocal) throws Exception {
public void saveAttach(String remoteAttachName, String remoteFolderPath, String localAttach, boolean isDelLocal) throws Exception {
worker.saveAttach(remoteAttachName, remoteFolderPath, localAttach, isDelLocal);
}

public void copyAttach(String srcFileName, String desFileName, String remoteFolderPath, boolean isDelSrc) throws Exception {
public void copyAttach(String srcFileName, String desFileName, String remoteFolderPath, boolean isDelSrc) throws Exception {
worker.copyAttach(srcFileName, desFileName, remoteFolderPath, isDelSrc);
}

public void deletePath(String remotePath) throws Exception {
public void deletePath(String remotePath) throws Exception {
worker.deletePath(remotePath);
}

public void deleteAttach(String remotePath, String remoteName) throws Exception {
public void deleteAttach(String remotePath, String remoteName) throws Exception {
worker.deleteAttach(remotePath, remoteName);
}

public void downloadAttach(String remotePath, String remoteName, String fileName, HttpServletResponse response) throws Exception {
public void downloadAttach(String remotePath, String remoteName, String fileName, HttpServletResponse response) throws Exception {
worker.downloadAttach(remotePath, remoteName, fileName, response);
}

public void downloadAttach(String remotePath, String remoteName, String localPath) throws Exception {
public void downloadAttach(String remotePath, String remoteName, String localPath) throws Exception {
worker.downloadAttach(remotePath, remoteName, localPath);
}

public void downloadAttach(String remotePath, String remoteName, String localPath, String localName) throws Exception {
public void downloadAttach(String remotePath, String remoteName, String localPath, String localName) throws Exception {
worker.downloadAttach(remotePath, remoteName, localPath, localName);
}

public List<String> getAttachListFromFtp(final List<AttachInfo> attachlist, final String ownerType, final String localRoot) throws Exception {
public List<String> getAttachListFromFtp(final List<AttachInfo> attachlist, final String ownerType, final String localRoot) throws Exception {
return worker.getAttachListFromFtp(attachlist, ownerType, localRoot);
}

public void makeRemoteDir(String path) throws Exception {
public void makeRemoteDir(String path) throws Exception {
worker.makeRemoteDir(path);
}

public Path getAttachPath(String remotePath, String remoteName) throws Exception {
public Path getAttachPath(String remotePath, String remoteName) throws Exception {
return worker.getAttachPath(remotePath, remoteName);
}



+ 4
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/IAttachWorkIntf.java View File

@@ -1,7 +1,6 @@
package cc.smtweb.system.bpm.spring.file.attach;



import cc.smtweb.system.bpm.web.sys.base.attach.AttachInfo;

import javax.servlet.http.HttpServletResponse;
@@ -28,10 +27,10 @@ public interface IAttachWorkIntf {
/**
* 复制附件
*
* @param srcFileName 源文件
* @param desFileName 新文件
* @param remoteFolderPath 文件路径
* @param isDelSrc 保存后是否删除源文件
* @param srcFileName 源文件
* @param desFileName 新文件
* @param remoteFolderPath 文件路径
* @param isDelSrc 保存后是否删除源文件
* @throws Exception
*/
void copyAttach(String srcFileName, String desFileName, String remoteFolderPath, boolean isDelSrc) throws Exception;
@@ -109,7 +108,6 @@ public interface IAttachWorkIntf {

/**
* 获取文件路径
*
*/
Path getAttachPath(String remotePath, String remoteName);
}

+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/initPlugin/RunDataInit.java View File

@@ -18,6 +18,7 @@ public class RunDataInit implements ApplicationRunner {
private AttachFolderEntityBuffer attachFolderEntityBuffer;
@Autowired
private AttachUtil attachUtil;

@Override
public void run(ApplicationArguments args) throws Exception {
attachFolderEntityBuffer.initData();//附件目录缓存


+ 81
- 81
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/BeanUtil.java View File

@@ -1,7 +1,7 @@
package cc.smtweb.system.bpm.util;

import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.exception.SwException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
@@ -17,104 +17,104 @@ import java.util.Arrays;
import java.util.List;

public class BeanUtil {
private BeanUtil() {}
private BeanUtil() {
}

public static void mapToBean(SwMap source, Object target) {
mapToBean(source, target, null);
}
public static void mapToBean(SwMap source, Object target) {
mapToBean(source, target, null);
}

private static void mapToBean(SwMap source, Object target, @Nullable Class<?> editable,
@Nullable String... ignoreProperties) throws BeansException {
Assert.notNull(source, "Source must not be null");
Assert.notNull(target, "Target must not be null");
private static void mapToBean(SwMap source, Object target, @Nullable Class<?> editable,
@Nullable String... ignoreProperties) throws BeansException {
Assert.notNull(source, "Source must not be null");
Assert.notNull(target, "Target must not be null");

Class<?> actualEditable = target.getClass();
if (editable != null) {
if (!editable.isInstance(target)) {
throw new IllegalArgumentException("Target class [" + target.getClass().getName() +
"] not assignable to Editable class [" + editable.getName() + "]");
}
actualEditable = editable;
}
PropertyDescriptor[] targetPds = BeanUtils.getPropertyDescriptors(actualEditable);
List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties) : null);
Class<?> actualEditable = target.getClass();
if (editable != null) {
if (!editable.isInstance(target)) {
throw new IllegalArgumentException("Target class [" + target.getClass().getName() +
"] not assignable to Editable class [" + editable.getName() + "]");
}
actualEditable = editable;
}
PropertyDescriptor[] targetPds = BeanUtils.getPropertyDescriptors(actualEditable);
List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties): null);

for (PropertyDescriptor targetPd : targetPds) {
Method writeMethod = targetPd.getWriteMethod();
if (writeMethod != null && (ignoreList == null || !ignoreList.contains(targetPd.getName()))) {
Object value = source.get(targetPd.getName());
for (PropertyDescriptor targetPd : targetPds) {
Method writeMethod = targetPd.getWriteMethod();
if (writeMethod != null && (ignoreList == null || !ignoreList.contains(targetPd.getName()))) {
Object value = source.get(targetPd.getName());

if (value == null || ClassUtils.isAssignable(writeMethod.getParameterTypes()[0], value.getClass())) {
try {
if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
writeMethod.setAccessible(true);
if (value == null || ClassUtils.isAssignable(writeMethod.getParameterTypes()[0], value.getClass())) {
try {
if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
writeMethod.setAccessible(true);
}
writeMethod.invoke(target, value);
} catch (Throwable ex) {
throw new FatalBeanException(
"Could not copy property '" + targetPd.getName() + "' from source to target", ex);
}
}
}
writeMethod.invoke(target, value);
} catch (Throwable ex) {
throw new FatalBeanException(
"Could not copy property '" + targetPd.getName() + "' from source to target", ex);
}
}
}
}
}

public static void beanToMap(Object source, SwMap target, @Nullable String... ignoreProperties) throws BeansException {
Assert.notNull(source, "Source must not be null");
Assert.notNull(target, "Target must not be null");
public static void beanToMap(Object source, SwMap target, @Nullable String... ignoreProperties) throws BeansException {
Assert.notNull(source, "Source must not be null");
Assert.notNull(target, "Target must not be null");

List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties) : null);
List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties): null);

PropertyDescriptor[] sourcePds = BeanUtils.getPropertyDescriptors(source.getClass());
PropertyDescriptor[] sourcePds = BeanUtils.getPropertyDescriptors(source.getClass());

for (PropertyDescriptor sourcePd: sourcePds) {
if (ignoreList == null || !ignoreList.contains(sourcePd.getName())) {
for (PropertyDescriptor sourcePd : sourcePds) {
if (ignoreList == null || !ignoreList.contains(sourcePd.getName())) {
// PropertyDescriptor sourcePd = BeanUtils.getPropertyDescriptor(source.getClass(), targetPd.getKey());
// if (sourcePd != null) {
Method readMethod = sourcePd.getReadMethod();
if (readMethod != null) {
try {
if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
readMethod.setAccessible(true);
}
Object value = readMethod.invoke(source);
target.put(sourcePd.getName(), value);
}
catch (Throwable ex) {
throw new FatalBeanException(
"Could not copy property '" + sourcePd.getName() + "' from source to target", ex);
}
}
Method readMethod = sourcePd.getReadMethod();
if (readMethod != null) {
try {
if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
readMethod.setAccessible(true);
}
Object value = readMethod.invoke(source);
target.put(sourcePd.getName(), value);
} catch (Throwable ex) {
throw new FatalBeanException(
"Could not copy property '" + sourcePd.getName() + "' from source to target", ex);
}
}
// }
}
}
}
}
}

public static List<?> toBeanList(List<SwMap> bodyList, Class<?> clazz) {
List<Object> beans = new ArrayList<>(bodyList.size());
try {
for (SwMap body: bodyList) {
Object bean = clazz.newInstance();
BeanUtil.mapToBean(body, bean);
beans.add(bean);
}
} catch (InstantiationException | IllegalAccessException e) {
throw new SwException(e);
public static List<?> toBeanList(List<SwMap> bodyList, Class<?> clazz) {
List<Object> beans = new ArrayList<>(bodyList.size());
try {
for (SwMap body : bodyList) {
Object bean = clazz.newInstance();
BeanUtil.mapToBean(body, bean);
beans.add(bean);
}
} catch (InstantiationException | IllegalAccessException e) {
throw new SwException(e);
}
return beans;
}
return beans;
}

public static List<SwMap> toMapList(List<?> beans) {
List<SwMap> bodyList = null;
if (beans != null) {
bodyList = new ArrayList<>(beans.size());
for (Object bean: beans) {
SwMap body = new SwMap();
beanToMap(bean, body);
bodyList.add(body);
}
}
public static List<SwMap> toMapList(List<?> beans) {
List<SwMap> bodyList = null;
if (beans != null) {
bodyList = new ArrayList<>(beans.size());
for (Object bean : beans) {
SwMap body = new SwMap();
beanToMap(bean, body);
bodyList.add(body);
}
}

return bodyList;
}
return bodyList;
}
}

+ 1
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java View File

@@ -1,9 +1,9 @@
package cc.smtweb.system.bpm.util;

import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.exception.SwException;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateMethodModelEx;
@@ -12,7 +12,6 @@ import org.apache.commons.io.IOUtils;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;



+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/FileDynPath.java View File

@@ -53,7 +53,7 @@ public class FileDynPath extends FileFixPath {
// 如果文件数量太大就需要创建新子目录
while (this.fileCount >= MAX_FILE_COUNT) {
this.pathIndex++;
if(this.pathIndex > MAX_DIR_COUNT) {
if (this.pathIndex > MAX_DIR_COUNT) {
throw new RuntimeException("dir is two many");
}



+ 63
- 62
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/FilePathGenerator.java View File

@@ -1,16 +1,16 @@
package cc.smtweb.system.bpm.util;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;

import cc.smtweb.framework.core.db.jdbc.IdGenerator;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.tika.mime.MimeType;
import org.apache.tika.mime.MimeTypeException;
import org.apache.tika.mime.MimeTypes;
import org.springframework.web.multipart.MultipartFile;
import cc.smtweb.framework.core.db.jdbc.IdGenerator;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;

/**
* 文件名生成规则 subDir/[yyyymm]/[d]/[hex(fileid)]_[hex(rand)].[fileExt] 如果文件是图片格式,会生成缩略图,文件名会直接添加.thumb.jpg后缀 规则参数 yyyymm:
@@ -19,50 +19,51 @@ import cc.smtweb.framework.core.db.jdbc.IdGenerator;
@Slf4j
public class FilePathGenerator {

public static final String THUMB_FILE_EXT = ".thumb.jpg";
// 文件时间是否作为PK
private SimpleDateFormat sdf;
@Getter
private String rootPath;
private Map<String, FileFixPath> fileFxPathMap = new HashMap<>();
private Map<String, FileDynPath> fileDynPathMap = new HashMap<>();
private String fileUrl;
private IdGenerator idGenerator;

public FilePathGenerator(String rootPath, String fileUrl, IdGenerator idGenerator) {
this.fileUrl = fixEnd(fileUrl);
this.idGenerator = idGenerator;
this.rootPath = fixEnd(rootPath);

sdf = new SimpleDateFormat("yyyyMM/dd/");
}

private static String fixEnd(String path) {
if (path.endsWith("/") || path.endsWith("\\")) {
return path;
} else {
return path + "/";
}
}

/**
* 生成文件路径,根据日期分目录存储
*
* @param subPath 子目录,区分不同应用的文件
* @param originalFileName 原始的文件名,用于提取扩展名用
* @return 文件路径信息类
*/
public FilePathInfo make(String subPath, String originalFileName) {
return make(subPath, originalFileName, null, false);
}

public FilePathInfo make(String subPath, String originalFileName, boolean keepName) {
return make(subPath, originalFileName, null, keepName);
}
public static final String THUMB_FILE_EXT = ".thumb.jpg";
// 文件时间是否作为PK
private SimpleDateFormat sdf;
@Getter
private String rootPath;
private Map<String, FileFixPath> fileFxPathMap = new HashMap<>();
private Map<String, FileDynPath> fileDynPathMap = new HashMap<>();
private String fileUrl;
private IdGenerator idGenerator;

public FilePathGenerator(String rootPath, String fileUrl, IdGenerator idGenerator) {
this.fileUrl = fixEnd(fileUrl);
this.idGenerator = idGenerator;
this.rootPath = fixEnd(rootPath);

sdf = new SimpleDateFormat("yyyyMM/dd/");
}

private static String fixEnd(String path) {
if (path.endsWith("/") || path.endsWith("\\")) {
return path;
} else {
return path + "/";
}
}

/**
* 生成文件路径,根据日期分目录存储
*
* @param subPath 子目录,区分不同应用的文件
* @param subPath 子目录,区分不同应用的文件
* @param originalFileName 原始的文件名,用于提取扩展名用
* @return 文件路径信息类
*/
public FilePathInfo make(String subPath, String originalFileName) {
return make(subPath, originalFileName, null, false);
}

public FilePathInfo make(String subPath, String originalFileName, boolean keepName) {
return make(subPath, originalFileName, null, keepName);
}

/**
* 生成文件路径,根据日期分目录存储
*
* @param subPath 子目录,区分不同应用的文件
* @param multipartFile 上传文件流,用于提取扩展名用
* @return 文件路径信息类
*/
@@ -71,23 +72,23 @@ public class FilePathGenerator {
}

private synchronized FilePathInfo make(String subPath, String originFileName, String contentType, boolean keepName) {
if (keepName) {
FileFixPath filePathSub = fileFxPathMap.get(subPath);
if (filePathSub == null) {
filePathSub = new FileFixPath(this.rootPath, subPath);
fileFxPathMap.put(subPath, filePathSub);
}
if (keepName) {
FileFixPath filePathSub = fileFxPathMap.get(subPath);
if (filePathSub == null) {
filePathSub = new FileFixPath(this.rootPath, subPath);
fileFxPathMap.put(subPath, filePathSub);
}

return filePathSub.makeDatePath(this.idGenerator.nextId(), originFileName);
} else {
FileDynPath filePathSub = fileDynPathMap.get(subPath);
if (filePathSub == null) {
filePathSub = new FileDynPath(this.rootPath, subPath, sdf);
fileDynPathMap.put(subPath, filePathSub);
}
return filePathSub.makeDatePath(this.idGenerator.nextId(), originFileName);
} else {
FileDynPath filePathSub = fileDynPathMap.get(subPath);
if (filePathSub == null) {
filePathSub = new FileDynPath(this.rootPath, subPath, sdf);
fileDynPathMap.put(subPath, filePathSub);
}

return filePathSub.makeDatePath(this.idGenerator.nextId(), ext(originFileName, contentType));
}
return filePathSub.makeDatePath(this.idGenerator.nextId(), ext(originFileName, contentType));
}
}

private static String ext(String filename, String contentType) {
@@ -127,6 +128,6 @@ public class FilePathGenerator {

// 获取下载路径前缀
public String getDownloadUrl() {
return this.fileUrl;
return this.fileUrl;
}
}

+ 32
- 32
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/FilePathInfo.java View File

@@ -9,40 +9,40 @@ import lombok.Getter;
*/
@Getter
public class FilePathInfo {
// 文件ID
private long fileId;
// 文件创建时间,数据库需要存储
private long fileTime;
// 文件子路径
private String subPath;
// 文件名
private String fileName;
// 本地根路径
private String rootPath;
// 文件ID
private long fileId;
// 文件创建时间,数据库需要存储
private long fileTime;
// 文件子路径
private String subPath;
// 文件名
private String fileName;
// 本地根路径
private String rootPath;

public FilePathInfo(String rootPath, String subPath, long fileTime, String fileName, long fileId) {
this.rootPath = rootPath;
this.subPath = subPath;
this.fileTime = fileTime;
this.fileName = fileName;
this.fileId = fileId;
}
public FilePathInfo(String rootPath, String subPath, long fileTime, String fileName, long fileId) {
this.rootPath = rootPath;
this.subPath = subPath;
this.fileTime = fileTime;
this.fileName = fileName;
this.fileId = fileId;
}

/**
* 获取本地需要存储的文件全路径
*/
public String getFullFileName() {
return getDiskFilePath();
}
/**
* 获取本地需要存储的文件全路径
*/
public String getFullFileName() {
return getDiskFilePath();
}

public String getDiskFilePath() {
return this.rootPath + subPath + fileName;
}
public String getDiskFilePath() {
return this.rootPath + subPath + fileName;
}

/**
* 获取数据库存储需要的文件全路径
*/
public String getMysqlFilePath() {
return subPath + fileName;
}
/**
* 获取数据库存储需要的文件全路径
*/
public String getMysqlFilePath() {
return subPath + fileName;
}
}

+ 37
- 29
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ITreeDataHandler.java View File

@@ -4,42 +4,50 @@ import java.util.List;

/**
* 树型节点句柄
*
* @author xkliu
*/
public interface ITreeDataHandler<T> {
/**
* 获取ID
* @param node 节点
* @return 节点ID
*/
Long getId(T node);
/**
* 获取ID
*
* @param node 节点
* @return 节点ID
*/
Long getId(T node);

/**
* 获取上级ID
* @param node 当前节点
* @return 上级ID
*/
Long getParentId(T node);
/**
* 获取上级ID
*
* @param node 当前节点
* @return 上级ID
*/
Long getParentId(T node);

// void addChild(IWebTreeVO item);

/**
* 获取下级对象列表
* @param node 当前节点
* @return 下级对象列表
*/
List<T> getChildren(T node);
/**
* 获取下级对象列表
*
* @param node 当前节点
* @return 下级对象列表
*/
List<T> getChildren(T node);

/**
* 设置下级对象列表
* @param children 下级对象列表
*/
void setChildren(T node, List<T> children);
/**
* 设置下级对象列表
*
* @param children 下级对象列表
*/
void setChildren(T node, List<T> children);

/**
* 是否强行添加未找到上级的错误节点到顶级
* @param node 通过node有parentId值,但未找到对应上级节点
* @return 是否强行添加错误节点到顶级
*/
default boolean forceAdd(T node) { return false; }
/**
* 是否强行添加未找到上级的错误节点到顶级
*
* @param node 通过node有parentId值,但未找到对应上级节点
* @return 是否强行添加错误节点到顶级
*/
default boolean forceAdd(T node) {
return false;
}
}

+ 3
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ITreeDataLevelHandler.java View File

@@ -1,6 +1,7 @@
package cc.smtweb.system.bpm.util;

public interface ITreeDataLevelHandler<T> extends ITreeDataHandler<T> {
int getLevel(T t);
void setLevel(T t, int level);
int getLevel(T t);

void setLevel(T t, int level);
}

+ 4
- 7
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/IdeaUtil.java View File

@@ -1,18 +1,13 @@
package cc.smtweb.system.bpm.util;


import cc.smtweb.framework.core.common.SwMap;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.Data;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -23,6 +18,7 @@ import java.util.Map;
*/
public class IdeaUtil {
private final static int MODE_POM = 1;

//获取工程中的Module文件
public static Map<String, String> getModules(String ideaPath, int mode) {
if (mode == MODE_POM) {
@@ -41,7 +37,7 @@ public class IdeaUtil {
Map<String, String> map = new HashMap<>();
PomProject project = XmlUtil.readValue(file, PomProject.class);
if (project == null || project.modules == null) return map;
for (String module: project.modules) {
for (String module : project.modules) {
File f = new File(ideaPath + "/" + module);
String s = f.getName();
int i = s.lastIndexOf(".");
@@ -50,11 +46,12 @@ public class IdeaUtil {
}
return map;
}

public static Map<String, String> getModulesFromModule(String ideaPath, File file) {
Map<String, String> map = new HashMap<>();
IdeaProject project = XmlUtil.readValue(file, IdeaProject.class);
if (project == null || project.component == null || project.component.modules == null) return map;
for (Module module: project.component.modules) {
for (Module module : project.component.modules) {
String s = module.filepath.replace("$PROJECT_DIR$", ideaPath);
File f = new File(s);
s = f.getName();


+ 56
- 56
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/MemMultipartFile.java View File

@@ -6,74 +6,74 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.*;

public class MemMultipartFile implements MultipartFile {
private static final String DATA_IMAGE = "data:image/";
private byte[] data;
private String contentType;
private String filename;
private static final String DATA_IMAGE = "data:image/";
private byte[] data;
private String contentType;
private String filename;

public static MemMultipartFile build(String dataUrl) {
if (dataUrl != null && dataUrl.startsWith(DATA_IMAGE)) {
// data:image/png;base64,
int pos1 = dataUrl.indexOf(';', DATA_IMAGE.length());
int pos2 = dataUrl.indexOf(',', DATA_IMAGE.length());
if (pos1 > 0 && pos2 > pos1) {
byte[] data = Base64.decodeBase64(dataUrl.substring(pos2));
public static MemMultipartFile build(String dataUrl) {
if (dataUrl != null && dataUrl.startsWith(DATA_IMAGE)) {
// data:image/png;base64,
int pos1 = dataUrl.indexOf(';', DATA_IMAGE.length());
int pos2 = dataUrl.indexOf(',', DATA_IMAGE.length());
if (pos1 > 0 && pos2 > pos1) {
byte[] data = Base64.decodeBase64(dataUrl.substring(pos2));

if (data != null) {
String contentType = dataUrl.substring(5, pos1);
return new MemMultipartFile(contentType.replace('/', '.'), contentType, data);
if (data != null) {
String contentType = dataUrl.substring(5, pos1);
return new MemMultipartFile(contentType.replace('/', '.'), contentType, data);
}
}
}
}
}

return null;
}
return null;
}

private MemMultipartFile(String filename, String contentType, byte[] data) {
this.data = data;
this.contentType = contentType;
this.filename = filename;
}
private MemMultipartFile(String filename, String contentType, byte[] data) {
this.data = data;
this.contentType = contentType;
this.filename = filename;
}

@Override
public String getName() {
return "data";
}
@Override
public String getName() {
return "data";
}

@Override
public String getOriginalFilename() {
return filename;
}
@Override
public String getOriginalFilename() {
return filename;
}

@Override
public String getContentType() {
return contentType;
}
@Override
public String getContentType() {
return contentType;
}

@Override
public boolean isEmpty() {
return data.length == 0;
}
@Override
public boolean isEmpty() {
return data.length == 0;
}

@Override
public long getSize() {
return data.length;
}
@Override
public long getSize() {
return data.length;
}

@Override
public byte[] getBytes() throws IOException {
return data;
}
@Override
public byte[] getBytes() throws IOException {
return data;
}

@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(data);
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(data);
}

@Override
public void transferTo(File file) throws IOException, IllegalStateException {
try(FileOutputStream os = new FileOutputStream(file)) {
os.write(data);
@Override
public void transferTo(File file) throws IOException, IllegalStateException {
try (FileOutputStream os = new FileOutputStream(file)) {
os.write(data);
}
}
}
}

+ 88
- 87
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ThumbImage.java View File

@@ -1,13 +1,5 @@
package cc.smtweb.system.bpm.util;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.List;

import javax.imageio.ImageIO;

import lombok.Getter;
import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Positions;
@@ -15,95 +7,104 @@ import net.coobird.thumbnailator.resizers.configurations.Antialiasing;
import net.sf.image4j.codec.ico.ICODecoder;
import org.apache.commons.lang3.StringUtils;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.List;

/**
* 缩略图生成工具
*
* @author xkliu
*/
@Getter
public class ThumbImage {
// 图片处理方式
public static final int TYPE_DEFAULT = 1;
public static final int TYPE_THUMB = 2;
public static final int TYPE_AVATAR = 3;

private int imageWidth;
private int imageHeight;

public static int type(String thumb) {
// 解决历史遗留boolean类型
if (StringUtils.isBlank(thumb) || "false".equalsIgnoreCase(thumb)) {
return TYPE_DEFAULT;
}

if ("true".equalsIgnoreCase(thumb)) {
return TYPE_THUMB;
}

return Integer.parseInt(thumb);
}

public void makeThumb(boolean isThumb, File file, int size) throws IOException {
makeThumb(file, size, size, isThumb);
}
// 后台等比压缩后大小最好控制在20k以内
public void makeThumb(File file, int w, int h, boolean keepAspectRatio) throws IOException {
String fileName = file.getName().toLowerCase();

BufferedImage image;

if (fileName.endsWith(".ico")) {
List<BufferedImage> images = ICODecoder.read(file);
image = images.get(images.size() - 1);
} else {
image = ImageIO.read(file);
}

imageWidth = image.getWidth();
imageHeight = image.getHeight();

if (fileName.endsWith(".png") || fileName.endsWith(".gif")) {
// 把透明的图填充白色背景
BufferedImage newBufferedImage = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
newBufferedImage.createGraphics().drawImage(image, 0, 0, Color.WHITE, null);
image = newBufferedImage;
}

Thumbnails.Builder<BufferedImage> builder = Thumbnails.of(image);

if (keepAspectRatio) {
if (h > 0) {
// 高度为基准调整宽度到达原图缩放比例
int imageR = imageWidth * 1000 / imageHeight;
w = h * imageR / 1000;
} else {
// 宽度为基准调整宽度到达原图缩放比例
int imageR = imageHeight * 1000 / imageWidth;
h = w * imageR / 1000;
}
// 图片处理方式
public static final int TYPE_DEFAULT = 1;
public static final int TYPE_THUMB = 2;
public static final int TYPE_AVATAR = 3;

private int imageWidth;
private int imageHeight;

public static int type(String thumb) {
// 解决历史遗留boolean类型
if (StringUtils.isBlank(thumb) || "false".equalsIgnoreCase(thumb)) {
return TYPE_DEFAULT;
}

if ("true".equalsIgnoreCase(thumb)) {
return TYPE_THUMB;
}

return Integer.parseInt(thumb);
}

public void makeThumb(boolean isThumb, File file, int size) throws IOException {
makeThumb(file, size, size, isThumb);
}

// 后台等比压缩后大小最好控制在20k以内
public void makeThumb(File file, int w, int h, boolean keepAspectRatio) throws IOException {
String fileName = file.getName().toLowerCase();

BufferedImage image;

if (fileName.endsWith(".ico")) {
List<BufferedImage> images = ICODecoder.read(file);
image = images.get(images.size() - 1);
} else {
image = ImageIO.read(file);
}

imageWidth = image.getWidth();
imageHeight = image.getHeight();

if (fileName.endsWith(".png") || fileName.endsWith(".gif")) {
// 把透明的图填充白色背景
BufferedImage newBufferedImage = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
newBufferedImage.createGraphics().drawImage(image, 0, 0, Color.WHITE, null);
image = newBufferedImage;
}

Thumbnails.Builder<BufferedImage> builder = Thumbnails.of(image);

if (keepAspectRatio) {
if (h > 0) {
// 高度为基准调整宽度到达原图缩放比例
int imageR = imageWidth * 1000 / imageHeight;
w = h * imageR / 1000;
} else {
// 宽度为基准调整宽度到达原图缩放比例
int imageR = imageHeight * 1000 / imageWidth;
h = w * imageR / 1000;
}

// int r = w * 1000 / h;
// int imageR = imageWidth * 1000 / imageHeight;
// if (r != imageR) {
// w = imageHeight * r / 1000;
// }
} else {
int r = w * 1000 / h;
int imageR = imageWidth * 1000 / imageHeight;
if (r != imageR) {
int width = imageWidth;
int height = imageHeight;
if (r > imageR) {
width = imageHeight * r / 1000;
} else {
height = imageWidth * 1000 / r;
}
builder.sourceRegion(Positions.CENTER, width, height);
}
}
builder.size(w, h).antialiasing(Antialiasing.ON).outputFormat("jpg").outputQuality(0.9)
.toFile(file.getAbsolutePath() + FilePathGenerator.THUMB_FILE_EXT);
}
} else {
int r = w * 1000 / h;
int imageR = imageWidth * 1000 / imageHeight;
if (r != imageR) {
int width = imageWidth;
int height = imageHeight;
if (r > imageR) {
width = imageHeight * r / 1000;
} else {
height = imageWidth * 1000 / r;
}
builder.sourceRegion(Positions.CENTER, width, height);
}
}
builder.size(w, h).antialiasing(Antialiasing.ON).outputFormat("jpg").outputQuality(0.9)
.toFile(file.getAbsolutePath() + FilePathGenerator.THUMB_FILE_EXT);
}
}

+ 166
- 164
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/TreeDataUtil.java View File

@@ -6,212 +6,214 @@ import java.util.function.Consumer;

/**
* 树结构数据创建器
*
* @author xkliu
*/
public class TreeDataUtil {
private TreeDataUtil(){}

public static boolean longEquals(Long l1, Long l2) {
if (l1 != null) {
return l1.equals(l2);
private TreeDataUtil() {
}

return l2 == null;
}
public static boolean longEquals(Long l1, Long l2) {
if (l1 != null) {
return l1.equals(l2);
}

private static <T> boolean findAndAdd(T parent, T item, ITreeDataHandler<T> handler) {
if (longEquals(handler.getId(parent), handler.getParentId(item))) {
addChild(parent, item, handler);
return true;
} else {
List<T> children = handler.getChildren(parent);
return l2 == null;
}

if (children != null) {
for (T child : children) {
if (findAndAdd(child, item, handler)) {
private static <T> boolean findAndAdd(T parent, T item, ITreeDataHandler<T> handler) {
if (longEquals(handler.getId(parent), handler.getParentId(item))) {
addChild(parent, item, handler);
return true;
}
} else {
List<T> children = handler.getChildren(parent);

if (children != null) {
for (T child : children) {
if (findAndAdd(child, item, handler)) {
return true;
}
}
}
}
}
}

return false;
}

private static <T> boolean findAndAddLevel(T parent, T item, ITreeDataLevelHandler<T> handler) {
if (longEquals(handler.getId(parent), handler.getParentId(item))) {
addChildLevel(parent, item, handler);
return true;
} else {
List<T> children = handler.getChildren(parent);
return false;
}

if (children != null) {
for (T child : children) {
if (findAndAddLevel(child, item, handler)) {
private static <T> boolean findAndAddLevel(T parent, T item, ITreeDataLevelHandler<T> handler) {
if (longEquals(handler.getId(parent), handler.getParentId(item))) {
addChildLevel(parent, item, handler);
return true;
}
} else {
List<T> children = handler.getChildren(parent);

if (children != null) {
for (T child : children) {
if (findAndAddLevel(child, item, handler)) {
return true;
}
}
}
}
}

return false;
}

return false;
}
private static <T> void addChild(T parent, T item, ITreeDataHandler<T> handler) {
List<T> children = handler.getChildren(parent);
if (children == null) {
children = new ArrayList<>();
handler.setChildren(parent, children);
}

private static <T> void addChild(T parent, T item, ITreeDataHandler<T> handler) {
List<T> children = handler.getChildren(parent);
if (children == null) {
children = new ArrayList<>();
handler.setChildren(parent, children);
children.add(item);
}

children.add(item);
}
private static <T> void addChildLevel(T parent, T item, ITreeDataLevelHandler<T> handler) {
List<T> children = handler.getChildren(parent);
if (children == null) {
children = new ArrayList<>();
handler.setChildren(parent, children);
}

private static <T> void addChildLevel(T parent, T item, ITreeDataLevelHandler<T> handler) {
List<T> children = handler.getChildren(parent);
if (children == null) {
children = new ArrayList<>();
handler.setChildren(parent, children);
updateLevel(item, handler.getLevel(parent) + 1, handler);
children.add(item);
}

updateLevel(item, handler.getLevel(parent) + 1, handler);
children.add(item);
}

private static <T> void updateLevel(T parent, int parentLevel, ITreeDataLevelHandler<T> handler) {
handler.setLevel(parent, parentLevel);
List<T> children = handler.getChildren(parent);
if (children != null) {
int level = parentLevel + 1;
for (T t: children) {
handler.setLevel(t, level);
updateLevel(t, level, handler);
}
}
}

// 读取树结构
public static <T> List<T> buildTree(T root, List<T> list, ITreeDataHandler<T> handler) {
if (list != null) {
for (T item: list) {
if (!findAndAdd(root, item, handler)) {
for (T it: list) {
if (longEquals(handler.getId(it), handler.getParentId(item))) {
addChild(it, item, handler);
item = null;
break;
private static <T> void updateLevel(T parent, int parentLevel, ITreeDataLevelHandler<T> handler) {
handler.setLevel(parent, parentLevel);
List<T> children = handler.getChildren(parent);
if (children != null) {
int level = parentLevel + 1;
for (T t : children) {
handler.setLevel(t, level);
updateLevel(t, level, handler);
}
}

// not find item parent
if (item != null && handler.forceAdd(item)) {
addChild(root, item, handler);
}
}
}
}

return handler.getChildren(root);
}

// 读取树结构
public static <T> List<T> buildLevelTree(T root, List<T> list, ITreeDataLevelHandler<T> handler) {
if (list != null) {
handler.setLevel(root, 0);
for (T item: list) {
if (!findAndAddLevel(root, item, handler)) {
for (T it: list) {
if (longEquals(handler.getId(it), handler.getParentId(item))) {
addChildLevel(it, item, handler);
item = null;
break;
// 读取树结构
public static <T> List<T> buildTree(T root, List<T> list, ITreeDataHandler<T> handler) {
if (list != null) {
for (T item : list) {
if (!findAndAdd(root, item, handler)) {
for (T it : list) {
if (longEquals(handler.getId(it), handler.getParentId(item))) {
addChild(it, item, handler);
item = null;
break;
}
}

// not find item parent
if (item != null && handler.forceAdd(item)) {
addChild(root, item, handler);
}
}
}
}

// not find item parent
if (item != null && handler.forceAdd(item)) {
addChildLevel(root, item, handler);
}
}
}

return handler.getChildren(root);
}

return handler.getChildren(root);
}
// 读取树结构
public static <T> List<T> buildLevelTree(T root, List<T> list, ITreeDataLevelHandler<T> handler) {
if (list != null) {
handler.setLevel(root, 0);
for (T item : list) {
if (!findAndAddLevel(root, item, handler)) {
for (T it : list) {
if (longEquals(handler.getId(it), handler.getParentId(item))) {
addChildLevel(it, item, handler);
item = null;
break;
}
}

// not find item parent
if (item != null && handler.forceAdd(item)) {
addChildLevel(root, item, handler);
}
}
}
}

public static <T> T findParent(T root, Long id, int treeLevel, ITreeDataLevelHandler<T> handler) {
T result = findParentInLevel(root, id, treeLevel, handler);
if (result != null && handler.getLevel(result) != treeLevel) {
result = null;
return handler.getChildren(root);
}

return result;
}
public static <T> T findParent(T root, Long id, int treeLevel, ITreeDataLevelHandler<T> handler) {
T result = findParentInLevel(root, id, treeLevel, handler);
if (result != null && handler.getLevel(result) != treeLevel) {
result = null;
}

private static <T> T findParentInLevel(T parent, Long id, int treeLevel, ITreeDataLevelHandler<T> handler) {
List<T> children = handler.getChildren(parent);
if (children != null) {
for (T child: children) {
if (id.equals(handler.getId(child))) {
return parent;
} else {
T find = findParentInLevel(child, id, treeLevel - 1, handler);
if (find != null) {
if (treeLevel > 0) {
return find;
} else {
return parent;
return result;
}

private static <T> T findParentInLevel(T parent, Long id, int treeLevel, ITreeDataLevelHandler<T> handler) {
List<T> children = handler.getChildren(parent);
if (children != null) {
for (T child : children) {
if (id.equals(handler.getId(child))) {
return parent;
} else {
T find = findParentInLevel(child, id, treeLevel - 1, handler);
if (find != null) {
if (treeLevel > 0) {
return find;
} else {
return parent;
}
}
}
}
}
}
}
}

return null;
}
return null;
}

public static <T> T findParent(T root, Long id,ITreeDataHandler<T> handler) {
List<T> children = handler.getChildren(root);
if (children != null) {
for (T child: children) {
if (id.equals(handler.getId(child))) {
return root;
} else {
T find = findParent(child, id, handler);
if (find != null) {
return find;
}
public static <T> T findParent(T root, Long id, ITreeDataHandler<T> handler) {
List<T> children = handler.getChildren(root);
if (children != null) {
for (T child : children) {
if (id.equals(handler.getId(child))) {
return root;
} else {
T find = findParent(child, id, handler);
if (find != null) {
return find;
}
}
}
}
}
}

return null;
}
return null;
}

public static <T> T find(T root, Long id, ITreeDataHandler<T> handler) {
List<T> children = handler.getChildren(root);
if (children != null) {
for (T child: children) {
if (id.equals(handler.getId(child))) {
return child;
} else {
T find = find(child, id, handler);
if (find != null) {
return find;
}
public static <T> T find(T root, Long id, ITreeDataHandler<T> handler) {
List<T> children = handler.getChildren(root);
if (children != null) {
for (T child : children) {
if (id.equals(handler.getId(child))) {
return child;
} else {
T find = find(child, id, handler);
if (find != null) {
return find;
}
}
}
}
}
}

return null;
}
return null;
}

public static <T> void forEach(T node, ITreeDataHandler<T> handler, Consumer<T> action) {
List<T> children = handler.getChildren(node);
if (children != null) {
for (T child: children) {
action.accept(child);
}
public static <T> void forEach(T node, ITreeDataHandler<T> handler, Consumer<T> action) {
List<T> children = handler.getChildren(node);
if (children != null) {
for (T child : children) {
action.accept(child);
}
}
}
}
}

+ 8
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilFile.java View File

@@ -1,6 +1,6 @@
package cc.smtweb.system.bpm.util;

import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.StringUtil;
import com.aliyuncs.utils.IOUtils;
import org.springframework.util.FileCopyUtils;
import sun.misc.BASE64Decoder;
@@ -149,7 +149,7 @@ public class UtilFile {
write.flush();
write.close();
} catch (IOException e) {
UtilLogger.error(e.getMessage( ), e);
UtilLogger.error(e.getMessage(), e);
}
}

@@ -341,8 +341,8 @@ public class UtilFile {
/**
* 查找所有的文件 *
*
* @param sSearchStr 要搜索的字符串
* return 文件名list
* @param sSearchStr 要搜索的字符串
* return 文件名list
*/
public static List<String> searchFiles(String sSearchStr, String sFilePath) {
List<String> list = new ArrayList<>();
@@ -898,7 +898,7 @@ public class UtilFile {
} else {
//String filePath = child.getAbsolutePath();
String filePath = child.getName();
if (PubUtil.isEmpty(suffix)) {
if (StringUtil.isEmpty(suffix)) {
//后缀名为null则为所有文件
fileList.add(filePath);
} else {
@@ -951,7 +951,7 @@ public class UtilFile {
getFiles(fileList, child, suffix, level + 1, max_level);
} else {
String filePath = child.getName();
if (PubUtil.isEmpty(suffix)) {
if (StringUtil.isEmpty(suffix)) {
//后缀名为null则为所有文件
fileList.add(child);
} else {
@@ -1069,6 +1069,7 @@ public class UtilFile {

/**
* 读取txt文件类型
*
* @param fileName
* @return
*/
@@ -1097,6 +1098,7 @@ public class UtilFile {
}
return sbf.toString();
}

/**
* 解压文件到指定目录
*


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilLogger.java View File

@@ -1,6 +1,6 @@
package cc.smtweb.system.bpm.util;

import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.CommUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@@ -12,7 +12,7 @@ public class UtilLogger {

private static String getOrigMsg(String message, Throwable e) {
if (message != null) return message;
return PubUtil.getOrigMsg(e);
return CommUtil.getOrigMsg(e);
}

public static void debug(String message) {
@@ -60,7 +60,7 @@ public class UtilLogger {
}

public static void error(String message, Throwable e) {
if (e instanceof Exception) logger.info(message + PubUtil.getOrigMsg(e));
if (e instanceof Exception) logger.info(message + CommUtil.getOrigMsg(e));
else logger.error(getOrigMsg(message, e), e);
}
}

+ 0
- 465
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilMath.java View File

@@ -1,465 +0,0 @@
package cc.smtweb.system.bpm.util;

import cc.smtweb.framework.core.util.PubUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;

/**
* Created with IntelliJ IDEA.
* User: AKhh
* Date: 12-12-25 下午1:02
* To change this template use File | Settings | File Templates.
*/
public class UtilMath {
//整数
private static DecimalFormat dfLng = new DecimalFormat("##############0");
private static DecimalFormat dfLong = new DecimalFormat("###,###,###,###,##0");
//一位小数
private static DecimalFormat df1 = new DecimalFormat("##############0.0");
private static DecimalFormat df1Format = new DecimalFormat("###,###,###,###,##0.0");
//两位小数
private static DecimalFormat df2 = new DecimalFormat("##############0.00");
private static DecimalFormat df2Format = new DecimalFormat("###,###,###,###,##0.00");
//四位小数
private static DecimalFormat df4 = new DecimalFormat("###,###,###,###,##0.0000");
//六位小数
private static DecimalFormat df6Number = new DecimalFormat("#######################0.000000");
private static DecimalFormat df6NumberF = new DecimalFormat("#,###,###,###,###,###,##0.000000");

public final static DecimalFormat stdAmountFormat = new DecimalFormat("###,###,###,###,##0.00");
public final static DecimalFormat stdNumberFormat = new DecimalFormat("#0.00");
public final static String DEF_NUM_TEN_THOUSAND = "10000";//万
public static final double MAX_VALUE = 9999999999999.99D;
public static final double MIN_VALUE = -9999999999999.99D;

private final static BigDecimal ONE_BIG = new BigDecimal(1.00D);
private static final String UNIT = "万仟佰拾亿仟佰拾万仟佰拾元角分";
private static final String DIGIT = "零壹贰叁肆伍陆柒捌玖";

/**
* 4舍5入double,2位小数
*/
public static double roundDouble(double src) {
return roundDouble(src, 2);
}

/**
* 4舍5入double,N 位小数
* @param src
* @param scale 小数位数
* @return
*/
public static double roundDouble(Object src, int scale) {
if (src == null) return 0.0;
String v = src.toString();
if (PubUtil.isEmpty(v)) return 0.0;
if (scale < 0) scale = 2;

BigDecimal src_b = new BigDecimal(v);
BigDecimal src_v = src_b.divide(ONE_BIG, scale + 2, BigDecimal.ROUND_HALF_UP);// 4舍5入
src_v = src_v.divide(ONE_BIG, scale, BigDecimal.ROUND_HALF_UP);// 4舍5入
return src_v.doubleValue();
}

/**
* 舍位处理,原生floor有坑,部分浮点数记录为.99999999999形式,导致floor结果错误
* @param d
* @return
*/
public static double floor(double d) {
return Math.floor(UtilMath.roundDouble(d, 2));
}

/**
* 比较两Double是否相等,将会吧他们专程BigDecimal进行比较;
*
* @param src double1
* @param tag double2
* @return src > tag 返回1, src < tag 返回-1, 否则返回0
*/
public static int compare(double src, double tag) {
BigDecimal src_b = new BigDecimal(src);
BigDecimal src_v = src_b.divide(ONE_BIG, 2, BigDecimal.ROUND_HALF_UP);// 4舍5入

BigDecimal tag_b = new BigDecimal(tag);
BigDecimal tag_v = tag_b.divide(ONE_BIG, 2, BigDecimal.ROUND_HALF_UP);// 4舍5入

return src_v.compareTo(tag_v);
}

/**
* 自动过滤金额中的逗号转换为double,如果出错,则返回0
*
* @param s 源串,可能为带逗号的金额串;
* @return double
*/
public static Double toDouble(String s) {
return todouble(s);
}

/**
* 自动过滤金额中的逗号转换为double,如果出错,则返回0
*
* @param s 源串,可能为带逗号的金额串;
* @return double
*/
public static double todouble(String s) {
try {
return Double.parseDouble(s.replaceAll(",", ""));
} catch (Exception e) {
return 0.00;
}
}

/**
* 获取double,主要过滤d为null的情况;
*
* @param d Double对象;
* @return double
*/
public static double todouble(Double d) {
if (d == null) return 0.0d;
return d.doubleValue();
}

/**
* 自动过滤金额中的逗号转换为float,如果出错,则返回0
*
* @param s 源串,可能为带逗号的金额串;
* @return Float
*/
public static Float toFloat(String s) {
return tofloat(s);
}

/**
* 自动过滤金额中的逗号转换为float,如果出错,则返回0
*
* @param s 源串,可能为带逗号的金额串;
* @return Float
*/
public static float tofloat(String s) {
try {
return Float.parseFloat(s.replaceAll(",", ""));
} catch (Exception e) {
return 0.0f;
}
}

public static long tolong(String src, long defaultvalue) {
try {
return Long.parseLong(src);
} catch (Exception e) {
return defaultvalue;
}
}

public static int toint(String src, int defaultvalue) {
try {
return Integer.parseInt(src);
} catch (Exception e) {
return defaultvalue;
}
}

/**
* 考虑使用中的精度,判断一个Value是否>0,实际是>0.00001
*
* @param value double类型
* @return boolean
*/
public static boolean isBigThanZero(double value) {
return (value > 0.00001);
}

/**
* 考虑使用中的精度,判断一个Value是否>0,实际是>0.00001
*
* @param value String类型
* @return boolean
*/
public static boolean isBigThanZero(String value) {
return !PubUtil.isEmpty(value) && isBigThanZero(toDouble(value));
}

/**
* 考虑使用中的精度,判断一个Value是否=0,实际是给出一个值范围。
*
* @param value double类型
* @return boolean
*/
public static boolean isEqualsZero(double value) {
return (-0.00001 < value && value < 0.00001);
}

/**
* 考虑使用中的精度,判断一个Value是否=0,实际是给出一个值范围。
*
* @param value String类型
* @return boolean
*/
public static boolean isEqualsZero(String value) {
return PubUtil.isEmpty(value) || isEqualsZero(toDouble(value));
}

/**
* 是否是负数
*
* @param db_val 要判断的double
* @return 负数则返回true;
*/
public static boolean isNegative(double db_val) {
return (compare(db_val, 0.00D) == -1);
}

/**
* 是否是正数
*
* @param db_val 要判断的double
* @return 正数则返回true;
*/
public static boolean isPlus(double db_val) {
return (compare(db_val, 0.00D) == 1);
}

/**
* 得到金额字符串,保持小数点2位
*
* @param db 将double转换为金额字符串;
* @return 金额字符串#0.00;
*/
public static String toStdNumberString(double db) {
try {
return stdNumberFormat.format(db);
} catch (Exception e) {
return "0.00";
}
}

public static String toStdNumberStringEx(double db) {
try {
if (compare(db, -1d) == 0) return "-";
return stdNumberFormat.format(db);
} catch (Exception e) {
return "0.00";
}
}

/**
* 将金额格式字符串,如23,333,093.01 去掉逗号
*
* @param s 金额串
* @return String 去掉逗号后的串,如果amount为空,则返回0.00
*/
public static String toStdNumberString(String s) {
if (PubUtil.isEmpty(s))
return "0.00";
return stdNumberFormat.format(UtilMath.todouble(s));
}

/**
* 将数据转换为两位小数的数字格式;
*
* @param d 数据
* @param isZeroToEmpty 如果未0,是否返回“”;
* @return 两位小数的字符串;
*/
public static String toStdNumberString(double d, boolean isZeroToEmpty) {
if (isEqualsZero(d)) {
return isZeroToEmpty ? "": "0.00";
}
return stdNumberFormat.format(d);
}

public static String toStdNumberString(String s, boolean isZeroToEmpty) {
return toStdNumberString(UtilMath.todouble(s), isZeroToEmpty);
}

public static String toStdNumberString(double d, int scale) {
DecimalFormat dfn = null;
if (scale == 1) dfn = df1Format;
if (scale == 2) dfn = df2Format;
else if (scale == 4) dfn = df4;
else if (scale == 6) dfn = df6NumberF;
else if (scale <= 0) dfn = dfLong;
else {
StringBuilder sb = new StringBuilder("###,###,###,###,##0.");
for (int i = 0; i < scale; i++) sb.append("0");
dfn = new DecimalFormat(sb.toString());
}
return dfn.format(d);
}

/**
* 将数字乘100,保留小数点后两位, 然后后面添加%
*
* @param d 值
* @param isZeroToEmpty,如果值为0,是否返回空;
* @return 字符串;
*/
public static String toStdPercentNumberStr(double d, boolean isZeroToEmpty) {
if (d > -0.00000000001 && d < 0.00000000001) {
return isZeroToEmpty ? "": "0.00%";
}
return toStdNumberString(d * 100) + "%";
}


public static String toStdAmountString(double d) {
return toStdAmountString(d, false);
}

/**
* 将数据转换为两位小数的金额格式,带逗号;
*
* @param d 数据
* @param isZeroToEmpty 如果未0,是否返回“”;
* @return 金额格式的字符串;
*/
public static String toStdAmountString(double d, boolean isZeroToEmpty) {
if (isEqualsZero(d)) {
return isZeroToEmpty ? "": "0.00";
}
return stdAmountFormat.format(d);
}

public static String toStdAmountString(String s) {
return toStdAmountString(UtilMath.todouble(s), false);
}

public static String toStdAmountString(String s, boolean isZeroToEmpty) {
return toStdAmountString(UtilMath.todouble(s), isZeroToEmpty);
}


/**
* 将小写金额转换为人民币大写金额
*
* @param s 金额格式的串
* @return String 转换结果
*/
public static String toCapsAmountString(String s) {
if (PubUtil.isEmpty(s)) return "";
return toCapsAmountString(todouble(s));
}

/**
* 将小写金额转换为人民币大写金额
*
* @param v double
* @return String 转换结果
*/
public static String toCapsAmountString(double v) {
if (v < MIN_VALUE || v > MAX_VALUE) return "参数非法!";

boolean negative = isNegative(v);

if (negative) v = Math.abs(v);
long l = Math.round(v * 100);
if (l == 0) return "零元整";

String strValue = String.valueOf(l);
// i用来控制数
int i = 0;
// j用来控制单位
int j = UNIT.length() - strValue.length();
StringBuilder rs = new StringBuilder(32);
boolean isZero = false;
for (; i < strValue.length(); i++, j++) {
char ch = strValue.charAt(i);
if (ch == '0') {
isZero = true;
if (UNIT.charAt(j) == '亿' || UNIT.charAt(j) == '万' || UNIT.charAt(j) == '元') {
rs.append(UNIT.charAt(j));
isZero = false;
}
} else {
if (isZero) {
rs.append('零');
isZero = false;
}
rs.append(DIGIT.charAt(ch - '0')).append(UNIT.charAt(j));
}
}
if (rs.charAt(rs.length() - 1) != '分')
rs.append('整');

i = rs.indexOf("亿万");
if (i > 0) rs.delete(i + 1, i + 2); // i+1 ->万

if (negative)
return rs.insert(0, '负').toString();
else
return rs.toString();
}

/**
* 返回0 到 maxvalue的随机数
*
* @param maxvalue 随机数的最大值
* @return int
*/
public static int rnd(int maxvalue) {
return (int) (Math.random() * (maxvalue + 1));
}


public static double chkDbNull(Double v) {
return v == null ? 0: v;
}

public static double max(double d1, double d2) {
return compare(d1, d2) < 0 ? d2 : d1;
}

public static double min(double d1, double d2) {
return compare(d1, d2) < 0 ? d1 : d2;
}


public static void main(String[] args) {
double aa=123456789.345678900005;
System.out.println("args0 = " + upDouble(aa,0));
System.out.println("args1 = " + upDouble(aa,1));
System.out.println("args2 = " + upDouble(aa,2));
System.out.println("args3 = " + upDouble(aa,3));
System.out.println("args4 = " + upDouble(aa,4));
System.out.println("args5 = " + upDouble(aa,5));
System.out.println("args5 = " + upDouble(aa,6));
System.out.println("args5 = " + upDouble(aa,7));
System.out.println("args5 = " + upDouble(aa,8));

}

/**
* double 去尾法
* @param src 待处理数据
* @param scale 保留小数位数
* @return
*/
public static double cutDouble(double src, int scale){
String v = toStdNumberString(src, 6);//先到6位小数,再去计算,否则容易出错,如8.3成8.29999999999,舍位就成了8.29了
DecimalFormat formater = new DecimalFormat();
formater.setMaximumFractionDigits(scale);
formater.setGroupingSize(0);
formater.setRoundingMode(RoundingMode.FLOOR);
return new BigDecimal(formater.format(toDouble(v))).doubleValue();
}

/**
* double 进位法
* @param src 待处理数据
* @param scale 保留小数位数
* @return
*/
public static double upDouble(double src, int scale){
String v = toStdNumberString(src, 6);//先到6位小数,再去计算
DecimalFormat formater = new DecimalFormat();
formater.setMaximumFractionDigits(scale);
formater.setGroupingSize(0);
formater.setRoundingMode(RoundingMode.UP);
return new BigDecimal(formater.format(toDouble(v))).doubleValue();
}
}

+ 0
- 504
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilString.java View File

@@ -1,504 +0,0 @@
package cc.smtweb.system.bpm.util;


import cc.smtweb.framework.core.util.PubUtil;

import java.text.Collator;
import java.util.*;

/**
* Created with IntelliJ IDEA.
* User: AKhh
* Date: 12-12-24 下午5:09
* To change this template use File | Settings | File Templates.
*/
@SuppressWarnings("UnusedDeclaration")
public class UtilString {
private static Collator chineseCollator = Collator.getInstance(Locale.CHINA);

/**
* strSrc中寻找第一个strSe并且返回以其分隔的Left部分,汉字长度也为1
*
* @param strSrc 源字符串
* @param strSe 分割字符
* @return String 返回
*/
public static String getLeft(String strSrc, String strSe) {
if (PubUtil.isEmpty(strSrc))
return "";
if (PubUtil.isEmpty(strSe))
strSe = " ";

String result = "";
int pos = strSrc.indexOf(strSe);
if (pos >= 0)
result = strSrc.substring(0, pos);
return result;
}

/**
* 返回字符串的左边部分,汉字长度也为1
*
* @param strSrc 源串,如果为空,则返回“”;
* @param count 要获取的右边字符串长度,负数将返回“”,如果count>字符串长度,则返回整个字符串;
* @return String return
*/
public static String getLeft(String strSrc, int count) {
if (PubUtil.isEmpty(strSrc) || count <= 0) {
return "";
}
if (strSrc.length() < count) {
return strSrc;
} else {
return strSrc.substring(0, count);
}
}

/**
* strSrc中寻找第一个strSe并且返回以其分隔的Right部分,汉字长度也为1
*
* @param strSrc 源串
* @param strSe 分隔符,一个字符
* @return String right部分
*/
public static String getRight(String strSrc, String strSe) {
if (PubUtil.isEmpty(strSrc))
return "";
if (PubUtil.isEmpty(strSe))
strSe = " ";

String result = strSrc;
int pos = strSrc.indexOf(strSe);
if (pos >= 0)
result = strSrc.substring(pos + strSe.length());
return result;
}

/**
* 返回字符串的右边部分,汉字长度也为1
*
* @param strSrc 源串
* @param count 要获取的右边字符串长度,负数将返回“”,如果count>字符串长度,则返回整个字符串;
* @return String return
*/
public static String getRight(String strSrc, int count) {
if (PubUtil.isEmpty(strSrc) || count <= 0) {
return "";
}
int l = strSrc.length();
if (l <= count) {
return strSrc;
}
return strSrc.substring(l - count);
}

/**
* 左边补齐字符
*
* @param src 源串
* @param pad 补齐字符
* @param length 最终长度
* @return 补齐后的字符串
*/
public static String padLeft(String src, String pad, int length) {
StringBuilder sb = new StringBuilder(repeatString(pad, length));
sb.append(src);
return sb.substring(sb.length() - length);
}

public static String padLeft(long src, String pad, int length) {
StringBuilder sb = new StringBuilder(repeatString(pad, length));
sb.append(src);
return sb.substring(sb.length() - length);
}

public static String padRight(String src, String pad, int length) {
StringBuilder sb = new StringBuilder(length * pad.length() + src.length());
sb.append(src).append(repeatString(pad, length));
return sb.substring(0, length);
}

public static String padRight(long src, String pad, int length) {
StringBuilder sb = new StringBuilder(length * pad.length());
sb.append(src).append(repeatString(pad, length));
return sb.substring(0, length);
}

/**
* 由于jdk1.3提供的replace函数不能满足替换要求,自己写一个
*
* @param src 源串
* @param oldS 将...
* @param newS 替换成...
* @return 替换后的字符串
*/
public static String replaceString(String src, String oldS, String newS) {
StringBuilder ret = new StringBuilder(64);
int pos = src.indexOf(oldS);
while (pos >= 0) {
ret.append(src, 0, pos).append(newS);
src = src.substring(pos + oldS.length());
pos = src.indexOf(oldS);
}
ret.append(src);
return ret.toString();
}

/**
* 取得指定字符串左边的有效数字,首先去掉两边空格
*
* @param s 源串
* @return 串左边的有效数字
*/
public static String getStringLeftNumber(String s) {
String ret = "";
int dotCount = 0;
s = s.trim();
char[] carr = s.toCharArray();
for (char aCarr : carr) {
if (Character.isDigit(aCarr)) {
ret += aCarr;
} else if (aCarr == '.' && dotCount == 0) {
ret += aCarr;
dotCount++;
} else {
break;
}
}
if (ret.endsWith(".")) {
ret = ret.substring(0, ret.length() - 1);
}
return ret;
}

/**
* 取得重复字串
*
* @param repeatString 重复字串
* @param count 重复次数
* @return String
*/
public static String repeatString(String repeatString, int count) {
if (count <= 0) return "";
StringBuilder ret = new StringBuilder(repeatString.length() * count);
for (int i = 1; i <= count; i++) {
ret.append(repeatString);
}
return ret.toString();
}

/**
* 去除字符串左边的指定字符串
*
* @param src 源字符串
* @param cut 要去掉的字符串;
* @return 处理结果
*/
public static String cutStringLeft(String src, String cut) {
if (PubUtil.isEmpty(src) || PubUtil.isEmpty(cut)) {
return "";
}
if (src.startsWith(cut)) {
return cutStringLeft(src.substring(cut.length()), cut);
} else {
return src;
}
}

public static String cutStringRight(String src, String cut) {
if (PubUtil.isEmpty(src) || PubUtil.isEmpty(cut)) {
return "";
}
while (src.endsWith(cut))
src = src.substring(0, src.length() - cut.length());

return src;
}

/**
* Removes all spaces from a string
* 可以替换大部分空白字符, 不限于空格,\s 可以匹配空格、制表符、换页符等空白字符的其中任意一个
*/
public static String removeSpaces(String str) {
return str.replaceAll("\\s*", "");
}

/**
* Creates a single string from a List of strings seperated by a delimiter.
*
* @param list a list of strings to join
* @param delim the delimiter character(s) to use. (null value will join with no delimiter)
* @return a String of all values in the list seperated by the delimiter
*/
public static String join(List<String> list, String delim) {
if (list == null || list.size() < 1)
return null;
StringBuffer buf = new StringBuffer();
Iterator i = list.iterator();

while (i.hasNext()) {
buf.append((String) i.next());
if (i.hasNext())
buf.append(delim);
}
return buf.toString();
}

/**
* Splits a String on a delimiter into a List of Strings.
*
* @param str the String to split
* @param delim the delimiter character(s) to join on (null will split on whitespace)
* @return a list of Strings
*/
public static List<String> split(String str, String delim) {
List<String> splitList = new ArrayList<>();
StringTokenizer st;
if (str == null)
return splitList;

if (delim != null)
st = new StringTokenizer(str, delim);
else
st = new StringTokenizer(str);

while (st.hasMoreTokens()) {
splitList.add(st.nextToken());
}
return splitList;
}

//是否为true,(1,y,true,yes)
public static boolean toBoolean(String v) {
return "1".equals(v) || "y".equalsIgnoreCase(v) || "true".equalsIgnoreCase(v) || "yes".equalsIgnoreCase(v);
}

public static int chineseCompare(String s1, String s2) {
return chineseCollator.compare(s1, s2);
}

/**
* 按照编码级次,得到类型的真实编码,主要用于like 'parentCode%'
* getSplitTypeCode('GF82000',2, 2, 1) == GF82
* getSplitTypeCode('GF82100',3, 2, 1) == GF821
* getSplitTypeCode('82100' ,3, 0, 1) == 821
*
* @param curLevel 当前编码的所在层次
* @param startIndex 数字编码的开始选项
* @param perSize 每层的数字编码长度
*/
public static String getRealCode(String code, int curLevel, int startIndex, int perSize) {
StringBuilder sb = new StringBuilder(code.length());
if (startIndex > 0) sb.append(code, 0, startIndex);
for (int i = startIndex, l = 0; i < code.length(); i += perSize) {
if (l < curLevel) {
sb.append(code, i, i + perSize);
++l;
} else {
break;
}
}
return sb.toString();
}

//函数功能: 正整数
public static boolean isPureNumber(String inputString) {
return inputString.matches("^[1-9]\\d*$");
}

//函数功能: 整数
public static boolean isNumber(String inputString) {
return inputString.matches("^[-+][0-9]\\d*$");
}

//函数功能: 浮点数
public static boolean isAmount(String inputString) {
return inputString.matches("^[-+]?[\\d,]+(\\.\\d+)?$");
}

//函数功能: 带千分号的整数
public static boolean isFormatNumber(String inputString) {
return inputString.matches("^[-+]?[\\d,]+(\\d+)?$");
}


//首字母大写
public static String upFirst(String s) {
return s.substring(0, 1).toUpperCase() + s.substring(1);
}

public static String padRightBytes(String src, String pad, int length) {
length -= src.replaceAll("[^\\x00-\\xff]", "**").length();
return src + repeatString(pad, length);
}

//按字节数取子串,begin不是按字节的
public static String substrByte(String src, int begin, int len) {
StringBuilder sb = new StringBuilder(32);
char c;
int tl = src.length();
for (int i = begin; i < len + begin && i < tl; i++) {

c = src.charAt(i);
sb.append(c);
if (String.valueOf(c).replaceAll("[^\\x00-\\xff]", "**").length() > 1) {
// 遇到中文汉字,截取字节总数减1
--len;
}
}
return sb.toString();
}

/**
* 通配符算法。 可以匹配"*"和"?"
* 如a*b?d可以匹配aAAAbcd
*
* @param pattern 匹配表达式
* @param str 匹配的字符串
* @return
*/
public static boolean match(String pattern, String str) {
if (pattern == null || str == null)
return false;

boolean result = false;
char c; // 当前要匹配的字符串
boolean beforeStar = false; // 是否遇到通配符*
int back_i = 0;// 回溯,当遇到通配符时,匹配不成功则回溯
int back_j = 0;
int i, j;
for (i = 0, j = 0; i < str.length(); ) {
if (pattern.length() <= j) {
if (back_i != 0) {// 有通配符,但是匹配未成功,回溯
beforeStar = true;
i = back_i;
j = back_j;
back_i = 0;
back_j = 0;
continue;
}
break;
}

if ((c = pattern.charAt(j)) == '*') {
if (j == pattern.length() - 1) {// 通配符已经在末尾,返回true
result = true;
break;
}
beforeStar = true;
j++;
continue;
}

if (beforeStar) {
if (str.charAt(i) == c) {
beforeStar = false;
back_i = i + 1;
back_j = j;
j++;
}
} else {
if (c != '?' && c != str.charAt(i)) {
result = false;
if (back_i != 0) {// 有通配符,但是匹配未成功,回溯
beforeStar = true;
i = back_i;
j = back_j;
back_i = 0;
back_j = 0;
continue;
}
break;
}
j++;
}
i++;
}

if (i == str.length() && j == pattern.length())// 全部遍历完毕
result = true;
return result;
}

//填充变量
public static String myReplaceStrEx(String express, String b, String e, IStrHanlder hanlder) {
if (null == express) return express;
int keyBegin = 0, keyEnd = 0;
int lb = b.length(), le = e.length();
String fn;
while (true) {
keyBegin = express.indexOf(b, keyBegin);
if (keyBegin < 0) break;
keyEnd = express.indexOf(e, keyBegin);
if (keyEnd <= keyBegin) break;
keyBegin++;
fn = express.substring(keyBegin + lb - 1, keyEnd);
fn = hanlder.work(fn);
if (fn != null) {
express = express.substring(0, keyBegin - 1) + fn + express.substring(keyEnd + le);
}
}
return express;
}

//填充变量
public static String myReplaceStrEx(String express, String b, String e, final Map<String, String> mapVals) {
return myReplaceStrEx(express, b, e, new IStrHanlder() {
@Override
public String work(String src) {
return PubUtil.checkNull(mapVals.get(src));
}
});
}

/*Blob转String*/
// public static String blob2Str(Blob blob) {
// if (blob == null) return "";
// ByteArrayOutputStream outStream = null;
// try {
// long len = blob.length();
// if (len == 0L) return "";
// byte[] bytes;
// long i = 1L;
// outStream = new ByteArrayOutputStream();
// while (i < len) {
// bytes = blob.getBytes(i, 1024);
// i += 1024L;
// outStream.write(bytes);
// }
//
// return UtilEncode.base64EncodeB(outStream.toByteArray());
// } catch (Exception e) {
// e.printStackTrace();
// return "";
// } finally {
// IOUtils.closeQuietly(outStream);
// }
// }


public interface IStrHanlder {
String work(String src);
}

public static int[] splitStr(String src, String ch) {
String[] ss = src.split(ch);
int[] ret = new int[ss.length];
for (int i = 0, len = ss.length; i < len; i++) {
ret[i] = PubUtil.getIntIgnoreErr(ss[i]);
}
return ret;
}

public static void main(String[] args) {
String s = "a[#[#123#]bcde[aaa]bcd";
s = UtilString.myReplaceStrEx(s, "[#", "#]", new UtilString.IStrHanlder() {
@Override
public String work(String src) {
if (src.equals("123")) return "1";
return null;
}
});
System.out.println(s);
}
}

+ 59
- 58
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/XmlUtil.java View File

@@ -13,76 +13,77 @@ import java.io.InputStream;
import java.io.OutputStream;

public class XmlUtil {
private static final XmlMapper OBJECT_MAPPER = new XmlMapper();
private static final XmlMapper OBJECT_MAPPER = new XmlMapper();

static {
OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
OBJECT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
}
static {
OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);
OBJECT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
}

private XmlUtil() {}
private XmlUtil() {
}

public static <T> T readValue(String str, Class<T> clazz) {
try {
if (StringUtils.isBlank(str)) {
return null;
} else {
return OBJECT_MAPPER.readValue(str, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this json to " + clazz + " type", e);
public static <T> T readValue(String str, Class<T> clazz) {
try {
if (StringUtils.isBlank(str)) {
return null;
} else {
return OBJECT_MAPPER.readValue(str, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this json to " + clazz + " type", e);
}
}
}

public static <T> T readValue(File file, Class<T> clazz) {
try {
if (file == null || !file.exists()) {
return null;
} else {
return OBJECT_MAPPER.readValue(file, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this json to " + clazz + " type", e);
public static <T> T readValue(File file, Class<T> clazz) {
try {
if (file == null || !file.exists()) {
return null;
} else {
return OBJECT_MAPPER.readValue(file, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this json to " + clazz + " type", e);
}
}
}

public static <T> T readValue(InputStream is, Class<T> clazz) {
try {
if (is == null) {
return null;
} else {
return OBJECT_MAPPER.readValue(is, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this xml to " + clazz + " type", e);
public static <T> T readValue(InputStream is, Class<T> clazz) {
try {
if (is == null) {
return null;
} else {
return OBJECT_MAPPER.readValue(is, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this xml to " + clazz + " type", e);
}
}
}

public static String writeValue(Object obj) {
try {
return OBJECT_MAPPER.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new JsonParseException("can't convert type " + obj.getClass() + " to json string", e);
public static String writeValue(Object obj) {
try {
return OBJECT_MAPPER.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new JsonParseException("can't convert type " + obj.getClass() + " to json string", e);
}
}
}

public static void writeValue(OutputStream outputStream, Object obj) {
try {
OBJECT_MAPPER.writeValue(outputStream, obj);
} catch (JsonProcessingException e) {
throw new JsonParseException("can't convert type " + obj.getClass() + " to json string", e);
} catch (IOException e) {
throw new JsonParseException(e.getMessage(), e);
public static void writeValue(OutputStream outputStream, Object obj) {
try {
OBJECT_MAPPER.writeValue(outputStream, obj);
} catch (JsonProcessingException e) {
throw new JsonParseException("can't convert type " + obj.getClass() + " to json string", e);
} catch (IOException e) {
throw new JsonParseException(e.getMessage(), e);
}
}
}

public static void writeValue(File file, Object obj) {
try {
OBJECT_MAPPER.writeValue(file, obj);
} catch (JsonProcessingException e) {
throw new JsonParseException("can't convert type " + obj.getClass() + " to json string", e);
} catch (IOException e) {
throw new JsonParseException(e.getMessage(), e);
public static void writeValue(File file, Object obj) {
try {
OBJECT_MAPPER.writeValue(file, obj);
} catch (JsonProcessingException e) {
throw new JsonParseException("can't convert type " + obj.getClass() + " to json string", e);
} catch (IOException e) {
throw new JsonParseException(e.getMessage(), e);
}
}
}
}

+ 79
- 79
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/YamlUtil.java View File

@@ -16,97 +16,97 @@ import java.io.*;
import java.nio.charset.StandardCharsets;

public class YamlUtil {
private static final ObjectMapper OBJECT_MAPPER;
private static final Representer representer;
private static final ObjectMapper OBJECT_MAPPER;
private static final Representer representer;

static {
YAMLFactory yamlFactory = new YAMLFactory();
static {
YAMLFactory yamlFactory = new YAMLFactory();

// yamlFactory.enable(YAMLGenerator.Feature.CANONICAL_OUTPUT);
yamlFactory.disable(YAMLGenerator.Feature.SPLIT_LINES);
yamlFactory.enable(YAMLGenerator.Feature.MINIMIZE_QUOTES);

OBJECT_MAPPER = new ObjectMapper(yamlFactory);
OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);

// 生成yaml时忽略null属性
representer = new Representer() {
@Override
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) {
// if value of property is null, ignore it.
if (propertyValue == null) {
return null;
yamlFactory.disable(YAMLGenerator.Feature.SPLIT_LINES);
yamlFactory.enable(YAMLGenerator.Feature.MINIMIZE_QUOTES);

OBJECT_MAPPER = new ObjectMapper(yamlFactory);
OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL);

// 生成yaml时忽略null属性
representer = new Representer() {
@Override
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) {
// if value of property is null, ignore it.
if (propertyValue == null) {
return null;
} else {
return super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
}
}
};
}

private YamlUtil() {
}

public static <T> T readValue(String str, Class<T> clazz) {
try {
if (StringUtils.isBlank(str)) {
return null;
} else {
return OBJECT_MAPPER.readValue(str, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this json to " + clazz + " type", e);
}
else {
return super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
}

public static <T> T readValue(File file, Class<T> clazz) {
try {
return OBJECT_MAPPER.readValue(file, clazz);
} catch (Exception e) {
throw new JsonParseException("can't convert this json to " + clazz + " type", e);
}
}
};
}

private YamlUtil() {}

public static <T> T readValue(String str, Class<T> clazz) {
try {
if (StringUtils.isBlank(str)) {
return null;
} else {
return OBJECT_MAPPER.readValue(str, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this json to " + clazz + " type", e);
}
}

public static <T> T readValue(File file, Class<T> clazz) {
try {
return OBJECT_MAPPER.readValue(file, clazz);
} catch (Exception e) {
throw new JsonParseException("can't convert this json to " + clazz + " type", e);
public static <T> T readValue(InputStream is, Class<T> clazz) {
try {
if (is == null) {
return null;
} else {
return OBJECT_MAPPER.readValue(is, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this yaml to " + clazz + " type", e);
}
}
}

public static <T> T readValue(InputStream is, Class<T> clazz) {
try {
if (is == null) {
return null;
} else {
return OBJECT_MAPPER.readValue(is, clazz);
}
} catch (Exception e) {
throw new JsonParseException("can't convert this yaml to " + clazz + " type", e);

public static String writeValue(Object obj) {
Yaml yaml = buildYaml();
StringWriter sw = new StringWriter();
yaml.dump(obj, sw);
return sw.toString();
}
}

public static String writeValue(Object obj) {
Yaml yaml = buildYaml();
StringWriter sw = new StringWriter();
yaml.dump(obj, sw);
return sw.toString();
}

private static Yaml buildYaml() {
Yaml result = new Yaml(representer);

return result;
}

public static void writeValue(OutputStream outputStream, Object obj) {
Yaml yaml = buildYaml();
yaml.dump(obj, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
}

public static void writeValue(File file, Object obj) {
Yaml yaml = buildYaml();
try(OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
yaml.dump(obj, out);
// OBJECT_MAPPER.writeValue(file, obj);
} catch (IOException e) {
throw new JsonParseException(e.getMessage(), e);

private static Yaml buildYaml() {
Yaml result = new Yaml(representer);

return result;
}

public static void writeValue(OutputStream outputStream, Object obj) {
Yaml yaml = buildYaml();
yaml.dump(obj, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
}

public static void writeValue(File file, Object obj) {
Yaml yaml = buildYaml();
try (OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
yaml.dump(obj, out);
// OBJECT_MAPPER.writeValue(file, obj);
} catch (IOException e) {
throw new JsonParseException(e.getMessage(), e);
}


// StringWriter sw = new StringWriter();
// System.out.println(sw.toString());
}
}
}

+ 9
- 8
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/FtpTaskManager.java View File

@@ -1,9 +1,8 @@
package cc.smtweb.system.bpm.util.ftp;



import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.util.UtilLogger;

import java.io.File;
@@ -24,7 +23,7 @@ public class FtpTaskManager {
private Map<Thread, IFtpUtil> mapThreadFtp = new HashMap<>();

public static FtpTaskManager getInstance(String key, IFtpServerConfig ftpConfig) {
key = key + "_" + (ftpConfig.isSFTP() ? 1 : 0) + ftpConfig.getServerIp() + "_" + ftpConfig.getPort() + "_" + ftpConfig.getUserName();
key = key + "_" + (ftpConfig.isSFTP() ? 1: 0) + ftpConfig.getServerIp() + "_" + ftpConfig.getPort() + "_" + ftpConfig.getUserName();
FtpTaskManager instance = mapInstance.get(key);
if (instance == null) {
synchronized (FtpTaskManager.class) {
@@ -55,7 +54,7 @@ public class FtpTaskManager {
IFtpUtil ftp = mapThreadFtp.get(Thread.currentThread());
if (ftp != null) return ftp;

ftp = ftpConfig.isSFTP() ? new SFtpUtil() : new FtpUtil();
ftp = ftpConfig.isSFTP() ? new SFtpUtil(): new FtpUtil();
boolean isConnect = ftp.login(ftpConfig);
if (isConnect) {
UtilLogger.info("FTP连接成功!");
@@ -87,7 +86,7 @@ public class FtpTaskManager {
public Object execute(FtpTask ftpTask) throws Exception {
IFtpUtil ftp = getFtpUtil();
if (!ftp.isConnected())
throw new Exception("FTP连接失败(" + ftpConfig.getServerIp() + "/" + ftpConfig.getUserName() + "/" + (ftpConfig.isSFTP() ? "sftp" : "ftp") + ")。");
throw new Exception("FTP连接失败(" + ftpConfig.getServerIp() + "/" + ftpConfig.getUserName() + "/" + (ftpConfig.isSFTP() ? "sftp": "ftp") + ")。");
try {
return ftpTask.execute(ftp);
} finally {
@@ -118,7 +117,7 @@ public class FtpTaskManager {
}

private String getBakPath(String path) {
path = PubUtil.isEmpty(path) ? DateUtil.getNowYm() : path;
path = StringUtil.isEmpty(path) ? DateUtil.getNowYm(): path;
return "bak/" + path + "/";
}

@@ -161,15 +160,17 @@ public class FtpTaskManager {
}
});
}

public void delFile(String delPath, String fileName) throws Exception {
this.execute(new FtpTask() {
public Object execute(IFtpUtil ftp) throws Exception {
if (!ftp.existsFile(delPath, fileName)) return null;
ftp.deleteFile(delPath,fileName );
ftp.deleteFile(delPath, fileName);
return null;
}
});
}

//从服务器下载文件到本地。传完后,根据设置删除远程目录文件
public String[] listFileNames(final String remotePath) throws Exception {
IFtpUtil ftp = getFtpUtil();
@@ -190,7 +191,7 @@ public class FtpTaskManager {
public Object execute(IFtpUtil ftp) throws Exception {
for (String file : files) {
if (worker != null && !worker.isDownload(file, fileNamePrefix)) continue;
if (PubUtil.isNotEmptyId(fileNamePrefix) && !file.startsWith(fileNamePrefix)) continue;
if (StringUtil.isNotEmpty(fileNamePrefix) && !file.startsWith(fileNamePrefix)) continue;
ftp.downloadFileEx(remotePath, file, localPath + "/" + file);
if (isDelLocal) {
ftp.setRemoteDir("/");


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/FtpUtil.java View File

@@ -1,6 +1,6 @@
package cc.smtweb.system.bpm.util.ftp;

import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.system.bpm.util.UtilFile;
import cc.smtweb.system.bpm.util.UtilLogger;
import org.apache.commons.net.ftp.FTPClient;
@@ -243,7 +243,7 @@ public class FtpUtil implements IFtpUtil {
ftpClient.enterLocalPassiveMode();//设置被动模式
setRemoteDir(path);
String[] files = ftpClient.listNames(gbktoiso8859(filename));
return PubUtil.isNotEmpty(files);
return !CommUtil.isEmpty(files);
} catch (IOException e) {
logError("判断文件是否存在失败", e);
return false;


+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/IFtpServerConfig.java View File

@@ -6,6 +6,7 @@ package cc.smtweb.system.bpm.util.ftp;
*/
public interface IFtpServerConfig {
boolean isSFTP();

String getServerIp();

Integer getPort();


+ 5
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/IFtpUtil.java View File

@@ -9,10 +9,13 @@ import java.io.InputStream;
public interface IFtpUtil {
//是否自动删除
boolean isAutoFree();

//设置自动删除
void setAutoFree(boolean autoFree);

//登录ftp
boolean login(IFtpServerConfig ftpConf);

//退出ftp
void logout();

@@ -21,6 +24,7 @@ public interface IFtpUtil {

//设置远程目录
boolean setRemoteDir(String path);

void mkdir(String dirName);

//删除远程路径
@@ -37,6 +41,7 @@ public interface IFtpUtil {
boolean uploadFile(String path, String filename, File localFile) throws Exception;

void deleteFile(String path, String filename);

//判断文件是否存在
boolean existsFile(String path, String filename);



+ 5
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/SFtpUtil.java View File

@@ -1,6 +1,7 @@
package cc.smtweb.system.bpm.util.ftp;

import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.util.UtilFile;
import cc.smtweb.system.bpm.util.UtilLogger;
import com.jcraft.jsch.*;
@@ -63,7 +64,7 @@ public class SFtpUtil implements IFtpUtil {
UtilLogger.debug("已连接到 " + ftpConf.getServerIp() + ";");
return true;
} catch (Exception e) {
UtilLogger.debug("connect fail[" + count + "/3]:" + PubUtil.getOrigMsg(e));
UtilLogger.debug("connect fail[" + count + "/3]:" + CommUtil.getOrigMsg(e));
}
}
UtilLogger.debug("sftp登录失败:3次连接超时...");
@@ -135,7 +136,7 @@ public class SFtpUtil implements IFtpUtil {
try {
String now = sftp.pwd();
for (int i = 0; i < dirs.length; i++) {
if (PubUtil.isEmpty(dirs[i])) continue;
if (StringUtil.isEmpty(dirs[i])) continue;
boolean dirExists = openRemoteDir(dirs[i]);
if (!dirExists) {
sftp.mkdir(dirs[i]);
@@ -387,7 +388,7 @@ public class SFtpUtil implements IFtpUtil {
setRemoteDir(path);
Vector<ChannelSftp.LsEntry> files = sftp.ls(filename);
sftp.cd(now);
return PubUtil.isNotEmpty(files);
return !CommUtil.isEmpty(files);
} catch (SftpException e) {
logError("判断文件是否存在失败", e);
return false;


+ 1
- 10
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/BpmStartedListener.java View File

@@ -1,22 +1,13 @@
package cc.smtweb.system.bpm.web;

import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.annotation.SwStartListener;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.impl.DatabaseUtil;
import cc.smtweb.framework.core.db.vo.ModelCatalog;
import cc.smtweb.framework.core.mvc.controller.IStartListener;
import cc.smtweb.framework.core.mvc.service.TreeHelper;
import cc.smtweb.framework.core.systask.TaskStartEvent;
import cc.smtweb.framework.core.systask.WebStartedEvent;
import cc.smtweb.system.bpm.web.design.db.ModelCatalogTreeHelper;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
* Created by Akmm at 2022/7/8 19:57
@@ -38,7 +29,7 @@ public class BpmStartedListener implements IStartListener {
new DatabaseUtil(true, false).checkDb();
//初始化缓存
CacheManager.getIntance().init();
TreeHelper.regTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class);
}
}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogCache.java View File

@@ -40,7 +40,7 @@ public class ModelCatalogCache extends AbstractCache<ModelCatalog> {

public String getName(long id) {
ModelCatalog bean = get(id);
return bean != null ? bean.getName() : "";
return bean != null ? bean.getName(): "";
}

public String getFullName(long id) {


+ 4
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java View File

@@ -64,7 +64,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>

@Override
protected List<DefaultEntity> filterData() {
Set<Long> setId =exc_depend ? new HashSet<>(Arrays.asList(prj_id)) : ModelProjectCache.getInstance().getDependsPrjIds(prj_id);
Set<Long> setId = exc_depend ? new HashSet<>(Arrays.asList(prj_id)): ModelProjectCache.getInstance().getDependsPrjIds(prj_id);
if (setId.isEmpty()) return new ArrayList<>();
String sqlPrjId = CommUtil.getSqlInIds(setId);

@@ -106,7 +106,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>

@Override
protected List<DefaultEntity> getChildren(long id) {
List<ModelCatalog> list = mcTreeHelper.getChildren(id, prj_id,exc_depend, (o1, o2) -> StringUtil.chineseCompare(o1.getName(), o2.getName()));
List<ModelCatalog> list = mcTreeHelper.getChildren(id, prj_id, exc_depend, (o1, o2) -> StringUtil.chineseCompare(o1.getName(), o2.getName()));
List<DefaultEntity> listRet;
if (type != TYPE_CATALOG && exc_empty) {//排除空目录
listRet = cleanEmpty(list);
@@ -160,7 +160,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
addPageChildren(listRet, mc.getId(), type);
}
if (!listRet.isEmpty()) return true;
List<ModelCatalog> list = mcTreeHelper.getChildren(mc.getId(), prj_id,exc_depend,null);
List<ModelCatalog> list = mcTreeHelper.getChildren(mc.getId(), prj_id, exc_depend, null);
if (list == null || list.isEmpty()) return false;
for (ModelCatalog c : list) {
if (hasChildren(c)) return true;
@@ -259,7 +259,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
final ModelForm form = (ModelForm) bean;
node.put("type", form.getType() + 2);
// 返回页面名称
bean.put("pageName",ModelProjectCache.getInstance().getModule(((ModelForm) bean).getPrjId())+"."+((ModelForm) bean).getName());
bean.put("pageName", ModelProjectCache.getInstance().getModule(((ModelForm) bean).getPrjId()) + "." + ((ModelForm) bean).getName());
//是模块,需要加子页面
if (form.getType() == SwEnum.FormType.MODULE.value) {
List<DefaultEntity> lf = mapFormChild.get(form.getEntityId());


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java View File

@@ -17,15 +17,15 @@ public class ModelCatalogTreeHelper extends TreeHelper<ModelCatalog> {
super(ModelCatalog.ENTITY_NAME);
}

public List<ModelCatalog> getChildren(long id, long prj_id,boolean exc_depend, Comparator<ModelCatalog> comparator) {
public List<ModelCatalog> getChildren(long id, long prj_id, boolean exc_depend, Comparator<ModelCatalog> comparator) {
if (id > 0L) {
return getChildren(id, comparator);
}
Set<Long> setId = exc_depend ? new HashSet<>(Arrays.asList(prj_id)) : ModelProjectCache.getInstance().getDependsPrjIds(prj_id);
Set<Long> setId = exc_depend ? new HashSet<>(Arrays.asList(prj_id)): ModelProjectCache.getInstance().getDependsPrjIds(prj_id);
if (setId.isEmpty()) return new ArrayList<>();
Set<ModelCatalog> set = new HashSet<>();

for (long prjId: setId) {
for (long prjId : setId) {
Collection<ModelCatalog> st = cache.getListByKey(CACHE_KEY, prjId + SwConsts.SPLIT_CHAR + SwConsts.DEF_ROOT_ID);
if (st != null) set.addAll(st);
}


+ 9
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelProjectCache.java View File

@@ -19,12 +19,13 @@ import java.util.Set;
@SwCache(ident = "ASP_MODEL_PROJECT", title = "项目定义")
public class ModelProjectCache extends AbstractCache<ModelProject> {
private final static String mm = "m";

public static ModelProjectCache getInstance() {
return CacheManager.getIntance().getCache(ModelProjectCache.class);
}

public ModelProjectCache() {
regMap(mm, k-> String.valueOf(k.getModule()));
regMap(mm, k -> String.valueOf(k.getModule()));
}

@Override
@@ -40,14 +41,16 @@ public class ModelProjectCache extends AbstractCache<ModelProject> {

public String getModule(long id) {
ModelProject bean = get(id);
return bean != null ? bean.getModule() : "";
return bean != null ? bean.getModule(): "";
}
public ModelProject getByModule(String module){
return getByKey(mm,module);

public ModelProject getByModule(String module) {
return getByKey(mm, module);
}

public String getIdByModule(String module) {
ModelProject bean = getByModule(module);
return bean !=null ? String.valueOf(bean.getId()): "";
return bean != null ? String.valueOf(bean.getId()): "";
}

//找当前项目及其依赖项目的id集合,递归
@@ -65,7 +68,7 @@ public class ModelProjectCache extends AbstractCache<ModelProject> {
set.add(id);
if (StringUtils.isEmpty(bean.getDepends())) return;
String[] dps = bean.getDepends().split(",");
for (String s: dps) {
for (String s : dps) {
s = s.trim();
if (StringUtils.isEmpty(s)) return;
addPrjId(set, NumberUtil.getLongIgnoreErr(s));


+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/FlowConst.java View File

@@ -44,6 +44,7 @@ public interface FlowConst {
public static StrEnumBean LOG = instance.addEnum("log", "流程历史");

}

/**
* 活动类型 1-开始任务 2-用户任务 3-条件分支 4-并行开始 5-并行结束 6-脚本任务 9-结束任务
*/


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProc.java View File

@@ -24,7 +24,7 @@ public class ModelProc extends DefaultEntity {
public void clear() {
procInfo = null;
}
public ProcInfo getProcInfo() {
if (procInfo == null) {
synchronized ("ModelProc_" + getId()) {


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcCache.java View File

@@ -25,9 +25,9 @@ public class ModelProcCache extends AbstractCache<ModelProc> {
}

public ModelProcCache() {
regMap(mk, k-> k.getName().toUpperCase());
regList(mp, k-> String.valueOf(k.getPrjId()));
regList(mc, k-> String.valueOf(k.getMcId()));
regMap(mk, k -> k.getName().toUpperCase());
regList(mp, k -> String.valueOf(k.getPrjId()));
regList(mc, k -> String.valueOf(k.getMcId()));
}

@Override


+ 4
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcHelper.java View File

@@ -22,11 +22,13 @@ public class ModelProcHelper {
public static ModelProc getFromCache(long proc_id) {
return ModelProcCache.getInstance().get(proc_id);
}

public static ProcInfo getProcFromCache(long proc_id) {
ModelProc proc = getFromCache(proc_id);
if (proc == null) return null;
return proc.getProcInfo();
}

/**
* 获取配置的工作流程定义
*
@@ -36,7 +38,7 @@ public class ModelProcHelper {
*/
public static ModelProc getBillProc(long bill_type, long user_id) {
Set<BillFlow> list = BillFlowCache.getInstance().getByBillType(bill_type);
if (CommUtil.isEmpty(list)) {
return null;
}
@@ -101,7 +103,7 @@ public class ModelProcHelper {
return act;
}
}
return null;
}



+ 0
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcLoadHandler.java View File

@@ -1,8 +1,6 @@
package cc.smtweb.system.bpm.web.design.flow;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler;



+ 3
- 7
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcService.java View File

@@ -3,7 +3,6 @@ package cc.smtweb.system.bpm.web.design.flow;
import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
@@ -14,15 +13,12 @@ import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.DefaultDelHandler;
import cc.smtweb.framework.core.mvc.service.DefaultListHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormCache;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.engine.flow.entity.Comment;
import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
* Created by Akmm at 2022/3/22 9:12
@@ -47,12 +43,12 @@ public class ModelProcService extends AbstractCompService {

//保存页面模型
public R saveModel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_SAVE, handler -> ((ModelProcSaveHandler)handler).saveModel());
return pageHandler(params, us, TYPE_SAVE, handler -> ((ModelProcSaveHandler) handler).saveModel());
}

//加载页面模型
public R loadModel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_LOAD, handler -> ((ModelProcLoadHandler)handler).loadModel());
return pageHandler(params, us, TYPE_LOAD, handler -> ((ModelProcLoadHandler) handler).loadModel());
}

//加载工作流的列表字段
@@ -66,7 +62,7 @@ public class ModelProcService extends AbstractCompService {
ModelFormHelper.buildFieldInfo(table, field, col);
ret.add(col);
}
return R.success(ret);
}



+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/define/ProcInfo.java View File

@@ -26,7 +26,7 @@ public class ProcInfo {

public Activity findActivity(String id) {
if (StringUtils.isEmpty(id)) return null;
for (Activity act: activities) {
for (Activity act : activities) {
if (id.equalsIgnoreCase(act.getId())) {
return act;
}
@@ -37,13 +37,13 @@ public class ProcInfo {
//获取任务名称
public String getActNameById(String id) {
Activity act = findActivity(id);
return act != null ? act.getLabel() : "";
return act != null ? act.getLabel(): "";
}

//获取结束节点
public List<Activity> findEndActivity() {
List<Activity> list = new ArrayList<>();
for (Activity act: activities) {
for (Activity act : activities) {
if (act.getType() == FlowConst.ActivityType.END.value) {
list.add(act);
}


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/define/Sign.java View File

@@ -14,5 +14,5 @@ public class Sign extends Handler {
private int minAgree;
//最少会签同意人数单位:0-人数 1-会签同意占比
private int minAgreeUnit;
}

+ 3
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java View File

@@ -1,6 +1,8 @@
package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.common.*;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.vo.ModelCache;
import cc.smtweb.framework.core.db.vo.ModelField;


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelForm.java View File

@@ -231,6 +231,6 @@ public class ModelForm extends DefaultEntity {
//返回单据类型id
public long getBillType() {
SwMap opts = getOpts();
return opts != null ? opts.readLong(ModelFormHelper.KEY_BILL_TYPE) : 0L;
return opts != null ? opts.readLong(ModelFormHelper.KEY_BILL_TYPE): 0L;
}
}

+ 4
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java View File

@@ -16,6 +16,7 @@ import java.util.Set;
public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> {
//被删除的id
private Set<ModelForm> listDeled = new HashSet<>();

public ModelFormDelHandler() {
super(ModelForm.ENTITY_NAME);
}
@@ -29,7 +30,7 @@ public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> {
protected void delDb() {
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class);
Set<ModelForm> l1 = ModelFormCache.getInstance().getListByModule(id);
Set<ModelForm> list = l1 != null ? new HashSet<>(l1) : null;
Set<ModelForm> list = l1 != null ? new HashSet<>(l1): null;
if (CommUtil.isEmpty(list)) {
listDeled = null;
dao.deleteEntity(id);
@@ -37,7 +38,7 @@ public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> {
listDeled = new HashSet<>(list);
List<Long> ids = new ArrayList<>();
ids.add(id);
for (ModelForm form: list) {
for (ModelForm form : list) {
ids.add(form.getId());
}
dao.deleteEntity(ids);
@@ -48,7 +49,7 @@ public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> {
protected void saveSuccess() {
ModelFormCache cache = ModelFormCache.getInstance();
if (!CommUtil.isEmpty(listDeled)) {
for (ModelForm form: listDeled) {
for (ModelForm form : listDeled) {
cache.remove(form.getId());
}
}


+ 10
- 7
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java View File

@@ -1,6 +1,5 @@
package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.common.AbstractEnum;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
@@ -9,7 +8,10 @@ import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.variable.SwVariableFactory;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.*;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.MapUtil;
import cc.smtweb.framework.core.util.SpringUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.spring.BpmConfigBean;
import cc.smtweb.system.bpm.util.CodeGenerator;
import cc.smtweb.system.bpm.util.IdeaUtil;
@@ -493,7 +495,7 @@ public class ModelFormHelper {
field.put("field", pdf.field);
field.put("name", pdf.name);
String label = (String) field.get("field_label");
field.put("label", StringUtils.isEmpty(label)? pdf.label: label);
field.put("label", StringUtils.isEmpty(label) ? pdf.label: label);
field.put("required", pdf.isFieldNotNull());
final SwEnum.DataTypeBean dtb = SwEnum.DataType.instance.getByValue(pdf.dataType);
if (dtb != null) {
@@ -501,10 +503,10 @@ public class ModelFormHelper {
} else {
field.put("maxlength", 0);
}
Map lookup = (Map)field.get("lookup");
if (lookup!=null){
long widgetId = MapUtil.readLong(lookup, "widgetId",-1L);
if(widgetId>0){
Map lookup = (Map) field.get("lookup");
if (lookup != null) {
long widgetId = MapUtil.readLong(lookup, "widgetId", -1L);
if (widgetId > 0) {
setWidget.add(widgetId);
}
}
@@ -513,6 +515,7 @@ public class ModelFormHelper {

/**
* 页面设计时,返回的字段信息,带控件
*
* @param table
* @param field
* @param col


+ 2
- 9
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java View File

@@ -2,23 +2,16 @@ package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler;
import cc.smtweb.framework.core.util.FileUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.SpringUtil;
import cc.smtweb.system.bpm.spring.BpmConfigBean;
import cc.smtweb.system.bpm.util.IdeaUtil;
import cc.smtweb.system.bpm.web.design.db.ModelProjectCache;
import cc.smtweb.system.bpm.web.sys.base.billType.BillTypeCache;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/5/9 16:17
@@ -76,7 +69,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
//加载页面js方法
public R loadJsFuncs() {
ModelForm form = localLoadForm();
List<String> listRet = new ArrayList<>();
R r = R.success(listRet);



+ 0
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormService.java View File

@@ -11,7 +11,6 @@ import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.mvc.service.AbstractCompService;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.DefaultDelHandler;
import cc.smtweb.framework.core.mvc.service.DefaultListHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.SqlUtil;


+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/BaseDatasetField.java View File

@@ -42,6 +42,7 @@ public class BaseDatasetField {
public String defValue;
// type为depend时, 表达式
public String dependExpr;

@JsonIgnore
public boolean isFieldNotNull() {
return notNull == 1;


+ 4
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java View File

@@ -3,7 +3,10 @@ package cc.smtweb.system.bpm.web.design.form.define;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/5/25 15:53


+ 2
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/BaseModelWorker.java View File

@@ -5,16 +5,13 @@ import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormCache;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Set;

/**
* Created by Akmm at 2022-08-14 10:37
@@ -23,6 +20,7 @@ import java.util.Set;
public class BaseModelWorker {
/**
* 模块/页面保存:opts根据模型做些个性化处理,如果是模块,需要添加子页面
*
* @param bean
* @param listFormChild
*/
@@ -74,6 +72,7 @@ public class BaseModelWorker {

/**
* 根据模型生成页面
*
* @param bean
*/
public void buildSaveModel(ModelForm bean) {


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcLtMsWorker.java View File

@@ -14,10 +14,10 @@ public class LcLtMsWorker extends LcMsWorker {

@Override
protected String getTmplId(ModelForm bean) {
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.LIST.value))){
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.LIST.value))) {
return templateList;
}
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.CARD.value))){
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.CARD.value))) {
return templateCard;
}
return super.getTmplId(bean);


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcLtWorker.java View File

@@ -14,10 +14,10 @@ public class LcLtWorker extends LcNormalWorker {

@Override
protected String getTmplId(ModelForm bean) {
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.LIST.value))){
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.LIST.value))) {
return templateList;
}
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.CARD.value))){
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.CARD.value))) {
return templateCard;
}
return super.getTmplId(bean);


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcMsWorker.java View File

@@ -8,16 +8,16 @@ import cc.smtweb.system.bpm.web.design.form.ModelForm;
* @Author:lip
* @Date : 2022/8/28 12:11
*/
public class LcMsWorker extends LcNormalWorker{
public class LcMsWorker extends LcNormalWorker {
private final static String templateList = "model_list_normal";
private final static String templateCard = "model_card_ms";

@Override
protected String getTmplId(ModelForm bean) {
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.LIST.value))){
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.LIST.value))) {
return templateList;
}
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.CARD.value))){
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.CARD.value))) {
return templateCard;
}
return super.getTmplId(bean);


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcNormalWorker.java View File

@@ -59,10 +59,10 @@ public class LcNormalWorker extends BaseModelWorker {

@Override
protected String getTmplId(ModelForm bean) {
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.LIST.value))){
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.LIST.value))) {
return templateList;
}
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.CARD.value))){
if (bean.getName().endsWith(StringUtil.upFirst(SwEnum.PageType.CARD.value))) {
return templateCard;
}
return super.getTmplId(bean);


+ 4
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java View File

@@ -8,7 +8,9 @@ import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.design.form.model.flow.FlowSingleWorker;
import org.apache.commons.lang3.StringUtils;

import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022-08-14 10:02
@@ -17,6 +19,7 @@ import java.util.*;
public class ModelFactory {
private static ModelFactory instance;
private static Map<String, BaseModelWorker> mapWorker;

static {
instance = new ModelFactory();
mapWorker = new HashMap<>();


+ 6
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/flow/FlowSingleWorker.java View File

@@ -22,6 +22,7 @@ import java.util.List;
public class FlowSingleWorker extends BaseModelWorker {
private final static String listTmpl = "model_list_flow";
private final static String cardTmpl = "model_card_flow";

@Override
protected void saveModule(ModelForm bean, List<ModelForm> listFormChild) {
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class);
@@ -58,14 +59,14 @@ public class FlowSingleWorker extends BaseModelWorker {
@Override
public void buildSaveModel(ModelForm bean) {
ModelForm parent = ModelFormCache.getInstance().get(bean.getParent());
if(parent==null){
if (parent == null) {
return;
}
String listFormName = parent.getName()+ StringUtil.upFirst(SwEnum.PageType.LIST.value);
String cardFormName = parent.getName()+ StringUtil.upFirst(SwEnum.PageType.CARD.value);
if(listFormName.equals(bean.getName())){
String listFormName = parent.getName() + StringUtil.upFirst(SwEnum.PageType.LIST.value);
String cardFormName = parent.getName() + StringUtil.upFirst(SwEnum.PageType.CARD.value);
if (listFormName.equals(bean.getName())) {
ModelFormHelper.buildSaveModelByTmpl(bean, listTmpl);
}else if(cardFormName.equals(bean.getName())){
} else if (cardFormName.equals(bean.getName())) {
ModelFormHelper.buildSaveModelByTmpl(bean, cardTmpl);
}
}


+ 42
- 42
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/MenuVO.java View File

@@ -7,46 +7,46 @@ import java.util.List;

@Data
public class MenuVO {
private Long id;
private Long parentId;
private int level;
private String name;
private String path;
private String icon;
private List<MenuVO> children;
// 树结构数据句柄
public static ITreeDataLevelHandler<MenuVO> createTreeHandler() {
return new ITreeDataLevelHandler<MenuVO> () {
@Override
public Long getId (MenuVO node){
return node.getId();
}
@Override
public Long getParentId (MenuVO node){
return node.getParentId();
}
@Override
public List<MenuVO> getChildren (MenuVO node){
return node.children;
}
@Override
public void setChildren (MenuVO node, List <MenuVO> children){
node.children = children;
}
@Override
public int getLevel (MenuVO node){
return node.level;
}
@Override
public void setLevel (MenuVO node, int level){
node.level = level;
}
} ;
}
private Long id;
private Long parentId;
private int level;
private String name;
private String path;
private String icon;
private List<MenuVO> children;
// 树结构数据句柄
public static ITreeDataLevelHandler<MenuVO> createTreeHandler() {
return new ITreeDataLevelHandler<MenuVO>() {
@Override
public Long getId(MenuVO node) {
return node.getId();
}
@Override
public Long getParentId(MenuVO node) {
return node.getParentId();
}
@Override
public List<MenuVO> getChildren(MenuVO node) {
return node.children;
}
@Override
public void setChildren(MenuVO node, List<MenuVO> children) {
node.children = children;
}
@Override
public int getLevel(MenuVO node) {
return node.level;
}
@Override
public void setLevel(MenuVO node, int level) {
node.level = level;
}
};
}
}

+ 5
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/PreviewMenuTreeService.java View File

@@ -9,7 +9,7 @@ import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.vo.ModelCatalog;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.util.TreeDataUtil;
import cc.smtweb.system.bpm.web.design.db.ModelCatalogCache;
@@ -32,9 +32,9 @@ public class PreviewMenuTreeService {

public R treeAll(@SwParam("module") String module, UserSession us) {
String prj_id = ModelProjectCache.getInstance().getIdByModule(module);
if(!SwConsts.SysParam.SYS_DEBUG){
if (!SwConsts.SysParam.SYS_DEBUG) {
List<MenuVO> menuVOList = buildMenu(prj_id, module, us);
if (PubUtil.isNotEmpty(menuVOList)) {
if (!CommUtil.isEmpty(menuVOList)) {
return R.success(menuVOList);
}
}
@@ -79,7 +79,7 @@ public class PreviewMenuTreeService {

public List<MenuVO> buildMenu(String prj_id, String module, UserSession us) {
Set<MenuPlan> set = MenuPlanCache.getInstance().getByP(prj_id);
if (PubUtil.isEmpty(set)) {
if (CommUtil.isEmpty(set)) {
return new ArrayList<>();
}
MenuPlan menuPlan = set.iterator().next();
@@ -107,7 +107,7 @@ public class PreviewMenuTreeService {
menu.setPath(MenuCache.getInstance().getPath(mp.getMenu()));
menu.setParentId(parent_id);
List<MenuVO> child = new ArrayList<>();
if (PubUtil.isNotEmpty(mp.getChildren())) {
if (!CommUtil.isEmpty(mp.getChildren())) {
for (MenuPlanItem cmp : mp.getChildren()) {
List<MenuVO> m = buildMenu(menu.getId(), cmp);
if (m == null) continue;


+ 3
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java View File

@@ -1,8 +1,7 @@
package cc.smtweb.system.bpm.web.engine.dynPage;

import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
@@ -20,9 +19,11 @@ public abstract class AbstractDynPageHandler extends AbstractHandler {
protected PageDatasets datasets;

protected DynPageProvider provider = getProvider();

public DynPageProvider getProvider() {
return new DynPageProvider();
}

@Override
public void init(SwMap params, UserSession us) {
super.init(params, us);


+ 5
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java View File

@@ -14,10 +14,9 @@ import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.mvc.service.SqlNamedPara;
import cc.smtweb.framework.core.util.MapUtil;
import cc.smtweb.framework.core.util.NumberUtil;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.design.form.define.*;
import org.apache.commons.lang3.StringUtils;
import reactor.util.annotation.Nullable;

import java.util.HashMap;
import java.util.HashSet;
@@ -275,7 +274,7 @@ public class DynPageHelper {
return null;
}
IBuilderExpr builder = getBuilder(dynCond.opt);
String ns = isNameSelf ? filter.name : filter.name + "_" + dynCond.hashCode();
String ns = isNameSelf ? filter.name: filter.name + "_" + dynCond.hashCode();
return builder.build(dynCond.opt, filter.sqlName, ns, value, args);
}

@@ -321,13 +320,13 @@ public class DynPageHelper {
});

mapBuilder.put(SwEnum.OptType.IN.value, (opt, field, name, value, args) -> {
if (PubUtil.isEmpty(value.toString())) return "";
if (StringUtil.isEmpty(value.toString())) return "";
args.put(name, value);
return field + " in (:" + name + ") ";
});

mapBuilder.put(SwEnum.OptType.NOT_IN.value, (opt, field, name, value, args) -> {
if (PubUtil.isEmpty(value.toString())) return "";
if (StringUtil.isEmpty(value.toString())) return "";
args.put(name, value);
return field + " not in (:" + name + ") ";
});
@@ -335,7 +334,7 @@ public class DynPageHelper {

private static IBuilderExpr getBuilder(String opt) {
IBuilderExpr builder = mapBuilder.get(opt);
return builder != null ? builder : baseBuilder;
return builder != null ? builder: baseBuilder;
}

interface IBuilderExpr {


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageListHandler.java View File

@@ -52,18 +52,18 @@ public class DynPageListHandler extends AbstractListHandler {
@Override
protected List<SwMap> queryData(String sql, SqlPara sqlPara) {
List<SwMap> list;
SqlNamedPara sp = (SqlNamedPara)sqlPara;
SqlNamedPara sp = (SqlNamedPara) sqlPara;
if (sqlPara.page > 0 && sqlPara.rows > 0) {
list = DbEngine.getInstance().pagedQueryN(sql, SwMap.class, (sqlPara.page - 1) * sqlPara.rows, sqlPara.rows, sp.mapParas);
} else {
list = DbEngine.getInstance().queryN(sql, sp.mapParas, SwMap.class);
}
if(pageDataSet.masterTable > 0L){
if (pageDataSet.masterTable > 0L) {
ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable);
EntityHelper.loadBeanText(masterTable.getName(), list, sp.mapFieldAlias);
}

for (SwMap map: list) {
for (SwMap map : list) {
DynPageHelper.setCalcFields(map, pageDataSet);
}
return list;


+ 11
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageLoadHandler.java View File

@@ -4,8 +4,6 @@ import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.SwListData;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;

/**
@@ -19,6 +17,7 @@ public class DynPageLoadHandler extends AbstractDynPageHandler {

//对应的数据集定义
private PageDataset pageDataSet;

//列表工具类
public DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) {
DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet);
@@ -32,6 +31,7 @@ public class DynPageLoadHandler extends AbstractDynPageHandler {
listHandler.init(params, us);
return listHandler;
}

//新增操作,初始化定义的数据集
public R add() {
//返回的数据,以dataset.name为key,查出的结果(bean或list)为value
@@ -64,11 +64,16 @@ public class DynPageLoadHandler extends AbstractDynPageHandler {
}

//新增初始化 - bean
protected void afterAddBean(PageDataset dataset, SwMap bean){}
protected void afterAddBean(PageDataset dataset, SwMap bean) {
}

//加载之后
protected void afterLoadBean(PageDataset dataset, SwMap bean){}
protected void afterLoadBean(PageDataset dataset, SwMap bean) {
}

//新增初始化 - list
protected void afterAddList(PageDataset dataset, SwListData bean){}
protected void afterAddList(PageDataset dataset, SwListData bean) {
}

//新增操作,初始化定义的数据集
public R addOne() {
@@ -107,7 +112,7 @@ public class DynPageLoadHandler extends AbstractDynPageHandler {
bean = DynRetBean.createList(SwListData.create(getTreeWorker(filter, pageDataSet).buildData(), 0));
} else {//表单类
SwMap data = provider.loadData(filter, pageDataSet);
afterLoadBean(pageDataSet,data);
afterLoadBean(pageDataSet, data);
bean = DynRetBean.createBean(data);
}



+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java View File

@@ -1,13 +1,13 @@
package cc.smtweb.system.bpm.web.engine.dynPage;

import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.EntityHelper;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.mvc.service.AbstractCompProvider;
import cc.smtweb.framework.core.mvc.service.SqlNamedPara;


+ 9
- 9
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageService.java View File

@@ -30,46 +30,46 @@ public class DynPageService extends AbstractCompService {

//新增
public R add(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler)handler).add());
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler) handler).add());
}

//新增
public R addOne(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler)handler).addOne());
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler) handler).addOne());
}

//加载
public R loadOne(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler)handler).loadOne());
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler) handler).loadOne());
}

//保存指定数据集
public R saveOne(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_SAVE, handler -> ((DynPageSaveHandler)handler).saveOne());
return pageHandler(params, us, TYPE_SAVE, handler -> ((DynPageSaveHandler) handler).saveOne());
}

//保存指定数据集
public R save(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_SAVE, handler -> ((DynPageSaveHandler)handler).saveAll());
return pageHandler(params, us, TYPE_SAVE, handler -> ((DynPageSaveHandler) handler).saveAll());
}

//删除指定数据集
public R delOne(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_DEL, handler -> ((DynPageDelHandler)handler).delOne());
return pageHandler(params, us, TYPE_DEL, handler -> ((DynPageDelHandler) handler).delOne());
}

//删除数据
public R del(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_DEL, handler -> ((DynPageDelHandler)handler).delAll());
return pageHandler(params, us, TYPE_DEL, handler -> ((DynPageDelHandler) handler).delAll());
}

//列表总记录数及合计栏
public R total(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler)handler).getTotal());
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler) handler).getTotal());
}

//树过滤
public R treeFilter(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler)handler).treeFilter());
return pageHandler(params, us, TYPE_LOAD, handler -> ((DynPageLoadHandler) handler).treeFilter());
}
}

+ 3
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageTreeHandler.java View File

@@ -50,6 +50,7 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> {

/**
* 构建sql
*
* @return
*/
protected SqlNamedPara buildDataSqlPara(long id) {
@@ -58,6 +59,7 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> {

/**
* 构建sql
*
* @return
*/
protected SqlNamedPara buildFilterSqlPara(String text) {
@@ -86,6 +88,6 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> {
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable);
if (table == null) throw new BizException("未找到数据集表定义:" + pageDataSet.masterTable);
ModelField field = table.findFieldByType(SwEnum.FieldType.NAME.value);
return field != null ? bean.readString(field.getName()) : bean.readString(table.getIdField());
return field != null ? bean.readString(field.getName()): bean.readString(table.getIdField());
}
}

+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynRetBean.java View File

@@ -19,6 +19,7 @@ public class DynRetBean {
public static DynRetBean createBean(DefaultEntity bean) {
return createBean(bean.getData());
}

public static DynRetBean createBean(SwMap swMap) {
SwMap form = (SwMap) swMap.clone();
DynRetBean bean = new DynRetBean();


+ 0
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/IBuildSqlListener.java View File

@@ -1,7 +1,6 @@
package cc.smtweb.system.bpm.web.engine.dynPage;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.SqlNamedPara;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;

/**


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowHelper.java View File

@@ -49,7 +49,7 @@ public class FlowHelper {

public static void stopTask(long billId, long tskId) {
DbEngine.getInstance().update("update " + EntityHelper.getSchemaTableName(Task.ENTITY_NAME) +
" set tsk_statu=? where tsk_pri_id=? and tsk_id<>? and tsk_statu<?", FlowConst.ActivityStatu.STOP.value, billId,tskId, FlowConst.ActivityStatu.SUBMIT.value);
" set tsk_statu=? where tsk_pri_id=? and tsk_id<>? and tsk_statu<?", FlowConst.ActivityStatu.STOP.value, billId, tskId, FlowConst.ActivityStatu.SUBMIT.value);
}

/**
@@ -71,7 +71,7 @@ public class FlowHelper {
return listRet;
}

/**
/**
* 递归处理,兼容判断后面加判断,并发后面跟并发
*
* @param act


+ 2
- 29
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java View File

@@ -10,7 +10,6 @@ import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.framework.core.util.MathUtil;
import cc.smtweb.framework.core.util.NumberUtil;
import cc.smtweb.system.bpm.web.design.flow.FlowConst;
import cc.smtweb.system.bpm.web.design.flow.ModelProc;
@@ -18,7 +17,6 @@ import cc.smtweb.system.bpm.web.design.flow.ModelProcHelper;
import cc.smtweb.system.bpm.web.design.flow.define.Activity;
import cc.smtweb.system.bpm.web.design.flow.define.ProcInfo;
import cc.smtweb.system.bpm.web.engine.flow.entity.*;
import cc.smtweb.system.bpm.web.sys.base.billFlow.BillFlow;
import cc.smtweb.system.bpm.web.sys.user.dept.Dept;
import cc.smtweb.system.bpm.web.sys.user.dept.DeptCache;
import cc.smtweb.system.bpm.web.sys.user.party.Party;
@@ -262,23 +260,11 @@ public class FlowInstance {
String sqlIn = "";
for (Task act : list) {
//如果办理人是当前用户,则置此任务为当前任务
// if (act_inst == null) {
//我办理中的任务:非待办,且是我的任务
if (act.getStatu() != FlowConst.ActivityStatu.WAIT.value) {
if (us.getUserId() == act.getHandler()) {
actInst = act;
}
} else if (FlowHelper.isMyWaitedTask(act.getId(), us.getUserId())) {
//我的待办任务
actInst = act;
if (act.getStatu() == FlowConst.ActivityStatu.WAIT.value && FlowHelper.isMyWaitedTask(act.getId(), us.getUserId())) {
//我的待办任务,设下值,为后面的按钮判断减轻负担
act.setHandler(us.getUserId());
} else {
Activity ae = procDef.getProcInfo().findActivity(act.getActId());
if (ae != null && ae.getType() == FlowConst.ActivityType.END.value) {
actInst = act;
}
}
// }
//如果当前任务为待办理,那么要找其前置任务,作为活动任务,方便取回
if (act.getStatu() == FlowConst.ActivityStatu.WAIT.value && !act.isReject() && !act.isRetake()) {
sqlIn += "," + act.getEntityId();
@@ -288,19 +274,6 @@ public class FlowInstance {
if (StringUtils.isNotEmpty(sqlIn)) {
List<Task> list1 = provider.findBeforeTasks(sqlIn.substring(1));
listTask.addAll(list1);
if (actInst == null) {
for (Task act : list1) {
//如果办理人是当前用户,则置此任务为当前任务
if (us.getUserId() == act.getHandler()) {
actInst = act;
break;
}
}
}
}
//没有我的处理任务,用流程当前任务来
if (actInst == null) {
actInst = provider.findTask(procInst.getTaskId());
}

listTask.addAll(list);


+ 17
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowListener.java View File

@@ -11,16 +11,27 @@ import java.util.List;
*/
public interface FlowListener {
//设置条件计算参数
default void setExprParam(SwMap param) {}
default void setExprParam(SwMap param) {
}

//提交
default void afterSubmit(Task srcTask, List<Task> dstTasks) {}
default void afterSubmit(Task srcTask, List<Task> dstTasks) {
}

//取回
default void afterRetake(Task srcTask, List<Task> dstTasks) {}
default void afterRetake(Task srcTask, List<Task> dstTasks) {
}

//驳回
default void afterReject(Task srcTask, List<Task> dstTasks) {}
default void afterReject(Task srcTask, List<Task> dstTasks) {
}

//办理,签收
default void afterHandle(Task srcTask) {}
default void afterHandle(Task srcTask) {
}

//作废
default void afterDisuse(Task srcTask) {}
default void afterDisuse(Task srcTask) {
}

}

+ 0
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowProvider.java View File

@@ -5,12 +5,8 @@ import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.EntityHelper;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.service.AbstractCompProvider;
import cc.smtweb.framework.core.mvc.service.IDataProvider;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.system.bpm.web.design.flow.FlowConst;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.engine.flow.entity.Comment;
import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst;
import cc.smtweb.system.bpm.web.engine.flow.entity.Task;


+ 76
- 23
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/Comment.java View File

@@ -1,7 +1,6 @@
package cc.smtweb.system.bpm.web.engine.flow.entity;

import cc.smtweb.framework.core.annotation.SwTable;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;

/**
@@ -16,102 +15,156 @@ public class Comment extends DefaultEntity {
super(ENTITY_NAME);
}

/** 主键 */
/**
* 主键
*/
public long getId() {
return getLong("cmt_id");
}

/** 主键 */
/**
* 主键
*/
public void setId(long cmt_id) {
put("cmt_id", cmt_id);
}
/** 流程id */

/**
* 流程id
*/
public long getPriId() {
return getLong("cmt_pri_id");
}

/** 流程id */
/**
* 流程id
*/
public void setPriId(long cmt_pri_id) {
put("cmt_pri_id", cmt_pri_id);
}
/** 任务id */

/**
* 任务id
*/
public long getTskId() {
return getLong("cmt_tsk_id");
}

/** 任务id */
/**
* 任务id
*/
public void setTskId(long cmt_tsk_id) {
put("cmt_tsk_id", cmt_tsk_id);
}
/** 活动id */

/**
* 活动id
*/
public String getActId() {
return getStr("cmt_act_id");
}

/** 活动id */
/**
* 活动id
*/
public void setActId(String cmt_act_id) {
put("cmt_act_id", cmt_act_id);
}
/** 活动名 */

/**
* 活动名
*/
public String getActName() {
return getStr("cmt_act_name");
}

/** 活动名 */
/**
* 活动名
*/
public void setActName(String cmt_act_name) {
put("cmt_act_name", cmt_act_name);
}
/** 主办人 */

/**
* 主办人
*/
public long getHandler() {
return getLong("cmt_handler");
}

/** 主办人 */
/**
* 主办人
*/
public void setHandler(long cmt_handler) {
put("cmt_handler", cmt_handler);
}
/** 开始时间 */

/**
* 开始时间
*/
public long getStartTime() {
return getLong("cmt_start_time");
}

/** 开始时间 */
/**
* 开始时间
*/
public void setStartTime(long cmt_start_time) {
put("cmt_start_time", cmt_start_time);
}
/** 签收时间 */

/**
* 签收时间
*/
public long getHandlerTime() {
return getLong("cmt_handler_time");
}

/** 签收时间 */
/**
* 签收时间
*/
public void setHandlerTime(long cmt_handler_time) {
put("cmt_handler_time", cmt_handler_time);
}
/** 结束时间 */

/**
* 结束时间
*/
public long getEndTime() {
return getLong("cmt_end_time");
}

/** 结束时间 */
/**
* 结束时间
*/
public void setEndTime(long cmt_end_time) {
put("cmt_end_time", cmt_end_time);
}
/** 审批意见 */

/**
* 审批意见
*/
public String getComment() {
return getStr("cmt_comment");
}

/** 审批意见 */
/**
* 审批意见
*/
public void setComment(String cmt_comment) {
put("cmt_comment", cmt_comment);
}
/** 状态 */

/**
* 状态
*/
public int getStatu() {
return getInt("cmt_statu");
}

/** 状态 */
/**
* 状态
*/
public void setStatu(int cmt_statu) {
put("cmt_statu", cmt_statu);
}


+ 62
- 19
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/FlowLog.java View File

@@ -1,7 +1,6 @@
package cc.smtweb.system.bpm.web.engine.flow.entity;

import cc.smtweb.framework.core.annotation.SwTable;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;

/**
@@ -16,84 +15,128 @@ public class FlowLog extends DefaultEntity {
super(ENTITY_NAME);
}

/** 主键 */
/**
* 主键
*/
public long getId() {
return getLong("wfl_id");
}

/** 主键 */
/**
* 主键
*/
public void setId(long wfl_id) {
put("wfl_id", wfl_id);
}
/** 单据id */

/**
* 单据id
*/
public long getPriId() {
return getLong("wfl_pri_id");
}

/** 单据id */
/**
* 单据id
*/
public void setPriId(long wfl_pri_id) {
put("wfl_pri_id", wfl_pri_id);
}
/** 操作人 */

/**
* 操作人
*/
public long getUsrId() {
return getLong("wfl_usr_id");
}

/** 操作人 */
/**
* 操作人
*/
public void setUsrId(long wfl_usr_id) {
put("wfl_usr_id", wfl_usr_id);
}
/** 步骤id */

/**
* 步骤id
*/
public long getActId() {
return getLong("wfl_act_id");
}

/** 步骤id */
/**
* 步骤id
*/
public void setActId(long wfl_act_id) {
put("wfl_act_id", wfl_act_id);
}
/** 步骤名 */

/**
* 步骤名
*/
public String getActName() {
return getStr("wfl_act_name");
}

/** 步骤名 */
/**
* 步骤名
*/
public void setActName(String wfl_act_name) {
put("wfl_act_name", wfl_act_name);
}
/** 操作 */

/**
* 操作
*/
public String getOpt() {
return getStr("wfl_opt");
}

/** 操作 */
/**
* 操作
*/
public void setOpt(String wfl_opt) {
put("wfl_opt", wfl_opt);
}
/** 提交信息 */

/**
* 提交信息
*/
public String getInfo() {
return getStr("wfl_info");
}

/** 提交信息 */
/**
* 提交信息
*/
public void setInfo(String wfl_info) {
put("wfl_info", wfl_info);
}
/** 意见 */

/**
* 意见
*/
public String getComment() {
return getStr("wfl_comment");
}

/** 意见 */
/**
* 意见
*/
public void setComment(String wfl_comment) {
put("wfl_comment", wfl_comment);
}
/** 操作时间 */

/**
* 操作时间
*/
public long getTime() {
return getLong("wfl_time");
}

/** 操作时间 */
/**
* 操作时间
*/
public void setTime(long wfl_time) {
put("wfl_time", wfl_time);
}


+ 103
- 30
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/ProcInst.java View File

@@ -15,111 +15,170 @@ public class ProcInst extends DefaultEntity {
super(ENTITY_NAME);
}

/** 主键 */
/**
* 主键
*/
public long getId() {
return getLong("pri_id");
}

/** 主键 */
/**
* 主键
*/
public void setId(long pri_id) {
put("pri_id", pri_id);
}
/** 单据编号 */

/**
* 单据编号
*/
public String getBillCode() {
return getStr("pri_bill_code");
}

/** 单据编号 */
/**
* 单据编号
*/
public void setBillCode(String pri_bill_code) {
put("pri_bill_code", pri_bill_code);
}
/** 制单日期 */

/**
* 制单日期
*/
public long getMakeDate() {
return getLong("pri_make_date");
}

/** 制单日期 */
/**
* 制单日期
*/
public void setMakeDate(long pri_make_date) {
put("pri_make_date", pri_make_date);
}
/** 单据类别 */

/**
* 单据类别
*/
public long getBillType() {
return getLong("pri_bill_type");
}

/** 单据类别 */
/**
* 单据类别
*/
public void setBillType(long pri_bill_type) {
put("pri_bill_type", pri_bill_type);
}
/** 编制单位 */

/**
* 编制单位
*/
public long getPartyId() {
return getLong("pri_party_id");
}

/** 编制单位 */
/**
* 编制单位
*/
public void setPartyId(long pri_party_id) {
put("pri_party_id", pri_party_id);
}
/** 编制部门 */

/**
* 编制部门
*/
public long getDeptId() {
return getLong("pri_dept_id");
}

/** 编制部门 */
/**
* 编制部门
*/
public void setDeptId(long pri_dept_id) {
put("pri_dept_id", pri_dept_id);
}
/** 摘要 */

/**
* 摘要
*/
public String getBillDesc() {
return getStr("pri_bill_desc");
}

/** 摘要 */
/**
* 摘要
*/
public void setBillDesc(String pri_bill_desc) {
put("pri_bill_desc", pri_bill_desc);
}
/** 流程定义 */

/**
* 流程定义
*/
public long getPrcId() {
return getLong("pri_prc_id");
}

/** 流程定义 */
/**
* 流程定义
*/
public void setPrcId(long pri_prc_id) {
put("pri_prc_id", pri_prc_id);
}
/** 开始时间 */

/**
* 开始时间
*/
public long getStartTime() {
return getLong("pri_start_time");
}

/** 开始时间 */
/**
* 开始时间
*/
public void setStartTime(long pri_start_time) {
put("pri_start_time", pri_start_time);
}
/** 结束时间 */

/**
* 结束时间
*/
public long getEndTime() {
return getLong("pri_end_time");
}

/** 结束时间 */
/**
* 结束时间
*/
public void setEndTime(long pri_end_time) {
put("pri_end_time", pri_end_time);
}
/** 最后操作用户 */

/**
* 最后操作用户
*/
public long getUserId() {
return getLong("pri_user_id");
}

/** 最后操作用户 */
/**
* 最后操作用户
*/
public void setUserId(long pri_user_id) {
put("pri_user_id", pri_user_id);
}
/** 当前任务 */

/**
* 当前任务
*/
public long getTaskId() {
return getLong("pri_task_id");
}

/** 当前任务 */
/**
* 当前任务
*/
public void setTaskId(long pri_task_id) {
put("pri_task_id", pri_task_id);
}
@@ -132,30 +191,44 @@ public class ProcInst extends DefaultEntity {
put("pri_act_name", priActName);
}

/** 单据状态 */
/**
* 单据状态
*/
public int getStatu() {
return getInt("pri_statu");
}

/** 单据状态 */
/**
* 单据状态
*/
public void setStatu(int pri_statu) {
put("pri_statu", pri_statu);
}
/** 单据描述 */

/**
* 单据描述
*/
public String getBillInfo() {
return getStr("pri_bill_info");
}

/** 单据描述 */
/**
* 单据描述
*/
public void setBillInfo(String pri_bill_info) {
put("pri_bill_info", pri_bill_info);
}
/** 单据链接 */

/**
* 单据链接
*/
public String getUrl() {
return getStr("pri_url");
}

/** 单据链接 */
/**
* 单据链接
*/
public void setUrl(String pri_url) {
put("pri_url", pri_url);
}


+ 139
- 40
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/Task.java View File

@@ -15,183 +15,282 @@ public class Task extends DefaultEntity {
super(ENTITY_NAME);
}

/** 主键 */
/**
* 主键
*/
public long getId() {
return getLong("tsk_id");
}

/** 主键 */
/**
* 主键
*/
public void setId(long tsk_id) {
put("tsk_id", tsk_id);
}
/** 流程实例id */

/**
* 流程实例id
*/
public long getPriId() {
return getLong("tsk_pri_id");
}

/** 流程实例id */
/**
* 流程实例id
*/
public void setPriId(long tsk_pri_id) {
put("tsk_pri_id", tsk_pri_id);
}
/** 流程定义id */

/**
* 流程定义id
*/
public long getPrcId() {
return getLong("tsk_prc_id");
}

/** 流程定义id */
/**
* 流程定义id
*/
public void setPrcId(long tsk_prc_id) {
put("tsk_prc_id", tsk_prc_id);
}
/** 活动定义id */

/**
* 活动定义id
*/
public String getActId() {
return getStr("tsk_act_id");
}

/** 活动定义id */
/**
* 活动定义id
*/
public void setActId(String tsk_act_id) {
put("tsk_act_id", tsk_act_id);
}
/** 活动名称 */

/**
* 活动名称
*/
public String getActName() {
return getStr("tsk_act_name");
}

/** 活动名称 */
/**
* 活动名称
*/
public void setActName(String tsk_act_name) {
put("tsk_act_name", tsk_act_name);
}
/** 主办人 */

/**
* 主办人
*/
public long getHandler() {
return getLong("tsk_handler");
}

/** 主办人 */
/**
* 主办人
*/
public void setHandler(long tsk_handler) {
put("tsk_handler", tsk_handler);
}
/** 开始时间 */

/**
* 开始时间
*/
public long getStartTime() {
return getLong("tsk_start_time");
}

/** 开始时间 */
/**
* 开始时间
*/
public void setStartTime(long tsk_start_time) {
put("tsk_start_time", tsk_start_time);
}
/** 签收时间 */

/**
* 签收时间
*/
public long getHandlerTime() {
return getLong("tsk_handler_time");
}

/** 签收时间 */
/**
* 签收时间
*/
public void setHandlerTime(long tsk_handler_time) {
put("tsk_handler_time", tsk_handler_time);
}
/** 结束时间 */

/**
* 结束时间
*/
public long getEndTime() {
return getLong("tsk_end_time");
}

/** 结束时间 */
/**
* 结束时间
*/
public void setEndTime(long tsk_end_time) {
put("tsk_end_time", tsk_end_time);
}
/** 状态 */

/**
* 状态
*/
public int getStatu() {
return getInt("tsk_statu");
}

/** 状态 */
/**
* 状态
*/
public void setStatu(int tsk_statu) {
put("tsk_statu", tsk_statu);
}
/** 审批意见 */

/**
* 审批意见
*/
public String getComment() {
return getStr("tsk_comment");
}

/** 审批意见 */
/**
* 审批意见
*/
public void setComment(String tsk_comment) {
put("tsk_comment", tsk_comment);
}
/** 是否制单步骤 */

/**
* 是否制单步骤
*/
public boolean isMake() {
return getBool("tsk_is_make");
}

/** 是否制单步骤 */
/**
* 是否制单步骤
*/
public void setMake(boolean tsk_is_make) {
setBool("tsk_is_make", tsk_is_make);
}
/** 是否需要会签 */

/**
* 是否需要会签
*/
public boolean isSign() {
return getBool("tsk_is_sign");
}

/** 是否需要会签 */
/**
* 是否需要会签
*/
public void setSign(boolean tsk_is_sign) {
setBool("tsk_is_sign", tsk_is_sign);
}
/** 会签人数 */

/**
* 会签人数
*/
public int getSignTotal() {
return getInt("tsk_sign_total");
}

/** 会签人数 */
/**
* 会签人数
*/
public void setSignTotal(int tsk_sign_total) {
put("tsk_sign_total", tsk_sign_total);
}
/** 设置会签过关人数 */

/**
* 设置会签过关人数
*/
public int getSignPass() {
return getInt("tsk_sign_pass");
}

/** 设置会签过关人数 */
/**
* 设置会签过关人数
*/
public void setSignPass(int tsk_sign_pass) {
put("tsk_sign_pass", tsk_sign_pass);
}
/** 会签同意人数 */

/**
* 会签同意人数
*/
public int getSignAgree() {
return getInt("tsk_sign_agree");
}

/** 会签同意人数 */
/**
* 会签同意人数
*/
public void setSignAgree(int tsk_sign_agree) {
put("tsk_sign_agree", tsk_sign_agree);
}
/** 是否被驳回 */

/**
* 是否被驳回
*/
public boolean isReject() {
return getBool("tsk_is_reject");
}

/** 是否被驳回 */
/**
* 是否被驳回
*/
public void setReject(boolean tsk_is_reject) {
setBool("tsk_is_reject", tsk_is_reject);
}
/** 是否取回 */

/**
* 是否取回
*/
public boolean isRetake() {
return getBool("tsk_is_retake");
}

/** 是否取回 */
/**
* 是否取回
*/
public void setRetake(boolean tsk_is_retake) {
setBool("tsk_is_retake", tsk_is_retake);
}
/** 是否自动任务 */

/**
* 是否自动任务
*/
public boolean isAuto() {
return getBool("tsk_is_auto");
}

/** 是否自动任务 */
/**
* 是否自动任务
*/
public void setAuto(boolean tsk_is_auto) {
setBool("tsk_is_auto", tsk_is_auto);
}
/** 备注 */

/**
* 备注
*/
public String getRemark() {
return getStr("tsk_remark");
}

/** 备注 */
/**
* 备注
*/
public void setRemark(String tsk_remark) {
put("tsk_remark", tsk_remark);
}


+ 27
- 8
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/TaskRel.java View File

@@ -15,39 +15,58 @@ public class TaskRel extends DefaultEntity {
super(ENTITY_NAME);
}

/** 主键 */
/**
* 主键
*/
public long getId() {
return getLong("trl_id");
}

/** 主键 */
/**
* 主键
*/
public void setId(long trl_id) {
put("trl_id", trl_id);
}
/** 流程实例id */

/**
* 流程实例id
*/
public long getPriId() {
return getLong("trl_pri_id");
}

/** 流程实例id */
/**
* 流程实例id
*/
public void setPriId(long trl_pri_id) {
put("trl_pri_id", trl_pri_id);
}
/** 前任务id */

/**
* 前任务id
*/
public long getSrcTaskId() {
return getLong("trl_src_task_id");
}

/** 前任务id */
/**
* 前任务id
*/
public void setSrcTaskId(long trl_src_task_id) {
put("trl_src_task_id", trl_src_task_id);
}
/** 目标任务id */

/**
* 目标任务id
*/
public long getDstTaskId() {
return getLong("trl_dst_task_id");
}

/** 目标任务id */
/**
* 目标任务id
*/
public void setDstTaskId(long trl_dst_task_id) {
put("trl_dst_task_id", trl_dst_task_id);
}

+ 2
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowDelHandler.java View File

@@ -11,12 +11,13 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleDelHandler;
*/
public class FlowDelHandler extends LCSingleDelHandler implements FlowListener {
protected FlowInstance flowInstance;

@Override
protected void localDel(long id, ModelTable table) {
long taskId = params.readLong("taskId");
flowInstance = FlowInstance.createById(us, this, id, taskId);
flowInstance.delete();
super.localDel(id, table);
}
}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowListHandler.java View File

@@ -14,7 +14,7 @@ import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst;
* Created by Akmm at 2022-08-29 11:41
*/
public class FlowListHandler extends DynPageListHandler {
static IBuildSqlListener sqlListener = new IBuildSqlListener(){
static IBuildSqlListener sqlListener = new IBuildSqlListener() {
@Override
public void buildSelect(PageDataset dataSet, StringBuilder sql) {
sql.append("\ninner join " + EntityHelper.getSchemaTableName(ProcInst.ENTITY_NAME) + " on pri_id=" + dataSet._getModelTable().getIdField());


+ 2
- 11
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java View File

@@ -1,27 +1,18 @@
package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwConsts;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.service.SwListData;
import cc.smtweb.system.bpm.web.design.flow.FlowConst;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;
import cc.smtweb.system.bpm.web.engine.flow.FlowHelper;
import cc.smtweb.system.bpm.web.engine.flow.FlowInstance;
import cc.smtweb.system.bpm.web.engine.flow.FlowListener;
import cc.smtweb.system.bpm.web.engine.flow.FlowProvider;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleLoadHandler;

import java.util.ArrayList;

/**
* Created by Akmm at 2022-08-26 17:15
* 流程加载
@@ -32,7 +23,7 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad
@Override
protected void afterAdd(SwMap ret, T bean) {
flowInstance = FlowInstance.createByBillType(us, this, form.getBillType());
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets);
bean.setEntityId(flowInstance.getProcInst().getId());

@@ -54,7 +45,7 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad
ret.put(cardDataset.name, DynRetBean.createBean(bean));

//加载流程信息
flowInstance = FlowInstance.createById(us,this, id, taskId);
flowInstance = FlowInstance.createById(us, this, id, taskId);

ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst()));
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0)));


+ 1
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java View File

@@ -1,6 +1,5 @@
package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.exception.BizException;
@@ -35,7 +34,7 @@ public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSave
if (bean.isNew()) {
flowInstance = FlowInstance.createByBillType(us, this, form.getBillType());
} else {
flowInstance = FlowInstance.createById(us,this, id, taskId);
flowInstance = FlowInstance.createById(us, this, id, taskId);
}
flowInstance.readFromPage(data);
flowInstance.getProcInst().setIsNew(bean.isNew());


+ 3
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java View File

@@ -4,7 +4,6 @@ import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.IWorker;
import cc.smtweb.framework.core.session.UserSession;
@@ -20,6 +19,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService;
@SwService
public class FlowSingleService extends LCSingleService {
public static final String TYPE_FLOW = "flow";

@Override
protected AbstractHandler createHandler(String type) {
if (TYPE_FLOW.equals(type)) return new FlowTransHandler();
@@ -43,12 +43,13 @@ public class FlowSingleService extends LCSingleService {

protected R flowHandler(SwMap params, UserSession us, IWorker<FlowTransHandler> worker) {
try {
FlowTransHandler handler = (FlowTransHandler)getHandler(params, us, TYPE_FLOW);
FlowTransHandler handler = (FlowTransHandler) getHandler(params, us, TYPE_FLOW);
return worker.doWork(handler);
} catch (Exception e) {
return R.error("操作失败!", e);
}
}

public R submit(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::submit);
}


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java View File

@@ -17,7 +17,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper;
* Created by Akmm at 2022-09-01 15:03
* 流程流转
*/
public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHandler implements FlowListener{
public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHandler implements FlowListener {
//流程id
protected long billId;
//任务id


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java View File

@@ -27,7 +27,7 @@ public abstract class AbsDelHandler extends AbstractDynPageHandler {
long id = params.readLong("id");
if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!");
//数据集
PageDataset pageDataset = ModelUtils.findPageDatasetByName(this.datasets,dsName);
PageDataset pageDataset = ModelUtils.findPageDatasetByName(this.datasets, dsName);
//
checkBean(pageDataset, id);
//


+ 7
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java View File

@@ -18,6 +18,7 @@ public abstract class AbsLoadHandler extends AbstractDynPageHandler {

/**
* 新增初始化
*
* @param dsName
* @return
*/
@@ -36,19 +37,21 @@ public abstract class AbsLoadHandler extends AbstractDynPageHandler {

/**
* 加载卡片数据
*
* @param dsName
* @return
*/
protected SwMap doLoadCard(String dsName){
protected SwMap doLoadCard(String dsName) {
//过滤条件
SwMap filter = params.readMap("filter");
//对应的数据集定义
PageDataset loadDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName);
PageDataset loadDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName);
return provider.loadData(filter, loadDataSet);
}

/**
* 列表数据
*
* @return
*/
protected DynRetBean doList(String dsName) {
@@ -56,7 +59,7 @@ public abstract class AbsLoadHandler extends AbstractDynPageHandler {
SwMap filter = params.readMap("filter");

//对应的数据集定义
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName);
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName);

return DynRetBean.createList(getListWorker(filter, listDataSet).buildListData());
}
@@ -71,7 +74,7 @@ public abstract class AbsLoadHandler extends AbstractDynPageHandler {
SwMap filter = params.readMap("filter");

//对应的数据集定义
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName);
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName);

return getListWorker(filter, listDataSet).getTotal();
}


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java View File

@@ -29,7 +29,7 @@ import java.util.Map;
* @Author:lip
* @Date : 2022/9/2 15:02
*/
public abstract class AbsSaveHandler <T extends DefaultEntity> extends AbstractDynPageHandler {
public abstract class AbsSaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler {
private Map<String, List<T>> mapTreeBean = new HashMap<>();

protected void setNewId(T bean) {
@@ -43,7 +43,7 @@ public abstract class AbsSaveHandler <T extends DefaultEntity> extends AbstractD
SwMap data = params.readMap("data");
if (data == null) throw new BizException("没有收到待保存的的数据:" + dsName + "!");
//对应的数据集定义
PageDataset pageDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName);
PageDataset pageDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName);
//读取待保存的bean
T bean = readBeanFromPage(pageDataSet, data.readMap(dsName).readMap("form"));
if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上


+ 8
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java View File

@@ -11,36 +11,40 @@ public class LCLC1DelHandler extends AbsDelHandler {

/**
* 左列表删除
*
* @return
*/
public R lLDel(){
public R lLDel() {
doDel(LCLC1Define.dsLList);
return R.success();
}

/**
* 左卡片删除
*
* @return
*/
public R lCDel(){
public R lCDel() {
doDel(LCLC1Define.dsLCard);
return R.success();
}

/**
* 右列表删除
*
* @return
*/
public R rLDel(){
public R rLDel() {
doDel(LCLC1Define.dsRList);
return R.success();
}

/**
* 右卡片删除
*
* @return
*/
public R rCDel(){
public R rCDel() {
doDel(LCLC1Define.dsRCard);
return R.success();
}


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save