diff --git a/modules/core/src/main/resources/templates/modules/gen/cloud/api.xml b/modules/core/src/main/resources/templates/modules/gen/cloud/api.xml new file mode 100644 index 00000000..28eaf603 --- /dev/null +++ b/modules/core/src/main/resources/templates/modules/gen/cloud/api.xml @@ -0,0 +1,28 @@ + + + + controller + ${moduleName}-client/src/main/java/${packageName}/${moduleName}/api/${subModuleName} + ${ClassName}ServiceApi.java + { + +}]]> + + \ No newline at end of file diff --git a/modules/core/src/main/resources/templates/modules/gen/cloud/client.xml b/modules/core/src/main/resources/templates/modules/gen/cloud/client.xml new file mode 100644 index 00000000..233e1187 --- /dev/null +++ b/modules/core/src/main/resources/templates/modules/gen/cloud/client.xml @@ -0,0 +1,29 @@ + + + + controller + ${moduleName}-client/src/main/java/${packageName}/${moduleName}/client/${subModuleName} + ${ClassName}ServiceClient.java + + + \ No newline at end of file diff --git a/modules/core/src/main/resources/templates/modules/gen/cloud/entity.xml b/modules/core/src/main/resources/templates/modules/gen/cloud/entity.xml new file mode 100644 index 00000000..fd97cc1a --- /dev/null +++ b/modules/core/src/main/resources/templates/modules/gen/cloud/entity.xml @@ -0,0 +1,352 @@ + + + + entity + ${moduleName}-client/src/main/java/${packageName}/${moduleName}/entity/${subModuleName} + ${ClassName}.java + +import ${i}; +<% } %> + +import com.jeesite.common.entity.DataEntity; +<% if(table.isTreeEntity){ %> +import com.jeesite.common.entity.TreeEntity; +<% } %> +import com.jeesite.common.mybatis.annotation.Column; +import com.jeesite.common.mybatis.annotation.Table; +import com.jeesite.common.mybatis.mapper.query.QueryType; +<% if(toBoolean(table.optionMap['isBpmForm'])){ %> + <% if(table.isTreeEntity){ %> +import com.jeesite.modules.bpm.entity.BpmTreeEntity; + <% }else{ %> +import com.jeesite.modules.bpm.entity.BpmEntity; + <% } %> +<% } %> + +/** + * ${functionName}Entity + * @author ${functionAuthor} + * @version ${functionVersion} + */ +@Table(name="${table.genTableName}", alias="a", columns={ + <% + var isBase = false, isData = false, + isTree = false, isExtend = false; + // ◆ 生成字段属性 + for(c in table.columnList){ + // ● 如果是BaseEntity类属性 + if(table.isBaseEntity && c.isBaseEntityColumn){ + if(!isBase){ + isBase = true; + %> + @Column(includeEntity=BaseEntity.class), + <% + } + // ● 如果是DataEntity类属性 + }else if(table.isDataEntity && c.isDataEntityColumn){ + if(!isData){ + isData = true; + %> + @Column(includeEntity=DataEntity.class), + <% + } + // ● 如果是TreeEntity类属性 + }else if(table.isTreeEntity && c.isTreeEntityColumn){ + if(!isTree){ + isTree = true; + %> + @Column(includeEntity=TreeEntity.class), + <% + } + // ● 如果是Extend类属性 + }else if(table.isExtendEntity && c.isExtendColumn){ + if(!isExtend){ + isExtend = true; + %> + @Column(includeEntity=Extend.class, attrName="extend"), + <% + } + // ● 其它情况下 + }else{ + // 容错,如果没有设置父表的主键属性,则设置 + if(!@StringUtils.contains(c.attrName, ".")){ + if (table.parentExists && table.parentTableFkName == c.columnName){ + for (pk in table.parent.pkList){ + c.fullAttrName = c.fullAttrName + '.' + pk.attrName; + break; + } + } + } + %> + @Column(name="${c.columnName}", attrName="${c.attrName}", label="${c.columnLabel}"<% + if (c.comments != c.columnLabel){ + print(', comment="'+c.comments+'"'); + } + if (c.isPk == @Global.YES){ + print(', isPK=true'); + }else{ + if (c.isInsert != @Global.YES){ + print(', isInsert=false'); + } + if (c.isUpdate != @Global.YES){ + print(', isUpdate=false'); + } + if (c.isQuery == @Global.YES && @StringUtils.inString(c.queryType, + 'NE', 'GT', 'GTE', 'LT', 'LTE', 'LIKE', 'LEFT_LIKE', 'RIGHT_LIKE')){ + print(', queryType=QueryType.'+c.queryType); + } + if (c.isQuery != @Global.YES){ + print(', isQuery=false'); + } + if (c.attrName == table.treeViewNameAttrName){ + print(', isTreeName=true'); + } + } + %>), + <% + } + } + %> + }, <% + // ◆ 生成关联表 + var joinTables = ''; + for(c in table.columnList){ + if (c.attrType == 'com.jeesite.modules.sys.entity.User'){ + var joinTable = { + %> + @JoinTable(type=Type.LEFT_JOIN, entity=User.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}", + on="u${cLP.index}.user_code = a.${c.columnName}", columns={ + @Column(name="user_code", label="用户编码", isPK=true), + @Column(name="user_name", label="用户名称", isQuery=false), + }), + <% + }; + joinTables = joinTables + joinTable; + } + else if (c.attrType == 'com.jeesite.modules.sys.entity.Office'){ + var joinTable = { + %> + @JoinTable(type=Type.LEFT_JOIN, entity=Office.class, attrName="${c.simpleAttrName}", alias="u${cLP.index}", + on="u${cLP.index}.office_code = a.${c.columnName}", columns={ + @Column(name="office_code", label="机构编码", isPK=true), + @Column(name="office_name", label="机构名称", isQuery=false), + }), + <% + }; + joinTables = joinTables + joinTable; + } + } + if (isNotBlank(joinTables)){ + print('joinTable={'); + print(joinTables); + print('}, '); + } + // ◆ 生成排序字段 + %>orderBy="<% if (isTree){ + %>a.tree_sorts<% + for(pk in table.pkList){ + %>, a.${pk.columnName}<% + } + }else if(table.parentExists && table.createDateExists){ + %>a.create_date ASC<% + }else if(table.updateDateExists){ + %>a.update_date DESC<% + }else{ + for(pk in table.pkList){ + %>${pkLP.index!=1?', ':''}a.${pk.columnName} ${table.parentExists?'ASC':'DESC'}<% + } + } %>" +) +public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(table.isTreeEntity?'BpmTree':'Bpm'):table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> { + + private static final long serialVersionUID = 1L; + <% + isExtend = false; + // 生成字段属性 + for(c in table.columnList){ + // 如果是Extend类属性 + if(table.isExtendEntity && c.isExtendColumn){ + if(!isExtend){ + isExtend = true; + %> + private Extend extend; // 扩展字段 + <% + } + } + // 如果不是基类属性 + else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){ + // 父类对象 + if(table.parentExists && table.parentTableFkName == c.columnName){ + %> + private ${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}; <% if (isNotBlank(c.comments)){ %>// ${c.comments} 父类<% } %> + <% + // 其它字段 + }else{ + %> + private ${c.simpleAttrType} ${c.simpleAttrName}; <%if(isNotBlank(c.comments)){%>// ${c.comments}<%}%> + <% + } + } + } + + // 生成子表列表字段 + for(child in table.childList){ + %> + private List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List = ListUtils.newArrayList(); // 子表列表 + <% + } + + // 生成构造方法 + %> + + public ${ClassName}() { + this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>); + } + + <% + // 生成带主键参数的构造 + if (!table.parentExists){ + if (table.pkList.~size == 1){ %> + public ${ClassName}(String id){ + super(id); + } + <% }else{ %> + public ${ClassName}(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType} ${pk.simpleAttrName}<% } %>){ + <% for(pk in table.pkList){ %> + this.${pk.simpleAttrName} = ${pk.simpleAttrName}; + <% } %> + } + <% + } + } + + // 生成父表参数的构造 + else{ + for(c in table.columnList){ + if(table.parentExists && table.parentTableFkName == c.columnName){ + %> + + public ${ClassName}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}){ + this.${c.simpleAttrName} = ${c.simpleAttrName}; + } + <% + } + } + } + + // 如果是树实体,则输出相应方法 + if (table.isTreeEntity){ + %> + + @Override + public ${ClassName} getParent() { + return parent; + } + + @Override + public void setParent(${ClassName} parent) { + this.parent = parent; + } + <% + } + + // 生成属性的get和set方法 + isExtend = false; + for(c in table.columnList){ + // 如果是Extend类属性 + if(c.isExtendColumn){ + if(!isExtend){ + isExtend = true; + %> + + public Extend getExtend() { + return extend; + } + + public void setExtend(Extend extend) { + this.extend = extend; + } + <% + } + // 如果不是基类属性 + }else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){ + %> + + <% + for(a in c.simpleAnnotationList){ + %> + @${a} + <% + } + // 父类对象 + if(table.parentExists && table.parentTableFkName == c.columnName){ + %> + public ${@StringUtils.cap(table.parent.className)} get${@StringUtils.cap(c.simpleAttrName)}() { + return ${c.simpleAttrName}; + } + + public void set${@StringUtils.cap(c.simpleAttrName)}(${@StringUtils.cap(table.parent.className)} ${c.simpleAttrName}) { + this.${c.simpleAttrName} = ${c.simpleAttrName}; + } + <% + // 其它字段 + }else{ + %> + public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}() { + return ${c.simpleAttrName}; + } + + public void set${@StringUtils.cap(c.simpleAttrName)}(${c.simpleAttrType} ${c.simpleAttrName}) { + this.${c.simpleAttrName} = ${c.simpleAttrName}; + } + <% + } + } + } + + // 生成条件字段get和set方法(范围类型) + for(c in table.columnList){ + if(c.isQuery == "1" && c.queryType == "BETWEEN"){ + %> + + public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_gte() { + return sqlMap.getWhere().getValue("${c.columnName}", QueryType.GTE); + } + + public void set${@StringUtils.cap(c.simpleAttrName)}_gte(${c.simpleAttrType} ${c.simpleAttrName}) { + sqlMap.getWhere().and("${c.columnName}", QueryType.GTE, ${c.simpleAttrName}); + } + + public ${c.simpleAttrType} get${@StringUtils.cap(c.simpleAttrName)}_lte() { + return sqlMap.getWhere().getValue("${c.columnName}", QueryType.LTE); + } + + public void set${@StringUtils.cap(c.simpleAttrName)}_lte(${c.simpleAttrType} ${c.simpleAttrName}) { + sqlMap.getWhere().and("${c.columnName}", QueryType.LTE, ${c.simpleAttrName}); + } + <% + } + } + + // 生成子表列表get和set方法 + for(child in table.childList){ + %> + + public List<${@StringUtils.cap(child.className)}> get${@StringUtils.cap(child.className)}List() { + return ${@StringUtils.uncap(child.className)}List; + } + + public void set${@StringUtils.cap(child.className)}List(List<${@StringUtils.cap(child.className)}> ${@StringUtils.uncap(child.className)}List) { + this.${@StringUtils.uncap(child.className)}List = ${@StringUtils.uncap(child.className)}List; + } + <% } %> + +}]]> + + \ No newline at end of file diff --git a/modules/core/src/main/resources/templates/modules/gen/cloud/service.xml b/modules/core/src/main/resources/templates/modules/gen/cloud/service.xml new file mode 100644 index 00000000..49950181 --- /dev/null +++ b/modules/core/src/main/resources/templates/modules/gen/cloud/service.xml @@ -0,0 +1,216 @@ + + + + service + src/main/java/${packageName}/${moduleName}/service/${subModuleName} + ${ClassName}Service.java + 0){ %> +import org.springframework.beans.factory.annotation.Autowired; +<% } %> +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RestController; + +import com.jeesite.common.entity.Page; +import com.jeesite.common.service.${table.isTreeEntity?'Tree':'Crud'}Service; +import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}; +import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}Dao; +import ${packageName}.${moduleName}.api${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}ServiceApi; +<% if(toBoolean(table.optionMap['isBpmForm'])){ %> +import java.util.Map; +import com.jeesite.common.lang.StringUtils; +import com.jeesite.common.collect.MapUtils; +import com.jeesite.common.service.ServiceException; +import com.jeesite.modules.bpm.utils.client.BpmUtils; +<% } %> +<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %> +import com.jeesite.modules.file.utils.FileUploadUtils; +<% } %> +<% for (child in table.childList){ %> +import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}; +import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao; +<% } %> + +/** + * ${functionName}Service + * @author ${functionAuthor} + * @version ${functionVersion} + */ +@Service +@RestController +@Transactional(readOnly=true) +public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Service<${ClassName}Dao, ${ClassName}> + implements ${ClassName}ServiceApi { + <% for (child in table.childList){ %> + + @Autowired + private ${@StringUtils.cap(child.className)}Dao ${@StringUtils.uncap(child.className)}Dao; + <% } %> + + /** + * 获取单条数据 + * @param ${className} + * @return + */ + @Override + public ${ClassName} get(${ClassName} ${className}) { + <% if (table.childList.~size > 0){ %> + ${ClassName} entity = super.get(${className}); + if (entity != null){ + <% for (child in table.childList){ %> + ${@StringUtils.cap(child.className)} ${@StringUtils.uncap(child.className)} = new ${@StringUtils.cap(child.className)}(entity); + ${@StringUtils.uncap(child.className)}.setStatus(${@StringUtils.cap(child.className)}.STATUS_NORMAL); + entity.set${@StringUtils.cap(child.className)}List(${@StringUtils.uncap(child.className)}Dao.findList(${@StringUtils.uncap(child.className)})); + <% } %> + } + return entity; + <% }else{ %> + return super.get(${className}); + <% } %> + } + <% if(!table.isTreeEntity){ %> + + /** + * 查询分页数据 + * @param ${className} 查询条件 + * @param ${className}.page 分页对象 + * @return + */ + @Override + public Page<${ClassName}> findPage(${ClassName} ${className}) { + return super.findPage(${className}); + } + <% }else{ %> + + /** + * 查询列表数据 + * @param ${className} + * @return + */ + @Override + public List<${ClassName}> findList(${ClassName} ${className}) { + return super.findList(${className}); + } + <% } %> + + /** + * 保存数据(插入或更新) + * @param ${className} + */ + @Override + @Transactional(readOnly=false) + public void save(${ClassName} ${className}) { + <% if(toBoolean(table.optionMap['isBpmForm'])){ %> + // 如果未设置状态,则指定状态为审核状态,以提交审核流程 + if (StringUtils.isBlank(${className}.getStatus())){ + ${className}.setStatus(${ClassName}.STATUS_AUDIT); + } + + // 如果状态为正常,则代表不正常操作,可能前端进行了数据参数修改 + if (${ClassName}.STATUS_NORMAL.equals(${className}.getStatus())){ + throw new ServiceException(text("非法操作,前端数据被劫持!")); + } + + // 如果状态为草稿或审核状态,才可以保存业务数据 + if (${ClassName}.STATUS_DRAFT.equals(${className}.getStatus()) + || ${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){ + super.save(${className}); + } + + // 如果为审核状态,则进行审批流操作 + if (${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){ + + // 指定流程变量,作为流程条件,决定流转方向 + Map variables = MapUtils.newHashMap(); + //variables.put("leaveDays", ${className}.getLeaveDays()); + + // 如果流程实例为空,任务编号也为空,则:启动流程 + if (StringUtils.isBlank(${className}.getBpm().getProcInsId()) + && StringUtils.isBlank(${className}.getBpm().getTaskId())){ + BpmUtils.start(${className}, "${table.optionMap['bpmFormKey']}", variables, null); + } + // 如果有任务信息,则:提交任务 + else{ + BpmUtils.complete(${className}, variables, null); + } + } + <% }else{ %> + super.save(${className}); + <% } %> + <% if(toBoolean(table.optionMap['isImageUpload'])){ %> + // 保存上传图片 + FileUploadUtils.saveFileUpload(${className}.getId(), "${className}_image"); + <% } %> + <% if(toBoolean(table.optionMap['isFileUpload'])){ %> + // 保存上传附件 + FileUploadUtils.saveFileUpload(${className}.getId(), "${className}_file"); + <% } %> + <% for (child in table.childList) { %> + // 保存 ${ClassName}子表 + for (${@StringUtils.cap(child.className)} ${@StringUtils.uncap(child.className)} : ${className}.get${@StringUtils.cap(child.className)}List()){ + if (!${@StringUtils.cap(child.className)}.STATUS_DELETE.equals(${@StringUtils.uncap(child.className)}.getStatus())){ + <% + for(c in child.columnList){ + if (child.parentExists && child.parentTableFkName == c.columnName){ + %> + ${@StringUtils.uncap(child.className)}.set${@StringUtils.cap(c.simpleAttrName)}(${className}); + <% + } + } + %> + if (${@StringUtils.uncap(child.className)}.getIsNewRecord()){ + ${@StringUtils.uncap(child.className)}Dao.insert(${@StringUtils.uncap(child.className)}); + }else{ + ${@StringUtils.uncap(child.className)}Dao.update(${@StringUtils.uncap(child.className)}); + } + }else{ + ${@StringUtils.uncap(child.className)}Dao.delete(${@StringUtils.uncap(child.className)}); + } + } + <% } %> + } + + /** + * 更新状态 + * @param ${className} + */ + @Override + @Transactional(readOnly=false) + public void updateStatus(${ClassName} ${className}) { + super.updateStatus(${className}); + } + + /** + * 删除数据 + * @param ${className} + */ + @Override + @Transactional(readOnly=false) + public void delete(${ClassName} ${className}) { + super.delete(${className}); + <% for (child in table.childList) { %> + ${@StringUtils.cap(child.className)} ${@StringUtils.uncap(child.className)} = new ${@StringUtils.cap(child.className)}(); + <% + for(c in child.columnList){ + if (child.parentExists && child.parentTableFkName == c.columnName){ + %> + ${@StringUtils.uncap(child.className)}.set${@StringUtils.cap(c.simpleAttrName)}(${className}); + <% + } + } + %> + ${@StringUtils.uncap(child.className)}Dao.deleteByEntity(${@StringUtils.uncap(child.className)}); + <% } %> + } + +}]]> + + \ No newline at end of file diff --git a/modules/core/src/main/resources/templates/modules/gen/config.xml b/modules/core/src/main/resources/templates/modules/gen/config.xml index 3e481b25..f554fa36 100644 --- a/modules/core/src/main/resources/templates/modules/gen/config.xml +++ b/modules/core/src/main/resources/templates/modules/gen/config.xml @@ -14,9 +14,28 @@ category-ref:dao + + crud/mapper.xml + cloud/entity.xml + crud/dao.xml + cloud/api.xml + cloud/client.xml + cloud/service.xml + crud/controller.xml + crud/viewList.xml + crud/viewForm.xml + + crud/mapper.xml + cloud/entity.xml + crud/dao.xml + + category-ref:crud + + category-ref:crud + category-ref:dao crud/service.xml diff --git a/modules/core/src/main/resources/templates/modules/gen/crud/entity.xml b/modules/core/src/main/resources/templates/modules/gen/crud/entity.xml index e5e08d92..b285f9ae 100644 --- a/modules/core/src/main/resources/templates/modules/gen/crud/entity.xml +++ b/modules/core/src/main/resources/templates/modules/gen/crud/entity.xml @@ -21,6 +21,13 @@ import com.jeesite.common.entity.TreeEntity; import com.jeesite.common.mybatis.annotation.Column; import com.jeesite.common.mybatis.annotation.Table; import com.jeesite.common.mybatis.mapper.query.QueryType; +<% if(toBoolean(table.optionMap['isBpmForm'])){ %> + <% if(table.isTreeEntity){ %> +import com.jeesite.modules.bpm.entity.BpmTreeEntity; + <% }else{ %> +import com.jeesite.modules.bpm.entity.BpmEntity; + <% } %> +<% } %> /** * ${functionName}Entity @@ -156,7 +163,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType; } } %>" ) -public class ${ClassName} extends ${table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> { +public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(table.isTreeEntity?'BpmTree':'Bpm'):table.isTreeEntity?'Tree':'Data'}Entity<${ClassName}> { private static final long serialVersionUID = 1L; <% diff --git a/modules/core/src/main/resources/templates/modules/gen/crud/service.xml b/modules/core/src/main/resources/templates/modules/gen/crud/service.xml index de718b38..e3f8c715 100644 --- a/modules/core/src/main/resources/templates/modules/gen/crud/service.xml +++ b/modules/core/src/main/resources/templates/modules/gen/crud/service.xml @@ -22,6 +22,13 @@ import com.jeesite.common.entity.Page; import com.jeesite.common.service.${table.isTreeEntity?'Tree':'Crud'}Service; import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}; import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${ClassName}Dao; +<% if(toBoolean(table.optionMap['isBpmForm'])){ %> +import java.util.Map; +import com.jeesite.common.lang.StringUtils; +import com.jeesite.common.collect.MapUtils; +import com.jeesite.common.service.ServiceException; +import com.jeesite.modules.bpm.utils.BpmUtils; +<% } %> <% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %> import com.jeesite.modules.file.utils.FileUploadUtils; <% } %> @@ -97,7 +104,43 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv @Override @Transactional(readOnly=false) public void save(${ClassName} ${className}) { + <% if(toBoolean(table.optionMap['isBpmForm'])){ %> + // 如果未设置状态,则指定状态为审核状态,以提交审核流程 + if (StringUtils.isBlank(${className}.getStatus())){ + ${className}.setStatus(${ClassName}.STATUS_AUDIT); + } + + // 如果状态为正常,则代表不正常操作,可能前端进行了数据参数修改 + if (${ClassName}.STATUS_NORMAL.equals(${className}.getStatus())){ + throw new ServiceException(text("非法操作,前端数据被劫持!")); + } + + // 如果状态为草稿或审核状态,才可以保存业务数据 + if (${ClassName}.STATUS_DRAFT.equals(${className}.getStatus()) + || ${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){ + super.save(${className}); + } + + // 如果为审核状态,则进行审批流操作 + if (${ClassName}.STATUS_AUDIT.equals(${className}.getStatus())){ + + // 指定流程变量,作为流程条件,决定流转方向 + Map variables = MapUtils.newHashMap(); + //variables.put("leaveDays", ${className}.getLeaveDays()); + + // 如果流程实例为空,任务编号也为空,则:启动流程 + if (StringUtils.isBlank(${className}.getBpm().getProcInsId()) + && StringUtils.isBlank(${className}.getBpm().getTaskId())){ + BpmUtils.start(${className}, "${table.optionMap['bpmFormKey']}", variables, null); + } + // 如果有任务信息,则:提交任务 + else{ + BpmUtils.complete(${className}, variables, null); + } + } + <% }else{ %> super.save(${className}); + <% } %> <% if(toBoolean(table.optionMap['isImageUpload'])){ %> // 保存上传图片 FileUploadUtils.saveFileUpload(${className}.getId(), "${className}_image"); diff --git a/modules/core/src/main/resources/templates/modules/gen/crud/viewForm.xml b/modules/core/src/main/resources/templates/modules/gen/crud/viewForm.xml index 4c03ab52..7c28b63c 100644 --- a/modules/core/src/main/resources/templates/modules/gen/crud/viewForm.xml +++ b/modules/core/src/main/resources/templates/modules/gen/crud/viewForm.xml @@ -45,13 +45,38 @@ <% } %> <% include('/templates/modules/gen/include/formControl.html'){} %> <% include('/templates/modules/gen/include/formChildTable.html'){} %> + <% if(toBoolean(table.optionMap['isBpmForm'])){ %> + \<% if(isNotBlank(${className}.bpm.taskId)){ %> + + + + ${text('审批意见')}: + + <${'#'}bpm:comment bpmEntity="\${${className}}" /> + + + + + \<% } %> + <${'#'}bpm:nextTaskInfo bpmEntity="\${${className}}" /> + <% } %>