李云瑞 1 рік тому
батько
коміт
f4d2fa75c1
34 змінених файлів з 2814 додано та 0 видалено
  1. 19 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  2. 105 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  3. 84 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  4. 229 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  5. 56 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  6. 105 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  7. 84 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  8. 105 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  9. 84 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  10. 105 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  11. 84 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  12. 19 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  13. 19 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/one2/java/${bussiPackage}/service/${entityPackage}/impl/${entityName}ServiceImpl.javai
  14. 101 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  15. 54 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  16. 101 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/onetomany2/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  17. 53 0
      jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/onetomany2/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  18. 19 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  19. 105 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  20. 84 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  21. 229 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  22. 56 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  23. 105 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  24. 84 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  25. 105 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  26. 84 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  27. 105 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  28. 84 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  29. 19 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  30. 19 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/one2/java/${bussiPackage}/service/${entityPackage}/impl/${entityName}ServiceImpl.javai
  31. 101 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  32. 54 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai
  33. 101 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/onetomany2/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai
  34. 53 0
      jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/onetomany2/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

+ 19 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,19 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+}

+ 105 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,105 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 84 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,84 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelEntity;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+	<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
+    <#list originalColumns as po>
+    <#-- 生成字典Code -->
+    <#assign list_field_dictCode="">
+    <#if po.classType='sel_user'>
+      <#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
+    <#elseif po.classType='sel_depart'>
+      <#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
+    <#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
+      <#if po.dictTable?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
+      <#elseif po.dictField?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
+      </#if>
+    </#if>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+		<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
+			<#if po.classType=='date'>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+			<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+			</#if>
+		<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
+	</#if>
+		</#if>
+        <#if list_field_dictCode?length gt 1>
+    @Dict(${list_field_dictCode?substring(2)})
+        </#if>
+	</#if>
+	@ApiModelProperty(value = "${po.filedComment}")
+	<#if po.fieldDbType=='Blob'>
+    private java.lang.String ${po.fieldName}String;
+    <#else>
+    private ${po.fieldType} ${po.fieldName};
+    </#if>
+	</#list>
+
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+
+}

