diff --git a/MESClassLibrary/BLL/BasicInfo/Bom_MKBLL.cs b/MESClassLibrary/BLL/BasicInfo/Bom_MKBLL.cs index 673e144..9194ac3 100644 --- a/MESClassLibrary/BLL/BasicInfo/Bom_MKBLL.cs +++ b/MESClassLibrary/BLL/BasicInfo/Bom_MKBLL.cs @@ -60,9 +60,17 @@ namespace MESClassLibrary.BLL.BasicInfo //} //初始化要更新的字段 - string[] proNames = new string[2]; + string[] proNames = new string[10]; proNames[0] = "PartNo1"; proNames[1] = "PartNo2"; + proNames[2] = "LineName"; + proNames[3] = "StationNo"; + proNames[4] = "IsChecked"; + proNames[5] = "IsPartAssemble"; + proNames[6] = "LeftCount"; + proNames[7] = "RightCount"; + proNames[8] = "PartDesc1"; + proNames[9] = "PartDesc2"; //必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化 //如果没有初始化必填字段,更新会报错 @@ -102,7 +110,7 @@ namespace MESClassLibrary.BLL.BasicInfo /// 查询全部信息分页 /// /// - public string SearchInfoAll(string page, string pagesize, string partNo1, string partNo2, string placeName) + public string SearchInfoAll(string page, string pagesize, string partNo1, string partNo2, string lineName) { try { @@ -121,9 +129,9 @@ namespace MESClassLibrary.BLL.BasicInfo list = list.Where(p => p.PartNo2 != null && p.PartNo2.Contains(partNo2) ).ToList(); } - if (!String.IsNullOrEmpty(placeName)) + if (!String.IsNullOrEmpty(lineName)) { - list = list.Where(p => p.PlaceName != null && p.PlaceName.Contains(placeName)).ToList(); + list = list.Where(p => p.LineName != null && p.LineName.Contains(lineName)).ToList(); } if (list.Count > 0) @@ -277,5 +285,72 @@ namespace MESClassLibrary.BLL.BasicInfo } } + public List> SearchForExcel(string paintNo, string stock) + { + try + { + List> list1 = new List>(); + List list = new List(); + + string jsonStr = "[]"; + int total = 0;//总行数 + + list = db.SearchAllInfo(); + + if (!string.IsNullOrWhiteSpace(paintNo)) + { + list = list.Where(p => p.PartNo1.Equals(paintNo)).ToList(); + } + + if (!string.IsNullOrWhiteSpace(stock)) + { + list = list.Where(p => p.LineName.Equals(stock)).ToList(); + } + + if (list != null && list.Count() > 0) + { + List title_ = new List(); + + title_.Add("总成零件号"); + title_.Add("产品名称"); + title_.Add("子零件号"); + title_.Add("子零件名称"); + title_.Add("是否检测"); + title_.Add("是否半成品"); + title_.Add("产线"); + title_.Add("工位号"); + title_.Add("左侧数量"); + title_.Add("右侧数量"); + list1.Add(title_); + + List titleList = new List(); + foreach (var item in list) + { + List rowList = new List(); + + rowList.Add(item.PartNo1 == null ? "" : item.PartNo1); + rowList.Add(item.PartDesc1 == null ? "" : item.PartDesc1); + rowList.Add(item.PartNo2 == null ? "" : item.PartNo2); + rowList.Add(item.PartDesc2 == null ? "" : item.PartDesc2); + rowList.Add(item.IsChecked == null ? "" : item.IsChecked.ToString()); + rowList.Add(item.IsPartAssemble == null ? "" : item.IsPartAssemble.ToString()); + rowList.Add(item.LineName == null ? "" : item.LineName); + rowList.Add(item.StationNo == null ? "" : item.StationNo); + rowList.Add(item.LeftCount == null ? "" : item.LeftCount.ToString()); + rowList.Add(item.RightCount == null ? "" : item.RightCount.ToString()); + list1.Add(rowList); + } + } + + return list1; + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return null; + } + } + + } } diff --git a/MESClassLibrary/BLL/BasicInfo/ConfigBLL.cs b/MESClassLibrary/BLL/BasicInfo/ConfigBLL.cs new file mode 100644 index 0000000..d875a24 --- /dev/null +++ b/MESClassLibrary/BLL/BasicInfo/ConfigBLL.cs @@ -0,0 +1,143 @@ +using MESClassLibrary.BLL.Log; +using MESClassLibrary.EFModel; +using MESClassLibrary.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace MESClassLibrary.BLL.BasicInfo +{ + public class ConfigBLL + { + BasicBLL db = new BasicBLL(); + /// + /// 查询信息 + /// + /// + public string SearchInfo(string page, string pagesize, string name) + { + try + { + string jsonStr = "[]"; + int total = 0;//总行数 + List list = db.SearchAllInfo(); + + if (!String.IsNullOrEmpty(name)) + { + list = list.Where(p => p.name == name).ToList();//按条件分页查询 + } + + + if (list.Count > 0) + { + total = list.Count; + int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize); + list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList(); + + #region 联查 + List ModelList = new List(); + + foreach (var item in list) + { + if(item.name == "PunchAssembleVerifyQA") + { + ModelList.Add(item); + } + } + #endregion + + JsonDataModel md = new JsonDataModel(); + md.total = total.ToString(); + md.rows = ModelList; + jsonStr = JSONTools.ScriptSerialize>(md); + } + return jsonStr; + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return ""; + } + + + } + /// + /// 添加信息 + /// + /// 生产线模型对象 + /// + public bool AddInfo(tb_Config md) + { + try + { + var list = db.SearchInfoByKey("name", md.name);//判断是否有重复数据 + if (list != null) + { + if (list.Where(p => p.name != md.name).Count() > 0) + { + return false; + } + + } + + return db.AddInfo(md); + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return false; + } + + } + /// + /// 修改信息 + /// + /// 生产线模型对象 + /// + public bool UpdateInfo(tb_Config md) + { + try + { + var list = db.SearchAllInfo().Where(p => p.name == md.name).ToList();//判断是否有重复数据 + if (list.Count > 0) + { + return false; + } + + //初始化要更新的字段 + string[] proNames = new string[1]; + proNames[0] = "value"; + //proNames[1] = "des"; + + //必填字段初始化,如果不需要更新必填字段则设置为空即可,时间类型无需初始化 + //如果没有初始化必填字段,更新会报错 + //md.Des = ""; + + return db.UpdateInfo(md, proNames); + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return false; + } + } + /// 删除配置项信息 + public bool DelInfo(tb_Config md) + { + try + { + return db.DelInfo(md); + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return false; + } + } + + + } +} diff --git a/MESClassLibrary/BLL/BasicInfo/LineBLL.cs b/MESClassLibrary/BLL/BasicInfo/LineBLL.cs index d9f485f..908fe3c 100644 --- a/MESClassLibrary/BLL/BasicInfo/LineBLL.cs +++ b/MESClassLibrary/BLL/BasicInfo/LineBLL.cs @@ -166,5 +166,26 @@ namespace MESClassLibrary.BLL.BasicInfo return ""; } } + + public bool IsExist(string lineName) + { + try + { + var list = db.SearchAllInfo().Where(p => p.LineName.Equals(lineName)).ToList(); + if (list.Count > 0) + { + return true; + } + + return false; + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return false; + } + } + + } } diff --git a/MESClassLibrary/BLL/BasicInfo/ProductBLL.cs b/MESClassLibrary/BLL/BasicInfo/ProductBLL.cs index 57eaaa8..cd9017a 100644 --- a/MESClassLibrary/BLL/BasicInfo/ProductBLL.cs +++ b/MESClassLibrary/BLL/BasicInfo/ProductBLL.cs @@ -664,6 +664,25 @@ namespace MESClassLibrary.BLL.BasicInfo } } + public bool IsExist(string partNo) + { + try + { + var list = db.SearchAllInfo().Where(p => p.PartNo.Equals(partNo)).ToList(); + if (list.Count > 0) + { + return true; + } + + return false; + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return false; + } + } + } } diff --git a/MESClassLibrary/BLL/BasicInfo/StationBLL.cs b/MESClassLibrary/BLL/BasicInfo/StationBLL.cs index 53967c7..0921a77 100644 --- a/MESClassLibrary/BLL/BasicInfo/StationBLL.cs +++ b/MESClassLibrary/BLL/BasicInfo/StationBLL.cs @@ -257,5 +257,26 @@ namespace MESClassLibrary.BLL.BasicInfo { return da.SearchStationNameByID(stationID); } + + + public bool IsExist(string stationNo) + { + try + { + var list = db.SearchAllInfo().Where(p => p.StationNo.Equals(stationNo)).ToList(); + if (list.Count > 0) + { + return true; + } + + return false; + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return false; + } + } + } } diff --git a/MESClassLibrary/BLL/ZPPlan/ZP_MK_PlanBLL.cs b/MESClassLibrary/BLL/ZPPlan/ZP_MK_PlanBLL.cs index 7b20c9c..44f35e5 100644 --- a/MESClassLibrary/BLL/ZPPlan/ZP_MK_PlanBLL.cs +++ b/MESClassLibrary/BLL/ZPPlan/ZP_MK_PlanBLL.cs @@ -57,7 +57,10 @@ namespace MESClassLibrary.BLL.BasicInfo { try { - var data = db.SearchInfoByID(md.ID.ToString()); + var list = db.SearchAllInfo().Where(p => p.ID == md.ID).ToList();//查询明细 + if(list.Count==0) return false; + var data = list[0]; + //var data = db.SearchInfoByID(md.ID.ToString()); if (data.State == 3) { msg = "该计划已经完成"; @@ -69,13 +72,11 @@ namespace MESClassLibrary.BLL.BasicInfo return false; } if (data.OKCount.GetValueOrDefault(0) == 0) - { - //data.StationID = md.StationID; + { data.PartNo = md.PartNo; data.OrderDate = md.OrderDate; } - - //data.IsOneMore = md.IsOneMore; + data.OrderCount = md.OrderCount; data.OrderName = md.OrderName; return db.UpdateInfo(data); @@ -117,13 +118,43 @@ namespace MESClassLibrary.BLL.BasicInfo int pagesize, string startTime, string endTime, - string partNo) + string partNo, string state) { try { + int stateFlag = 0; + if(!string.IsNullOrEmpty(state)) + { + if(state == "新建") + { + stateFlag = 0; + } + else if(state == "启用") + { + stateFlag = 1; + } + else if (state == "暂停") + { + stateFlag = 2; + } + else if (state == "完成") + { + stateFlag = 3; + } + else + { + stateFlag = 0; + } + } + + string jsonStr = "[]"; int total = 0;//总行数 IEnumerable list = SearchDB(startTime, endTime, partNo); + if(!string.IsNullOrEmpty(state)) + { + list = list.Where(p => p.State == stateFlag); + } if (list.Any()) { List modelList = new List(); @@ -202,8 +233,8 @@ namespace MESClassLibrary.BLL.BasicInfo { list = db.Search( q => (q.OrderDate >= st && - q.OrderDate <= et) && - q.State != 3, + q.OrderDate <= et) + , q => q.OrderDate); } else diff --git a/MESClassLibrary/EFModel/BBMPT.Context.cs b/MESClassLibrary/EFModel/BBMPT.Context.cs index 7b9b865..d8dbedc 100644 --- a/MESClassLibrary/EFModel/BBMPT.Context.cs +++ b/MESClassLibrary/EFModel/BBMPT.Context.cs @@ -195,7 +195,7 @@ namespace MESClassLibrary.EFModel public virtual DbSet t_XD_ProductType { get; set; } public virtual DbSet W_XD_Product_del { get; set; } public virtual DbSet t_XD_StockArea { get; set; } - public virtual DbSet tb_Bom_MK { get; set; } public virtual DbSet tb_ZP_MK_Plan { get; set; } + public virtual DbSet tb_Bom_MK { get; set; } } } diff --git a/MESClassLibrary/EFModel/BBMPT.edmx b/MESClassLibrary/EFModel/BBMPT.edmx index b2a1c18..332ac08 100644 --- a/MESClassLibrary/EFModel/BBMPT.edmx +++ b/MESClassLibrary/EFModel/BBMPT.edmx @@ -662,9 +662,13 @@ - + + + + + @@ -3591,8 +3595,8 @@ - + @@ -6081,19 +6085,6 @@ - - - - - - - - - - - - - @@ -6114,6 +6105,23 @@ + + + + + + + + + + + + + + + + + @@ -8754,20 +8762,6 @@ - - - - - - - - - - - - - - @@ -8789,6 +8783,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/MESClassLibrary/EFModel/BBMPT.edmx.diagram b/MESClassLibrary/EFModel/BBMPT.edmx.diagram index 1233514..18e291d 100644 --- a/MESClassLibrary/EFModel/BBMPT.edmx.diagram +++ b/MESClassLibrary/EFModel/BBMPT.edmx.diagram @@ -173,8 +173,9 @@ - + + @@ -6599,6 +6600,166 @@ + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + + >>>>>>> .r85 + + + diff --git a/MESClassLibrary/EFModel/tb_Bom_MK.cs b/MESClassLibrary/EFModel/tb_Bom_MK.cs index 8143218..cc99a91 100644 --- a/MESClassLibrary/EFModel/tb_Bom_MK.cs +++ b/MESClassLibrary/EFModel/tb_Bom_MK.cs @@ -19,8 +19,12 @@ namespace MESClassLibrary.EFModel public string PartNo2 { get; set; } public string UserID { get; set; } public Nullable IsChecked { get; set; } - public string PlaceName { get; set; } + public string LineName { get; set; } public Nullable IsPartAssemble { get; set; } public string StationNo { get; set; } + public Nullable LeftCount { get; set; } + public Nullable RightCount { get; set; } + public string PartDesc1 { get; set; } + public string PartDesc2 { get; set; } } } diff --git a/MESClassLibrary/MESClassLibrary.csproj b/MESClassLibrary/MESClassLibrary.csproj index 27bcfcc..553ea0a 100644 --- a/MESClassLibrary/MESClassLibrary.csproj +++ b/MESClassLibrary/MESClassLibrary.csproj @@ -67,6 +67,7 @@ + @@ -831,6 +832,7 @@ + diff --git a/MESClassLibrary/Model/ConfigModel .cs b/MESClassLibrary/Model/ConfigModel .cs new file mode 100644 index 0000000..64318d3 --- /dev/null +++ b/MESClassLibrary/Model/ConfigModel .cs @@ -0,0 +1,14 @@ +using MESClassLibrary.EFModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MESClassLibrary.Model +{ + public class ConfigModel : tb_Config + { + public string FactoryName { get; set; } + } +} diff --git a/MESWebSite/Excel/装配Bom导入模板.xlsx b/MESWebSite/Excel/装配Bom导入模板.xlsx new file mode 100644 index 0000000..1b1182f Binary files /dev/null and b/MESWebSite/Excel/装配Bom导入模板.xlsx differ diff --git a/MESWebSite/HttpHandlers/Bom_MKHandler.ashx.cs b/MESWebSite/HttpHandlers/Bom_MKHandler.ashx.cs index 33e42c5..0b49593 100644 --- a/MESWebSite/HttpHandlers/Bom_MKHandler.ashx.cs +++ b/MESWebSite/HttpHandlers/Bom_MKHandler.ashx.cs @@ -2,8 +2,11 @@ using MESClassLibrary.BLL.BasicInfo; using MESClassLibrary.EFModel; using MESWebSite.CommonClass; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Web; @@ -37,7 +40,10 @@ namespace MESWebSite.HttpHandlers case "DelInfo": DelInfo(); break; - + case "QueryExcel": + QueryExcel(); + break; + default: break; @@ -58,7 +64,7 @@ namespace MESWebSite.HttpHandlers string pagesize = Request.Params["rows"]; string partNo1 = Request.Params["PartNo1"]; string partNo2 = Request.Params["PartNo2"]; - string placeName = Request.Params["PlaceName"]; + string lineName = Request.Params["LineName"]; if (string.IsNullOrEmpty(page)) { @@ -69,7 +75,7 @@ namespace MESWebSite.HttpHandlers pagesize = "15"; } Bom_MKBLL bll = new Bom_MKBLL(); - Response.Write(bll.SearchInfoAll(page, pagesize, partNo1, partNo2, placeName)); + Response.Write(bll.SearchInfoAll(page, pagesize, partNo1, partNo2, lineName)); Response.End(); @@ -82,9 +88,37 @@ namespace MESWebSite.HttpHandlers string IsChecked = Request.Params["IsChecked"]; string IsPartAssemble = Request.Params["IsPartAssemble"]; string StationNo = Request.Params["StationNo"]; - string PlaceName = Request.Params["PlaceName"]; + string LineName = Request.Params["LineName"]; + string LeftCount = Request.Params["LeftCount"]; + string RightCount = Request.Params["RightCount"]; + string ProductName1 = Request.Params["ProductName1"]; + string ProductName2 = Request.Params["ProductName2"]; + + if(string.IsNullOrEmpty(LeftCount)) + { + LeftCount = "0"; + } + if (string.IsNullOrEmpty(RightCount)) + { + RightCount = "0"; + } + string lineName = ""; + BasicBLL lineNameDB = new BasicBLL(); + var lineNameList = lineNameDB.Search(p => p.LineName == LineName); + if (lineNameList != null && lineNameList.Count > 0) + { + lineName = lineNameList[0].LineName; + } + + if (string.IsNullOrEmpty(lineName)) + { + Response.Write(ResponseResult.Fail("产线不存在!")); + Response.End(); + return; + } + string stationNo = ""; BasicBLL stationDB = new BasicBLL(); var stationList = stationDB.Search(p => p.StationNo == StationNo); @@ -100,14 +134,57 @@ namespace MESWebSite.HttpHandlers return; } + //一个总成对应一个半成品 + BasicBLL partAssembleNum = new BasicBLL(); + int id_mk = int.Parse(BomID); + var partAssembleList = partAssembleNum.Search(p => p.PartNo1 == PartNo1 && p.IsPartAssemble == 1 && p.BomID != id_mk); + if (partAssembleList != null && partAssembleList.Count == 1 && IsPartAssemble == "1") + { + Response.Write(ResponseResult.Fail("一个总成只能配置一个半成品!")); + Response.End(); + return; + } + + //查询产品描述 + BasicBLL productDesc = new BasicBLL(); + var productDescList = productDesc.Search(p => p.PartNo == PartNo1); + if (productDescList != null && productDescList.Count >= 1 ) + { + ProductName1 = productDescList[0].ProductName; + } + else + { + Response.Write(ResponseResult.Fail("总成零件号:" + PartNo1 +" 产品信息不存在")); + Response.End(); + return; + } + + productDescList = productDesc.Search(p => p.PartNo == PartNo2); + if (productDescList != null && productDescList.Count >= 1) + { + ProductName2 = productDescList[0].ProductName; + } + else + { + Response.Write(ResponseResult.Fail("子零件号:" + PartNo2 + " 产品信息不存在")); + Response.End(); + return; + } + + Bom_MKBLL bll = new Bom_MKBLL(); tb_Bom_MK md = new tb_Bom_MK(); md.PartNo1 = PartNo1; md.PartNo2 = PartNo2; - md.PlaceName = PlaceName; + md.LineName = LineName; md.StationNo = StationNo; - if(IsPartAssemble == "1") + md.LeftCount = int.Parse(LeftCount); + md.RightCount = int.Parse(RightCount); + md.PartDesc1 = ProductName1; + md.PartDesc2 = ProductName2; + + if (IsPartAssemble == "1") { md.IsPartAssemble = 1; } @@ -129,6 +206,15 @@ namespace MESWebSite.HttpHandlers if (BomID == "0") { + BasicBLL partNoBindDB = new BasicBLL(); + var partNo1List = partNoBindDB.Search(p => p.PartNo1 == PartNo1 && p.PartNo2 == PartNo2 && p.LineName == LineName && p.StationNo == StationNo); + if (partNo1List != null && partNo1List.Count > 0) + { + Response.Write(ResponseResult.Fail("BOM总成零件号与子零件号绑定关系在系统中已存在")); + Response.End(); + return; + } + //新增 //md.BomID = Guid.NewGuid().ToString(); Response.Write(bll.AddInfo(md) == true ? ResponseResult.Success() : ResponseResult.Fail("添加失败")); @@ -158,5 +244,37 @@ namespace MESWebSite.HttpHandlers } + void QueryExcel() + { + string PartNo1 = Request.Params["PartNo1"]; + string LineName = Request.Params["LineName"]; + + Bom_MKBLL bll = new Bom_MKBLL(); + + List> list = bll.SearchForExcel(PartNo1, LineName); + XSSFWorkbook book = new XSSFWorkbook(); + ISheet sheet = book.CreateSheet("Sheet1"); + + for (int i = 0; i < list.Count; i++) + { + IRow row = sheet.CreateRow(i); + + for (int k = 0; k < list[i].Count; k++) + { + row.CreateCell(k).SetCellValue(list[i][k].ToString()); + } + + } + + // 写入到客户端 + MemoryStream ms = new MemoryStream(); + book.Write(ms); + Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmssfff"))); + Response.BinaryWrite(ms.ToArray()); + book = null; + ms.Close(); + ms.Dispose(); + } + } } \ No newline at end of file diff --git a/MESWebSite/HttpHandlers/ConfigHandler.ashx b/MESWebSite/HttpHandlers/ConfigHandler.ashx new file mode 100644 index 0000000..210020a --- /dev/null +++ b/MESWebSite/HttpHandlers/ConfigHandler.ashx @@ -0,0 +1 @@ +<%@ WebHandler Language="C#" CodeBehind="ConfigHandler.ashx.cs" Class="MESWebSite.HttpHandlers.ConfigHandler" %> diff --git a/MESWebSite/HttpHandlers/ConfigHandler.ashx.cs b/MESWebSite/HttpHandlers/ConfigHandler.ashx.cs new file mode 100644 index 0000000..519f5f3 --- /dev/null +++ b/MESWebSite/HttpHandlers/ConfigHandler.ashx.cs @@ -0,0 +1,132 @@ +using MESClassLibrary.BLL.BasicInfo; +using MESClassLibrary.EFModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace MESWebSite.HttpHandlers +{ + /// + /// ConfigHandler 的摘要说明 + /// + public class ConfigHandler : IHttpHandler + { + + HttpRequest Request = null; + HttpResponse Response = null; + + public void ProcessRequest(HttpContext context) + { + context.Response.ContentType = "text/plain"; + Request = context.Request; + Response = context.Response; + + string method = Request.Params["method"]; + switch (method) + { + + case "QueryList": + QueryList(); + break; + case "SaveInfo": + SaveInfo(); + break; + case "DelInfo": + DelInfo(); + break; + case "QueryForCombobox": + QueryForCombobox(); + break; + default: + break; + + } + + } + public bool IsReusable + { + get + { + return false; + } + } + + void QueryList() + { + string page = Request.Params["page"]; + string pagesize = Request.Params["rows"]; + string name = Request.Params["name"]; + + if (string.IsNullOrEmpty(page)) + { + page = "0"; + } + if (string.IsNullOrEmpty(pagesize)) + { + pagesize = "15"; + } + ConfigBLL bll = new ConfigBLL(); + Response.Write(bll.SearchInfo(page, pagesize, name)); + Response.End(); + + + } + void SaveInfo() + { + string ID = Request.Params["ID"]; + string name = Request.Params["name"]; + string value = Request.Params["value"]; + string des = Request.Params["des"]; + + ConfigBLL bll = new ConfigBLL(); + tb_Config md = new tb_Config(); + + //md.name = name; + if(value != "true" && value != "false") + { + Response.Write("false"); + Response.End(); + return; + } + md.value = value; + //md.des = des; + + + + if (ID == "0") + { + //新增 + md.ID = Guid.NewGuid().ToString(); + Response.Write(bll.AddInfo(md) == true ? "true" : "false"); + } + else + { + //修改 + md.ID = ID; + Response.Write(bll.UpdateInfo(md) == true ? "true" : "false"); + } + Response.End(); + } + void DelInfo() + { + string ID = Request.Params["ID"]; + + ConfigBLL bll = new ConfigBLL(); + tb_Config md = new tb_Config(); + + md.ID = ID; + //Response.Write(bll.DelInfo(md) == true ? "true" : "false"); + Response.Write("false"); + Response.End(); + + } + void QueryForCombobox() + { + PlaceBLL bll = new PlaceBLL(); + Response.Write(bll.GetComboboxData()); + Response.End(); + + } + } +} \ No newline at end of file diff --git a/MESWebSite/HttpHandlers/StationHandler.ashx.cs b/MESWebSite/HttpHandlers/StationHandler.ashx.cs index fdcedcb..e873782 100644 --- a/MESWebSite/HttpHandlers/StationHandler.ashx.cs +++ b/MESWebSite/HttpHandlers/StationHandler.ashx.cs @@ -41,6 +41,9 @@ namespace MESWebSite.HttpHandlers case "QueryForComboboxByLineID": QueryForComboboxByLineID(); break; + case "QueryForComboboxByLineIDNew": + QueryForComboboxByLineIDNew(); + break; default: break; @@ -147,5 +150,16 @@ namespace MESWebSite.HttpHandlers Response.End(); } + + void QueryForComboboxByLineIDNew() + { + string LineID = Request.Params["LineID"]; + + StationBLL bll = new StationBLL(); + Response.Write(bll.GetComboboxDataByLine(LineID)); + Response.End(); + + } + } } \ No newline at end of file diff --git a/MESWebSite/HttpHandlers/ZP_MK_PlanHandler.ashx.cs b/MESWebSite/HttpHandlers/ZP_MK_PlanHandler.ashx.cs index 2ddeb73..589c248 100644 --- a/MESWebSite/HttpHandlers/ZP_MK_PlanHandler.ashx.cs +++ b/MESWebSite/HttpHandlers/ZP_MK_PlanHandler.ashx.cs @@ -40,11 +40,12 @@ namespace MESWebSite.HttpHandlers string StartTime = GetParam("StartTime"); string EndTime = GetParam("EndTime"); string PartNo = GetParam("PartNo"); + string State = GetParam("State"); int page = Page.To32Int(); int pageSize = Rows.To32Int(); ZP_MK_PlanBLL bll = new ZP_MK_PlanBLL(); - string reslut = bll.SearchInfoAll(page, pageSize, StartTime, EndTime, PartNo); + string reslut = bll.SearchInfoAll(page, pageSize, StartTime, EndTime, PartNo, State); Response.Write(reslut); Response.End(); } @@ -117,7 +118,7 @@ namespace MESWebSite.HttpHandlers tb_ZP_MK_Plan zpp = new tb_ZP_MK_Plan { - + ID = int.Parse(id), PartNo = partNo, OrderDate = orderDate, OrderCount = orderCount, @@ -126,17 +127,7 @@ namespace MESWebSite.HttpHandlers Station = station, }; - - //DataTable dt = bll.SearchOrderNo(DateTime.Now.ToString("yyyMMdd")); - //if (dt != null && dt.Rows.Count > 0) - //{ - // string old = dt.Rows[0]["OrderNo"].ToString(); - // zpp.OrderNo = DateTime.Now.ToString("yyyMMdd") + (Convert.ToInt32(old.Substring(old.Length - 4, 4))+1).ToString().PadLeft(4,'0'); - //} - //else - //{ - // zpp.OrderNo = DateTime.Now.ToString("yyyMMdd") + "0001"; - //} + if (id == "0") { diff --git a/MESWebSite/MESWebSite.csproj b/MESWebSite/MESWebSite.csproj index ccaf66e..86a2684 100644 --- a/MESWebSite/MESWebSite.csproj +++ b/MESWebSite/MESWebSite.csproj @@ -121,6 +121,7 @@ + @@ -840,6 +841,8 @@ + + @@ -1094,6 +1097,9 @@ BucketStateHandler.ashx + + ConfigHandler.ashx + XDProductHandler.ashx @@ -1363,6 +1369,13 @@ BucketState.aspx + + Config.aspx + ASPXCodeBehind + + + Config.aspx + XDStockArea.aspx ASPXCodeBehind diff --git a/MESWebSite/MESWebSite.csproj.user b/MESWebSite/MESWebSite.csproj.user index ced2bb3..9b19fce 100644 --- a/MESWebSite/MESWebSite.csproj.user +++ b/MESWebSite/MESWebSite.csproj.user @@ -1,7 +1,7 @@ - + - D:\Project\2、北汽模塑一厂\SVN\Code\MESWebSite\Properties\PublishProfiles\BBMPT1.pubxml + D:\job\BBMPT1\MESWebSite\Properties\PublishProfiles\FolderProfile.pubxml ProjectFiles Debug|Any CPU true diff --git a/MESWebSite/Manage/Bom_MK.aspx b/MESWebSite/Manage/Bom_MK.aspx index 6cdda30..637c35d 100644 --- a/MESWebSite/Manage/Bom_MK.aspx +++ b/MESWebSite/Manage/Bom_MK.aspx @@ -49,7 +49,7 @@ } } - 门槛BOM信息 + 装配BOM信息
@@ -60,12 +60,12 @@ BOM信息 - 注塑件零件号: + 总成零件号: - 塑料粒子零件号: + 子零件号: - 地点: - + 产线: + 查询 @@ -77,6 +77,12 @@ 删除 + + 导出 + + + 导入 + @@ -88,7 +94,7 @@

