From 68d502cb23ca881d7601b08ab593670d2c654ef0 Mon Sep 17 00:00:00 2001 From: ddlucky Date: Tue, 25 Jun 2024 09:51:37 +0800 Subject: [PATCH] =?UTF-8?q?20240625=20=E6=8E=A5=E6=94=B6=E5=A4=A7=E7=AE=80?= =?UTF-8?q?=E4=BA=91=E8=AE=A2=E8=88=B1=20=E7=AE=B1=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=AF=8F=E6=AC=A1=E9=83=BD=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E4=BF=9D=E5=AD=98=E6=AD=A4=E6=AC=A1=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DSWeb/Areas/CommMng/DAL/PubSysDAL.cs | 152 +++++++++++++++------------ 1 file changed, 87 insertions(+), 65 deletions(-) diff --git a/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs b/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs index 1b30f9f5..2dc9b8d1 100644 --- a/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs +++ b/DSWeb/Areas/CommMng/DAL/PubSysDAL.cs @@ -1220,56 +1220,78 @@ namespace DSWeb.Areas.CommMng.DAL if (ctnInputs != null) { - var CurrCtnList = new List(); + //var CurrCtnList = new List(); if (BSNO != "*") { - //CurrCtnList = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL.GetBodyList($" BSNO='{BSNO}'"); - - CurrCtnList = cdc.OP_CTN.Where(x => x.BSNO == BSNO).ToList(); - - var djyctnids = ctnInputs.Select(x => x.id).ToList(); - - var 需删除Ctn = CurrCtnList.Where(x => !djyctnids.Contains(x.DJYCTNID)).ToList(); - - if (需删除Ctn != null && 需删除Ctn.Count > 0) + ////CurrCtnList = DSWeb.MvcShipping.DAL.MsOpSeaeDAL.MsOpSeaeDAL.GetBodyList($" BSNO='{BSNO}'"); + + //CurrCtnList = cdc.OP_CTN.Where(x => x.BSNO == BSNO).ToList(); + + //var djyctnids = ctnInputs.Select(x => x.id).ToList(); + + //var 需删除Ctn = CurrCtnList.Where(x => !djyctnids.Contains(x.DJYCTNID)).ToList(); + + //if (需删除Ctn != null && 需删除Ctn.Count > 0) + //{ + + // cdc.OP_CTN.RemoveRange(需删除Ctn); + // cdc.SaveChanges(); + // result.AddRange(需删除Ctn); + // //var 需删除Ctnid = 需删除Ctn.Select(s => s.CTN_ID).ToArray(); + + // //var delidstr = "'"+string.Join("','", 需删除Ctnid )+ "'"; + + // //Database db = DatabaseFactory.CreateDatabase(); + // //using (var conn = db.CreateConnection()) + // //{ + // // conn.Open(); + // // var tran = conn.BeginTransaction(); + // // try + // // { + // // var cmdDeletectn = db.GetSqlStringCommand(" delete from op_ctn where ctn_id in(" + delidstr + ") "); + // // db.ExecuteNonQuery(cmdDeletectn, tran); + // // } + // // catch (Exception e) + // // { + // // tran.Rollback(); + // // BasicDataRefDAL.SaveLog(JsonConvert.SerializeObject(e), "删除箱", "接收大简云订舱", "错误"); + // // //return result; + // // } + // //} + //} + + //20240625 改为删除所有本地集装箱信息 然后重新保存报文里的 + var delcondition = $" BSNO='{BSNO}'"; + + Database db = DatabaseFactory.CreateDatabase(); + using (var conn = db.CreateConnection()) { - - cdc.OP_CTN.RemoveRange(需删除Ctn); - result.AddRange(需删除Ctn); - //var 需删除Ctnid = 需删除Ctn.Select(s => s.CTN_ID).ToArray(); - - //var delidstr = "'"+string.Join("','", 需删除Ctnid )+ "'"; - - //Database db = DatabaseFactory.CreateDatabase(); - //using (var conn = db.CreateConnection()) - //{ - // conn.Open(); - // var tran = conn.BeginTransaction(); - // try - // { - // var cmdDeletectn = db.GetSqlStringCommand(" delete from op_ctn where ctn_id in(" + delidstr + ") "); - // db.ExecuteNonQuery(cmdDeletectn, tran); - // } - // catch (Exception e) - // { - // tran.Rollback(); - // BasicDataRefDAL.SaveLog(JsonConvert.SerializeObject(e), "删除箱", "接收大简云订舱", "错误"); - // //return result; - // } - //} + conn.Open(); + var tran = conn.BeginTransaction(); + try + { + var cmdDeletectn = db.GetSqlStringCommand(" delete from op_ctn where "+ delcondition); + db.ExecuteNonQuery(cmdDeletectn, tran); + BasicDataRefDAL.SaveLog(cmdDeletectn, "删除箱", "接收大简云订舱", "执行"); + } + catch (Exception e) + { + tran.Rollback(); + BasicDataRefDAL.SaveLog(JsonConvert.SerializeObject(e), "删除箱", "接收大简云订舱", "错误"); + //return result; + } } } foreach (var ctn in ctnInputs) { var 箱型infoList = cdc.CODE_CTN.Where(x => - (x.CTNSIZE + "'" + x.CTNTYPE) == ctn.ctnall - || (x.CTNSIZE + x.CTNTYPE) == ctn.ctnall - || (x.CTNSIZE + "'" + x.CTNTYPE.Replace("OT", "O/T")) == ctn.ctnall - || (x.CTNSIZE + x.CTNTYPE.Replace("OT", "O/T")) == ctn.ctnall - + (x.CTNSIZE + "'" + x.CTNTYPE) == ctn.ctnall + || (x.CTNSIZE + x.CTNTYPE) == ctn.ctnall + || (x.CTNSIZE + "'" + x.CTNTYPE.Replace("OT", "O/T")) == ctn.ctnall + || (x.CTNSIZE + x.CTNTYPE.Replace("OT", "O/T")) == ctn.ctnall ).ToList(); var 箱型info = new CODE_CTN_md(); if (箱型infoList != null && 箱型infoList.Count > 0) @@ -1283,37 +1305,37 @@ namespace DSWeb.Areas.CommMng.DAL var ctnbsno = BSNO; - if ( CurrCtnList.Exists(x => x.DJYCTNID == ctn.id)) - { - ctnbsno = BSNO; - var updctn = CurrCtnList.FirstOrDefault(x => x.DJYCTNID == ctn.id); - updctn.CTNCODE = 箱型info.CTNID; - updctn.SIZE = 箱型info.CTNSIZE; - updctn.CTN = 箱型info.CTN; - updctn.BSNO = ctnbsno; - updctn.CTNALL = ctn.ctnall; - updctn.CTNNUM = ctn.ctnnum == null ? 0 : (int)ctn.ctnnum; - updctn.CNTRNO = ctn.cntrno; - updctn.SEALNO = ctn.sealno; - updctn.PKGS = ctn.pkgs == null ? 0 : (int)ctn.pkgs; - updctn.KINDPKGS = ctn.kindpkgs; - updctn.KGS = ctn.kgs == null ? 0 : (decimal)ctn.kgs; - updctn.CBM = ctn.cbm == null ? 0 : (decimal)ctn.cbm; - updctn.TAREWEIGHT = ctn.tareweight == null ? 0 : (decimal)ctn.tareweight; - updctn.TEU = 箱型info.TEU == null ? 0 : (int)箱型info.TEU; - updctn.WEIGHKGS = ctn.weighkgs == null ? 0 : (decimal)ctn.weighkgs; - //DJYCTNID = ctn.id; - result.Add(updctn); - cdc.OP_CTN.AddOrUpdate(updctn); - } - else - { + //if ( CurrCtnList.Exists(x => x.DJYCTNID == ctn.id)) + //{ + // ctnbsno = BSNO; + // var updctn = CurrCtnList.FirstOrDefault(x => x.DJYCTNID == ctn.id); + // updctn.CTNCODE = 箱型info.CTNID; + // updctn.SIZE = 箱型info.CTNSIZE; + // updctn.CTN = 箱型info.CTN; + // updctn.BSNO = ctnbsno; + // updctn.CTNALL = ctn.ctnall; + // updctn.CTNNUM = ctn.ctnnum == null ? 0 : (int)ctn.ctnnum; + // updctn.CNTRNO = ctn.cntrno; + // updctn.SEALNO = ctn.sealno; + // updctn.PKGS = ctn.pkgs == null ? 0 : (int)ctn.pkgs; + // updctn.KINDPKGS = ctn.kindpkgs; + // updctn.KGS = ctn.kgs == null ? 0 : (decimal)ctn.kgs; + // updctn.CBM = ctn.cbm == null ? 0 : (decimal)ctn.cbm; + // updctn.TAREWEIGHT = ctn.tareweight == null ? 0 : (decimal)ctn.tareweight; + // updctn.TEU = 箱型info.TEU == null ? 0 : (int)箱型info.TEU; + // updctn.WEIGHKGS = ctn.weighkgs == null ? 0 : (decimal)ctn.weighkgs; + // //DJYCTNID = ctn.id; + // result.Add(updctn); + // cdc.OP_CTN.AddOrUpdate(updctn); + //} + //else + //{ //如果DS7里面没有这个djyctnid,保存时新增,依据BSNO = *作为标记(ds7现有逻辑) var newctn = ctn.GetNewCtn(BSNO, 箱型info); result.Add(newctn); cdc.OP_CTN.Add(newctn); - } + //} }