+ 229 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,229 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.common.system.vo.SelectTreeModel;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+<#assign pidFieldName = "">
+<#assign hasChildrenField = "">
+<#list originalColumns as po>
+<#if po.fieldDbName == tableVo.extendParams.pidField>
+<#assign pidFieldName = po.fieldName>
+</#if>
+<#if po.fieldDbName == tableVo.extendParams.hasChildren>
+<#assign hasChildrenField = po.fieldName>
+</#if>
+</#list>
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Override
+	public void add${entityName}(${entityName} ${entityName?uncap_first}) {
+	   //新增时设置hasChild为0
+	    ${entityName?uncap_first}.set${hasChildrenField?cap_first}(I${entityName}Service.NOCHILD);
+		if(oConvertUtils.isEmpty(${entityName?uncap_first}.get${pidFieldName?cap_first}())){
+			${entityName?uncap_first}.set${pidFieldName?cap_first}(I${entityName}Service.ROOT_PID_VALUE);
+		}else{
+			//如果当前节点父ID不为空 则设置父节点的hasChildren 为1
+			${entityName} parent = baseMapper.selectById(${entityName?uncap_first}.get${pidFieldName?cap_first}());
+			if(parent!=null && !"1".equals(parent.get${hasChildrenField?cap_first}())){
+				parent.set${hasChildrenField?cap_first}("1");
+				baseMapper.updateById(parent);
+			}
+		}
+		baseMapper.insert(${entityName?uncap_first});
+	}
+	
+	@Override
+	public void update${entityName}(${entityName} ${entityName?uncap_first}) {
+		${entityName} entity = this.getById(${entityName?uncap_first}.getId());
+		if(entity==null) {
+			throw new JeecgBootException("未找到对应实体");
+		}
+		String old_pid = entity.get${pidFieldName?cap_first}();
+		String new_pid = ${entityName?uncap_first}.get${pidFieldName?cap_first}();
+		if(!old_pid.equals(new_pid)) {
+			updateOldParentNode(old_pid);
+			if(oConvertUtils.isEmpty(new_pid)){
+				${entityName?uncap_first}.set${pidFieldName?cap_first}(I${entityName}Service.ROOT_PID_VALUE);
+			}
+			if(!I${entityName}Service.ROOT_PID_VALUE.equals(${entityName?uncap_first}.get${pidFieldName?cap_first}())) {
+				baseMapper.updateTreeNodeStatus(${entityName?uncap_first}.get${pidFieldName?cap_first}(), I${entityName}Service.HASCHILD);
+			}
+		}
+		baseMapper.updateById(${entityName?uncap_first});
+	}
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delete${entityName}(String id) throws JeecgBootException {
+		//查询选中节点下所有子节点一并删除
+        id = this.queryTreeChildIds(id);
+        if(id.indexOf(",")>0) {
+            StringBuffer sb = new StringBuffer();
+            String[] idArr = id.split(",");
+            for (String idVal : idArr) {
+                if(idVal != null){
+                    ${entityName} ${entityName?uncap_first} = this.getById(idVal);
+                    String pidVal = ${entityName?uncap_first}.get${pidFieldName?cap_first}();
+                    //查询此节点上一级是否还有其他子节点
+                    List<${entityName}> dataList = baseMapper.selectList(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pidVal).notIn("id",Arrays.asList(idArr)));
+                    boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(pidVal) && !sb.toString().contains(pidVal);
+                    if(flag){
+                        //如果当前节点原本有子节点 现在木有了,更新状态
+                        sb.append(pidVal).append(",");
+                    }
+                }
+            }
+            //批量删除节点
+            baseMapper.deleteBatchIds(Arrays.asList(idArr));
+            //修改已无子节点的标识
+            String[] pidArr = sb.toString().split(",");
+            for(String pid : pidArr){
+                this.updateOldParentNode(pid);
+            }
+        }else{
+            ${entityName} ${entityName?uncap_first} = this.getById(id);
+            if(${entityName?uncap_first}==null) {
+                throw new JeecgBootException("未找到对应实体");
+            }
+            updateOldParentNode(${entityName?uncap_first}.get${pidFieldName?cap_first}());
+            baseMapper.deleteById(id);
+        }
+	}
+	
+	@Override
+    public List<${entityName}> queryTreeListNoPage(QueryWrapper<${entityName}> queryWrapper) {
+        List<${entityName}> dataList = baseMapper.selectList(queryWrapper);
+        List<${entityName}> mapList = new ArrayList<>();
+        for(${entityName} data : dataList){
+            String pidVal = data.get${pidFieldName?cap_first}();
+            //递归查询子节点的根节点
+            if(pidVal != null && !I${entityName}Service.NOCHILD.equals(pidVal)){
+                ${entityName} rootVal = this.getTreeRoot(pidVal);
+                if(rootVal != null && !mapList.contains(rootVal)){
+                    mapList.add(rootVal);
+                }
+            }else{
+                if(!mapList.contains(data)){
+                    mapList.add(data);
+                }
+            }
+        }
+        return mapList;
+    }
+
+    @Override
+    public List<SelectTreeModel> queryListByCode(String parentCode) {
+        String pid = ROOT_PID_VALUE;
+        if (oConvertUtils.isNotEmpty(parentCode)) {
+            LambdaQueryWrapper<${entityName}> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(${entityName}::get${pidFieldName?cap_first}, parentCode);
+            List<${entityName}> list = baseMapper.selectList(queryWrapper);
+            if (list == null || list.size() == 0) {
+                throw new JeecgBootException("该编码【" + parentCode + "】不存在,请核实!");
+            }
+            if (list.size() > 1) {
+                throw new JeecgBootException("该编码【" + parentCode + "】存在多个,请核实!");
+            }
+            pid = list.get(0).getId();
+        }
+        return baseMapper.queryListByPid(pid, null);
+    }
+
+    @Override
+    public List<SelectTreeModel> queryListByPid(String pid) {
+        if (oConvertUtils.isEmpty(pid)) {
+            pid = ROOT_PID_VALUE;
+        }
+        return baseMapper.queryListByPid(pid, null);
+    }
+
+	/**
+	 * 根据所传pid查询旧的父级节点的子节点并修改相应状态值
+	 * @param pid
+	 */
+	private void updateOldParentNode(String pid) {
+		if(!I${entityName}Service.ROOT_PID_VALUE.equals(pid)) {
+			Long count = baseMapper.selectCount(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pid));
+			if(count==null || count<=1) {
+				baseMapper.updateTreeNodeStatus(pid, I${entityName}Service.NOCHILD);
+			}
+		}
+	}
+
+	/**
+     * 递归查询节点的根节点
+     * @param pidVal
+     * @return
+     */
+    private ${entityName} getTreeRoot(String pidVal){
+        ${entityName} data =  baseMapper.selectById(pidVal);
+        if(data != null && !I${entityName}Service.ROOT_PID_VALUE.equals(data.get${pidFieldName?cap_first}())){
+            return this.getTreeRoot(data.get${pidFieldName?cap_first}());
+        }else{
+            return data;
+        }
+    }
+
+    /**
+     * 根据id查询所有子节点id
+     * @param ids
+     * @return
+     */
+    private String queryTreeChildIds(String ids) {
+        //获取id数组
+        String[] idArr = ids.split(",");
+        StringBuffer sb = new StringBuffer();
+        for (String pidVal : idArr) {
+            if(pidVal != null){
+                if(!sb.toString().contains(pidVal)){
+                    if(sb.toString().length() > 0){
+                        sb.append(",");
+                    }
+                    sb.append(pidVal);
+                    this.getTreeChildIds(pidVal,sb);
+                }
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 递归查询所有子节点
+     * @param pidVal
+     * @param sb
+     * @return
+     */
+    private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){
+        List<${entityName}> dataList = baseMapper.selectList(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pidVal));
+        if(dataList != null && dataList.size()>0){
+            for(${entityName} tree : dataList) {
+                if(!sb.toString().contains(tree.getId())){
+                    sb.append(",").append(tree.getId());
+                }
+                this.getTreeChildIds(tree.getId(),sb);
+            }
+        }
+        return sb;
+    }
+
+}