- 注塑件(零件号): + 总成零件号:

@@ -100,7 +106,7 @@

- 塑料粒子(零件号): + 子零件号:

@@ -130,6 +136,18 @@ + + +

+ 产线: +

+ + + * + +

@@ -137,19 +155,33 @@

- * - + * +

- 地点: + 左侧数量:

- * + + + +

+ 右侧数量: +

+ + + + + + + @@ -160,6 +192,34 @@ + + + + + + +
diff --git a/MESWebSite/Manage/Bom_MK.aspx.cs b/MESWebSite/Manage/Bom_MK.aspx.cs index 9d22bf4..aa01a3a 100644 --- a/MESWebSite/Manage/Bom_MK.aspx.cs +++ b/MESWebSite/Manage/Bom_MK.aspx.cs @@ -1,9 +1,17 @@ -using System; +using MESClassLibrary.BLL.BasicInfo; +using MESClassLibrary.BLL.Log; +using MESClassLibrary.EFModel; +using System; using System.Collections.Generic; +using System.Data.OleDb; +using System.Data; using System.Linq; +using System.Reflection; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using System.IO; +using MESClassLibrary.BLL; namespace MESWebSite.Manage { @@ -16,5 +24,263 @@ namespace MESWebSite.Manage Response.Write(""); } } + + + protected void ImportExcel_Click(object sender, EventArgs e) + { + try + { + if (input01.PostedFile.ContentLength > 0) + { + string strUrl = "../Excel/"; + if (Directory.Exists(Server.MapPath(strUrl)) == false) + { + Directory.CreateDirectory(Server.MapPath(strUrl)); + } + String fileExtension = System.IO.Path.GetExtension(input01.PostedFile.FileName).ToLower(); + String fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + fileExtension; + input01.PostedFile.SaveAs(Server.MapPath(strUrl) + fileName); + string excelPath = Server.MapPath(strUrl) + fileName; + DataTable dt = null; + + #region 校验文件 + + try + { + dt = GetExcelTableByOleDB(excelPath, "Sheet1"); + if (dt != null && dt.Rows.Count > 1) + { + + } + else + { + ClientScript.RegisterStartupScript(this.GetType(), "tishi", ""); + return; + } + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return; + } + + #endregion + + Bom_MKBLL bll = new Bom_MKBLL(); + List list = new List(); + tb_Bom_MK md = new tb_Bom_MK(); + + ProductBLL pbll = new ProductBLL(); + LineBLL linebll = new LineBLL(); + StationBLL stationbll = new StationBLL(); + BasicBLL partNoBindDB = new BasicBLL(); + + + #region 校验数据 + + if (dt != null && dt.Rows.Count > 0) + { + for (int i = 1; i < dt.Rows.Count; i++) + { + #region 值校验 + + string PartNo1 = dt.Rows[i][0].ToString(); + if (PartNo1 == "") + { + ClientScript.RegisterStartupScript(this.GetType(), "tishi", ""); + return; + } + string PartNo2 = dt.Rows[i][1].ToString(); + if (PartNo2 == "") + { + ClientScript.RegisterStartupScript(this.GetType(), "tishi", ""); + return; + } + + string LineName = dt.Rows[i][2].ToString(); + if (LineName == "") + { + ClientScript.RegisterStartupScript(this.GetType(), "tishi", ""); + return; + } + + string StationNo = dt.Rows[i][3].ToString(); + if (StationNo == "") + { + ClientScript.RegisterStartupScript(this.GetType(), "tishi", ""); + return; + } + + string LeftCount = dt.Rows[i][4].ToString(); + if (LeftCount == "") + { + ClientScript.RegisterStartupScript(this.GetType(), "tishi", ""); + return; + } + + string RightCount = dt.Rows[i][5].ToString(); + if (RightCount == "") + { + ClientScript.RegisterStartupScript(this.GetType(), "tishi", ""); + return; + } + + #endregion + + #region 逻辑校验 + + if (!pbll.IsExist(PartNo1)) + { + ClientScript.RegisterStartupScript(this.GetType(), "提示", ""); + return; + } + + if (!pbll.IsExist(PartNo2)) + { + ClientScript.RegisterStartupScript(this.GetType(), "提示", ""); + return; + } + + if (!linebll.IsExist(LineName)) + { + ClientScript.RegisterStartupScript(this.GetType(), "提示", ""); + return; + } + + if (!stationbll.IsExist(StationNo)) + { + ClientScript.RegisterStartupScript(this.GetType(), "提示", ""); + return; + } + + var partNo1List = partNoBindDB.Search(p => p.PartNo1 == PartNo1 && p.PartNo2 == PartNo2 && p.LineName == LineName && p.StationNo == StationNo); + if (partNo1List != null && partNo1List.Count > 0) + { + ClientScript.RegisterStartupScript(this.GetType(), "提示", ""); + return; + } + + #endregion + + var info = Request.Cookies.Get("LoginUserInfo"); + if (info != null) + { + md.UserID = info["UserID"].ToUpper(); + } + + + md.PartNo1 = PartNo1; + md.PartNo2 = PartNo2; + md.LineName = LineName; + md.StationNo = StationNo; + md.LeftCount = int.Parse(LeftCount); + md.RightCount = int.Parse(RightCount); + + list.Add(md); + } + } + + #endregion + + #region 存储数据 + + try + { + bool flag = false; + if (list.Count > 0) + { + foreach (var item in list) + { + flag = bll.AddInfo(item); + } + } + if (flag == true) + { + ClientScript.RegisterStartupScript(this.GetType(), "提示", ""); + } + else + { + ClientScript.RegisterStartupScript(this.GetType(), "提示", ""); + } + + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + } + + #endregion + } + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + } + } + + public DataTable GetExcelTableByOleDB(string strExcelPath, string tableName) + { + OleDbConnection objConn = null; + try + { + DataTable dtExcel = new DataTable(); + //数据表 + DataSet ds = new DataSet(); + //获取文件扩展名 + string strExtension = System.IO.Path.GetExtension(strExcelPath); + string strFileName = System.IO.Path.GetFileName(strExcelPath); + //Excel的连接 + + switch (strExtension) + { + case ".xls": + objConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strExcelPath + ";" + "Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1;\""); + break; + case ".xlsx": + objConn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strExcelPath + ";" + "Extended Properties=\"Excel 12.0;HDR=NO;IMEX=1;\""); + break; + + default: + objConn = null; + break; + } + if (objConn == null) + { + return null; + } + try + { + objConn.Open(); + } + catch (Exception ex) + { + + } + + //获取Excel中所有Sheet表的信息 + //System.Data.DataTable schemaTable = objConn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null); + //获取Excel的第一个Sheet表名 + //string tableName = schemaTable.Rows[0][2].ToString().Trim(); + string strSql = "select * from [" + tableName + "$]"; + //获取Excel指定Sheet表中的信息 + OleDbCommand objCmd = new OleDbCommand(strSql, objConn); + OleDbDataAdapter myData = new OleDbDataAdapter(strSql, objConn); + myData.Fill(ds, tableName);//填充数据 + objConn.Close(); + //dtExcel即为excel文件中指定表中存储的信息 + dtExcel = ds.Tables[tableName]; + return dtExcel; + } + catch (Exception ex) + { + if (objConn != null) + { + objConn.Close(); + } + + return null; + } + } + } } \ No newline at end of file diff --git a/MESWebSite/Manage/Bom_MK.aspx.designer.cs b/MESWebSite/Manage/Bom_MK.aspx.designer.cs index 427fc22..b8f0584 100644 --- a/MESWebSite/Manage/Bom_MK.aspx.designer.cs +++ b/MESWebSite/Manage/Bom_MK.aspx.designer.cs @@ -23,6 +23,24 @@ namespace MESWebSite.Manage /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; + /// + /// ProductName1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlInputText ProductName1; + + /// + /// ProductName2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlInputText ProductName2; + /// /// lblMessage 控件。 /// @@ -32,6 +50,42 @@ namespace MESWebSite.Manage /// protected global::System.Web.UI.WebControls.Label lblMessage; + /// + /// Label1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label Label1; + + /// + /// Label2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label Label2; + + /// + /// ImportExcel 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Button ImportExcel; + + /// + /// input01 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlInputFile input01; + /// /// UserID 控件。 /// diff --git a/MESWebSite/Manage/Config.aspx b/MESWebSite/Manage/Config.aspx new file mode 100644 index 0000000..7c9174a --- /dev/null +++ b/MESWebSite/Manage/Config.aspx @@ -0,0 +1,354 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Config.aspx.cs" Inherits="MESWebSite.Manage.Config" %> + + + + + + + + + + + + + + + + 配置信息 + + +
+
+ + + + + + + + + + + + +
配置信息 + 配置项: + 查询 + 新增 + + 编辑 + + 删除 +
+
+ +
+ + + + + + + + +
+ + diff --git a/MESWebSite/Manage/Config.aspx.cs b/MESWebSite/Manage/Config.aspx.cs new file mode 100644 index 0000000..d8112ab --- /dev/null +++ b/MESWebSite/Manage/Config.aspx.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace MESWebSite.Manage +{ + public partial class Config : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + if (Request.Cookies["LoginUserInfo"] == null) + { + Response.Write(""); + } + } + } +} \ No newline at end of file diff --git a/MESWebSite/Manage/Config.aspx.designer.cs b/MESWebSite/Manage/Config.aspx.designer.cs new file mode 100644 index 0000000..e69bb7c --- /dev/null +++ b/MESWebSite/Manage/Config.aspx.designer.cs @@ -0,0 +1,44 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace MESWebSite.Manage +{ + + + public partial class Config + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// lblMessage 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblMessage; + + /// + /// UserID 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlInputText UserID; + } +} diff --git a/MESWebSite/Manage/ZP_MK_Plan.aspx b/MESWebSite/Manage/ZP_MK_Plan.aspx index 087cff8..7ee663a 100644 --- a/MESWebSite/Manage/ZP_MK_Plan.aspx +++ b/MESWebSite/Manage/ZP_MK_Plan.aspx @@ -57,11 +57,14 @@ - + - + @@ -108,7 +111,7 @@ @@ -129,7 +132,9 @@

@@ -139,7 +144,9 @@

@@ -155,7 +162,7 @@
门槛装配计划 零件号: 装配日期: + 状态: + + 装配时间:
- + *
- + *

- 装配日期: + 装配时间:

@@ -188,6 +195,7 @@ }); // 下拉框加载 + reloadline_station(); //reload_station_no('#station_no'); reload_part_no('#part_no'); //新增按钮点击 @@ -285,6 +293,24 @@ return getTime(unixtime).substring(0, 19); } }, + { + field: 'State', title: '状态', sortable: 'true', width: 10, + formatter: function (value) { + if (value == 0) { + return "新建"; + } + else if (value == 1) { + return "启用"; + } + else if (value == 2) { + return "暂停"; + } + else { + return "完成"; + } + } + }, + ]], @@ -308,14 +334,12 @@ function SaveInfo(isEdit) { var ID = isEdit == true ? PrimaryID : 0; - var PartNo = $('#part_no').combo('getValue'); - //var StationID = $('#station_no').combo('getValue'); - var OrderDate = $('#OrderDate').datebox('getValue'); - //var IsOneMore = checkboxValue($('#IsOneMore')); + var PartNo = $('#part_no').combo('getValue'); + var OrderDate = $('#OrderDate').datebox('getValue'); var OrderCount = $('#OrderCount').val(); var OrderName = $('#OrderName').val(); - var Line = $('#Line').val(); - var Station = $('#Station').val(); + var Line = $('#line_id').combo('getText'); + var Station = $('#station_id').combo('getText'); if (PartNo == "") { $.messager.alert('提示', '零件不能为空,请重新输入', 'warning'); @@ -381,12 +405,14 @@ function SearchInfo() { var PartNo = $('#part_no_s').val(); + var State = $('#state_s').val(); var StartTime = $('#start_time').datebox('getValue'); var EndTime = $('#end_time').datebox('getValue'); dg.datagrid({ queryParams: { PartNo, + State, StartTime, EndTime } @@ -413,8 +439,8 @@ //toggleChecked('#IsOneMore', row.IsOneMore); $('#OrderCount').val(row.OrderCount); $('#OrderName').val(row.OrderName); - $('#Line').val(row.Line); - $('#Station').val(row.Station); + $('#line_id').combobox('select', row.Line); + $('#station_id').combobox('select', row.Station); var pa = /.*\((.*)\)/; var unixtime = row.OrderDate.match(pa)[1].substring(0, 10); $('#OrderDate').datetimebox('setValue', getTime(unixtime).substring(0, 19)); @@ -467,8 +493,8 @@ $('#OrderDate').datebox('setValue', ''); $('#OrderCount').val(''); $('#OrderName').val(''); - $('#Line').val(''); - $('#Station').val(''); + $('#line_id').combo('clear'); + $('#station_id').combo('clear'); } function toggleChecked(id, checked) { @@ -482,7 +508,7 @@ * 加载产品下拉信息 **/ function reload_part_no(ctl) { - base_reload_combobox(ctl, '/HttpHandlers/ProductHandler.ashx?method=GetComboboxProduct4'); + base_reload_combobox(ctl, '/HttpHandlers/ProductHandler.ashx?method=QueryForCombobox&ProductTypeNo=6000'); } function reload_station_no(ctl) { @@ -507,6 +533,27 @@ document.body.appendChild(temp_form); temp_form.submit(); } + + function reloadline_station() { + + $('#line_id').combobox({ + url: '/HttpHandlers/LineHandler.ashx?method=QueryForCombobox', + onLoadSuccess: function () { + var val = $(this).combobox('getData'); + $(this).combobox('select', val[0].LineID); + }, + onSelect: function (row) { + $('#station_id').combobox({ + url: '/HttpHandlers/StationHandler.ashx?method=QueryForComboboxByLineIDNew&&LineID=' + row.LineID + '', + onLoadSuccess: function () { + //var val = $(this).combobox('getData'); + //$(this).combobox('select', val[0].ID); + }, + + }); + } + }); + } diff --git a/MESWebSite/Properties/PublishProfiles/FolderProfile.pubxml b/MESWebSite/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..0246c1b --- /dev/null +++ b/MESWebSite/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,17 @@ + + + + + false + false + true + Release + Any CPU + FileSystem + D:\发布\Mes + FileSystem + <_TargetId>Folder + + \ No newline at end of file diff --git a/WebService/AppWebservice.asmx.cs b/WebService/AppWebservice.asmx.cs index 071dd5c..9487064 100644 --- a/WebService/AppWebservice.asmx.cs +++ b/WebService/AppWebservice.asmx.cs @@ -1,6 +1,9 @@ using System.Collections.Generic; using System.Data; +using System.Linq; using System.Reflection; +using System.Runtime.Remoting.Contexts; +using System.Text; using System.Web.Script.Services; using System.Web.Services; using Tools; @@ -25,6 +28,188 @@ namespace Webservice return "Hello World"; } + + /// + /// 箱码与总成码关系绑定 + /// + /// + /// + /// + /// + [WebMethod] + [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] + public void BindBoxCodeAndBarCode(string app_id, string boxCode, string barCode, string sign) + { + string errorReason = ""; + + JsonModel model = new JsonModel(); + model.Result = "0"; + model.ResultType = "Result"; + model.ResultRowsCount = "0"; + model.ErrReason = errorReason; + model.DataList = null; + + LogHelper.WriteSysLogBase("箱码与总成码关系绑定,入参boxCode=" + boxCode + ",barCode=" + barCode, MethodBase.GetCurrentMethod().Name); + Context.Response.ContentType = "application/json; charset=utf-8"; + + #region 参数判断 + //if (string.IsNullOrWhiteSpace(app_id)) + //{ + // model.ErrReason = "缺少必要传入参数 app_id"; + // Context.Response.Write(JSONTools.ScriptSerialize>(model)); + // return; + //} + if (string.IsNullOrWhiteSpace(boxCode)) + { + model.ErrReason = "缺少必要传入参数 boxCode"; + Context.Response.Write(JSONTools.ScriptSerialize>(model)); + return; + } + //箱码格式验证 + var boxCodeList = boxCode.Split(';'); + if (!boxCode.Contains("PN") || !boxCode.Contains("PKG") || !boxCode.Contains("QTY") || boxCodeList.Length != 7 || boxCodeList[0].Length != 16 || boxCodeList[1].Length != 12 || boxCodeList[5].Length != 16) + { + model.ErrReason = "箱码标签格式不对"; + Context.Response.Write(JSONTools.ScriptSerialize>(model)); + return; + } + //if (string.IsNullOrWhiteSpace(barCode)) + //{ + // model.ErrReason = "缺少必要传入参数 barCode"; + // Context.Response.Write(JSONTools.ScriptSerialize>(model)); + // return; + //} + //if (string.IsNullOrWhiteSpace(sign)) + //{ + // model.ErrReason = "缺少必要传入参数 sign"; + // Context.Response.Write(JSONTools.ScriptSerialize>(model)); + // return; + //} + //bool access = Function.AppIDIsRight(app_id.Trim()); + //if (!access) + //{ + // model.ErrReason = "APP接口调用标识不正确 远程服务器拒绝了此次连接请求"; + // Context.Response.Write(JSONTools.ScriptSerialize>(model)); + // return; + //} + //string[] param = { Function.app_secret.Trim(), boxCode.Trim(), barCode.Trim() }; + //bool paramIsRight = Function.signIsRight(param, sign); + //if (!paramIsRight) + //{ + // model.ErrReason = "sign参数传输错误 远程服务器拒绝了此次连接请求"; + // Context.Response.Write(JSONTools.ScriptSerialize>(model)); + // return; + //} + #endregion + + string errorReasonBoxData = ""; + DataTable dt = Function.GetCodeRecords(boxCode, out errorReasonBoxData); + List listInfo = new List(); + + if (dt.Rows.Count < 1) + { + + model.ResultRowsCount = "0"; + model.DataList = null; + if (string.IsNullOrEmpty(errorReasonBoxData)) + { + model.Result = "1"; + model.ErrReason = ""; + } + else + { + model.Result = "0"; + model.ErrReason = errorReasonBoxData; + } + } + else + { + listInfo = Tools.DataTableToList.ConvertTo(dt); + model.ResultRowsCount = listInfo.Count.ToString(); + model.DataList = listInfo; + } + if(!string.IsNullOrEmpty(barCode)) + { + #region 数据合法性判断 + //总成码格式验证 + var barCodeList = barCode.Split(';'); + if (!barCode.Contains("S104") || !barCode.Contains(".") || barCodeList[0].Length != 17 || barCodeList[1].Length != 4 || barCodeList[2].Length != 4) + { + model.Result = "0"; + model.ErrReason = "总成条码格式不对或不存在"; + Context.Response.Write(JSONTools.ScriptSerialize>(model)); + return; + } + + //箱码和总成码零件验证 + string boxPartNo = boxCodeList[0].Substring(3,10); + string barCodePartNo = barCodeList[0].Substring(0, 10); + if(boxPartNo != barCodePartNo) + { + model.Result = "0"; + model.ErrReason = "箱码和总成条码零件号不符"; + Context.Response.Write(JSONTools.ScriptSerialize>(model)); + return; + } + + + + #endregion + + int updateNum = Function.BindBoxCodeAndBarCode(boxCode, barCode, out errorReason); + + dt = Function.GetCodeRecords(boxCode, out errorReasonBoxData); + + if (dt.Rows.Count < 1) + { + + model.ResultRowsCount = "0"; + model.DataList = null; + if (string.IsNullOrEmpty(errorReasonBoxData)) + { + model.Result = "1"; + model.ErrReason = ""; + } + else + { + model.Result = "0"; + model.ErrReason = errorReasonBoxData; + } + } + else + { + + listInfo = Tools.DataTableToList.ConvertTo(dt); + model.ResultRowsCount = listInfo.Count.ToString(); + model.DataList = listInfo; + } + + if (!string.IsNullOrEmpty(errorReason) && !string.IsNullOrEmpty(barCode)) + { + model.Result = "0"; + model.ErrReason = errorReason; + } + else + { + model.Result = "1"; + string qtyValue = "0"; + var boxCodeSplit = boxCode.Split(';'); + foreach (string part in boxCodeSplit) + { + if (part.StartsWith("QTY:")) + { + qtyValue = part.Substring(4); // 从"QTY:"后的字符开始截取 + } + } + if (listInfo.Count.ToString() == qtyValue) + { + + } + } + } + Context.Response.Write(JSONTools.ScriptSerialize>(model)); + } + [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public void MD5Encrypt(string str) diff --git a/WebService/Function.cs b/WebService/Function.cs index 4a330d3..2f759b5 100644 --- a/WebService/Function.cs +++ b/WebService/Function.cs @@ -325,6 +325,126 @@ namespace Webservice } } + /// + /// 获取装箱记录 + /// + /// + /// + /// + public static DataTable GetCodeRecords(string boxCode, out string errorReason) + { + DataTable res = new DataTable(); + try + { + string sql = @" + select * from tb_Punch_Code_Record where BoxCode = '" + boxCode + @"' order by CreateTime desc + "; + res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + + errorReason = ""; + return res; + } + catch (Exception ex) + { + LogHelper.WriteLogManager(ex); + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + errorReason = ex.Message; + return res; + } + } + + /// + /// 箱码和总成码绑定 + /// + /// + /// + /// + /// + public static int BindBoxCodeAndBarCode(string boxCode, string barCode, out string errorReason) + { + int updateNum = 0; + string qtyValue = "0"; + try + { + errorReason = ""; + var boxCodeSplit = boxCode.Split(';'); + foreach (string part in boxCodeSplit) + { + if (part.StartsWith("QTY:")) + { + qtyValue = part.Substring(4); // 从"QTY:"后的字符开始截取 + } + } + + DataTable dtBoxNum = GetCodeRecords(boxCode, out errorReason); + if(dtBoxNum != null && dtBoxNum.Rows.Count.ToString() == qtyValue) + { + errorReason = "扫描总数超出箱码限制数量"; + return updateNum; + } + + + + string sql = @" + select top 1 * from tb_Punch_Code_Record where Flag=1 and ZcBarCode = '" + barCode + @"' order by CreateTime desc + "; + DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + if (dt != null && dt.Rows.Count > 0) + { + string id = dt.Rows[0]["ID"].ToString(); + string barcode = dt.Rows[0]["barcode"].ToString(); + string zcBarCode = dt.Rows[0]["ZcBarCode"].ToString(); + string boxCodeDB = dt.Rows[0]["BoxCode"].ToString(); + if(string.IsNullOrEmpty(boxCodeDB)) + { + string updateSql = @" update [dbo].[tb_Punch_Code_Record] set BoxCode='" + boxCode + "',pkg='"+qtyValue+"' where ID='" + id + "'"; + updateNum = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, updateSql, null); + if (updateNum == 0) + { + errorReason = "总成条码装箱失败"; + } + else + { + string insertSql = @" + insert into tb_Punch_Interface(PackageCode,OneBarCode) + values('" + boxCode + "','"+ barCode + @"') + "; + int insertNum = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, insertSql, null); + } + } + else + { + if(boxCode.Trim() == boxCodeDB.Trim()) + { + errorReason = "总成条码已装箱"; + } + else + { + errorReason = "总成条码已被其他箱码装箱"; + } + + } + + } + else + { + errorReason = "总成条码格式不对或不存在"; + } + + return updateNum; + } + catch (Exception ex) + { + LogHelper.WriteLogManager(ex); + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + errorReason = ex.Message; + return updateNum; + } + } + + + + public static DataTable GetMaterialInfo(string drumCode, out string errorReason) { DataTable res = new DataTable(); diff --git a/WebService/Model/MKModel .cs b/WebService/Model/MKModel .cs new file mode 100644 index 0000000..7b5b120 --- /dev/null +++ b/WebService/Model/MKModel .cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace WebService.Model +{ + public class MKModel + { + /// + /// 塑件码 + /// + public string barcode { get; set; } + /// + /// 总成零件号 + /// + public string ZcBarCode { get; set; } + ///// + ///// 订单号 + ///// + //public string OrderNo { get; set; } + ///// + ///// 班次 + ///// + //public string WorkClass { get; set; } + /// + /// 合格标记 + /// + public int Flag { get; set; } + /// + /// 箱码 + /// + public string BoxCode { get; set; } + ///// + ///// 标包 + ///// + //public string PKG { get; set; } + ///// + ///// 创建时间 + ///// + //public DateTime CreateTime { get; set; } + } +} \ No newline at end of file diff --git a/WebService/WebService.csproj b/WebService/WebService.csproj index b40b104..4bc0235 100644 --- a/WebService/WebService.csproj +++ b/WebService/WebService.csproj @@ -122,6 +122,7 @@ + diff --git a/WebService/WebService.csproj.user b/WebService/WebService.csproj.user index e32f45c..1f24385 100644 --- a/WebService/WebService.csproj.user +++ b/WebService/WebService.csproj.user @@ -1,4 +1,4 @@ - + Debug|Any CPU @@ -15,7 +15,7 @@ - WMSWebService.asmx + AppWebservice.asmx SpecificPage True False