public static List <OnCigOrderInfo> GetOneCigOrder() { using (DZEntities en = new DZEntities()) { List <OnCigOrderInfo> list = new List <OnCigOrderInfo>(); //var query = en.T_UN_POKE.GroupBy(item => new { item.BILLCODE, item.SORTNUM }).Where(item => item.Sum(items => items.POKENUM) == 1).Select(item => // new { BillCode = item.Key.BILLCODE, Sortnum = item.Key.SORTNUM, Num = item.Sum(items => items.POKENUM) }).OrderBy(item => item.Sortnum).ToList(); //list = (from task in en.T_UN_TASK // join poke in query on task.SORTNUM equals poke.Sortnum // select new OnCigOrderInfo // { // RegionCode = task.REGIONCODE, // RegionDesc = task.REGIONDESC, // BillCode = task.BILLCODE, // CustomerCode = task.CUSTOMERCODE, // CustomerName = task.CUSTOMERNAME, // Num = poke.Num ?? 0, // SortNum = poke.Sortnum ?? 0 // }).OrderBy(item => item.SortNum).ToList(); string sqlStr = "select task.regioncode,task.regiondesc,task.billcode,task.customercode,task.customername,poke.num,POKE.SORTNUM from t_un_task task, " + "(select billcode,sortnum,sum(pokenum) as num from t_un_poke group by billcode,sortnum having sum(pokenum)=1 order by sortnum) poke " + "where poke.sortnum=task.sortnum order by task.sortnum"; list = en.ExecuteStoreQuery <OnCigOrderInfo>(sqlStr).ToList(); return(list); } }
/// <summary> /// 获取批次号 /// </summary> /// <returns>字符串批次号</returns> public Response CreateBatchCode() { Response re = new Response("未找到数据!"); String yearmonth = DateTime.Now.ToString("yyyyMMdd"); using (DZEntities en = new DZEntities()) { var t_batch_count = (from item in en.T_PRODUCE_BATCH where item.BATCHCODE.StartsWith(yearmonth) select item).Count(); if (t_batch_count < 0) { re.DefaultResponse.DefaultResponse.ResultObject = yearmonth + "0" + 1; return(re.DefaultResponse); } else { if (t_batch_count < 10) { re.ResultObject = yearmonth + "0" + (t_batch_count + 1); } else { re.ResultObject = yearmonth + (t_batch_count + 1); } re.IsSuccess = true; re.MessageText = "成功获取新的批次"; } } return(re); }
/// <summary> /// 获取所有信息 /// </summary> /// <param name="seq">通道号</param> /// <returns></returns> public static List <HunheNowViewInfos> GetALLCigarette(decimal seq, decimal groupNo) { using (DZEntities entity = new DZEntities()) { try { var query = (from item in entity.T_UN_POKE join item2 in entity.T_PRODUCE_SORTTROUGH on item.TROUGHNUM equals item2.TROUGHNUM join item3 in entity.T_UN_TASK on item.TASKNUM equals item3.TASKNUM join item4 in entity.T_UN_POKE_HUNHE on item.POKEID equals item4.POKEID where item2.CIGARETTETYPE == 40 && item.MACHINESEQ == seq && item2.GROUPNO == groupNo orderby item.SORTNUM, item2.MACHINESEQ, item2.TROUGHNUM, item.POKEID select new HunheNowViewInfos() { PULLSTATUS = item4.PULLSTATUS, tasknum = item.TASKNUM, sortnum = item.SORTNUM, customername = item3.CUSTOMERNAME, regioncode = item3.REGIONCODE, TROUGHNUM = item.MACHINESEQ, CIGARETTECODE = item2.CIGARETTECODE, CIGARETTENAME = item2.CIGARETTENAME, pokenum = item.POKENUM, status = item.STATUS, pokeid = item.POKEID, sendtasknum = item.SENDTASKNUM }).ToList(); return(query); } catch (Exception e) { throw e; } } }
/// <summary> /// 验证接收订单日期 /// </summary> /// <param name="nowTime"></param> /// <returns></returns> public Response ValiDataTime(DateTime nowTime) { Response re = new Response(); using (DZEntities en = new DZEntities()) { var orderTime = (from item in en.T_PRODUCE_ORDER select item ).ToList(); if (orderTime.Any()) { if (nowTime == orderTime.FirstOrDefault().ORDERDATE) { re.IsSuccess = true; re.MessageText = "日期无误!"; return(re); } else { re.IsSuccess = false; re.MessageText = "当前接收订单日期与已接收订单日期不符,请重新选择订单进行接收!"; return(re); } } else { re.IsSuccess = true; re.MessageText = "未接收任务任何数据!"; return(re); } } }
public static List <T_PRODUCE_REGIONMANAGE> GetRegionSort() { using (DZEntities en = new DZEntities()) { return(en.T_PRODUCE_REGIONMANAGE.ToList()); } }
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 List <Replenish> GetReplenishByCigName(int index, string condition) { using (DZEntities en = new DZEntities()) { List <Replenish> list = new List <Replenish>(); string sqlStr = ""; if (condition == "") { sqlStr = "select tr.TASKNUM,tr.CIGARETTECODE,tr.CIGARETTENAME,tr.JYCODE,tr.REPLENISHQTY,tr.STATUS,tr.TROUGHNUM " + "from T_PRODUCE_REPLENISHPLAN tr order by TASKNUM,TROUGHNUM"; } else { if (index == 0) { sqlStr = "select tr.TASKNUM,tr.CIGARETTECODE,tr.CIGARETTENAME,tr.JYCODE,tr.REPLENISHQTY,tr.STATUS,tr.TROUGHNUM " + "from T_PRODUCE_REPLENISHPLAN tr where tr.CIGARETTENAME like '" + condition + "%' order by TASKNUM,TROUGHNUM"; } else { sqlStr = "select tr.TASKNUM,tr.CIGARETTECODE,tr.CIGARETTENAME,tr.JYCODE,tr.REPLENISHQTY,tr.STATUS,tr.TROUGHNUM " + "from T_PRODUCE_REPLENISHPLAN tr where tr.JYCODE like '" + condition + "%' order by TASKNUM,TROUGHNUM"; } } list = en.ExecuteStoreQuery <Replenish>(sqlStr).ToList(); return(list); } }
/// <summary> /// 校验特异形烟是否录入长宽 /// </summary> /// <returns></returns> public static string GetNullLWSomke() { string needInfo = null; using (DZEntities data = new DZEntities()) { var jydate = (from item in data.T_UN_POKE select item).ToList(); if (jydate == null || jydate.Count == 0) { return("当前没有数据"); } var query = (from item in data.T_WMS_ITEM join trough in data.T_PRODUCE_SORTTROUGH on item.ITEMNO equals trough.CIGARETTECODE join task in data.T_UN_TASKLINE on trough.CIGARETTECODE equals task.CIGARETTECODE where (trough.CIGARETTETYPE == 30 || trough.CIGARETTETYPE == 40) && trough.TROUGHTYPE == 10 && ((item.ILENGTH == null || item.IWIDTH == null) || (item.ILENGTH == 0 || item.IWIDTH == 0)) group item by new { trough.CIGARETTECODE, trough.CIGARETTENAME } into g select g).ToList(); if (query == null || query.Count == 0) { return("校验无误!"); } else { foreach (var item in query) { needInfo += item.Key.CIGARETTECODE + "|" + item.Key.CIGARETTENAME + ","; } return(needInfo + "这些品牌没有录入长宽!请在分拣前录入!!"); } } }
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> /// <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 object[] GetSendTasks(decimal isCompleted, out StringBuilder outStr) { using (DZEntities en = new DZEntities()) { object[] data = new object[7]; StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.Length; i++) { data[i] = 0; } UnnormalInfo info = new UnnormalInfo(); string sqlStr = "select sortnum,sum(pokenum) as num from t_un_poke where ctype=1 and status = 10 group by sortnum order by sortnum"; info = en.ExecuteStoreQuery <UnnormalInfo>(sqlStr).FirstOrDefault(); if (info != null) { data[0] = info.SortNum; data[1] = info.SortNum; data[2] = info.Num; data[3] = info.Num; data[4] = 0; data[5] = 0; data[6] = 1; sb.AppendLine(data[0] + ",数量:" + data[2] + ",任务发送标志位:" + data[6]); } //int count = en.T_UN_POKE_HUNHE.Where(item => item.SORTNUM == info.SortNum).Count(); else { sb.AppendLine("特异型烟道暂无任务"); } outStr = sb; return(data); } }
/// <summary> /// 验证批次 /// </summary> /// <returns></returns> public Response ValiBatchCode() { Response re = new Response(); using (DZEntities en = new DZEntities()) { var MaxBtach = (from item in en.T_PRODUCE_BATCH where item.STATE == 10 && item.BATCHTYPE == 20 select item).Max(a => a.BATCHCODE); if (!string.IsNullOrWhiteSpace(MaxBtach) && MaxBtach != "0") { re.IsSuccess = true; re.MessageText = "有新的批次"; re.ResultObject = MaxBtach; return(re); } else { re.IsSuccess = false; re.MessageText = "查询不到批次号,接收订单前请先创建批次!"; return(re); } } }
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 ValidNewCustomer(decimal maxSyncseq) { Response response = new Response(); using (DZEntities dzEntities = new DZEntities()) { var query = (from pitem in dzEntities.T_WMS_CUSTOMER where pitem.DELSTATUS == 10 select pitem.ID).ToList(); //var newCust = (from order in dzEntities.T_PRODUCE_ORDER where !query.Contains(order.CUSTOMERCODE) select order).ToList(); var newCust1 = (from order in dzEntities.T_PRODUCE_ORDER where order.SYNSEQ == maxSyncseq select order.CUSTOMERCODE).ToList(); var newCust = newCust1.Except(query).ToList(); if (newCust.Count() > 0) { response.IsSuccess = false; response.MessageText = "订单接收发现【" + newCust.Count() + "】个新客户,请为同步零售户信息!"; } else { response.IsSuccess = true; response.MessageText = "本次接收暂未发现新零售户!"; } } return(response); }
/// <summary> /// 验证单个通道 1验证,通道是否启用 /// </summary> /// <param name="cahnnel"></param> /// <returns></returns> public Response ValiSingleChannel(T_PRODUCE_SORTTROUGH channel) { Response re = new Response(); using (DZEntities en = new DZEntities()) { var date = (from item in en.T_PRODUCE_SORTTROUGH orderby item.MACHINESEQ select item).ToList(); //先判断该品牌是否通道中存在 var vali_1 = date.Where(a => a.CIGARETTECODE == channel.CIGARETTECODE && a.STATE == "10").ToList(); var Vali_2 = date.Where(a => a.MACHINESEQ == channel.MACHINESEQ && a.STATE == "10").ToList(); if (!vali_1.Any()) { if (!Vali_2.Any()) { re.IsSuccess = true; re.MessageText = "该通道未被启用" + channel.MACHINESEQ; return(re); } else { re.IsSuccess = false; re.MessageText = "该通道已经启用:" + channel.MACHINESEQ; return(re); } } else { re.IsSuccess = false; re.MessageText = "该通道已经启用:" + channel.MACHINESEQ; return(re); } } }
/// <summary> /// 验证订单数量是否与源数据一致 /// </summary> /// <returns></returns> public Response ValiOrderNum(decimal maxSyncseq, DateTime nowDate) { Response response = new Response(); response.IsSuccess = true; using (DZEntities dzEntities = new DZEntities()) { //订单个数 var regionInfo = (from region in dzEntities.T_PRODUCE_ORDER where region.SYNSEQ == maxSyncseq select region.REGIONCODE).Distinct().ToList(); var orderCount = (from order in dzEntities.T_PRODUCE_ORDER where order.SYNSEQ == maxSyncseq select order).ToList(); var saleOrder = (from sale in dzEntities.T_SALE_ORDER_HEAD where sale.ORDERDATE == nowDate && regionInfo.Contains(sale.ROUTECODE) select sale).ToList(); if (orderCount.Count() != saleOrder.Count()) { response.IsSuccess = false; response.MessageText = "中间表订单数:" + saleOrder.Count() + "个,接收订单数:" + orderCount.Count() + "个,两边信息不一致!"; } //订单明细条数 var orderLineCount = (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 line).ToList(); var saleLineOrder = (from sale in dzEntities.T_SALE_ORDER_HEAD join sline in dzEntities.T_SALE_ORDER_LINE on sale.ORDERNO equals sline.ORDERNO where sale.ORDERDATE == nowDate && regionInfo.Contains(sale.ROUTECODE) select sline).ToList(); if (orderLineCount.Count() != saleLineOrder.Count()) { response.IsSuccess = false; response.MessageText = response.MessageText + "中间表订单明细数:" + orderLineCount.Count() + "个,接收订单明细数:" + orderLineCount.Count() + "个,两边信息不一致!"; } } return(response); }
public static object[] GetSendTask(decimal isCompleted, out StringBuilder outStr) { using (DZEntities en = new DZEntities()) { object[] data = new object[6]; StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.Length; i++) { data[i] = 0; } List <T_PRODUCE_REPLENISHPLAN> list = new List <T_PRODUCE_REPLENISHPLAN>(); string sqlStr = "select * from T_PRODUCE_REPLENISHPLAN where iscompleted = 10 and cigarettecode in(" + "select cigarettecode from t_produce_sorttrough where groupno=3) and troughnum<=6 order by id"; list = en.ExecuteStoreQuery <T_PRODUCE_REPLENISHPLAN>(sqlStr).ToList(); data[0] = list[0].TASKNUM; data[1] = Convert.ToDecimal(list[0].TROUGHNUM); data[2] = list[0].JYCODE; data[3] = 0; data[4] = 0; data[5] = 1; sb.AppendLine("任务号:" + data[0] + "," + data[1] + "号通道补烟,任务发送标志位:" + data[5]); outStr = sb; return(data); } }
/// <summary> /// 获取新的ID /// </summary> /// <returns></returns> private decimal GetTroughId() { using (DZEntities en = new DZEntities()) { return(en.ExecuteStoreQuery <decimal>(Str_SortTId, null).FirstOrDefault()); } }
public static decimal GetMinSortNum() { using (DZEntities en = new DZEntities()) { string sqlStr = "select min(sortnum) as num from t_un_poke where ctype=1 and status = 15 group by sortnum order by sortnum"; return(en.ExecuteStoreQuery <decimal>(sqlStr).FirstOrDefault()); } }
/// <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 List <string> GetAllRegion() { using (DZEntities en = new DZEntities()) { List <string> list = new List <string>(); list = en.T_PRODUCE_PACKAGECALLBACK.Select(item => item.ROTENAME).Distinct().ToList(); return(list); } }
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 List <T_PRODUCE_PACKAGECALLBACK> GetPackInfoByRegion(string regionName) { using (DZEntities en = new DZEntities()) { List <T_PRODUCE_PACKAGECALLBACK> list = new List <T_PRODUCE_PACKAGECALLBACK>(); string date = DateTime.Now.Date.ToString("yyyy-MM-dd"); list = en.T_PRODUCE_PACKAGECALLBACK.Where(item => item.ROTENAME == regionName && item.ORDERDATE == date).OrderBy(item => item.DEVSEQ).ToList(); return(list); } }
/// <summary> /// 查询通道表 (查询条件:1默认所有,2卷烟编码, 3卷烟名称, 4通道号, /// </summary> /// <returns></returns> public Response <List <T_PRODUCE_SORTTROUGH> > GetSortTroughInfo(object condition = null, int queryType = 1) { Response <List <T_PRODUCE_SORTTROUGH> > re = new Response <List <T_PRODUCE_SORTTROUGH> >("查询通道表:未找到任何数据,请检查网络连接!"); try { using (DZEntities en = new DZEntities()) { var t_produce_sorttorugh = (from item in en.T_PRODUCE_SORTTROUGH select item).OrderBy(a => a.MACHINESEQ).ToList(); if (t_produce_sorttorugh.Any()) { switch (queryType) { case 1: re.Content = t_produce_sorttorugh; re.IsSuccess = true; re.MessageText = "查询成功!"; return(re); case 2: var con = t_produce_sorttorugh.Where(a => a.CIGARETTENAME.StartsWith(condition.ToString())).ToList(); re.Content = con; re.IsSuccess = true; re.MessageText = "查询成功!"; return(re); case 3: re.Content = t_produce_sorttorugh.Where(a => a.CIGARETTECODE.StartsWith(condition.ToString())).ToList(); re.IsSuccess = true; re.MessageText = "查询成功!"; return(re); case 4: re.Content = t_produce_sorttorugh.Where(a => a.MACHINESEQ == Convert.ToDecimal(condition)).ToList(); re.IsSuccess = true; re.MessageText = "查询成功!"; return(re); default: re.DefaultResponse.MessageText += "未识别的查询类型!" + queryType; return(re.DefaultResponse); } } else { return(re.DefaultResponse); } } } catch (Exception e) { re.DefaultResponse.MessageText += "\r\n 异常信息:" + e.Message; return(re.DefaultResponse); } }
public static List <ReplenishInfo> GetReplenish(decimal condition) { using (DZEntities en = new DZEntities()) { string sqlStr = ""; //Func<T_PRODUCE_REPLENISHPLAN, bool> fun; if (condition == 0) { sqlStr = "select r.TROUGHNUM as ThroughNum,r.CIGARETTENAME,JYCODE,REPLENISHQTY,TASKNUM,r.CIGARETTECODE from t_produce_replenishplan r,t_produce_sorttrough s " + " where s.machineseq=r.troughnum and s.cigarettecode=r.cigarettecode " + " and s.groupno=3 order by r.id"; } else { sqlStr = "select r.TROUGHNUM as ThroughNum,r.CIGARETTENAME,JYCODE,REPLENISHQTY,TASKNUM,r.CIGARETTECODE from t_produce_replenishplan r,t_produce_sorttrough s " + " where s.machineseq=r.troughnum and s.cigarettecode=r.cigarettecode " + " and s.groupno=3 and iscompleted=" + condition + " order by r.id"; } List <ReplenishInfo> list = new List <ReplenishInfo>(); list = en.ExecuteStoreQuery <ReplenishInfo>(sqlStr).ToList(); //var query = en.T_PRODUCE_REPLENISHPLAN.Where(fun).Select(item => new //{ // ThroughNum = item.TROUGHNUM, // CigaretteName = item.CIGARETTENAME, // JYCode = item.JYCODE, // ReplenishQTY = item.REPLENISHQTY ?? 0, // TaskNum = item.TASKNUM, // cigarettecode = item.CIGARETTECODE //}).OrderBy(item => Convert.ToDecimal(item.TaskNum)).ToList(); //list = query.Join(en.T_PRODUCE_SORTTROUGH, plan => new { plan.ThroughNum, plan.cigarettecode }, through => new { through.TROUGHNUM, through.CIGARETTECODE }, (plan, through) => // new // { // throughNum = plan.ThroughNum, // CigaretteName = plan.CigaretteName, // JYCode = plan.JYCode, // ReplenishQTY = plan.ReplenishQTY, // TaskNum = plan.TaskNum, // groupNo = through.GROUPNO // }).Where(item => item.groupNo == 3).Select(item => new ReplenishInfo // { // ThroughNum = item.throughNum, // CigaretteName = item.CigaretteName, // JYCode = item.JYCode, // ReplenishQTY = item.ReplenishQTY, // TaskNum = item.TaskNum // }).OrderBy(item => Convert.ToDecimal(item.TaskNum)).ToList(); return(list); } }
/// <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 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 List <T_PRODUCE_REPLENISHPLAN> GetReplenishplan() { using (DZEntities en = new DZEntities()) { List <T_PRODUCE_REPLENISHPLAN> list = new List <T_PRODUCE_REPLENISHPLAN>(); string sqlStr = "select * from T_PRODUCE_REPLENISHPLAN where iscompleted != 20 and cigarettecode in(" + "select cigarettecode from t_produce_sorttrough where groupno=3) and troughnum<=6 order by id"; list = en.ExecuteStoreQuery <T_PRODUCE_REPLENISHPLAN>(sqlStr).ToList(); return(list); } }