+ 56 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,56 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 105 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,105 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 84 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,84 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelEntity;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
+    <#list originalColumns as po>
+    <#-- 生成字典Code -->
+    <#assign list_field_dictCode="">
+    <#if po.classType='sel_user'>
+      <#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
+    <#elseif po.classType='sel_depart'>
+      <#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
+    <#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
+      <#if po.dictTable?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
+      <#elseif po.dictField?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
+      </#if>
+    </#if>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+		<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
+			<#if po.classType=='date'>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+			<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+			</#if>
+		<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
+	</#if>
+	<#if list_field_dictCode?length gt 1>
+    @Dict(${list_field_dictCode?substring(2)})
+    </#if>
+		</#if>
+	</#if>
+	@ApiModelProperty(value = "${po.filedComment}")
+    <#if po.fieldDbType=='Blob'>
+    private java.lang.String ${po.fieldName}String;
+    <#else>
+    private ${po.fieldType} ${po.fieldName};
+    </#if>
+	</#list>
+	
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+	
+}

+ 105 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,105 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 84 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,84 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelEntity;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+	<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
+    <#list originalColumns as po>
+    <#-- 生成字典Code -->
+    <#assign list_field_dictCode="">
+    <#if po.classType='sel_user'>
+      <#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
+    <#elseif po.classType='sel_depart'>
+      <#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
+    <#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
+      <#if po.dictTable?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
+      <#elseif po.dictField?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
+      </#if>
+    </#if>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+		<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
+			<#if po.classType=='date'>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+			<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+			</#if>
+		<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
+	</#if>
+		</#if>
+        <#if list_field_dictCode?length gt 1>
+    @Dict(${list_field_dictCode?substring(2)})
+        </#if>
+	</#if>
+	@ApiModelProperty(value = "${po.filedComment}")
+    <#if po.fieldDbType=='Blob'>
+    private java.lang.String ${po.fieldName}String;
+    <#else>
+    private ${po.fieldType} ${po.fieldName};
+    </#if>
+	</#list>
+
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+
+}

