From 8a0da15b0bc3f5710fa6317ed2a8b244fedf5d71 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Mon, 31 Aug 2020 08:57:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=A6=E5=B7=9E=E9=A1=B9=E7=9B=AE=E5=90=88?= =?UTF-8?q?=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CK.SCP.Controller.csproj | 1 + Controller/PublicDataController.cs | 10 +- Controller/SCP_ASK_CONTROLLER.cs | 6 +- Controller/SCP_EXCEL_CONTROLLER.cs | 34 ++ Controller/SCP_FORECAST_CONTROLLER.cs | 445 ++++++++++++++ Controller/SCP_INFO_CONTROLLER.cs | 30 +- Controller/SCP_INVOICE_CONTROLLER.cs | 1 + Controller/SCP_PO_CONTROLLER.cs | 6 +- Controller/SCP_RECEIVE_CONTROLLER.cs | 13 +- Controller/SCP_REPORT_CONTROLLER.cs | 192 +++--- Controller/SCP_WMS_CONTROLLER.cs | 74 +++ Controller/UniApiController.cs | 75 +++ Models/CK.SCP.Models.csproj | 5 +- Models/ScpEntities.cs | 2 +- .../SCP_ASK_DETAIL_EXPORT.cs | 3 + .../ExcelExportEnttity/SCP_FORECAST_EXPORT.cs | 16 +- .../SCP_OTD_REPORT_EXPORT.cs | 24 + .../SCP_PO_DETAIL_EXPORT.cs | 3 + Models/ScpEntity/SCP_OTD_EXPORT.cs | 2 + Models/ScpEntity/TB_FORECAST.cs | 23 +- Models/ScpEntity/TB_INVOICE_DETAIL.cs | 2 + Models/ScpEntity/TB_RECEIVE_DETAIL_QAD.cs | 6 +- Models/ScpEntity/TB_RECEIVE_QAD.cs | 6 +- Models/ScpEntity/TS_BARCODE_CUSTOM.cs | 2 +- Models/ScpEntity/V_FORECAST_REPORT.cs | 22 + Models/ScpEntity/V_TB_ASK_DETAIL.cs | 3 + Models/ScpEntity/V_TB_FORECAST.cs | 48 ++ Models/ScpEntity/V_TB_INCOMPLETE_ASK.cs | 2 + Models/ScpEntity/V_TB_PO_INCOMPLETE.cs | 28 - Models/ScpEntity/V_TB_RECEIVE_LIST.cs | 2 +- Models/UniApiEntity/xxscm_inv_det.cs | 2 +- Models/UniApiEntity/xxwms_arv_det.cs | 2 +- Models/UniApiEntity/xxwms_rc_det.cs | 2 +- Models/WmsEntity/VIEW_STOCK_QTY.cs | 33 ++ Models/WmsEntity/VIEW_STOCK_VEND.cs | 2 + Models/WmsEntity/WmsEntities.cs | 1 + SCP.sln | 18 +- SCP/Admin/user.aspx | 2 +- SCP/Admin/user_new.aspx | 4 +- SCP/Business/PageBase.cs | 118 +++- SCP/Common/MailHelper.cs | 11 - SCP/SCP.csproj | 80 +++ SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs | 16 +- SCP/Views/BasicData/SCP_VenderUser.aspx | 10 + SCP/Views/BasicData/SCP_VenderUser.aspx.cs | 2 +- .../BasicData/SCP_VenderUser.aspx.designer.cs | 69 ++- SCP/Views/PlanData/SCP_ASK.aspx | 2 +- SCP/Views/PlanData/SCP_ASK_DETAIL.aspx | 4 +- SCP/Views/PlanData/SCP_FORECAST.aspx | 113 ++++ SCP/Views/PlanData/SCP_FORECAST.aspx.cs | 239 ++++++++ .../PlanData/SCP_FORECAST.aspx.designer.cs | 197 ++++++ SCP/Views/PlanData/SCP_PO_DETAIL_OUT.aspx | 20 +- SCP/Views/PlanData/SCP_PO_DETAIL_OUT.aspx.cs | 4 + SCP/Views/PlanData/SCP_UNI_API.aspx | 73 +++ SCP/Views/PlanData/SCP_UNI_API.aspx.cs | 100 ++++ .../PlanData/SCP_UNI_API.aspx.designer.cs | 152 +++++ SCP/Views/Report/SCP_OTD_REPORT.aspx | 94 +++ SCP/Views/Report/SCP_OTD_REPORT.aspx.cs | 137 +++++ .../Report/SCP_OTD_REPORT.aspx.designer.cs | 179 ++++++ SCP/Views/SupplierData/SCP_ASK.aspx.cs | 3 + SCP/Views/SupplierData/SCP_ASK_DETAIL.aspx | 3 + SCP/Views/SupplierData/SCP_FORECAST.aspx | 113 ++++ SCP/Views/SupplierData/SCP_FORECAST.aspx.cs | 240 ++++++++ .../SCP_FORECAST.aspx.designer.cs | 197 ++++++ SCP/Views/SupplierData/SCP_INFO_EDIT.aspx.cs | 10 +- .../SupplierData/SCP_INVOICE_CREATE.aspx | 7 +- .../SupplierData/SCP_INVOICE_CREATE.aspx.cs | 6 +- SCP/Views/SupplierData/SCP_RECEIVE_LIST.aspx | 9 +- .../SupplierData/SCP_RECEIVE_LIST.aspx.cs | 30 +- SCP/Views/SupplierData/SCP_STOCK.aspx | 81 +-- SCP/Views/SupplierData/SCP_STOCK.aspx.cs | 92 +-- .../SupplierData/SCP_STOCK.aspx.designer.cs | 170 ++---- SCP/Views/SupplierData/SCP_STOCK_DETAIL.aspx | 75 +++ .../SupplierData/SCP_STOCK_DETAIL.aspx.cs | 116 ++++ .../SCP_STOCK_DETAIL.aspx.designer.cs | 179 ++++++ SCP/Views/SupplierData/SCP_UNPAID.aspx | 54 ++ SCP/Views/SupplierData/SCP_UNPAID.aspx.cs | 17 + .../SupplierData/SCP_UNPAID.aspx.designer.cs | 69 +++ .../WarehouseData/SCP_INVOICE_CONFIRM.aspx | 2 +- .../SCP_INVOICE_CONFIRM_DETAIL.aspx | 2 - ...CP_INVOICE_CONFIRM_DETAIL.aspx.designer.cs | 85 ++- SCP/Views/WarehouseData/SCP_RECEIVE.aspx | 8 +- SCP/Views/WarehouseData/SCP_RECEIVE.aspx.cs | 43 +- .../WarehouseData/SCP_RECEIVE_DETAIL.aspx | 1 + .../WarehouseData/SCP_RECEIVE_DETAIL.aspx.cs | 21 +- .../SCP_RECEIVE_DETAIL_VIEW.aspx.cs | 2 +- .../Report/SCP_INCOMPLETE_ASK.aspx | 1 + .../锦州锦恒/SupplierData/SCP_ASN.aspx | 132 +++++ .../锦州锦恒/SupplierData/SCP_ASN.aspx.cs | 168 ++++++ .../SupplierData/SCP_ASN.aspx.designer.cs | 287 +++++++++ .../SupplierData/SCP_ASN_DETAIL.aspx | 184 ++++++ .../SupplierData/SCP_ASN_DETAIL.aspx.cs | 561 ++++++++++++++++++ .../SCP_ASN_DETAIL.aspx.designer.cs | 323 ++++++++++ .../SupplierData/SCP_SELECT_MAKE.aspx | 38 ++ .../SupplierData/SCP_SELECT_MAKE.aspx.cs | 33 ++ .../SCP_SELECT_MAKE.aspx.designer.cs | 80 +++ .../SupplierData/SCP_SHIP_DETAIL_BARCODE.aspx | 64 ++ .../SCP_SHIP_DETAIL_BARCODE.aspx.cs | 130 ++++ .../SCP_SHIP_DETAIL_BARCODE.aspx.designer.cs | 161 +++++ SCP/Web.config | 11 +- 100 files changed, 5985 insertions(+), 595 deletions(-) create mode 100644 Controller/SCP_FORECAST_CONTROLLER.cs create mode 100644 Models/ScpEntity/ExcelExportEnttity/SCP_OTD_REPORT_EXPORT.cs create mode 100644 Models/ScpEntity/V_FORECAST_REPORT.cs create mode 100644 Models/ScpEntity/V_TB_FORECAST.cs delete mode 100644 Models/ScpEntity/V_TB_PO_INCOMPLETE.cs create mode 100644 Models/WmsEntity/VIEW_STOCK_QTY.cs create mode 100644 SCP/Views/PlanData/SCP_FORECAST.aspx create mode 100644 SCP/Views/PlanData/SCP_FORECAST.aspx.cs create mode 100644 SCP/Views/PlanData/SCP_FORECAST.aspx.designer.cs create mode 100644 SCP/Views/PlanData/SCP_UNI_API.aspx create mode 100644 SCP/Views/PlanData/SCP_UNI_API.aspx.cs create mode 100644 SCP/Views/PlanData/SCP_UNI_API.aspx.designer.cs create mode 100644 SCP/Views/Report/SCP_OTD_REPORT.aspx create mode 100644 SCP/Views/Report/SCP_OTD_REPORT.aspx.cs create mode 100644 SCP/Views/Report/SCP_OTD_REPORT.aspx.designer.cs create mode 100644 SCP/Views/SupplierData/SCP_FORECAST.aspx create mode 100644 SCP/Views/SupplierData/SCP_FORECAST.aspx.cs create mode 100644 SCP/Views/SupplierData/SCP_FORECAST.aspx.designer.cs create mode 100644 SCP/Views/SupplierData/SCP_STOCK_DETAIL.aspx create mode 100644 SCP/Views/SupplierData/SCP_STOCK_DETAIL.aspx.cs create mode 100644 SCP/Views/SupplierData/SCP_STOCK_DETAIL.aspx.designer.cs create mode 100644 SCP/Views/SupplierData/SCP_UNPAID.aspx create mode 100644 SCP/Views/SupplierData/SCP_UNPAID.aspx.cs create mode 100644 SCP/Views/SupplierData/SCP_UNPAID.aspx.designer.cs create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_ASN.aspx create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_ASN.aspx.cs create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_ASN.aspx.designer.cs create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_ASN_DETAIL.aspx create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_ASN_DETAIL.aspx.cs create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_ASN_DETAIL.aspx.designer.cs create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_SELECT_MAKE.aspx create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_SELECT_MAKE.aspx.cs create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_SELECT_MAKE.aspx.designer.cs create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_SHIP_DETAIL_BARCODE.aspx create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_SHIP_DETAIL_BARCODE.aspx.cs create mode 100644 SCP/Views/锦州锦恒/SupplierData/SCP_SHIP_DETAIL_BARCODE.aspx.designer.cs diff --git a/Controller/CK.SCP.Controller.csproj b/Controller/CK.SCP.Controller.csproj index 344b706..64d5a9a 100644 --- a/Controller/CK.SCP.Controller.csproj +++ b/Controller/CK.SCP.Controller.csproj @@ -58,6 +58,7 @@ + diff --git a/Controller/PublicDataController.cs b/Controller/PublicDataController.cs index f68a721..ad6c74d 100644 --- a/Controller/PublicDataController.cs +++ b/Controller/PublicDataController.cs @@ -81,7 +81,7 @@ namespace CK.SCP.Controller { - public static string GetUserlistSql(string p_roleName, string p_Domain) + public static string GetUserlistSql(string p_roleName, string p_Domain, string p_username) { StringBuilder _builder = new StringBuilder(); _builder.Append("select u.*from Users u "); @@ -90,18 +90,22 @@ namespace CK.SCP.Controller _builder.Append("Inner join FactoryUsers fu on u.ID = fu.UserID "); _builder.Append("inner join TA_FACTORY f on fu.FACTORY_ID = f.ID "); _builder.AppendFormat("where r.id = '{0}' AND F.FactoryId = '{1}' ",p_roleName,p_Domain); + if (!string.IsNullOrEmpty(p_username)) + { + _builder.AppendFormat(" AND u.Name like '%{0}%'" , p_username); + } return _builder.ToString(); } - public static void Get_UserList(string p_roleName, string p_Domain,Action>> p_action) + public static void Get_UserList(string p_username,string p_roleName, string p_Domain,Action>> p_action) { ResultObject> _ret = new ResultObject>(); try { using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance()) { - string sql = GetUserlistSql(p_roleName, p_Domain); + string sql = GetUserlistSql(p_roleName, p_Domain, p_username); IQueryable q = db.Database.SqlQuery(sql).AsQueryable(); _ret.State = ReturnStatus.Succeed; diff --git a/Controller/SCP_ASK_CONTROLLER.cs b/Controller/SCP_ASK_CONTROLLER.cs index 5ecbb42..c734ec1 100644 --- a/Controller/SCP_ASK_CONTROLLER.cs +++ b/Controller/SCP_ASK_CONTROLLER.cs @@ -353,7 +353,10 @@ namespace CK.SCP.Controller { q = q.Where(p => p.AskBillNum == p_entity.AskBillNum); } - + if (!string.IsNullOrEmpty(p_entity.PartCode)) + { + q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); + } if (!string.IsNullOrEmpty(p_entity.CreateUser)) { q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser)); @@ -543,6 +546,7 @@ namespace CK.SCP.Controller } }); _detail.OnRoadQty = Convert.ToDecimal(_detail.Qty) - _detail.ArriveQty; + _detail.DepositQty = _detail.ArriveQty - _detail.ReceivedQty; } } } diff --git a/Controller/SCP_EXCEL_CONTROLLER.cs b/Controller/SCP_EXCEL_CONTROLLER.cs index 49e23ad..e5ea48d 100644 --- a/Controller/SCP_EXCEL_CONTROLLER.cs +++ b/Controller/SCP_EXCEL_CONTROLLER.cs @@ -113,6 +113,9 @@ namespace CK.SCP.Controller po_detail.收货口 = itm.DockCode; po_detail.项目编号 = itm.ProjectId; po_detail.备注 = string.Empty; + po_detail.预测一 = "0"; + po_detail.预测二 = "0"; + po_detail.预测三 = "0"; _exportDetailList.Add(po_detail); }); @@ -201,6 +204,9 @@ namespace CK.SCP.Controller //_entity.价格 = itm.Price.ToString(); _entity.要货数量 = itm.AskQty.ToString(); _entity.说明 = string.IsNullOrEmpty(itm.Remark)?string.Empty:itm.Remark.ToString(); + _entity.预测一 = itm.OneMonth.ToString(); + _entity.预测二= itm.TwoMonth.ToString(); + _entity.预测三 = itm.ThreeMonth.ToString(); _exportDetailList.Add(_entity); }); @@ -321,6 +327,34 @@ namespace CK.SCP.Controller return _ds; } + public static DataSet GET_OTD_REPORT_EXECEL(List p_lst) + { + DataSet _ds = new DataSet(); + var _exportList = new List(); + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + p_lst.ForEach(itm => + { + SCP_OTD_REPORT_EXPORT _entity = new SCP_OTD_REPORT_EXPORT(); + _entity.供应商编号 = itm.VendId; + _entity.供应商名称 = itm.VendName; + _entity.要货看板号 = itm.AskBillNum; + _entity.零件号 = itm.PartCode; + _entity.零件名称 = itm.PartName; + _entity.要求到货时间 = Convert.ToDateTime(itm.EndTime).ToString("yyyy/MM/dd"); + _entity.订单要货数量 = itm.AskQty.ToString(); + _entity.到货数量 = itm.ArriveQty.ToString(); + _entity.差额 = itm.Qty.ToString(); + _entity.及时数量 = itm.NntimelyQty.ToString(); + _entity.及时率 = itm.OTD.ToString(); + _entity.到货率 = itm.ArriveOTD.ToString(); + _exportList.Add(_entity); + }); + var _dt = ConvertHelper.ToDataTable(_exportList); + _ds.Tables.Add(_dt); + } + return _ds; + } } } diff --git a/Controller/SCP_FORECAST_CONTROLLER.cs b/Controller/SCP_FORECAST_CONTROLLER.cs new file mode 100644 index 0000000..12b2110 --- /dev/null +++ b/Controller/SCP_FORECAST_CONTROLLER.cs @@ -0,0 +1,445 @@ +using CK.SCP.Models; +using CK.SCP.Models.Enums; +using CK.SCP.Models.ScpEntity; +using CK.SCP.Models.ScpEntity.ExcelExportEnttity; +using CK.SCP.Utils; +using System; +using System.Collections.Generic; +using System.Data.Entity.Core; +using System.Data.Entity.Migrations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CK.SCP.Controller +{ + public class SCP_FORECAST_CONTROLLER + { + /// + /// 获取数据 + /// + /// + /// + public static void Get_V_TB_FORECAST_List(V_TB_FORECAST p_entity, Action>> p_action) + { + ResultObject> _ret = new ResultObject>(); + try + { + using (Models.ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + IQueryable q = db.V_TB_FORECAST; + + if (!string.IsNullOrEmpty(p_entity.PartCode)) + { + q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); + } + if (!string.IsNullOrEmpty(p_entity.VendId)) + { + q = q.Where(p => p.VendId == p_entity.VendId); + } + if (p_entity.BillStateList != null && p_entity.BillStateList.Count > 0) + { + q = q.Where(p => p_entity.BillStateList.Contains((int)p.State)); + } + if (!string.IsNullOrEmpty(p_entity.State_DESC)) + { + q = q.Where(p => p.State_DESC.Contains(p_entity.State_DESC)); + } + //if (!string.IsNullOrEmpty(p_entity.Month)) + //{ + // q = q.Where(p => p.Month == p_entity.Month); + //} + q = q.Where(p => p.IsDeleted == p_entity.IsDeleted); + if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0) + { + q = q.Where(p => p_entity.UserInAddress.Contains(p.Site)); + } + if (!string.IsNullOrEmpty(p_entity.CreateUser)) + { + q = q.Where(p => p.CreateUser == p_entity.CreateUser); + } + if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0) + { + q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId)); + } + _ret.State = ReturnStatus.Succeed; + _ret.Result = q; + p_action(_ret); + } + } + 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.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_FORECAST_CONTROLLER), "Get_V_TB_FORECAST_List", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_FORECAST_CONTROLLER), "Get_V_TB_FORECAST_List", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_FORECAST_CONTROLLER), "Get_V_TB_FORECAST_List", 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; + _ret.ErrorList.Add(e); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_FORECAST_CONTROLLER), "Get_V_TB_FORECAST_List", e.Message); + throw e; + } + } + /// + /// EXCEL导入 + /// + /// + /// + /// + public static ResultObject EXCEL_FORECAST_MOD(List p_order_list, string p_creator, string site) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + int number = 1; + List lineError = new List(); + List ErrorList = new List(); + var _lst = p_order_list; + _lst.ForEach + (p => + { + var _ls = CheckExcelMode_Forecast(db, p); + if (_ls.Count > 0) + { + lineError.Add(number.ToString()); + ErrorList.Add(string.Join("
", _ls.ToArray())); + } + number++; + }); + if (lineError.Count > 0) + { + _ret.State = ReturnStatus.Failed; + _ret.MessageList.AddRange(ErrorList); + _ret.Result = false; + } + else + { + _lst.ForEach(p => + { + // var _item = db.TB_FORECAST.SingleOrDefault(t => t.PartCode == p.零件编号.ToUpper() && t.VendId == p.供应商编码 && t.Month == p.月份) ?? + // new TB_FORECAST { PartCode = p.零件编号.ToUpper(), VendId = p.供应商编码, Month = p.月份, GUID = System.Guid.NewGuid() }; + var _item = new TB_FORECAST(); + _item.PoType = p.订单; + _item.VendId = p.供应商编码; + _item.GUID = System.Guid.NewGuid(); + _item.PartCode = p.零件编号; + _item.PoLine =Int32.Parse(p.图号); + _item.ShippdedPlace = p.规格; + _item.Unit = p.单位; + _item.Qty = decimal.Parse(p.当次订单数量); + _item.ProductStatus = p.产品状态; + _item.IsUrgent = p.紧急; + _item.ShippdedTime = DateTime.Parse(p.要求到货日期); + _item.ShippdedPlace = p.到货地; + _item.MonthQty = decimal.Parse(p.当月); + _item.MonthQty1 = decimal.Parse(p.预测1); + _item.MonthQty2 = decimal.Parse(p.预测2); + _item.MonthQty3 = decimal.Parse(p.预测3); + _item.Ontime = p.是否按期交货; + _item.Datetime = p.不能按期交付日期; + _item.Remark = p.备注; + _item.IsDeleted = false; + _item.CreateUser = p_creator; + _item.CreateTime = DateTime.Now; + _item.State = (int)ForecastState.New; + _item.UpdateInfo = ""; + _item.Site = site; + db.TB_FORECAST.AddOrUpdate(_item); + }); + 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_FORECAST_CONTROLLER), "EXCEL_FORECAST_MOD", 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_FORECAST_CONTROLLER), "EXCEL_FORECAST_MOD", 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_FORECAST_CONTROLLER), "EXCEL_FORECAST_MOD", 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_FORECAST_CONTROLLER), "EXCEL_FORECAST_MOD", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + return _ret; + } + /// + /// 导入验证 + /// + /// + /// + /// + private static List CheckExcelMode_Forecast(ScpEntities db, SCP_FORECAST_EXPORT p_excel) + { + List ErrorList = new List(); + if ( + string.IsNullOrEmpty(p_excel.零件编号) || + string.IsNullOrEmpty(p_excel.供应商编码) || + string.IsNullOrEmpty(p_excel.图号) || + string.IsNullOrEmpty(p_excel.当次订单数量) || + string.IsNullOrEmpty(p_excel.要求到货日期) || + string.IsNullOrEmpty(p_excel.当月) || + string.IsNullOrEmpty(p_excel.预测1) || + string.IsNullOrEmpty(p_excel.预测2) || + string.IsNullOrEmpty(p_excel.预测3)) + { + ErrorList.Add(string.Format("零件编号【{0}】有填写为空!", p_excel.零件编号)); + } + return ErrorList; + } + + public static ResultObject Save_TB_FORECAST_STATE(List p_list, string p_user, ForecastState State) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + if (State == ForecastState.Confirm) + { + var _ls = db.TB_FORECAST.Where(p => p_list.Contains(p.UID)).ToList(); + int count = _ls.Count(p => p.State == (int)ForecastState.New); + if (count == _ls.Count && _ls.Count > 0) + { + _ls.ForEach(p => + { + p.State = (int)ForecastState.Confirm; + p.UpdateTime = DateTime.Now; + p.UpdateUser = p_user; + p.UpdateInfo = "供应商确认"; + } + ); + db.TB_FORECAST.AddOrUpdate(p => p.UID, _ls.ToArray()); + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "选择的记录,有已经确认的数据!"; + } + } + if (State == ForecastState.Reject) + { + var _ls = db.TB_FORECAST.Where(p => p_list.Contains(p.UID)).ToList(); + int count = _ls.Count(p => p.State == (int)ForecastState.New); + if (count == _ls.Count && _ls.Count > 0) + { + _ls.ForEach(p => + { + p.State = (int)ForecastState.Reject; + p.UpdateTime = DateTime.Now; + p.UpdateUser = p_user; + p.UpdateInfo = "作废"; + p.IsDeleted = true ; + } + ); + db.TB_FORECAST.AddOrUpdate(p => p.UID, _ls.ToArray()); + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "选择的记录,有已经确认的数据!"; + } + } + if (State == ForecastState.New) + { + var _ls = db.TB_FORECAST.Where(p => p_list.Contains(p.UID)).ToList(); + int count = _ls.Count(p => p.State == (int)ForecastState.Confirm); + if (count == _ls.Count && _ls.Count > 0) + { + _ls.ForEach(p => + { + p.State = (int)ForecastState.New; + p.UpdateTime = DateTime.Now; + p.UpdateUser = p_user; + p.UpdateInfo = "取消确认"; + } + ); + db.TB_FORECAST.AddOrUpdate(p => p.UID, _ls.ToArray()); + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "选择的记录,有不是确认的数据!"; + } + } + if (string.IsNullOrEmpty(_ret.Message)) + { + if (db.SaveChanges() != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "数据更新失败!"; + } + } + } + } + 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_FORECAST_CONTROLLER), "Save_TB_FORECAST_STATE", 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_FORECAST_CONTROLLER), "Save_TB_FORECAST_STATE", 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_FORECAST_CONTROLLER), "Save_TB_FORECAST_STATE", 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_FORECAST_CONTROLLER), "Save_TB_FORECAST_STATE", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + + return _ret; + } + } +} diff --git a/Controller/SCP_INFO_CONTROLLER.cs b/Controller/SCP_INFO_CONTROLLER.cs index a8ecf0d..3287d8a 100644 --- a/Controller/SCP_INFO_CONTROLLER.cs +++ b/Controller/SCP_INFO_CONTROLLER.cs @@ -260,14 +260,25 @@ namespace CK.SCP.Controller - public static bool SaveInfo(TA_INFO model) + public static ResultObject SaveInfo(TA_INFO model) { + ResultObject _ret = new ResultObject(); try { using (ScpEntities db = EntitiesFactory.CreateScpInstance()) { db.TA_Info.AddOrUpdate(model); - db.SaveChanges(); + if (db.SaveChanges() != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.Message = "数据更新失败!"; + } } } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 @@ -282,13 +293,18 @@ namespace CK.SCP.Controller 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_INFO_CONTROLLER), "SaveInfo", 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_INFO_CONTROLLER), "SaveInfo", ex.ToString()); throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); } @@ -296,6 +312,9 @@ namespace CK.SCP.Controller { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INFO_CONTROLLER), "SaveInfo", ex.ToString()); if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) @@ -312,10 +331,13 @@ namespace CK.SCP.Controller } catch (Exception e) { + _ret.State = ReturnStatus.Failed; LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INFO_CONTROLLER), "SaveInfo", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); throw e; } - return true; + return _ret; } public static bool UpdateInfo(TA_INFO model) diff --git a/Controller/SCP_INVOICE_CONTROLLER.cs b/Controller/SCP_INVOICE_CONTROLLER.cs index a4a79b4..981ea96 100644 --- a/Controller/SCP_INVOICE_CONTROLLER.cs +++ b/Controller/SCP_INVOICE_CONTROLLER.cs @@ -985,6 +985,7 @@ namespace CK.SCP.Controller invocieDetail.PoBillNum = p.PoBillNum; invocieDetail.PoLineNum = p.PoLine; invocieDetail.RecvBillNum = p.RecvBillNum; + invocieDetail.ErpRecvBillNum = p.ErpRecvBillNum; invocieDetail.CreateUser = invoice.CreateUser; invocieDetail.CreateTime = invoice.CreateTime; invocieDetail.PoUnit = p.PoUnit; //自己改数据库 diff --git a/Controller/SCP_PO_CONTROLLER.cs b/Controller/SCP_PO_CONTROLLER.cs index a766459..0991720 100644 --- a/Controller/SCP_PO_CONTROLLER.cs +++ b/Controller/SCP_PO_CONTROLLER.cs @@ -671,7 +671,6 @@ namespace CK.SCP.Controller string.IsNullOrEmpty(p_excel.域名) || string.IsNullOrEmpty(p_excel.站点) || string.IsNullOrEmpty(p_excel.计划员) || - string.IsNullOrEmpty(p_excel.计划员电话) || string.IsNullOrEmpty(p_excel.订单数) || string.IsNullOrEmpty(p_excel.单位)) { @@ -1012,12 +1011,13 @@ namespace CK.SCP.Controller _t_ASK_Detail.GUID = Guid.NewGuid(); _t_ASK_Detail.Remark = _ask.Site; _t_ASK_Detail.UpdateInfo = itm.备注; - + _t_ASK_Detail.Extend1 = itm.预测一; + _t_ASK_Detail.Extend2 = itm.预测二; + _t_ASK_Detail.Extend3 = itm.预测三; db.TB_ASK_DETAIL.Add(_t_ASK_Detail); _ls.Add(_t_ASK_Detail); // _number++; }); - } else { diff --git a/Controller/SCP_RECEIVE_CONTROLLER.cs b/Controller/SCP_RECEIVE_CONTROLLER.cs index 7470bf5..91c1505 100644 --- a/Controller/SCP_RECEIVE_CONTROLLER.cs +++ b/Controller/SCP_RECEIVE_CONTROLLER.cs @@ -60,7 +60,7 @@ namespace CK.SCP.Controller } if (!string.IsNullOrEmpty(p_entity.CreateUser)) { - q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser)); + q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser)||p.CreateUser==null); } if (p_entity.IsDeleted != false) { @@ -642,9 +642,9 @@ namespace CK.SCP.Controller { p.OperName = userName; p.State = (int)ReceiveState.Check; - var _list = db.TB_RECEIVE_DETAIL.Where(itm => itm.RecvBillNum == p.RecvBillNum && itm.Remark == p_site).ToList(); + var _list = db.TB_RECEIVE_DETAIL_QAD.Where(itm => itm.RecvBillNum == p.RecvBillNum && itm.Site == p_site).ToList(); _list.ForEach(itm => itm.State = (int)ReceiveState.Check); - db.TB_RECEIVE_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); + db.TB_RECEIVE_DETAIL_QAD.AddOrUpdate(itm => itm.UID, _list.ToArray()); #region 收货审核提醒供应商提起发票申请 TB_PENING_ITEMS _item = new TB_PENING_ITEMS(); _item.ROLE_NAME = "供应商"; @@ -692,7 +692,7 @@ namespace CK.SCP.Controller p.OperName = userName; p.State = (int)ReceiveState.Reject; p.IsDeleted = true; - var _list = db.TB_RECEIVE_DETAIL.Where(itm => itm.RecvBillNum == p.RecvBillNum && p.Site == p_site).ToList(); + var _list = db.TB_RECEIVE_DETAIL_QAD.Where(itm => itm.RecvBillNum == p.RecvBillNum && p.Site == p_site).ToList(); _list.ForEach(itm => { itm.State = (int)ReceiveState.Reject; @@ -700,7 +700,7 @@ namespace CK.SCP.Controller } ); - db.TB_RECEIVE_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); + db.TB_RECEIVE_DETAIL_QAD.AddOrUpdate(itm => itm.UID, _list.ToArray()); } @@ -1652,7 +1652,8 @@ namespace CK.SCP.Controller var _ls = p_list.Select(p => p.UID).ToList(); var _list=db.TB_RECEIVE_DETAIL.Where(p => _ls.Contains(p.UID)).ToList(); - _list.ForEach(p => { + _list.ForEach(p => + { var _entity=p_list.Where(itm => itm.UID == p.UID).FirstOrDefault(); if (_entity != null) { diff --git a/Controller/SCP_REPORT_CONTROLLER.cs b/Controller/SCP_REPORT_CONTROLLER.cs index 19e643f..235a021 100644 --- a/Controller/SCP_REPORT_CONTROLLER.cs +++ b/Controller/SCP_REPORT_CONTROLLER.cs @@ -630,7 +630,7 @@ namespace CK.SCP.Controller StringBuilder _builder = new StringBuilder(); _builder.Append(" SELECT A.UID, A.RecvBillNum, A.PoLine, A.PartCode, A.Batch, A.Qty, A.DockCode, A.Remark, A.CreateTime, A.CreateUser, "); _builder.Append(" A.IsDeleted, A.GUID, A.AsnBillNum, A.Site, A.VendId, A.ShipTime, A.OperName, A.PartDesc1, A.State, A.PoBillNum, "); - _builder.Append(" B.VendName, B.Site_Desc, p.Price, p.Currency, A.Unit, A.VendBatch, A.PoUnit, A.LocUnit, A.BillType_DESC, "); + _builder.Append(" B.VendName, B.Site_Desc, isnull(p.Price,0) as Price, p.Currency, A.Unit, A.VendBatch, A.PoUnit, A.LocUnit, A.BillType_DESC, "); _builder.Append(" B.State_DESC, p.BeginTime,SUM(isnull(C.Qty,0)) as InvQty,an.AskBillNum "); _builder.Append(" FROM dbo.V_TB_RECEIVE_DETAIL AS A LEFT OUTER JOIN "); _builder.Append(" dbo.V_TB_RECEIVE AS B ON A.RecvBillNum = B.RecvBillNum LEFT OUTER JOIN "); @@ -761,27 +761,27 @@ namespace CK.SCP.Controller _builder.Append(" on s1.AskBillNum=s2.AskBillNum and s1.PartCode=s2.PartCode and s1.PoLine=s2.PoLine"); return _builder.ToString(); } - //public static string Get_V_SCP_FORECAST_REPORT_SQL(V_FORECAST_REPORT p_entity) - //{ - // StringBuilder _builder = new StringBuilder(); - // _builder.Append(" select B.PartCode,B.VendId,B.AskQty,B.Month, ISNULL(c.MonthQty1,0) as MonthQty1 ,ISNULL(c.MonthQty2,0) as MonthQty2 ,ISNULL(c.MonthQty3,0) as MonthQty3 from ( "); - // _builder.Append(" (selecT PartCode,VendId ,MONTH(BeginTime) as Month,sum(AskQty) as AskQty from V_TB_ASK_DETAIL A "); - // _builder.Append(" where A.IsDeleted=0 group by A.PartCode,A.VendId ,MONTH(A.BeginTime)) B LEFT OUTER JOIN "); - // _builder.Append(" TB_FORECAST c on B.PartCode=c.PartCode and B.VendId=c.VendId and b.Month=c.Month and c.IsDeleted=0 and c.State=1 ) where 1=1 "); - // if (!string.IsNullOrEmpty(p_entity.PartCode)) - // { - // _builder.AppendFormat(" And B.PartCode='{0}'", p_entity.PartCode); - // } - // if (!string.IsNullOrEmpty(p_entity.VendId)) - // { - // _builder.AppendFormat(" And B.VendId='{0}'", p_entity.VendId); - // } - // if (p_entity.Month!=0) - // { - // _builder.AppendFormat(" And B.Month='{0}'", p_entity.Month); - // } - // return _builder.ToString(); - //} + public static string Get_V_SCP_FORECAST_REPORT_SQL(V_FORECAST_REPORT p_entity) + { + StringBuilder _builder = new StringBuilder(); + _builder.Append(" select B.PartCode,B.VendId,B.AskQty,B.Month, ISNULL(c.MonthQty1,0) as MonthQty1 ,ISNULL(c.MonthQty2,0) as MonthQty2 ,ISNULL(c.MonthQty3,0) as MonthQty3 from ( "); + _builder.Append(" (selecT PartCode,VendId ,MONTH(BeginTime) as Month,sum(AskQty) as AskQty from V_TB_ASK_DETAIL A "); + _builder.Append(" where A.IsDeleted=0 group by A.PartCode,A.VendId ,MONTH(A.BeginTime)) B LEFT OUTER JOIN "); + _builder.Append(" TB_FORECAST c on B.PartCode=c.PartCode and B.VendId=c.VendId and b.Month=c.Month and c.IsDeleted=0 and c.State=1 ) where 1=1 "); + if (!string.IsNullOrEmpty(p_entity.PartCode)) + { + _builder.AppendFormat(" And B.PartCode='{0}'", p_entity.PartCode); + } + if (!string.IsNullOrEmpty(p_entity.VendId)) + { + _builder.AppendFormat(" And B.VendId='{0}'", p_entity.VendId); + } + if (p_entity.Month!=0) + { + _builder.AppendFormat(" And B.Month='{0}'", p_entity.Month); + } + return _builder.ToString(); + } /// /// 按零件编号获取及时率语句(沈阳) /// @@ -791,13 +791,13 @@ namespace CK.SCP.Controller { StringBuilder _builder = new StringBuilder(); - _builder.Append(" select h.PartCode ,sum (h.Qty) as ArriveQty , SUM(AskQty) as AskQty ,(SUM(AskQty) -sum (h.Qty)) as Qty ,sum(h.NntimelyQty) as NntimelyQty , "); - _builder.Append(" (CASE WHEN sum(Qty)=0 Then 0 ELSE (sum (NntimelyQty)/sum(Qty)) END) as OTD , sum (h.Qty)/sum(AskQty) AS ArriveOTD from ( SELECT p.AskBillNum, p.PartCode, ISNULL(A.Qty,0) as Qty, "); - _builder.Append(" p.AskQty, (CASE WHEN DATEDIFF(day, A.ShipTime, p.EndTime) > 0 THEN A.Qty ELSE 0 END) as NntimelyQty ,a.ShipTime ,p.EndTime FROM dbo.V_TB_ASK_DETAIL AS p LEFT OUTER JOIN "); - _builder.Append(" dbo.V_TB_ARRIVE_DETAIL AS A ON A.Remark = p.AskBillNum AND A.PoLine = p.PoLine AND A.PartCode = p.PartCode LEFT OUTER JOIN dbo.V_TB_ARRIVE AS B ON A.ArrvBillNum = B.ArrvBillNum "); + _builder.Append(" select h.Site, h.AskBillNum,h.EndTime, h.VendId, h.PartCode ,sum (h.Qty) as ArriveQty , AskQty ,(AskQty -sum (h.Qty)) as Qty ,sum(h.NntimelyQty) as NntimelyQty , "); + _builder.Append(" (CASE WHEN AskQty=0 Then 0 ELSE (sum (NntimelyQty)/AskQty) END) as OTD ,( CASE WHEN AskQty=0 Then 0 ELSE (sum (h.Qty)/AskQty) END ) AS ArriveOTD from ( SELECT p.Site, p.VendId, p.AskBillNum, p.PartCode, ISNULL(A.Qty,0) as Qty, "); + _builder.Append(" (p.AskQty- ISNULL(p.ReduceQty,0)) as AskQty , (CASE WHEN DATEDIFF(day, A.ShipTime, p.EndTime) >= -1 THEN A.Qty ELSE 0 END) as NntimelyQty ,a.ShipTime ,p.EndTime FROM dbo.V_TB_ASK_DETAIL AS p LEFT OUTER JOIN "); + _builder.Append(" V_TB_ASN AS B on p.AskBillNum=b.AskBillNum LEFT OUTER JOIN dbo.V_TB_ARRIVE_DETAIL AS A ON b.AsnBillNum=A.AsnBillNum AND A.PoLine = p.PoLine AND A.PartCode = p.PartCode where p.IsDeleted=0 "); if (p_entity.BeginTime != null) { - _builder.AppendFormat(" where p.EndTime>='{0}'", p_entity.BeginTime); + _builder.AppendFormat(" AND p.EndTime>='{0}'", p_entity.BeginTime); } if (p_entity.EndTime != null) { @@ -807,7 +807,11 @@ namespace CK.SCP.Controller { _builder.AppendFormat(" AND p.PartCode='{0}'", p_entity.PartCode); } - _builder.Append(") as h group by h.PartCode"); + if (!string.IsNullOrEmpty(p_entity.VendId)) + { + _builder.AppendFormat(" AND p.VendId='{0}'", p_entity.VendId); + } + _builder.Append(") as h group by h.PartCode ,h.VendId ,h.AskBillNum,h.EndTime,h.Site,h.AskQty"); return _builder.ToString(); } @@ -819,88 +823,88 @@ namespace CK.SCP.Controller public static string Get_V_SCP_OTD_REPORT_SQL_VendId(SCP_OTD_EXPORT p_entity) { StringBuilder _builder = new StringBuilder(); - _builder.Append(" select h.VendId ,sum (h.Qty) as ArriveQty , SUM(AskQty) as AskQty ,(SUM(AskQty) -sum (h.Qty)) as Qty ,sum(h.NntimelyQty) as NntimelyQty , "); - _builder.Append(" (CASE WHEN sum(Qty)=0 Then 0 ELSE (sum (NntimelyQty)/sum(Qty)) END) as OTD , sum (h.Qty)/sum(AskQty) AS ArriveOTD from ( SELECT p.VendId, p.AskBillNum, ISNULL(A.Qty,0) as Qty, "); - _builder.Append(" p.AskQty, (CASE WHEN DATEDIFF(day, A.ShipTime, p.EndTime) > 0 THEN A.Qty ELSE 0 END) as NntimelyQty ,a.ShipTime ,p.EndTime FROM dbo.V_TB_ASK_DETAIL AS p LEFT OUTER JOIN "); - _builder.Append(" dbo.V_TB_ARRIVE_DETAIL AS A ON A.Remark = p.AskBillNum AND A.PoLine = p.PoLine AND A.PartCode = p.PartCode LEFT OUTER JOIN dbo.V_TB_ARRIVE AS B ON A.ArrvBillNum = B.ArrvBillNum "); + _builder.Append(" select h.AskBillNum ,h.EndTime, h.Site, h.VendId ,sum (h.Qty) as ArriveQty , AskQty ,(AskQty -sum (h.Qty)) as Qty ,sum(h.NntimelyQty) as NntimelyQty , "); + _builder.Append(" (CASE WHEN AskQty=0 Then 0 ELSE (sum (NntimelyQty)/AskQty) END) as OTD , ( CASE WHEN AskQty=0 Then 0 ELSE (sum (h.Qty)/AskQty) END)AS ArriveOTD from ( SELECT p.Site,p.VendId, p.AskBillNum, ISNULL(A.Qty,0) as Qty, "); + _builder.Append(" (p.AskQty- ISNULL(p.ReduceQty,0)) as AskQty , (CASE WHEN DATEDIFF(day, A.ShipTime, p.EndTime) >= -1 THEN A.Qty ELSE 0 END) as NntimelyQty ,a.ShipTime ,p.EndTime FROM dbo.V_TB_ASK_DETAIL AS p LEFT OUTER JOIN "); + _builder.Append(" dbo.V_TB_ARRIVE_DETAIL AS A ON A.Remark = p.AskBillNum AND A.PoLine = p.PoLine AND A.PartCode = p.PartCode LEFT OUTER JOIN dbo.V_TB_ARRIVE AS B ON A.ArrvBillNum = B.ArrvBillNum where p.IsDeleted=0 "); if (p_entity.BeginTime != null) { - _builder.AppendFormat(" where p.EndTime>='{0}'", p_entity.BeginTime); + _builder.AppendFormat(" AND p.EndTime>='{0}'", p_entity.BeginTime); } if (p_entity.EndTime != null) { _builder.AppendFormat(" AND p.EndTime<='{0}' ", p_entity.EndTime); } - if (!string.IsNullOrEmpty(p_entity.PartCode)) + if (!string.IsNullOrEmpty(p_entity.VendId)) { _builder.AppendFormat(" AND p.VendId='{0}'", p_entity.VendId); } - _builder.Append(") as h group by h.VendId"); + _builder.Append(") as h group by h.VendId,h.Site,h.AskQty,h.AskBillNum,h.EndTime"); return _builder.ToString(); } - //public static void Get_V_SCP_FORECAST_REPORT_List(V_FORECAST_REPORT p_entity, Action>> p_action) - //{ - // ResultObject> _ret = new ResultObject>(); - // try - // { - // using (ScpEntities db = EntitiesFactory.CreateScpInstance()) - // { - // string _sql = Get_V_SCP_FORECAST_REPORT_SQL(p_entity); + public static void Get_V_SCP_FORECAST_REPORT_List(V_FORECAST_REPORT p_entity, Action>> p_action) + { + ResultObject> _ret = new ResultObject>(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + string _sql = Get_V_SCP_FORECAST_REPORT_SQL(p_entity); - // IQueryable q = db.Database.SqlQuery(_sql).AsQueryable(); - // _ret.State = ReturnStatus.Succeed; - // _ret.Result = q; - // p_action(_ret); - // } - // } - // 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.ErrorList.Add(dbEx); - // LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_SCP_FORECAST_REPORT_List", sb.ToString()); - // throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); - // } - // catch (OptimisticConcurrencyException ex)//并发冲突异常 - // { + IQueryable q = db.Database.SqlQuery(_sql).AsQueryable(); + _ret.State = ReturnStatus.Succeed; + _ret.Result = q; + p_action(_ret); + } + } + 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.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_SCP_FORECAST_REPORT_List", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { - // _ret.State = ReturnStatus.Failed; - // _ret.ErrorList.Add(ex); - // LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_SCP_FORECAST_REPORT_List", ex.ToString()); - // throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); - // } - // catch (ScpException ex) - // { - // _ret.State = ReturnStatus.Failed; - // _ret.ErrorList.Add(ex); - // LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_SCP_FORECAST_REPORT_List", ex.ToString()); + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_SCP_FORECAST_REPORT_List", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_SCP_FORECAST_REPORT_List", 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; - // _ret.ErrorList.Add(e); - // LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_SCP_FORECAST_REPORT_List", e.Message); - // throw e; - // } - //} + 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; + _ret.ErrorList.Add(e); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_REPORT_CONTROLLER), "Get_V_SCP_FORECAST_REPORT_List", e.Message); + throw e; + } + } /// /// 获取及时率数据 /// diff --git a/Controller/SCP_WMS_CONTROLLER.cs b/Controller/SCP_WMS_CONTROLLER.cs index 59527cb..7f33685 100644 --- a/Controller/SCP_WMS_CONTROLLER.cs +++ b/Controller/SCP_WMS_CONTROLLER.cs @@ -104,6 +104,80 @@ namespace CK.SCP.Controller } } + public static void Get_VIEW_STOCK_DETAIL(VIEW_STOCK_QTY p_entity, Action>> p_action) + { + ResultObject> _ret = new ResultObject>(); + try + { + using (WmsEntities db = EntitiesFactory.CreateWmsInstance()) + { + IQueryable q = db.VIEW_STOCK_QTY; + if (!string.IsNullOrEmpty(p_entity.PartCode)) + { + q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); + } + if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0) + { + q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId)); + } + if (p_entity.BeginTime != null && !p_entity.BeginTime.ToString().Contains("0001/1/1")) + { + q = q.Where(p => p.LogTime >= p_entity.BeginTime); + } + if (p_entity.EndTime != null && !p_entity.EndTime.ToString().Contains("0001/1/1")) + { + q = q.Where(p => p.LogTime <= p_entity.EndTime); + } + _ret.State = ReturnStatus.Succeed; + _ret.Result = q; + p_action(_ret); + } + } + 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.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_WMS_CONTROLLER), "Get_VIEW_STOCK_DETAIL", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_WMS_CONTROLLER), "Get_VIEW_STOCK_DETAIL", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_WMS_CONTROLLER), "Get_VIEW_STOCK_DETAIL", 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; + _ret.ErrorList.Add(e); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_WMS_CONTROLLER), "Get_VIEW_STOCK_DETAIL", e.Message); + throw e; + } + } public static void Get_VIEW_STOCK_DETAIL(VIEW_STOCK_VEND p_entity, Action>> p_action) { ResultObject> _ret = new ResultObject>(); diff --git a/Controller/UniApiController.cs b/Controller/UniApiController.cs index 7ffcabc..1aa15ee 100644 --- a/Controller/UniApiController.cs +++ b/Controller/UniApiController.cs @@ -1,16 +1,91 @@ using System; using System.Collections.Generic; +using System.Data.Entity.Core; using System.Linq; +using System.Text; using CK.SCP.Models; using CK.SCP.Models.Enums; using CK.SCP.Models.ScpEntity; using CK.SCP.Models.UniApiEntity; +using CK.SCP.Utils; namespace CK.SCP.Controller { public static class UniApiController { + public static void Get_TS_UNI_API_List(TS_UNI_API p_entity, Action>> p_action) + { + ResultObject> _ret = new ResultObject>(); + try + { + using (Models.ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + IQueryable q = db.TS_UNI_API; + if (!string.IsNullOrEmpty(p_entity.PartCode)) + { + q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); + } + if (!string.IsNullOrEmpty(p_entity.VendId)) + { + q = q.Where(p => p.VendId == p_entity.VendId); + } + if (!string.IsNullOrEmpty(p_entity.BillNum)) + { + q = q.Where(p => p.BillNum == p_entity.BillNum); + } + q = q.Where(p => p.State == p_entity.State); + q = q.Where(p => p.InterfaceType == p_entity.InterfaceType); + _ret.State = ReturnStatus.Succeed; + _ret.Result = q; + p_action(_ret); + } + } + 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.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(UniApiController), "Get_TS_UNI_API_List", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(UniApiController), "Get_TS_UNI_API_List", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(UniApiController), "Get_TS_UNI_API_List", 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; + _ret.ErrorList.Add(e); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(UniApiController), "Get_TS_UNI_API_List", e.Message); + throw e; + } + } public static void RemoveList(ScpEntities db, List uniApiList) { db.TS_UNI_API.RemoveRange(uniApiList); diff --git a/Models/CK.SCP.Models.csproj b/Models/CK.SCP.Models.csproj index 0b8d682..ab132b0 100644 --- a/Models/CK.SCP.Models.csproj +++ b/Models/CK.SCP.Models.csproj @@ -332,6 +332,7 @@ + @@ -370,6 +371,7 @@ + @@ -410,6 +412,7 @@ + @@ -423,7 +426,6 @@ - @@ -694,6 +696,7 @@ + diff --git a/Models/ScpEntities.cs b/Models/ScpEntities.cs index 3f32acc..88c9b81 100644 --- a/Models/ScpEntities.cs +++ b/Models/ScpEntities.cs @@ -118,7 +118,7 @@ namespace CK.SCP.Models public virtual DbSet V_TA_VEND_PART { get; set; } public virtual DbSet TB_PRICE { get; set; } public virtual DbSet TB_FORECAST { get; set; } - + public virtual DbSet V_TB_FORECAST { get; set; } public virtual DbSet TB_RECEIVE_DETAIL_QAD { get; set; } public virtual DbSet TB_RECEIVE_QAD { get; set; } diff --git a/Models/ScpEntity/ExcelExportEnttity/SCP_ASK_DETAIL_EXPORT.cs b/Models/ScpEntity/ExcelExportEnttity/SCP_ASK_DETAIL_EXPORT.cs index ca953e1..db2b598 100644 --- a/Models/ScpEntity/ExcelExportEnttity/SCP_ASK_DETAIL_EXPORT.cs +++ b/Models/ScpEntity/ExcelExportEnttity/SCP_ASK_DETAIL_EXPORT.cs @@ -20,6 +20,9 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity public string 要货数量 {get;set;} //"AskQty" public string 说明 { get; set; } //"ReMark" + public string 预测一 { get; set; } //"OneMonth" + public string 预测二 { get; set; } //"TwoMonth" + public string 预测三 { get; set; } //"ThreeMonth" } } diff --git a/Models/ScpEntity/ExcelExportEnttity/SCP_FORECAST_EXPORT.cs b/Models/ScpEntity/ExcelExportEnttity/SCP_FORECAST_EXPORT.cs index 548d418..4c5bc97 100644 --- a/Models/ScpEntity/ExcelExportEnttity/SCP_FORECAST_EXPORT.cs +++ b/Models/ScpEntity/ExcelExportEnttity/SCP_FORECAST_EXPORT.cs @@ -8,11 +8,23 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity { public class SCP_FORECAST_EXPORT { + public string 订单 { get; set; } + public string 供应商编码 { get; set; } public string 零件编号 { get; set; } - public string 月份 { get; set; } + public string 图号 { get; set; } + public string 规格 { get; set; } + public string 单位 { get; set; } + public string 当次订单数量 { get; set; } + public string 产品状态 { get; set; } + public string 紧急 { get; set; } + public string 要求到货日期 { get; set; } + public string 到货地 { get; set; } + public string 当月 { get; set; } public string 预测1 { get; set; } public string 预测2 { get; set; } public string 预测3 { get; set; } - public string 供应商编码 { get; set; } + public string 是否按期交货 { get; set; } + public string 不能按期交付日期 { get; set; } + public string 备注 { get; set; } } } diff --git a/Models/ScpEntity/ExcelExportEnttity/SCP_OTD_REPORT_EXPORT.cs b/Models/ScpEntity/ExcelExportEnttity/SCP_OTD_REPORT_EXPORT.cs new file mode 100644 index 0000000..4566bf1 --- /dev/null +++ b/Models/ScpEntity/ExcelExportEnttity/SCP_OTD_REPORT_EXPORT.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity +{ + public class SCP_OTD_REPORT_EXPORT + { + public string 要货看板号 { get; set; } + public string 供应商编号 { get; set; } //VendId + public string 供应商名称 { get; set; } //VendId + public string 零件号 { get; set; } + public string 零件名称 { get; set; } + public string 要求到货时间 { get; set; } + public string 到货数量 { get; set; } //ArriveQty + public string 订单要货数量 { get; set; } //AskQty + public string 差额 { get; set; } //Qty + public string 及时数量 { get; set; } //NntimelyQty + public string 及时率 { get; set; }//OTD + public string 到货率 { get; set; }//ArriveOTD + } +} \ No newline at end of file diff --git a/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs b/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs index 401695c..d4e44d3 100644 --- a/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs +++ b/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs @@ -46,6 +46,9 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity public string 收货口 { get; set; } public string 备注 { get; set; } + public string 预测一 { get; set; } + public string 预测二 { get; set; } + public string 预测三{ get; set; } diff --git a/Models/ScpEntity/SCP_OTD_EXPORT.cs b/Models/ScpEntity/SCP_OTD_EXPORT.cs index ec2fecb..82a13e9 100644 --- a/Models/ScpEntity/SCP_OTD_EXPORT.cs +++ b/Models/ScpEntity/SCP_OTD_EXPORT.cs @@ -32,5 +32,7 @@ namespace CK.SCP.Models.ScpEntity public decimal ArriveOTD { get; set; }//到货率 public Nullable BeginTime { get; set; }//开始时间 public Nullable EndTime { get; set; } //结束时间 + public string AskBillNum { get; set; } = "";//看板号 + public string Site { get; set; } } } diff --git a/Models/ScpEntity/TB_FORECAST.cs b/Models/ScpEntity/TB_FORECAST.cs index 30adbde..d14aea4 100644 --- a/Models/ScpEntity/TB_FORECAST.cs +++ b/Models/ScpEntity/TB_FORECAST.cs @@ -21,14 +21,24 @@ namespace CK.SCP.Models.ScpEntity /// 零件编号 /// [StringLength(50)] - public string PartCode { get; set; } - /// + public string PoType { get; set; } + [StringLength(50)] /// 供应商编号 /// public string VendId { get; set; } - /// - /// N+1 + [StringLength(50)] + public string PartCode { get; set; } + public int PoLine { get; set; } + [StringLength(50)] + public string Specifications { get; set; } + public string Unit { get; set; } /// + public decimal Qty { get; set; } + public string ProductStatus { get; set; } + public string IsUrgent { get; set; } + public DateTime? ShippdedTime { get; set; } + public string ShippdedPlace { get; set; } + public decimal MonthQty { get; set; } public decimal MonthQty1 { get; set; } /// /// N+2 @@ -41,7 +51,10 @@ namespace CK.SCP.Models.ScpEntity /// /// 月份 /// - public string Month { get; set; } + public string Ontime { get; set; } + public string Datetime { get; set; } + [StringLength(50)] + public string Remark { get; set; } /// /// 状态 /// diff --git a/Models/ScpEntity/TB_INVOICE_DETAIL.cs b/Models/ScpEntity/TB_INVOICE_DETAIL.cs index a77a4ea..c9ee8b0 100644 --- a/Models/ScpEntity/TB_INVOICE_DETAIL.cs +++ b/Models/ScpEntity/TB_INVOICE_DETAIL.cs @@ -15,6 +15,8 @@ namespace CK.SCP.Models.ScpEntity [StringLength(50)] public string RecvBillNum { get; set; } [StringLength(50)] + public string ErpRecvBillNum { get; set; } + [StringLength(50)] public string AsnBillNum { get; set; } [StringLength(50)] public string PoBillNum { get; set; } diff --git a/Models/ScpEntity/TB_RECEIVE_DETAIL_QAD.cs b/Models/ScpEntity/TB_RECEIVE_DETAIL_QAD.cs index b634a3d..b08ade1 100644 --- a/Models/ScpEntity/TB_RECEIVE_DETAIL_QAD.cs +++ b/Models/ScpEntity/TB_RECEIVE_DETAIL_QAD.cs @@ -9,8 +9,7 @@ namespace CK.SCP.Models.ScpEntity [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long UID { get; set; } [StringLength(50)] - [Key] - [Column(Order = 0)] + public string RecvBillNum { get; set; } [Key] [Column(Order = 1)] @@ -45,7 +44,8 @@ namespace CK.SCP.Models.ScpEntity public string PoUnit { get; set; } [StringLength(50)] public string LocUnit { get; set; } - + [Key] + [Column(Order = 0)] public string ErpRecvBillNum { get; set; } /// diff --git a/Models/ScpEntity/TB_RECEIVE_QAD.cs b/Models/ScpEntity/TB_RECEIVE_QAD.cs index 75150d6..e47f7ab 100644 --- a/Models/ScpEntity/TB_RECEIVE_QAD.cs +++ b/Models/ScpEntity/TB_RECEIVE_QAD.cs @@ -10,8 +10,7 @@ namespace CK.SCP.Models.ScpEntity [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long UID { get; set; } [StringLength(50)] - [Key] - [Column(Order = 0)] + public string RecvBillNum { get; set; } [StringLength(50)] public string PoBillNum { get; set; } @@ -36,7 +35,8 @@ namespace CK.SCP.Models.ScpEntity [StringLength(50)] public string OperName { get; set; } public int BillType { get; set; } - + [Key] + [Column(Order = 0)] public string ErpRecvBillNum { get; set; } diff --git a/Models/ScpEntity/TS_BARCODE_CUSTOM.cs b/Models/ScpEntity/TS_BARCODE_CUSTOM.cs index 7103671..a17f3f6 100644 --- a/Models/ScpEntity/TS_BARCODE_CUSTOM.cs +++ b/Models/ScpEntity/TS_BARCODE_CUSTOM.cs @@ -77,7 +77,7 @@ namespace CK.SCP.Models.ScpEntity [DisplayName("Ӧ")] - public string VendName => ScpCache.GetVendName(VendId, Site)+"(Զ)"; + public string VendName => ScpCache.GetVendName(VendId, Site)+"(Զ)"; [DisplayName("")] diff --git a/Models/ScpEntity/V_FORECAST_REPORT.cs b/Models/ScpEntity/V_FORECAST_REPORT.cs new file mode 100644 index 0000000..48f387c --- /dev/null +++ b/Models/ScpEntity/V_FORECAST_REPORT.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CK.SCP.Models.ScpEntity +{ + public class V_FORECAST_REPORT + { + public string VendId { get; set; } //供应商编号 + public string PartCode { get; set; } //零件号 + public decimal AskQty { get; set; } //订单要货数量 + public int Month { get; set; } //月份 + public decimal MonthQty1 { get; set; } //N+1 + public decimal MonthQty2 { get; set; } //N+2 + public decimal MonthQty3 { get; set; } //N+3 + [NotMapped] + public string VendName => ScpCache.GetVendName(VendId);//供应商名称 + } +} diff --git a/Models/ScpEntity/V_TB_ASK_DETAIL.cs b/Models/ScpEntity/V_TB_ASK_DETAIL.cs index ff16455..2700800 100644 --- a/Models/ScpEntity/V_TB_ASK_DETAIL.cs +++ b/Models/ScpEntity/V_TB_ASK_DETAIL.cs @@ -84,6 +84,9 @@ namespace CK.SCP.Models.ScpEntity public decimal? ReduceQty { get; set; } + public decimal OneMonth { get; set; } + public decimal TwoMonth { get; set; } + public decimal ThreeMonth { get; set; } public int ValidityDays { get; set; } diff --git a/Models/ScpEntity/V_TB_FORECAST.cs b/Models/ScpEntity/V_TB_FORECAST.cs new file mode 100644 index 0000000..3c80bff --- /dev/null +++ b/Models/ScpEntity/V_TB_FORECAST.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CK.SCP.Models.ScpEntity +{ + public class V_TB_FORECAST : RecordEntity + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public long UID { get; set; } + [StringLength(50)] + public string PoType { get; set; } + [StringLength(50)] + public string VendId { get; set; } + [StringLength(50)] + public string PartCode { get; set; } + public int PoLine { get; set; } + [StringLength(50)] + public string Specifications { get; set; } + public string Unit { get; set; } + + public decimal Qty { get; set; } + public string ProductStatus { get; set; } + public string IsUrgent { get; set; } + public DateTime? ShippdedTime { get; set; } + public string ShippdedPlace { get; set; } + public decimal MonthQty { get; set; } + public decimal MonthQty1 { get; set; } + public decimal MonthQty2 { get; set; } + public decimal MonthQty3 { get; set; } + public string Ontime { get; set; } + public string Datetime { get; set; } + [StringLength(50)] + public string Remark { get; set; } + public int? State { get; set; } + + [StringLength(50)] + public string State_DESC { get; set; } + [StringLength(50)] + public string Site { get; set; } + + } +} diff --git a/Models/ScpEntity/V_TB_INCOMPLETE_ASK.cs b/Models/ScpEntity/V_TB_INCOMPLETE_ASK.cs index 83cbfd2..f61cdec 100644 --- a/Models/ScpEntity/V_TB_INCOMPLETE_ASK.cs +++ b/Models/ScpEntity/V_TB_INCOMPLETE_ASK.cs @@ -30,6 +30,8 @@ [NotMapped] public decimal ReceivedQty { get; set; }//合格数量 [NotMapped] + public decimal DepositQty { get; set; }//寄存数量 + [NotMapped] public decimal OnRoadQty { get; set; }//在途数量 public DateTime? BeginTime { get; set; } diff --git a/Models/ScpEntity/V_TB_PO_INCOMPLETE.cs b/Models/ScpEntity/V_TB_PO_INCOMPLETE.cs deleted file mode 100644 index 49aa789..0000000 --- a/Models/ScpEntity/V_TB_PO_INCOMPLETE.cs +++ /dev/null @@ -1,28 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码已从模板生成。 -// -// 手动更改此文件可能导致应用程序出现意外的行为。 -// 如果重新生成代码,将覆盖对此文件的手动更改。 -// -//------------------------------------------------------------------------------ - -namespace CK.SCP.Models.ScpEntity -{ - using System; - using System.Collections.Generic; - - public partial class V_TB_PO_INCOMPLETE - { - public string PoBillNum { get; set; } - public Nullable EndTime { get; set; } - public string Buyer { get; set; } - public string Site { get; set; } - public string VendId { get; set; } - public string PartCode { get; set; } - public decimal PlanQty { get; set; } - public decimal QTY { get; set; } - public string VendName { get; set; } - public string partdesc { get; set; } - } -} diff --git a/Models/ScpEntity/V_TB_RECEIVE_LIST.cs b/Models/ScpEntity/V_TB_RECEIVE_LIST.cs index 65f0c8f..f963e52 100644 --- a/Models/ScpEntity/V_TB_RECEIVE_LIST.cs +++ b/Models/ScpEntity/V_TB_RECEIVE_LIST.cs @@ -55,7 +55,7 @@ namespace CK.SCP.Models.ScpEntity public string ProjectId { get; set; } public Nullable BeginTime { get; set; } - [NotMapped] + public decimal CanQty { get; set; } [NotMapped] diff --git a/Models/UniApiEntity/xxscm_inv_det.cs b/Models/UniApiEntity/xxscm_inv_det.cs index bd9050b..774f34f 100644 --- a/Models/UniApiEntity/xxscm_inv_det.cs +++ b/Models/UniApiEntity/xxscm_inv_det.cs @@ -14,7 +14,7 @@ namespace CK.SCP.Models.UniApiEntity public string xxscm_inv_seq { get; set; } [Required(AllowEmptyStrings = true)] - [StringLength(58)] + [StringLength(50)] public string xxscm_inv_domain { get; set; } [Required(AllowEmptyStrings = true)] diff --git a/Models/UniApiEntity/xxwms_arv_det.cs b/Models/UniApiEntity/xxwms_arv_det.cs index d778add..a57c9e5 100644 --- a/Models/UniApiEntity/xxwms_arv_det.cs +++ b/Models/UniApiEntity/xxwms_arv_det.cs @@ -37,7 +37,7 @@ namespace CK.SCP.Models.UniApiEntity public decimal xxwms_arv_conv { get; set; } [StringLength(100)] public string xxwms_arv_lot { get; set; } - [StringLength(20)] + [StringLength(50)] public string xxwms_arv_vend_batch { get; set; } [StringLength(1)] public string xxwms_arv_qadread { get; set; } diff --git a/Models/UniApiEntity/xxwms_rc_det.cs b/Models/UniApiEntity/xxwms_rc_det.cs index 848e2e1..282b8cd 100644 --- a/Models/UniApiEntity/xxwms_rc_det.cs +++ b/Models/UniApiEntity/xxwms_rc_det.cs @@ -64,7 +64,7 @@ namespace CK.SCP.Models.UniApiEntity public string xxwms_rc_lot { get; set; } [Required(AllowEmptyStrings = true)] - [StringLength(20)] + [StringLength(100)] public string xxwms_rc_vend_batch { get; set; } [StringLength(1)] diff --git a/Models/WmsEntity/VIEW_STOCK_QTY.cs b/Models/WmsEntity/VIEW_STOCK_QTY.cs new file mode 100644 index 0000000..a3311f5 --- /dev/null +++ b/Models/WmsEntity/VIEW_STOCK_QTY.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ChangKeTec.Wms.Models.Wms +{ + public partial class VIEW_STOCK_QTY + { + [Key] + [Column(Order = 0)] + [StringLength(50)] + public string PartCode { get; set; } + [Key] + [Column(Order = 1)] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public System.DateTime LogTime { get; set; } + + public decimal qty { get; set; } + + public string VendId { get; set; } + + public string status { get; set; } + + [NotMapped] + public DateTime? BeginTime { get; set; } + + [NotMapped] + public DateTime? EndTime { get; set; } + [NotMapped] + public List UserInVendIds { set; get; } + } +} diff --git a/Models/WmsEntity/VIEW_STOCK_VEND.cs b/Models/WmsEntity/VIEW_STOCK_VEND.cs index 9a8ca76..828b1d5 100644 --- a/Models/WmsEntity/VIEW_STOCK_VEND.cs +++ b/Models/WmsEntity/VIEW_STOCK_VEND.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; @@ -12,6 +13,7 @@ namespace ChangKeTec.Wms.Models.Wms public long UID { get; set; } [StringLength(50)] + [DisplayName("零件名称")] public string PartCode { get; set; } [StringLength(50)] public string PartDesc1 { get; set; } diff --git a/Models/WmsEntity/WmsEntities.cs b/Models/WmsEntity/WmsEntities.cs index 95f1d69..09e7653 100644 --- a/Models/WmsEntity/WmsEntities.cs +++ b/Models/WmsEntity/WmsEntities.cs @@ -21,6 +21,7 @@ namespace ChangKeTec.Wms.Models.Wms public virtual DbSet VIEW_PRODUCT_DETAIL { get; set; } public virtual DbSet VIEW_STOCK_VEND { get; set; } + public virtual DbSet VIEW_STOCK_QTY { get; set; } public virtual DbSet TA_BILLTYPE { get; set; } public virtual DbSet TA_BOM { get; set; } public virtual DbSet TA_CELL { get; set; } diff --git a/SCP.sln b/SCP.sln index b21b3b1..7f19f0a 100644 --- a/SCP.sln +++ b/SCP.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29424.173 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCP", "SCP\SCP.csproj", "{B5ECC9CB-5122-458B-A8B4-B1D3B679E40D}" EndProject @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CK.SCP.Controller", "Contro EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CK.SCP.Models", "Models\CK.SCP.Models.csproj", "{74DCE5F2-A501-45F2-B4F9-494AA1867226}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CK.SCP.UniApi", "UniApi\CK.SCP.UniApi.csproj", "{B870B746-D647-4B84-8F84-6281D3A55FCB}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CK.SCP.Common", "Common\CK.SCP.Common.csproj", "{3D6090AB-2F0C-4350-AEF3-59DD73EAB1AA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CK.SCP.Utils", "Utils\CK.SCP.Utils.csproj", "{4C6A951D-AD7F-47CE-B2CE-32C205D8D6BA}" @@ -33,18 +31,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "数据库脚本", "数据 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "库存查询脚本", "库存查询脚本", "{8D2819CE-1334-4EFE-A50F-E23BC8DDD71D}" ProjectSection(SolutionItems) = preProject - ..\..\..\Desktop\SCP项目\VIEW_PRODUCT_DETAIL.sql = ..\..\..\Desktop\SCP项目\VIEW_PRODUCT_DETAIL.sql - ..\..\..\Desktop\SCP项目\Wms数据库设置.ini = ..\..\..\Desktop\SCP项目\Wms数据库设置.ini + ..\..\Desktop\SCP项目\VIEW_PRODUCT_DETAIL.sql = ..\..\Desktop\SCP项目\VIEW_PRODUCT_DETAIL.sql + ..\..\Desktop\SCP项目\Wms数据库设置.ini = ..\..\Desktop\SCP项目\Wms数据库设置.ini EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "权限库备份", "权限库备份", "{137B27CF-8F56-49BB-9705-060995312716}" ProjectSection(SolutionItems) = preProject - ..\..\..\Desktop\权限系统.sql = ..\..\..\Desktop\权限系统.sql + ..\..\Desktop\权限系统.sql = ..\..\Desktop\权限系统.sql EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SCP库备份", "SCP库备份", "{636001CD-8969-4077-9A44-E681C4ADF8BD}" ProjectSection(SolutionItems) = preProject - ..\..\..\Desktop\SCP系统脚本.sql = ..\..\..\Desktop\SCP系统脚本.sql + ..\..\Desktop\SCP系统脚本.sql = ..\..\Desktop\SCP系统脚本.sql EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CK.SCP.GrupUniApi", "UniApiGroup\CK.SCP.GrupUniApi.csproj", "{6A22F275-D490-46B3-B183-35408BF106C4}" @@ -69,10 +67,6 @@ Global {74DCE5F2-A501-45F2-B4F9-494AA1867226}.Debug|Any CPU.Build.0 = Debug|Any CPU {74DCE5F2-A501-45F2-B4F9-494AA1867226}.Release|Any CPU.ActiveCfg = Release|Any CPU {74DCE5F2-A501-45F2-B4F9-494AA1867226}.Release|Any CPU.Build.0 = Release|Any CPU - {B870B746-D647-4B84-8F84-6281D3A55FCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B870B746-D647-4B84-8F84-6281D3A55FCB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B870B746-D647-4B84-8F84-6281D3A55FCB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B870B746-D647-4B84-8F84-6281D3A55FCB}.Release|Any CPU.Build.0 = Release|Any CPU {3D6090AB-2F0C-4350-AEF3-59DD73EAB1AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3D6090AB-2F0C-4350-AEF3-59DD73EAB1AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D6090AB-2F0C-4350-AEF3-59DD73EAB1AA}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/SCP/Admin/user.aspx b/SCP/Admin/user.aspx index f6e87bb..2aa155f 100644 --- a/SCP/Admin/user.aspx +++ b/SCP/Admin/user.aspx @@ -90,7 +90,7 @@ - +