From 8766897be52c9802299550237e2c0e0787ef1f56 Mon Sep 17 00:00:00 2001 From: qian Date: Tue, 24 Sep 2024 11:15:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/SCP_PLAN_CONTROLLER.cs | 402 +----------------- 北京北汽/Controller/SCP_PO_CONTROLLER.cs | 323 +++++--------- 北京北汽/Models/CK.SCP.Models.csproj | 2 - 北京北汽/Models/ScpEntity/TB_ASN.cs | 88 ++-- 北京北汽/Models/ScpEntity/V_TB_PO_PLAN.cs | 105 ----- .../Models/ScpEntity/V_TB_PO_PLAN_DETAIL.cs | 31 -- 北京北汽/SCP/SCP.csproj | 8 - 7 files changed, 168 insertions(+), 791 deletions(-) delete mode 100644 北京北汽/Models/ScpEntity/V_TB_PO_PLAN.cs delete mode 100644 北京北汽/Models/ScpEntity/V_TB_PO_PLAN_DETAIL.cs diff --git a/北京北汽/Controller/SCP_PLAN_CONTROLLER.cs b/北京北汽/Controller/SCP_PLAN_CONTROLLER.cs index 4b412d0..d39d09b 100644 --- a/北京北汽/Controller/SCP_PLAN_CONTROLLER.cs +++ b/北京北汽/Controller/SCP_PLAN_CONTROLLER.cs @@ -1576,15 +1576,15 @@ namespace CK.SCP.Controller var OrderList = _lst.GroupBy(p => p.PoBillNum).ToList(); OrderList.ForEach((p) => { - + var list = p.ToList(); if (list.Count > 0) { var _entity = list.FirstOrDefault(); - var _priceList= db.V_TB_PRICE.Where(price => price.StartTime <= _entity.EndTime && _entity.EndTime <= price.EndTime &&price.VendId== _entity.VendId); + var _priceList = db.V_TB_PRICE.Where(price => price.StartTime <= _entity.EndTime && _entity.EndTime <= price.EndTime && price.VendId == _entity.VendId); if (_priceList != null && _priceList.Count() > 0) { - + TB_ASK _ask = new TB_ASK(); _ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakePLAN_EXTEND_ASKCode(); @@ -1630,7 +1630,7 @@ namespace CK.SCP.Controller List _ls = new List(); list.ForEach((itm) => { - + @@ -1668,7 +1668,7 @@ namespace CK.SCP.Controller } else { - _ret.MessageList.Add(string.Format("供应商编号{0}零件{1}计划到货时间{2}内无价格表!",_ask.VendId,_t_ASK_Detail.PartCode,_ask.EndTime)); + _ret.MessageList.Add(string.Format("供应商编号{0}零件{1}计划到货时间{2}内无价格表!", _ask.VendId, _t_ASK_Detail.PartCode, _ask.EndTime)); } _t_ASK_Detail.GUID = Guid.NewGuid(); @@ -1679,7 +1679,7 @@ namespace CK.SCP.Controller } else { - _ret.MessageList.Add(string.Format("供应商编号{0}计划到货时间{1}范围内无价格表!",_entity.VendId,_entity.EndTime)); + _ret.MessageList.Add(string.Format("供应商编号{0}计划到货时间{1}范围内无价格表!", _entity.VendId, _entity.EndTime)); } } @@ -1919,396 +1919,6 @@ namespace CK.SCP.Controller // return _ret; //} - public static ResultObject PLAN_TO_ASK1(List p_order_list, User p_user) - { - ResultObject _ret = new ResultObject(); - try - { - using (ScpEntities db = EntitiesFactory.CreateScpInstance()) - { - List lineError = new List(); - List ErrorList = new List(); - var _lst = p_order_list.Where(p => p.PlanQty != 0).ToList(); - - if (lineError.Count > 0) - { - _ret.State = ReturnStatus.Failed; - _ret.MessageList.AddRange(ErrorList); - _ret.Result = false; - } - else - { - var VenderList = _lst.Select(p => p.VendId).Distinct(); - var PartCodeList = _lst.Select(p => p.PartCode).Distinct(); - var OrderList = _lst.GroupBy(p => p.PoBillNum).ToList(); - OrderList.ForEach((p) => - { - var list = p.ToList(); - if (list.Count > 0) - { - var _entity = list.FirstOrDefault(); - TB_ASK _ask = new TB_ASK(); - _ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCode(); - _ask.VendId = _entity.VendId; - _ask.State = (int)AskState.New; - _ask.PoBillNum = _entity.PoBillNum; - _ask.ModType = (int)BillModType.Contract; - _ask.Site = _entity.Site; - _ask.Remark = _entity.Version; - _ask.State = (int)AskState.New; - DateTime date = DateTime.Now; - string str = date.Year.ToString(); - string str1 = date.Month.ToString(); - string datetime = str + "-" + str1; - _ask.UpdateTime = DateTime.Parse(datetime); - _ask.Buyer = p_user.ChineseName; - _ask.BuyerPhone = p_user.CellPhone; - _ask.ErpBillNum = _entity.PoBillNum; - _ask.BeginTime = DateTime.Parse( _entity.BeginTime.ToString()); - _ask.EndTime = _entity.EndTime; - _ask.CreateTime = DateTime.Now.Date; - _ask.CreateUser = p_user.Name; - _ask.VendId = _entity.VendId; - _ask.GUID = Guid.NewGuid(); - _ask.ReceivedPort = string.Empty; - _ask.IsDeleted = false; - _ask.SubSite = p_user.UserdSite; - db.TB_ASK.Add(_ask); - #region 供应商新任务代办接口 - TB_PENING_ITEMS _item = new TB_PENING_ITEMS(); - _item.ROLE_NAME = "供应商"; - _item.ITEM_NO = _ask.AskBillNum; - _item.ITEM_CONTENT = "要货看盘有信息"; - _item.ITEM_TYPE = (int)PENDING_MESSAGE_TYPE.NEW_ASK; - _item.VEND_ID = _ask.VendId; - _item.ITEM_STATE = (int)PENDING_STATE.WAITING; - _item.SENDER = p_user.ChineseName; - _item.SENDING_TIME = DateTime.Now; - db.TB_PENING_ITEMS.Add(_item); - #endregion - // int _number = 1; - List _ls = new List(); - list.ForEach((itm) => - { - var _number = _ls.Count(p1 => p1.PoBillNum == _ask.PoBillNum - && p1.PoLine == itm.PoLine && p1.PartCode == itm.PartCode); - if (_number > 0) - { - _ret.MessageList.Add(string.Format("已经存在订单为{0}行号为{1}零件编码为{2}", itm.PoBillNum, itm.PoLine.ToString(), itm.PartCode)); - } - TB_ASK_DETAIL _t_ASK_Detail = new TB_ASK_DETAIL(); - //_t_ASK_Detail.PoLine = _number; - _t_ASK_Detail.PoLine = itm.PoLine; - _t_ASK_Detail.Currency = "CNY"; - _t_ASK_Detail.AskBillNum = _ask.AskBillNum; - _t_ASK_Detail.PoBillNum = _ask.PoBillNum; - _t_ASK_Detail.PoUnit = itm.PoUnit; - _t_ASK_Detail.CreateTime = DateTime.Now; - _t_ASK_Detail.CreateUser = _ask.CreateUser; - _t_ASK_Detail.PartCode = itm.PartCode; - _t_ASK_Detail.BeginTime = _ask.BeginTime; - _t_ASK_Detail.EndTime = itm.EndTime; - _t_ASK_Detail.TempQty = itm.PlanQty; - _t_ASK_Detail.AskQty = itm.PlanQty; - _t_ASK_Detail.IsDeleted = false; - _t_ASK_Detail.LocUnit = itm.PoUnit; - _t_ASK_Detail.UnConv = 1; - _t_ASK_Detail.Remark = itm.Version; - _t_ASK_Detail.State = _ask.State; - _t_ASK_Detail.SubSite = p_user.UserdSite; - // _t_ASK_Detail.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.价格); - _t_ASK_Detail.GUID = Guid.NewGuid(); - _t_ASK_Detail.Remark = _ask.Site; - db.TB_ASK_DETAIL.Add(_t_ASK_Detail); - _ls.Add(_t_ASK_Detail); - // _number++; - }); - - } - else - { - _ret.MessageList.Add("ERP订单编号已存在,请重新导入!"); - - } - if (_ret.MessageList.Count == 0) - { - int state = db.SaveChanges(); - if (state != -1) - { - _ret.State = ReturnStatus.Succeed; - _ret.Result = true; - } - else - { - _ret.State = ReturnStatus.Failed; - _ret.Result = false; - } - } - else - { - _ret.State = ReturnStatus.Failed; - _ret.Result = false; - } - } - ); - } - } - } - catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 - { - var sb = new StringBuilder(); - foreach (var error in dbEx.EntityValidationErrors.ToList()) - { - error.ValidationErrors.ToList().ForEach(i => - { - sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); - }); - } - _ret.State = ReturnStatus.Failed; - _ret.Result = false; - _ret.ErrorList.Add(dbEx); - LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_TO_ASK", sb.ToString()); - throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); - } - catch (OptimisticConcurrencyException ex)//并发冲突异常 - { - - _ret.State = ReturnStatus.Failed; - _ret.Result = false; - _ret.ErrorList.Add(ex); - LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_TO_ASK", ex.ToString()); - throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); - } - catch (ScpException ex) - { - _ret.State = ReturnStatus.Failed; - _ret.Result = false; - _ret.ErrorList.Add(ex); - LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_TO_ASK", ex.ToString()); - - if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) - { - var inner = (UpdateException)ex.InnerException; - - - throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); - } - else - { - if (ex.InnerException != null) throw ex.InnerException; - } - } - catch (Exception e) - { - _ret.State = ReturnStatus.Failed; - LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_TO_ASK", e.Message); - _ret.Result = false; - _ret.ErrorList.Add(e); - throw e; - } - return _ret; - - } - public static DataTable Get_TB_PLAN_REPORT(V_TB_PO_PLAN p_plan) - { - DataTable dt = new DataTable(); - DataTable dt1 = new DataTable(); - DataTable dt2 = new DataTable(); - DataTable dt3 = new DataTable(); - string _sqlString = "SELECT * FROM ( SELECT partcode,endtime,planqty,partdesc,pounit,domain,pobillnum,poline FROM V_TB_PO_PLAN where {0}\n " + - ") A\n" + - " pivot ( sum(planQty) for a.endtime in (\n" + - " {1}\n" + - ")\n" + - ") as ourpivot "; - - string _sql = "SELECT DISTINCT(ENDTIME) FROM V_TB_PO_PLAN where {0} ORDER BY ENDTIME"; - - string _askBillSql = "SELECT * FROM V_TB_ASK_DETAIL where VENDID = '{0}' AND EndTime IN ({1}) AND AskBillNum like 'E%' "; - - string _asn_recive = "SELECT A.PartCode, A.PoBillNum, A.PoLine, SUM(A.Qty) AS AsnQty, SUM(ISNULL(B.Qty, 0)) AS ReciveQty,\n" + - " SUM(ISNULL(C.AskQty, 0)) AS AskQty\n" + - "FROM V_TB_ASN_DETAIL AS A LEFT OUTER JOIN\n" + - " V_TB_RECEIVE_DETAIL AS B ON A.AsnBillNum = B.AsnBillNum AND A.PartCode = B.PartCode AND\n" + - " A.PoBillNum = B.PoBillNum AND A.PoLine = B.PoLine INNER JOIN\n" + - " TB_ASK_DETAIL AS C ON A.AskBillNum = C.AskBillNum AND A.PartCode = C.PartCode AND\n" + - " A.PoBillNum = C.PoBillNum AND A.PoLine = C.PoLine\n" + - "WHERE (A.AskBillNum LIKE 'E%') AND (A.State > 0) and {0}\n" + - "GROUP BY A.PartCode, A.PoBillNum, A.PoLine"; - var dbSetting = GlobalConfig.ScpDatabase; - try - { - var strConn = EntitiesFactory.GetEfConnectionString(dbSetting); - SqlConnection conn = new System.Data.SqlClient.SqlConnection(); - conn.ConnectionString = strConn; - if (conn.State != ConnectionState.Open) - { - conn.Open(); - } - #region 结束时间范围 - SqlCommand cmd = new SqlCommand(); - cmd.Connection = conn; - string where1 = " 1=1 "; - if (!string.IsNullOrEmpty(p_plan.PartCode)) - { - where1 += string.Format(" and partcode='{0}' ", p_plan.PartCode); - } - if (!string.IsNullOrEmpty(p_plan.VendId)) - { - where1 += string.Format(" and VendId='{0}' ", p_plan.VendId); - } - if (!string.IsNullOrEmpty(p_plan.PoBillNum)) - { - where1 += string.Format(" and PoBillNum='{0}' ", p_plan.PoBillNum); - } - if (p_plan.EndTime_Begin != null) - { - where1 += string.Format(" and EndTime>='{0}'", p_plan.EndTime_Begin.Value.ToString("yyyy-MM-dd")); - } - else - { - where1 += string.Format(" and EndTime>='{0}'", DateTime.Now.ToString("yyyy-MM-dd")); - } - if (p_plan.EndTime_End != null) - { - where1 += string.Format(" and EndTime<='{0}'", p_plan.EndTime_End.Value.ToString("yyyy-MM-dd")); - } - else - { - where1 += string.Format(" and EndTime<='{0}'", DateTime.Now.AddMonths(1).ToString("yyyy-MM-dd")); - } - cmd.CommandText = string.Format(_sql, where1); - SqlDataAdapter adapter = new SqlDataAdapter(cmd); - adapter.Fill(dt); - - #endregion - List _ls = new List(); - List _ls1 = new List(); - foreach (DataRow row in dt.Rows) - { - _ls.Add(string.Format("[{0}]", row["EndTime"].ToString())); - _ls1.Add(string.Format("'{0}'", row["EndTime"].ToString())); - } - if (_ls.Count > 0) - { - #region 计划行转列 - SqlCommand cmd1 = new SqlCommand(); - cmd1.Connection = conn; - string where = "1=1 "; - if (!string.IsNullOrEmpty(p_plan.PartCode)) - { - where += string.Format(" and partcode='{0}' ", p_plan.PartCode); - } - where += string.Format(" and VendId='{0}' ", p_plan.VendId); - if (!string.IsNullOrEmpty(p_plan.PoBillNum)) - { - where += string.Format(" and PoBillNum='{0}' ", p_plan.PoBillNum); - } - cmd1.CommandText = string.Format(_sqlString, where, string.Join(",", _ls.ToArray())); - var adapter1 = new SqlDataAdapter(cmd1); - adapter1.Fill(dt1); - #endregion - - #region 此范围内的看板号 - SqlCommand cmd2 = new SqlCommand(); - cmd2.Connection = conn; - cmd2.CommandText = string.Format(_askBillSql, p_plan.VendId, string.Join(",", _ls1.ToArray())); - SqlDataAdapter adapter2 = new SqlDataAdapter(cmd2); - adapter2.Fill(dt2); - #endregion - - List _askList = new List(); - foreach (DataRow row in dt2.Rows) - { - _askList.Add(string.Format("'{0}'", row["AskBillNum"].ToString())); - } - if (_askList.Count > 0) - { - SqlCommand cmd3 = new SqlCommand(); - cmd3.Connection = conn; - cmd3.CommandText = string.Format(_asn_recive, string.Format(" A.askBillNum in ({0}) ", string.Join(",", _askList.ToArray()))); - SqlDataAdapter adapter3 = new SqlDataAdapter(cmd3); - adapter3.Fill(dt3); - } - var column0 = dt1.Columns.Add("要货数量"); - var column1 = dt1.Columns.Add("收货数量"); - var column2 = dt1.Columns.Add("发货数量"); - var column3 = dt1.Columns.Add("未发数量"); - var column4 = dt1.Columns.Add("未收数量"); - foreach (DataRow dr in dt1.Rows) - { - foreach (DataRow row in dt3.Rows) - { - if ( - dr["PartCode"].ToString() == row["PartCode"].ToString() - && dr["PoBillNum"].ToString() == row["PoBillNum"].ToString() - && dr["PoLine"].ToString() == row["PoLine"].ToString()) - { - dr["要货数量"] = row["ReciveQty"].ToString(); - dr["收货数量"] = row["ReciveQty"].ToString(); - dr["发货数量"] = row["AsnQty"].ToString(); - dr["未收数量"] = decimal.Parse(row["AsnQty"].ToString()) - decimal.Parse(row["ReciveQty"].ToString()); - dr["未发数量"] = decimal.Parse(row["AskQty"].ToString()) - decimal.Parse(row["AsnQty"].ToString()); - } - } - } - foreach (DataColumn column in dt1.Columns) - { - try - { - var _dt1 = DateTime.Parse(column.ColumnName); - var _curDate = _dt1.ToString("yyyy-MM-dd"); - column.ColumnName = _curDate + "(预测)";//要货预测头 - - foreach (DataRow row in dt2.Rows) - { - var _cur = DateTime.Parse(row["EndTime"].ToString()).ToString("yyyy-MM-dd");//看板时间 - StringBuilder _buf = new StringBuilder(); - if (_curDate == _cur) - { - var _ask = row["AskBillNum"].ToString(); - column.ColumnName = _cur + "(" + _ask + ")"; - switch (int.Parse(row["state"].ToString())) - { - case (int)AskState.New: - column.ColumnName = _cur + "(" + _ask + ")" + "(计划)"; - break; - case (int)AskState.Ship: - column.ColumnName = _cur + "(" + _ask + ")" + "(已发货)"; - break; - case (int)AskState.Confirm: - column.ColumnName = _cur + "(" + _ask + ")" + "(已确认)"; - break; - case (int)AskState.Release: - column.ColumnName = _cur + "(" + _ask + ")" + "(已发布)"; - break; - case (int)AskState.Receive: - column.ColumnName = _cur + "(" + _ask + ")" + "(已收货)"; - break; - } - } - } - } - catch - { - continue; - } - } - dt1.Columns["PartCode"].ColumnName = "零件编码"; - dt1.Columns["PartDesc"].ColumnName = "零件描述"; - dt1.Columns["PoUnit"].ColumnName = "单位"; - dt1.Columns["PoBillNum"].ColumnName = "订单编号"; - dt1.Columns["PoLine"].ColumnName = "行号"; - dt1.Columns["Domain"].ColumnName = "域"; - } - conn.Close(); - } - catch (SqlException ex) - { - throw new Exception($"系统无法连接到数据库:{dbSetting},请检查配置的服务器,数据库,用户名和密码等信息是否正确。{Environment.NewLine}{ex}"); - } - return dt1; - } } } diff --git a/北京北汽/Controller/SCP_PO_CONTROLLER.cs b/北京北汽/Controller/SCP_PO_CONTROLLER.cs index 5762657..0efa55a 100644 --- a/北京北汽/Controller/SCP_PO_CONTROLLER.cs +++ b/北京北汽/Controller/SCP_PO_CONTROLLER.cs @@ -508,7 +508,7 @@ namespace CK.SCP.Controller foreach (var po1 in p_list1) { var PoDetail = db.TB_ASK_DETAIL.SingleOrDefault(p => p.PoBillNum == po && p.PartCode == po1); - PoDetail.AskQty=0; + PoDetail.AskQty = 0; db.TB_ASK_DETAIL.AddOrUpdate(PoDetail); } @@ -1067,17 +1067,17 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("供应商编号【{0}】有填写为空!", p_excel.供应商编号)); } return ErrorList; - + } private static List CheckExcelMode_Vender1(ScpEntities db, SCP_PRICE_EXPORT p_excel) { List ErrorList = new List(); - - - if ( - string.IsNullOrEmpty(p_excel.零件最新价格) || - string.IsNullOrEmpty(p_excel.最新开始时间)) + + if ( + + string.IsNullOrEmpty(p_excel.零件最新价格) || + string.IsNullOrEmpty(p_excel.最新开始时间)) { ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】有填写为空!", p_excel.标识, p_excel.供应商编号)); @@ -1096,14 +1096,14 @@ namespace CK.SCP.Controller DateTime st1 = DateTime.Parse(st7.ToShortDateString()); DateTime st5 = DateTime.Parse(p_excel.开始时间); - DateTime st3=DateTime.Parse( st5.ToShortDateString()); + DateTime st3 = DateTime.Parse(st5.ToShortDateString()); Decimal st4 = Decimal.Parse(p_excel.零件基础价格); DateTime dd = st2.AddDays(1); DateTime dd1 = st1.AddYears(10); int b = int.Parse(p_excel.是否临时价格); var Th = db.TB_PRICE.SingleOrDefault(p => p.UID.ToString() == p_excel.标识 && p.VendId == p_excel.供应商编号 && p.PartCode == p_excel.零件编码 - && p.Amt == st4 && p.SubSite == p_excel.地点 &&p.Curr==p_excel.币种&&p.Unit==p_excel.单位 + && p.Amt == st4 && p.SubSite == p_excel.地点 && p.Curr == p_excel.币种 && p.Unit == p_excel.单位 ); if (Th == null) { @@ -1111,14 +1111,14 @@ namespace CK.SCP.Controller } else { - if ((DateTime.Parse(Th.StartTime.ToString())).ToShortDateString()!=st3.ToShortDateString()|| (DateTime.Parse(Th.EndTime.ToString())).ToShortDateString() != st2.ToShortDateString()) + if ((DateTime.Parse(Th.StartTime.ToString())).ToShortDateString() != st3.ToShortDateString() || (DateTime.Parse(Th.EndTime.ToString())).ToShortDateString() != st2.ToShortDateString()) { ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】的导出数据不能修改!", p_excel.标识, p_excel.供应商编号)); } - DateTime STA =DateTime.Parse(Th.StartTime.ToString()); - if(DateTime.Parse(STA.ToShortDateString())!= st3) + DateTime STA = DateTime.Parse(Th.StartTime.ToString()); + if (DateTime.Parse(STA.ToShortDateString()) != st3) { - ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】的导出数据不能修改!", p_excel.标识, p_excel.供应商编号)); + ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】的导出数据不能修改!", p_excel.标识, p_excel.供应商编号)); } if (Th.State != (int)PriceState.FConfirm) { @@ -1128,7 +1128,7 @@ namespace CK.SCP.Controller { ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】最新开始时间填写错误!", p_excel.标识, p_excel.供应商编号)); } - if(st1>st2&& st1 < dd) + if (st1 > st2 && st1 < dd) { ErrorList.Add(string.Format("标识【{0}】供应商编号【{1}】最新开始时间填写错误!", p_excel.标识, p_excel.供应商编号)); } @@ -1144,14 +1144,14 @@ namespace CK.SCP.Controller } } - var _second1 = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件编码 && p.VendId == p_excel.供应商编号&&p.SubSite== p_excel.地点&&p.State!=-1).Select(r => r.UID).Max(); - int a = 0; - int.TryParse(p_excel.标识, out a); - if (a < _second1) - { - ErrorList.Add(string.Format("标识【{0}】供应商编号为【{1}】的零件编号【{2}】价格表里已经存在!", p_excel.标识, p_excel.供应商编号, p_excel.零件编码)); + var _second1 = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件编码 && p.VendId == p_excel.供应商编号 && p.SubSite == p_excel.地点 && p.State != -1).Select(r => r.UID).Max(); + int a = 0; + int.TryParse(p_excel.标识, out a); + if (a < _second1) + { + ErrorList.Add(string.Format("标识【{0}】供应商编号为【{1}】的零件编号【{2}】价格表里已经存在!", p_excel.标识, p_excel.供应商编号, p_excel.零件编码)); + - } return ErrorList; } @@ -1179,12 +1179,12 @@ namespace CK.SCP.Controller } else { - if (p_excel.币种 != "CNY"&& p_excel.币种 != "EUR" && p_excel.币种 != "USD") + if (p_excel.币种 != "CNY" && p_excel.币种 != "EUR" && p_excel.币种 != "USD") { ErrorList.Add(string.Format("供应商编号为【{0}】的零件编号【{1}】币种填写错误,只能是CNY或者EUR或者USD!", p_excel.供应商编号, p_excel.零件编码)); } - var Site = db.TB_FACTORY.Where(p=>p.ErpSite== p_excel.域).FirstOrDefault(); - var _first = db.TA_PART.Where(p => p.PartCode == p_excel.零件编码.Trim() &&p.Site== p_excel.域).FirstOrDefault(); + var Site = db.TB_FACTORY.Where(p => p.ErpSite == p_excel.域).FirstOrDefault(); + var _first = db.TA_PART.Where(p => p.PartCode == p_excel.零件编码.Trim() && p.Site == p_excel.域).FirstOrDefault(); if (_first == null) { ErrorList.Add(string.Format("供应商编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.供应商编号, p_excel.零件编码)); @@ -1197,16 +1197,16 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("零件编号【{0}】状态为SP,无法导入!", p_excel.零件编码)); } } - + p_excel.供应商编号 = !string.IsNullOrEmpty(p_excel.供应商编号) ? p_excel.供应商编号.Trim() : string.Empty; - var _count = db.TA_VENDER.Where(p => p.VendId == p_excel.供应商编号&&p.Site== p_excel.域).Count(); + var _count = db.TA_VENDER.Where(p => p.VendId == p_excel.供应商编号 && p.Site == p_excel.域).Count(); if (_count == 0) { ErrorList.Add(string.Format("未找到供应商编号为【{0}】无法导入!", p_excel.供应商编号)); } - + DateTime st = DateTime.Parse(p_excel.开始时间); DateTime et = DateTime.Parse(p_excel.结束时间); DateTime st_st = Convert.ToDateTime(st.ToShortDateString()); @@ -1251,10 +1251,10 @@ namespace CK.SCP.Controller // ErrorList.Add(string.Format("供应商{0}零件编号{1},新添价格的上期价格不是审批状态", p_excel.供应商编号, p_excel.零件编码)); // } - + //} } - + } return ErrorList; } @@ -1313,7 +1313,7 @@ namespace CK.SCP.Controller // ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.订单编号,p_excel.零件号 )); //} - var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号.Trim()&&p.Site== site); + var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site); if (_checkpart != null) { if (_checkpart.State.ToUpper() != "SP") @@ -1323,21 +1323,21 @@ namespace CK.SCP.Controller else { ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表零件停用,无法导入!", p_excel.订单编号, p_excel.零件号)); - } + } } - var _checkpart1= db.TA_PART.Count(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site); + var _checkpart1 = db.TA_PART.Count(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site); if (_checkpart1 == 0) { ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.订单编号, p_excel.零件号)); } - + DateTime _d = DateTime.Now; #region 日程单验证 - + if (p_modtype == BillModType.Contract) { if (string.IsNullOrEmpty(p_excel.订单编号) || string.IsNullOrEmpty(p_excel.行号) || string.IsNullOrEmpty(p_excel.订单创建时间) || @@ -1348,7 +1348,7 @@ namespace CK.SCP.Controller } else { - if (!string.IsNullOrEmpty(p_excel.备注)&&p_excel.备注.Length > 50) + if (!string.IsNullOrEmpty(p_excel.备注) && p_excel.备注.Length > 50) { ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的备注长度必须小于50", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); } @@ -1413,7 +1413,7 @@ namespace CK.SCP.Controller } break; } - + } else { @@ -1423,12 +1423,12 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】零件号【{2}】的订单编号不正确,请更换订单编号!", p_excel.订单编号, p_excel.行号, p_excel.零件号)); } } - - + + int _polinr = Int32.Parse(p_excel.行号); if (string.IsNullOrEmpty(subsite)) { - var _partlist = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel.订单编号 && p.PartCode == p_excel.零件号.Trim() && p.PoLine != _polinr && p.PoBillNum.Substring(0, 1) == "S").ToList(); + var _partlist = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel.订单编号 && p.PartCode == p_excel.零件号.Trim() && p.PoLine != _polinr && p.PoBillNum.Substring(0, 1) == "S").ToList(); if (_partlist.Count > 0) { ErrorList.Add(string.Format("订单编号【{0}】零件号【{1}】已经存在(系统:行号-【{2}】),请更换零件号!", p_excel.订单编号, p_excel.零件号, _partlist[0].PoLine)); @@ -1437,8 +1437,8 @@ namespace CK.SCP.Controller // 判断北汽多次导入 是否存在零件号重复现象 else { - var _partlist = db.V_TB_PO_DETAIL.Where(p => p.VendId == p_excel.供应商编号.Trim()&&p.SubSite == subsite && p.PartCode == p_excel.零件号.Trim() && p.PoBillNum.Substring(0,1) =="S").ToList(); - if (_partlist.Count > 0 ) + var _partlist = db.V_TB_PO_DETAIL.Where(p => p.VendId == p_excel.供应商编号.Trim() && p.SubSite == subsite && p.PartCode == p_excel.零件号.Trim() && p.PoBillNum.Substring(0, 1) == "S").ToList(); + if (_partlist.Count > 0) { var pobillnum = db.V_TB_PO_DETAIL.FirstOrDefault(p => p.VendId == p_excel.供应商编号.Trim() && p.SubSite == subsite && p.PartCode == p_excel.零件号.Trim() && p.PoBillNum.Substring(0, 1) == "S").PoBillNum; ErrorList.Add(string.Format("订单编号【{0}】零件号【{1}】在【{2}】中存在,请更换零件号!", p_excel.订单编号, p_excel.零件号, pobillnum)); @@ -1447,7 +1447,7 @@ namespace CK.SCP.Controller if (lcount > 0) { var pobillnum = db.V_TB_PO_DETAIL.FirstOrDefault(p => p.VendId == p_excel.供应商编号.Trim() && p.SubSite == subsite && p.PoLine == _polinr && p.PartCode == p_excel.零件号.Trim() && p.PoBillNum.Substring(0, 1) == "S").PoBillNum; - ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】在【{2}】订单中已经存在,请更换行号!", p_excel.订单编号, p_excel.行号,pobillnum)); + ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】在【{2}】订单中已经存在,请更换行号!", p_excel.订单编号, p_excel.行号, pobillnum)); } } @@ -1564,13 +1564,13 @@ namespace CK.SCP.Controller if (!string.IsNullOrEmpty(p_excel.库位) && p_excel.库位.Length > 8) { ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); - } + } } } #endregion #region 离散单验证 - + if (p_modtype == BillModType.Non_Contract) { //if (!string.IsNullOrEmpty(p_excel.订单编号)) @@ -1612,7 +1612,7 @@ namespace CK.SCP.Controller } if (!string.IsNullOrEmpty(p_excel.订单截至日期)) { - DateTime year =DateTime.Parse(p_excel.订单截至日期); + DateTime year = DateTime.Parse(p_excel.订单截至日期); if (year.Year > 2049) { ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); @@ -1628,8 +1628,8 @@ namespace CK.SCP.Controller p_excel.单价 = checkcount[0].Amt.ToString(); p_excel.单位 = checkcount[0].Unit; p_excel.币种 = checkcount[0].Curr; - } - if (!Regex.IsMatch(p_excel.税率, "^[0-9]{1,2}$")) + } + if (!Regex.IsMatch(p_excel.税率, "^[0-9]{1,2}$")) { ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】税率最大2位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); } @@ -1643,7 +1643,7 @@ namespace CK.SCP.Controller else { ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单创建日期或要求到货日期要求为文本格式!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); - } + } //if (DateTime.Parse(p_excel.零件开始时间) > DateTime.Parse(p_excel.零件截至日期)) //{ // ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】零件截止日期不能小于零件开始日期!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); @@ -1689,7 +1689,7 @@ namespace CK.SCP.Controller return ErrorList; } //重庆订单导入验证 - private static List CheckExcelMode_Po_CQ(ScpEntities db, SCP_PO_EXPORT_IMPORT_MODEL p_excel, BillModType p_modtype, string site , string subsite ) + private static List CheckExcelMode_Po_CQ(ScpEntities db, SCP_PO_EXPORT_IMPORT_MODEL p_excel, BillModType p_modtype, string site, string subsite) { List ErrorList = new List(); @@ -1705,7 +1705,7 @@ namespace CK.SCP.Controller // ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.订单编号,p_excel.零件号 )); //} - var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号.Trim()&&p.Site== site); + var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号.Trim() && p.Site == site); if (_checkpart != null) { if (_checkpart.State.ToUpper() != "SP") @@ -1723,7 +1723,7 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.订单编号, p_excel.零件号)); } - + DateTime _d = DateTime.Now; @@ -1761,7 +1761,7 @@ namespace CK.SCP.Controller ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); } } - var pode = db.TB_PO_DETAIL.Count(p=>p.PoBillNum== p_excel.订单编号&&p.PartCode==p_excel.零件号.Trim()); + var pode = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.订单编号 && p.PartCode == p_excel.零件号.Trim()); if (pode > 0) { ErrorList.Add(string.Format("订单号【{1}】零件号【{0}】已存在!", p_excel.零件号, p_excel.订单编号)); @@ -2840,15 +2840,15 @@ namespace CK.SCP.Controller } else { - List PartList = _lst.Select(q => q.零件编码.Trim()).ToList(); - List _partList = db.TA_PART.Where(q => PartList.Contains(q.PartCode)).ToList(); + List PartList = _lst.Select(q => q.零件编码.Trim()).ToList(); + List _partList = db.TA_PART.Where(q => PartList.Contains(q.PartCode)).ToList(); _lst.ForEach(p => { var _price = new TB_PRICE(); - string starttime = DateTime.Parse(p.开始时间).ToShortDateString(); + string starttime = DateTime.Parse(p.开始时间).ToShortDateString(); string endtime = DateTime.Parse(p.结束时间).ToShortDateString(); DateTime st = DateTime.Parse(p.开始时间); - + DateTime et = DateTime.Parse(p.结束时间); #region 201909011修改 var _Site = new SqlParameter("@Site", p.域); @@ -2874,10 +2874,10 @@ namespace CK.SCP.Controller _price.StartTime = DateTime.Parse(starttime); _price.EndTime = DateTime.Parse(endtime); _price.Curr = p.币种; - _price.Unit = _partList.Where(q=>q.PartCode == p.零件编码.Trim()) != null? _partList.First(q => q.PartCode == p.零件编码.Trim()).Unit : p.单位; + _price.Unit = _partList.Where(q => q.PartCode == p.零件编码.Trim()) != null ? _partList.First(q => q.PartCode == p.零件编码.Trim()).Unit : p.单位; _price.Amt = decimal.Parse(p.零件基础价格); _price.Site = p.域.Trim(); - _price.SubSite = p.地点.Trim(); + _price.SubSite = p.地点.Trim(); _price.Remarks = p.备注; _price.TemporaryPrice = Int32.Parse(p.是否临时价格); _price.Creator = p_createuser; @@ -3034,20 +3034,20 @@ namespace CK.SCP.Controller else { _lst.ForEach(p => - { - var _part = db.TA_PART.SingleOrDefault(t => t.PartCode == p.零件编号.ToUpper() && t.Site == p.域) ?? - new TA_PART { PartCode = p.零件编号.ToUpper(), Site = p.域 }; - _part.PartCode = p.零件编号; - _part.ErpPartCode = p.零件编号; - _part.PartDesc1 = p.零件名称; - _part.PartDesc2 = ""; - _part.ProjectId = p.项目编号; - _part.Unit = p.单位; - _part.PartGroup = p.零件类型; - _part.State = p.状态; - _part.Remark = p.备注; - db.TA_PART.AddOrUpdate(_part); - }); + { + var _part = db.TA_PART.SingleOrDefault(t => t.PartCode == p.零件编号.ToUpper() && t.Site == p.域) ?? + new TA_PART { PartCode = p.零件编号.ToUpper(), Site = p.域 }; + _part.PartCode = p.零件编号; + _part.ErpPartCode = p.零件编号; + _part.PartDesc1 = p.零件名称; + _part.PartDesc2 = ""; + _part.ProjectId = p.项目编号; + _part.Unit = p.单位; + _part.PartGroup = p.零件类型; + _part.State = p.状态; + _part.Remark = p.备注; + db.TA_PART.AddOrUpdate(_part); + }); if (_ret.MessageList.Count == 0) { int state = db.SaveChanges(); @@ -3177,8 +3177,8 @@ namespace CK.SCP.Controller { lineError.Add(string.Format("供应商编号{0}零件编号{3}数据不存在", p.供应商编号, p.开始时间, p.结束时间, p.零件编码.Trim())); ErrorList = lineError; - } - if (DateTime.Parse(p.最新开始时间)< DateTime.Parse(p.结束时间) && DateTime.Parse(p.最新开始时间) >DateTime.Parse(p.开始时间)) + } + if (DateTime.Parse(p.最新开始时间) < DateTime.Parse(p.结束时间) && DateTime.Parse(p.最新开始时间) > DateTime.Parse(p.开始时间)) { _vender.EndTime = Convert.ToDateTime(DateTime.Parse(starttime).AddDays(-1)); @@ -3221,9 +3221,9 @@ namespace CK.SCP.Controller } db.TS_UNI_API.Add(TS); } - - db.TB_PRICE.AddOrUpdate(_vender); - } + + db.TB_PRICE.AddOrUpdate(_vender); + } TB_PRICE tb = new TB_PRICE(); tb.State = 0; tb.Extend3 = "价格表修改增加"; @@ -3231,12 +3231,12 @@ namespace CK.SCP.Controller tb.PartCode = p.零件编码.Trim(); tb.Curr = p.币种; tb.Unit = _partList.Where(q => q.PartCode == p.零件编码.Trim()) != null ? _partList.First(q => q.PartCode == p.零件编码.Trim()).Unit : p.单位; - tb.Remarks = p.备注; + tb.Remarks = p.备注; tb.Amt = Convert.ToDecimal(p.零件最新价格); tb.Site = p.域; tb.SubSite = p.地点; - tb.StartTime = Convert.ToDateTime(starttime); - tb.EndTime = Convert.ToDateTime(endtime); + tb.StartTime = Convert.ToDateTime(starttime); + tb.EndTime = Convert.ToDateTime(endtime); tb.Creator = p_createuser; tb.IsPost = 0; tb.TemporaryPrice = Int32.Parse(p.是否临时价格); @@ -3247,10 +3247,10 @@ namespace CK.SCP.Controller if (_ret.MessageList.Count == 0) { - db.BulkSaveChanges(); - - _ret.State = ReturnStatus.Succeed; - _ret.Result = true; + db.BulkSaveChanges(); + + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; //} //else //{ @@ -3365,7 +3365,7 @@ namespace CK.SCP.Controller _lst.ForEach (p => { - var _ls = CheckExcelMode_Po(db, p, p_modtype,site,subsite); + var _ls = CheckExcelMode_Po(db, p, p_modtype, site, subsite); if (_ls.Count > 0) { lineError.Add(number.ToString()); @@ -3617,17 +3617,17 @@ namespace CK.SCP.Controller using (ScpEntities db = EntitiesFactory.CreateScpInstance()) { List ErrorList = new List(); - foreach(var po in p_list) + foreach (var po in p_list) { - foreach(var po1 in p_list1) + foreach (var po1 in p_list1) { - var _ls = db.TB_ASK_DETAIL.Count(p =>p.PoBillNum==po&&p.PartCode==po1 && p.IsDeleted == false); + var _ls = db.TB_ASK_DETAIL.Count(p => p.PoBillNum == po && p.PartCode == po1 && p.IsDeleted == false); if (_ls > 0) { ErrorList.Add("订单号【{0}】零件号【{1}】已生成看板,不能关闭"); } } - } + } if (ErrorList.Count > 0) { _ret.State = ReturnStatus.Failed; @@ -3842,9 +3842,9 @@ namespace CK.SCP.Controller // 导入规则校验 var _ls = CheckExcelMode_Po(db, p, p_modtype, site, subsite); if (_ls.Count > 0) - { + { ErrorList.Add(string.Join("
", _ls.ToArray())); - } + } }); var groupList = _lst.GroupBy(g => new { g.订单编号, g.行号, g.零件号 }).Where(g => g.Count() > 1).ToList(); @@ -3960,8 +3960,8 @@ namespace CK.SCP.Controller { var _count1 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.行号 == p.行号); var _count2 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.零件号.Trim() == p.零件号.Trim()); - - + + if (_count1 > 1 && p_modtype == BillModType.Contract) { lineError.Add(string.Format("导入订单编号【{0}】行号【{1}】有重复", p.订单编号, p.行号)); @@ -3971,8 +3971,8 @@ namespace CK.SCP.Controller { lineError.Add(string.Format("导入订单编号【{0}】零件编码【{1}】有重复", p.订单编号, p.零件号.Trim())); ErrorList = lineError; - } - + } + }); p_order_list.ForEach (p => @@ -4074,8 +4074,8 @@ namespace CK.SCP.Controller var list = p.ToList(); if (list.Count > 0) { - #region 日程单 - if (p_modtype == BillModType.Contract) + #region 日程单 + if (p_modtype == BillModType.Contract) { var _entity = list.FirstOrDefault(); var _po = db.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity.订单编号/* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity.供应商编号.ToUpper()) ?? @@ -4083,8 +4083,8 @@ namespace CK.SCP.Controller _po.ErpBillNum = _entity.订单编号.ToUpper(); _po.ModType = (int)p_modtype; _po.Contacter = p_chineseName;// _entity.联系人; - _po.Buyer = p_chineseName;// _entity.联系人; - _po.BuyerPhone = p_buyerPhone; + _po.Buyer = p_chineseName;// _entity.联系人; + _po.BuyerPhone = p_buyerPhone; _po.Site = site; _po.Remark = _entity.备注; _po.IsDeleted = false; @@ -4120,7 +4120,7 @@ namespace CK.SCP.Controller _PO_Detail.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); _PO_Detail.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); _PO_Detail.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); - _PO_Detail.Supplieritem =string.IsNullOrEmpty(itm.供应商零件)? itm.供应商零件 :itm.供应商零件.ToUpper(); + _PO_Detail.Supplieritem = string.IsNullOrEmpty(itm.供应商零件) ? itm.供应商零件 : itm.供应商零件.ToUpper(); _PO_Detail.Dliverypatterncode = itm.发货样式; _PO_Detail.Deliverytimecode = itm.发货时间样式; _PO_Detail.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); @@ -4129,9 +4129,9 @@ namespace CK.SCP.Controller }); _polist = _polist + _po.PoBillNum + ","; } - #endregion - #region 离散单 - if (p_modtype == BillModType.Non_Contract) + #endregion + #region 离散单 + if (p_modtype == BillModType.Non_Contract) { var _entity = list.FirstOrDefault(); TB_PO _po = new TB_PO(); @@ -4144,8 +4144,8 @@ namespace CK.SCP.Controller _po.ErpBillNum = _po.PoBillNum; _po.ModType = (int)p_modtype; _po.Contacter = p_chineseName;// _entity.联系人; - _po.Buyer = p_chineseName;// _entity.联系人; - _po.BuyerPhone = p_buyerPhone; + _po.Buyer = p_chineseName;// _entity.联系人; + _po.BuyerPhone = p_buyerPhone; _po.Site = site; _po.Remark = _entity.备注; _po.IsDeleted = false; @@ -4166,7 +4166,7 @@ namespace CK.SCP.Controller _ask.CreateUser = p_creator; _ask.Site = site; _ask.ReceivedPort = "";//交货口 - _ask.State = (int)AskState.New; + _ask.State = (int)AskState.New; _ask.Remark = _entity.备注; _ask.ModType = (int)p_modtype; _ask.ErpBillNum = _po.PoBillNum; @@ -4241,8 +4241,8 @@ namespace CK.SCP.Controller }); _polist = _polist + _po.PoBillNum + "
"; } - #endregion - } + #endregion + } else { _ret.MessageList.Add("ERP订单编号已存在,请重新导入!"); @@ -4711,7 +4711,7 @@ namespace CK.SCP.Controller } - public static ResultObject Save_PO_TO_ASK_CQ(V_TB_PO p_order, List p_order_list, string p_buyer, string p_buyerPhone, string p_creator,string remark,string Ssite) + public static ResultObject Save_PO_TO_ASK_CQ(V_TB_PO p_order, List p_order_list, string p_buyer, string p_buyerPhone, string p_creator, string remark, string Ssite) { ResultObject _ret = new ResultObject(); try @@ -4740,7 +4740,7 @@ namespace CK.SCP.Controller _t.CreateTime = DateTime.Now; _t.CreateUser = p_creator; _t.Site = p_order.Site; - _t.ReceivedPort = p_order.ReceivedPort; + _t.ReceivedPort = p_order.ReceivedPort; _t.State = (int)AskState.New; _t.Remark = remark; _t.GUID = Guid.NewGuid(); @@ -4783,15 +4783,15 @@ namespace CK.SCP.Controller _tDetail.Site = itm.Site; if (itm.Site == "BJBMPT") { - var price = db.TB_PRICE.Where(p => p.PartCode == itm.PartCode&&p.State>-1&&p.VendId== p_order.VendId).Max(p => p.UID); - var pri = db.TB_PRICE.FirstOrDefault(t=>t.UID==price); + var price = db.TB_PRICE.Where(p => p.PartCode == itm.PartCode && p.State > -1 && p.VendId == p_order.VendId).Max(p => p.UID); + var pri = db.TB_PRICE.FirstOrDefault(t => t.UID == price); _tDetail.Price = pri.Amt; } else { _tDetail.Price = itm.Price; } - + _tDetail.Remark = itm.Remark; _tDetail.GUID = Guid.NewGuid(); _tDetail.Currency = itm.Currency; @@ -5519,7 +5519,7 @@ namespace CK.SCP.Controller .Select(p => new { AsSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode }); var arrive = db.TB_ARRIVE_DETAIL.Where(p => p.PoBillNum == _detail.PoBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.BillType == (int)ArriveBillType.Receive) .GroupBy(p => new { p.PoBillNum, p.PoLine, p.PartCode, p.SubSite }).Select(p => new { ArriveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode, Subsite = p.Key.SubSite }); - + rec.ToList().ForEach(itm => { if (_detail.PoBillNum == itm.PoBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode) @@ -5527,7 +5527,7 @@ namespace CK.SCP.Controller _detail.ReceivedQty = itm.ReceiveSum; } }); - + asn.ToList().ForEach(itm => { if (_detail.PoBillNum == itm.PoBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode) @@ -5535,7 +5535,7 @@ namespace CK.SCP.Controller _detail.ShippedQty = itm.AsSum; } }); - + arrive.ToList().ForEach(itm => { if (_detail.PoBillNum == itm.PoBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode && _detail.SubSite == itm.Subsite) @@ -5551,7 +5551,7 @@ namespace CK.SCP.Controller } - public static List GetPriceError(List details,V_TB_PO po) + public static List GetPriceError(List details, V_TB_PO po) { List errorlist = new List(); using (ScpEntities db = EntitiesFactory.CreateScpInstance()) @@ -5564,97 +5564,10 @@ namespace CK.SCP.Controller errorlist.Add(string.Format("零件编号【{0}】供应编码【{1}】价格表没有维护信息!", item.PartCode.Trim(), po.VendId)); } } - + } return errorlist; } - - public static void Get_V_TB_PO_PLAN_List_BJKFT(V_TB_PO_PLAN_BJBMPT p_entity, Action>> p_action) - { - ResultObject> _ret = new ResultObject>(); - try - { - using (ScpEntities db = EntitiesFactory.CreateScpInstance()) - { - IQueryable q = db.V_TB_PO_PLAN_BJBMPT; - if (!string.IsNullOrEmpty(p_entity.Domain)) - { - q = q.Where(p => p.Domain.Contains(p_entity.Domain)); - } - if (!string.IsNullOrEmpty(p_entity.PartCode)) - { - q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); - } - if (!string.IsNullOrEmpty(p_entity.PoBillNum)) - { - q = q.Where(p => p.PoBillNum.Contains(p_entity.PoBillNum)); - } - if (!string.IsNullOrEmpty(p_entity.Site)) - { - q = q.Where(p => p.Site.Contains(p_entity.Site)); - } - if (!string.IsNullOrEmpty(p_entity.Buyer)) - { - q = q.Where(p => p.Buyer.Contains(p_entity.Buyer)); - } - if (!string.IsNullOrEmpty(p_entity.ProjectId)) - { - q = q.Where(p => p.ProjectId.Contains(p_entity.ProjectId)); - } - if (!string.IsNullOrEmpty(p_entity.AskBillNum)) - { - q = q.Where(p => p.AskBillNum.Contains(p_entity.AskBillNum)); - } - if (!string.IsNullOrEmpty(p_entity.Version)) - { - q = q.Where(p => p.Version.Contains(p_entity.Version)); - } - if (!string.IsNullOrEmpty(p_entity.PartDesc)) - { - q = q.Where(p => p.PartDesc.Contains(p_entity.PartDesc)); - } - if (!string.IsNullOrEmpty(p_entity.VendId)) - { - q = q.Where(p => p.VendId.Contains(p_entity.VendId)); - } - - if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0) - { - q = q.Where(p => p_entity.UserInAddress.Contains(p.Domain)); - } - if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0) - { - q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId)); - } - if (p_entity.EndTime_Begin != null) - { - q = q.Where(p => p.EndTime >= p_entity.EndTime_Begin.Value); - } - if (p_entity.EndTime_End != null) - { - q = q.Where(p => p.EndTime <= p_entity.EndTime_End.Value); - } - if (p_entity.EndTime_Begin1 != null) - { - q = q.Where(p => p.CreateTime >= p_entity.EndTime_Begin1.Value); - } - if (p_entity.EndTime_End1 != null) - { - q = q.Where(p => p.CreateTime <= p_entity.EndTime_End1.Value); - } - _ret.State = ReturnStatus.Succeed; - _ret.Result = q; - p_action(_ret); - } - } - catch (Exception e) - { - _ret.State = ReturnStatus.Failed; - _ret.ErrorList.Add(e); - LogHelper.Writlog(LogHelper.LogType.Error, typeof(V_TB_PO_PLAN), "Get_V_TB_PO_PLAN_List", e.Message); - throw e; - } - } } } diff --git a/北京北汽/Models/CK.SCP.Models.csproj b/北京北汽/Models/CK.SCP.Models.csproj index f71f40d..a8be577 100644 --- a/北京北汽/Models/CK.SCP.Models.csproj +++ b/北京北汽/Models/CK.SCP.Models.csproj @@ -448,9 +448,7 @@ - - diff --git a/北京北汽/Models/ScpEntity/TB_ASN.cs b/北京北汽/Models/ScpEntity/TB_ASN.cs index ea1476c..3a04693 100644 --- a/北京北汽/Models/ScpEntity/TB_ASN.cs +++ b/北京北汽/Models/ScpEntity/TB_ASN.cs @@ -14,61 +14,61 @@ namespace CK.SCP.Models.ScpEntity using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; - //public partial class V_TB_PO_PLAN_EXTEND - //{ + public partial class V_TB_PO_PLAN_EXTEND + { - // [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - // [Key] - // public long UID { get; set; } - // public string Domain { get; set; } + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + [Key] + public long UID { get; set; } + public string Domain { get; set; } - // public string PartCode { get; set; } - // public Nullable EndTime { get; set; } - // public string PoBillNum { get; set; } - // public string Site { get; set; } - // public string AskBillNum { get; set; } - // public string Version { get; set; } + public string PartCode { get; set; } + public Nullable EndTime { get; set; } + public string PoBillNum { get; set; } + public string Site { get; set; } + public string AskBillNum { get; set; } + public string Version { get; set; } - // public string PartDesc { get; set; } + public string PartDesc { get; set; } - // public decimal PlanQty { get; set; } - // public string PoUnit { get; set; } - // public int PoLine { get; set; } - // public string VendId { get; set; } + public decimal PlanQty { get; set; } + public string PoUnit { get; set; } + public int PoLine { get; set; } + public string VendId { get; set; } - // public string ProjectId { get; set; } - // public string IsPlan { get; set; } + public string ProjectId { get; set; } + public string IsPlan { get; set; } - // [NotMapped] - // public List UserInAddress { set; get; } + [NotMapped] + public List UserInAddress { set; get; } - // [NotMapped] - // public List UserInVendIds { set; get; } + [NotMapped] + public List UserInVendIds { set; get; } - // [NotMapped] - // public List BillStateList { set; get; } + [NotMapped] + public List BillStateList { set; get; } - // [NotMapped] - // public DateTime? EndTime_Begin { set; get; } - // [NotMapped] - // public DateTime? EndTime_End { set; get; } - //} - //public partial class V_TB_PO_PLAN_DETAIL - //{ - // [Key] - // public long UID { get; set; } - // public string PoBillNum { get; set; } - // public string VendId { get; set; } - // public Nullable EndTime { get; set; } - // public string PartCode { get; set; } - // public string AskBillNum { get; set; } - // public string Version { get; set; } - // public string Domain { get; set; } - // public decimal PlanQty { get; set; } - // public string PoUnit { get; set; } + [NotMapped] + public DateTime? EndTime_Begin { set; get; } + [NotMapped] + public DateTime? EndTime_End { set; get; } + } + public partial class V_TB_PO_PLAN_DETAIL + { + [Key] + public long UID { get; set; } + public string PoBillNum { get; set; } + public string VendId { get; set; } + public Nullable EndTime { get; set; } + public string PartCode { get; set; } + public string AskBillNum { get; set; } + public string Version { get; set; } + public string Domain { get; set; } + public decimal PlanQty { get; set; } + public string PoUnit { get; set; } - //} + } public partial class TB_ASN:RecordEntity { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] diff --git a/北京北汽/Models/ScpEntity/V_TB_PO_PLAN.cs b/北京北汽/Models/ScpEntity/V_TB_PO_PLAN.cs deleted file mode 100644 index 51b2ea2..0000000 --- a/北京北汽/Models/ScpEntity/V_TB_PO_PLAN.cs +++ /dev/null @@ -1,105 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码已从模板生成。 -// -// 手动更改此文件可能导致应用程序出现意外的行为。 -// 如果重新生成代码,将覆盖对此文件的手动更改。 -// -//------------------------------------------------------------------------------ - -namespace CK.SCP.Models.ScpEntity -{ - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations; - using System.ComponentModel.DataAnnotations.Schema; - - public partial class V_TB_PO_PLAN - { - - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Key] - public long UID { get; set; } - public string Domain { get; set; } - - public string PartCode { get; set; } - public Nullable EndTime { get; set; } - //public Nullable CreateTime { get; set; } - public string PoBillNum { get; set; } - public string Site { get; set; } - public string AskBillNum { get; set; } - public string Version { get; set; } - - public string PartDesc { get; set; } - - public decimal PlanQty { get; set; } - public string PoUnit { get; set; } - public int PoLine { get; set; } - public string VendId { get; set; } - - public string ProjectId { get; set; } - public string IsPlan { get; set; } - //public string Buyer { get; set; } - - [NotMapped] - public List UserInAddress { set; get; } - - [NotMapped] - public List UserInVendIds { set; get; } - - - [NotMapped] - public List BillStateList { set; get; } - - [NotMapped] - public DateTime? EndTime_Begin { set; get; } - [NotMapped] - public DateTime? EndTime_End { set; get; } - public DateTime? BeginTime { get; set; } - - //[NotMapped] - //public DateTime? EndTime_Begin1 { set; get; } - //[NotMapped] - //public DateTime? EndTime_End1 { set; get; } - } - public partial class V_TB_PO_PLAN_EXTEND - { - - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - [Key] - public long UID { get; set; } - public string Domain { get; set; } - - public string PartCode { get; set; } - public Nullable EndTime { get; set; } - public string PoBillNum { get; set; } - public string Site { get; set; } - public string AskBillNum { get; set; } - public string Version { get; set; } - - public string PartDesc { get; set; } - - public decimal PlanQty { get; set; } - public string PoUnit { get; set; } - public int PoLine { get; set; } - public string VendId { get; set; } - - public string ProjectId { get; set; } - public string IsPlan { get; set; } - - [NotMapped] - public List UserInAddress { set; get; } - - [NotMapped] - public List UserInVendIds { set; get; } - - - [NotMapped] - public List BillStateList { set; get; } - - [NotMapped] - public DateTime? EndTime_Begin { set; get; } - [NotMapped] - public DateTime? EndTime_End { set; get; } - } -} diff --git a/北京北汽/Models/ScpEntity/V_TB_PO_PLAN_DETAIL.cs b/北京北汽/Models/ScpEntity/V_TB_PO_PLAN_DETAIL.cs deleted file mode 100644 index 3c0c4a6..0000000 --- a/北京北汽/Models/ScpEntity/V_TB_PO_PLAN_DETAIL.cs +++ /dev/null @@ -1,31 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码已从模板生成。 -// -// 手动更改此文件可能导致应用程序出现意外的行为。 -// 如果重新生成代码,将覆盖对此文件的手动更改。 -// -//------------------------------------------------------------------------------ - -namespace CK.SCP.Models.ScpEntity -{ - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations; - - public partial class V_TB_PO_PLAN_DETAIL - { - [Key] - public long UID { get; set; } - public string PoBillNum { get; set; } - public string VendId { get; set; } - public Nullable EndTime { get; set; } - public string PartCode { get; set; } - public string AskBillNum { get; set; } - public string Version { get; set; } - public string Domain { get; set; } - public decimal PlanQty { get; set; } - public string PoUnit { get; set; } - - } -} diff --git a/北京北汽/SCP/SCP.csproj b/北京北汽/SCP/SCP.csproj index cb10e79..9ded1de 100644 --- a/北京北汽/SCP/SCP.csproj +++ b/北京北汽/SCP/SCP.csproj @@ -2930,7 +2930,6 @@ - @@ -5484,13 +5483,6 @@ SCP_ASK.aspx - - SCP_PO_BJPLAN.aspx - ASPXCodeBehind - - - SCP_PO_BJPLAN.aspx - SCP_PO_PLAN_DETAIL.aspx ASPXCodeBehind