+ 105 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,105 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 84 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,84 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelEntity;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+	<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
+    <#list originalColumns as po>
+    <#-- 生成字典Code -->
+    <#assign list_field_dictCode="">
+    <#if po.classType='sel_user'>
+      <#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
+    <#elseif po.classType='sel_depart'>
+      <#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
+    <#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
+      <#if po.dictTable?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
+      <#elseif po.dictField?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
+      </#if>
+    </#if>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+		<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
+			<#if po.classType=='date'>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+			<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+			</#if>
+		<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
+	</#if>
+		</#if>
+        <#if list_field_dictCode?length gt 1>
+    @Dict(${list_field_dictCode?substring(2)})
+        </#if>
+	</#if>
+	@ApiModelProperty(value = "${po.filedComment}")
+    <#if po.fieldDbType=='Blob'>
+    private java.lang.String ${po.fieldName}String;
+    <#else>
+    private ${po.fieldType} ${po.fieldName};
+    </#if>
+	</#list>
+
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+
+}

+ 19 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,19 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+}

+ 19 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/one2/java/${bussiPackage}/service/${entityPackage}/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,19 @@
+package ${bussiPackage}.service.${entityPackage}.impl;
+
+import ${bussiPackage}.entity.${entityPackage}.${entityName};
+import ${bussiPackage}.mapper.${entityPackage}.${entityName}Mapper;
+import ${bussiPackage}.service.${entityPackage}.I${entityName}Service;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+}

+ 101 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,101 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+			<#list sub.foreignKeys as key>
+			//外键设置
+			<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+			<#else>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+			</#if>
+			</#list>
+			${sub.entityName?uncap_first}Mapper.insert(entity);
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+			<#list sub.foreignKeys as key>
+			//外键设置
+			<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+			<#else>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+			</#if>
+			</#list>
+			${sub.entityName?uncap_first}Mapper.insert(entity);
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 54 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,54 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+	
+    <#list originalColumns as po>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+    <#if po.fieldType =='java.util.Date'>
+  	<#if po.fieldDbType =='date'>
+  	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+  	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+  	<#elseif po.fieldDbType =='datetime'>
+  	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+  	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+  	</#if>
+  	<#else>
+  	@Excel(name = "${po.filedComment}", width = 15)
+    </#if>
+  </#if>
+	private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
+	</#list>
+	
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+	
+}

+ 101 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/onetomany2/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,101 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+			<#list sub.foreignKeys as key>
+			//外键设置
+			<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+			<#else>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+			</#if>
+			</#list>
+			${sub.entityName?uncap_first}Mapper.insert(entity);
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+			<#list sub.foreignKeys as key>
+			//外键设置
+			<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+			<#else>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+			</#if>
+			</#list>
+			${sub.entityName?uncap_first}Mapper.insert(entity);
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 53 - 0
jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template/onetomany2/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,53 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+    <#list originalColumns as po>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+    <#if po.fieldType =='java.util.Date'>
+  	<#if po.fieldDbType =='date'>
+  	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+  	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+  	<#elseif po.fieldDbType =='datetime'>
+  	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+  	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+  	</#if>
+  	<#else>
+  	@Excel(name = "${po.filedComment}", width = 15)
+    </#if>
+  </#if>
+	private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
+	</#list>
+
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+	
+}

+ 19 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,19 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+}

+ 105 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,105 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 84 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/default/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,84 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelEntity;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+	<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
+    <#list originalColumns as po>
+    <#-- 生成字典Code -->
+    <#assign list_field_dictCode="">
+    <#if po.classType='sel_user'>
+      <#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
+    <#elseif po.classType='sel_depart'>
+      <#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
+    <#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
+      <#if po.dictTable?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
+      <#elseif po.dictField?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
+      </#if>
+    </#if>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+		<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
+			<#if po.classType=='date'>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+			<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+			</#if>
+		<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
+	</#if>
+		</#if>
+        <#if list_field_dictCode?length gt 1>
+    @Dict(${list_field_dictCode?substring(2)})
+        </#if>
+	</#if>
+	@ApiModelProperty(value = "${po.filedComment}")
+	<#if po.fieldDbType=='Blob'>
+    private java.lang.String ${po.fieldName}String;
+    <#else>
+    private ${po.fieldType} ${po.fieldName};
+    </#if>
+	</#list>
+
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+
+}

