Przeglądaj źródła

重构:去掉多余引用+格式化

4.0
郑根木 2 lat temu
rodzic
commit
0397ca5b77
100 zmienionych plików z 1904 dodań i 1557 usunięć
  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. +52
    -55
      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. +4
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachFileWork.java
  16. +2
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachFtpWork.java
  17. +39
    -38
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachHelper.java
  18. +15
    -14
      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. +5
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilFile.java
  33. +59
    -58
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/XmlUtil.java
  34. +79
    -79
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/YamlUtil.java
  35. +7
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/FtpTaskManager.java
  36. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/IFtpServerConfig.java
  37. +5
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/IFtpUtil.java
  38. +1
    -10
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/BpmStartedListener.java
  39. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogCache.java
  40. +4
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java
  41. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java
  42. +9
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelProjectCache.java
  43. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/FlowConst.java
  44. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProc.java
  45. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcCache.java
  46. +4
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcHelper.java
  47. +0
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcLoadHandler.java
  48. +3
    -7
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcService.java
  49. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/define/ProcInfo.java
  50. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/define/Sign.java
  51. +3
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java
  52. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelForm.java
  53. +4
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java
  54. +10
    -7
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  55. +2
    -9
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java
  56. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/BaseDatasetField.java
  57. +4
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java
  58. +2
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/BaseModelWorker.java
  59. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcLtMsWorker.java
  60. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcLtWorker.java
  61. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcMsWorker.java
  62. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcNormalWorker.java
  63. +4
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java
  64. +6
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/flow/FlowSingleWorker.java
  65. +42
    -42
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/MenuVO.java
  66. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/PreviewMenuTreeService.java
  67. +3
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java
  68. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java
  69. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageListHandler.java
  70. +11
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageLoadHandler.java
  71. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java
  72. +9
    -9
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageService.java
  73. +3
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageTreeHandler.java
  74. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynRetBean.java
  75. +0
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/IBuildSqlListener.java
  76. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowHelper.java
  77. +17
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowListener.java
  78. +0
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowProvider.java
  79. +76
    -23
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/Comment.java
  80. +62
    -19
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/FlowLog.java
  81. +103
    -30
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/ProcInst.java
  82. +139
    -40
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/Task.java
  83. +27
    -8
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/entity/TaskRel.java
  84. +2
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowDelHandler.java
  85. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowListHandler.java
  86. +2
    -11
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java
  87. +1
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java
  88. +3
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java
  89. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java
  90. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java
  91. +7
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java
  92. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java
  93. +8
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java
  94. +12
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java
  95. +2
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java
  96. +15
    -14
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java
  97. +11
    -9
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDelHandler.java
  98. +10
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsLoadHandler.java
  99. +6
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java
  100. +9
    -9
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsService.java

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/BpmApplication.java Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

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

