コード例 #1
0
ファイル: app.go プロジェクト: hongjinqiu/finance
func (c App) MenuList() revel.Result {
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	_, db := global.GetConnection(sessionId)
	menuResultLi := []map[string]interface{}{}
	err := db.C("Menu").Find(nil).Sort("level").All(&menuResultLi)
	if err != nil {
		panic(err)
	}

	menuLi := []map[string]interface{}{}
	for _, item := range menuResultLi {
		level := fmt.Sprint(item["level"])
		if len(level) == 3 {
			menuLi = append(menuLi, item)

			subMenuLi := []map[string]interface{}{}
			for _, subItem := range menuResultLi {
				subLevel := fmt.Sprint(subItem["level"])
				if len(subLevel) == 6 && subLevel[0:3] == level {
					subMenuLi = append(subMenuLi, subItem)
				}
			}
			item["subMenuLi"] = subMenuLi
		}
	}

	result := map[string]interface{}{
		"menuLi": menuLi,
	}
	return c.Render(result)
}
コード例 #2
0
ファイル: admin.go プロジェクト: hongjinqiu/finance
func (c Hjq) Login() revel.Result {
	if strings.ToLower(c.Request.Method) == "get" {
		//c.Response.ContentType = "text/html; charset=utf-8"
		return c.Render()
	}
	username := c.Params.Get("username")
	password := c.Params.Get("password")

	hash := sha1.New()
	_, err := io.WriteString(hash, password)
	if err != nil {
		panic(err)
	}
	encryPassword := fmt.Sprintf("%x", hash.Sum(nil))

	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	session, _ := global.GetConnection(sessionId)
	qb := QuerySupport{}
	user, found := qb.FindByMapWithSession(session, "SysUser", map[string]interface{}{
		"A.type":     1,
		"A.name":     username,
		"A.password": encryPassword,
	})
	if !found {
		c.Response.ContentType = "text/plain; charset=utf-8"
		return c.RenderText("用户名密码错误")
	}
	c.Session["adminUserId"] = fmt.Sprint(user["id"])
	c.Session["userId"] = fmt.Sprint(user["id"])

	return c.Redirect("/console/listschema?@name=LastSessionData&cookie=false")
}
コード例 #3
0
ファイル: console.go プロジェクト: hongjinqiu/finance
func (c Console) Relation() revel.Result {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)

	selectorId := c.Params.Get("selectorId")
	id := c.Params.Get("id")

	templateManager := TemplateManager{}
	relationLi := []map[string]interface{}{
		map[string]interface{}{
			"selectorId": selectorId,
			"relationId": id,
		},
	}
	relationBo := templateManager.GetRelationBo(sessionId, relationLi)
	var result interface{} = nil
	var url interface{} = nil
	if relationBo[selectorId] != nil {
		selRelationBo := relationBo[selectorId].(map[string]interface{})
		if selRelationBo[id] != nil {
			result = selRelationBo[id]
			url = selRelationBo["url"]
		}
	}
	c.Response.ContentType = "application/json; charset=utf-8"
	return c.RenderJson(map[string]interface{}{
		"result": result,
		"url":    url,
	})
}
コード例 #4
0
ファイル: basedataaction.go プロジェクト: hongjinqiu/finance
func (c BaseDataAction) RCopyDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	dataSourceModelId := c.Params.Get("dataSourceModelId")
	formTemplateId := c.Params.Get("formTemplateId")
	strId := c.Params.Get("id")
	id, err := strconv.Atoi(strId)
	if err != nil {
		panic(err)
	}

	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id": id,
	}
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	srcBo, found := querySupport.FindByMap(collectionName, queryMap)
	if !found {
		panic("CopyData, dataSouceModelId=" + dataSourceModelId + ", id=" + strId + " not found")
	}

	modelTemplateFactory.ConvertDataType(dataSource, &srcBo)
	c.RActionSupport.RBeforeCopyData(sessionId, dataSource, formTemplate, srcBo)
	dataSource, bo := modelTemplateFactory.GetCopyInstance(dataSourceModelId, srcBo)
	c.RActionSupport.RAfterCopyData(sessionId, dataSource, formTemplate, &bo)

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:       userId,
		Bo:           bo,
		RelationBo:   relationBo,
		DataSource:   dataSource,
		FormTemplate: formTemplate,
	}
}
コード例 #5
0
func (o ProgramDictionaryManager) GetProgramDictionary(code string) map[string]interface{} {
	mongoDBFactory := mongo.GetInstance()
	session, db := mongoDBFactory.GetConnection()
	defer session.Close()
	
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)
	
	return o.GetProgramDictionaryBySession(sessionId, db, code)
}
コード例 #6
0
ファイル: Layer.go プロジェクト: hongjinqiu/finance
func (o LayerManager) GetLayer(code string) map[string]interface{} {
	connectionFactory := mongo.GetInstance()
	session, db := connectionFactory.GetConnection()
	defer session.Close()

	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	return o.GetLayerBySession(sessionId, db, code)
}
コード例 #7
0
ファイル: component.go プロジェクト: hongjinqiu/finance
func (c Component) SchemaQueryParameterTest() revel.Result {
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	file, err := os.Open(`/home/hongjinqiu/goworkspace/src/finance/app/src/com/papersns/component/schema/SysUser.xml`)
	defer file.Close()
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	data, err := ioutil.ReadAll(file)
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	listTemplate := ListTemplate{}
	err = xml.Unmarshal(data, &listTemplate)
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	// 1.query data,
	// from data-provider
	// from query-parameters
	templateManager := TemplateManager{}
	paramMap := map[string]string{}
	{
		//		paramMap["nick"] = "abc"
		//		paramMap["dept_id"] = "2"
		//		paramMap["type"] = "0,1,2.5,3.5,abc"
		//		paramMap["createTimeBegin"] = "2013-05-07"
		//		paramMap["createTimeEnd"] = "2014-06-03"
	}
	pageNo := 1
	pageSize := 10
	queryResult := templateManager.QueryDataForListTemplate(sessionId, &listTemplate, paramMap, pageNo, pageSize)
	items := queryResult["items"].([]interface{})
	if len(items) > 1 {
		queryResult["items"] = items[:1]
	}

	jsonByte, err := json.MarshalIndent(queryResult, "", "\t")
	if err != nil {
		panic(err)
	}

	c.Response.Status = http.StatusOK
	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText(string(jsonByte))
}
コード例 #8
0
ファイル: component.go プロジェクト: hongjinqiu/finance
func (c Component) GetColumnModelDataForListTemplate() revel.Result {
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	file, err := os.Open(`/home/hongjinqiu/goworkspace/src/finance/app/src/com/papersns/component/schema/SysUser.xml`)
	defer file.Close()
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	data, err := ioutil.ReadAll(file)
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	listTemplate := ListTemplate{}
	err = xml.Unmarshal(data, &listTemplate)
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	templateManager := TemplateManager{}
	paramMap := map[string]string{}
	pageNo := 1
	pageSize := 10
	queryResult := templateManager.QueryDataForListTemplate(sessionId, &listTemplate, paramMap, pageNo, pageSize)
	items := queryResult["items"].([]interface{})
	if len(items) > 1 {
		queryResult["items"] = items[:1]
	}

	columnResult := templateManager.GetColumnModelDataForListTemplate(sessionId, listTemplate, items[:1])
	resultItems := columnResult["items"].([]interface{})
	jsonByte, err := json.MarshalIndent(resultItems, "", "\t")
	if err != nil {
		panic(err)
	}

	c.Response.Status = http.StatusOK
	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText(string(jsonByte))
}
コード例 #9
0
ファイル: app.go プロジェクト: hongjinqiu/finance
func (c App) StepTest() revel.Result {
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	_, db := global.GetConnection(sessionId)
	stepLi := []interface{}{}
	err := db.C("SysStep").Find(map[string]interface{}{
		"A.sysUnitId": 1,
		"A.status":    1,
	}).Sort("A.type").All(&stepLi)
	if err != nil {
		panic(err)
	}
	c.RenderArgs["result"] = map[string]interface{}{
		"stepLi": stepLi,
	}
	//c.Response.ContentType = "text/html; charset=utf-8"
	return c.RenderTemplate("Step/Step.html")
}
コード例 #10
0
ファイル: app.go プロジェクト: hongjinqiu/finance
func (c App) Step() revel.Result {
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}
	sysUser := map[string]interface{}{}
	_, db := global.GetConnection(sessionId)
	err = db.C("SysUser").Find(map[string]interface{}{
		"id": userId,
	}).One(&sysUser)
	sysUserMain := sysUser["A"].(map[string]interface{})

	maxStep := map[string]interface{}{}
	err = db.C("SysStep").Find(map[string]interface{}{
		"A.sysUnitId": sysUserMain["createUnit"],
	}).Sort("-A.type").Limit(1).One(&maxStep)
	if err != nil {
		panic(err)
	}

	currentStep := map[string]interface{}{}
	err = db.C("SysStep").Find(map[string]interface{}{
		"A.sysUnitId": sysUserMain["createUnit"],
		"A.status":    1,
	}).Sort("A.type").Limit(1).One(&currentStep)
	currentId := 0
	maxStepMain := maxStep["A"].(map[string]interface{})
	if err != nil {
		currentId = CommonUtil{}.GetIntFromMap(maxStepMain, "type") + 1
	} else {
		currentStepMain := currentStep["A"].(map[string]interface{})
		currentId = CommonUtil{}.GetIntFromMap(currentStepMain, "type")
	}
	response := map[string]interface{}{
		"maxId":     maxStepMain["type"],
		"currentId": currentId,
	}
	return c.RenderJson(response)
}
コード例 #11
0
ファイル: console.go プロジェクト: hongjinqiu/finance
// 管理员查看页面,设置session.userId,以查看数据,
func (c Console) BbsPostAdminReplySchema() revel.Result {
	// 取一下bbsPostId

	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	schemaName := c.Params.Get("@name")

	templateManager := TemplateManager{}
	listTemplate := templateManager.GetListTemplate(schemaName)

	isFromList := true
	result := c.listSelectorCommon(&listTemplate, true, isFromList)
	bbsPostIdStr := c.Params.Get("bbsPostId")
	bbsPostId, err := strconv.Atoi(bbsPostIdStr)
	if err != nil {
		panic(err)
	}
	c.addOrUpdateBbsPostRead(sessionId, bbsPostId)
	c.CommitTxn(sessionId)

	format := c.Params.Get("format")
	if strings.ToLower(format) == "json" {
		callback := c.Params.Get("callback")
		if callback == "" {
			dataBo := result["dataBo"]
			c.Response.ContentType = "application/json; charset=utf-8"
			return c.RenderJson(&dataBo)
		}
		dataBoText := result["dataBoText"].(string)
		c.Response.ContentType = "text/javascript; charset=utf-8"
		return c.RenderText(callback + "(" + dataBoText + ");")
	} else {
		//c.Response.ContentType = "text/html; charset=utf-8"
		c.RenderArgs["result"] = result
		return c.RenderTemplate(listTemplate.ViewTemplate.View)
		//		return c.Render(result)
	}
}
コード例 #12
0
ファイル: basedataaction.go プロジェクト: hongjinqiu/finance
func (c BaseDataAction) RNewDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	dataSourceModelId := c.Params.Get("dataSourceModelId")
	formTemplateId := c.Params.Get("formTemplateId")
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	c.RActionSupport.RBeforeNewData(sessionId, dataSource, formTemplate)
	bo := modelTemplateFactory.GetInstanceByDS(dataSource)
	c.RActionSupport.RAfterNewData(sessionId, dataSource, formTemplate, &bo)

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	modelTemplateFactory.ClearReverseRelation(&dataSource)

	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:       userId,
		Bo:           bo,
		RelationBo:   relationBo,
		DataSource:   dataSource,
		FormTemplate: formTemplate,
	}
}
コード例 #13
0
ファイル: StepService.go プロジェクト: hongjinqiu/finance
func (o StepService) Run(sysUser map[string]interface{}) {
	sysUserManster := sysUser["A"].(map[string]interface{})
	sysUnitId := CommonUtil{}.GetIntFromMap(sysUserManster, "createUnit")
	// 加锁
	lockService := LockService{}
	unitLock := lockService.GetUnitLock(fmt.Sprint(sysUnitId))
	(*unitLock).Lock()
	defer (*unitLock).Unlock()

	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)
	defer global.RollbackTxn(sessionId)

	txnId := global.GetTxnId(sessionId)
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	stepLi := []map[string]interface{}{}
	err := db.C("SysStep").Find(map[string]interface{}{
		"A.sysUnitId": sysUnitId,
	}).Sort("A.type").All(&stepLi)
	if err != nil {
		panic(err)
	}

	for _, item := range stepLi {
		master := item["A"].(map[string]interface{})
		item["A"] = master

		status := fmt.Sprint(master["status"])
		if status == "1" { // 未开始
			stepType := fmt.Sprint(master["type"])
			if stepType == "3" { //初始化供应商类别
				o.InitProviderType(sessionId, sysUser)
			} else if stepType == "5" { //初始化币别
				o.InitCurrencyType(sessionId, sysUser)
			} else if stepType == "6" { //初始化银行资料
				o.InitBank(sessionId, sysUser)
			} else if stepType == "7" { //初始化计量单位
				o.InitMeasureUnit(sessionId, sysUser)
			} else if stepType == "9" { //初始化客户类别
				o.InitCustomerType(sessionId, sysUser)
			} else if stepType == "12" { //初始化税率类别
				o.InitTaxType(sessionId, sysUser)
			} else if stepType == "14" { //初始化收入费用类别
				o.InitIncomeType(sessionId, sysUser)
			} else if stepType == "15" { //初始化收入费用项目
				o.InitIncomeItem(sessionId, sysUser)
			} else if stepType == "16" { //初始化会计期
				o.InitAccountingPeriod(sessionId, sysUser)
			} else if stepType == "18" { //初始化收款单类型参数
				o.InitBillReceiveTypeParameter(sessionId, sysUser)
			} else if stepType == "19" { //初始化付款单类型参数
				o.InitBillPaymentTypeParameter(sessionId, sysUser)
			} else if stepType == "20" { //初始化系统参数
				o.InitSystemParameter(sessionId, sysUser)
			}
		}
		master["status"] = 2
		_, updateResult := txnManager.Update(txnId, "SysStep", item)
		if !updateResult {
			panic(BusinessError{Message: "更新SysStep" + fmt.Sprint(master["name"]) + "失败"})
		}
	}

	global.CommitTxn(sessionId)
}
コード例 #14
0
func (c AccountInOutDisplay) RGetDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	dataSourceModelId := c.Params.Get("dataSourceModelId")
	formTemplateId := c.Params.Get("formTemplateId")
	jsonData := c.Params.Get("jsonData")

	jsonMap := map[string]interface{}{}
	err = json.Unmarshal([]byte(jsonData), &jsonMap)
	if err != nil {
		panic(err)
	}
	queryMap := jsonMap["A"].(map[string]interface{})

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	accountLi := c.getAccountList(sessionId, formTemplate, queryMap)
	origBalanceLi := c.getOrigBalanceList(sessionId, formTemplate, queryMap)
	increaseReduceBalanceLi := c.getIncreaseReduceBalanceList(sessionId, formTemplate, queryMap)

	dataSetLi := c.mergeAndCalceFinalBalance(accountLi, origBalanceLi, increaseReduceBalanceLi)
	dataSetLi = c.filterEmpty(dataSetLi, queryMap)

	bo := map[string]interface{}{
		"_id": 0,
		"id":  0,
		"A": map[string]interface{}{
			"id": 0,
		},
		"B": dataSetLi,
	}

	//	usedCheck := UsedCheck{}
	//	usedCheckBo := usedCheck.GetFormUsedCheck(sessionId, dataSource, bo)
	usedCheckBo := map[string]interface{}{}

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	modelTemplateFactory.ConvertDataType(dataSource, &bo)

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	return ModelRenderVO{
		UserId:      userId,
		Bo:          bo,
		RelationBo:  relationBo,
		UsedCheckBo: usedCheckBo,
		DataSource:  dataSource,
	}
}
コード例 #15
0
ファイル: console.go プロジェクト: hongjinqiu/finance
func (c Console) Summary() revel.Result {
	println("session is:", c.Session["userId"])
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)

	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate("Console")

	//	if true {
	//		xmlDataArray, err := xml.Marshal(&formTemplate)
	//		if err != nil {
	//			panic(err)
	//		}
	//		return c.RenderXml(&formTemplate)
	//	}

	formTemplateJsonDataArray, err := json.Marshal(&formTemplate)
	if err != nil {
		panic(err)
	}

	toolbarBo := map[string]interface{}{}

	dataBo := map[string]interface{}{}
	{
		listTemplateInfoLi := templateManager.GetListTemplateInfoLi()
		dataBo["Component"] = getSummaryListTemplateInfoLi(listTemplateInfoLi)
	}
	{
		selectorTemplateInfoLi := templateManager.GetSelectorTemplateInfoLi()
		dataBo["Selector"] = getSummarySelectorTemplateInfoLi(selectorTemplateInfoLi)
	}
	{
		formTemplateInfoLi := templateManager.GetFormTemplateInfoLi()
		dataBo["Form"] = getSummaryFormTemplateInfoLi(formTemplateInfoLi)
	}
	{
		modelTemplateFactory := ModelTemplateFactory{}
		dataSourceInfoLi := modelTemplateFactory.GetDataSourceInfoLi()
		dataBo["DataSource"] = getSummaryDataSourceInfoLi(dataSourceInfoLi)
	}
	for _, item := range formTemplate.FormElemLi {
		if item.XMLName.Local == "column-model" {
			if dataBo[item.ColumnModel.Name] == nil {
				dataBo[item.ColumnModel.Name] = []interface{}{}
			}
			items := dataBo[item.ColumnModel.Name].([]interface{})
			itemsDict := templateManager.GetColumnModelDataForColumnModel(sessionId, item.ColumnModel, items)
			items = itemsDict["items"].([]interface{})
			dataBo[item.ColumnModel.Name] = items
		} else if item.XMLName.Local == "toolbar" {
			toolbarBo[item.Toolbar.Name] = templateManager.GetToolbarBo(item.Toolbar)
		}
	}

	dataBoByte, err := json.Marshal(dataBo)
	if err != nil {
		panic(err)
	}

	//	c.Response.Status = http.StatusOK
	//	c.Response.ContentType = "text/plain; charset=utf-8"
	result := map[string]interface{}{
		"formTemplate":         formTemplate,
		"toolbarBo":            toolbarBo,
		"dataBo":               dataBo,
		"formTemplateJsonData": template.JS(string(formTemplateJsonDataArray)),
		"dataBoJson":           template.JS(string(dataBoByte)),
	}
	// formTemplate.ViewTemplate.View
	//	RenderText(text string, objs ...interface{}) Result

	viewPath := revel.Config.StringDefault("REVEL_VIEW_PATH", "")
	file, err := os.Open(viewPath + "/" + formTemplate.ViewTemplate.View)
	defer file.Close()
	if err != nil {
		panic(err)
	}

	fileContent, err := ioutil.ReadAll(file)
	if err != nil {
		panic(err)
	}
	//	c.Response.Out
	//	return c.RenderTemplate(string(fileContent))
	funcMap := map[string]interface{}{
		"eq": func(a, b interface{}) bool {
			return a == b
		},
	}
	//c.Response.ContentType = "text/html; charset=utf-8"
	tmpl, err := template.New("summary").Funcs(funcMap).Parse(string(fileContent))
	if err != nil {
		panic(err)
	}
	tmplResult := map[string]interface{}{
		"result": result,
	}
	//tmpl.Execute(c.Response.Out, result)
	tmpl.Execute(c.Response.Out, tmplResult)
	return nil
	//	return c.Render(string(fileContent), result)
}
コード例 #16
0
ファイル: console.go プロジェクト: hongjinqiu/finance
func (c Console) listSelectorCommon(listTemplate *ListTemplate, isGetBo bool, isFromList bool) map[string]interface{} {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)

	// 1.toolbar bo
	templateManager := TemplateManager{}
	//templateManager.ApplyDictionaryForQueryParameter(listTemplate)
	//templateManager.ApplyTreeForQueryParameter(listTemplate)
	toolbarBo := templateManager.GetToolbarForListTemplate(*listTemplate)
	paramMap := map[string]string{}

	defaultBo := templateManager.GetQueryDefaultValue(*listTemplate)
	defaultBoByte, err := json.Marshal(&defaultBo)
	if err != nil {
		panic(err)
	}
	for key, value := range defaultBo {
		paramMap[key] = value
	}
	paramMap, _ = c.getCookieDataAndParamMap(sessionId, *listTemplate, isFromList, paramMap)

	formDataByte, err := json.Marshal(&paramMap)
	if err != nil {
		panic(err)
	}

	//	}
	pageNo := 1
	pageSize := 10
	if listTemplate.DataProvider.Size != "" {
		pageSizeInt, err := strconv.Atoi(listTemplate.DataProvider.Size)
		if err != nil {
			panic(err)
		}
		pageSize = pageSizeInt
	}
	if c.Params.Get("pageNo") != "" {
		pageNoInt, _ := strconv.ParseInt(c.Params.Get("pageNo"), 10, 0)
		if pageNoInt > 1 {
			pageNo = int(pageNoInt)
		}
	}
	if c.Params.Get("pageSize") != "" {
		pageSizeInt, _ := strconv.ParseInt(c.Params.Get("pageSize"), 10, 0)
		if pageSizeInt >= 10 {
			pageSize = int(pageSizeInt)
		}
	}
	dataBo := map[string]interface{}{
		"totalResults": 0,
		"items":        []interface{}{},
	}
	relationBo := map[string]interface{}{}
	usedCheckBo := map[string]interface{}{}
	//if c.Params.Get("@entrance") != "true" {
	if isGetBo {
		dataBo = templateManager.GetBoForListTemplate(sessionId, listTemplate, paramMap, pageNo, pageSize)
		relationBo = dataBo["relationBo"].(map[string]interface{})
		//delete(dataBo, "relationBo")

		// usedCheck的修改,
		if listTemplate.DataSourceModelId != "" {
			modelTemplateFactory := ModelTemplateFactory{}
			dataSource := modelTemplateFactory.GetDataSource(listTemplate.DataSourceModelId)
			items := dataBo["items"].([]interface{})
			usedCheck := UsedCheck{}

			usedCheckBo = usedCheck.GetListUsedCheck(sessionId, dataSource, items, listTemplate.ColumnModel.DataSetId)
		}
	}
	dataBo["usedCheckBo"] = usedCheckBo

	dataBoByte, err := json.Marshal(&dataBo)
	if err != nil {
		panic(err)
	}

	relationBoByte, err := json.Marshal(&relationBo)
	if err != nil {
		panic(err)
	}

	listTemplateByte, err := json.Marshal(listTemplate)
	if err != nil {
		panic(err)
	}

	usedCheckByte, err := json.Marshal(&usedCheckBo)
	if err != nil {
		panic(err)
	}

	// 系统参数的获取
	commonUtil := CommonUtil{}
	userId := commonUtil.GetIntFromString(c.Session["userId"])
	sysParam := c.getSysParam(sessionId, userId)
	sysParamJson, err := json.Marshal(&sysParam)
	if err != nil {
		panic(err)
	}

	queryParameterRenderLi := c.getQueryParameterRenderLi(*listTemplate)

	//showParameterLi := templateManager.GetShowParameterLiForListTemplate(listTemplate)
	showParameterLi := []QueryParameter{}
	hiddenParameterLi := templateManager.GetHiddenParameterLiForListTemplate(listTemplate)

	layerBo := templateManager.GetLayerForListTemplate(sessionId, *listTemplate)
	iLayerBo := layerBo["layerBo"]
	layerBoByte, err := json.Marshal(&iLayerBo)
	if err != nil {
		panic(err)
	}
	iLayerBoLi := layerBo["layerBoLi"]
	layerBoLiByte, err := json.Marshal(&iLayerBoLi)
	if err != nil {
		panic(err)
	}
	layerBoJson := string(layerBoByte)
	layerBoJson = commonUtil.FilterJsonEmptyAttr(layerBoJson)
	layerBoLiJson := string(layerBoLiByte)
	layerBoLiJson = commonUtil.FilterJsonEmptyAttr(layerBoLiJson)

	result := map[string]interface{}{
		"pageSize":               pageSize,
		"listTemplate":           listTemplate,
		"toolbarBo":              toolbarBo,
		"showParameterLi":        showParameterLi,
		"hiddenParameterLi":      hiddenParameterLi,
		"queryParameterRenderLi": queryParameterRenderLi,
		"dataBo":                 dataBo,
		//		"columns":       columns,
		"dataBoText":       string(dataBoByte),
		"dataBoJson":       template.JS(string(dataBoByte)),
		"relationBoJson":   template.JS(string(relationBoByte)),
		"listTemplateJson": template.JS(string(listTemplateByte)),
		"layerBoJson":      template.JS(layerBoJson),
		"layerBoLiJson":    template.JS(layerBoLiJson),
		"defaultBoJson":    template.JS(string(defaultBoByte)),
		"formDataJson":     template.JS(string(formDataByte)),
		"usedCheckJson":    template.JS(string(usedCheckByte)),
		"sysParamJson":     template.JS(string(sysParamJson)),
		//		"columnsJson":   string(columnsByte),
	}
	return result
}
コード例 #17
0
ファイル: console.go プロジェクト: hongjinqiu/finance
func (c Console) SelectorSchema() revel.Result {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)

	schemaName := c.Params.Get("@name")

	templateManager := TemplateManager{}
	listTemplate := templateManager.GetSelectorTemplate(schemaName)
	c.setSelectionMode(&listTemplate)
	c.setDisplayField(&listTemplate)
	isGetBo := false
	if c.Params.Get("format") != "" {
		isGetBo = true
	}
	isFromList := false
	result := c.listSelectorCommon(&listTemplate, isGetBo, isFromList)

	selectionBo := map[string]interface{}{
		"url":         templateManager.GetViewUrl(listTemplate),
		"Description": listTemplate.Description,
	}
	ids := c.Params.Get("@id")
	if ids != "" {
		relationLi := []map[string]interface{}{}
		strIdLi := strings.Split(ids, ",")
		selectorId := listTemplate.SelectorId
		if selectorId == "" {
			selectorId = listTemplate.Id
		}
		for _, item := range strIdLi {
			if item != "" {
				id, err := strconv.Atoi(item)
				if err != nil {
					panic(err)
				}
				relationLi = append(relationLi, map[string]interface{}{
					"relationId": id,
					"selectorId": selectorId,
				})
			}
		}
		templateManager := TemplateManager{}
		relationBo := templateManager.GetRelationBo(sessionId, relationLi)
		if relationBo[selectorId] != nil {
			selectionBo = relationBo[selectorId].(map[string]interface{})
		}
	}
	selectionBoByte, err := json.Marshal(&selectionBo)
	if err != nil {
		panic(err)
	}

	commonUtil := CommonUtil{}
	selectionBoJson := string(selectionBoByte)
	selectionBoJson = commonUtil.FilterJsonEmptyAttr(selectionBoJson)
	result["selectionBoJson"] = template.JS(selectionBoJson)

	format := c.Params.Get("format")
	if strings.ToLower(format) == "json" {
		callback := c.Params.Get("callback")
		if callback == "" {
			dataBo := result["dataBo"]
			c.Response.ContentType = "application/json; charset=utf-8"
			return c.RenderJson(&dataBo)
		}
		dataBoText := result["dataBoText"].(string)
		c.Response.ContentType = "text/javascript; charset=utf-8"
		return c.RenderText(callback + "(" + dataBoText + ");")
	} else {
		//		return c.Render(result)
		//c.Response.ContentType = "text/html; charset=utf-8"
		c.RenderArgs["result"] = result
		return c.RenderTemplate(listTemplate.ViewTemplate.SelectorView)
	}
}
コード例 #18
0
ファイル: console.go プロジェクト: hongjinqiu/finance
// TODO,by test
func (c Console) FormSchema() revel.Result {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)

	schemaName := c.Params.Get("@name")
	strId := c.Params.Get("id")
	formStatus := c.Params.Get("formStatus")
	copyFlag := c.Params.Get("copyFlag")

	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(schemaName)

	result := map[string]interface{}{
		"formTemplate": formTemplate,
		"id":           strId,
		"formStatus":   formStatus,
		"copyFlag":     copyFlag,
	}
	if formTemplate.DataSourceModelId != "" {
		// 光有formTemplate不行,还要有model的内容,才可以渲染数据
		modelTemplateFactory := ModelTemplateFactory{}
		dataSource := modelTemplateFactory.GetDataSource(formTemplate.DataSourceModelId)
		modelTemplateFactory.ClearReverseRelation(&dataSource)
		dataSourceByte, err := json.Marshal(&dataSource)
		if err != nil {
			panic(err)
		}
		result["dataSource"] = dataSource
		commonUtil := CommonUtil{}
		dataSourceJson := string(dataSourceByte)
		dataSourceJson = commonUtil.FilterJsonEmptyAttr(dataSourceJson)
		result["dataSourceJson"] = template.JS(dataSourceJson)
	}
	//toolbarBo
	toolbarBo := map[string]interface{}{}
	for i, item := range formTemplate.FormElemLi {
		if item.XMLName.Local == "toolbar" {
			toolbarBo[item.Toolbar.Name] = templateManager.GetToolbarBo(item.Toolbar)
		}
		// 加入主数据集tag,页面渲染用
		if item.XMLName.Local == "column-model" && item.ColumnModel.DataSetId == "A" {
			formTemplate.FormElemLi[i].RenderTag = item.ColumnModel.DataSetId + "_" + fmt.Sprint(i)
		}
	}
	result["toolbarBo"] = toolbarBo
	dataBo := map[string]interface{}{}
	relationBo := map[string]interface{}{}
	result["dataBo"] = dataBo
	result["relationBo"] = relationBo

	relationBoByte, err := json.Marshal(&relationBo)
	if err != nil {
		panic(err)
	}

	// 主数据集的后台渲染
	result["masterRenderLi"] = c.getMasterRenderLi(formTemplate)

	formTemplateJsonDataArray, err := json.Marshal(&formTemplate)
	if err != nil {
		panic(err)
	}

	dataBoByte, err := json.Marshal(&dataBo)
	if err != nil {
		panic(err)
	}

	layerBo := templateManager.GetLayerForFormTemplate(sessionId, formTemplate)
	iLayerBo := layerBo["layerBo"]
	layerBoByte, err := json.Marshal(&iLayerBo)
	if err != nil {
		panic(err)
	}
	iLayerBoLi := layerBo["layerBoLi"]
	layerBoLiByte, err := json.Marshal(&iLayerBoLi)
	if err != nil {
		panic(err)
	}

	commonUtil := CommonUtil{}
	userId := commonUtil.GetIntFromString(c.Session["userId"])
	sysParam := c.getSysParam(sessionId, userId)
	sysParamJson, err := json.Marshal(&sysParam)
	if err != nil {
		panic(err)
	}
	result["sysParamJson"] = template.JS(string(sysParamJson))

	formTemplateJsonData := string(formTemplateJsonDataArray)
	formTemplateJsonData = commonUtil.FilterJsonEmptyAttr(formTemplateJsonData)
	result["formTemplateJsonData"] = template.JS(formTemplateJsonData)
	dataBoJson := string(dataBoByte)
	dataBoJson = commonUtil.FilterJsonEmptyAttr(dataBoJson)
	result["dataBoJson"] = template.JS(dataBoJson)
	layerBoJson := string(layerBoByte)
	layerBoJson = commonUtil.FilterJsonEmptyAttr(layerBoJson)
	result["layerBoJson"] = template.JS(layerBoJson)
	layerBoLiJson := string(layerBoLiByte)
	layerBoLiJson = commonUtil.FilterJsonEmptyAttr(layerBoLiJson)
	result["layerBoLiJson"] = template.JS(layerBoLiJson)
	relationBoJson := string(relationBoByte)
	relationBoJson = commonUtil.FilterJsonEmptyAttr(relationBoJson)
	result["relationBoJson"] = template.JS(relationBoJson)

	viewPath := revel.Config.StringDefault("REVEL_VIEW_PATH", "")
	file, err := os.Open(viewPath + "/" + formTemplate.ViewTemplate.View)
	defer file.Close()
	if err != nil {
		panic(err)
	}

	fileContent, err := ioutil.ReadAll(file)
	if err != nil {
		panic(err)
	}
	funcMap := map[string]interface{}{
		"eq": func(a, b interface{}) bool {
			return a == b
		},
	}
	//c.Response.ContentType = "text/html; charset=utf-8"
	tmpl, err := template.New("formSchema").Funcs(funcMap).Parse(string(fileContent))
	if err != nil {
		panic(err)
	}
	tmplResult := map[string]interface{}{
		"result":  result,
		"flash":   c.Flash.Out,
		"session": c.Session,
	}
	tmpl.Execute(c.Response.Out, tmplResult)
	return nil
}
コード例 #19
0
ファイル: component.go プロジェクト: hongjinqiu/finance
func (c Component) ListTemplate() revel.Result {
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)

	file, err := os.Open("/home/hongjinqiu/goworkspace/src/finance/app/src/com/papersns/component/schema/SysUser.xml")
	defer file.Close()
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	data, err := ioutil.ReadAll(file)
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	listTemplate := ListTemplate{}
	err = xml.Unmarshal(data, &listTemplate)
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	// 1.toolbar bo
	templateManager := TemplateManager{}
	//	templateManager.ApplyDictionaryForQueryParameter(&listTemplate)
	//	templateManager.ApplyTreeForQueryParameter(&listTemplate)
	toolbarBo := templateManager.GetToolbarForListTemplate(listTemplate)
	paramMap := map[string]string{}
	for k, v := range c.Params.Form {
		value := strings.Join(v, ",")
		if value != "" {
			paramMap[k] = value
		}
	}
	pageNo := 1
	pageSize := 10
	if listTemplate.DataProvider.Size != "" {
		pageSizeInt, err := strconv.Atoi(listTemplate.DataProvider.Size)
		if err != nil {
			panic(err)
		}
		pageSize = pageSizeInt
	}
	if c.Params.Get("pageNo") != "" {
		pageNoInt, _ := strconv.ParseInt(c.Params.Get("pageNo"), 10, 0)
		if pageNoInt > 1 {
			pageNo = int(pageNoInt)
		}
	}
	if c.Params.Get("pageSize") != "" {
		pageSizeInt, _ := strconv.ParseInt(c.Params.Get("pageSize"), 10, 0)
		if pageSizeInt >= 10 {
			pageSize = int(pageSizeInt)
		}
	}
	dataBo := templateManager.GetBoForListTemplate(sessionId, &listTemplate, paramMap, pageNo, pageSize)

	//	columns := templateManager.GetColumns(&listTemplate)

	//	columnsByte, err := json.Marshal(columns)
	//	if err != nil {
	//		fmt.Printf("error: %v", err)
	//		return c.Render(err)
	//	}

	dataBoByte, err := json.Marshal(&dataBo)
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	listTemplateByte, err := json.Marshal(&listTemplate)
	if err != nil {
		fmt.Printf("error: %v", err)
		return c.Render(err)
	}

	format := c.Params.Get("format")
	if strings.ToLower(format) == "json" {
		callback := c.Params.Get("callback")
		if callback == "" {
			c.Response.ContentType = "application/json; charset=utf-8"
			return c.RenderJson(&dataBo)
		}
		c.Response.ContentType = "text/javascript; charset=utf-8"
		return c.RenderText(callback + "(" + string(dataBoByte) + ");")
	} else {
		showParameterLi := templateManager.GetShowParameterLiForListTemplate(&listTemplate)
		hiddenParameterLi := templateManager.GetHiddenParameterLiForListTemplate(&listTemplate)
		result := map[string]interface{}{
			"pageSize":          pageSize,
			"listTemplate":      listTemplate,
			"toolbarBo":         toolbarBo,
			"showParameterLi":   showParameterLi,
			"hiddenParameterLi": hiddenParameterLi,
			//		"dataBo":       dataBo,
			//		"columns":       columns,
			"dataBoJson":       template.JS(string(dataBoByte)),
			"listTemplateJson": template.JS(string(listTemplateByte)),
			//		"columnsJson":   string(columnsByte),
		}
		//c.Response.ContentType = "text/html; charset=utf-8"
		return c.Render(result)
	}
}
コード例 #20
0
ファイル: app.go プロジェクト: hongjinqiu/finance
/**
http://uhz001889.chinaw3.com/?myEnt=approval&code=BiWbZfjYoCIp4oRzo7rgRpUv243721&state=
*/
func (c App) Index() revel.Result {
	if c.Params.Query.Get("code") != "" {
		url := c.Request.URL.Path + "?" + c.Request.URL.RawQuery
		sessionId := global.GetSessionId()
		defer global.CloseSession(sessionId)
		defer global.RollbackTxn(sessionId)

		resStruct, userId, isStep := LoginService{}.DealLogin(sessionId, url)
		global.CommitTxn(sessionId)
		c.Session["userId"] = fmt.Sprint(userId)

		loginService := LoginService{}
		if isStep {
			qb := QuerySupport{}
			session, db := global.GetConnection(sessionId)
			user := qb.FindByMapWithSessionExact(session, "SysUser", map[string]interface{}{
				"id": userId,
			})
			userMain := user["A"].(map[string]interface{})
			appKey := fmt.Sprint(resStruct["app_key"])
			stepTypeLi := loginService.GetStepTypeLi(appKey)
			stepLi := []interface{}{}
			err := db.C("SysStep").Find(map[string]interface{}{
				"A.sysUnitId": userMain["createUnit"],
				"A.type": map[string]interface{}{
					"$in": stepTypeLi,
				},
			}).Sort("A.type").All(&stepLi)
			if err != nil {
				panic(err)
			}
			c.RenderArgs["result"] = map[string]interface{}{
				"stepLi": stepLi,
			}
			//c.Response.ContentType = "text/html; charset=utf-8"
			return c.RenderTemplate("Step/Step.html")
		} else {
			return c.Redirect("/")
		}
	}

	if c.Session["userId"] == "" {
		if strings.Index(c.Request.Header.Get("HTTP_REFERER"), "taobao") > -1 {
			taobaoPath := revel.Config.StringDefault("TAOBAO_PATH", "")
			return c.Redirect(taobaoPath)
		} else {
			c.Response.ContentType = "text/plain; charset=utf-8"
			return c.RenderText("会话过期,请您从淘宝重新登录应用!")
		}
	}
	// 取得菜单等数据,
	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}
	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)
	qb := QuerySupport{}
	session, _ := global.GetConnection(sessionId)
	user := qb.FindByMapWithSessionExact(session, "SysUser", map[string]interface{}{
		"id": userId,
	})

	// 获取数据,
	result := map[string]interface{}{
		"user":            user,
		"unit":            c.getSysUnit(sessionId, user),
		"menuLi":          c.getMenuLi(sessionId),
		"gatheringBillLi": c.getGatheringBillLi(sessionId, user),
		"payBillLi":       c.getPayBillLi(sessionId, user),
	}
	return c.Render(result)
}
コード例 #21
0
ファイル: billaction.go プロジェクト: hongjinqiu/finance
func (c BillAction) RUnCancelDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	dataSourceModelId := c.Params.Get("dataSourceModelId")
	formTemplateId := c.Params.Get("formTemplateId")
	strId := c.Params.Get("id")
	id, err := strconv.Atoi(strId)
	if err != nil {
		panic(err)
	}
	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id": id,
	}
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	bo, found := querySupport.FindByMap(collectionName, queryMap)
	if !found {
		panic("UnCancelData, dataSouceModelId=" + dataSourceModelId + ", id=" + strId + " not found")
	}

	c.setRequestParameterToBo(&bo)

	modelTemplateFactory.ConvertDataType(dataSource, &bo)
	c.RSetModifyFixFieldValue(sessionId, dataSource, &bo)
	c.RActionSupport.RBeforeUnCancelData(sessionId, dataSource, formTemplate, &bo)
	mainData := bo["A"].(map[string]interface{})
	if fmt.Sprint(mainData["billStatus"]) == "1" {
		panic(BusinessError{Message: "单据已经反作废,不可再次反作废"})
	}
	mainData["billStatus"] = 1

	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	_, updateResult := txnManager.Update(txnId, dataSourceModelId, bo)
	if !updateResult {
		panic("反作废失败")
	}

	c.RActionSupport.RAfterUnCancelData(sessionId, dataSource, formTemplate, &bo)

	bo, _ = querySupport.FindByMap(collectionName, queryMap)

	usedCheck := UsedCheck{}
	usedCheckBo := usedCheck.GetFormUsedCheck(sessionId, dataSource, bo)

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:       userId,
		Bo:           bo,
		RelationBo:   relationBo,
		UsedCheckBo:  usedCheckBo,
		DataSource:   dataSource,
		FormTemplate: formTemplate,
	}
}
コード例 #22
0
ファイル: basedataaction.go プロジェクト: hongjinqiu/finance
func (c BaseDataAction) RDeleteDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	dataSourceModelId := c.Params.Get("dataSourceModelId")
	formTemplateId := c.Params.Get("formTemplateId")
	strId := c.Params.Get("id")
	id, err := strconv.Atoi(strId)
	if err != nil {
		panic(err)
	}

	_, db := global.GetConnection(sessionId)
	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id": id,
	}
	formTemplate := FormTemplate{}
	if formTemplateId != "" {
		templateManager := TemplateManager{}
		formTemplate = templateManager.GetFormTemplate(formTemplateId)
	}
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	// 列表页也调用这个删除方法,但是列表页又没有传递formTemplateId,只有 gatheringBill等要做赤字判断,走与form相同的逻辑,才会传 formTemplateId,
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	bo, found := querySupport.FindByMap(collectionName, queryMap)
	if !found {
		panic("DeleteData, dataSouceModelId=" + dataSourceModelId + ", id=" + strId + " not found")
	}
	// 将客户端传入的各种参数写入,程序在业务方法before,after中有可能会用到
	c.setRequestParameterToBo(&bo)

	modelTemplateFactory.ConvertDataType(dataSource, &bo)
	c.RActionSupport.RBeforeDeleteData(sessionId, dataSource, formTemplate, &bo)

	usedCheck := UsedCheck{}
	if usedCheck.CheckUsed(sessionId, dataSource, bo) {
		panic(BusinessError{Message: "已被用,不能删除"})
	}

	modelIterator := ModelIterator{}
	var result interface{} = ""
	modelIterator.IterateDataBo(dataSource, &bo, &result, func(fieldGroupLi []FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
		//		if fieldGroupLi[0].IsMasterField() {
		usedCheck.DeleteAll(sessionId, fieldGroupLi, *data)
		//		}
	})

	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	_, removeResult := txnManager.Remove(txnId, dataSourceModelId, bo)
	if !removeResult {
		panic("删除失败")
	}

	c.RActionSupport.RAfterDeleteData(sessionId, dataSource, formTemplate, &bo)

	// 列表页也调用这个删除方法,但是列表页又没有传递formTemplateId
	relationBo := map[string]interface{}{}
	if formTemplateId != "" {
		templateManager := TemplateManager{}
		columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
		bo = columnModelData["bo"].(map[string]interface{})
		relationBo = columnModelData["relationBo"].(map[string]interface{})
	}

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:       userId,
		Bo:           bo,
		RelationBo:   relationBo,
		DataSource:   dataSource,
		FormTemplate: formTemplate,
	}
}
コード例 #23
0
func (c AccountingPeriod) renderCommon(modelRenderVO ModelRenderVO) revel.Result {
	bo := modelRenderVO.Bo
	relationBo := modelRenderVO.RelationBo
	dataSource := modelRenderVO.DataSource
	usedCheckBo := modelRenderVO.UsedCheckBo
	// 重新修改usedCheckBo,改为查询单据,只要在会计期内存在单据,则视为被用
	modelTemplateFactory := ModelTemplateFactory{}
	strId := modelTemplateFactory.GetStrId(bo)
	if strId != "" && strId != "0" {
		bDataSetLi := bo["B"].([]interface{})
		firstLineData := bDataSetLi[0].(map[string]interface{})
		lastLineData := bDataSetLi[len(bDataSetLi)-1].(map[string]interface{})

		commonUtil := CommonUtil{}
		firstStartDate := commonUtil.GetIntFromMap(firstLineData, "startDate")
		lastEndDate := commonUtil.GetIntFromMap(lastLineData, "endDate")

		qb := QuerySupport{}
		//GatheringBill,PayBill
		sessionId := global.GetSessionId()
		global.SetGlobalAttr(sessionId, "userId", fmt.Sprint(modelRenderVO.UserId))
		defer global.CloseSession(sessionId)
		session, _ := global.GetConnection(sessionId)

		queryMap := map[string]interface{}{
			"A.billDate": map[string]interface{}{
				"$gte": firstStartDate,
				"$lt":  lastEndDate,
			},
		}
		permissionSupport := PermissionSupport{}
		permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, modelRenderVO.FormTemplate.Security)
		for k, v := range permissionQueryDict {
			queryMap[k] = v
		}

		dataSourceIdLi := []string{"GatheringBill", "PayBill"}
		for _, dataSourceId := range dataSourceIdLi {
			tmpDataSource := modelTemplateFactory.GetDataSource(dataSourceId)
			collectionName := modelTemplateFactory.GetCollectionName(tmpDataSource)
			_, found := qb.FindByMapWithSession(session, collectionName, queryMap)
			if found {
				// 主数据集设置被用标记
				if usedCheckBo["A"] == nil {
					usedCheckBo["A"] = map[string]interface{}{}
				}
				masterUsedCheck := usedCheckBo["A"].(map[string]interface{})
				usedCheckBo["A"] = masterUsedCheck
				masterUsedCheck[strId] = true

				// 分录数据集设置被用标记
				if usedCheckBo["B"] == nil {
					usedCheckBo["B"] = map[string]interface{}{}
				}
				detailUsedCheck := usedCheckBo["B"].(map[string]interface{})
				usedCheckBo["B"] = usedCheckBo["B"]
				for _, detailData := range bDataSetLi {
					detailDataDict := detailData.(map[string]interface{})
					detailUsedCheck[fmt.Sprint(detailDataDict["id"])] = true
				}
				break
			}
		}
	}

	modelIterator := ModelIterator{}
	var result interface{} = ""
	modelIterator.IterateAllFieldBo(dataSource, &bo, &result, func(fieldGroup FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
		if (*data)[fieldGroup.Id] != nil {
			(*data)[fieldGroup.Id] = fmt.Sprint((*data)[fieldGroup.Id])
		}
	})
	format := c.Params.Get("format")
	if strings.ToLower(format) == "json" {
		c.Response.ContentType = "application/json; charset=utf-8"
		return c.RenderJson(map[string]interface{}{
			"bo":          bo,
			"relationBo":  relationBo,
			"usedCheckBo": usedCheckBo,
			//"dataSource": dataSource,
		})
	}
	//c.Response.ContentType = "text/html; charset=utf-8"
	return c.Render()
}
コード例 #24
0
ファイル: basedataaction.go プロジェクト: hongjinqiu/finance
func (c BaseDataAction) RSaveCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	dataSourceModelId := c.Params.Form.Get("dataSourceModelId")
	formTemplateId := c.Params.Get("formTemplateId")
	jsonBo := c.Params.Form.Get("jsonData")

	bo := map[string]interface{}{}
	err = json.Unmarshal([]byte(jsonBo), &bo)
	if err != nil {
		panic(err)
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	modelTemplateFactory.ConvertDataType(dataSource, &bo)
	strId := modelTemplateFactory.GetStrId(bo)
	if strId == "" || strId == "0" {
		c.RSetCreateFixFieldValue(sessionId, dataSource, &bo)
	} else {
		c.RSetModifyFixFieldValue(sessionId, dataSource, &bo)
		editMessage, isValid := c.RActionSupport.REditValidate(sessionId, dataSource, formTemplate, bo)
		if !isValid {
			panic(editMessage)
		}
	}

	c.RActionSupport.RBeforeSaveData(sessionId, dataSource, formTemplate, &bo)
	financeService := FinanceService{}

	diffDataRowLi := financeService.SaveData(sessionId, dataSource, &bo)

	c.RActionSupport.RAfterSaveData(sessionId, dataSource, formTemplate, &bo, diffDataRowLi)

	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id": bo["id"],
	}
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	bo, _ = querySupport.FindByMap(collectionName, queryMap)

	usedCheck := UsedCheck{}
	usedCheckBo := usedCheck.GetFormUsedCheck(sessionId, dataSource, bo)

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:       userId,
		Bo:           bo,
		RelationBo:   relationBo,
		UsedCheckBo:  usedCheckBo,
		DataSource:   dataSource,
		FormTemplate: formTemplate,
	}
}
コード例 #25
0
ファイル: cashaccountinit.go プロジェクト: hongjinqiu/finance
func (c CashAccountInit) RGetDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	//	dataSourceModelId := c.Params.Get("dataSourceModelId")
	dataSourceModelId := "AccountInit"
	formTemplateId := c.Params.Get("formTemplateId")

	session, _ := global.GetConnection(sessionId)
	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"A.accountType": 1,
	}
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	c.RActionSupport.RBeforeGetData(sessionId, dataSource, formTemplate)
	// 需要进行循环处理,再转回来,
	pageNo := 1
	pageSize := 1000
	orderBy := ""

	queryMapByte, err := json.MarshalIndent(&queryMap, "", "\t")
	if err != nil {
		panic(err)
	}
	log.Println("dealDelete,collectionName:" + collectionName + ", query:" + string(queryMapByte))
	result := querySupport.IndexWithSession(session, collectionName, queryMap, pageNo, pageSize, orderBy)
	items := result["items"].([]interface{})
	dataSetLi := []interface{}{}
	for _, item := range items {
		line := item.(map[string]interface{})
		bo := map[string]interface{}{
			"_id": line["id"],
			"id":  line["id"],
			"A":   line["A"],
		}
		modelTemplateFactory.ConvertDataType(dataSource, &bo)
		c.RActionSupport.RAfterGetData(sessionId, dataSource, formTemplate, &bo)
		dataSetLi = append(dataSetLi, bo["A"])
	}
	bo := map[string]interface{}{
		"_id": 0,
		"id":  0,
		"A": map[string]interface{}{
			"id":        0,
			"accountId": 0,
		},
		"B": dataSetLi,
	}

	//	usedCheck := UsedCheck{}
	//	usedCheckBo := usedCheck.GetFormUsedCheck(sessionId, dataSource, bo)
	usedCheckBo := map[string]interface{}{}

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	//	modelTemplateFactory.ConvertDataType(dataSource, &bo)

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	return ModelRenderVO{
		UserId:      userId,
		Bo:          bo,
		RelationBo:  relationBo,
		UsedCheckBo: usedCheckBo,
		DataSource:  dataSource,
	}
}
コード例 #26
0
ファイル: console.go プロジェクト: hongjinqiu/finance
func (c Console) Refretor() revel.Result {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)

	refretorType := c.Params.Get("type")
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate("Console")

	if refretorType == "Component" {
		listTemplateInfoLi := templateManager.RefretorListTemplateInfo()
		items := getSummaryListTemplateInfoLi(listTemplateInfoLi)
		for _, item := range formTemplate.FormElemLi {
			if item.XMLName.Local == "column-model" && item.ColumnModel.Name == "Component" {
				itemsDict := templateManager.GetColumnModelDataForColumnModel(sessionId, item.ColumnModel, items)
				items = itemsDict["items"].([]interface{})
				break
			}
		}

		dataBo := map[string]interface{}{
			"items": items,
		}

		c.Response.ContentType = "application/json; charset=utf-8"
		return c.RenderJson(&dataBo)
	}
	if refretorType == "Selector" {
		selectorTemplateInfoLi := templateManager.RefretorSelectorTemplateInfo()
		items := getSummarySelectorTemplateInfoLi(selectorTemplateInfoLi)
		for _, item := range formTemplate.FormElemLi {
			if item.XMLName.Local == "column-model" && item.ColumnModel.Name == "Selector" {
				itemsDict := templateManager.GetColumnModelDataForColumnModel(sessionId, item.ColumnModel, items)
				items = itemsDict["items"].([]interface{})
				break
			}
		}

		dataBo := map[string]interface{}{
			"items": items,
		}
		c.Response.ContentType = "application/json; charset=utf-8"
		return c.RenderJson(&dataBo)
	}
	if refretorType == "Form" {
		formTemplateInfoLi := templateManager.RefretorFormTemplateInfo()
		items := getSummaryFormTemplateInfoLi(formTemplateInfoLi)
		for _, item := range formTemplate.FormElemLi {
			if item.XMLName.Local == "column-model" && item.ColumnModel.Name == "Form" {
				itemsDict := templateManager.GetColumnModelDataForColumnModel(sessionId, item.ColumnModel, items)
				items = itemsDict["items"].([]interface{})
				break
			}
		}

		dataBo := map[string]interface{}{
			"items": items,
		}
		c.Response.ContentType = "application/json; charset=utf-8"
		return c.RenderJson(&dataBo)
	}
	if refretorType == "DataSource" {
		modelTemplateFactory := ModelTemplateFactory{}
		dataSourceTemplateInfoLi := modelTemplateFactory.RefretorDataSourceInfo()
		items := getSummaryDataSourceInfoLi(dataSourceTemplateInfoLi)
		for _, item := range formTemplate.FormElemLi {
			if item.XMLName.Local == "column-model" && item.ColumnModel.Name == "DataSource" {
				itemsDict := templateManager.GetColumnModelDataForColumnModel(sessionId, item.ColumnModel, items)
				items = itemsDict["items"].([]interface{})
				break
			}
		}

		dataBo := map[string]interface{}{
			"items": items,
		}
		c.Response.ContentType = "application/json; charset=utf-8"
		return c.RenderJson(&dataBo)
	}
	c.Response.ContentType = "application/json; charset=utf-8"
	return c.RenderJson(map[string]interface{}{
		"message": "可能传入了错误的refretorType:" + refretorType,
	})
}
コード例 #27
0
ファイル: cashaccountinit.go プロジェクト: hongjinqiu/finance
func (c CashAccountInit) RSaveCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	// 自己拆,再循环保存
	//	dataSourceModelId := c.Params.Form.Get("dataSourceModelId")
	dataSourceModelId := "AccountInit"
	formTemplateId := c.Params.Get("formTemplateId")
	jsonBo := c.Params.Form.Get("jsonData")

	bo := map[string]interface{}{}
	err = json.Unmarshal([]byte(jsonBo), &bo)
	if err != nil {
		panic(err)
	}
	continueAnyAll := "false"
	if bo["continueAnyAll"] != nil && fmt.Sprint(bo["continueAnyAll"]) != "" {
		continueAnyAll = bo["continueAnyAll"].(string)
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	//	modelTemplateFactory.ConvertDataType(dataSource, &bo)

	cashAccountInitLi := []map[string]interface{}{}
	bDataSetLi := bo["B"].([]interface{})
	nowIdLi := []int{}
	for _, item := range bDataSetLi {
		mapItem := item.(map[string]interface{})
		line := map[string]interface{}{
			"A": mapItem,
		}
		if mapItem["id"] != nil {
			line["id"] = mapItem["id"]
			line["_id"] = mapItem["id"]
		} else {
			line["id"] = ""
			line["_id"] = ""
		}
		modelTemplateFactory.ConvertDataType(dataSource, &line)
		strId := fmt.Sprint(line["id"])
		if strId != "" {
			intId, _ := strconv.Atoi(strId)
			nowIdLi = append(nowIdLi, intId)
		}
		cashAccountInitLi = append(cashAccountInitLi, line)
	}
	queryData := bo["A"].(map[string]interface{})
	strAccountId := fmt.Sprint(queryData["accountId"])
	// 先处理删除的数据,并弄到差异数据中
	diffDataRowAllLi := []DiffDataRow{}
	toDeleteLi := c.dealDelete(sessionId, dataSource, formTemplate, queryData, nowIdLi)
	modelIterator := ModelIterator{}
	for _, item := range toDeleteLi {
		var result interface{} = ""
		modelIterator.IterateDataBo(dataSource, &item, &result, func(fieldGroupLi []FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
			diffDataRow := DiffDataRow{
				FieldGroupLi: fieldGroupLi,
				SrcData:      *data,
				SrcBo:        item,
			}
			diffDataRowAllLi = append(diffDataRowAllLi, diffDataRow)
		})
	}

	bo = map[string]interface{}{
		"_id": 0,
		"id":  0,
		"A": map[string]interface{}{
			"id":        0,
			"accountId": strAccountId,
		},
	}
	bDataSetLi = []interface{}{}
	for i, _ := range cashAccountInitLi {
		cashAccountInit := &cashAccountInitLi[i]
		strId := modelTemplateFactory.GetStrId(*cashAccountInit)
		if strId == "" || strId == "0" {
			c.RSetCreateFixFieldValue(sessionId, dataSource, cashAccountInit)
		} else {
			c.RSetModifyFixFieldValue(sessionId, dataSource, cashAccountInit)
			editMessage, isValid := c.RActionSupport.REditValidate(sessionId, dataSource, formTemplate, *cashAccountInit)
			if !isValid {
				panic(editMessage)
			}
		}
		// 这样只会是新增和修改的数据
		c.RActionSupport.RBeforeSaveData(sessionId, dataSource, formTemplate, cashAccountInit)
		financeService := FinanceService{}
		diffDataRowLi := financeService.SaveData(sessionId, dataSource, cashAccountInit)
		c.RActionSupport.RAfterSaveData(sessionId, dataSource, formTemplate, cashAccountInit, diffDataRowLi)

		bDataSetLi = append(bDataSetLi, (*cashAccountInit)["A"])

		for _, diffDataRowItem := range *diffDataRowLi {
			diffDataRowAllLi = append(diffDataRowAllLi, diffDataRowItem)
		}
	}
	cashAccountInitSupport := c.RActionSupport.(CashAccountInitSupport)
	cashAccountInitSupport.checkLimitsControl(sessionId, diffDataRowAllLi, continueAnyAll)
	bo["B"] = bDataSetLi

	usedCheckBo := map[string]interface{}{}

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:      userId,
		Bo:          bo,
		RelationBo:  relationBo,
		UsedCheckBo: usedCheckBo,
		DataSource:  dataSource,
	}
}
コード例 #28
0
ファイル: cashaccountinit.go プロジェクト: hongjinqiu/finance
func (c CashAccountInit) RRefreshDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	//	dataSourceModelId := c.Params.Get("dataSourceModelId")
	dataSourceModelId := "AccountInit"
	formTemplateId := c.Params.Get("formTemplateId")
	queryDataStr := c.Params.Get("queryData")
	queryData := map[string]interface{}{}
	err = json.Unmarshal([]byte(queryDataStr), &queryData)
	if err != nil {
		panic(err)
	}
	strAccountId := fmt.Sprint(queryData["accountId"])
	//	strId := c.Params.Get("id")
	//	id, err := strconv.Atoi(strId)
	//	if err != nil {
	//		panic(err)
	//	}

	session, _ := global.GetConnection(sessionId)
	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"A.accountType": 1,
	}
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	if strAccountId != "" && strAccountId != "0" {
		accountIdLi := []int{}
		for _, item := range strings.Split(strAccountId, ",") {
			accountId, err := strconv.Atoi(item)
			if err != nil {
				panic(err)
			}
			accountIdLi = append(accountIdLi, accountId)
		}
		queryMap["A.accountId"] = map[string]interface{}{
			"$in": accountIdLi,
		}
	}
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	// 需要进行循环处理,再转回来,
	pageNo := 1
	pageSize := 1000
	orderBy := ""
	result := querySupport.IndexWithSession(session, collectionName, queryMap, pageNo, pageSize, orderBy)
	items := result["items"].([]interface{})
	dataSetLi := []interface{}{}
	for _, item := range items {
		line := item.(map[string]interface{})
		bo := map[string]interface{}{
			"_id": line["id"],
			"id":  line["id"],
			"A":   line["A"],
		}
		modelTemplateFactory.ConvertDataType(dataSource, &bo)
		c.RActionSupport.RBeforeRefreshData(sessionId, dataSource, formTemplate, &bo)
		c.RActionSupport.RAfterRefreshData(sessionId, dataSource, formTemplate, &bo)
		dataSetLi = append(dataSetLi, bo["A"])
	}
	bo := map[string]interface{}{
		"_id": 0,
		"id":  0,
		"A": map[string]interface{}{
			"id":        0,
			"accountId": strAccountId,
		},
		"B": dataSetLi,
	}

	//	usedCheck := UsedCheck{}
	//	usedCheckBo := usedCheck.GetFormUsedCheck(sessionId, dataSource, bo)
	usedCheckBo := map[string]interface{}{}

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:      userId,
		Bo:          bo,
		RelationBo:  relationBo,
		UsedCheckBo: usedCheckBo,
		DataSource:  dataSource,
	}
}