+ 229 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,229 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.common.system.vo.SelectTreeModel;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+<#assign pidFieldName = "">
+<#assign hasChildrenField = "">
+<#list originalColumns as po>
+<#if po.fieldDbName == tableVo.extendParams.pidField>
+<#assign pidFieldName = po.fieldName>
+</#if>
+<#if po.fieldDbName == tableVo.extendParams.hasChildren>
+<#assign hasChildrenField = po.fieldName>
+</#if>
+</#list>
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Override
+	public void add${entityName}(${entityName} ${entityName?uncap_first}) {
+	   //新增时设置hasChild为0
+	    ${entityName?uncap_first}.set${hasChildrenField?cap_first}(I${entityName}Service.NOCHILD);
+		if(oConvertUtils.isEmpty(${entityName?uncap_first}.get${pidFieldName?cap_first}())){
+			${entityName?uncap_first}.set${pidFieldName?cap_first}(I${entityName}Service.ROOT_PID_VALUE);
+		}else{
+			//如果当前节点父ID不为空 则设置父节点的hasChildren 为1
+			${entityName} parent = baseMapper.selectById(${entityName?uncap_first}.get${pidFieldName?cap_first}());
+			if(parent!=null && !"1".equals(parent.get${hasChildrenField?cap_first}())){
+				parent.set${hasChildrenField?cap_first}("1");
+				baseMapper.updateById(parent);
+			}
+		}
+		baseMapper.insert(${entityName?uncap_first});
+	}
+	
+	@Override
+	public void update${entityName}(${entityName} ${entityName?uncap_first}) {
+		${entityName} entity = this.getById(${entityName?uncap_first}.getId());
+		if(entity==null) {
+			throw new JeecgBootException("未找到对应实体");
+		}
+		String old_pid = entity.get${pidFieldName?cap_first}();
+		String new_pid = ${entityName?uncap_first}.get${pidFieldName?cap_first}();
+		if(!old_pid.equals(new_pid)) {
+			updateOldParentNode(old_pid);
+			if(oConvertUtils.isEmpty(new_pid)){
+				${entityName?uncap_first}.set${pidFieldName?cap_first}(I${entityName}Service.ROOT_PID_VALUE);
+			}
+			if(!I${entityName}Service.ROOT_PID_VALUE.equals(${entityName?uncap_first}.get${pidFieldName?cap_first}())) {
+				baseMapper.updateTreeNodeStatus(${entityName?uncap_first}.get${pidFieldName?cap_first}(), I${entityName}Service.HASCHILD);
+			}
+		}
+		baseMapper.updateById(${entityName?uncap_first});
+	}
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delete${entityName}(String id) throws JeecgBootException {
+		//查询选中节点下所有子节点一并删除
+        id = this.queryTreeChildIds(id);
+        if(id.indexOf(",")>0) {
+            StringBuffer sb = new StringBuffer();
+            String[] idArr = id.split(",");
+            for (String idVal : idArr) {
+                if(idVal != null){
+                    ${entityName} ${entityName?uncap_first} = this.getById(idVal);
+                    String pidVal = ${entityName?uncap_first}.get${pidFieldName?cap_first}();
+                    //查询此节点上一级是否还有其他子节点
+                    List<${entityName}> dataList = baseMapper.selectList(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pidVal).notIn("id",Arrays.asList(idArr)));
+                    boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(pidVal) && !sb.toString().contains(pidVal);
+                    if(flag){
+                        //如果当前节点原本有子节点 现在木有了,更新状态
+                        sb.append(pidVal).append(",");
+                    }
+                }
+            }
+            //批量删除节点
+            baseMapper.deleteBatchIds(Arrays.asList(idArr));
+            //修改已无子节点的标识
+            String[] pidArr = sb.toString().split(",");
+            for(String pid : pidArr){
+                this.updateOldParentNode(pid);
+            }
+        }else{
+            ${entityName} ${entityName?uncap_first} = this.getById(id);
+            if(${entityName?uncap_first}==null) {
+                throw new JeecgBootException("未找到对应实体");
+            }
+            updateOldParentNode(${entityName?uncap_first}.get${pidFieldName?cap_first}());
+            baseMapper.deleteById(id);
+        }
+	}
+	
+	@Override
+    public List<${entityName}> queryTreeListNoPage(QueryWrapper<${entityName}> queryWrapper) {
+        List<${entityName}> dataList = baseMapper.selectList(queryWrapper);
+        List<${entityName}> mapList = new ArrayList<>();
+        for(${entityName} data : dataList){
+            String pidVal = data.get${pidFieldName?cap_first}();
+            //递归查询子节点的根节点
+            if(pidVal != null && !I${entityName}Service.NOCHILD.equals(pidVal)){
+                ${entityName} rootVal = this.getTreeRoot(pidVal);
+                if(rootVal != null && !mapList.contains(rootVal)){
+                    mapList.add(rootVal);
+                }
+            }else{
+                if(!mapList.contains(data)){
+                    mapList.add(data);
+                }
+            }
+        }
+        return mapList;
+    }
+
+    @Override
+    public List<SelectTreeModel> queryListByCode(String parentCode) {
+        String pid = ROOT_PID_VALUE;
+        if (oConvertUtils.isNotEmpty(parentCode)) {
+            LambdaQueryWrapper<${entityName}> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(${entityName}::get${pidFieldName?cap_first}, parentCode);
+            List<${entityName}> list = baseMapper.selectList(queryWrapper);
+            if (list == null || list.size() == 0) {
+                throw new JeecgBootException("该编码【" + parentCode + "】不存在,请核实!");
+            }
+            if (list.size() > 1) {
+                throw new JeecgBootException("该编码【" + parentCode + "】存在多个,请核实!");
+            }
+            pid = list.get(0).getId();
+        }
+        return baseMapper.queryListByPid(pid, null);
+    }
+
+    @Override
+    public List<SelectTreeModel> queryListByPid(String pid) {
+        if (oConvertUtils.isEmpty(pid)) {
+            pid = ROOT_PID_VALUE;
+        }
+        return baseMapper.queryListByPid(pid, null);
+    }
+
+	/**
+	 * 根据所传pid查询旧的父级节点的子节点并修改相应状态值
+	 * @param pid
+	 */
+	private void updateOldParentNode(String pid) {
+		if(!I${entityName}Service.ROOT_PID_VALUE.equals(pid)) {
+			Long count = baseMapper.selectCount(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pid));
+			if(count==null || count<=1) {
+				baseMapper.updateTreeNodeStatus(pid, I${entityName}Service.NOCHILD);
+			}
+		}
+	}
+
+	/**
+     * 递归查询节点的根节点
+     * @param pidVal
+     * @return
+     */
+    private ${entityName} getTreeRoot(String pidVal){
+        ${entityName} data =  baseMapper.selectById(pidVal);
+        if(data != null && !I${entityName}Service.ROOT_PID_VALUE.equals(data.get${pidFieldName?cap_first}())){
+            return this.getTreeRoot(data.get${pidFieldName?cap_first}());
+        }else{
+            return data;
+        }
+    }
+
+    /**
+     * 根据id查询所有子节点id
+     * @param ids
+     * @return
+     */
+    private String queryTreeChildIds(String ids) {
+        //获取id数组
+        String[] idArr = ids.split(",");
+        StringBuffer sb = new StringBuffer();
+        for (String pidVal : idArr) {
+            if(pidVal != null){
+                if(!sb.toString().contains(pidVal)){
+                    if(sb.toString().length() > 0){
+                        sb.append(",");
+                    }
+                    sb.append(pidVal);
+                    this.getTreeChildIds(pidVal,sb);
+                }
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 递归查询所有子节点
+     * @param pidVal
+     * @param sb
+     * @return
+     */
+    private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){
+        List<${entityName}> dataList = baseMapper.selectList(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pidVal));
+        if(dataList != null && dataList.size()>0){
+            for(${entityName} tree : dataList) {
+                if(!sb.toString().contains(tree.getId())){
+                    sb.append(",").append(tree.getId());
+                }
+                this.getTreeChildIds(tree.getId(),sb);
+            }
+        }
+        return sb;
+    }
+
+}

