123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SqlSugar;
- using Uninpho.DBOperation.Model;
- using System.IO;
- using Npgsql;
- using System.Data;
- namespace Uninpho.DBOperation.Operation
- {
- class mm
- {
- public int Max { get; set; }
- }
- public class DataAnalysisToPG
- {
- static SqlSugarClient db = Config.GetPgClient();
- public static void Test()
- {
- var list1 = db.SqlQueryable<T_daocha_account>("select * from \"t_daocha_account\"").ToList();
- var list2 = db.SqlQueryable<T_guanjie_account>("select * from \"t_guanjie_account\"").ToList();
- var list3 = db.SqlQueryable<T_quxian_account>("select * from \"t_quxian_account\"").ToList();
- var list4 = db.SqlQueryable<T_lunguili_account>("select * from \"t_lunguili_account\"").ToList();
- var list5 = db.SqlQueryable<T_jihefenxi_account>("select * from \"t_jihefenxi_account\"").ToList();
- var list6 = db.SqlQueryable<T_file_account>("select * from \"t_file_account\"").ToList();
- }
- /// <summary>
- /// 读取数据并展示
- /// </summary>
- public static Object getfile(string cxtj,List<int> suanfarunid,List<string> suanfazt)
- {
- var obj = db.SqlQueryable<T_file_account>("select * from \"t_file_account\"").Where(it => it.Houzhui == cxtj).ToList();
- for (int i = 0; i < obj.Count; i++)
- {
- if (!File.Exists(obj[i].Srlj))
- {
- obj[i].Wjzt = "文件未找到";
- }
- for (int j = 0; j < suanfarunid.Count; j++)
- {
- if (suanfarunid[j] == obj[i].Id)
- {
- obj[i].Rwzt = suanfazt[j];
- }
- }
- }
- return obj;
- }
- /// <summary>
- /// 读取数据并展示
- /// </summary>
- /// 电务功率
- public static Object getDwfile(string cxtj, List<int> suanfarunid, List<string> suanfazt)
- {
-
- var obj = db.SqlQueryable<T_dwfile_account>("select * from \"t_dwfile_account\" ").ToList();
- for (int i = 0; i < obj.Count; i++)
- {
- if (!File.Exists(obj[i].Srlj))
- {
- obj[i].Filestatus = "文件未找到";
- }
- for (int j = 0; j < suanfarunid.Count; j++)
- {
- if (suanfarunid[j] == obj[i].Id)
- {
- obj[i].Taskstatus = suanfazt[j];
- }
- }
- }
- return obj;
- }
- /// <summary>
- /// 电务缺口
- /// </summary>
- /// <param name="cxtj"></param>
- /// <param name="suanfarunid"></param>
- /// <param name="suanfazt"></param>
- /// <returns></returns>
- public static Object getDwqkfile(string cxtj, List<int> suanfarunid, List<string> suanfazt)
- {
- var obj = db.SqlQueryable<T_dwqkfile_account>("select * from \"t_dwqkfile_account\" ").ToList();
- for (int i = 0; i < obj.Count; i++)
- {
- if (!File.Exists(obj[i].Srlj))
- {
- obj[i].Filestatus = "文件未找到";
- }
- for (int j = 0; j < suanfarunid.Count; j++)
- {
- if (suanfarunid[j] == obj[i].Id)
- {
- obj[i].Taskstatus = suanfazt[j];
- }
- }
- }
- return obj;
- }
- /// <summary>
- /// 自动化读取数据
- /// </summary>
- public static Object getfile(string cxtj)
- {
- var obj = db.SqlQueryable<T_file_account>("select * from \"t_file_account\"").Where(it => it.Houzhui == cxtj).ToList();
- return obj;
- }
- /// <summary>
- /// 更新任务状态
- /// </summary>
- public static void updataRWZT(string[] Yswjm)
- {
- NpgsqlConnection conn = new NpgsqlConnection();
- conn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbConnection"] as string;
- NpgsqlCommand comm = new NpgsqlCommand();
- comm.Connection = conn;
- conn.Open();
- comm.CommandText = "UPDATE \"t_file_account\" SET rwzt = '" + Yswjm[1] + "' WHERE id =" + Yswjm[0];
- //comm.CommandText = @"SELECT* FROM " + tablename + " where " + querystring;
- comm.ExecuteNonQuery();
- conn.Close();
- }
- /// <summary>
- /// 读取密贴离缝数据并展示
- /// </summary>
- public static List<T_mitielifeng_filelist> getfilemtlf()
- {
- var obj = db.SqlQueryable<T_mitielifeng_filelist>("select * from \"t_mitielifeng_filelist\"").ToList();
- return obj;
- }
- /// <summary>
- /// 读取逐枕几何数据并展示
- /// </summary>
- public static List<T_zhuzhenjihe_filelist> getfilezzjh()
- {
- var obj = db.SqlQueryable<T_zhuzhenjihe_filelist>("select * from \"t_zhuzhenjihe_filelist\"").ToList();
- return obj;
- }
- /// <summary>
- /// 读取线形线位list数据并展示
- /// </summary>
- public static List<T_xxxw_csvlist> getfilexxxwL()
- {
- var obj = db.SqlQueryable<T_xxxw_csvlist>("select * from \"t_xxxw_csvlist\"").ToList();
- return obj;
- }
- /// <summary>
- /// 读取线形线位数据并展示
- /// </summary>
- public static List<T_xxxw_csvdata> getfilexxxwD(string uuid)
- {
- var obj = db.SqlQueryable<T_xxxw_csvdata>("select * from \"t_xxxw_csvdata\" where listid = '" +uuid+"' ORDER BY cld ASC").ToList();
- return obj;
- }
- //**************************************增********************************************
- /// <summary>
- /// 更新最大id
- /// </summary>
- public static void InsertGetIdMAX(T_jihefenxi_boxing updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- public static void InsertGetIdMAX(T_lunguili_boxing updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// 插入csvdata信息数据表
- /// </summary>
- /// <param name="listqx"></param>
- public static void Insertdata_CsvData(List<T_xxxw_csvdata> listqx)
- {
- db.Insertable<T_xxxw_csvdata>(listqx).ExecuteCommand();//get change row count
- }
- /// <summary>
- /// 插入csvlist信息数据表
- /// </summary>
- /// <param name="listqx"></param>
- public static string Insertdata_CsvList(T_xxxw_csvlist updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();//get change row count
- return db.Queryable<T_xxxw_csvlist>().Where(it => it.Jiancharen == updateObjs.Jiancharen && it.Jianchariqi == updateObjs.Jianchariqi).Single().Id;
- }
- /// <summary>
- /// 插入功率信息数据表
- /// </summary>
- /// <param name="listqx"></param>
- public static void Insert_gl_data_CsvData(List<T_gonglv_account> gonglvCsvdata)
- {
- // db.Insertable(gonglvCsvdata).ExecuteCommand();
- db.Insertable<T_gonglv_account>(gonglvCsvdata).ExecuteCommand();//get change row count
- }
- /// <summary>
- /// 插入缺口信息数据表
- /// </summary>
- /// <param name="listqx"></param>
- public static void Insert_qk_data_CsvData(List<T_quekou_account> quekouCsvdata)
- {
- // db.Insertable(gonglvCsvdata).ExecuteCommand();
- db.Insertable<T_quekou_account>(quekouCsvdata).ExecuteCommand();//get change row count
- }
- /// <summary>
- /// 插入功率信息数据表
- /// </summary>
- /// <param name="listqx"></param>
- public static string Insertdata_gl_CsvList(T_gonglv_account gonglvCsvdata)
- {
- db.Insertable(gonglvCsvdata).ExecuteCommand();//get change row count
- return db.Queryable<T_gonglv_account>().Where(it => it.Chezhan == gonglvCsvdata.Chezhan).Single().Id;
- }
- /// <summary>
- /// T_file_account表添加新数据
- /// </summary>
- public static void InsertToPG(List<T_file_account> updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// T_dwfile_account表添加新数据
- /// </summary>
- public static void GLInsertToPG(List<T_dwfile_account> updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// T_dwqkfile_account表添加新数据
- /// </summary>
- public static void QKInsertToPG(List<T_dwqkfile_account> updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// 密贴离缝表添加新数据
- /// </summary>
- public static string InsertMTLFListDataToPG(T_mitielifeng_filelist updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- return db.Queryable<T_mitielifeng_filelist>().Where(it => it.Remark == updateObjs.Remark && it.Excelbytearr == updateObjs.Excelbytearr).Single().Id;
- }
- /// <summary>
- /// 密贴离缝excel表添加新数据
- /// </summary>
- public static void InsertMTLFExcelDataToPG(T_mitielifeng_exceldata updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// 逐枕几何表添加新数据
- /// </summary>
- public static string InsertZZJHListDataToPG(T_zhuzhenjihe_filelist updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- return db.Queryable<T_zhuzhenjihe_filelist>().Where(it => it.Remark == updateObjs.Remark && it.Excelbytearr == updateObjs.Excelbytearr).Single().Id;
- }
- /// <summary>
- /// 逐枕几何excel表添加新数据
- /// </summary>
- public static void InsertZZJHExcelDataToPG(List<T_zhuzhenjihe_exceldata> updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// 道岔几何表添加新数据
- /// </summary>
- public static void InsertJHDataToPG(List<T_jihefenxi_account> updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// 轮轨力表添加新数据
- /// </summary>
- public static void InsertLGLDataToPG(List<T_lunguili_account> updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// 道岔几何波形表添加新数据
- /// </summary>
- public static void InsertJHBXDataToPG(List<T_jihefenxi_boxing> updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// 轮轨力波形表添加新数据
- /// </summary>
- public static void InsertLGLBXDataToPG(List<T_lunguili_boxing> updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- //**************************************改********************************************
- public static void UpdataToPG(T_file_account item)
- {
- db.Updateable<T_file_account>(it => new T_file_account() { Jccxx = item.Jccxx }).Where(it => it.Id == item.Id).ExecuteCommand();
- }
- /// <summary>
- /// 更新线形线位数据表
- /// </summary>
- public static void UpdataToPGXXXWD(string name ,string value,string uuid)
- {
- //db.Updateable<T_xxxw_csvdata>(it => new T_xxxw_csvdata() { }).Where(it => it.Id.ToString() == item.Id).ExecuteCommand();
- NpgsqlConnection conn = new NpgsqlConnection();
- conn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbConnection"] as string;
- NpgsqlCommand comm = new NpgsqlCommand();
- comm.Connection = conn;
- conn.Open();
- comm.CommandText = "UPDATE \"t_xxxw_csvdata\" SET " + name + " = '" + value + "' WHERE id ='" + uuid + "'";
- //comm.CommandText = @"SELECT* FROM " + tablename + " where " + querystring;
- comm.ExecuteNonQuery();
- conn.Close();
- }
- /// <summary>
- /// 更新线形线位list表
- /// </summary>
- public static void UpdataToPGXXXWL(string name, string value, string uuid)
- {
- db.Updateable<T_xxxw_csvlist>(it => new T_xxxw_csvlist() { Gengxinren = name,Gengxinriqi=value }).Where(it => it.Id.ToString() == uuid).ExecuteCommand();
- }
- public static void UpdataToPGMTLF(T_mitielifeng_filelist item)
- {
- db.Updateable<T_mitielifeng_filelist>(item).Where(it => it.Id.ToString() == item.Id).ExecuteCommand();
- //db.Updateable<T_mitielifeng_filelist>(it => new T_mitielifeng_filelist() { Gengxinriqi = item.Gengxinriqi, Gengxinren = item.Gengxinren, Excelbytearr = item.Excelbytearr }).Where(it => it.Id.ToString() == item.Id).ExecuteCommand();
- }
- public static void UpdataToPGZZJH(T_zhuzhenjihe_filelist item)
- {
- db.Updateable<T_zhuzhenjihe_filelist>(item).Where(it => it.Id.ToString() == item.Id).ExecuteCommand();
- //db.Updateable<T_zhuzhenjihe_filelist>(it => new T_zhuzhenjihe_filelist() { Gengxinriqi = item.Gengxinriqi, Gengxinren = item.Gengxinren, Excelbytearr = item.Excelbytearr }).Where(it => it.Id.ToString() == item.Id).ExecuteCommand();
- }
- /// <summary>
- /// 道岔几何表更新微小算法执行结果
- /// </summary>
- public static void UpdataJHDataToPG(List<T_jihefenxi_account> updateObjs)
- {
- for (int i = 0; i < updateObjs.Count; i++)
- {
- //使用 线路名、行别、尖轨尖里程、检测车、日期 5个条件进行匹配更新数据
- db.Updateable<T_jihefenxi_account>(it => new T_jihefenxi_account()
- {
- Wx_check = updateObjs[i].Wx_check,
- Wx_bhl_gd = updateObjs[i].Wx_bhl_gd,
- Wx_bhl_gj = updateObjs[i].Wx_bhl_gj,
- Wx_bhl_sp = updateObjs[i].Wx_bhl_sp,
- Wx_bhl_gx = updateObjs[i].Wx_bhl_gx,
- Wx_bhl_sjk = updateObjs[i].Wx_bhl_sjk,
- Wx_isload = 1,
- }).Where(it => it.Xlm == updateObjs[i].Xlm && it.Xingbie == updateObjs[i].Xingbie && it.Jgjlc == updateObjs[i].Jgjlc && it.Jcc == updateObjs[i].Jcc && it.Riqi == updateObjs[i].Riqi).ExecuteCommand();
-
- }
- }
- /// <summary>
- /// 道岔几何波形表更新微小算法执行结果
- /// </summary>
- public static void UpdataJHBXDataToPG(List<T_jihefenxi_boxing> updateObjs)
- {
- db.Updateable<T_jihefenxi_boxing>(updateObjs).ExecuteCommand();
- }
- //**************************************删********************************************
- /// <summary>
- /// 删除数据 account、boxing两个表
- /// type:"轮轨力"、"几何"、"微小"
- /// </summary>type
- public static void DelUpdataData(string yswjm,string type)
- {
- T_file_account file = db.SqlQueryable<T_file_account>("select * from \"t_file_account\" where id = " + yswjm).ToList()[0];
- //updataRWZT(new string[] { yswjm, "算法未执行" });
- if (type == "轮轨力")
- {
- List<T_lunguili_account> whichupdata = (List<T_lunguili_account>)QueryToPGByNameL(yswjm);
- DelToPGLGLBX(whichupdata);
- DelToPGLGL(file);
- }
- else if(type == "几何")
- {
- List<T_jihefenxi_account> whichupdata = (List<T_jihefenxi_account>)QueryToPGByName(yswjm);
- DelToPGJHBX(whichupdata);
- DelToPGJH(file);
- }
- //else if (type == "功率")
- //{
- // List<T_dwfile_account> whichupdata = (List<T_dwfile_account>)QueryToPGByName(yswjm);
- // DelToPGJHBX(whichupdata);
- // DelToPGJH(file);
- //}
- }
- /// <summary>
- /// 删除数据 by ID
- /// </summary>
- public static void DelToPGXXXW(string Id)
- {
- db.Deleteable<T_xxxw_csvlist>().Where(it => it.Id.ToString() == Id).ExecuteCommand();
- db.Deleteable<T_xxxw_csvdata>().Where(it => it.Listid == Id).ExecuteCommand();
- }
- /// <summary>
- /// 删除数据 by ID
- /// </summary>
- public static void DelToPGXXXWD(string Id)
- {
- db.Deleteable<T_xxxw_csvdata>().Where(it => it.Id.ToString() == Id).ExecuteCommand();
- }
- /// <summary>
- /// 删除数据 by ID
- /// </summary>
- public static void DelToPGMTLF(T_mitielifeng_filelist item)
- {
- db.Deleteable<T_mitielifeng_filelist>().Where(it => it.Id.ToString() == item.Id).ExecuteCommand();
- db.Deleteable<T_mitielifeng_exceldata>().Where(it => it.Filelistid == item.Id).ExecuteCommand();
- }
- /// <summary>
- /// 删除数据 by ID
- /// </summary>
- public static void DelToPGZZJH(T_zhuzhenjihe_filelist item)
- {
- db.Deleteable<T_zhuzhenjihe_filelist>().Where(it => it.Id.ToString() == item.Id).ExecuteCommand();
- db.Deleteable<T_zhuzhenjihe_exceldata>().Where(it => it.Filelistid == item.Id).ExecuteCommand();
- }
- /// <summary>
- /// 删除数据 by ID
- /// </summary>
- public static void DelToPG(T_file_account item)
- {
- db.Deleteable<T_file_account>().Where(it => it.Id == item.Id).ExecuteCommand();
- }
- /// <summary>
- /// 删除数据 by Yswjm
- /// </summary>
- public static void DelToPG1(T_file_account item)
- {
-
- db.Deleteable<T_file_account>().Where(it => it.Yswjm == item.Yswjm).ExecuteCommand();
- }
- /// 删除数据 by 文件名
- /// </summary>
- public static void DelToDW(T_dwfile_account item)
- {
-
- db.Deleteable<T_dwfile_account>().Where(it => it.Filename == item.Filename).ExecuteCommand();
- }
- public static void DelToDWQK(T_dwqkfile_account item)
- {
-
- db.Deleteable<T_dwqkfile_account>().Where(it => it.Filename == item.Filename).ExecuteCommand();
- }
- /// <summary>
- /// 删除几何account表数据
- /// </summary>
- public static void DelToPGJH(T_file_account updateObjs)
- {
- db.Deleteable<T_jihefenxi_account>().Where(it => it.Filename_jh == updateObjs.Id.ToString()).ExecuteCommand();
- }
- /// <summary>
- /// 删除几何波形表数据
- /// </summary>
- public static void DelToPGJHBX(List<T_jihefenxi_account> updateObjs)
- {
- NpgsqlConnection conn = new NpgsqlConnection();
- conn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbConnection"] as string;
- NpgsqlCommand comm = new NpgsqlCommand();
- comm.Connection = conn;
- conn.Open();
- foreach (var item in updateObjs)
- {
- string[] dd = item.Yswjm_jhfx.Split(',');
- comm.CommandText = "DELETE FROM public.t_jihefenxi_boxing where id >= " + dd[0] + " and id <= " + dd[1];
- comm.ExecuteNonQuery();
- }
- conn.Close();
- }
- /// <summary>
- /// 删除轮轨力account表数据
- /// </summary>
- public static void DelToPGLGL(T_file_account updateObjs)
- {
- db.Deleteable<T_lunguili_account>().Where(it => it.Filename_lgl == updateObjs.Id.ToString()).ExecuteCommand();
- }
- /// <summary>
- /// 删除轮轨力波形表数据
- /// </summary>
- public static void DelToPGLGLBX(List<T_lunguili_account> updateObjs)
- {
- NpgsqlConnection conn = new NpgsqlConnection();
- conn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbConnection"] as string;
- NpgsqlCommand comm = new NpgsqlCommand();
- comm.Connection = conn;
- conn.Open();
- foreach (var item in updateObjs)
- {
- string[] dd = item.Yswjm.Split(',');
- comm.CommandText = "DELETE FROM public.t_lunguili_boxing where id >= " + dd[0] + " and id <= " + dd[1];
- comm.ExecuteNonQuery();
- }
- conn.Close();
- }
- /// 删除电务功率 算法结果数据 //还未创建对应库
- /// </summary>
- public static void DelToDWGL(T_dwfile_account updateObjs)
- {
- //db.Deleteable<T_lunguili_account>().Where(it => it.Filename_lgl == updateObjs.Id.ToString()).ExecuteCommand();
- }
- /// <summary>
- /// 删除查询ID暂时添加的波形条数
- /// </summary>
- public static void InitBXID()
- {
- db.Deleteable<T_lunguili_boxing>().Where(it => it.Yswjm == "?????").ExecuteCommand();
- db.Deleteable<T_jihefenxi_boxing>().Where(it => it.Yswjm == "?????").ExecuteCommand();
- db.Insertable<T_lunguili_boxing>(new T_lunguili_boxing() {Yswjm = "?????" }).ExecuteCommand();
- db.Insertable<T_jihefenxi_boxing>(new T_jihefenxi_boxing() { Yswjm = "?????" }).ExecuteCommand();
- }
- /// <summary>
- /// 数据展示删除
- /// </summary>
- /// <param name="item"></param>
- /// <param name="itemjh"></param>
- public static void DelSJZS(string item,string itemjh,string xlm,string hangbie,string jgjlc)
- {
- NpgsqlConnection conn = new NpgsqlConnection();
- conn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbConnection"] as string;
- NpgsqlCommand comm = new NpgsqlCommand();
- comm.Connection = conn;
- conn.Open();
- if (item != "")
- {
- string[] dd = item.Split(',');
- comm.CommandText = "DELETE FROM public.t_lunguili_boxing where id >= " + dd[0] + " and id <= " + dd[1];
- comm.ExecuteNonQuery();
- comm.CommandText = "DELETE FROM public.t_lunguili_account where xlm = '" + xlm + "' and xingbie = '" + hangbie + "' and jgjlc = '" + jgjlc + "'";
- comm.ExecuteNonQuery();
- }
- if (itemjh != "")
- {
- string[] ddd = itemjh.Split(',');
- comm.CommandText = "DELETE FROM public.t_jihefenxi_boxing where id >= " + ddd[0] + " and id <= " + ddd[1];
- comm.ExecuteNonQuery();
- comm.CommandText = "DELETE FROM public.t_jihefenxi_account where xlm = '" + xlm + "' and xingbie = '" + hangbie + "' and jgjlc = '" + jgjlc + "'";
- comm.ExecuteNonQuery();
- }
- conn.Close();
- }
- //**************************************查********************************************
- /// <summary>
- /// 按Id查询
- /// </summary>
- public static Object QueryToPGById(int id_)
- {
- return db.Queryable<T_file_account>().Where(it => it.Id == id_).Single();
- }
- /// <summary>
- /// 按文件名查询文件
- /// </summary>
- public static Object QueryToPGByNameFile(string yswjm)
- {
- return db.Queryable<T_file_account>().Where(it => it.Yswjm == yswjm).ToList();
- }
- /// <summary>
- /// 按文件名查询 电务功率文件
- /// </summary>
- public static Object DWQueryToPGByNameFile(string filename)
- {
- return db.Queryable<T_dwfile_account>().Where(it => it.Filename == filename).ToList();
- }
- /// 按文件名查询 电务缺口文件
- /// </summary>
- public static Object DWQKQueryToPGByNameFile(string filename)
- {
- return db.Queryable<T_dwqkfile_account>().Where(it => it.Filename == filename).ToList();
- }
- /// <summary>
- /// 微笑算法筛选Sudu >= 100 && Zcx != "侧向"的数据
- /// </summary>
- public static Object QueryToPGByNameWXSF(string id)
- {
- return db.Queryable<T_jihefenxi_account>().Where(it => it.Filename_jh == id && (it.Sudu_jhfx >= 100 && it.Zcx != "侧向" && it.Wx_isload == 0)).ToList();
- }
- /// <summary>
- /// 查可执行微小算法的数据
- /// </summary>
- public static Object QueryToPGByNameWXSFZD()
- {
- return db.Queryable<T_jihefenxi_account>().Where(it => it.Sudu_jhfx >= 100 && it.Zcx != "侧向" && it.Wx_isload == 0).ToList();
- }
- /// <summary>
- /// 查数据(条件:线路名、行别、尖轨尖里程、未执行微小算法wx_isload = 1)
- /// </summary>
- public static List<List<T_jihefenxi_account>> QueryToPGByNameWXSFZDReference(List<T_jihefenxi_account> newdata)
- {
- List<List<T_jihefenxi_account>> ReferenceList = new List<List<T_jihefenxi_account>>();
- for (int i = 0; i < newdata.Count; i++)
- {
- var aa = (db.Queryable<T_jihefenxi_account>().Where(it => it.Xlm == newdata[i].Xlm && it.Xingbie == newdata[i].Xingbie && it.Jgjlc == newdata[i].Jgjlc && it.Wx_isload == 1).ToList()) as List<T_jihefenxi_account>;
- if (aa.Count != 0)
- {
- ReferenceList.Add(aa);
- }
- }
- return ReferenceList;
- }
- /// <summary>
- /// 按文件名查询JH
- /// </summary>
- public static Object QueryToPGByName(string id)
- {
- return db.Queryable<T_jihefenxi_account>().Where(it => it.Filename_jh == id).ToList();
- }
- /// <summary>
- /// 按文件名查询LGL
- /// </summary>
- public static Object QueryToPGByNameL(string yswjm)
- {
- return db.Queryable<T_lunguili_account>().Where(it => it.Filename_lgl == yswjm).ToList();
- }
- /// <summary>
- /// 查询几何提取算法线路里程值
- /// </summary>
- /// <param name="xllc_">线路里程名称</param>
- /// <returns></returns>
- public static Object QueryToString(string xllc_)
- {
- return db.Queryable<T_xianlulicheng_sf>().Where(it => it.Xllc == xllc_).Single();
- }
- /// <summary>
- /// 查询线路名
- /// </summary>
- /// <param name="xllc_">简称</param>
- /// <returns></returns>
- public static Object QueryToXlm(string xlmjx)
- {
- return db.Queryable<T_luxianming_sf>().Where(it => it.Xlmsx == xlmjx).First();
- }
- /// <summary>
- /// 查询最大id
- /// </summary>
- /// <param name="tablename"></param>
- /// <returns></returns>
- public static int QueryMaxID(string tablename)
- {
- var list1 = new mm();
- if (tablename == "lgl")
- {
- list1 = db.SqlQueryable<mm>("select MAX(ID) from \"t_lunguili_boxing\"").Single();
- }
- else
- {
- list1 = db.SqlQueryable<mm>("select MAX(ID) from \"t_jihefenxi_boxing\"").Single();
- }
- return list1.Max;
- }
- /// 查询电务功率全部信息
- public static List<T_dwfile_account> QueryDWGLALL()
- {
- return db.Queryable<T_dwfile_account>().ToList();
- }
- /// <summary>
- /// 查询道岔台账全部信息
- /// </summary>
- public static List<T_daocha_account> QueryDCTZALL()
- {
- return db.Queryable<T_daocha_account>().ToList();
- }
- /// <summary>
- /// 查询道岔台账信息
- /// </summary>
- public static Object QueryDCTZ(string xlm,Char[] hangbie)
- {
- if (hangbie[hangbie.Length-1] == 'S')
- {
- return db.Queryable<T_daocha_account>().Where(it => it.Xlm == xlm && it.Xingbie == "上"||it.Xingbie == "上行").ToList();
- }
- else
- {
- return db.Queryable<T_daocha_account>().Where(it => it.Xlm == xlm && it.Xingbie == "下" || it.Xingbie == "下行").ToList();
- }
- }
- /// <summary>
- /// 查询管界台账信息
- /// </summary>
- public static Object QueryGJTZ(string xlm, Char[] hangbie)
- {
- if (hangbie[hangbie.Length - 1] == 'S')
- {
- return db.Queryable<T_guanjie_account>().Where(it => it.Xianming == xlm && it.Hangbie == "上" || it.Hangbie == "上行").ToList();
- }
- else
- {
- return db.Queryable<T_guanjie_account>().Where(it => it.Xianming == xlm && it.Hangbie == "下" || it.Hangbie == "下行").ToList();
- }
- }
- /// <summary>
- /// 查询曲线台账信息
- /// </summary>
- public static Object QueryQXTZ(string xlm, Char[] hangbie)
- {
- if (hangbie[hangbie.Length - 1] == 'S')
- {
- return db.Queryable<T_quxian_account>().Where(it => it.Xianming == xlm && it.Hangbie == "上" || it.Hangbie == "上行").ToList();
- }
- else
- {
- return db.Queryable<T_quxian_account>().Where(it => it.Xianming == xlm && it.Hangbie == "下" || it.Hangbie == "下行").ToList();
- }
- }
- //*********************************************************************************************************
- /// <summary>
- /// 插入尖轨尖心轨间距表
- /// </summary>
- public static void InsertJGJXGJJ(T_jgjdistance_table updateObjs)
- {
- db.Insertable(updateObjs).ExecuteCommand();
- }
- /// <summary>
- /// 查询尖轨尖心轨间距表
- /// </summary>
- public static List<T_jgjdistance_table> QueryJGJXGJJ()
- {
- return db.Queryable<T_jgjdistance_table>().ToList();
- }
- /// <summary>
- /// 删除数据 by ID
- /// </summary>
- public static void DelJGJXGJJ(string Id)
- {
- db.Deleteable<T_jgjdistance_table>().Where(it => it.Id.ToString() == Id).ExecuteCommand();
- }
- /// <summary>
- /// 更新数据
- /// </summary>
- /// <param name="uuid">更新的ID</param>
- /// <param name="issave">更新类型 true 仅为了逻辑 false 真是更新</param>
- public static void UpdataJGJXGJJ(bool issave,T_jgjdistance_table data)
- {
- if (issave)
- {
- db.Updateable<T_jgjdistance_table>(it => new T_jgjdistance_table() { Isnew = "no" }).Where(it => it.Id.ToString() == data.Id).ExecuteCommand();
- }
- else
- {
- db.Updateable<T_jgjdistance_table>(it => new T_jgjdistance_table() { Zch = data.Zch,Dcqc = data.Dcqc,Gdjxgjj=data.Gdjxgjj, Isnew = "yes" }).Where(it => it.Id.ToString() == data.Id).ExecuteCommand();
- }
- }
- /// <summary>
- /// 清理中间数据
- /// </summary>
- public static void ClearCacheJGJXGJJ()
- {
- db.Deleteable<T_jgjdistance_table>().Where(it => it.Isnew == "no" || it.Isnew == "").ExecuteCommand();
- }
- //*********************************************************************************************************
- /// <summary>
- /// 初始化表id值,因为id是自增的,有时候删除表内数据之后,id后间断
- /// 长时间下,可能未出现id间断几十万的情况,可以使用一下两句sql语句将id值重新归零,让他从1开始进行自增
- /// </summary>
- public static void chushihuaPG()
- {
- NpgsqlConnection conn = new NpgsqlConnection();
- conn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbConnection"] as string;
- NpgsqlCommand comm = new NpgsqlCommand();
- comm.Connection = conn;
- conn.Open();
- comm.CommandText = @"ALTER TABLE public.t_file_account DROP COLUMN id;alter table public.t_file_account add id serial PRIMARY KEY;";
- //comm.CommandText = @"SELECT* FROM " + tablename + " where " + querystring;
- comm.ExecuteNonQuery();
- conn.Close();
- }
- public static void GetTongDaoData(ref List<T_metadata_account> metadata)
- {
- metadata = db.Queryable<T_metadata_account>().ToList();
- }
- /// <summary>
- /// 查询全部
- /// </summary>
- public static void GetAllData(ref List<T_jihefenxi_boxing> jhbx, ref List<T_lunguili_boxing> lglbx,decimal jgj,string xlm,string xingbie)
- {
- //var aa = test.GetType() == typeof(List<T_daocha_account>);
- var dc = db.Queryable<T_daocha_account>().Where(it => it.Xlm == xlm && it.Xingbie == xingbie && it.Jgjlc == jgj).ToList();
- var jh = db.Queryable<T_jihefenxi_account>().Where(it => it.Xlm == xlm && it.Xingbie == xingbie && it.Jgjlc == jgj).ToList();
- var lgl = db.Queryable<T_lunguili_account>().Where(it => it.Xlm == xlm && it.Xingbie == xingbie && it.Jgjlc == jgj).ToList();
- if (dc.Count > 0 && jh.Count > 0 && lgl.Count > 0)
- {
- decimal jhindex0 = Convert.ToDecimal(jh[jh.Count - 1].Yswjm_jhfx.Split(',')[0]);
- decimal jhindex1 = Convert.ToDecimal(jh[jh.Count - 1].Yswjm_jhfx.Split(',')[1]);
- decimal lglindex0 = Convert.ToDecimal(lgl[0].Yswjm.Split(',')[0]);
- decimal lglindex1 = Convert.ToDecimal(lgl[0].Yswjm.Split(',')[1]);
- jhbx = db.Queryable<T_jihefenxi_boxing>().Where(it => it.Id >= jhindex0 && it.Id <= jhindex1).ToList();
- lglbx = db.Queryable<T_lunguili_boxing>().Where(it => it.Id >= lglindex0 && it.Id <= lglindex1).ToList();
- }
- }
- }
- }
|