@@ -9,6 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
@SpringBootApplication | @SpringBootApplication | ||||
public class BpmApplication { | public class BpmApplication { | ||||
public static void main(String[] args) { | public static void main(String[] args) { | ||||
SpringApplication.run(BpmApplication.class, args); | |||||
SpringApplication.run(BpmApplication.class, args); | |||||
} | } | ||||
} | } |
@@ -11,9 +11,11 @@ import org.springframework.context.annotation.Configuration; | |||||
@Configuration | @Configuration | ||||
@ComponentScan | @ComponentScan | ||||
public class BpmAutoConfiguration { | 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); | |||||
} | |||||
} | } |
@@ -8,6 +8,6 @@ import org.springframework.stereotype.Component; | |||||
@ConfigurationProperties(prefix = "smtweb.bpm") | @ConfigurationProperties(prefix = "smtweb.bpm") | ||||
@Data | @Data | ||||
public class BpmConfigBean { | public class BpmConfigBean { | ||||
private String codeJavaPath; | |||||
private int mode; | |||||
private String codeJavaPath; | |||||
private int mode; | |||||
} | } |
@@ -1,10 +1,10 @@ | |||||
package cc.smtweb.system.bpm.spring.config; | package cc.smtweb.system.bpm.spring.config; | ||||
import cc.smtweb.framework.core.db.jdbc.IdGenerator; | |||||
import cc.smtweb.system.bpm.util.FilePathGenerator; | import cc.smtweb.system.bpm.util.FilePathGenerator; | ||||
import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
import org.springframework.context.annotation.Bean; | import org.springframework.context.annotation.Bean; | ||||
import org.springframework.context.annotation.Configuration; | import org.springframework.context.annotation.Configuration; | ||||
import cc.smtweb.framework.core.db.jdbc.IdGenerator; | |||||
/** | /** | ||||
* 微服务框架封装自动配置类 | * 微服务框架封装自动配置类 | ||||
@@ -13,7 +13,7 @@ public class FileConfigProperties { | |||||
/** | /** | ||||
* 系统底层附件保存路径和访问路径 | * 系统底层附件保存路径和访问路径 | ||||
*/ | */ | ||||
private String localPath; | |||||
private String localPath; | |||||
private String url; | private String url; | ||||
/** | /** | ||||
@@ -48,7 +48,7 @@ import java.util.Map; | |||||
@RestController | @RestController | ||||
@RequestMapping("/api/attach") | @RequestMapping("/api/attach") | ||||
public class AttachController { | public class AttachController { | ||||
private static Logger logger = LoggerFactory.getLogger(AttachController.class); | |||||
private static Logger logger = LoggerFactory.getLogger(AttachController.class); | |||||
@Autowired | @Autowired | ||||
private FileConfigProperties properties; | private FileConfigProperties properties; | ||||
@Autowired | @Autowired | ||||
@@ -60,14 +60,13 @@ public class AttachController { | |||||
private BASE64Decoder decoder = new BASE64Decoder(); | private BASE64Decoder decoder = new BASE64Decoder(); | ||||
/** | /** | ||||
* | |||||
* @param request | * @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 attachIsTemp 是否临时文件:true/false 字符串 | ||||
* @param attachName 附件名称,如:XXXXX.jpg | |||||
* @param savePath 保存路径,指定文件保存目录,可为空 | |||||
* @param attachName 附件名称,如:XXXXX.jpg | |||||
* @param savePath 保存路径,指定文件保存目录,可为空 | |||||
* @return | * @return | ||||
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
@@ -91,14 +90,14 @@ public class AttachController { | |||||
AttachInfo attach = new AttachInfo(); | AttachInfo attach = new AttachInfo(); | ||||
attach.setId(dbEngine.nextId()); | attach.setId(dbEngine.nextId()); | ||||
attach.setType(type);//附件类别 | attach.setType(type);//附件类别 | ||||
if(null !=ownerId) { | |||||
if (null != ownerId) { | |||||
attach.setOwnerId(ownerId);//附件拥有者id | attach.setOwnerId(ownerId);//附件拥有者id | ||||
} | } | ||||
attach.setPath(path);//附件路径 | attach.setPath(path);//附件路径 | ||||
attach.setPartyId(-1l); | attach.setPartyId(-1l); | ||||
attach.setTime(DateUtil.nowDateTimeLong()); | attach.setTime(DateUtil.nowDateTimeLong()); | ||||
attach.setUserId(-1l); | attach.setUserId(-1l); | ||||
attach.setIsTemp("true".equals(attachIsTemp) ? 1 : 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件 | |||||
attach.setIsTemp("true".equals(attachIsTemp) ? 1: 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件 | |||||
// 上传文件名 | // 上传文件名 | ||||
final int i = file.getOriginalFilename().lastIndexOf("."); | final int i = file.getOriginalFilename().lastIndexOf("."); | ||||
if (i >= 0) { | if (i >= 0) { | ||||
@@ -106,8 +105,7 @@ public class AttachController { | |||||
} | } | ||||
if (StringUtil.isEmpty(attachName)) { | if (StringUtil.isEmpty(attachName)) { | ||||
attachName = file.getOriginalFilename(); | attachName = file.getOriginalFilename(); | ||||
} | |||||
else { | |||||
} else { | |||||
attachName = attachName + attach.getSuffix(); | attachName = attachName + attach.getSuffix(); | ||||
} | } | ||||
attach.setName(attachName); | attach.setName(attachName); | ||||
@@ -138,18 +136,17 @@ public class AttachController { | |||||
} | } | ||||
/** | /** | ||||
* | |||||
* @param request | * @param request | ||||
* @param response | * @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 attachIsTemp 是否临时文件:true/false 字符串 | ||||
* @param attachName 附件名称,如:XXXXX.jpg | |||||
* @param savePath 保存路径,指定文件保存目录,可为空 | |||||
* @param suffix 文件后缀,如.jpg | |||||
* @param attachName 附件名称,如:XXXXX.jpg | |||||
* @param savePath 保存路径,指定文件保存目录,可为空 | |||||
* @param suffix 文件后缀,如.jpg | |||||
* @return | * @return | ||||
* @throws Exception | * @throws Exception | ||||
*/ | */ | ||||
@@ -164,23 +161,22 @@ public class AttachController { | |||||
@RequestParam(value = "attachName", required = false) String attachName, | @RequestParam(value = "attachName", required = false) String attachName, | ||||
@RequestParam(value = "savePath", required = false) String savePath, | @RequestParam(value = "savePath", required = false) String savePath, | ||||
@RequestParam(value = "suffix", required = false) String suffix | @RequestParam(value = "suffix", required = false) String suffix | ||||
) throws Exception { | |||||
) throws Exception { | |||||
// UtilLogger.error("上传文件接收base64", base64File); | // UtilLogger.error("上传文件接收base64", base64File); | ||||
if (null == base64File || "".equals(base64File)){ | |||||
if (null == base64File || "".equals(base64File)) { | |||||
return R.error("文件不能为空"); | 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(); | //String uploadContentType = file.getContentType(); | ||||
AttachInfo attach = null; | AttachInfo attach = null; | ||||
boolean isNew = StringUtil.isEmpty(attachId+""); | |||||
boolean isNew = StringUtil.isEmpty(attachId + ""); | |||||
if (isNew) { | if (isNew) { | ||||
attach = new AttachInfo(); | attach = new AttachInfo(); | ||||
} | |||||
else { | |||||
} else { | |||||
attach = dbEngine.findDao(AttachInfo.class).queryEntity(attachId); | attach = dbEngine.findDao(AttachInfo.class).queryEntity(attachId); | ||||
if (attach == null) { | if (attach == null) { | ||||
attach = new AttachInfo(); | attach = new AttachInfo(); | ||||
@@ -188,19 +184,19 @@ public class AttachController { | |||||
} else isNew = attach.isNew(); | } else isNew = attach.isNew(); | ||||
} | } | ||||
attach.setId(attachId); | attach.setId(attachId); | ||||
if (StringUtil.isEmpty(attachId+"")) attach.setId(dbEngine.nextId()); | |||||
if (StringUtil.isEmpty(attachId + "")) attach.setId(dbEngine.nextId()); | |||||
attach.setType(type);//附件类别 | attach.setType(type);//附件类别 | ||||
if(null !=ownerId) { | |||||
if (null != ownerId) { | |||||
attach.setOwnerId(ownerId);//附件拥有者id | attach.setOwnerId(ownerId);//附件拥有者id | ||||
} | } | ||||
attach.setPath(path);//附件路径 | attach.setPath(path);//附件路径 | ||||
attach.setPartyId(-1l); | attach.setPartyId(-1l); | ||||
attach.setTime(DateUtil.nowDateTimeLong()); | attach.setTime(DateUtil.nowDateTimeLong()); | ||||
attach.setUserId(-1l); | attach.setUserId(-1l); | ||||
attach.setIsTemp("true".equals(attachIsTemp) ? 1 : 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件 | |||||
attach.setIsTemp("true".equals(attachIsTemp) ? 1: 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件 | |||||
attach.setTime(DateUtil.nowDateTimeLong()); | attach.setTime(DateUtil.nowDateTimeLong()); | ||||
attach.setIsTemp("true".equals(attachIsTemp) ? 1 : 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件 | |||||
attach.setIsTemp("true".equals(attachIsTemp) ? 1: 0);//暂时没有有效拥有者标记 方便定时任务清除垃圾附件 | |||||
// 上传文件名 | // 上传文件名 | ||||
attach.setSuffix(suffix); | attach.setSuffix(suffix); | ||||
attach.setName(attachName); | attach.setName(attachName); | ||||
@@ -235,25 +231,26 @@ public class AttachController { | |||||
} | } | ||||
return R.success(attach.getId()); | return R.success(attach.getId()); | ||||
} | } | ||||
@PostMapping({"/copyupload"}) | @PostMapping({"/copyupload"}) | ||||
public R copyupload(HttpServletRequest request) throws Exception { | 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(""); | 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(""); | 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 remotePath = attach.getPath(); | ||||
String filePath =attachHelper.getAttachTmpPath()+"tempFiles/"; | |||||
String filePath = attachHelper.getAttachTmpPath() + "tempFiles/"; | |||||
UtilFile.makeDir(filePath); | UtilFile.makeDir(filePath); | ||||
Map<String, String> map = null; | Map<String, String> map = null; | ||||
try { | try { | ||||
attachUtil.downloadAttach(remotePath, remoteName, filePath); | attachUtil.downloadAttach(remotePath, remoteName, filePath); | ||||
String filePaths=filePath+remoteName; | |||||
String filePaths = filePath + remoteName; | |||||
attach.setId(dbEngine.nextId()); | attach.setId(dbEngine.nextId()); | ||||
attach.setType(type);//附件类别 | attach.setType(type);//附件类别 | ||||
@@ -261,16 +258,16 @@ public class AttachController { | |||||
attach.setPartyId(-1l); | attach.setPartyId(-1l); | ||||
attach.setTime(DateUtil.nowDateTimeLong()); | attach.setTime(DateUtil.nowDateTimeLong()); | ||||
attach.setUserId(-1l); | attach.setUserId(-1l); | ||||
attach.setName(attach.getId()+attach.getSuffix()); | |||||
attach.setName(attach.getId() + attach.getSuffix()); | |||||
// 上传文件域对象 | // 上传文件域对象 | ||||
File upload = new File(filePaths); | File upload = new File(filePaths); | ||||
// attach.setSize((long) FileCopyUtils.copy(file.getInputStream(), new BufferedOutputStream(new FileOutputStream(upload)))); | // attach.setSize((long) FileCopyUtils.copy(file.getInputStream(), new BufferedOutputStream(new FileOutputStream(upload)))); | ||||
localSaveAttach(attach, upload); | localSaveAttach(attach, upload); | ||||
}catch (Exception e){ | |||||
} catch (Exception e) { | |||||
logger.error("上传文件失败", e); | logger.error("上传文件失败", e); | ||||
return R.error("上传文件失败"); | 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}) | @RequestMapping(value = "/download", method = {RequestMethod.GET, RequestMethod.POST}) | ||||
public R down(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "attachId", required = false) Long attachId) throws Exception { | 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) { | if (null == attach) { | ||||
return R.error("附件不存在"); | return R.error("附件不存在"); | ||||
} | } | ||||
@@ -302,9 +299,9 @@ public class AttachController { | |||||
try { | try { | ||||
attachUtil.downloadAttach(remotePath, remoteFileName, fileName, response); | attachUtil.downloadAttach(remotePath, remoteFileName, fileName, response); | ||||
attach.setCount(attach.getCount() + 1); | attach.setCount(attach.getCount() + 1); | ||||
dbEngine.updateEntity(attach,"attach_count"); | |||||
dbEngine.updateEntity(attach, "attach_count"); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
logger.error("附件下载失败",e); | |||||
logger.error("附件下载失败", e); | |||||
R.error("附件下载失败"); | R.error("附件下载失败"); | ||||
} | } | ||||
@@ -314,21 +311,21 @@ public class AttachController { | |||||
//图片附件显示路径 | //图片附件显示路径 | ||||
@GetMapping(value = "/showImg") | @GetMapping(value = "/showImg") | ||||
public R showImg(HttpServletResponse response, @RequestParam(value = "attachId", required = false) Long attachId) throws Exception { | 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) { | if (null == attach) { | ||||
return R.error("附件不存在"); | return R.error("附件不存在"); | ||||
} | } | ||||
// attachUtil.showImg(attach.getPath(),attach.getName(),response); | // 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; | return null; | ||||
} | } | ||||
//图片附件显示路径 | //图片附件显示路径 | ||||
@RequestMapping(value = "/showImgThumb", method = {RequestMethod.GET, RequestMethod.POST}) | @RequestMapping(value = "/showImgThumb", method = {RequestMethod.GET, RequestMethod.POST}) | ||||
public R showImgThumb(HttpServletResponse response, @RequestParam(value = "attachId", required = false) Long attachId, | 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) { | if (null == attach) { | ||||
return R.error("附件不存在"); | return R.error("附件不存在"); | ||||
} | } | ||||
@@ -339,8 +336,8 @@ public class AttachController { | |||||
String lfo = tempPath + "/" + remoteFileName; | String lfo = tempPath + "/" + remoteFileName; | ||||
String lfd = tempPath + "/thumb_" + attach.getId() + attach.getSuffix(); | String lfd = tempPath + "/thumb_" + attach.getId() + attach.getSuffix(); | ||||
attachUtil.downloadAttach(remotePath, remoteFileName, tempPath); | 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 (w <= 0) w = 100; | ||||
if (h <= 0) h = 100; | if (h <= 0) h = 100; | ||||
getImgThumb(lfo, lfd, w, h); | getImgThumb(lfo, lfd, w, h); | ||||
@@ -350,7 +347,7 @@ public class AttachController { | |||||
UtilDownloadFile.downfileEx(response, lfo, attach.getName()); | UtilDownloadFile.downfileEx(response, lfo, attach.getName()); | ||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
logger.error("附件下载失败",e); | |||||
logger.error("附件下载失败", e); | |||||
R.error("附件下载失败"); | R.error("附件下载失败"); | ||||
} | } | ||||
return null; | return null; | ||||
@@ -419,7 +416,7 @@ public class AttachController { | |||||
//图片附件显示路径 | //图片附件显示路径 | ||||
@GetMapping(value = "/loadAttachBean") | @GetMapping(value = "/loadAttachBean") | ||||
public R loadAttachBean(@RequestParam(value = "attachIds") String attachIds) throws Exception { | 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); | return R.success(beans); | ||||
} | } | ||||
} | } |
@@ -9,7 +9,10 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
import org.springframework.core.io.InputStreamResource; | import org.springframework.core.io.InputStreamResource; | ||||
import org.springframework.http.*; | 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 javax.servlet.http.HttpServletRequest; | ||||
import java.io.File; | import java.io.File; | ||||
@@ -22,164 +25,170 @@ import java.util.concurrent.TimeUnit; | |||||
@RestController | @RestController | ||||
public class FileDownloadController { | 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.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() | return ResponseEntity.ok() | ||||
.headers(headers) | .headers(headers) | ||||
.contentLength(file.length()) | .contentLength(file.length()) | ||||
.contentType(contentType) | |||||
.contentType(MediaType.APPLICATION_OCTET_STREAM) | |||||
.body(new InputStreamResource(new FileInputStream(file))); | .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()) | // .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; | |||||
} | |||||
} | } |
@@ -1,10 +1,12 @@ | |||||
package cc.smtweb.system.bpm.spring.controller; | 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.common.R; | ||||
import cc.smtweb.framework.core.db.DbEngine; | 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.framework.core.session.SessionUtil; | ||||
import cc.smtweb.system.bpm.spring.dao.ImageAttachDao; | 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.FilePathGenerator; | ||||
import cc.smtweb.system.bpm.util.FilePathInfo; | import cc.smtweb.system.bpm.util.FilePathInfo; | ||||
import cc.smtweb.system.bpm.util.MemMultipartFile; | 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.util.FileCopyUtils; | ||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
import org.springframework.web.multipart.MultipartFile; | 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 javax.servlet.http.HttpServletRequest; | ||||
import java.io.*; | import java.io.*; | ||||
@@ -23,135 +23,135 @@ import java.text.SimpleDateFormat; | |||||
@RestController | @RestController | ||||
public class FileUploadController { | 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(); | |||||
} | |||||
} | } |
@@ -1,63 +1,63 @@ | |||||
package cc.smtweb.system.bpm.spring.dao; | package cc.smtweb.system.bpm.spring.dao; | ||||
import cc.smtweb.system.bpm.spring.entity.UploadDataVO; | |||||
import cc.smtweb.system.bpm.util.ThumbImage; | import cc.smtweb.system.bpm.util.ThumbImage; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import cc.smtweb.system.bpm.spring.entity.UploadDataVO; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
@Service | @Service | ||||
public class ImageAttachDao { | 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; | 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) { | 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()); | |||||
} | |||||
} | } | ||||
} | |||||
} | } |
@@ -14,101 +14,101 @@ import java.util.Map; | |||||
@Service | @Service | ||||
public class SysAttachDao { | 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) { | // 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=?", | // 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); | // AttachPathPO.class, id); | ||||
// } | // } | ||||
// | // | ||||
// return null; | // return null; | ||||
} | |||||
} | |||||
// 删除文件 | |||||
public void remove(String filePath) { | |||||
// 删除文件 | |||||
public void remove(String filePath) { | |||||
// if (id != null) { | // 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=?", | // 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); | // AttachPathPO.class, id); | ||||
// } | // } | ||||
// | // | ||||
// return null; | // 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) { | |||||
} | |||||
} | |||||
} | } |
@@ -20,13 +20,13 @@ public final class AttachFolderEntityBuffer { | |||||
@Autowired | @Autowired | ||||
private DbEngine dbEngine; | private DbEngine dbEngine; | ||||
public static final String cacheKey="attach_folder_"; | |||||
public static final String cacheKey = "attach_folder_"; | |||||
//根据附件路径和期间获取对象 | //根据附件路径和期间获取对象 | ||||
public AttachFolderPojo getByPath(String attachPath, String period) { | 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.setFolderId(pojo.getId()); | ||||
p.setFolderAttachPath(pojo.getPath()); | p.setFolderAttachPath(pojo.getPath()); | ||||
p.setFolderFileCount(pojo.getFileCount()); | p.setFolderFileCount(pojo.getFileCount()); | ||||
p.setFolderPeriod(pojo.getPeriod()); | p.setFolderPeriod(pojo.getPeriod()); | ||||
p.setFolderMaxSeq(pojo.getMaxSeq()); | 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); | |||||
} | } | ||||
} | } |
@@ -4,10 +4,10 @@ import lombok.Data; | |||||
@Data | @Data | ||||
public class AttachPathPO { | 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; | |||||
} | } |
@@ -4,5 +4,5 @@ import lombok.Data; | |||||
@Data | @Data | ||||
public class FileDataVO { | public class FileDataVO { | ||||
private String data; | |||||
private String data; | |||||
} | } |
@@ -4,12 +4,12 @@ import lombok.Data; | |||||
@Data | @Data | ||||
public class UploadDataVO { | 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; | |||||
} | } |
@@ -19,12 +19,13 @@ import java.util.List; | |||||
public final class AttachFileWork implements IAttachWorkIntf { | public final class AttachFileWork implements IAttachWorkIntf { | ||||
@Autowired | @Autowired | ||||
private FileConfigProperties properties; | private FileConfigProperties properties; | ||||
private String getPath(String remoteFolderPath) { | private String getPath(String remoteFolderPath) { | ||||
String path =properties.getAttachPath(); | |||||
String path = properties.getAttachPath(); | |||||
if (StringUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/")) | if (StringUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/")) | ||||
path = path + "/" + remoteFolderPath; | path = path + "/" + remoteFolderPath; | ||||
else path = path + remoteFolderPath; | else path = path + remoteFolderPath; | ||||
path = path.replaceAll("-",""); | |||||
path = path.replaceAll("-", ""); | |||||
UtilFile.makeDir(path); | UtilFile.makeDir(path); | ||||
if (!path.endsWith("/")) path = path + "/"; | if (!path.endsWith("/")) path = path + "/"; | ||||
return 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 { | public void saveAttach(String remoteAttachName, String remoteFolderPath, String localAttach, boolean isDelLocal) throws Exception { | ||||
String dstFile = getFileName(remoteFolderPath, remoteAttachName); | String dstFile = getFileName(remoteFolderPath, remoteAttachName); | ||||
if (isDelLocal) UtilFile.renameTo(localAttach, dstFile); | if (isDelLocal) UtilFile.renameTo(localAttach, dstFile); | ||||
else UtilFile.copy(localAttach,dstFile); | |||||
else UtilFile.copy(localAttach, dstFile); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -31,6 +31,7 @@ public final class AttachFtpWork implements IAttachWorkIntf { | |||||
Logger logger = LoggerFactory.getLogger(AttachFtpWork.class); | Logger logger = LoggerFactory.getLogger(AttachFtpWork.class); | ||||
@Autowired | @Autowired | ||||
private FileConfigProperties properties; | private FileConfigProperties properties; | ||||
private String getPath(String remoteFolderPath) { | private String getPath(String remoteFolderPath) { | ||||
String path = properties.getAttachPath(); | String path = properties.getAttachPath(); | ||||
if (StringUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/")) | if (StringUtil.isNotEmpty(remoteFolderPath) && !path.endsWith("/") && !remoteFolderPath.startsWith("/")) | ||||
@@ -169,7 +170,7 @@ public final class AttachFtpWork implements IAttachWorkIntf { | |||||
getFtpManager().execute(new FtpTask() { | getFtpManager().execute(new FtpTask() { | ||||
public Object execute(IFtpUtil ftp) throws Exception { | public Object execute(IFtpUtil ftp) throws Exception { | ||||
try { | try { | ||||
ftp.downloadFileEx(getPath(remotePath), remoteName,localPath + File.separator + localName ); | |||||
ftp.downloadFileEx(getPath(remotePath), remoteName, localPath + File.separator + localName); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
} | } | ||||
@@ -31,8 +31,9 @@ public final class AttachHelper { | |||||
private DbEngine dbEngine; | private DbEngine dbEngine; | ||||
@Autowired | @Autowired | ||||
private AttachUtil attachUtil; | private AttachUtil attachUtil; | ||||
//得到附件临时目录 | //得到附件临时目录 | ||||
public String getAttachTmpPath() { | |||||
public String getAttachTmpPath() { | |||||
String tmp_attach = properties.getAttachTempPath(); | String tmp_attach = properties.getAttachTempPath(); | ||||
if (!tmp_attach.endsWith("/")) tmp_attach += "/"; | if (!tmp_attach.endsWith("/")) tmp_attach += "/"; | ||||
File file = new File(tmp_attach); | File file = new File(tmp_attach); | ||||
@@ -43,10 +44,10 @@ public final class AttachHelper { | |||||
} | } | ||||
//删除ftp服务器的文件 | //删除ftp服务器的文件 | ||||
public boolean deleteOneAttach(String attachId) throws Exception { | |||||
public boolean deleteOneAttach(String attachId) throws Exception { | |||||
if (StringUtil.isEmpty(attachId)) return true; | if (StringUtil.isEmpty(attachId)) return true; | ||||
AttachInfo attachInfo = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId)); | AttachInfo attachInfo = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId)); | ||||
if(null == attachInfo){ | |||||
if (null == attachInfo) { | |||||
return true; | return true; | ||||
} | } | ||||
boolean deleteSuccess = deleteAttachInFtpServer(attachInfo.getPath(), attachInfo.getName()); | boolean deleteSuccess = deleteAttachInFtpServer(attachInfo.getPath(), attachInfo.getName()); | ||||
@@ -57,7 +58,7 @@ public final class AttachHelper { | |||||
} | } | ||||
//删除ftp服务器的文件 | //删除ftp服务器的文件 | ||||
public boolean deleteOneAttach(AttachInfo bean) { | |||||
public boolean deleteOneAttach(AttachInfo bean) { | |||||
boolean deleteSuccess = deleteAttachInFtpServer(bean.getPath(), bean.getName()); | boolean deleteSuccess = deleteAttachInFtpServer(bean.getPath(), bean.getName()); | ||||
if (deleteSuccess) { | if (deleteSuccess) { | ||||
dbEngine.deleteEntity(bean); | dbEngine.deleteEntity(bean); | ||||
@@ -66,41 +67,41 @@ public final class AttachHelper { | |||||
} | } | ||||
//删除ftp服务器的文件夹 | //删除ftp服务器的文件夹 | ||||
public void deleteFolder(final String remotePath) throws Exception { | |||||
public void deleteFolder(final String remotePath) throws Exception { | |||||
attachUtil.deletePath(remotePath); | 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); | final List<AttachInfo> list = listAttachListByOwnerIdAndType(ownerId, attachType); | ||||
return deleteAttachListEx(list); | return deleteAttachListEx(list); | ||||
} | } | ||||
public boolean deleteAttachByOwnerId(String ownerId) throws Exception { | |||||
public boolean deleteAttachByOwnerId(String ownerId) throws Exception { | |||||
final List<AttachInfo> list = getAttachListByOwnerId(ownerId); | final List<AttachInfo> list = getAttachListByOwnerId(ownerId); | ||||
return deleteAttachListEx(list); | 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; | 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; | return true; | ||||
} | } | ||||
public boolean deleteAttachListEx(List<AttachInfo> list) throws Exception { | |||||
public boolean deleteAttachListEx(List<AttachInfo> list) throws Exception { | |||||
boolean result = true; | boolean result = true; | ||||
for (AttachInfo bean : list) { | for (AttachInfo bean : list) { | ||||
if (!deleteAttachInFtpServer(bean.getPath(), bean.getName())) { | if (!deleteAttachInFtpServer(bean.getPath(), bean.getName())) { | ||||
@@ -117,7 +118,7 @@ public final class AttachHelper { | |||||
} | } | ||||
//删除在ftp服务器上的附件 | //删除在ftp服务器上的附件 | ||||
public boolean deleteAttachInFtpServer(String remotePath, String remoteName) { | |||||
public boolean deleteAttachInFtpServer(String remotePath, String remoteName) { | |||||
try { | try { | ||||
attachUtil.deleteAttach(remotePath, remoteName); | attachUtil.deleteAttach(remotePath, remoteName); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
@@ -135,7 +136,7 @@ public final class AttachHelper { | |||||
* @return 返回文件名 | * @return 返回文件名 | ||||
* @throws Exception | * @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)); | AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId)); | ||||
if (null == attach) throw new Exception("附件不存在!"); | if (null == attach) throw new Exception("附件不存在!"); | ||||
@@ -155,7 +156,7 @@ public final class AttachHelper { | |||||
* @return 返回文件名 | * @return 返回文件名 | ||||
* @throws Exception | * @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)); | AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, Long.valueOf(attachId)); | ||||
if (null == attach) throw new Exception("附件不存在!"); | if (null == attach) throw new Exception("附件不存在!"); | ||||
final String remoteFileName = attach.getName(); | final String remoteFileName = attach.getName(); | ||||
@@ -174,7 +175,7 @@ public final class AttachHelper { | |||||
* @return 返回文件名列表,本地有此文件将不再下载 | * @return 返回文件名列表,本地有此文件将不再下载 | ||||
* @throws Exception | * @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()); | return attachUtil.getAttachListFromFtp(attachlist, ownerType, getAttachTmpPath()); | ||||
} | } | ||||
@@ -186,7 +187,7 @@ public final class AttachHelper { | |||||
* @return 返回文件名列表,本地有此文件将不再下载 | * @return 返回文件名列表,本地有此文件将不再下载 | ||||
* @throws Exception | * @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); | final List<AttachInfo> attachlist = getAttachListByOwnerId(ownerId); | ||||
return getAttachListFromFtp(attachlist, ownerType); | return getAttachListFromFtp(attachlist, ownerType); | ||||
@@ -201,20 +202,20 @@ public final class AttachHelper { | |||||
* @return 返回文件名列表,本地有此文件将不再下载 | * @return 返回文件名列表,本地有此文件将不再下载 | ||||
* @throws Exception | * @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>(); | List<Object> paras = new ArrayList<Object>(); | ||||
if (!CommUtil.isEmpty(attachIds)) { | if (!CommUtil.isEmpty(attachIds)) { | ||||
StringBuilder sb = new StringBuilder(128); | 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=? "); | sb.append(" attach_id=? "); | ||||
}else{ | |||||
} else { | |||||
sb.append(" or attach_id=? "); | sb.append(" or attach_id=? "); | ||||
} | } | ||||
paras.add(attachIds.get(i)); | 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 getAttachListFromFtp(attachlist, ownerType); | ||||
} | } | ||||
return new ArrayList<>(); | return new ArrayList<>(); | ||||
@@ -225,7 +226,7 @@ public final class AttachHelper { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
public String getSizeStr(long fileSize) { | |||||
public String getSizeStr(long fileSize) { | |||||
if (fileSize < 1024) return fileSize + "B"; | if (fileSize < 1024) return fileSize + "B"; | ||||
double n = fileSize * 1.0 / 1024; | double n = fileSize * 1.0 / 1024; | ||||
if (NumberUtil.compare(n, 1024) < 0) return NumberUtil.toStdNumberString(n, 0) + "KB"; | if (NumberUtil.compare(n, 1024) < 0) return NumberUtil.toStdNumberString(n, 0) + "KB"; | ||||
@@ -239,23 +240,23 @@ public final class AttachHelper { | |||||
* @param attach_owner_id 拥有者 | * @param attach_owner_id 拥有者 | ||||
* @throws Exception | * @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); | AttachInfo attach = dbEngine.queryEntity(AttachInfo.class, attachId); | ||||
if(attach==null){ | |||||
if (attach == null) { | |||||
return ""; | 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 remotePath = attach.getPath(); | ||||
String filePath =getAttachTmpPath()+"tempFiles/"; | |||||
String filePath = getAttachTmpPath() + "tempFiles/"; | |||||
UtilFile.makeDir(filePath); | UtilFile.makeDir(filePath); | ||||
Map<String, String> map = null; | Map<String, String> map = null; | ||||
try { | try { | ||||
attachUtil.downloadAttach(remotePath, remoteName, filePath); | attachUtil.downloadAttach(remotePath, remoteName, filePath); | ||||
String filePaths=filePath+remoteName; | |||||
String filePaths = filePath + remoteName; | |||||
attach.setId(dbEngine.nextId()); | attach.setId(dbEngine.nextId()); | ||||
attach.setType(type);//附件类别 | attach.setType(type);//附件类别 | ||||
@@ -263,7 +264,7 @@ public final class AttachHelper { | |||||
attach.setPartyId(-1l); | attach.setPartyId(-1l); | ||||
attach.setTime(DateUtil.nowDateTimeLong()); | attach.setTime(DateUtil.nowDateTimeLong()); | ||||
attach.setUserId(-1l); | attach.setUserId(-1l); | ||||
attach.setName(attach.getId()+attach.getSuffix()); | |||||
attach.setName(attach.getId() + attach.getSuffix()); | |||||
// 上传文件域对象 | // 上传文件域对象 | ||||
File upload = new File(filePaths); | File upload = new File(filePaths); | ||||
// attach.setAttachSize((long) FileCopyUtils.copy(file.getInputStream(), new BufferedOutputStream(new FileOutputStream(upload)))); | // attach.setAttachSize((long) FileCopyUtils.copy(file.getInputStream(), new BufferedOutputStream(new FileOutputStream(upload)))); | ||||
@@ -276,10 +277,10 @@ public final class AttachHelper { | |||||
} finally { | } finally { | ||||
UtilFile.delFile(upload.getAbsolutePath()); | UtilFile.delFile(upload.getAbsolutePath()); | ||||
} | } | ||||
}catch (Exception e){ | |||||
} catch (Exception e) { | |||||
logger.error("复制文件失败", e); | logger.error("复制文件失败", e); | ||||
return ""; | return ""; | ||||
} | } | ||||
return attach.getId()+""; | |||||
return attach.getId() + ""; | |||||
} | } | ||||
} | } |
@@ -24,7 +24,7 @@ import java.util.List; | |||||
public final class AttachUtil { | public final class AttachUtil { | ||||
//一个文件夹下最多允许多少文件 | //一个文件夹下最多允许多少文件 | ||||
private final static int MAX_FILE_COUNT = 1000; | private final static int MAX_FILE_COUNT = 1000; | ||||
private static IAttachWorkIntf worker; | |||||
private static IAttachWorkIntf worker; | |||||
@Autowired | @Autowired | ||||
private FileConfigProperties properties; | private FileConfigProperties properties; | ||||
@Autowired | @Autowired | ||||
@@ -35,22 +35,23 @@ public final class AttachUtil { | |||||
private AttachFtpWork attachFtpWork; | private AttachFtpWork attachFtpWork; | ||||
@Autowired | @Autowired | ||||
private AttachFileWork attachFileWork; | private AttachFileWork attachFileWork; | ||||
static { | static { | ||||
// init(); | // init(); | ||||
} | } | ||||
public void init() { | |||||
public void init() { | |||||
final String at = StringUtil.checkNull(properties.getAttachType()).toLowerCase(); | final String at = StringUtil.checkNull(properties.getAttachType()).toLowerCase(); | ||||
if ("ftp".equals(at) || "sftp".equals(at)) | if ("ftp".equals(at) || "sftp".equals(at)) | ||||
worker = attachFtpWork; | worker = attachFtpWork; | ||||
else worker = attachFileWork; | else worker = attachFileWork; | ||||
} | } | ||||
private void checkAttachFolder(final AttachInfo attach) throws Exception { | |||||
private void checkAttachFolder(final AttachInfo attach) throws Exception { | |||||
final String period = DateUtil.getNowYm(); | final String period = DateUtil.getNowYm(); | ||||
AttachFolderPojo folder = attachFolderEntityBuffer.getByPath(attach.getPath(), period); | AttachFolderPojo folder = attachFolderEntityBuffer.getByPath(attach.getPath(), period); | ||||
AttachFolder entity=new AttachFolder(); | |||||
AttachFolder entity = new AttachFolder(); | |||||
boolean isNew = false; | boolean isNew = false; | ||||
if (folder == null) { | if (folder == null) { | ||||
isNew = true; | 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); | 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); | worker.copyAttach(srcFileName, desFileName, remoteFolderPath, isDelSrc); | ||||
} | } | ||||
public void deletePath(String remotePath) throws Exception { | |||||
public void deletePath(String remotePath) throws Exception { | |||||
worker.deletePath(remotePath); | 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); | 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); | 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); | 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); | 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); | return worker.getAttachListFromFtp(attachlist, ownerType, localRoot); | ||||
} | } | ||||
public void makeRemoteDir(String path) throws Exception { | |||||
public void makeRemoteDir(String path) throws Exception { | |||||
worker.makeRemoteDir(path); | 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); | return worker.getAttachPath(remotePath, remoteName); | ||||
} | } | ||||
@@ -1,7 +1,6 @@ | |||||
package cc.smtweb.system.bpm.spring.file.attach; | package cc.smtweb.system.bpm.spring.file.attach; | ||||
import cc.smtweb.system.bpm.web.sys.base.attach.AttachInfo; | import cc.smtweb.system.bpm.web.sys.base.attach.AttachInfo; | ||||
import javax.servlet.http.HttpServletResponse; | 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 | * @throws Exception | ||||
*/ | */ | ||||
void copyAttach(String srcFileName, String desFileName, String remoteFolderPath, boolean 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); | Path getAttachPath(String remotePath, String remoteName); | ||||
} | } |
@@ -18,6 +18,7 @@ public class RunDataInit implements ApplicationRunner { | |||||
private AttachFolderEntityBuffer attachFolderEntityBuffer; | private AttachFolderEntityBuffer attachFolderEntityBuffer; | ||||
@Autowired | @Autowired | ||||
private AttachUtil attachUtil; | private AttachUtil attachUtil; | ||||
@Override | @Override | ||||
public void run(ApplicationArguments args) throws Exception { | public void run(ApplicationArguments args) throws Exception { | ||||
attachFolderEntityBuffer.initData();//附件目录缓存 | attachFolderEntityBuffer.initData();//附件目录缓存 | ||||
@@ -1,7 +1,7 @@ | |||||
package cc.smtweb.system.bpm.util; | 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.common.SwMap; | ||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import org.springframework.beans.BeanUtils; | import org.springframework.beans.BeanUtils; | ||||
import org.springframework.beans.BeansException; | import org.springframework.beans.BeansException; | ||||
import org.springframework.beans.FatalBeanException; | import org.springframework.beans.FatalBeanException; | ||||
@@ -17,104 +17,104 @@ import java.util.Arrays; | |||||
import java.util.List; | import java.util.List; | ||||
public class BeanUtil { | 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()); | // PropertyDescriptor sourcePd = BeanUtils.getPropertyDescriptor(source.getClass(), targetPd.getKey()); | ||||
// if (sourcePd != null) { | // 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,9 +1,9 @@ | |||||
package cc.smtweb.system.bpm.util; | package cc.smtweb.system.bpm.util; | ||||
import cc.smtweb.framework.core.common.SwConsts; | 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.common.SwMap; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import freemarker.template.Configuration; | import freemarker.template.Configuration; | ||||
import freemarker.template.Template; | import freemarker.template.Template; | ||||
import freemarker.template.TemplateMethodModelEx; | import freemarker.template.TemplateMethodModelEx; | ||||
@@ -12,7 +12,6 @@ import org.apache.commons.io.IOUtils; | |||||
import java.io.*; | import java.io.*; | ||||
import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -53,7 +53,7 @@ public class FileDynPath extends FileFixPath { | |||||
// 如果文件数量太大就需要创建新子目录 | // 如果文件数量太大就需要创建新子目录 | ||||
while (this.fileCount >= MAX_FILE_COUNT) { | while (this.fileCount >= MAX_FILE_COUNT) { | ||||
this.pathIndex++; | this.pathIndex++; | ||||
if(this.pathIndex > MAX_DIR_COUNT) { | |||||
if (this.pathIndex > MAX_DIR_COUNT) { | |||||
throw new RuntimeException("dir is two many"); | throw new RuntimeException("dir is two many"); | ||||
} | } | ||||
@@ -1,16 +1,16 @@ | |||||
package cc.smtweb.system.bpm.util; | 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.Getter; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.tika.mime.MimeType; | import org.apache.tika.mime.MimeType; | ||||
import org.apache.tika.mime.MimeTypeException; | import org.apache.tika.mime.MimeTypeException; | ||||
import org.apache.tika.mime.MimeTypes; | import org.apache.tika.mime.MimeTypes; | ||||
import org.springframework.web.multipart.MultipartFile; | 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: | * 文件名生成规则 subDir/[yyyymm]/[d]/[hex(fileid)]_[hex(rand)].[fileExt] 如果文件是图片格式,会生成缩略图,文件名会直接添加.thumb.jpg后缀 规则参数 yyyymm: | ||||
@@ -19,50 +19,51 @@ import cc.smtweb.framework.core.db.jdbc.IdGenerator; | |||||
@Slf4j | @Slf4j | ||||
public class FilePathGenerator { | 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 上传文件流,用于提取扩展名用 | * @param multipartFile 上传文件流,用于提取扩展名用 | ||||
* @return 文件路径信息类 | * @return 文件路径信息类 | ||||
*/ | */ | ||||
@@ -71,23 +72,23 @@ public class FilePathGenerator { | |||||
} | } | ||||
private synchronized FilePathInfo make(String subPath, String originFileName, String contentType, boolean keepName) { | 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) { | private static String ext(String filename, String contentType) { | ||||
@@ -127,6 +128,6 @@ public class FilePathGenerator { | |||||
// 获取下载路径前缀 | // 获取下载路径前缀 | ||||
public String getDownloadUrl() { | public String getDownloadUrl() { | ||||
return this.fileUrl; | |||||
return this.fileUrl; | |||||
} | } | ||||
} | } |
@@ -9,40 +9,40 @@ import lombok.Getter; | |||||
*/ | */ | ||||
@Getter | @Getter | ||||
public class FilePathInfo { | 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; | |||||
} | |||||
} | } |
@@ -4,42 +4,50 @@ import java.util.List; | |||||
/** | /** | ||||
* 树型节点句柄 | * 树型节点句柄 | ||||
* | |||||
* @author xkliu | * @author xkliu | ||||
*/ | */ | ||||
public interface ITreeDataHandler<T> { | 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); | // 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; | |||||
} | |||||
} | } |
@@ -1,6 +1,7 @@ | |||||
package cc.smtweb.system.bpm.util; | package cc.smtweb.system.bpm.util; | ||||
public interface ITreeDataLevelHandler<T> extends ITreeDataHandler<T> { | 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); | |||||
} | } |
@@ -1,18 +1,13 @@ | |||||
package cc.smtweb.system.bpm.util; | package cc.smtweb.system.bpm.util; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; | ||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; | ||||
import lombok.Data; | import lombok.Data; | ||||
import org.apache.commons.io.FileUtils; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.InputStream; | |||||
import java.net.MalformedURLException; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -23,6 +18,7 @@ import java.util.Map; | |||||
*/ | */ | ||||
public class IdeaUtil { | public class IdeaUtil { | ||||
private final static int MODE_POM = 1; | private final static int MODE_POM = 1; | ||||
//获取工程中的Module文件 | //获取工程中的Module文件 | ||||
public static Map<String, String> getModules(String ideaPath, int mode) { | public static Map<String, String> getModules(String ideaPath, int mode) { | ||||
if (mode == MODE_POM) { | if (mode == MODE_POM) { | ||||
@@ -41,7 +37,7 @@ public class IdeaUtil { | |||||
Map<String, String> map = new HashMap<>(); | Map<String, String> map = new HashMap<>(); | ||||
PomProject project = XmlUtil.readValue(file, PomProject.class); | PomProject project = XmlUtil.readValue(file, PomProject.class); | ||||
if (project == null || project.modules == null) return map; | if (project == null || project.modules == null) return map; | ||||
for (String module: project.modules) { | |||||
for (String module : project.modules) { | |||||
File f = new File(ideaPath + "/" + module); | File f = new File(ideaPath + "/" + module); | ||||
String s = f.getName(); | String s = f.getName(); | ||||
int i = s.lastIndexOf("."); | int i = s.lastIndexOf("."); | ||||
@@ -50,11 +46,12 @@ public class IdeaUtil { | |||||
} | } | ||||
return map; | return map; | ||||
} | } | ||||
public static Map<String, String> getModulesFromModule(String ideaPath, File file) { | public static Map<String, String> getModulesFromModule(String ideaPath, File file) { | ||||
Map<String, String> map = new HashMap<>(); | Map<String, String> map = new HashMap<>(); | ||||
IdeaProject project = XmlUtil.readValue(file, IdeaProject.class); | IdeaProject project = XmlUtil.readValue(file, IdeaProject.class); | ||||
if (project == null || project.component == null || project.component.modules == null) return map; | 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); | String s = module.filepath.replace("$PROJECT_DIR$", ideaPath); | ||||
File f = new File(s); | File f = new File(s); | ||||
s = f.getName(); | s = f.getName(); | ||||
@@ -6,74 +6,74 @@ import org.springframework.web.multipart.MultipartFile; | |||||
import java.io.*; | import java.io.*; | ||||
public class MemMultipartFile implements MultipartFile { | 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); | |||||
} | |||||
} | } | ||||
} | |||||
} | } |
@@ -1,13 +1,5 @@ | |||||
package cc.smtweb.system.bpm.util; | 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 lombok.Getter; | ||||
import net.coobird.thumbnailator.Thumbnails; | import net.coobird.thumbnailator.Thumbnails; | ||||
import net.coobird.thumbnailator.geometry.Positions; | 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 net.sf.image4j.codec.ico.ICODecoder; | ||||
import org.apache.commons.lang3.StringUtils; | 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 | * @author xkliu | ||||
*/ | */ | ||||
@Getter | @Getter | ||||
public class ThumbImage { | 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 r = w * 1000 / h; | ||||
// int imageR = imageWidth * 1000 / imageHeight; | // int imageR = imageWidth * 1000 / imageHeight; | ||||
// if (r != imageR) { | // if (r != imageR) { | ||||
// w = imageHeight * r / 1000; | // 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); | |||||
} | |||||
} | } |
@@ -6,212 +6,214 @@ import java.util.function.Consumer; | |||||
/** | /** | ||||
* 树结构数据创建器 | * 树结构数据创建器 | ||||
* | |||||
* @author xkliu | * @author xkliu | ||||
*/ | */ | ||||
public class TreeDataUtil { | 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; | 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; | 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); | |||||
} | |||||
} | |||||
} | } | ||||
} | |||||
} | } |
@@ -149,7 +149,7 @@ public class UtilFile { | |||||
write.flush(); | write.flush(); | ||||
write.close(); | write.close(); | ||||
} catch (IOException e) { | } 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) { | public static List<String> searchFiles(String sSearchStr, String sFilePath) { | ||||
List<String> list = new ArrayList<>(); | List<String> list = new ArrayList<>(); | ||||
@@ -1069,6 +1069,7 @@ public class UtilFile { | |||||
/** | /** | ||||
* 读取txt文件类型 | * 读取txt文件类型 | ||||
* | |||||
* @param fileName | * @param fileName | ||||
* @return | * @return | ||||
*/ | */ | ||||
@@ -1097,6 +1098,7 @@ public class UtilFile { | |||||
} | } | ||||
return sbf.toString(); | return sbf.toString(); | ||||
} | } | ||||
/** | /** | ||||
* 解压文件到指定目录 | * 解压文件到指定目录 | ||||
* | * | ||||
@@ -13,76 +13,77 @@ import java.io.InputStream; | |||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
public class XmlUtil { | 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); | |||||
} | |||||
} | } | ||||
} | |||||
} | } |
@@ -16,97 +16,97 @@ import java.io.*; | |||||
import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | ||||
public class YamlUtil { | 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.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(); | // StringWriter sw = new StringWriter(); | ||||
// System.out.println(sw.toString()); | // System.out.println(sw.toString()); | ||||
} | |||||
} | |||||
} | } |
@@ -1,7 +1,6 @@ | |||||
package cc.smtweb.system.bpm.util.ftp; | package cc.smtweb.system.bpm.util.ftp; | ||||
import cc.smtweb.framework.core.util.DateUtil; | import cc.smtweb.framework.core.util.DateUtil; | ||||
import cc.smtweb.framework.core.util.StringUtil; | import cc.smtweb.framework.core.util.StringUtil; | ||||
import cc.smtweb.system.bpm.util.UtilLogger; | import cc.smtweb.system.bpm.util.UtilLogger; | ||||
@@ -24,7 +23,7 @@ public class FtpTaskManager { | |||||
private Map<Thread, IFtpUtil> mapThreadFtp = new HashMap<>(); | private Map<Thread, IFtpUtil> mapThreadFtp = new HashMap<>(); | ||||
public static FtpTaskManager getInstance(String key, IFtpServerConfig ftpConfig) { | 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); | FtpTaskManager instance = mapInstance.get(key); | ||||
if (instance == null) { | if (instance == null) { | ||||
synchronized (FtpTaskManager.class) { | synchronized (FtpTaskManager.class) { | ||||
@@ -55,7 +54,7 @@ public class FtpTaskManager { | |||||
IFtpUtil ftp = mapThreadFtp.get(Thread.currentThread()); | IFtpUtil ftp = mapThreadFtp.get(Thread.currentThread()); | ||||
if (ftp != null) return ftp; | if (ftp != null) return ftp; | ||||
ftp = ftpConfig.isSFTP() ? new SFtpUtil() : new FtpUtil(); | |||||
ftp = ftpConfig.isSFTP() ? new SFtpUtil(): new FtpUtil(); | |||||
boolean isConnect = ftp.login(ftpConfig); | boolean isConnect = ftp.login(ftpConfig); | ||||
if (isConnect) { | if (isConnect) { | ||||
UtilLogger.info("FTP连接成功!"); | UtilLogger.info("FTP连接成功!"); | ||||
@@ -87,7 +86,7 @@ public class FtpTaskManager { | |||||
public Object execute(FtpTask ftpTask) throws Exception { | public Object execute(FtpTask ftpTask) throws Exception { | ||||
IFtpUtil ftp = getFtpUtil(); | IFtpUtil ftp = getFtpUtil(); | ||||
if (!ftp.isConnected()) | 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 { | try { | ||||
return ftpTask.execute(ftp); | return ftpTask.execute(ftp); | ||||
} finally { | } finally { | ||||
@@ -118,7 +117,7 @@ public class FtpTaskManager { | |||||
} | } | ||||
private String getBakPath(String path) { | private String getBakPath(String path) { | ||||
path = StringUtil.isEmpty(path) ? DateUtil.getNowYm() : path; | |||||
path = StringUtil.isEmpty(path) ? DateUtil.getNowYm(): path; | |||||
return "bak/" + path + "/"; | return "bak/" + path + "/"; | ||||
} | } | ||||
@@ -161,15 +160,17 @@ public class FtpTaskManager { | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
public void delFile(String delPath, String fileName) throws Exception { | public void delFile(String delPath, String fileName) throws Exception { | ||||
this.execute(new FtpTask() { | this.execute(new FtpTask() { | ||||
public Object execute(IFtpUtil ftp) throws Exception { | public Object execute(IFtpUtil ftp) throws Exception { | ||||
if (!ftp.existsFile(delPath, fileName)) return null; | if (!ftp.existsFile(delPath, fileName)) return null; | ||||
ftp.deleteFile(delPath,fileName ); | |||||
ftp.deleteFile(delPath, fileName); | |||||
return null; | return null; | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
//从服务器下载文件到本地。传完后,根据设置删除远程目录文件 | //从服务器下载文件到本地。传完后,根据设置删除远程目录文件 | ||||
public String[] listFileNames(final String remotePath) throws Exception { | public String[] listFileNames(final String remotePath) throws Exception { | ||||
IFtpUtil ftp = getFtpUtil(); | IFtpUtil ftp = getFtpUtil(); | ||||
@@ -6,6 +6,7 @@ package cc.smtweb.system.bpm.util.ftp; | |||||
*/ | */ | ||||
public interface IFtpServerConfig { | public interface IFtpServerConfig { | ||||
boolean isSFTP(); | boolean isSFTP(); | ||||
String getServerIp(); | String getServerIp(); | ||||
Integer getPort(); | Integer getPort(); | ||||
@@ -9,10 +9,13 @@ import java.io.InputStream; | |||||
public interface IFtpUtil { | public interface IFtpUtil { | ||||
//是否自动删除 | //是否自动删除 | ||||
boolean isAutoFree(); | boolean isAutoFree(); | ||||
//设置自动删除 | //设置自动删除 | ||||
void setAutoFree(boolean autoFree); | void setAutoFree(boolean autoFree); | ||||
//登录ftp | //登录ftp | ||||
boolean login(IFtpServerConfig ftpConf); | boolean login(IFtpServerConfig ftpConf); | ||||
//退出ftp | //退出ftp | ||||
void logout(); | void logout(); | ||||
@@ -21,6 +24,7 @@ public interface IFtpUtil { | |||||
//设置远程目录 | //设置远程目录 | ||||
boolean setRemoteDir(String path); | boolean setRemoteDir(String path); | ||||
void mkdir(String dirName); | void mkdir(String dirName); | ||||
//删除远程路径 | //删除远程路径 | ||||
@@ -37,6 +41,7 @@ public interface IFtpUtil { | |||||
boolean uploadFile(String path, String filename, File localFile) throws Exception; | boolean uploadFile(String path, String filename, File localFile) throws Exception; | ||||
void deleteFile(String path, String filename); | void deleteFile(String path, String filename); | ||||
//判断文件是否存在 | //判断文件是否存在 | ||||
boolean existsFile(String path, String filename); | boolean existsFile(String path, String filename); | ||||
@@ -1,22 +1,13 @@ | |||||
package cc.smtweb.system.bpm.web; | 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.annotation.SwStartListener; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.SwConsts; | 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.impl.DatabaseUtil; | ||||
import cc.smtweb.framework.core.db.vo.ModelCatalog; | import cc.smtweb.framework.core.db.vo.ModelCatalog; | ||||
import cc.smtweb.framework.core.mvc.controller.IStartListener; | import cc.smtweb.framework.core.mvc.controller.IStartListener; | ||||
import cc.smtweb.framework.core.mvc.service.TreeHelper; | 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 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 | * Created by Akmm at 2022/7/8 19:57 | ||||
@@ -38,7 +29,7 @@ public class BpmStartedListener implements IStartListener { | |||||
new DatabaseUtil(true, false).checkDb(); | new DatabaseUtil(true, false).checkDb(); | ||||
//初始化缓存 | //初始化缓存 | ||||
CacheManager.getIntance().init(); | CacheManager.getIntance().init(); | ||||
TreeHelper.regTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class); | TreeHelper.regTreeHelper(ModelCatalog.ENTITY_NAME, ModelCatalogTreeHelper.class); | ||||
} | } | ||||
} | } |
@@ -40,7 +40,7 @@ public class ModelCatalogCache extends AbstractCache<ModelCatalog> { | |||||
public String getName(long id) { | public String getName(long id) { | ||||
ModelCatalog bean = get(id); | ModelCatalog bean = get(id); | ||||
return bean != null ? bean.getName() : ""; | |||||
return bean != null ? bean.getName(): ""; | |||||
} | } | ||||
public String getFullName(long id) { | public String getFullName(long id) { | ||||
@@ -64,7 +64,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
@Override | @Override | ||||
protected List<DefaultEntity> filterData() { | 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<>(); | if (setId.isEmpty()) return new ArrayList<>(); | ||||
String sqlPrjId = CommUtil.getSqlInIds(setId); | String sqlPrjId = CommUtil.getSqlInIds(setId); | ||||
@@ -106,7 +106,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
@Override | @Override | ||||
protected List<DefaultEntity> getChildren(long id) { | 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; | List<DefaultEntity> listRet; | ||||
if (type != TYPE_CATALOG && exc_empty) {//排除空目录 | if (type != TYPE_CATALOG && exc_empty) {//排除空目录 | ||||
listRet = cleanEmpty(list); | listRet = cleanEmpty(list); | ||||
@@ -160,7 +160,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
addPageChildren(listRet, mc.getId(), type); | addPageChildren(listRet, mc.getId(), type); | ||||
} | } | ||||
if (!listRet.isEmpty()) return true; | 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; | if (list == null || list.isEmpty()) return false; | ||||
for (ModelCatalog c : list) { | for (ModelCatalog c : list) { | ||||
if (hasChildren(c)) return true; | if (hasChildren(c)) return true; | ||||
@@ -259,7 +259,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity> | |||||
final ModelForm form = (ModelForm) bean; | final ModelForm form = (ModelForm) bean; | ||||
node.put("type", form.getType() + 2); | 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) { | if (form.getType() == SwEnum.FormType.MODULE.value) { | ||||
List<DefaultEntity> lf = mapFormChild.get(form.getEntityId()); | List<DefaultEntity> lf = mapFormChild.get(form.getEntityId()); | ||||
@@ -17,15 +17,15 @@ public class ModelCatalogTreeHelper extends TreeHelper<ModelCatalog> { | |||||
super(ModelCatalog.ENTITY_NAME); | 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) { | if (id > 0L) { | ||||
return getChildren(id, comparator); | 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<>(); | if (setId.isEmpty()) return new ArrayList<>(); | ||||
Set<ModelCatalog> set = new HashSet<>(); | 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); | Collection<ModelCatalog> st = cache.getListByKey(CACHE_KEY, prjId + SwConsts.SPLIT_CHAR + SwConsts.DEF_ROOT_ID); | ||||
if (st != null) set.addAll(st); | if (st != null) set.addAll(st); | ||||
} | } | ||||
@@ -19,12 +19,13 @@ import java.util.Set; | |||||
@SwCache(ident = "ASP_MODEL_PROJECT", title = "项目定义") | @SwCache(ident = "ASP_MODEL_PROJECT", title = "项目定义") | ||||
public class ModelProjectCache extends AbstractCache<ModelProject> { | public class ModelProjectCache extends AbstractCache<ModelProject> { | ||||
private final static String mm = "m"; | private final static String mm = "m"; | ||||
public static ModelProjectCache getInstance() { | public static ModelProjectCache getInstance() { | ||||
return CacheManager.getIntance().getCache(ModelProjectCache.class); | return CacheManager.getIntance().getCache(ModelProjectCache.class); | ||||
} | } | ||||
public ModelProjectCache() { | public ModelProjectCache() { | ||||
regMap(mm, k-> String.valueOf(k.getModule())); | |||||
regMap(mm, k -> String.valueOf(k.getModule())); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -40,14 +41,16 @@ public class ModelProjectCache extends AbstractCache<ModelProject> { | |||||
public String getModule(long id) { | public String getModule(long id) { | ||||
ModelProject bean = get(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) { | public String getIdByModule(String module) { | ||||
ModelProject bean = getByModule(module); | ModelProject bean = getByModule(module); | ||||
return bean !=null ? String.valueOf(bean.getId()): ""; | |||||
return bean != null ? String.valueOf(bean.getId()): ""; | |||||
} | } | ||||
//找当前项目及其依赖项目的id集合,递归 | //找当前项目及其依赖项目的id集合,递归 | ||||
@@ -65,7 +68,7 @@ public class ModelProjectCache extends AbstractCache<ModelProject> { | |||||
set.add(id); | set.add(id); | ||||
if (StringUtils.isEmpty(bean.getDepends())) return; | if (StringUtils.isEmpty(bean.getDepends())) return; | ||||
String[] dps = bean.getDepends().split(","); | String[] dps = bean.getDepends().split(","); | ||||
for (String s: dps) { | |||||
for (String s : dps) { | |||||
s = s.trim(); | s = s.trim(); | ||||
if (StringUtils.isEmpty(s)) return; | if (StringUtils.isEmpty(s)) return; | ||||
addPrjId(set, NumberUtil.getLongIgnoreErr(s)); | addPrjId(set, NumberUtil.getLongIgnoreErr(s)); | ||||
@@ -44,6 +44,7 @@ public interface FlowConst { | |||||
public static StrEnumBean LOG = instance.addEnum("log", "流程历史"); | public static StrEnumBean LOG = instance.addEnum("log", "流程历史"); | ||||
} | } | ||||
/** | /** | ||||
* 活动类型 1-开始任务 2-用户任务 3-条件分支 4-并行开始 5-并行结束 6-脚本任务 9-结束任务 | * 活动类型 1-开始任务 2-用户任务 3-条件分支 4-并行开始 5-并行结束 6-脚本任务 9-结束任务 | ||||
*/ | */ | ||||
@@ -24,7 +24,7 @@ public class ModelProc extends DefaultEntity { | |||||
public void clear() { | public void clear() { | ||||
procInfo = null; | procInfo = null; | ||||
} | } | ||||
public ProcInfo getProcInfo() { | public ProcInfo getProcInfo() { | ||||
if (procInfo == null) { | if (procInfo == null) { | ||||
synchronized ("ModelProc_" + getId()) { | synchronized ("ModelProc_" + getId()) { | ||||
@@ -25,9 +25,9 @@ public class ModelProcCache extends AbstractCache<ModelProc> { | |||||
} | } | ||||
public ModelProcCache() { | 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 | @Override | ||||
@@ -22,11 +22,13 @@ public class ModelProcHelper { | |||||
public static ModelProc getFromCache(long proc_id) { | public static ModelProc getFromCache(long proc_id) { | ||||
return ModelProcCache.getInstance().get(proc_id); | return ModelProcCache.getInstance().get(proc_id); | ||||
} | } | ||||
public static ProcInfo getProcFromCache(long proc_id) { | public static ProcInfo getProcFromCache(long proc_id) { | ||||
ModelProc proc = getFromCache(proc_id); | ModelProc proc = getFromCache(proc_id); | ||||
if (proc == null) return null; | if (proc == null) return null; | ||||
return proc.getProcInfo(); | return proc.getProcInfo(); | ||||
} | } | ||||
/** | /** | ||||
* 获取配置的工作流程定义 | * 获取配置的工作流程定义 | ||||
* | * | ||||
@@ -36,7 +38,7 @@ public class ModelProcHelper { | |||||
*/ | */ | ||||
public static ModelProc getBillProc(long bill_type, long user_id) { | public static ModelProc getBillProc(long bill_type, long user_id) { | ||||
Set<BillFlow> list = BillFlowCache.getInstance().getByBillType(bill_type); | Set<BillFlow> list = BillFlowCache.getInstance().getByBillType(bill_type); | ||||
if (CommUtil.isEmpty(list)) { | if (CommUtil.isEmpty(list)) { | ||||
return null; | return null; | ||||
} | } | ||||
@@ -101,7 +103,7 @@ public class ModelProcHelper { | |||||
return act; | return act; | ||||
} | } | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
@@ -1,8 +1,6 @@ | |||||
package cc.smtweb.system.bpm.web.design.flow; | package cc.smtweb.system.bpm.web.design.flow; | ||||
import cc.smtweb.framework.core.common.R; | 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.exception.BizException; | ||||
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | ||||
@@ -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.SwBody; | ||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.common.R; | 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.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | 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.DefaultDelHandler; | ||||
import cc.smtweb.framework.core.mvc.service.DefaultListHandler; | import cc.smtweb.framework.core.mvc.service.DefaultListHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | 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.design.form.ModelFormHelper; | ||||
import cc.smtweb.system.bpm.web.engine.flow.entity.Comment; | 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.ProcInst; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Set; | |||||
/** | /** | ||||
* Created by Akmm at 2022/3/22 9:12 | * 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) { | 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) { | 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); | ModelFormHelper.buildFieldInfo(table, field, col); | ||||
ret.add(col); | ret.add(col); | ||||
} | } | ||||
return R.success(ret); | return R.success(ret); | ||||
} | } | ||||
@@ -26,7 +26,7 @@ public class ProcInfo { | |||||
public Activity findActivity(String id) { | public Activity findActivity(String id) { | ||||
if (StringUtils.isEmpty(id)) return null; | if (StringUtils.isEmpty(id)) return null; | ||||
for (Activity act: activities) { | |||||
for (Activity act : activities) { | |||||
if (id.equalsIgnoreCase(act.getId())) { | if (id.equalsIgnoreCase(act.getId())) { | ||||
return act; | return act; | ||||
} | } | ||||
@@ -37,13 +37,13 @@ public class ProcInfo { | |||||
//获取任务名称 | //获取任务名称 | ||||
public String getActNameById(String id) { | public String getActNameById(String id) { | ||||
Activity act = findActivity(id); | Activity act = findActivity(id); | ||||
return act != null ? act.getLabel() : ""; | |||||
return act != null ? act.getLabel(): ""; | |||||
} | } | ||||
//获取结束节点 | //获取结束节点 | ||||
public List<Activity> findEndActivity() { | public List<Activity> findEndActivity() { | ||||
List<Activity> list = new ArrayList<>(); | List<Activity> list = new ArrayList<>(); | ||||
for (Activity act: activities) { | |||||
for (Activity act : activities) { | |||||
if (act.getType() == FlowConst.ActivityType.END.value) { | if (act.getType() == FlowConst.ActivityType.END.value) { | ||||
list.add(act); | list.add(act); | ||||
} | } | ||||
@@ -14,5 +14,5 @@ public class Sign extends Handler { | |||||
private int minAgree; | private int minAgree; | ||||
//最少会签同意人数单位:0-人数 1-会签同意占比 | //最少会签同意人数单位:0-人数 1-会签同意占比 | ||||
private int minAgreeUnit; | private int minAgreeUnit; | ||||
} | } |
@@ -1,6 +1,8 @@ | |||||
package cc.smtweb.system.bpm.web.design.form; | 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.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelCache; | import cc.smtweb.framework.core.db.vo.ModelCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelField; | import cc.smtweb.framework.core.db.vo.ModelField; | ||||
@@ -231,6 +231,6 @@ public class ModelForm extends DefaultEntity { | |||||
//返回单据类型id | //返回单据类型id | ||||
public long getBillType() { | public long getBillType() { | ||||
SwMap opts = getOpts(); | SwMap opts = getOpts(); | ||||
return opts != null ? opts.readLong(ModelFormHelper.KEY_BILL_TYPE) : 0L; | |||||
return opts != null ? opts.readLong(ModelFormHelper.KEY_BILL_TYPE): 0L; | |||||
} | } | ||||
} | } |
@@ -16,6 +16,7 @@ import java.util.Set; | |||||
public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> { | public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> { | ||||
//被删除的id | //被删除的id | ||||
private Set<ModelForm> listDeled = new HashSet<>(); | private Set<ModelForm> listDeled = new HashSet<>(); | ||||
public ModelFormDelHandler() { | public ModelFormDelHandler() { | ||||
super(ModelForm.ENTITY_NAME); | super(ModelForm.ENTITY_NAME); | ||||
} | } | ||||
@@ -29,7 +30,7 @@ public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> { | |||||
protected void delDb() { | protected void delDb() { | ||||
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class); | EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class); | ||||
Set<ModelForm> l1 = ModelFormCache.getInstance().getListByModule(id); | 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)) { | if (CommUtil.isEmpty(list)) { | ||||
listDeled = null; | listDeled = null; | ||||
dao.deleteEntity(id); | dao.deleteEntity(id); | ||||
@@ -37,7 +38,7 @@ public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> { | |||||
listDeled = new HashSet<>(list); | listDeled = new HashSet<>(list); | ||||
List<Long> ids = new ArrayList<>(); | List<Long> ids = new ArrayList<>(); | ||||
ids.add(id); | ids.add(id); | ||||
for (ModelForm form: list) { | |||||
for (ModelForm form : list) { | |||||
ids.add(form.getId()); | ids.add(form.getId()); | ||||
} | } | ||||
dao.deleteEntity(ids); | dao.deleteEntity(ids); | ||||
@@ -48,7 +49,7 @@ public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> { | |||||
protected void saveSuccess() { | protected void saveSuccess() { | ||||
ModelFormCache cache = ModelFormCache.getInstance(); | ModelFormCache cache = ModelFormCache.getInstance(); | ||||
if (!CommUtil.isEmpty(listDeled)) { | if (!CommUtil.isEmpty(listDeled)) { | ||||
for (ModelForm form: listDeled) { | |||||
for (ModelForm form : listDeled) { | |||||
cache.remove(form.getId()); | cache.remove(form.getId()); | ||||
} | } | ||||
} | } | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.system.bpm.web.design.form; | 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.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | 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.exception.BizException; | ||||
import cc.smtweb.framework.core.mvc.variable.SwVariableFactory; | import cc.smtweb.framework.core.mvc.variable.SwVariableFactory; | ||||
import cc.smtweb.framework.core.session.UserSession; | 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.spring.BpmConfigBean; | ||||
import cc.smtweb.system.bpm.util.CodeGenerator; | import cc.smtweb.system.bpm.util.CodeGenerator; | ||||
import cc.smtweb.system.bpm.util.IdeaUtil; | import cc.smtweb.system.bpm.util.IdeaUtil; | ||||
@@ -493,7 +495,7 @@ public class ModelFormHelper { | |||||
field.put("field", pdf.field); | field.put("field", pdf.field); | ||||
field.put("name", pdf.name); | field.put("name", pdf.name); | ||||
String label = (String) field.get("field_label"); | 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()); | field.put("required", pdf.isFieldNotNull()); | ||||
final SwEnum.DataTypeBean dtb = SwEnum.DataType.instance.getByValue(pdf.dataType); | final SwEnum.DataTypeBean dtb = SwEnum.DataType.instance.getByValue(pdf.dataType); | ||||
if (dtb != null) { | if (dtb != null) { | ||||
@@ -501,10 +503,10 @@ public class ModelFormHelper { | |||||
} else { | } else { | ||||
field.put("maxlength", 0); | 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); | setWidget.add(widgetId); | ||||
} | } | ||||
} | } | ||||
@@ -513,6 +515,7 @@ public class ModelFormHelper { | |||||
/** | /** | ||||
* 页面设计时,返回的字段信息,带控件 | * 页面设计时,返回的字段信息,带控件 | ||||
* | |||||
* @param table | * @param table | ||||
* @param field | * @param field | ||||
* @param col | * @param col | ||||
@@ -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.R; | ||||
import cc.smtweb.framework.core.common.SwConsts; | 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.common.SwMap; | ||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler; | ||||
import cc.smtweb.framework.core.util.FileUtil; | import cc.smtweb.framework.core.util.FileUtil; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | 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 cc.smtweb.system.bpm.web.sys.base.billType.BillTypeCache; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | |||||
/** | /** | ||||
* Created by Akmm at 2022/5/9 16:17 | * Created by Akmm at 2022/5/9 16:17 | ||||
@@ -76,7 +69,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
//加载页面js方法 | //加载页面js方法 | ||||
public R loadJsFuncs() { | public R loadJsFuncs() { | ||||
ModelForm form = localLoadForm(); | ModelForm form = localLoadForm(); | ||||
List<String> listRet = new ArrayList<>(); | List<String> listRet = new ArrayList<>(); | ||||
R r = R.success(listRet); | R r = R.success(listRet); | ||||
@@ -42,6 +42,7 @@ public class BaseDatasetField { | |||||
public String defValue; | public String defValue; | ||||
// type为depend时, 表达式 | // type为depend时, 表达式 | ||||
public String dependExpr; | public String dependExpr; | ||||
@JsonIgnore | @JsonIgnore | ||||
public boolean isFieldNotNull() { | public boolean isFieldNotNull() { | ||||
return notNull == 1; | return notNull == 1; | ||||
@@ -3,7 +3,10 @@ package cc.smtweb.system.bpm.web.design.form.define; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import com.fasterxml.jackson.annotation.JsonIgnore; | 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 | * Created by Akmm at 2022/5/25 15:53 | ||||
@@ -5,16 +5,13 @@ import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.exception.SwException; | 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.JsonUtil; | ||||
import cc.smtweb.framework.core.util.StringUtil; | import cc.smtweb.framework.core.util.StringUtil; | ||||
import cc.smtweb.system.bpm.web.design.form.ModelForm; | 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.design.form.ModelFormHelper; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Set; | |||||
/** | /** | ||||
* Created by Akmm at 2022-08-14 10:37 | * Created by Akmm at 2022-08-14 10:37 | ||||
@@ -23,6 +20,7 @@ import java.util.Set; | |||||
public class BaseModelWorker { | public class BaseModelWorker { | ||||
/** | /** | ||||
* 模块/页面保存:opts根据模型做些个性化处理,如果是模块,需要添加子页面 | * 模块/页面保存:opts根据模型做些个性化处理,如果是模块,需要添加子页面 | ||||
* | |||||
* @param bean | * @param bean | ||||
* @param listFormChild | * @param listFormChild | ||||
*/ | */ | ||||
@@ -74,6 +72,7 @@ public class BaseModelWorker { | |||||
/** | /** | ||||
* 根据模型生成页面 | * 根据模型生成页面 | ||||
* | |||||
* @param bean | * @param bean | ||||
*/ | */ | ||||
public void buildSaveModel(ModelForm bean) { | public void buildSaveModel(ModelForm bean) { | ||||
@@ -14,10 +14,10 @@ public class LcLtMsWorker extends LcMsWorker { | |||||
@Override | @Override | ||||
protected String getTmplId(ModelForm bean) { | 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; | 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 templateCard; | ||||
} | } | ||||
return super.getTmplId(bean); | return super.getTmplId(bean); | ||||
@@ -14,10 +14,10 @@ public class LcLtWorker extends LcNormalWorker { | |||||
@Override | @Override | ||||
protected String getTmplId(ModelForm bean) { | 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; | 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 templateCard; | ||||
} | } | ||||
return super.getTmplId(bean); | return super.getTmplId(bean); | ||||
@@ -8,16 +8,16 @@ import cc.smtweb.system.bpm.web.design.form.ModelForm; | |||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/8/28 12:11 | * @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 templateList = "model_list_normal"; | ||||
private final static String templateCard = "model_card_ms"; | private final static String templateCard = "model_card_ms"; | ||||
@Override | @Override | ||||
protected String getTmplId(ModelForm bean) { | 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; | 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 templateCard; | ||||
} | } | ||||
return super.getTmplId(bean); | return super.getTmplId(bean); | ||||
@@ -59,10 +59,10 @@ public class LcNormalWorker extends BaseModelWorker { | |||||
@Override | @Override | ||||
protected String getTmplId(ModelForm bean) { | 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; | 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 templateCard; | ||||
} | } | ||||
return super.getTmplId(bean); | return super.getTmplId(bean); | ||||
@@ -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 cc.smtweb.system.bpm.web.design.form.model.flow.FlowSingleWorker; | ||||
import org.apache.commons.lang3.StringUtils; | 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 | * Created by Akmm at 2022-08-14 10:02 | ||||
@@ -17,6 +19,7 @@ import java.util.*; | |||||
public class ModelFactory { | public class ModelFactory { | ||||
private static ModelFactory instance; | private static ModelFactory instance; | ||||
private static Map<String, BaseModelWorker> mapWorker; | private static Map<String, BaseModelWorker> mapWorker; | ||||
static { | static { | ||||
instance = new ModelFactory(); | instance = new ModelFactory(); | ||||
mapWorker = new HashMap<>(); | mapWorker = new HashMap<>(); | ||||
@@ -22,6 +22,7 @@ import java.util.List; | |||||
public class FlowSingleWorker extends BaseModelWorker { | public class FlowSingleWorker extends BaseModelWorker { | ||||
private final static String listTmpl = "model_list_flow"; | private final static String listTmpl = "model_list_flow"; | ||||
private final static String cardTmpl = "model_card_flow"; | private final static String cardTmpl = "model_card_flow"; | ||||
@Override | @Override | ||||
protected void saveModule(ModelForm bean, List<ModelForm> listFormChild) { | protected void saveModule(ModelForm bean, List<ModelForm> listFormChild) { | ||||
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class); | EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class); | ||||
@@ -58,14 +59,14 @@ public class FlowSingleWorker extends BaseModelWorker { | |||||
@Override | @Override | ||||
public void buildSaveModel(ModelForm bean) { | public void buildSaveModel(ModelForm bean) { | ||||
ModelForm parent = ModelFormCache.getInstance().get(bean.getParent()); | ModelForm parent = ModelFormCache.getInstance().get(bean.getParent()); | ||||
if(parent==null){ | |||||
if (parent == null) { | |||||
return; | 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); | ModelFormHelper.buildSaveModelByTmpl(bean, listTmpl); | ||||
}else if(cardFormName.equals(bean.getName())){ | |||||
} else if (cardFormName.equals(bean.getName())) { | |||||
ModelFormHelper.buildSaveModelByTmpl(bean, cardTmpl); | ModelFormHelper.buildSaveModelByTmpl(bean, cardTmpl); | ||||
} | } | ||||
} | } | ||||
@@ -7,46 +7,46 @@ import java.util.List; | |||||
@Data | @Data | ||||
public class MenuVO { | 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; | |||||
} | |||||
}; | |||||
} | |||||
} | } |
@@ -32,7 +32,7 @@ public class PreviewMenuTreeService { | |||||
public R treeAll(@SwParam("module") String module, UserSession us) { | public R treeAll(@SwParam("module") String module, UserSession us) { | ||||
String prj_id = ModelProjectCache.getInstance().getIdByModule(module); | 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); | List<MenuVO> menuVOList = buildMenu(prj_id, module, us); | ||||
if (!CommUtil.isEmpty(menuVOList)) { | if (!CommUtil.isEmpty(menuVOList)) { | ||||
return R.success(menuVOList); | return R.success(menuVOList); | ||||
@@ -1,8 +1,7 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | 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.common.SwMap; | ||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.mvc.service.AbstractHandler; | import cc.smtweb.framework.core.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.system.bpm.web.design.form.ModelForm; | import cc.smtweb.system.bpm.web.design.form.ModelForm; | ||||
@@ -20,9 +19,11 @@ public abstract class AbstractDynPageHandler extends AbstractHandler { | |||||
protected PageDatasets datasets; | protected PageDatasets datasets; | ||||
protected DynPageProvider provider = getProvider(); | protected DynPageProvider provider = getProvider(); | ||||
public DynPageProvider getProvider() { | public DynPageProvider getProvider() { | ||||
return new DynPageProvider(); | return new DynPageProvider(); | ||||
} | } | ||||
@Override | @Override | ||||
public void init(SwMap params, UserSession us) { | public void init(SwMap params, UserSession us) { | ||||
super.init(params, us); | super.init(params, us); | ||||
@@ -274,7 +274,7 @@ public class DynPageHelper { | |||||
return null; | return null; | ||||
} | } | ||||
IBuilderExpr builder = getBuilder(dynCond.opt); | 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); | return builder.build(dynCond.opt, filter.sqlName, ns, value, args); | ||||
} | } | ||||
@@ -334,7 +334,7 @@ public class DynPageHelper { | |||||
private static IBuilderExpr getBuilder(String opt) { | private static IBuilderExpr getBuilder(String opt) { | ||||
IBuilderExpr builder = mapBuilder.get(opt); | IBuilderExpr builder = mapBuilder.get(opt); | ||||
return builder != null ? builder : baseBuilder; | |||||
return builder != null ? builder: baseBuilder; | |||||
} | } | ||||
interface IBuilderExpr { | interface IBuilderExpr { | ||||
@@ -52,18 +52,18 @@ public class DynPageListHandler extends AbstractListHandler { | |||||
@Override | @Override | ||||
protected List<SwMap> queryData(String sql, SqlPara sqlPara) { | protected List<SwMap> queryData(String sql, SqlPara sqlPara) { | ||||
List<SwMap> list; | List<SwMap> list; | ||||
SqlNamedPara sp = (SqlNamedPara)sqlPara; | |||||
SqlNamedPara sp = (SqlNamedPara) sqlPara; | |||||
if (sqlPara.page > 0 && sqlPara.rows > 0) { | if (sqlPara.page > 0 && sqlPara.rows > 0) { | ||||
list = DbEngine.getInstance().pagedQueryN(sql, SwMap.class, (sqlPara.page - 1) * sqlPara.rows, sqlPara.rows, sp.mapParas); | list = DbEngine.getInstance().pagedQueryN(sql, SwMap.class, (sqlPara.page - 1) * sqlPara.rows, sqlPara.rows, sp.mapParas); | ||||
} else { | } else { | ||||
list = DbEngine.getInstance().queryN(sql, sp.mapParas, SwMap.class); | list = DbEngine.getInstance().queryN(sql, sp.mapParas, SwMap.class); | ||||
} | } | ||||
if(pageDataSet.masterTable > 0L){ | |||||
if (pageDataSet.masterTable > 0L) { | |||||
ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ||||
EntityHelper.loadBeanText(masterTable.getName(), list, sp.mapFieldAlias); | EntityHelper.loadBeanText(masterTable.getName(), list, sp.mapFieldAlias); | ||||
} | } | ||||
for (SwMap map: list) { | |||||
for (SwMap map : list) { | |||||
DynPageHelper.setCalcFields(map, pageDataSet); | DynPageHelper.setCalcFields(map, pageDataSet); | ||||
} | } | ||||
return list; | return list; | ||||
@@ -4,8 +4,6 @@ import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.mvc.service.SwListData; | 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; | import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | ||||
/** | /** | ||||
@@ -19,6 +17,7 @@ public class DynPageLoadHandler extends AbstractDynPageHandler { | |||||
//对应的数据集定义 | //对应的数据集定义 | ||||
private PageDataset pageDataSet; | private PageDataset pageDataSet; | ||||
//列表工具类 | //列表工具类 | ||||
public DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { | public DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { | ||||
DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); | DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); | ||||
@@ -32,6 +31,7 @@ public class DynPageLoadHandler extends AbstractDynPageHandler { | |||||
listHandler.init(params, us); | listHandler.init(params, us); | ||||
return listHandler; | return listHandler; | ||||
} | } | ||||
//新增操作,初始化定义的数据集 | //新增操作,初始化定义的数据集 | ||||
public R add() { | public R add() { | ||||
//返回的数据,以dataset.name为key,查出的结果(bean或list)为value | //返回的数据,以dataset.name为key,查出的结果(bean或list)为value | ||||
@@ -64,11 +64,16 @@ public class DynPageLoadHandler extends AbstractDynPageHandler { | |||||
} | } | ||||
//新增初始化 - bean | //新增初始化 - 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 | //新增初始化 - list | ||||
protected void afterAddList(PageDataset dataset, SwListData bean){} | |||||
protected void afterAddList(PageDataset dataset, SwListData bean) { | |||||
} | |||||
//新增操作,初始化定义的数据集 | //新增操作,初始化定义的数据集 | ||||
public R addOne() { | public R addOne() { | ||||
@@ -107,7 +112,7 @@ public class DynPageLoadHandler extends AbstractDynPageHandler { | |||||
bean = DynRetBean.createList(SwListData.create(getTreeWorker(filter, pageDataSet).buildData(), 0)); | bean = DynRetBean.createList(SwListData.create(getTreeWorker(filter, pageDataSet).buildData(), 0)); | ||||
} else {//表单类 | } else {//表单类 | ||||
SwMap data = provider.loadData(filter, pageDataSet); | SwMap data = provider.loadData(filter, pageDataSet); | ||||
afterLoadBean(pageDataSet,data); | |||||
afterLoadBean(pageDataSet, data); | |||||
bean = DynRetBean.createBean(data); | bean = DynRetBean.createBean(data); | ||||
} | } | ||||
@@ -1,13 +1,13 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | 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.common.SwMap; | ||||
import cc.smtweb.framework.core.db.DbEngine; | 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.EntityHelper; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | 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.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.exception.SwException; | import cc.smtweb.framework.core.exception.SwException; | ||||
import cc.smtweb.framework.core.mvc.service.AbstractCompProvider; | import cc.smtweb.framework.core.mvc.service.AbstractCompProvider; | ||||
import cc.smtweb.framework.core.mvc.service.SqlNamedPara; | import cc.smtweb.framework.core.mvc.service.SqlNamedPara; | ||||
@@ -30,46 +30,46 @@ public class DynPageService extends AbstractCompService { | |||||
//新增 | //新增 | ||||
public R add(@SwBody SwMap params, UserSession us) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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()); | |||||
} | } | ||||
} | } |
@@ -50,6 +50,7 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> { | |||||
/** | /** | ||||
* 构建sql | * 构建sql | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
protected SqlNamedPara buildDataSqlPara(long id) { | protected SqlNamedPara buildDataSqlPara(long id) { | ||||
@@ -58,6 +59,7 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> { | |||||
/** | /** | ||||
* 构建sql | * 构建sql | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
protected SqlNamedPara buildFilterSqlPara(String text) { | protected SqlNamedPara buildFilterSqlPara(String text) { | ||||
@@ -86,6 +88,6 @@ public class DynPageTreeHandler extends AbstractTreeHandler<SwMap> { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ||||
if (table == null) throw new BizException("未找到数据集表定义:" + pageDataSet.masterTable); | if (table == null) throw new BizException("未找到数据集表定义:" + pageDataSet.masterTable); | ||||
ModelField field = table.findFieldByType(SwEnum.FieldType.NAME.value); | 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()); | |||||
} | } | ||||
} | } |
@@ -19,6 +19,7 @@ public class DynRetBean { | |||||
public static DynRetBean createBean(DefaultEntity bean) { | public static DynRetBean createBean(DefaultEntity bean) { | ||||
return createBean(bean.getData()); | return createBean(bean.getData()); | ||||
} | } | ||||
public static DynRetBean createBean(SwMap swMap) { | public static DynRetBean createBean(SwMap swMap) { | ||||
SwMap form = (SwMap) swMap.clone(); | SwMap form = (SwMap) swMap.clone(); | ||||
DynRetBean bean = new DynRetBean(); | DynRetBean bean = new DynRetBean(); | ||||
@@ -1,7 +1,6 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | package cc.smtweb.system.bpm.web.engine.dynPage; | ||||
import cc.smtweb.framework.core.common.SwMap; | 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; | import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | ||||
/** | /** | ||||
@@ -49,7 +49,7 @@ public class FlowHelper { | |||||
public static void stopTask(long billId, long tskId) { | public static void stopTask(long billId, long tskId) { | ||||
DbEngine.getInstance().update("update " + EntityHelper.getSchemaTableName(Task.ENTITY_NAME) + | 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; | return listRet; | ||||
} | } | ||||
/** | |||||
/** | |||||
* 递归处理,兼容判断后面加判断,并发后面跟并发 | * 递归处理,兼容判断后面加判断,并发后面跟并发 | ||||
* | * | ||||
* @param act | * @param act | ||||
@@ -11,16 +11,27 @@ import java.util.List; | |||||
*/ | */ | ||||
public interface FlowListener { | 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) { | |||||
} | |||||
} | } |
@@ -5,12 +5,8 @@ import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.EntityHelper; | import cc.smtweb.framework.core.db.EntityHelper; | ||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
import cc.smtweb.framework.core.mvc.service.AbstractCompProvider; | 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.framework.core.util.CommUtil; | ||||
import cc.smtweb.system.bpm.web.design.flow.FlowConst; | 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.Comment; | ||||
import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst; | import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst; | ||||
import cc.smtweb.system.bpm.web.engine.flow.entity.Task; | import cc.smtweb.system.bpm.web.engine.flow.entity.Task; | ||||
@@ -1,7 +1,6 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow.entity; | package cc.smtweb.system.bpm.web.engine.flow.entity; | ||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
/** | /** | ||||
@@ -16,102 +15,156 @@ public class Comment extends DefaultEntity { | |||||
super(ENTITY_NAME); | super(ENTITY_NAME); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public long getId() { | public long getId() { | ||||
return getLong("cmt_id"); | return getLong("cmt_id"); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public void setId(long cmt_id) { | public void setId(long cmt_id) { | ||||
put("cmt_id", cmt_id); | put("cmt_id", cmt_id); | ||||
} | } | ||||
/** 流程id */ | |||||
/** | |||||
* 流程id | |||||
*/ | |||||
public long getPriId() { | public long getPriId() { | ||||
return getLong("cmt_pri_id"); | return getLong("cmt_pri_id"); | ||||
} | } | ||||
/** 流程id */ | |||||
/** | |||||
* 流程id | |||||
*/ | |||||
public void setPriId(long cmt_pri_id) { | public void setPriId(long cmt_pri_id) { | ||||
put("cmt_pri_id", cmt_pri_id); | put("cmt_pri_id", cmt_pri_id); | ||||
} | } | ||||
/** 任务id */ | |||||
/** | |||||
* 任务id | |||||
*/ | |||||
public long getTskId() { | public long getTskId() { | ||||
return getLong("cmt_tsk_id"); | return getLong("cmt_tsk_id"); | ||||
} | } | ||||
/** 任务id */ | |||||
/** | |||||
* 任务id | |||||
*/ | |||||
public void setTskId(long cmt_tsk_id) { | public void setTskId(long cmt_tsk_id) { | ||||
put("cmt_tsk_id", cmt_tsk_id); | put("cmt_tsk_id", cmt_tsk_id); | ||||
} | } | ||||
/** 活动id */ | |||||
/** | |||||
* 活动id | |||||
*/ | |||||
public String getActId() { | public String getActId() { | ||||
return getStr("cmt_act_id"); | return getStr("cmt_act_id"); | ||||
} | } | ||||
/** 活动id */ | |||||
/** | |||||
* 活动id | |||||
*/ | |||||
public void setActId(String cmt_act_id) { | public void setActId(String cmt_act_id) { | ||||
put("cmt_act_id", cmt_act_id); | put("cmt_act_id", cmt_act_id); | ||||
} | } | ||||
/** 活动名 */ | |||||
/** | |||||
* 活动名 | |||||
*/ | |||||
public String getActName() { | public String getActName() { | ||||
return getStr("cmt_act_name"); | return getStr("cmt_act_name"); | ||||
} | } | ||||
/** 活动名 */ | |||||
/** | |||||
* 活动名 | |||||
*/ | |||||
public void setActName(String cmt_act_name) { | public void setActName(String cmt_act_name) { | ||||
put("cmt_act_name", cmt_act_name); | put("cmt_act_name", cmt_act_name); | ||||
} | } | ||||
/** 主办人 */ | |||||
/** | |||||
* 主办人 | |||||
*/ | |||||
public long getHandler() { | public long getHandler() { | ||||
return getLong("cmt_handler"); | return getLong("cmt_handler"); | ||||
} | } | ||||
/** 主办人 */ | |||||
/** | |||||
* 主办人 | |||||
*/ | |||||
public void setHandler(long cmt_handler) { | public void setHandler(long cmt_handler) { | ||||
put("cmt_handler", cmt_handler); | put("cmt_handler", cmt_handler); | ||||
} | } | ||||
/** 开始时间 */ | |||||
/** | |||||
* 开始时间 | |||||
*/ | |||||
public long getStartTime() { | public long getStartTime() { | ||||
return getLong("cmt_start_time"); | return getLong("cmt_start_time"); | ||||
} | } | ||||
/** 开始时间 */ | |||||
/** | |||||
* 开始时间 | |||||
*/ | |||||
public void setStartTime(long cmt_start_time) { | public void setStartTime(long cmt_start_time) { | ||||
put("cmt_start_time", cmt_start_time); | put("cmt_start_time", cmt_start_time); | ||||
} | } | ||||
/** 签收时间 */ | |||||
/** | |||||
* 签收时间 | |||||
*/ | |||||
public long getHandlerTime() { | public long getHandlerTime() { | ||||
return getLong("cmt_handler_time"); | return getLong("cmt_handler_time"); | ||||
} | } | ||||
/** 签收时间 */ | |||||
/** | |||||
* 签收时间 | |||||
*/ | |||||
public void setHandlerTime(long cmt_handler_time) { | public void setHandlerTime(long cmt_handler_time) { | ||||
put("cmt_handler_time", cmt_handler_time); | put("cmt_handler_time", cmt_handler_time); | ||||
} | } | ||||
/** 结束时间 */ | |||||
/** | |||||
* 结束时间 | |||||
*/ | |||||
public long getEndTime() { | public long getEndTime() { | ||||
return getLong("cmt_end_time"); | return getLong("cmt_end_time"); | ||||
} | } | ||||
/** 结束时间 */ | |||||
/** | |||||
* 结束时间 | |||||
*/ | |||||
public void setEndTime(long cmt_end_time) { | public void setEndTime(long cmt_end_time) { | ||||
put("cmt_end_time", cmt_end_time); | put("cmt_end_time", cmt_end_time); | ||||
} | } | ||||
/** 审批意见 */ | |||||
/** | |||||
* 审批意见 | |||||
*/ | |||||
public String getComment() { | public String getComment() { | ||||
return getStr("cmt_comment"); | return getStr("cmt_comment"); | ||||
} | } | ||||
/** 审批意见 */ | |||||
/** | |||||
* 审批意见 | |||||
*/ | |||||
public void setComment(String cmt_comment) { | public void setComment(String cmt_comment) { | ||||
put("cmt_comment", cmt_comment); | put("cmt_comment", cmt_comment); | ||||
} | } | ||||
/** 状态 */ | |||||
/** | |||||
* 状态 | |||||
*/ | |||||
public int getStatu() { | public int getStatu() { | ||||
return getInt("cmt_statu"); | return getInt("cmt_statu"); | ||||
} | } | ||||
/** 状态 */ | |||||
/** | |||||
* 状态 | |||||
*/ | |||||
public void setStatu(int cmt_statu) { | public void setStatu(int cmt_statu) { | ||||
put("cmt_statu", cmt_statu); | put("cmt_statu", cmt_statu); | ||||
} | } | ||||
@@ -1,7 +1,6 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow.entity; | package cc.smtweb.system.bpm.web.engine.flow.entity; | ||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
/** | /** | ||||
@@ -16,84 +15,128 @@ public class FlowLog extends DefaultEntity { | |||||
super(ENTITY_NAME); | super(ENTITY_NAME); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public long getId() { | public long getId() { | ||||
return getLong("wfl_id"); | return getLong("wfl_id"); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public void setId(long wfl_id) { | public void setId(long wfl_id) { | ||||
put("wfl_id", wfl_id); | put("wfl_id", wfl_id); | ||||
} | } | ||||
/** 单据id */ | |||||
/** | |||||
* 单据id | |||||
*/ | |||||
public long getPriId() { | public long getPriId() { | ||||
return getLong("wfl_pri_id"); | return getLong("wfl_pri_id"); | ||||
} | } | ||||
/** 单据id */ | |||||
/** | |||||
* 单据id | |||||
*/ | |||||
public void setPriId(long wfl_pri_id) { | public void setPriId(long wfl_pri_id) { | ||||
put("wfl_pri_id", wfl_pri_id); | put("wfl_pri_id", wfl_pri_id); | ||||
} | } | ||||
/** 操作人 */ | |||||
/** | |||||
* 操作人 | |||||
*/ | |||||
public long getUsrId() { | public long getUsrId() { | ||||
return getLong("wfl_usr_id"); | return getLong("wfl_usr_id"); | ||||
} | } | ||||
/** 操作人 */ | |||||
/** | |||||
* 操作人 | |||||
*/ | |||||
public void setUsrId(long wfl_usr_id) { | public void setUsrId(long wfl_usr_id) { | ||||
put("wfl_usr_id", wfl_usr_id); | put("wfl_usr_id", wfl_usr_id); | ||||
} | } | ||||
/** 步骤id */ | |||||
/** | |||||
* 步骤id | |||||
*/ | |||||
public long getActId() { | public long getActId() { | ||||
return getLong("wfl_act_id"); | return getLong("wfl_act_id"); | ||||
} | } | ||||
/** 步骤id */ | |||||
/** | |||||
* 步骤id | |||||
*/ | |||||
public void setActId(long wfl_act_id) { | public void setActId(long wfl_act_id) { | ||||
put("wfl_act_id", wfl_act_id); | put("wfl_act_id", wfl_act_id); | ||||
} | } | ||||
/** 步骤名 */ | |||||
/** | |||||
* 步骤名 | |||||
*/ | |||||
public String getActName() { | public String getActName() { | ||||
return getStr("wfl_act_name"); | return getStr("wfl_act_name"); | ||||
} | } | ||||
/** 步骤名 */ | |||||
/** | |||||
* 步骤名 | |||||
*/ | |||||
public void setActName(String wfl_act_name) { | public void setActName(String wfl_act_name) { | ||||
put("wfl_act_name", wfl_act_name); | put("wfl_act_name", wfl_act_name); | ||||
} | } | ||||
/** 操作 */ | |||||
/** | |||||
* 操作 | |||||
*/ | |||||
public String getOpt() { | public String getOpt() { | ||||
return getStr("wfl_opt"); | return getStr("wfl_opt"); | ||||
} | } | ||||
/** 操作 */ | |||||
/** | |||||
* 操作 | |||||
*/ | |||||
public void setOpt(String wfl_opt) { | public void setOpt(String wfl_opt) { | ||||
put("wfl_opt", wfl_opt); | put("wfl_opt", wfl_opt); | ||||
} | } | ||||
/** 提交信息 */ | |||||
/** | |||||
* 提交信息 | |||||
*/ | |||||
public String getInfo() { | public String getInfo() { | ||||
return getStr("wfl_info"); | return getStr("wfl_info"); | ||||
} | } | ||||
/** 提交信息 */ | |||||
/** | |||||
* 提交信息 | |||||
*/ | |||||
public void setInfo(String wfl_info) { | public void setInfo(String wfl_info) { | ||||
put("wfl_info", wfl_info); | put("wfl_info", wfl_info); | ||||
} | } | ||||
/** 意见 */ | |||||
/** | |||||
* 意见 | |||||
*/ | |||||
public String getComment() { | public String getComment() { | ||||
return getStr("wfl_comment"); | return getStr("wfl_comment"); | ||||
} | } | ||||
/** 意见 */ | |||||
/** | |||||
* 意见 | |||||
*/ | |||||
public void setComment(String wfl_comment) { | public void setComment(String wfl_comment) { | ||||
put("wfl_comment", wfl_comment); | put("wfl_comment", wfl_comment); | ||||
} | } | ||||
/** 操作时间 */ | |||||
/** | |||||
* 操作时间 | |||||
*/ | |||||
public long getTime() { | public long getTime() { | ||||
return getLong("wfl_time"); | return getLong("wfl_time"); | ||||
} | } | ||||
/** 操作时间 */ | |||||
/** | |||||
* 操作时间 | |||||
*/ | |||||
public void setTime(long wfl_time) { | public void setTime(long wfl_time) { | ||||
put("wfl_time", wfl_time); | put("wfl_time", wfl_time); | ||||
} | } | ||||
@@ -15,111 +15,170 @@ public class ProcInst extends DefaultEntity { | |||||
super(ENTITY_NAME); | super(ENTITY_NAME); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public long getId() { | public long getId() { | ||||
return getLong("pri_id"); | return getLong("pri_id"); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public void setId(long pri_id) { | public void setId(long pri_id) { | ||||
put("pri_id", pri_id); | put("pri_id", pri_id); | ||||
} | } | ||||
/** 单据编号 */ | |||||
/** | |||||
* 单据编号 | |||||
*/ | |||||
public String getBillCode() { | public String getBillCode() { | ||||
return getStr("pri_bill_code"); | return getStr("pri_bill_code"); | ||||
} | } | ||||
/** 单据编号 */ | |||||
/** | |||||
* 单据编号 | |||||
*/ | |||||
public void setBillCode(String pri_bill_code) { | public void setBillCode(String pri_bill_code) { | ||||
put("pri_bill_code", pri_bill_code); | put("pri_bill_code", pri_bill_code); | ||||
} | } | ||||
/** 制单日期 */ | |||||
/** | |||||
* 制单日期 | |||||
*/ | |||||
public long getMakeDate() { | public long getMakeDate() { | ||||
return getLong("pri_make_date"); | return getLong("pri_make_date"); | ||||
} | } | ||||
/** 制单日期 */ | |||||
/** | |||||
* 制单日期 | |||||
*/ | |||||
public void setMakeDate(long pri_make_date) { | public void setMakeDate(long pri_make_date) { | ||||
put("pri_make_date", pri_make_date); | put("pri_make_date", pri_make_date); | ||||
} | } | ||||
/** 单据类别 */ | |||||
/** | |||||
* 单据类别 | |||||
*/ | |||||
public long getBillType() { | public long getBillType() { | ||||
return getLong("pri_bill_type"); | return getLong("pri_bill_type"); | ||||
} | } | ||||
/** 单据类别 */ | |||||
/** | |||||
* 单据类别 | |||||
*/ | |||||
public void setBillType(long pri_bill_type) { | public void setBillType(long pri_bill_type) { | ||||
put("pri_bill_type", pri_bill_type); | put("pri_bill_type", pri_bill_type); | ||||
} | } | ||||
/** 编制单位 */ | |||||
/** | |||||
* 编制单位 | |||||
*/ | |||||
public long getPartyId() { | public long getPartyId() { | ||||
return getLong("pri_party_id"); | return getLong("pri_party_id"); | ||||
} | } | ||||
/** 编制单位 */ | |||||
/** | |||||
* 编制单位 | |||||
*/ | |||||
public void setPartyId(long pri_party_id) { | public void setPartyId(long pri_party_id) { | ||||
put("pri_party_id", pri_party_id); | put("pri_party_id", pri_party_id); | ||||
} | } | ||||
/** 编制部门 */ | |||||
/** | |||||
* 编制部门 | |||||
*/ | |||||
public long getDeptId() { | public long getDeptId() { | ||||
return getLong("pri_dept_id"); | return getLong("pri_dept_id"); | ||||
} | } | ||||
/** 编制部门 */ | |||||
/** | |||||
* 编制部门 | |||||
*/ | |||||
public void setDeptId(long pri_dept_id) { | public void setDeptId(long pri_dept_id) { | ||||
put("pri_dept_id", pri_dept_id); | put("pri_dept_id", pri_dept_id); | ||||
} | } | ||||
/** 摘要 */ | |||||
/** | |||||
* 摘要 | |||||
*/ | |||||
public String getBillDesc() { | public String getBillDesc() { | ||||
return getStr("pri_bill_desc"); | return getStr("pri_bill_desc"); | ||||
} | } | ||||
/** 摘要 */ | |||||
/** | |||||
* 摘要 | |||||
*/ | |||||
public void setBillDesc(String pri_bill_desc) { | public void setBillDesc(String pri_bill_desc) { | ||||
put("pri_bill_desc", pri_bill_desc); | put("pri_bill_desc", pri_bill_desc); | ||||
} | } | ||||
/** 流程定义 */ | |||||
/** | |||||
* 流程定义 | |||||
*/ | |||||
public long getPrcId() { | public long getPrcId() { | ||||
return getLong("pri_prc_id"); | return getLong("pri_prc_id"); | ||||
} | } | ||||
/** 流程定义 */ | |||||
/** | |||||
* 流程定义 | |||||
*/ | |||||
public void setPrcId(long pri_prc_id) { | public void setPrcId(long pri_prc_id) { | ||||
put("pri_prc_id", pri_prc_id); | put("pri_prc_id", pri_prc_id); | ||||
} | } | ||||
/** 开始时间 */ | |||||
/** | |||||
* 开始时间 | |||||
*/ | |||||
public long getStartTime() { | public long getStartTime() { | ||||
return getLong("pri_start_time"); | return getLong("pri_start_time"); | ||||
} | } | ||||
/** 开始时间 */ | |||||
/** | |||||
* 开始时间 | |||||
*/ | |||||
public void setStartTime(long pri_start_time) { | public void setStartTime(long pri_start_time) { | ||||
put("pri_start_time", pri_start_time); | put("pri_start_time", pri_start_time); | ||||
} | } | ||||
/** 结束时间 */ | |||||
/** | |||||
* 结束时间 | |||||
*/ | |||||
public long getEndTime() { | public long getEndTime() { | ||||
return getLong("pri_end_time"); | return getLong("pri_end_time"); | ||||
} | } | ||||
/** 结束时间 */ | |||||
/** | |||||
* 结束时间 | |||||
*/ | |||||
public void setEndTime(long pri_end_time) { | public void setEndTime(long pri_end_time) { | ||||
put("pri_end_time", pri_end_time); | put("pri_end_time", pri_end_time); | ||||
} | } | ||||
/** 最后操作用户 */ | |||||
/** | |||||
* 最后操作用户 | |||||
*/ | |||||
public long getUserId() { | public long getUserId() { | ||||
return getLong("pri_user_id"); | return getLong("pri_user_id"); | ||||
} | } | ||||
/** 最后操作用户 */ | |||||
/** | |||||
* 最后操作用户 | |||||
*/ | |||||
public void setUserId(long pri_user_id) { | public void setUserId(long pri_user_id) { | ||||
put("pri_user_id", pri_user_id); | put("pri_user_id", pri_user_id); | ||||
} | } | ||||
/** 当前任务 */ | |||||
/** | |||||
* 当前任务 | |||||
*/ | |||||
public long getTaskId() { | public long getTaskId() { | ||||
return getLong("pri_task_id"); | return getLong("pri_task_id"); | ||||
} | } | ||||
/** 当前任务 */ | |||||
/** | |||||
* 当前任务 | |||||
*/ | |||||
public void setTaskId(long pri_task_id) { | public void setTaskId(long pri_task_id) { | ||||
put("pri_task_id", pri_task_id); | put("pri_task_id", pri_task_id); | ||||
} | } | ||||
@@ -132,30 +191,44 @@ public class ProcInst extends DefaultEntity { | |||||
put("pri_act_name", priActName); | put("pri_act_name", priActName); | ||||
} | } | ||||
/** 单据状态 */ | |||||
/** | |||||
* 单据状态 | |||||
*/ | |||||
public int getStatu() { | public int getStatu() { | ||||
return getInt("pri_statu"); | return getInt("pri_statu"); | ||||
} | } | ||||
/** 单据状态 */ | |||||
/** | |||||
* 单据状态 | |||||
*/ | |||||
public void setStatu(int pri_statu) { | public void setStatu(int pri_statu) { | ||||
put("pri_statu", pri_statu); | put("pri_statu", pri_statu); | ||||
} | } | ||||
/** 单据描述 */ | |||||
/** | |||||
* 单据描述 | |||||
*/ | |||||
public String getBillInfo() { | public String getBillInfo() { | ||||
return getStr("pri_bill_info"); | return getStr("pri_bill_info"); | ||||
} | } | ||||
/** 单据描述 */ | |||||
/** | |||||
* 单据描述 | |||||
*/ | |||||
public void setBillInfo(String pri_bill_info) { | public void setBillInfo(String pri_bill_info) { | ||||
put("pri_bill_info", pri_bill_info); | put("pri_bill_info", pri_bill_info); | ||||
} | } | ||||
/** 单据链接 */ | |||||
/** | |||||
* 单据链接 | |||||
*/ | |||||
public String getUrl() { | public String getUrl() { | ||||
return getStr("pri_url"); | return getStr("pri_url"); | ||||
} | } | ||||
/** 单据链接 */ | |||||
/** | |||||
* 单据链接 | |||||
*/ | |||||
public void setUrl(String pri_url) { | public void setUrl(String pri_url) { | ||||
put("pri_url", pri_url); | put("pri_url", pri_url); | ||||
} | } | ||||
@@ -15,183 +15,282 @@ public class Task extends DefaultEntity { | |||||
super(ENTITY_NAME); | super(ENTITY_NAME); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public long getId() { | public long getId() { | ||||
return getLong("tsk_id"); | return getLong("tsk_id"); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public void setId(long tsk_id) { | public void setId(long tsk_id) { | ||||
put("tsk_id", tsk_id); | put("tsk_id", tsk_id); | ||||
} | } | ||||
/** 流程实例id */ | |||||
/** | |||||
* 流程实例id | |||||
*/ | |||||
public long getPriId() { | public long getPriId() { | ||||
return getLong("tsk_pri_id"); | return getLong("tsk_pri_id"); | ||||
} | } | ||||
/** 流程实例id */ | |||||
/** | |||||
* 流程实例id | |||||
*/ | |||||
public void setPriId(long tsk_pri_id) { | public void setPriId(long tsk_pri_id) { | ||||
put("tsk_pri_id", tsk_pri_id); | put("tsk_pri_id", tsk_pri_id); | ||||
} | } | ||||
/** 流程定义id */ | |||||
/** | |||||
* 流程定义id | |||||
*/ | |||||
public long getPrcId() { | public long getPrcId() { | ||||
return getLong("tsk_prc_id"); | return getLong("tsk_prc_id"); | ||||
} | } | ||||
/** 流程定义id */ | |||||
/** | |||||
* 流程定义id | |||||
*/ | |||||
public void setPrcId(long tsk_prc_id) { | public void setPrcId(long tsk_prc_id) { | ||||
put("tsk_prc_id", tsk_prc_id); | put("tsk_prc_id", tsk_prc_id); | ||||
} | } | ||||
/** 活动定义id */ | |||||
/** | |||||
* 活动定义id | |||||
*/ | |||||
public String getActId() { | public String getActId() { | ||||
return getStr("tsk_act_id"); | return getStr("tsk_act_id"); | ||||
} | } | ||||
/** 活动定义id */ | |||||
/** | |||||
* 活动定义id | |||||
*/ | |||||
public void setActId(String tsk_act_id) { | public void setActId(String tsk_act_id) { | ||||
put("tsk_act_id", tsk_act_id); | put("tsk_act_id", tsk_act_id); | ||||
} | } | ||||
/** 活动名称 */ | |||||
/** | |||||
* 活动名称 | |||||
*/ | |||||
public String getActName() { | public String getActName() { | ||||
return getStr("tsk_act_name"); | return getStr("tsk_act_name"); | ||||
} | } | ||||
/** 活动名称 */ | |||||
/** | |||||
* 活动名称 | |||||
*/ | |||||
public void setActName(String tsk_act_name) { | public void setActName(String tsk_act_name) { | ||||
put("tsk_act_name", tsk_act_name); | put("tsk_act_name", tsk_act_name); | ||||
} | } | ||||
/** 主办人 */ | |||||
/** | |||||
* 主办人 | |||||
*/ | |||||
public long getHandler() { | public long getHandler() { | ||||
return getLong("tsk_handler"); | return getLong("tsk_handler"); | ||||
} | } | ||||
/** 主办人 */ | |||||
/** | |||||
* 主办人 | |||||
*/ | |||||
public void setHandler(long tsk_handler) { | public void setHandler(long tsk_handler) { | ||||
put("tsk_handler", tsk_handler); | put("tsk_handler", tsk_handler); | ||||
} | } | ||||
/** 开始时间 */ | |||||
/** | |||||
* 开始时间 | |||||
*/ | |||||
public long getStartTime() { | public long getStartTime() { | ||||
return getLong("tsk_start_time"); | return getLong("tsk_start_time"); | ||||
} | } | ||||
/** 开始时间 */ | |||||
/** | |||||
* 开始时间 | |||||
*/ | |||||
public void setStartTime(long tsk_start_time) { | public void setStartTime(long tsk_start_time) { | ||||
put("tsk_start_time", tsk_start_time); | put("tsk_start_time", tsk_start_time); | ||||
} | } | ||||
/** 签收时间 */ | |||||
/** | |||||
* 签收时间 | |||||
*/ | |||||
public long getHandlerTime() { | public long getHandlerTime() { | ||||
return getLong("tsk_handler_time"); | return getLong("tsk_handler_time"); | ||||
} | } | ||||
/** 签收时间 */ | |||||
/** | |||||
* 签收时间 | |||||
*/ | |||||
public void setHandlerTime(long tsk_handler_time) { | public void setHandlerTime(long tsk_handler_time) { | ||||
put("tsk_handler_time", tsk_handler_time); | put("tsk_handler_time", tsk_handler_time); | ||||
} | } | ||||
/** 结束时间 */ | |||||
/** | |||||
* 结束时间 | |||||
*/ | |||||
public long getEndTime() { | public long getEndTime() { | ||||
return getLong("tsk_end_time"); | return getLong("tsk_end_time"); | ||||
} | } | ||||
/** 结束时间 */ | |||||
/** | |||||
* 结束时间 | |||||
*/ | |||||
public void setEndTime(long tsk_end_time) { | public void setEndTime(long tsk_end_time) { | ||||
put("tsk_end_time", tsk_end_time); | put("tsk_end_time", tsk_end_time); | ||||
} | } | ||||
/** 状态 */ | |||||
/** | |||||
* 状态 | |||||
*/ | |||||
public int getStatu() { | public int getStatu() { | ||||
return getInt("tsk_statu"); | return getInt("tsk_statu"); | ||||
} | } | ||||
/** 状态 */ | |||||
/** | |||||
* 状态 | |||||
*/ | |||||
public void setStatu(int tsk_statu) { | public void setStatu(int tsk_statu) { | ||||
put("tsk_statu", tsk_statu); | put("tsk_statu", tsk_statu); | ||||
} | } | ||||
/** 审批意见 */ | |||||
/** | |||||
* 审批意见 | |||||
*/ | |||||
public String getComment() { | public String getComment() { | ||||
return getStr("tsk_comment"); | return getStr("tsk_comment"); | ||||
} | } | ||||
/** 审批意见 */ | |||||
/** | |||||
* 审批意见 | |||||
*/ | |||||
public void setComment(String tsk_comment) { | public void setComment(String tsk_comment) { | ||||
put("tsk_comment", tsk_comment); | put("tsk_comment", tsk_comment); | ||||
} | } | ||||
/** 是否制单步骤 */ | |||||
/** | |||||
* 是否制单步骤 | |||||
*/ | |||||
public boolean isMake() { | public boolean isMake() { | ||||
return getBool("tsk_is_make"); | return getBool("tsk_is_make"); | ||||
} | } | ||||
/** 是否制单步骤 */ | |||||
/** | |||||
* 是否制单步骤 | |||||
*/ | |||||
public void setMake(boolean tsk_is_make) { | public void setMake(boolean tsk_is_make) { | ||||
setBool("tsk_is_make", tsk_is_make); | setBool("tsk_is_make", tsk_is_make); | ||||
} | } | ||||
/** 是否需要会签 */ | |||||
/** | |||||
* 是否需要会签 | |||||
*/ | |||||
public boolean isSign() { | public boolean isSign() { | ||||
return getBool("tsk_is_sign"); | return getBool("tsk_is_sign"); | ||||
} | } | ||||
/** 是否需要会签 */ | |||||
/** | |||||
* 是否需要会签 | |||||
*/ | |||||
public void setSign(boolean tsk_is_sign) { | public void setSign(boolean tsk_is_sign) { | ||||
setBool("tsk_is_sign", tsk_is_sign); | setBool("tsk_is_sign", tsk_is_sign); | ||||
} | } | ||||
/** 会签人数 */ | |||||
/** | |||||
* 会签人数 | |||||
*/ | |||||
public int getSignTotal() { | public int getSignTotal() { | ||||
return getInt("tsk_sign_total"); | return getInt("tsk_sign_total"); | ||||
} | } | ||||
/** 会签人数 */ | |||||
/** | |||||
* 会签人数 | |||||
*/ | |||||
public void setSignTotal(int tsk_sign_total) { | public void setSignTotal(int tsk_sign_total) { | ||||
put("tsk_sign_total", tsk_sign_total); | put("tsk_sign_total", tsk_sign_total); | ||||
} | } | ||||
/** 设置会签过关人数 */ | |||||
/** | |||||
* 设置会签过关人数 | |||||
*/ | |||||
public int getSignPass() { | public int getSignPass() { | ||||
return getInt("tsk_sign_pass"); | return getInt("tsk_sign_pass"); | ||||
} | } | ||||
/** 设置会签过关人数 */ | |||||
/** | |||||
* 设置会签过关人数 | |||||
*/ | |||||
public void setSignPass(int tsk_sign_pass) { | public void setSignPass(int tsk_sign_pass) { | ||||
put("tsk_sign_pass", tsk_sign_pass); | put("tsk_sign_pass", tsk_sign_pass); | ||||
} | } | ||||
/** 会签同意人数 */ | |||||
/** | |||||
* 会签同意人数 | |||||
*/ | |||||
public int getSignAgree() { | public int getSignAgree() { | ||||
return getInt("tsk_sign_agree"); | return getInt("tsk_sign_agree"); | ||||
} | } | ||||
/** 会签同意人数 */ | |||||
/** | |||||
* 会签同意人数 | |||||
*/ | |||||
public void setSignAgree(int tsk_sign_agree) { | public void setSignAgree(int tsk_sign_agree) { | ||||
put("tsk_sign_agree", tsk_sign_agree); | put("tsk_sign_agree", tsk_sign_agree); | ||||
} | } | ||||
/** 是否被驳回 */ | |||||
/** | |||||
* 是否被驳回 | |||||
*/ | |||||
public boolean isReject() { | public boolean isReject() { | ||||
return getBool("tsk_is_reject"); | return getBool("tsk_is_reject"); | ||||
} | } | ||||
/** 是否被驳回 */ | |||||
/** | |||||
* 是否被驳回 | |||||
*/ | |||||
public void setReject(boolean tsk_is_reject) { | public void setReject(boolean tsk_is_reject) { | ||||
setBool("tsk_is_reject", tsk_is_reject); | setBool("tsk_is_reject", tsk_is_reject); | ||||
} | } | ||||
/** 是否取回 */ | |||||
/** | |||||
* 是否取回 | |||||
*/ | |||||
public boolean isRetake() { | public boolean isRetake() { | ||||
return getBool("tsk_is_retake"); | return getBool("tsk_is_retake"); | ||||
} | } | ||||
/** 是否取回 */ | |||||
/** | |||||
* 是否取回 | |||||
*/ | |||||
public void setRetake(boolean tsk_is_retake) { | public void setRetake(boolean tsk_is_retake) { | ||||
setBool("tsk_is_retake", tsk_is_retake); | setBool("tsk_is_retake", tsk_is_retake); | ||||
} | } | ||||
/** 是否自动任务 */ | |||||
/** | |||||
* 是否自动任务 | |||||
*/ | |||||
public boolean isAuto() { | public boolean isAuto() { | ||||
return getBool("tsk_is_auto"); | return getBool("tsk_is_auto"); | ||||
} | } | ||||
/** 是否自动任务 */ | |||||
/** | |||||
* 是否自动任务 | |||||
*/ | |||||
public void setAuto(boolean tsk_is_auto) { | public void setAuto(boolean tsk_is_auto) { | ||||
setBool("tsk_is_auto", tsk_is_auto); | setBool("tsk_is_auto", tsk_is_auto); | ||||
} | } | ||||
/** 备注 */ | |||||
/** | |||||
* 备注 | |||||
*/ | |||||
public String getRemark() { | public String getRemark() { | ||||
return getStr("tsk_remark"); | return getStr("tsk_remark"); | ||||
} | } | ||||
/** 备注 */ | |||||
/** | |||||
* 备注 | |||||
*/ | |||||
public void setRemark(String tsk_remark) { | public void setRemark(String tsk_remark) { | ||||
put("tsk_remark", tsk_remark); | put("tsk_remark", tsk_remark); | ||||
} | } | ||||
@@ -15,39 +15,58 @@ public class TaskRel extends DefaultEntity { | |||||
super(ENTITY_NAME); | super(ENTITY_NAME); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public long getId() { | public long getId() { | ||||
return getLong("trl_id"); | return getLong("trl_id"); | ||||
} | } | ||||
/** 主键 */ | |||||
/** | |||||
* 主键 | |||||
*/ | |||||
public void setId(long trl_id) { | public void setId(long trl_id) { | ||||
put("trl_id", trl_id); | put("trl_id", trl_id); | ||||
} | } | ||||
/** 流程实例id */ | |||||
/** | |||||
* 流程实例id | |||||
*/ | |||||
public long getPriId() { | public long getPriId() { | ||||
return getLong("trl_pri_id"); | return getLong("trl_pri_id"); | ||||
} | } | ||||
/** 流程实例id */ | |||||
/** | |||||
* 流程实例id | |||||
*/ | |||||
public void setPriId(long trl_pri_id) { | public void setPriId(long trl_pri_id) { | ||||
put("trl_pri_id", trl_pri_id); | put("trl_pri_id", trl_pri_id); | ||||
} | } | ||||
/** 前任务id */ | |||||
/** | |||||
* 前任务id | |||||
*/ | |||||
public long getSrcTaskId() { | public long getSrcTaskId() { | ||||
return getLong("trl_src_task_id"); | return getLong("trl_src_task_id"); | ||||
} | } | ||||
/** 前任务id */ | |||||
/** | |||||
* 前任务id | |||||
*/ | |||||
public void setSrcTaskId(long trl_src_task_id) { | public void setSrcTaskId(long trl_src_task_id) { | ||||
put("trl_src_task_id", trl_src_task_id); | put("trl_src_task_id", trl_src_task_id); | ||||
} | } | ||||
/** 目标任务id */ | |||||
/** | |||||
* 目标任务id | |||||
*/ | |||||
public long getDstTaskId() { | public long getDstTaskId() { | ||||
return getLong("trl_dst_task_id"); | return getLong("trl_dst_task_id"); | ||||
} | } | ||||
/** 目标任务id */ | |||||
/** | |||||
* 目标任务id | |||||
*/ | |||||
public void setDstTaskId(long trl_dst_task_id) { | public void setDstTaskId(long trl_dst_task_id) { | ||||
put("trl_dst_task_id", trl_dst_task_id); | put("trl_dst_task_id", trl_dst_task_id); | ||||
} | } |
@@ -11,12 +11,13 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleDelHandler; | |||||
*/ | */ | ||||
public class FlowDelHandler extends LCSingleDelHandler implements FlowListener { | public class FlowDelHandler extends LCSingleDelHandler implements FlowListener { | ||||
protected FlowInstance flowInstance; | protected FlowInstance flowInstance; | ||||
@Override | @Override | ||||
protected void localDel(long id, ModelTable table) { | protected void localDel(long id, ModelTable table) { | ||||
long taskId = params.readLong("taskId"); | long taskId = params.readLong("taskId"); | ||||
flowInstance = FlowInstance.createById(us, this, id, taskId); | flowInstance = FlowInstance.createById(us, this, id, taskId); | ||||
flowInstance.delete(); | flowInstance.delete(); | ||||
super.localDel(id, table); | super.localDel(id, table); | ||||
} | } | ||||
} | } |
@@ -14,7 +14,7 @@ import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst; | |||||
* Created by Akmm at 2022-08-29 11:41 | * Created by Akmm at 2022-08-29 11:41 | ||||
*/ | */ | ||||
public class FlowListHandler extends DynPageListHandler { | public class FlowListHandler extends DynPageListHandler { | ||||
static IBuildSqlListener sqlListener = new IBuildSqlListener(){ | |||||
static IBuildSqlListener sqlListener = new IBuildSqlListener() { | |||||
@Override | @Override | ||||
public void buildSelect(PageDataset dataSet, StringBuilder sql) { | public void buildSelect(PageDataset dataSet, StringBuilder sql) { | ||||
sql.append("\ninner join " + EntityHelper.getSchemaTableName(ProcInst.ENTITY_NAME) + " on pri_id=" + dataSet._getModelTable().getIdField()); | sql.append("\ninner join " + EntityHelper.getSchemaTableName(ProcInst.ENTITY_NAME) + " on pri_id=" + dataSet._getModelTable().getIdField()); | ||||
@@ -1,27 +1,18 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single; | package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single; | ||||
import cc.smtweb.framework.core.common.R; | 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.common.SwMap; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | 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.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.design.form.define.PageDataset; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; | 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.dynPage.DynRetBean; | ||||
import cc.smtweb.system.bpm.web.engine.flow.FlowHelper; | 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.FlowInstance; | ||||
import cc.smtweb.system.bpm.web.engine.flow.FlowListener; | 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.LCSingleHelper; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleLoadHandler; | import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleLoadHandler; | ||||
import java.util.ArrayList; | |||||
/** | /** | ||||
* Created by Akmm at 2022-08-26 17:15 | * Created by Akmm at 2022-08-26 17:15 | ||||
* 流程加载 | * 流程加载 | ||||
@@ -32,7 +23,7 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad | |||||
@Override | @Override | ||||
protected void afterAdd(SwMap ret, T bean) { | protected void afterAdd(SwMap ret, T bean) { | ||||
flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); | flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); | ||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | ||||
bean.setEntityId(flowInstance.getProcInst().getId()); | bean.setEntityId(flowInstance.getProcInst().getId()); | ||||
@@ -54,7 +45,7 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad | |||||
ret.put(cardDataset.name, DynRetBean.createBean(bean)); | 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_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ||||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0))); | ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0))); | ||||
@@ -1,6 +1,5 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single; | 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.common.SwMap; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
@@ -35,7 +34,7 @@ public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSave | |||||
if (bean.isNew()) { | if (bean.isNew()) { | ||||
flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); | flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); | ||||
} else { | } else { | ||||
flowInstance = FlowInstance.createById(us,this, id, taskId); | |||||
flowInstance = FlowInstance.createById(us, this, id, taskId); | |||||
} | } | ||||
flowInstance.readFromPage(data); | flowInstance.readFromPage(data); | ||||
flowInstance.getProcInst().setIsNew(bean.isNew()); | flowInstance.getProcInst().setIsNew(bean.isNew()); | ||||
@@ -4,7 +4,6 @@ import cc.smtweb.framework.core.annotation.SwBody; | |||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwMap; | 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.AbstractHandler; | ||||
import cc.smtweb.framework.core.mvc.service.IWorker; | import cc.smtweb.framework.core.mvc.service.IWorker; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
@@ -20,6 +19,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; | |||||
@SwService | @SwService | ||||
public class FlowSingleService extends LCSingleService { | public class FlowSingleService extends LCSingleService { | ||||
public static final String TYPE_FLOW = "flow"; | public static final String TYPE_FLOW = "flow"; | ||||
@Override | @Override | ||||
protected AbstractHandler createHandler(String type) { | protected AbstractHandler createHandler(String type) { | ||||
if (TYPE_FLOW.equals(type)) return new FlowTransHandler(); | 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) { | protected R flowHandler(SwMap params, UserSession us, IWorker<FlowTransHandler> worker) { | ||||
try { | try { | ||||
FlowTransHandler handler = (FlowTransHandler)getHandler(params, us, TYPE_FLOW); | |||||
FlowTransHandler handler = (FlowTransHandler) getHandler(params, us, TYPE_FLOW); | |||||
return worker.doWork(handler); | return worker.doWork(handler); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
return R.error("操作失败!", e); | return R.error("操作失败!", e); | ||||
} | } | ||||
} | } | ||||
public R submit(@SwBody SwMap params, UserSession us) { | public R submit(@SwBody SwMap params, UserSession us) { | ||||
return flowHandler(params, us, FlowTransHandler::submit); | return flowHandler(params, us, FlowTransHandler::submit); | ||||
} | } | ||||
@@ -17,7 +17,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | |||||
* Created by Akmm at 2022-09-01 15:03 | * 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 | //流程id | ||||
protected long billId; | protected long billId; | ||||
//任务id | //任务id | ||||
@@ -27,7 +27,7 @@ public abstract class AbsDelHandler extends AbstractDynPageHandler { | |||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + 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); | checkBean(pageDataset, id); | ||||
// | // | ||||
@@ -18,6 +18,7 @@ public abstract class AbsLoadHandler extends AbstractDynPageHandler { | |||||
/** | /** | ||||
* 新增初始化 | * 新增初始化 | ||||
* | |||||
* @param dsName | * @param dsName | ||||
* @return | * @return | ||||
*/ | */ | ||||
@@ -36,19 +37,21 @@ public abstract class AbsLoadHandler extends AbstractDynPageHandler { | |||||
/** | /** | ||||
* 加载卡片数据 | * 加载卡片数据 | ||||
* | |||||
* @param dsName | * @param dsName | ||||
* @return | * @return | ||||
*/ | */ | ||||
protected SwMap doLoadCard(String dsName){ | |||||
protected SwMap doLoadCard(String dsName) { | |||||
//过滤条件 | //过滤条件 | ||||
SwMap filter = params.readMap("filter"); | 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 provider.loadData(filter, loadDataSet); | ||||
} | } | ||||
/** | /** | ||||
* 列表数据 | * 列表数据 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
protected DynRetBean doList(String dsName) { | protected DynRetBean doList(String dsName) { | ||||
@@ -56,7 +59,7 @@ public abstract class AbsLoadHandler extends AbstractDynPageHandler { | |||||
SwMap filter = params.readMap("filter"); | 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()); | return DynRetBean.createList(getListWorker(filter, listDataSet).buildListData()); | ||||
} | } | ||||
@@ -71,7 +74,7 @@ public abstract class AbsLoadHandler extends AbstractDynPageHandler { | |||||
SwMap filter = params.readMap("filter"); | SwMap filter = params.readMap("filter"); | ||||
//对应的数据集定义 | //对应的数据集定义 | ||||
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); | |||||
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName); | |||||
return getListWorker(filter, listDataSet).getTotal(); | return getListWorker(filter, listDataSet).getTotal(); | ||||
} | } | ||||
@@ -29,7 +29,7 @@ import java.util.Map; | |||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/9/2 15:02 | * @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<>(); | private Map<String, List<T>> mapTreeBean = new HashMap<>(); | ||||
protected void setNewId(T bean) { | protected void setNewId(T bean) { | ||||
@@ -43,7 +43,7 @@ public abstract class AbsSaveHandler <T extends DefaultEntity> extends AbstractD | |||||
SwMap data = params.readMap("data"); | SwMap data = params.readMap("data"); | ||||
if (data == null) throw new BizException("没有收到待保存的的数据:" + dsName + "!"); | if (data == null) throw new BizException("没有收到待保存的的数据:" + dsName + "!"); | ||||
//对应的数据集定义 | //对应的数据集定义 | ||||
PageDataset pageDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); | |||||
PageDataset pageDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName); | |||||
//读取待保存的bean | //读取待保存的bean | ||||
T bean = readBeanFromPage(pageDataSet, data.readMap(dsName).readMap("form")); | T bean = readBeanFromPage(pageDataSet, data.readMap(dsName).readMap("form")); | ||||
if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 | if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 | ||||
@@ -11,36 +11,40 @@ public class LCLC1DelHandler extends AbsDelHandler { | |||||
/** | /** | ||||
* 左列表删除 | * 左列表删除 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lLDel(){ | |||||
public R lLDel() { | |||||
doDel(LCLC1Define.dsLList); | doDel(LCLC1Define.dsLList); | ||||
return R.success(); | return R.success(); | ||||
} | } | ||||
/** | /** | ||||
* 左卡片删除 | * 左卡片删除 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lCDel(){ | |||||
public R lCDel() { | |||||
doDel(LCLC1Define.dsLCard); | doDel(LCLC1Define.dsLCard); | ||||
return R.success(); | return R.success(); | ||||
} | } | ||||
/** | /** | ||||
* 右列表删除 | * 右列表删除 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rLDel(){ | |||||
public R rLDel() { | |||||
doDel(LCLC1Define.dsRList); | doDel(LCLC1Define.dsRList); | ||||
return R.success(); | return R.success(); | ||||
} | } | ||||
/** | /** | ||||
* 右卡片删除 | * 右卡片删除 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rCDel(){ | |||||
public R rCDel() { | |||||
doDel(LCLC1Define.dsRCard); | doDel(LCLC1Define.dsRCard); | ||||
return R.success(); | return R.success(); | ||||
} | } | ||||
@@ -13,6 +13,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | |||||
public class LCLC1LoadHandler extends AbsLoadHandler { | public class LCLC1LoadHandler extends AbsLoadHandler { | ||||
/** | /** | ||||
* 左表新增 | * 左表新增 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lAdd() { | public R lAdd() { | ||||
@@ -22,6 +23,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler { | |||||
/** | /** | ||||
* 右表新增 | * 右表新增 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rAdd() { | public R rAdd() { | ||||
@@ -31,6 +33,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler { | |||||
/** | /** | ||||
* 左表编辑 | * 左表编辑 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lLoad() { | public R lLoad() { | ||||
@@ -40,6 +43,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler { | |||||
/** | /** | ||||
* 右表编辑 | * 右表编辑 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rLoad() { | public R rLoad() { | ||||
@@ -49,35 +53,39 @@ public class LCLC1LoadHandler extends AbsLoadHandler { | |||||
/** | /** | ||||
* 左列表加载 | * 左列表加载 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lList(){ | |||||
public R lList() { | |||||
DynRetBean list = doList(LCLC1Define.dsLList); | DynRetBean list = doList(LCLC1Define.dsLList); | ||||
return R.success(list); | return R.success(list); | ||||
} | } | ||||
/** | /** | ||||
* 右列表加载 | * 右列表加载 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rList(){ | |||||
public R rList() { | |||||
DynRetBean list = doList(LCLC1Define.dsRList); | DynRetBean list = doList(LCLC1Define.dsRList); | ||||
return R.success(list); | return R.success(list); | ||||
} | } | ||||
/** | /** | ||||
* 左列表分页数据 | * 左列表分页数据 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R getLTotal(){ | |||||
public R getLTotal() { | |||||
return doTotal(LCLC1Define.dsLList); | return doTotal(LCLC1Define.dsLList); | ||||
} | } | ||||
/** | /** | ||||
* 右列表分页数据 | * 右列表分页数据 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R getRTotal(){ | |||||
public R getRTotal() { | |||||
return doTotal(LCLC1Define.dsRList); | return doTotal(LCLC1Define.dsRList); | ||||
} | } | ||||
} | } |
@@ -12,6 +12,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | |||||
public class LCLC1SaveHandler extends AbsSaveHandler { | public class LCLC1SaveHandler extends AbsSaveHandler { | ||||
/** | /** | ||||
* 左表保存 | * 左表保存 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lSave() { | public R lSave() { | ||||
@@ -21,6 +22,7 @@ public class LCLC1SaveHandler extends AbsSaveHandler { | |||||
/** | /** | ||||
* 右表保存 | * 右表保存 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rSave() { | public R rSave() { | ||||
@@ -19,6 +19,7 @@ public class LCLC1Service extends DynPageService { | |||||
protected final static String TYPE_MODEL_LOAD = "modelLoad"; | protected final static String TYPE_MODEL_LOAD = "modelLoad"; | ||||
protected final static String TYPE_MODEL_SAVE = "modelSave"; | protected final static String TYPE_MODEL_SAVE = "modelSave"; | ||||
protected final static String TYPE_MODEL_DEL = "modelDel"; | protected final static String TYPE_MODEL_DEL = "modelDel"; | ||||
// | // | ||||
@Override | @Override | ||||
protected AbstractHandler createHandler(String type) { | protected AbstractHandler createHandler(String type) { | ||||
@@ -37,73 +38,73 @@ public class LCLC1Service extends DynPageService { | |||||
//保存 | //保存 | ||||
public R modelLSave(@SwBody SwMap params, UserSession us) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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()); | |||||
} | } | ||||
} | } |
@@ -25,17 +25,19 @@ public class LCMsDelHandler extends AbsDelHandler { | |||||
/** | /** | ||||
* 列表删除 | * 列表删除 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lDel(){ | |||||
public R lDel() { | |||||
return del(); | return del(); | ||||
} | } | ||||
/** | /** | ||||
* 卡片删除 | * 卡片删除 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R cDel(){ | |||||
public R cDel() { | |||||
return del(); | return del(); | ||||
} | } | ||||
@@ -49,13 +51,13 @@ public class LCMsDelHandler extends AbsDelHandler { | |||||
if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | ||||
SwMap props = form.getOpts().readMap("config").readMap("props"); | 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(); | DbEngine engine = DbEngine.getInstance(); | ||||
@@ -88,7 +90,7 @@ public class LCMsDelHandler extends AbsDelHandler { | |||||
return R.success(); | 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())); | |||||
} | } | ||||
} | } |
@@ -13,6 +13,7 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | |||||
public class LCMsLoadHandler extends AbsLoadHandler { | public class LCMsLoadHandler extends AbsLoadHandler { | ||||
/** | /** | ||||
* 主表新增 | * 主表新增 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R mAdd() { | public R mAdd() { | ||||
@@ -22,6 +23,7 @@ public class LCMsLoadHandler extends AbsLoadHandler { | |||||
/** | /** | ||||
* 主表编辑 | * 主表编辑 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R mLoad() { | public R mLoad() { | ||||
@@ -31,35 +33,39 @@ public class LCMsLoadHandler extends AbsLoadHandler { | |||||
/** | /** | ||||
* 主表列表加载 | * 主表列表加载 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R mList(){ | |||||
public R mList() { | |||||
DynRetBean list = doList(LCMsDefine.dsMList); | DynRetBean list = doList(LCMsDefine.dsMList); | ||||
return R.success(list); | return R.success(list); | ||||
} | } | ||||
/** | /** | ||||
* 子列表加载 | * 子列表加载 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R sList(){ | |||||
public R sList() { | |||||
DynRetBean list = doList(LCMsDefine.dsSList); | DynRetBean list = doList(LCMsDefine.dsSList); | ||||
return R.success(list); | return R.success(list); | ||||
} | } | ||||
/** | /** | ||||
* 主列表分页数据 | * 主列表分页数据 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R getMTotal(){ | |||||
public R getMTotal() { | |||||
return doTotal(LCMsDefine.dsMList); | return doTotal(LCMsDefine.dsMList); | ||||
} | } | ||||
/** | /** | ||||
* 子列表分页数据 | * 子列表分页数据 | ||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R getSTotal(){ | |||||
public R getSTotal() { | |||||
return doTotal(LCMsDefine.dsSList); | return doTotal(LCMsDefine.dsSList); | ||||
} | } | ||||
} | } |
@@ -38,8 +38,8 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> { | |||||
if (data == null) throw new BizException("没有收到待保存的的数据:" + LCMsDefine.dsMCard + "!"); | 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 | //读取待保存的bean | ||||
DefaultEntity masterBean = readBeanFromPage(masterDataSet, data.readMap(LCMsDefine.dsMCard).readMap("form")); | 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"); | SwMap details = params.readMap("details"); | ||||
Assert.notNull(details,"没有收到待保存的明细数据"); | |||||
Assert.notNull(details, "没有收到待保存的明细数据"); | |||||
// | // | ||||
ArrayList<DefaultEntity> inserted = new ArrayList<>(); | ArrayList<DefaultEntity> inserted = new ArrayList<>(); | ||||
ArrayList<DefaultEntity> updated = new ArrayList<>(); | ArrayList<DefaultEntity> updated = new ArrayList<>(); | ||||
@@ -57,7 +57,7 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> { | |||||
SwMap rowData = new SwMap(); | SwMap rowData = new SwMap(); | ||||
rowData.putAll(row); | rowData.putAll(row); | ||||
DefaultEntity insertBean = readBeanFromPage(subDataSet, rowData); | DefaultEntity insertBean = readBeanFromPage(subDataSet, rowData); | ||||
insertBean.put(subForeignKey,masterBean.getEntityId()); | |||||
insertBean.put(subForeignKey, masterBean.getEntityId()); | |||||
inserted.add(insertBean); | inserted.add(insertBean); | ||||
}); | }); | ||||
details.readListMap("updated").forEach(row -> { | details.readListMap("updated").forEach(row -> { | ||||
@@ -76,12 +76,12 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> { | |||||
public void work() { | public void work() { | ||||
saveBean(masterBean); | saveBean(masterBean); | ||||
ModelTable subTable = ModelTableCache.getInstance().get(subDataSet.masterTable); | ModelTable subTable = ModelTableCache.getInstance().get(subDataSet.masterTable); | ||||
Assert.notNull(subTable,"未获取到子表"); | |||||
Assert.notNull(subTable, "未获取到子表"); | |||||
EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(subTable.getName()); | EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(subTable.getName()); | ||||
dao.batchInsertEntity(inserted); | dao.batchInsertEntity(inserted); | ||||
dao.batchUpdateEntity(updated); | dao.batchUpdateEntity(updated); | ||||
if (deleted != null){ | |||||
if (deleted != null) { | |||||
dao.deleteEntity(deleted); | dao.deleteEntity(deleted); | ||||
} | } | ||||
} | } | ||||
@@ -37,46 +37,46 @@ public class LCMsService extends DynPageService { | |||||
//保存 | //保存 | ||||
public R modelSave(@SwBody SwMap params, UserSession us) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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) { | 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()); | |||||
} | } | ||||
} | } |