+ 56 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/erp/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,56 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 105 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,105 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 84 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/inner-table/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,84 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelEntity;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
+    <#list originalColumns as po>
+    <#-- 生成字典Code -->
+    <#assign list_field_dictCode="">
+    <#if po.classType='sel_user'>
+      <#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
+    <#elseif po.classType='sel_depart'>
+      <#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
+    <#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
+      <#if po.dictTable?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
+      <#elseif po.dictField?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
+      </#if>
+    </#if>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+		<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
+			<#if po.classType=='date'>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+			<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+			</#if>
+		<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
+	</#if>
+	<#if list_field_dictCode?length gt 1>
+    @Dict(${list_field_dictCode?substring(2)})
+    </#if>
+		</#if>
+	</#if>
+	@ApiModelProperty(value = "${po.filedComment}")
+    <#if po.fieldDbType=='Blob'>
+    private java.lang.String ${po.fieldName}String;
+    <#else>
+    private ${po.fieldType} ${po.fieldName};
+    </#if>
+	</#list>
+	
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+	
+}

+ 105 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,105 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 84 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,84 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelEntity;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+	<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
+    <#list originalColumns as po>
+    <#-- 生成字典Code -->
+    <#assign list_field_dictCode="">
+    <#if po.classType='sel_user'>
+      <#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
+    <#elseif po.classType='sel_depart'>
+      <#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
+    <#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
+      <#if po.dictTable?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
+      <#elseif po.dictField?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
+      </#if>
+    </#if>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+		<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
+			<#if po.classType=='date'>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+			<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+			</#if>
+		<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
+	</#if>
+		</#if>
+        <#if list_field_dictCode?length gt 1>
+    @Dict(${list_field_dictCode?substring(2)})
+        </#if>
+	</#if>
+	@ApiModelProperty(value = "${po.filedComment}")
+    <#if po.fieldDbType=='Blob'>
+    private java.lang.String ${po.fieldName}String;
+    <#else>
+    private ${po.fieldType} ${po.fieldName};
+    </#if>
+	</#list>
+
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+
+}

