/// <summary> /// 更新任务(任务号区间查询) /// </summary> /// <param name="startNum">起始任务号</param> /// <param name="endNum">结束任务号</param> /// <param name="status"></param> public static int UpdateTask(decimal startNum, decimal endNum, decimal status) { using (DZEntities en = new DZEntities()) { var query = en.T_UN_POKE.Where(item => item.SORTNUM >= startNum && item.SORTNUM <= endNum).ToList(); foreach (var item in query) { item.STATUS = status; } en.SaveChanges(); var queryTask = en.T_UN_TASK.Where(item => item.SORTNUM >= startNum && item.SORTNUM <= endNum).ToList(); foreach (var item in queryTask) { if (status == 20) { item.STATE = "30"; item.FINISHTIME = DateTime.Now; } else { item.STATE = "15"; } } int rowNum = en.SaveChanges(); return(rowNum); } }
public static void UpdateunTask1(decimal sortnum, int status) { using (DZEntities en = new DZEntities()) { var poke = en.T_UN_POKE.Where(item => item.SORTNUM == sortnum && item.CTYPE == 1).ToList(); foreach (var item in poke) { if (item.STATUS == 15) { item.STATUS = status; } } en.SaveChanges(); var poke2 = en.T_UN_POKE.Where(item => item.SORTNUM == sortnum).ToList(); var taskFirst = poke2.FirstOrDefault(); if (taskFirst != null) { var pokestate = en.T_UN_POKE.Where(item => item.TASKNUM == taskFirst.TASKNUM && (item.STATUS == 15 || item.STATUS == 10)).ToList(); if (pokestate.Count == 0) { var task = en.T_UN_TASK.Where(item => item.TASKNUM == taskFirst.TASKNUM).ToList(); foreach (var item in task) { if (item.STATE == "15") { item.STATE = "30"; item.FINISHTIME = DateTime.Now; } } } } en.SaveChanges(); } }
/// <summary> /// 删除一个通道 /// </summary> /// <returns></returns> public Response RemoveOneTrough(T_PRODUCE_SORTTROUGH tps, bool thDelete = false) { Response re = new Response("删除通道失败:"); try { using (DZEntities en = new DZEntities()) { var res = ValiSingleChannel(tps); if (res.IsSuccess) //如果通道已经启用 { if (thDelete) //如果强制删除 则删除 { en.T_PRODUCE_SORTTROUGH.DeleteObject(tps); if (en.SaveChanges() > 0) { re.IsSuccess = true; re.MessageText = tps.MACHINESEQ + "通道删除成功"; return(re); } else { re.DefaultResponse.MessageText += "数据更新行数为0"; return(re.DefaultResponse); } } else { res.IsSuccess = false; res.MessageText += "通道删除失败!"; return(res); } } else//如果没有启用 则直接删除 { en.T_PRODUCE_SORTTROUGH.DeleteObject(tps); if (en.SaveChanges() > 0) { re.IsSuccess = true; re.MessageText = tps.MACHINESEQ + "通道删除成功"; return(re); } else { return(re.DefaultResponse); } } } } catch (Exception ex) { re.DefaultResponse.MessageText += ex.Message; return(re); } }
public static string UpdateThrough(T_PRODUCE_SORTTROUGH info, string lastCigarettecode) { using (DZEntities en = new DZEntities()) { T_PRODUCE_SORTTROUGH tps = new T_PRODUCE_SORTTROUGH(); tps = en.T_PRODUCE_SORTTROUGH.Where(item => item.ID == info.ID).FirstOrDefault(); tps.CIGARETTECODE = info.CIGARETTECODE; tps.CIGARETTENAME = info.CIGARETTENAME; int rows = en.SaveChanges(); if (rows > 0) { try { SetThroughActcount(info.CIGARETTECODE, info.GROUPNO ?? 0, lastCigarettecode); } catch (Exception ex) { return("分拣通道信息修改失败!" + ex.ToString()); } return("分拣通道信息修改成功!"); } return("分拣通道信息修改失败!"); } }
public static bool UpdateItemInfo(ItemInfo item) { using (DZEntities en = new DZEntities()) { int rows = 0; List <T_WMS_ITEM> list = new List <T_WMS_ITEM>(); list = en.T_WMS_ITEM.Where(it => it.ITEMNO == item.ItemNo && it.ITEMNAME == item.ItemName).ToList(); foreach (var ite in list) { ite.ITEMNAME = item.ItemName; ite.ILENGTH = item.ILength; ite.IWIDTH = item.IWidth; ite.IHEIGHT = item.IHeight; ite.JT_SIZE = item.JT_Size; ite.ROWSTATUS = item.RowStatus; ite.SHIPTYPE = item.Shiptype; ite.BIGBOX_BAR = item.BigBox_Bar; ///gogos rows += en.SaveChanges(); } if (rows > 0) { return(true); } return(false); } }
/// <summary> /// 验证是否有新品牌 /// </summary> /// <returns></returns> public Response ValidNewItem(decimal maxSyncseq) { Response response = new Response(); using (DZEntities dzEntities = new DZEntities()) { //正常使用的品牌信息 var T_WMS_ITEM = (from item in dzEntities.T_WMS_ITEM where item.ROWSTATUS == 10 select new { id = item.ID, itemno = item.ITEMNO, itemname = item.ITEMNAME }).ToList(); //maxSyncseq批次接收的订单信息 var T_WMS_ORDERITEM = (from order in dzEntities.T_PRODUCE_ORDER join line in dzEntities.T_PRODUCE_ORDERLINE on order.BILLCODE equals line.BILLCODE where order.SYNSEQ == maxSyncseq select new { id = line.CIGARETTECODE, itemno = line.CIGARETTECODE, itemname = line.CIGARETTENAME }).ToList();; var newItem = T_WMS_ORDERITEM.Except(T_WMS_ITEM).ToList(); if (newItem.Count() > 0) { decimal count = newItem.Count(); string itemnamestr = ""; foreach (var item in newItem) { var query = (from cig in dzEntities.T_WMS_ITEM where cig.ID == item.id select cig).ToList(); if (query.Count() > 0) { query.FirstOrDefault().ROWSTATUS = 10; query.FirstOrDefault().SHIPTYPE = "2"; } else { T_WMS_ITEM iteminfo = new T_WMS_ITEM(); iteminfo.ID = item.id; iteminfo.ITEMNO = item.itemno; iteminfo.ITEMNAME = item.itemname; iteminfo.SHIPTYPE = "2"; iteminfo.ROWSTATUS = 10; dzEntities.T_WMS_ITEM.AddObject(iteminfo); } int count1 = dzEntities.SaveChanges(); itemnamestr = itemnamestr + "," + item.itemname; } //dzEntities.SaveChanges(); response.IsSuccess = false; response.MessageText = "订单接收发现【" + count + "】个新品牌(" + itemnamestr.Substring(1) + "),请为新品牌完善品牌信息!"; } else { response.IsSuccess = true; response.MessageText = "本次接收暂未发现新品牌!"; } } return(response); }
public static bool UpdateMixTask(decimal sortNum, decimal status) { using (DZEntities en = new DZEntities()) { var query = en.T_UN_POKE.Where(item => item.SORTNUM == sortNum && item.TROUGHNUM.Substring(0, 1) == "1").FirstOrDefault(); query.STATUS = status; return(en.SaveChanges() > 0); } }
public static bool UpdateReplanStatus(string taskNum) { using (DZEntities en = new DZEntities()) { T_PRODUCE_REPLENISHPLAN replan = en.T_PRODUCE_REPLENISHPLAN.Where(item => item.TASKNUM == taskNum).FirstOrDefault(); replan.STATUS = 1; return(en.SaveChanges() > 0); } }
public static bool UpdatePullStatus2Put2(decimal machineSeq, decimal sortnum) { using (DZEntities en = new DZEntities()) { T_UN_POKE_HUNHE th = en.T_UN_POKE_HUNHE.Where(item => item.POKEID == sortnum && item.MACHINESEQ == machineSeq && item.PULLSTATUS == 0).OrderBy(item => item.SORTNUM).FirstOrDefault(); th.PULLSTATUS = 1; return(en.SaveChanges() > 0); } }
public static bool DeleteThroughCigarette(decimal machineseq, string throughnum) { using (DZEntities en = new DZEntities()) { var query = en.T_PRODUCE_SORTTROUGH.Where(item => item.MACHINESEQ == machineseq && item.TROUGHNUM == throughnum && item.STATE == "0").FirstOrDefault(); query.CIGARETTECODE = ""; query.CIGARETTENAME = ""; query.MANTISSA = 0; return(en.SaveChanges() > 0); } }
public static bool UpdateLeftCount(CigarreteLeftCountInfo info, decimal groupNo) { using (DZEntities en = new DZEntities()) { T_PRODUCE_SORTTROUGH infos = new T_PRODUCE_SORTTROUGH(); infos = en.T_PRODUCE_SORTTROUGH.Where(item => item.CIGARETTETYPE == 30 && item.GROUPNO == groupNo && item.STATE == "10" && item.MACHINESEQ == info.MachineSeq).OrderBy(item => item.MACHINESEQ).FirstOrDefault(); infos.MANTISSA = info.Mantissa; infos.THRESHOLD = info.Threshold; return(en.SaveChanges() > 0); } }
public static bool UpdateReplanTask(string tasknum, decimal isCompleted) { using (DZEntities en = new DZEntities()) { var query = en.T_PRODUCE_REPLENISHPLAN.Where(item => item.TASKNUM == tasknum).ToList(); for (int i = 0; i < query.Count; i++) { query[i].ISCOMPLETED = isCompleted; } return(en.SaveChanges() > 0); } }
public static bool UpdateHunhe(decimal sortnum) { using (DZEntities en = new DZEntities()) { try { T_UN_POKE_HUNHE hunhe = en.T_UN_POKE_HUNHE.Where(item => item.SORTNUM == sortnum && item.PULLSTATUS == 1).FirstOrDefault(); hunhe.PULLSTATUS = 2; } catch { return(false); } return(en.SaveChanges() > 0); } }
public static bool UpdatePullStatus2Put3(string cigarettecode, decimal machineSeq, decimal sortnum) { using (DZEntities en = new DZEntities()) { List <T_UN_POKE_HUNHE> th = en.T_UN_POKE_HUNHE.Where(item => item.CIGARETTECODE == cigarettecode && item.SORTNUM == sortnum && item.MACHINESEQ == machineSeq && item.PULLSTATUS == 0).OrderBy(item => item.SORTNUM).ToList(); for (int i = 0; i < th.Count; i++) { th[i].PULLSTATUS = 1; } return(en.SaveChanges() > 0); } }
public static bool UpdateSpecialState(decimal sortnum, decimal pullstatus) { using (DZEntities en = new DZEntities()) { List <T_UN_POKE_HUNHE> hunhe = new List <T_UN_POKE_HUNHE> (); hunhe = en.T_UN_POKE_HUNHE.Where(item => item.SORTNUM == sortnum).ToList(); foreach (var item in hunhe) { item.PULLSTATUS = pullstatus; } return(en.SaveChanges() > 0); } }
public static void RemoveHunhe() { using (DZEntities en = new DZEntities()) { List <T_UN_POKE_HUNHE> list = new List <T_UN_POKE_HUNHE>(); list = en.T_UN_POKE_HUNHE.ToList(); foreach (var item in list) { en.T_UN_POKE_HUNHE.DeleteObject(item); } en.SaveChanges(); } }
public static void GetSortFinish() { using (DZEntities en = new DZEntities()) { T_UN_POKE_HUNHE hunhe = en.T_UN_POKE_HUNHE.Where(item => item.PULLSTATUS == 1).OrderBy(item => item.SORTNUM).FirstOrDefault(); if (hunhe != null) { decimal status = en.T_UN_POKE.Where(item => item.SORTNUM == hunhe.SORTNUM).Select(item => item.STATUS).FirstOrDefault() ?? 0; if (status == 20) { hunhe.PULLSTATUS = 2; en.SaveChanges(); } } } }
public static int SpecialSmokePosition(decimal sortNum) { using (DZEntities en = new DZEntities()) { var query = en.T_UN_POKE.Where(item => item.CTYPE == 1 && item.SORTNUM >= sortNum).ToList(); for (int i = 0; i < query.Count; i++) { query[i].STATUS = 10; } var query2 = en.T_UN_POKE.Where(item => item.CTYPE == 1 && item.SORTNUM < sortNum).ToList(); for (int i = 0; i < query2.Count; i++) { query2[i].STATUS = 20; } return(en.SaveChanges()); } }
public static bool IsCompleted(string taskNum) { using (DZEntities en = new DZEntities()) { var data = en.T_PRODUCE_REPLENISHPLAN.Where(item => item.TASKNUM == taskNum).ToList(); foreach (var item in data) { item.ISCOMPLETED = 15; } int rows = en.SaveChanges(); if (rows > 0) { return(true); } return(false); } }
public static bool UpdateThroughState(ThroughInfo info) { using (DZEntities en = new DZEntities()) { decimal CigType = Convert.ToDecimal(info.CigaretteType); decimal tType = Convert.ToDecimal(info.GroupNo); T_PRODUCE_SORTTROUGH infos = new T_PRODUCE_SORTTROUGH(); infos = en.T_PRODUCE_SORTTROUGH.Where(item => item.ID == info.ID && item.CIGARETTETYPE == CigType && item.GROUPNO == tType).FirstOrDefault(); if (info.State == "禁用") { infos.STATE = "0"; } else { infos.STATE = "10"; } return(en.SaveChanges() > 0 ? true : false); } }
/// <summary> /// 修改一个通道 /// </summary> /// <returns></returns> public Response ChangeOneTrough(T_PRODUCE_SORTTROUGH tps) { Response re = new Response("修改通道失败:"); using (DZEntities en = new DZEntities()) { var date = (from item in en.T_PRODUCE_SORTTROUGH where item.MACHINESEQ == tps.MACHINESEQ select item).ToList(); if (date.Any()) { var singleDate = date.FirstOrDefault(); singleDate.STATE = tps.STATE; singleDate.ACTCOUNT = tps.ACTCOUNT; singleDate.CIGARETTECODE = tps.CIGARETTECODE; singleDate.CIGARETTENAME = tps.CIGARETTENAME; singleDate.CIGARETTETYPE = tps.CIGARETTETYPE; singleDate.GROUPNO = tps.GROUPNO; singleDate.LASTMANTISSA = tps.LASTMANTISSA; singleDate.LINENUM = tps.LINENUM; singleDate.MACHINESEQ = tps.MACHINESEQ; singleDate.MANTISSA = tps.MANTISSA; singleDate.SEQ = tps.SEQ; if (en.SaveChanges() > 0) { re.IsSuccess = true; re.MessageText = "通道修改成功"; return(re); } else { re.IsSuccess = false; re.MessageText = "通道修改失败"; return(re); } } else { re.DefaultResponse.MessageText += "未找到该通道"; return(re); } } }
/// <summary> /// 增加一个通道 /// </summary> /// <returns></returns> public Response AddOneTrough(T_PRODUCE_SORTTROUGH addInfo) { Response re = new Response("增加通道失败:"); try { using (DZEntities en = new DZEntities()) { var res = ValiSingleChannel(addInfo); if (res.IsSuccess) { addInfo.ID = GetId;//自增 涨一个ID en.T_PRODUCE_SORTTROUGH.AddObject(addInfo); if (en.SaveChanges() > 0) { re.IsSuccess = true; re.MessageText = "增加通道成功"; return(re); } else { re.IsSuccess = false; re.MessageText = "增加通道失败!"; return(re); } } else { return(res); } } } catch (Exception ex) { re.MessageText += "\r\n" + ex.Message; return(re); } }
public static int UpdateTask1(decimal packageNo, int status) { using (DZEntities data = new DZEntities()) { long sendSeq = DateTime.Now.Ticks; List <T_UN_POKE> list = new List <T_UN_POKE>(); try { list = data.T_UN_POKE.Where(item => item.SORTNUM == packageNo && item.CTYPE != 1).ToList(); if (list.Count > 0) { foreach (var item in list) { item.STATUS = status; //item.SENDSEQ = sendSeq; } } } catch { return(0); } int row = data.SaveChanges(); return(row); } }
public static bool Completed(string taskNum) { using (DZEntities en = new DZEntities()) { var data = en.T_PRODUCE_REPLENISHPLAN.Where(item => item.TASKNUM == taskNum).ToList(); foreach (var item in data) { item.ISCOMPLETED = 20; item.FINISHTIME = DateTime.Now; } //var task = en.T_UN_TASK.Where(item => item.TASKNUM == Convert.ToDecimal(taskNum)).FirstOrDefault(); //var taskFirst = data.FirstOrDefault(); //if (taskFirst != null) //{ // var pokestate = en.T_PRODUCE_REPLENISHPLAN.Where(item => item.TASKNUM == taskFirst.TASKNUM && (item.STATUS == 15 || item.STATUS == 10)).ToList(); // if (pokestate.Count == 0) // { // var tasks = en.T_UN_TASK.Where(item => item.TASKNUM == Convert.ToDecimal(taskFirst.TASKNUM)).ToList(); // foreach (var item in tasks) // { // if (item.STATE == "15") // { // item.STATE = "30"; // item.FINISHTIME = DateTime.Now; // } // } // } //} int rows = en.SaveChanges(); if (rows > 0) { return(true); } return(false); } }
public static string InsertThrough(T_PRODUCE_SORTTROUGH through) { using (DZEntities en = new DZEntities()) { decimal id = en.T_PRODUCE_SORTTROUGH.Select(item => item.ID).Max(); decimal throughNum = Convert.ToDecimal(en.T_PRODUCE_SORTTROUGH.Where(item => item.GROUPNO == through.GROUPNO).Select(item => item.TROUGHNUM).Max()); decimal seq = en.T_PRODUCE_SORTTROUGH.Where(item => item.GROUPNO == through.GROUPNO).Select(item => item.SEQ).Max() ?? 0; T_PRODUCE_SORTTROUGH tps = new T_PRODUCE_SORTTROUGH(); if (through.MACHINESEQ == 90) { int count = en.T_PRODUCE_SORTTROUGH.Where(item => item.CIGARETTETYPE == 40 && item.GROUPNO == 2 && item.CIGARETTECODE == through.CIGARETTECODE).Count(); if (count != 0) { return("该品牌在混合道中已经存在-" + through.CIGARETTENAME); } tps = new T_PRODUCE_SORTTROUGH() { ID = id + 1, CIGARETTECODE = through.CIGARETTECODE, CIGARETTENAME = through.CIGARETTENAME, CIGARETTETYPE = through.CIGARETTETYPE, GROUPNO = through.GROUPNO, LINENUM = through.LINENUM, MANTISSA = through.MANTISSA, SEQ = through.SEQ, STATE = through.STATE, TROUGHNUM = (throughNum + 1).ToString(), TROUGHTYPE = through.TROUGHTYPE, MACHINESEQ = through.MACHINESEQ, LASTMANTISSA = through.LASTMANTISSA, THRESHOLD = through.THRESHOLD, ACTCOUNT = through.ACTCOUNT, TROUGHDESC = through.TROUGHDESC }; } else { int count = en.T_PRODUCE_SORTTROUGH.Where(item => item.CIGARETTETYPE == 40 && item.GROUPNO == 1 && item.CIGARETTECODE == through.CIGARETTECODE).Count(); if (count != 0) { return("该品牌在特异形烟混合道中已经存在-" + through.CIGARETTENAME); } tps = new T_PRODUCE_SORTTROUGH() { ID = id + 1, CIGARETTECODE = through.CIGARETTECODE, CIGARETTENAME = through.CIGARETTENAME, CIGARETTETYPE = through.CIGARETTETYPE, GROUPNO = through.GROUPNO, LINENUM = through.LINENUM, MANTISSA = through.MANTISSA, SEQ = seq + 1, STATE = through.STATE, TROUGHNUM = (throughNum + 1).ToString(), TROUGHTYPE = through.TROUGHTYPE, MACHINESEQ = through.MACHINESEQ, LASTMANTISSA = through.LASTMANTISSA, THRESHOLD = through.THRESHOLD, ACTCOUNT = through.ACTCOUNT, TROUGHDESC = through.TROUGHDESC }; } en.T_PRODUCE_SORTTROUGH.AddObject(tps); int rows = en.SaveChanges(); if (rows > 0) { return("异形烟混合通道-" + through.CIGARETTENAME + "创建成功!"); } return("异形烟混合通道-" + through.CIGARETTENAME + "创建失败!"); } }
public static bool SetThroughActcount(string cigarettecode, decimal groupNo, string lastCigarettecode = "0") { using (DZEntities en = new DZEntities()) { if (lastCigarettecode != "0" && lastCigarettecode != "") { var query = en.T_PRODUCE_SORTTROUGH.Where(item => item.STATE == "10" && item.GROUPNO == groupNo && item.CIGARETTECODE == cigarettecode).ToList(); if (query.Count > 1) { foreach (var item in query) { item.ACTCOUNT = 2; } } else { foreach (var item in query) { item.ACTCOUNT = 1; } } var query2 = en.T_PRODUCE_SORTTROUGH.Where(item => item.STATE == "10" && item.GROUPNO == groupNo && item.CIGARETTECODE == lastCigarettecode).ToList(); if (query2.Count > 1) { foreach (var item in query2) { item.ACTCOUNT = 2; } } else { foreach (var item in query2) { item.ACTCOUNT = 1; } } } else { var query = en.T_PRODUCE_SORTTROUGH.Where(item => item.STATE == "10" && item.GROUPNO == groupNo && item.CIGARETTECODE == cigarettecode).ToList(); if (query.Count > 1) { foreach (var item in query) { item.ACTCOUNT = 2; } } else { if (query.Count == 0) { query = en.T_PRODUCE_SORTTROUGH.Where(item => item.GROUPNO == groupNo && item.CIGARETTECODE == cigarettecode).ToList(); } foreach (var item in query) { item.ACTCOUNT = 1; } } } return(en.SaveChanges() > 0); } }
/// <summary> /// 移除分拣数据到历史数据 /// </summary> /// <returns></returns> public Response RemoveTask() { Response re = new Response(); StringBuilder sb = new StringBuilder(); try { using (DZEntities en = new DZEntities()) { var t_un_task = (from item in en.T_UN_TASK select item ).ToList(); if (t_un_task.Any()) { foreach (var item in t_un_task) { T_UN_TASK_H th = new T_UN_TASK_H(); th.BATCHCODE = item.BATCHCODE; th.BILLCODE = item.BILLCODE; th.TASKNUM = item.TASKNUM; th.LINENUM = item.LINENUM; th.EXPORTNUM = item.EXPORTNUM; th.REGIONCODE = item.REGIONCODE; th.REGIONDESC = item.REGIONDESC; th.BILLCODE = item.BILLCODE; th.COMPANYCODE = item.COMPANYCODE; th.COMPANYNAME = item.COMPANYNAME; th.BATCHCODE = item.BATCHCODE; th.SYNSEQ = item.SYNSEQ; th.CUSTOMERCODE = item.CUSTOMERCODE; th.ORDERQUANTITY = item.ORDERQUANTITY; th.CUSTOMERNAME = item.CUSTOMERNAME; th.ORDERMONEY = item.ORDERMONEY; th.TASKQUANTITY = item.TASKQUANTITY; th.PRIORITY = item.PRIORITY; th.TASKBOX = item.TASKBOX; th.SORTSEQ = item.SORTSEQ; th.LABLENUM = item.LABLENUM; th.PLANTIME = item.PLANTIME; th.SORTTIME = item.SORTTIME; th.FINISHTIME = item.FINISHTIME; th.STATE = item.STATE; th.LABELBATCH = item.LABELBATCH; th.PALLETNUM = item.PALLETNUM; th.EXISTRCD = item.EXISTRCD; th.ORDERDATE = item.ORDERDATE; th.MAINBELT = item.MAINBELT; th.PACKAGEMACHINE = item.PACKAGEMACHINE; th.SORTNUM = item.SORTNUM; th.SECSORTNUM = item.SECSORTNUM; th.INSERTTIME = DateTime.Now; en.T_UN_TASK_H.AddObject(th); //将数据添加到历史表 en.T_UN_TASK.DeleteObject(item); //将数据从表中移除 } if (en.SaveChanges() > 0) { re.MessageText += "Task表移除至历史表成功!\r\n"; re.IsSuccess = true; } else { sb.AppendLine("Task表移除至历史表失败,数据库改变的行数为0!"); } } else { sb.AppendLine("未找到Task表数据!"); } var t_un_poke = (from item in en.T_UN_POKE select item ).ToList(); if (t_un_poke.Any()) { foreach (var item in t_un_poke) { T_UN_POKE_H tuh = new T_UN_POKE_H(); tuh.POKEID = item.POKEID; tuh.TROUGHNUM = item.TROUGHNUM; tuh.POKENUM = item.POKENUM; tuh.STATUS = item.STATUS; tuh.TASKNUM = item.TASKNUM; tuh.TASKQTY = item.TASKQTY; tuh.PACKAGEMACHINE = item.PACKAGEMACHINE; tuh.MACHINESEQ = item.MACHINESEQ; tuh.LINENUM = item.LINENUM; tuh.CIGARETTECODE = item.CIGARETTECODE; tuh.CUSTOMERCODE = item.CUSTOMERCODE; tuh.SORTNUM = item.SORTNUM; tuh.SECSORTNUM = item.SECSORTNUM; tuh.BILLCODE = item.BILLCODE; tuh.CTYPE = item.CTYPE; tuh.SENDTASKNUM = item.SENDTASKNUM; tuh.STORENUM = item.STORENUM; tuh.GRIDNUM = item.GRIDNUM; tuh.INVFLAG = item.INVFLAG; tuh.ORDERDATE = OrderDataBySortnum(en, item.SORTNUM ?? 0); tuh.SENDSEQ = item.SENDSEQ; } if (en.SaveChanges() > 0) { re.MessageText += "Poke表移除至历史表成功!"; re.IsSuccess = true; } else { sb.AppendLine("Poke表移除至历史表失败,数据库改变的行数为0!"); } } else { sb.AppendLine("未找到POKE表数据!"); } if (sb.Length == 0) { return(re); } else { re.MessageText = sb.ToString(); re.IsSuccess = false; return(re); } } } catch (Exception ex) { re.IsSuccess = false; re.MessageText = ex.Message; return(re); } }
public Response AutoGenReplan() { Response response = new Response(); Boolean flag = false; int i = 0; using (DZEntities entites = new DZEntities()) { TransactionOptions transactionOption = new TransactionOptions(); transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required, transactionOption)) { try { decimal maxid = 0; //卧式通道预补货 var wsList = (from ws in entites.T_PRODUCE_SORTTROUGH where ws.STATE == "10" && ws.GROUPNO == 3 select ws).ToList(); var itemList = (from item in entites.T_WMS_ITEM where item.ROWSTATUS == 10 select item).ToList(); if (wsList.Any()) { foreach (var item in wsList) { T_WMS_ITEM citem = itemList.Find(x => x.ITEMNO == item.CIGARETTECODE); //计算需要预补多少件 decimal jtsize = citem.JT_SIZE ?? 0; if (jtsize > 0) { decimal ct = ((item.THRESHOLD - item.MANTISSA) / jtsize) ?? 0; double cigCount = Math.Floor(Convert.ToDouble(ct)); if (cigCount > 0) { for (int j = 0; j < cigCount; j++) { i++; T_PRODUCE_REPLENISHPLAN plan = new T_PRODUCE_REPLENISHPLAN(); plan.CIGARETTECODE = item.CIGARETTECODE; plan.CIGARETTENAME = item.CIGARETTENAME; plan.ID = (++maxid); plan.JYCODE = citem.BIGBOX_BAR; plan.REPLENISHQTY = 1; plan.TASKNUM = maxid.ToString(); plan.MANTISSA = item.MANTISSA + citem.JT_SIZE; item.MANTISSA = plan.MANTISSA; plan.TROUGHNUM = item.MACHINESEQ.ToString(); //通道编号默认 plan.STATUS = 0; //新增状态 plan.TYPE = 10; //排程自动补货 plan.SEQ = 1; plan.ISCOMPLETED = 10; //已生成托盘补货计划 entites.T_PRODUCE_REPLENISHPLAN.AddObject(plan); //item.STATUS = 10;//已生成托盘补货计划 } } } } entites.SaveChanges();//提交 最多24条补货 } //根据订单正常补货 var sortList = (from item in entites.T_PRODUCE_SORTTROUGH where item.TROUGHTYPE == 10 && item.STATE == "10" && (item.CIGARETTETYPE == 30 || item.CIGARETTETYPE == 40) select item).ToList(); sortList.ForEach(x => x.LASTMANTISSA = x.MANTISSA);//更新上次尾数 var pokeList1 = (from item in entites.T_UN_POKE where item.STATUS == 0 select item).ToList(); var pokeList = (from item in entites.T_UN_POKE where item.STATUS == 0 group item by new { item.SORTNUM, item.TROUGHNUM, item.CIGARETTECODE } into g orderby g.Key.SORTNUM, g.Key.TROUGHNUM select new { SORTNUM = g.Key.SORTNUM, TROUGHNUM = g.Key.TROUGHNUM, CIGARETTECODE = g.Key.CIGARETTECODE, POKENUM = g.Sum(x => x.POKENUM) }).ToList(); var list = (from item in entites.T_PRODUCE_REPLENISHPLAN select item.ID).ToList(); if (list.Count > 0) { maxid = list.Max(); } if (pokeList1.Any()) { foreach (var item in pokeList) { T_PRODUCE_SORTTROUGH sorttrough = sortList.Find(x => x.CIGARETTECODE == item.CIGARETTECODE && x.TROUGHNUM == item.TROUGHNUM); T_WMS_ITEM citem = itemList.Find(x => x.ITEMNO == item.CIGARETTECODE); sorttrough.MANTISSA = sorttrough.MANTISSA - item.POKENUM; if (sorttrough.THRESHOLD - sorttrough.MANTISSA >= citem.JT_SIZE)//如果空出一件烟就可以补 { i++; T_PRODUCE_REPLENISHPLAN plan = new T_PRODUCE_REPLENISHPLAN(); plan.CIGARETTECODE = item.CIGARETTECODE; plan.CIGARETTENAME = sorttrough.CIGARETTENAME; plan.ID = (++maxid); plan.JYCODE = citem.BIGBOX_BAR; plan.REPLENISHQTY = 1; plan.TASKNUM = maxid.ToString(); plan.MANTISSA = sorttrough.MANTISSA + citem.JT_SIZE; sorttrough.MANTISSA = plan.MANTISSA; plan.TROUGHNUM = sorttrough.MACHINESEQ.ToString(); //通道编号默认 plan.STATUS = 0; //新增状态 plan.TYPE = 30; //排程自动补货 plan.SEQ = 0; plan.ISCOMPLETED = 10; //已生成托盘补货计划 entites.T_PRODUCE_REPLENISHPLAN.AddObject(plan); //item.STATUS = 10;//已生成托盘补货计划 if (i == 100) { entites.SaveChanges(); i = 0; } } // //entites.SaveChanges(); } pokeList1.ForEach(x => x.STATUS = 10); entites.SaveChanges(); tran.Complete(); flag = true; response.MessageText = "补货计划生成成功!"; } else { flag = false; response.MessageText = "暂无新的分拣数据,无需生成补货计划!"; } response.IsSuccess = flag; } catch (Exception e) { flag = false; response.MessageText = "生成补货计划出错,请联系系统管理员!" + e.ToString(); response.IsSuccess = flag; } return(response); } } }
public static bool InsertPokeMixed(List <MixedInfo> infos) { using (DZEntities en = new DZEntities()) { T_UN_POKE_HUNHE tph = new T_UN_POKE_HUNHE(); decimal id = 0; try { id = en.T_UN_POKE_HUNHE.Max(item => item.ID); } catch { id = 0; } foreach (var info in infos) { id = id + 1; if (info.PokeNum > 1) { for (int j = 0; j < info.PokeNum; j++) { tph = new T_UN_POKE_HUNHE() { CIGARETTECODE = info.CigaretteCode, MACHINESEQ = info.MachineSeq, PACKMACHINESEQ = info.PackageMachineSeq, POKEID = info.PokeID, PULLSTATUS = info.PullStatus, SENDTASKNUM = info.SendTasNum, SORTNUM = info.SortNum, TASKNUM = info.TaskNum, TROUGHNUM = Convert.ToDecimal(info.ThroughNum), ID = id }; en.T_UN_POKE_HUNHE.AddObject(tph); id = id + 1; en.SaveChanges(); } } else { tph = new T_UN_POKE_HUNHE() { CIGARETTECODE = info.CigaretteCode, MACHINESEQ = info.MachineSeq, PACKMACHINESEQ = info.PackageMachineSeq, POKEID = info.PokeID, PULLSTATUS = info.PullStatus, SENDTASKNUM = info.SendTasNum, SORTNUM = info.SortNum, TASKNUM = info.TaskNum, TROUGHNUM = Convert.ToDecimal(info.ThroughNum), ID = id }; en.T_UN_POKE_HUNHE.AddObject(tph); en.SaveChanges(); } } return(en.SaveChanges() > 0); } }
/// <summary> /// 根据批次号 操作一个批次 /// </summary> /// <param name="batchcode">批次号</param> /// <param name="optionType">操作0 关闭最近一个创建的批次(默认) , 1 创建一个批次 , 2 关闭一个指定的批次</param> public Response OperationBatch(string batchcode = "", int optionType = 0) { Response response = new Response("操作失败:未找到该批次号,或者该批次号有误:" + batchcode); using (DZEntities en = new DZEntities()) { if (optionType == 0)//关闭最近一个创建的批次 { var old_batch = (from item in en.T_PRODUCE_BATCH where item.STATE == 10 select item).ToList(); if (old_batch.Any()) { if (old_batch.Count() >= 2) { response.IsSuccess = false; response.MessageText = "批次:数据中同时出现两个或两个以上的批次未完成!"; return(response); } else { old_batch.ForEach(a => a.STATE = 0); //更新批次为关闭 old_batch.ForEach(a => a.ENDTIME = DateTime.Now); //更新批次为关闭 response.IsSuccess = true; response.MessageText = "批次:关闭批次成功!"; en.SaveChanges(); return(response); } } else { response.IsSuccess = true; return(response); } } else if (optionType == 1)//创建一个批次 { T_PRODUCE_BATCH t_batch = new T_PRODUCE_BATCH(); t_batch.BATCHCODE = batchcode; t_batch.STARTTIME = DateTime.Now; t_batch.STATE = 10; t_batch.BATCHTYPE = 20; en.T_PRODUCE_BATCH.AddObject(t_batch); if (en.SaveChanges() > 0) { response.IsSuccess = true; response.MessageText = "批次:批次创建成功"; return(response); } else { response.IsSuccess = false; response.MessageText = "批次:创建失败,数据更新行数为0!"; return(response); } } else if (optionType == 2)//关闭一个指定的批次 { var old_batch = (from item in en.T_PRODUCE_BATCH where item.BATCHCODE == batchcode select item).FirstOrDefault(); if (old_batch != null) { if (old_batch.STATE == 0) { response.IsSuccess = true; response.MessageText = "所选批次已是关闭状态!"; return(response); } else { old_batch.ENDTIME = DateTime.Now; old_batch.STATE = 0; if (en.SaveChanges() > 0) { response.IsSuccess = true; response.MessageText = "指定批次关闭成功"; return(response); } else { response.IsSuccess = false; response.MessageText = "批次关闭失败,数据更新行数为0!"; return(response); } } } else { return(response.DefaultResponse); } } else { return(response.DefaultResponse); } } }