/**


+ 52
- 55
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/controller/AttachController.java Wyświetl plik

@@ -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,14 +90,14 @@ 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(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) {
@@ -106,8 +105,7 @@ public class AttachController {
}
if (StringUtil.isEmpty(attachName)) {
attachName = file.getOriginalFilename();
}
else {
} else {
attachName = attachName + attach.getSuffix();
}
attach.setName(attachName);
@@ -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 = StringUtil.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 (StringUtil.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(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);
@@ -235,25 +231,26 @@ 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(StringUtil.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);//附件类别
@@ -261,16 +258,16 @@ public class AttachController {
attach.setPartyId(-1l);
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;
@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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;
}

+ 4
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachFileWork.java Wyświetl plik

@@ -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();
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


+ 2
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachFtpWork.java Wyświetl plik

@@ -31,6 +31,7 @@ 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 (StringUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/"))
@@ -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();
}


+ 39
- 38
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachHelper.java Wyświetl plik

@@ -31,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);
@@ -43,10 +44,10 @@ public final class AttachHelper {
}

//删除ftp服务器的文件
public boolean deleteOneAttach(String attachId) throws Exception {
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());
@@ -57,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);
@@ -66,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 {
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) + ")");
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())) {
@@ -117,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) {
@@ -135,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("附件不存在!");

@@ -155,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();
@@ -174,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());
}

@@ -186,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);
@@ -201,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 (!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<>();
@@ -225,7 +226,7 @@ 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 (NumberUtil.compare(n, 1024) < 0) return NumberUtil.toStdNumberString(n, 0) + "KB";
@@ -239,23 +240,23 @@ 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);//附件类别
@@ -263,7 +264,7 @@ public final class AttachHelper {
attach.setPartyId(-1l);
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))));
@@ -276,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() + "";
}
}

+ 15
- 14
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/spring/file/attach/AttachUtil.java Wyświetl plik

@@ -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() {
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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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);
}
}
}
}
}

+ 5
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/UtilFile.java Wyświetl plik

@@ -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<>();
@@ -1069,6 +1069,7 @@ public class UtilFile {

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

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


+ 59
- 58
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/XmlUtil.java Wyświetl plik

@@ -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 Wyświetl plik

@@ -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());
}
}
}

+ 7
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/FtpTaskManager.java Wyświetl plik

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



import cc.smtweb.framework.core.util.DateUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.util.UtilLogger;
@@ -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 = StringUtil.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();


+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/util/ftp/IFtpServerConfig.java Wyświetl plik

@@ -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 Wyświetl plik

@@ -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);



+ 1
- 10
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/BpmStartedListener.java Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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);



+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/BaseDatasetField.java Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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;
}
};
}
}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/PreviewMenuTreeService.java Wyświetl plik

@@ -32,7 +32,7 @@ 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 (!CommUtil.isEmpty(menuVOList)) {
return R.success(menuVOList);


+ 3
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java Wyświetl plik

@@ -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);


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java Wyświetl plik

@@ -274,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);
}

@@ -334,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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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


+ 17
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowListener.java Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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();
}


+ 12
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java Wyświetl plik

@@ -13,6 +13,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper;
public class LCLC1LoadHandler extends AbsLoadHandler {
/**
* 左表新增
*
* @return
*/
public R lAdd() {
@@ -22,6 +23,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler {

/**
* 右表新增
*
* @return
*/
public R rAdd() {
@@ -31,6 +33,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler {

/**
* 左表编辑
*
* @return
*/
public R lLoad() {
@@ -40,6 +43,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler {

/**
* 右表编辑
*
* @return
*/
public R rLoad() {
@@ -49,35 +53,39 @@ public class LCLC1LoadHandler extends AbsLoadHandler {

/**
* 左列表加载
*
* @return
*/
public R lList(){
public R lList() {
DynRetBean list = doList(LCLC1Define.dsLList);
return R.success(list);
}

/**
* 右列表加载
*
* @return
*/
public R rList(){
public R rList() {
DynRetBean list = doList(LCLC1Define.dsRList);
return R.success(list);
}

/**
* 左列表分页数据
*
* @return
*/
public R getLTotal(){
public R getLTotal() {
return doTotal(LCLC1Define.dsLList);
}

/**
* 右列表分页数据
*
* @return
*/
public R getRTotal(){
public R getRTotal() {
return doTotal(LCLC1Define.dsRList);
}
}

+ 2
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java Wyświetl plik

@@ -12,6 +12,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper;
public class LCLC1SaveHandler extends AbsSaveHandler {
/**
* 左表保存
*
* @return
*/
public R lSave() {
@@ -21,6 +22,7 @@ public class LCLC1SaveHandler extends AbsSaveHandler {

/**
* 右表保存
*
* @return
*/
public R rSave() {


+ 15
- 14
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java Wyświetl plik

@@ -19,6 +19,7 @@ public class LCLC1Service extends DynPageService {
protected final static String TYPE_MODEL_LOAD = "modelLoad";
protected final static String TYPE_MODEL_SAVE = "modelSave";
protected final static String TYPE_MODEL_DEL = "modelDel";

//
@Override
protected AbstractHandler createHandler(String type) {
@@ -37,73 +38,73 @@ public class LCLC1Service extends DynPageService {

//保存
public R modelLSave(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCLC1SaveHandler)handler).lSave());
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCLC1SaveHandler) handler).lSave());
}

//读取
public R modelLLoad(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCLC1LoadHandler)handler).lLoad());
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCLC1LoadHandler) handler).lLoad());
}

//读取
public R modelLAdd(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCLC1LoadHandler)handler).lAdd());
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCLC1LoadHandler) handler).lAdd());
}