+ 105 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,105 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
+			for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+				<#list sub.foreignKeys as key>
+				//外键设置
+				<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+				<#else>
+				entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+				</#if>
+				</#list>
+				${sub.entityName?uncap_first}Mapper.insert(entity);
+			}
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 84 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template-online/tab/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,84 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelEntity;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+	<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
+    <#list originalColumns as po>
+    <#-- 生成字典Code -->
+    <#assign list_field_dictCode="">
+    <#if po.classType='sel_user'>
+      <#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
+    <#elseif po.classType='sel_depart'>
+      <#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
+    <#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
+      <#if po.dictTable?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
+      <#elseif po.dictField?default("")?trim?length gt 1>
+        <#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
+      </#if>
+    </#if>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+		<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
+			<#if po.classType=='date'>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+			<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	</#if>
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+			</#if>
+		<#else>
+	<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
+	@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
+	</#if>
+		</#if>
+        <#if list_field_dictCode?length gt 1>
+    @Dict(${list_field_dictCode?substring(2)})
+        </#if>
+	</#if>
+	@ApiModelProperty(value = "${po.filedComment}")
+    <#if po.fieldDbType=='Blob'>
+    private java.lang.String ${po.fieldName}String;
+    <#else>
+    private ${po.fieldType} ${po.fieldName};
+    </#if>
+	</#list>
+
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+
+}

+ 19 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/one/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,19 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+}

