//TODO:添加一些资产 public IActionResult add_zc_ten() { M_Db_Operate m_Db_Ct = new M_Db_Operate(); var coll = m_Db_Ct.database.GetCollection <Class_template>("Class_templates"); M_Db_Operate zc_db = new M_Db_Operate(); var zc_coll = zc_db.database.GetCollection <SJ_ZC_Model>("ZC_data"); int number = zc_db.Inquire_Data(zc_coll, type: 2).Count; var types = m_Db_Ct.Inquire_Data(coll, type: 2); foreach (var type in types) { List <SJ_ZC_Model> sj_zc_s = new List <SJ_ZC_Model>(); var res = m_Db_Ct.Get_Aggregate("Class_templates", new List <string>() { "TPYE" }, new List <string>() { type.TPYE }, new List <string>() { "Meta_attribute" }, new List <string>() { "ZC_SX" }, new List <string>() { "ID" }, new List <string>() { "ZC_SX" })[0]; for (int i = 0; i < 27273; i++) { number++; SJ_ZC_Model sJ_ZC = new SJ_ZC_Model(res, type.TPYE, number); sj_zc_s.Add(sJ_ZC); } zc_coll.InsertMany(sj_zc_s); } //总条目数 return(query_zc()); }
[HttpGet]//根据资产ID获取一个资产的全部信息 public List <Dictionary <string, SJ_SX_Model> > Get_ZC_XX(string ID) { try { List <Dictionary <string, SJ_SX_Model> > resu = new List <Dictionary <string, SJ_SX_Model> >(); Dictionary <string, SJ_SX_Model> TY_SX = new Dictionary <string, SJ_SX_Model>(); Dictionary <string, SJ_SX_Model> ZY_SX = new Dictionary <string, SJ_SX_Model>(); Dictionary <string, SJ_SX_Model> KZ_SX = new Dictionary <string, SJ_SX_Model>(); Dictionary <string, SJ_SX_Model> GZ_WW = new Dictionary <string, SJ_SX_Model>(); Dictionary <string, SJ_SX_Model> GZ_WLW = new Dictionary <string, SJ_SX_Model>(); Dictionary <string, SJ_SX_Model> GZ_BB = new Dictionary <string, SJ_SX_Model>(); M_Db_Operate m_Db_Operate = new M_Db_Operate(); var collection = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data"); var result = m_Db_Operate.Get_Aggregate( "ZC_data", new List <string>() { "ZCBM" }, new List <string>() { ID }, new List <string>() { "Meta_attribute" }, new List <string>() { "ZC_SX.mp" }, new List <string>() { "ID" }, new List <string>() { "ZC_SXN" } )[0]; int j = 0; while (true) { try { SJ_SX_Model sJ_SX_ = new SJ_SX_Model(); sJ_SX_.mp = result["ZC_SXN"][j]["ID"].ToString(); int u = 0; while (true) { try { if (result["ZC_SX"][u]["mp"].ToString() == result["ZC_SXN"][j]["ID"].ToString()) { sJ_SX_.V = result["ZC_SX"][u]["V"].ToString(); break; } u++; } catch { break; } } if (result["ZC_SXN"][j]["Dimension_dic"]["资产类别维度"].ToString().Contains("通用集")) { TY_SX.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_); } else if (result["ZC_SXN"][j]["Dimension_dic"]["资产类别维度"].ToString().Contains("专用集")) { ZY_SX.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_); } else if (result["ZC_SXN"][j]["Dimension_dic"]["资产类别维度"].ToString().Contains("扩展集")) { if (result["ZC_SXN"][j]["Dimension_dic"]["应用特性维度"] == "文物信息") { GZ_WW.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_); } else if (result["ZC_SXN"][j]["Dimension_dic"]["应用特性维度"] == "物联网信息") { GZ_WLW.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_); } else if (result["ZC_SXN"][j]["Dimension_dic"]["应用特性维度"] == "标本信息") { GZ_BB.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_); } else { KZ_SX.Add(result["ZC_SXN"][j]["Name"].ToString(), sJ_SX_); } } j++; } catch { break; } } resu.Add(ZY_SX); resu.Add(KZ_SX); resu.Add(TY_SX); resu.Add(GZ_WW); resu.Add(GZ_WLW); resu.Add(GZ_BB); return(resu); } catch { return(null); } }
//资产修改完成动作result[0].SJZCFLBM public IActionResult Updata_zc_OK(IFormCollection f) { try { string id; if (f["zc_id"] == "-- 资产编码 --") { id = f["int_zc_"]; } else { id = f["zc_id"]; } List <SJ_SX_Model> new_ZC_SX = new List <SJ_SX_Model>(); M_Db_Operate m_Db_Operate = new M_Db_Operate(); var coll = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data"); var result = m_Db_Operate.Get_Aggregate( "ZC_data", new List <string>() { "ZCBM" }, new List <string>() { id }, new List <string>() { "Meta_attribute" }, new List <string>() { "ZC_SX.mp" }, new List <string>() { "ID" }, new List <string>() { "ZC_SXN" } )[0]; M_Db_Operate m_Db = new M_Db_Operate(); var collection = m_Db.database.GetCollection <YSX_Model>("Meta_attribute"); int j = 0; int[] flag = { 1, 1, 1 }; List <SJ_SX_Model> del_sx = new List <SJ_SX_Model>(); while (true) { try { SJ_SX_Model sx = new SJ_SX_Model(); sx.V = f[result["ZC_SXN"][j]["ID"].ToString()]; int u = 0; while (true) { try { if (result["ZC_SX"][u]["mp"].ToString() == result["ZC_SXN"][j]["ID"].ToString()) { sx.mp = result["ZC_SX"][u]["mp"].ToString(); break; } u++; } catch { break; } } //sx.mp = result["ZC_SX"][j]["mp"].ToString(); new_ZC_SX.Add(sx); if (result["ZC_SXN"][j]["Name"].ToString() == "文物标识") { if (sx.V == "1") { var ww_resu = m_Db.Inquire_Data(collection, new List <string>() { "Dimension_dic.应用特性维度" }, new List <string>() { "文物信息" }); foreach (var ysx in ww_resu) { SJ_SX_Model ww_sx = new SJ_SX_Model(); ww_sx.V = f[ysx.ID]; ww_sx.mp = ysx.ID; new_ZC_SX.Add(ww_sx); } } if (sx.V == "0") { var ww_resu = m_Db.Inquire_Data(collection, new List <string>() { "Dimension_dic.应用特性维度" }, new List <string>() { "文物信息" }); foreach (var ysx in ww_resu) { SJ_SX_Model ww_sx = new SJ_SX_Model(); ww_sx.V = f[ysx.ID]; ww_sx.mp = ysx.ID; del_sx.Add(ww_sx); } } } else if (result["ZC_SXN"][j]["Name"].ToString() == "是否包含物联网传感") { if (sx.V == "1") { var wlw_resu = m_Db.Inquire_Data(collection, new List <string>() { "Dimension_dic.应用特性维度" }, new List <string>() { "物联网信息" }); foreach (var ysx in wlw_resu) { SJ_SX_Model wlw_sx = new SJ_SX_Model(); wlw_sx.V = f[ysx.ID]; wlw_sx.mp = ysx.ID; new_ZC_SX.Add(wlw_sx); } } if (sx.V == "0") { var wlw_resu = m_Db.Inquire_Data(collection, new List <string>() { "Dimension_dic.应用特性维度" }, new List <string>() { "物联网信息" }); foreach (var ysx in wlw_resu) { SJ_SX_Model wlw_sx = new SJ_SX_Model(); wlw_sx.V = f[ysx.ID]; wlw_sx.mp = ysx.ID; del_sx.Add(wlw_sx); } } } else if (result["ZC_SXN"][j]["Name"].ToString() == "陈列品标识") { if (sx.V == "1") { var bb_resu = m_Db.Inquire_Data(collection, new List <string>() { "Dimension_dic.应用特性维度" }, new List <string>() { "标本信息" }); foreach (var ysx in bb_resu) { SJ_SX_Model bb_sx = new SJ_SX_Model(); bb_sx.V = f[ysx.ID]; bb_sx.mp = ysx.ID; new_ZC_SX.Add(bb_sx); } } if (sx.V == "0") { var bb_resu = m_Db.Inquire_Data(collection, new List <string>() { "Dimension_dic.应用特性维度" }, new List <string>() { "标本信息" }); foreach (var ysx in bb_resu) { SJ_SX_Model bb_sx = new SJ_SX_Model(); bb_sx.V = f[ysx.ID]; bb_sx.mp = ysx.ID; del_sx.Add(bb_sx); } } } j++; } catch { foreach (var del in del_sx) { new_ZC_SX.Remove(del); for (int i = 0; i < new_ZC_SX.Count; i++) { if (new_ZC_SX[i].mp == del.mp) { new_ZC_SX.RemoveAt(i); break; } } } break; } } m_Db_Operate.Up_Data(coll, "ZCBM", f["0003"], "ZC_SX", new_ZC_SX); return(View("../Home/add_OK")); } catch (InvalidCastException e) { ViewData["e"] = e.ToString(); return(View("../Home/add_ERROR")); }; }
//按照资产编码查找 public IActionResult query_zc_2(IFormCollection f) { string zc_name = f["zc_name"]; try { M_Db_Operate m_Db_Operate = new M_Db_Operate(); var collection1 = m_Db_Operate.database.GetCollection <Dimension_Information_Model>("Dimension_Information"); List <string> key1 = new List <string>(); key1.Add("TYPE"); List <string> value1 = new List <string>(); value1.Add("管理者维度"); var Result = m_Db_Operate.Inquire_Data(collection1, key1, value1); List <string> name = new List <string>(); for (var i = 0; i < Result.Count; i++) { name.Add(Result[i].NAME); } ViewData["glz_list"] = name; //在这里查询数据库并整合数据 var collection = m_Db_Operate.database.GetCollection <SJ_ZC_Model>("ZC_data"); List <string> key = new List <string>(); List <string> value = new List <string>(); key.Add("ZCBM"); value.Add(zc_name.ToString()); var result = m_Db_Operate.Get_Aggregate( "ZC_data", key, value, new List <string>() { "Meta_attribute" }, new List <string>() { "ZC_SX.mp" }, new List <string>() { "ID" }, new List <string>() { "ZC_SXN" } ); List <List <string> > ZC_datas = new List <List <string> >(); for (var i = 0; i < result.Count; i++) { List <string> ZC_data = new List <string>(); string kz_sx = ""; int j = 0; while (true) { try { if (result[i]["ZC_SXN"][j]["Dimension_dic"]["资产类别维度"].ToString().Contains("通用集")) { string uu = result[i]["ZC_SXN"][j]["Name"].ToString() + ":"; int k = 0; while (true) { try { if (result[i]["ZC_SXN"][j]["ID"].ToString() == result[i]["ZC_SX"][k]["mp"].ToString()) { uu += result[i]["ZC_SX"][k]["V"].ToString(); break; } k++; } catch { ; } } ZC_data.Add(uu); } else { string uu = result[i]["ZC_SXN"][j]["Name"].ToString() + ":"; int k = 0; while (true) { try { if (result[i]["ZC_SXN"][j]["ID"].ToString() == result[i]["ZC_SX"][k]["mp"].ToString()) { uu += result[i]["ZC_SX"][k]["V"].ToString(); break; } k++; } catch { ; } } ZC_data.Add(uu); } } catch { break; } j++; } ZC_data.Add(kz_sx); ZC_datas.Add(ZC_data); } ViewData["ZC_datas"] = ZC_datas; ViewData["sx_name"] = sx_name; } catch (InvalidCastException e) { ViewData["e"] = e.ToString(); return(View("query_ERROR")); } ViewData["wd_type"] = null; ViewData["wd_xx"] = null; ViewData["zc_name"] = null; ViewData["ysx_name"] = null; ViewData["ysx_value"] = null; return(View("query_zc")); }