//删除
public R modelLLDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler)handler).lLDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lLDel());
}

//删除
public R modelLCDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler)handler).lCDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lCDel());
}

//列表数据
public R modelLList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler)handler).lList());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler) handler).lList());
}

//列表总记录数及合计栏
public R modelLListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler)handler).getLTotal());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler) handler).getLTotal());
}

//右表
//保存
public R modelRSave(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCLC1SaveHandler)handler).rSave());
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCLC1SaveHandler) handler).rSave());
}

//读取
public R modelRLoad(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCLC1LoadHandler)handler).rLoad());
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCLC1LoadHandler) handler).rLoad());
}

//读取
public R modelRAdd(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCLC1LoadHandler)handler).rAdd());
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCLC1LoadHandler) handler).rAdd());
}

//删除
public R modelRLDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler)handler).rLDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rLDel());
}

//删除
public R modelRCDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler)handler).rCDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rCDel());
}

//列表数据
public R modelRList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler)handler).rList());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler) handler).rList());
}

//列表总记录数及合计栏
public R modelRListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler)handler).getRTotal());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler) handler).getRTotal());
}

}

+ 11
- 9
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDelHandler.java Wyświetl plik

@@ -25,17 +25,19 @@ public class LCMsDelHandler extends AbsDelHandler {

/**
* 列表删除
*
* @return
*/
public R lDel(){
public R lDel() {
return del();
}

/**
* 卡片删除
*
* @return
*/
public R cDel(){
public R cDel() {
return del();
}

@@ -49,13 +51,13 @@ public class LCMsDelHandler extends AbsDelHandler {
if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!");
SwMap props = form.getOpts().readMap("config").readMap("props");
//主表
ModelTable masterTable = ModelTableCache.getInstance().get(props.readLong("masterTable",-1L));
Assert.notNull(masterTable,"未获取到主表配置");
ModelTable masterTable = ModelTableCache.getInstance().get(props.readLong("masterTable", -1L));
Assert.notNull(masterTable, "未获取到主表配置");

//获取子表
ModelTable subTable = ModelTableCache.getInstance().get(props.readLong("subTable",-1L));
String subForeignKey = props.readString("subForeignKey","-1");
Assert.isTrue(subTable!= null && !subForeignKey.equals("-1"),"未获取到子表配置");
ModelTable subTable = ModelTableCache.getInstance().get(props.readLong("subTable", -1L));
String subForeignKey = props.readString("subForeignKey", "-1");
Assert.isTrue(subTable != null && !subForeignKey.equals("-1"), "未获取到子表配置");

//
DbEngine engine = DbEngine.getInstance();
@@ -88,7 +90,7 @@ public class LCMsDelHandler extends AbsDelHandler {
return R.success();
}

protected void checkDetails(List<? extends DefaultEntity> details){
details.forEach(item-> EntityHelper.checkExists(item.getModelTable().getId(), item.getEntityId()));
protected void checkDetails(List<? extends DefaultEntity> details) {
details.forEach(item -> EntityHelper.checkExists(item.getModelTable().getId(), item.getEntityId()));
}
}

+ 10
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsLoadHandler.java Wyświetl plik

@@ -13,6 +13,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper;
public class LCMsLoadHandler extends AbsLoadHandler {
/**
* 主表新增
*
* @return
*/
public R mAdd() {
@@ -22,6 +23,7 @@ public class LCMsLoadHandler extends AbsLoadHandler {

/**
* 主表编辑
*
* @return
*/
public R mLoad() {
@@ -31,35 +33,39 @@ public class LCMsLoadHandler extends AbsLoadHandler {

/**
* 主表列表加载
*
* @return
*/
public R mList(){
public R mList() {
DynRetBean list = doList(LCMsDefine.dsMList);
return R.success(list);
}

/**
* 子列表加载
*
* @return
*/
public R sList(){
public R sList() {
DynRetBean list = doList(LCMsDefine.dsSList);
return R.success(list);
}

/**
* 主列表分页数据
*
* @return
*/
public R getMTotal(){
public R getMTotal() {
return doTotal(LCMsDefine.dsMList);
}

/**
* 子列表分页数据
*
* @return
*/
public R getSTotal(){
public R getSTotal() {
return doTotal(LCMsDefine.dsSList);
}
}

+ 6
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java Wyświetl plik

@@ -38,8 +38,8 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> {
if (data == null) throw new BizException("没有收到待保存的的数据:" + LCMsDefine.dsMCard + "!");

//获取子表关联字段
String subForeignKey = form.getOpts().readMap("config").readMap("props").readString("subForeignKey","-1");
Assert.isTrue(!subForeignKey.equals("-1"),"未获取到子表外键配置");
String subForeignKey = form.getOpts().readMap("config").readMap("props").readString("subForeignKey", "-1");
Assert.isTrue(!subForeignKey.equals("-1"), "未获取到子表外键配置");

//读取待保存的bean
DefaultEntity masterBean = readBeanFromPage(masterDataSet, data.readMap(LCMsDefine.dsMCard).readMap("form"));
@@ -49,7 +49,7 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> {
}
// 读取子表数据
SwMap details = params.readMap("details");
Assert.notNull(details,"没有收到待保存的明细数据");
Assert.notNull(details, "没有收到待保存的明细数据");
//
ArrayList<DefaultEntity> inserted = new ArrayList<>();
ArrayList<DefaultEntity> updated = new ArrayList<>();
@@ -57,7 +57,7 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> {
SwMap rowData = new SwMap();
rowData.putAll(row);
DefaultEntity insertBean = readBeanFromPage(subDataSet, rowData);
insertBean.put(subForeignKey,masterBean.getEntityId());
insertBean.put(subForeignKey, masterBean.getEntityId());
inserted.add(insertBean);
});
details.readListMap("updated").forEach(row -> {
@@ -76,12 +76,12 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> {
public void work() {
saveBean(masterBean);
ModelTable subTable = ModelTableCache.getInstance().get(subDataSet.masterTable);
Assert.notNull(subTable,"未获取到子表");
Assert.notNull(subTable, "未获取到子表");

EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(subTable.getName());
dao.batchInsertEntity(inserted);
dao.batchUpdateEntity(updated);
if (deleted != null){
if (deleted != null) {
dao.deleteEntity(deleted);
}
}


+ 9
- 9
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsService.java Wyświetl plik

@@ -37,46 +37,46 @@ public class LCMsService extends DynPageService {

//保存
public R modelSave(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCMsSaveHandler)handler).save());
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCMsSaveHandler) handler).save());
}

//读取
public R modelLoad(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCMsLoadHandler)handler).mLoad());
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCMsLoadHandler) handler).mLoad());
}

//新增
public R modelAdd(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCMsLoadHandler)handler).mAdd());
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCMsLoadHandler) handler).mAdd());
}

//列表删除
public R modelLDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler)handler).lDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler) handler).lDel());
}

//卡片删除
public R modelCDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler)handler).cDel());
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler) handler).cDel());
}

//主表列表数据
public R modelMList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).mList());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler) handler).mList());
}

//主表列表总记录数及合计栏
public R modelMListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).getMTotal());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler) handler).getMTotal());
}

//子表列表数据
public R modelSList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).sList());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler) handler).sList());
}

//子表列表总记录数及合计栏
public R modelSListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).getSTotal());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler) handler).getSTotal());
}
}

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików

Ładowanie…
Anuluj
Zapisz