+ 19 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/one2/java/${bussiPackage}/service/${entityPackage}/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,19 @@
+package ${bussiPackage}.service.${entityPackage}.impl;
+
+import ${bussiPackage}.entity.${entityPackage}.${entityName};
+import ${bussiPackage}.mapper.${entityPackage}.${entityName}Mapper;
+import ${bussiPackage}.service.${entityPackage}.I${entityName}Service;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+}

+ 101 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,101 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+			<#list sub.foreignKeys as key>
+			//外键设置
+			<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+			<#else>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+			</#if>
+			</#list>
+			${sub.entityName?uncap_first}Mapper.insert(entity);
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+			<#list sub.foreignKeys as key>
+			//外键设置
+			<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+			<#else>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+			</#if>
+			</#list>
+			${sub.entityName?uncap_first}Mapper.insert(entity);
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 54 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/onetomany/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,54 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+	
+    <#list originalColumns as po>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+    <#if po.fieldType =='java.util.Date'>
+  	<#if po.fieldDbType =='date'>
+  	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+  	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+  	<#elseif po.fieldDbType =='datetime'>
+  	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+  	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+  	</#if>
+  	<#else>
+  	@Excel(name = "${po.filedComment}", width = 15)
+    </#if>
+  </#if>
+	private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
+	</#list>
+	
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+	
+}

+ 101 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/onetomany2/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai

@@ -0,0 +1,101 @@
+package ${bussiPackage}.${entityPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
+</#list>
+import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+	@Autowired
+	private ${entityName}Mapper ${entityName?uncap_first}Mapper;
+	<#list subTables as sub>
+	@Autowired
+	private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
+	</#list>
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
+		<#list subTables as sub>
+		for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+			<#list sub.foreignKeys as key>
+			//外键设置
+			<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+			<#else>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+			</#if>
+			</#list>
+			${sub.entityName?uncap_first}Mapper.insert(entity);
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
+		${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
+		
+		//1.先删除子表数据
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
+		</#list>
+		
+		//2.子表数据重新插入
+		<#list subTables as sub>
+		for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
+			<#list sub.foreignKeys as key>
+			//外键设置
+			<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
+			<#else>
+			entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
+			</#if>
+			</#list>
+			${sub.entityName?uncap_first}Mapper.insert(entity);
+		}
+		</#list>
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delMain(String id) {
+		<#list subTables as sub>
+		${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
+		</#list>
+		${entityName?uncap_first}Mapper.deleteById(id);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delBatchMain(Collection<? extends Serializable> idList) {
+		for(Serializable id:idList) {
+			<#list subTables as sub>
+			${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
+			</#list>
+			${entityName?uncap_first}Mapper.deleteById(id);
+		}
+	}
+	
+}

+ 53 - 0
jeecg-module-system/jeecg-system-biz/target/classes/jeecg/code-template/onetomany2/java/${bussiPackage}/${entityPackage}/vo/${entityName}Page.javai

@@ -0,0 +1,53 @@
+package ${bussiPackage}.${entityPackage}.vo;
+
+import java.util.List;
+import ${bussiPackage}.${entityPackage}.entity.${entityName};
+<#list subTables as sub>
+import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
+</#list>
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecgframework.poi.excel.annotation.ExcelCollection;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: jeecg-boot
+ * @Date:   ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Page {
+
+    <#list originalColumns as po>
+	/**${po.filedComment}*/
+	<#if po.fieldName == primaryKeyField>
+	<#else>
+    <#if po.fieldType =='java.util.Date'>
+  	<#if po.fieldDbType =='date'>
+  	@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
+  	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+  	<#elseif po.fieldDbType =='datetime'>
+  	@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+  	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+  	</#if>
+  	<#else>
+  	@Excel(name = "${po.filedComment}", width = 15)
+    </#if>
+  </#if>
+	private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
+	</#list>
+
+	<#list subTables as sub>
+	@ExcelCollection(name="${sub.ftlDescription}")
+	@ApiModelProperty(value = "${sub.ftlDescription}")
+	private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
+	</#list>
+	
+}