CAP4FormCacheManager cap4FormCacheManager = (CAP4FormCacheManager) AppContext.getBean(${doubleQuote}cap4FormCacheManager${doubleQuote});
        TemplateManager templateManager = (TemplateManager) AppContext.getBean(${doubleQuote}templateManager${doubleQuote});
        java.util.List<${returnEntityName}> result = new ArrayList<${returnEntityName}>();
        long toFormId = MagicHandleFormUtils.getProviderFormId(${doubleQuote}${businessId}${doubleQuote}, ${doubleQuote}${versionId}${doubleQuote}, ${doubleQuote}${methodName}${doubleQuote});;
        FormBean toFormBean = cap4FormCacheManager.getForm(toFormId);
        if (toFormBean == null || !cap4FormCacheManager.isEnabled(toFormBean)) {
            ${returnEntityName} data = new ${returnEntityName}();
            data.setSuccess(0);
            data.setMsg(${doubleQuote}无法找到表单ID为 ${doubleQuote} +toFormId +${doubleQuote}的表单${doubleQuote} );
            
            result.add(data);
            return result;
        }
        CtpTemplate ctpTemplate = null;
        try {
            template =MagicHandleFormUtils.getRealityTempalte(${doubleQuote}${businessId}${doubleQuote}, ${doubleQuote}${versionId}${doubleQuote}, ${doubleQuote}${methodName}${doubleQuote},template);
            ctpTemplate = templateManager.getCtpTemplate(template);
        } catch (BusinessException e2) {
            ${returnEntityName} data = new ${returnEntityName}();
            data.setSuccess(0);
            data.setMsg(${doubleQuote}表单名 ${doubleQuote} +toFormBean.getFormName() +${doubleQuote}获取模版异常;${doubleQuote} +e2.getLocalizedMessage());
            
            result.add(data);
            return result;
        }

        if (null == ctpTemplate || ctpTemplate.isDelete()) {
            ${returnEntityName} data = new ${returnEntityName}();
            data.setSuccess(0);
            data.setMsg(${doubleQuote}表单名 ${doubleQuote} +toFormBean.getFormName() +${doubleQuote}没有找到 模版ID= ${doubleQuote} + template +${doubleQuote}的模版${doubleQuote} );
            result.add(data);
            return result;
        }
        FormTableBean formTable = toFormBean.getMasterTableBean();
        List<FormDataMasterBean> masterBeans = new ArrayList<FormDataMasterBean>(formData.size());
        Long sourceDataId = 0L;
        Map<String, Map<Long, Set<Long>>> attachmentMap = new HashMap<String, Map<Long,Set<Long>>>();
        WorkflowApiManager wapi = (WorkflowApiManager) AppContext.getBean(${doubleQuote}wapi${doubleQuote});
        FormAuthViewBean authViewBean = null;
        try {
            String  operationId = FormUtil.parseOperationId(wapi.getNodeFormOperationName(ctpTemplate.getWorkflowId(), null));
            authViewBean = toFormBean.getAuthViewBeanById(Long.valueOf(operationId));
        } catch (BPMException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        Map<String, Map<String, Object>> toSub = new LinkedHashMap<String, Map<String, Object>>();
        Map<String, Object> toMain = new LinkedHashMap<String, Object>();
        context.addExtAttr(${doubleQuote}toSub${doubleQuote}, toSub);
        context.addExtAttr(${doubleQuote}toMain${doubleQuote}, toMain);
        String tableName = toFormBean.getMasterTableBean().getTableName();
        MagicProviderDefaultConvertor convertor = MagicProviderDefaultConvertor.getConvertor(${doubleQuote}${businessId}${doubleQuote}, ${doubleQuote}${versionId}${doubleQuote}, ${doubleQuote}${methodName}${doubleQuote});
        Map<String,String> formTableMapping =  MagicHandleFormUtils.getFormTableMapping(${doubleQuote}${businessId}${doubleQuote}, ${doubleQuote}${versionId}${doubleQuote}, ${doubleQuote}${methodName}${doubleQuote},true);
        for (${formDataEntityName} temp : formData) {
            Long createUser =Long.parseLong(temp.getCreateUserId());
            sourceDataId = Long.parseLong(temp.getSourceDataId().toString());
            FormDataMasterBean datamasterBean = new FormDataMasterBean(formTable, true);
            Map<String, Object> valueMap = new HashMap<String, Object>();
            valueMap.put(Enums.MasterTableField.start_member_id.getKey(), createUser);
            valueMap.put(Enums.MasterTableField.modify_member_id.getKey(), createUser);
            valueMap.put(Enums.MasterTableField.start_date.getKey(), DateUtil.currentTimestamp());
            valueMap.put(Enums.MasterTableField.state.getKey(), Enums.FormDataStateEnum.FLOW_UNOFFICIAL.getKey());// 先将数据的状态设置为非正式数据-2，校验通过后再设置为正式1
            datamasterBean.addFieldValue(valueMap);
            toMain.put(String.valueOf(sourceDataId), tableName + ${doubleQuote},${doubleQuote} + datamasterBean.getId());
            List<String> fillSubTables = new ArrayList<String>();
            ${assignDataContent}
            try {
                List<FormTableBean> allSubTableBean = toFormBean.getSubTableBean();
                FormDataSubBean subBean;
                if (Strings.isNotEmpty(allSubTableBean)) {
                    for (FormTableBean subTableBean : allSubTableBean) {
                        if (fillSubTables.contains(subTableBean.getTableName())) {
                            continue;
                        }
                        FormTriggerUtil.deleteNullSubData(subTableBean.getTableName(), datamasterBean, false);
                        subBean = new FormDataSubBean(subTableBean, datamasterBean, true);
                        // TODO 需要处理初始值
                        subBean.setFormmainId(datamasterBean.getId());
                        datamasterBean.addSubData(subTableBean.getTableName(), subBean);
                    }

                }
                MagicHandleFormUtils.dealOtherInfoBeforeValidate(toFormBean, datamasterBean, authViewBean, null, true);
            } catch (BusinessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            masterBeans.add(datamasterBean);
        }
        List<Map<String, Object>> saveReult = MagicHandleFormUtils.saveFlowDataBean(context, masterBeans, toFormBean,
                ctpTemplate, sourceDataId,attachmentMap);
        if (saveReult != null && !saveReult.isEmpty()) {
            for (Map<String, Object> temp : saveReult) {
                ${returnEntityName} d = new ${returnEntityName}();
                d.setDataId(ParamUtil.getLong(temp, ${doubleQuote}dataId${doubleQuote}, 0L));
                d.setSuccess(ParamUtil.getInt(temp, ${doubleQuote}success${doubleQuote}, 0));
                d.setMsg(ParamUtil.getString(temp, ${doubleQuote}msg${doubleQuote}));
                result.add(d);
            }

        }
        return result;