public void SaveFormulaItem(FapFormulaItems formula) { string tableName = formula.TableName; IEnumerable <FapFormula> list = formula.Formulas; //删除完毕重新加 _dbContext.Execute("delete from FapFormula where FcUid=@FcUid", new DynamicParameters(new { FcUid = formula.FcUid })); if (list != null && list.Any()) { var cols = _dbContext.Columns(formula.TableName); var entityMappingList = _dbContext.QueryWhere <CfgEntityMapping>($"{nameof(CfgEntityMapping.OriEntity)}=@OriEntity", new DynamicParameters(new { OriEntity = formula.MappingTable }), true); list.ToList().ForEach((f) => { f.FcUid = formula.FcUid; if (f.FmuDesc.IsPresent()) { if (f.FmuDesc.StartsWith("[引用]", StringComparison.OrdinalIgnoreCase)) { f.FmuContent = SqlUtils.ParsingFormulaMappingSql(entityMappingList, tableName, f.ColName, f.FmuDesc, _dbContext); } else if (f.FmuDesc.StartsWith("[累计]", StringComparison.OrdinalIgnoreCase)) { f.FmuContent = SqlUtils.ParsingFormulaGrandTotalSql(cols, f.ColName, formula.MappingTable, f.FmuDesc, _dbContext.DatabaseDialect); } else { f.FmuContent = SqlUtils.ParsingFormulaVariableSql(cols, f.ColName, f.FmuDesc, _dbContext.DatabaseDialect); } } }); _dbContext.InsertBatch(list); } }
public JsonResult FormulaItem(FapFormulaItems formula) { _gridFormService.SaveFormulaItem(formula); return(Json(ResponseViewModelUtils.Sueecss())); }