public void RecordKanbanTransaction(KanbanCard card, User transUser, DateTime transDate, KBTransType transType) { if (card != null && transUser != null) { KanbanTransaction trans = new KanbanTransaction(); trans.CardNo = card.CardNo; trans.TransactionType = transType; trans.TransactionDate = transDate; trans.CreateUserId = transUser.Id; trans.CreateUserName = transUser.Name; this.genericMgr.Create(trans); } }
//public void CreateKanbanScan(KanbanCard card, FlowDetail matchDetail, User scanUser, DateTime? scanTime) //{ // if (card != null && matchDetail != null && scanUser != null) // { // KanbanScan scan = Mapper.Map<KanbanCard, KanbanScan>(card); // scan.ScanUserId = scanUser.Id; // scan.ScanUserName = scanUser.Name; // scan.ScanTime = scanTime; // //FlowDetail fd = this.genericMgr.FindAll<FlowDetail>("from FlowDetail where Id = ? ", card.FlowDetailId).SingleOrDefault(); // scan.ScanQty = matchDetail.UnitCount; // scan.IsOrdered = false; // this.genericMgr.Create(scan); // } //} public void CreateKanbanScan(KanbanCard card, decimal qty, User scanUser, DateTime? scanTime) { if (card != null && scanUser != null) { KanbanScan scan = Mapper.Map<KanbanCard, KanbanScan>(card); scan.ScanUserId = scanUser.Id; scan.ScanUserName = scanUser.Name; scan.ScanTime = scanTime; scan.ReferenceItemCode = card.ReferenceItemCode; //用物流中心记工位 scan.LogisticCenterCode = card.OpRef; //FlowDetail fd = this.genericMgr.FindAll<FlowDetail>("from FlowDetail where Id = ? ", card.FlowDetailId).SingleOrDefault(); scan.ScanQty = qty; scan.IsOrdered = false; this.genericMgr.Create(scan); card.ScanId = scan.Id; } }
public KanbanScan CreateKanbanScan(KanbanCard card, FlowDetail matchDetail, User scanUser, DateTime? scanTime) { KanbanScan scan = new KanbanScan(); if (card != null && matchDetail != null && scanUser != null) { scan = Mapper.Map<KanbanCard, KanbanScan>(card); scan.ScanUserId = scanUser.Id; scan.ScanUserName = scanUser.Name; scan.ScanTime = scanTime; scan.ReferenceItemCode = card.ReferenceItemCode; //用物流中心记工位 scan.LogisticCenterCode = matchDetail.BinTo; //FlowDetail fd = this.genericMgr.FindAll<FlowDetail>("from FlowDetail where Id = ? ", card.FlowDetailId).SingleOrDefault(); scan.ScanQty = matchDetail.MinUnitCount; scan.IsOrdered = false; this.genericMgr.Create(scan); card.ScanId = scan.Id; return scan; } return scan; }
public KanbanCard Scan(string cardNo, User scanUser) { KanbanCard card = this.kanbanCardMgr.GetByCardNo(cardNo); //是否存在 if (card == null) { #region 处理遗失 IList<KanbanLost> kanbanLostList = genericMgr.FindAll<KanbanLost>(); var q = kanbanLostList.Where(k => k.CardNo == cardNo); if (q != null && q.Count() > 0) { KanbanLost kanbanLost = q.First(); genericMgr.Delete(kanbanLost); } #endregion card = new KanbanCard(); card.CardNo = cardNo; card.OpTime = DateTime.Now; SetCardRetMsg(card, KBProcessCode.NonExistingCard, Resources.KB.KanbanCard.Process_NonExistingCard); } else { //是否有效(未冻结) if (this.kanbanCardMgr.IsEffectiveCard(card)) { if (this.kanbanCardMgr.IsFrozenCard(card)) { card.OpTime = DateTime.Now; SetCardRetMsg(card, KBProcessCode.Frozen, Resources.KB.KanbanCard.Process_Frozen); } else { //是否已经扫描过 if (this.kanbanCardMgr.IsScanned(card)) { card.OpTime = DateTime.Now; SetCardRetMsg(card, KBProcessCode.AlreadyScanned, Resources.KB.KanbanCard.Process_AlreadyScanned); } else { //多轨,是否超循环量,这个时间计算多轨 decimal oldQty = card.Qty; decimal scanQty = card.Qty; //if (!multiSupplyGroupMgr.ScanMultiSupplyGroup(card)) //{ // #region 获取下一个双轨厂商零件,新华说现在看板都是双轨,直接取另一个厂商好了 // MultiSupplyItem multiSupplyItem = genericMgr.FindAll<MultiSupplyItem>("from MultiSupplyItem where GroupNo = ? and Supplier != ? ", new object[] { card.MultiSupplyGroup, card.Supplier }).FirstOrDefault(); // #endregion // if (multiSupplyItem != null) // { // SetCardRetMsg(card, KBProcessCode.ExceedCycleAmount, "当前生效的多轨厂商不是" + card.Supplier + "请扫描厂商:" + multiSupplyItem.Supplier + "件号:" + multiSupplyItem.Item); // } // else // { // SetCardRetMsg(card, KBProcessCode.ExceedCycleAmount, "当前生效的多轨厂商不是" + card.Supplier); // } //} //else //{ //if (oldQty != card.Qty) //{ // SetCardRetMsg(card, KBProcessCode.ExceedCycleAmount, "扫描量超过剩余量,请制作临时看板卡,数量" + card.Qty); // scanQty = card.Qty; // card.Qty = oldQty; //} FlowDetail fd = this.genericMgr.FindAll<FlowDetail>("from FlowDetail where Id = ? ", card.FlowDetailId).SingleOrDefault(); if (fd == null) { card.OpTime = DateTime.Now; SetCardRetMsg(card, KBProcessCode.NoFlowDetail, Resources.KB.KanbanCard.Process_NoFlowDetail); } else { //判断kanbancard相关字段与item,fd及supplier等其他表字段是否有变化 string validText = kanbanCardMgr.ValidateKanbanCardFields(card); if (!String.IsNullOrEmpty(validText)) { card.OpTime = DateTime.Now; SetCardRetMsg(card, KBProcessCode.InvalidFields, Resources.KB.KanbanCard.Process_InvalidFields + ":" + validText); } else { // 可以扫描,创建扫描记录,kb事务记录,设置卡片状态到scanned,不知道为什么会有0的情况 if (scanQty > 0) { DateTime dt = DateTime.Now; if (!string.IsNullOrEmpty(card.MultiSupplyGroup)) { CreateKanbanScan(card, scanQty, scanUser, dt); } else { CreateKanbanScan(card, fd, scanUser, dt); } card.Status = KBStatus.Scanned; card.LastUseDate = dt; card.OpTime = dt; this.genericMgr.Update(card); this.kanbanTransactionMgr.RecordKanbanTransaction(card, scanUser, dt, KBTransType.Scan); if (oldQty == scanQty) { SetCardRetMsg(card, KBProcessCode.Ok, Resources.KB.KanbanCard.Process_Ok); } } } } } //} } } else { card.OpTime = DateTime.Now; SetCardRetMsg(card, KBProcessCode.NotEffective, Resources.KB.KanbanCard.Process_NotEffective); } } return card; }
public ActionResult _AjaxTurnoverRateList(GridCommand command, KanbanCardSearchModel searchModel) { #region grid column var columns = new List<GridColumnSettings>(); columns.Add(new GridColumnSettings { Member = "CardNo", Title = Resources.KB.KanbanCard.KanbanCard_CardNo, Sortable = false }); columns.Add(new GridColumnSettings { Member = "OpRefSequence", Title = Resources.KB.KanbanCard.KanbanCard_OpRefSequence, Sortable = false }); columns.Add(new GridColumnSettings { Member = "Item", Title = Resources.KB.KanbanCard.KanbanCard_Item, Sortable = false }); columns.Add(new GridColumnSettings { Member = "ReferenceItemCode", Title = Resources.KB.KanbanCard.KanbanCard_ReferenceItemCode, Sortable = false }); columns.Add(new GridColumnSettings { Member = "ItemDescription", Title = Resources.KB.KanbanCard.KanbanCard_ItemDescription, Sortable = false }); columns.Add(new GridColumnSettings { Member = "Container1", Title = Resources.SCM.FlowDetail.FlowDetail_Container, Sortable = false }); columns.Add(new GridColumnSettings { Member = "ContainerDescription", Title = Resources.SCM.FlowDetail.FlowDetail_ContainerDescription, Sortable = false }); columns.Add(new GridColumnSettings { Member = "Qty", Title = Resources.KB.KanbanCard.KanbanCard_Qty, Sortable = false }); columns.Add(new GridColumnSettings { Member = "OpRef", Title = Resources.KB.KanbanCard.KanbanCard_OpRef, Sortable = false }); #endregion if (searchModel.StartDate == null || searchModel.EndDate == null) { } else if (searchModel.StartDate.Value.AddDays(31) < searchModel.EndDate) { } else { if (!string.IsNullOrWhiteSpace(searchModel.CardNo)) { if (searchModel.CardNo.Length > 2 && searchModel.CardNo.Substring(0, 2).ToUpper() == "$K") { searchModel.CardNo = searchModel.CardNo.Substring(2, searchModel.CardNo.Length - 2); } } command.PageSize = command.PageSize == 0 ? 20000 : command.PageSize; command.Page = command.Page == 0 ? 1 : command.Page; string searchSql = PrepareTurnoverRateSearchStatement(searchModel); int total = this.genericMgr.FindAllWithNativeSql<int>("select count(*) from (" + searchSql + ") as r1").First(); string sortingStatement = " order by CardNo "; searchSql = string.Format("select * from (select RowId=ROW_NUMBER()OVER({0}),r1.* from ({1}) as r1 ) as rt where rt.RowId between {2} and {3}", sortingStatement, searchSql, (command.Page - 1) * command.PageSize, command.PageSize * command.Page); IList<object[]> searchResult = this.genericMgr.FindAllWithNativeSql<object[]>(searchSql); IList<KanbanCard> opList = new List<KanbanCard>(); if (searchResult != null && searchResult.Count > 0) { #region //c.CardNo,c.OpRefSeq,c.Item,c.RefItemCode,c.ItemDesc,c.Qty,c.opref,CONVERT(varchar(10), s.CreateDate, 121) as '扫描日期',COUNT(*) as '扫描次数' opList = (from tak in searchResult select new KanbanCard { CardNo = (string)tak[1], OpRefSequence = (string)tak[2], Item = (string)tak[3], ReferenceItemCode = (string)tak[4], ItemDescription = (string)tak[5], Qty = (decimal)tak[6], OpRef = (string)tak[7], //ScanDate = Convert.ToDateTime(tak[8]), ScanDate = tak[8] == null ? searchModel.StartDate.Value.Date : Convert.ToDateTime(tak[8]), //ScanDate = tak[8] == null ? searchModel.StartDate.Value.Date : (Convert.ToDateTime(tak[8]) < searchModel.StartDate.Value.Date ? searchModel.StartDate.Value.Date : (Convert.ToDateTime(tak[8]) > searchModel.EndDate.Value.Date ? searchModel.EndDate.Value.Date : Convert.ToDateTime(tak[8]))), ScanCount = (int?)tak[9], Container1 = (string)tak[10], ContainerDescription = (string)tak[11], }).ToList(); #endregion #region //var listDays = opList.Select(o => o.ScanDate).Distinct().OrderBy(o => o.Value).ToList(); //for (int i = 0; i < listDays.Count(); i++) //{ // columns.Add(new GridColumnSettings // { // Member = "RowCellList[" + i + "].ScanCount", // Title = listDays[i].Value.ToShortDateString(), // Sortable = false // }); //} var minDate1 = searchModel.StartDate.Value; var maxDate1 = searchModel.EndDate.Value; int i = 0; while (minDate1 <= maxDate1) { columns.Add(new GridColumnSettings { Member = "RowCellList[" + i + "].ScanCount", Title = minDate1.ToShortDateString(), Sortable = false }); minDate1 = minDate1.AddDays(1); } IList<KanbanCard> kanbanCardList = new List<KanbanCard>(); #region body var groups = opList.GroupBy(g => new { g.CardNo, g.OpRefSequence, g.Item, g.ReferenceItemCode, g.ItemDescription, g.OpRef, g.Qty, g.Container1, g.ContainerDescription }).ToList(); foreach (var g in groups) { KanbanCard k = new KanbanCard(); k.CardNo = g.Key.CardNo; k.OpRefSequence = g.Key.OpRefSequence; k.Item = g.Key.Item; k.ReferenceItemCode = g.Key.ReferenceItemCode; k.ItemDescription = g.Key.ItemDescription; k.OpRef = g.Key.OpRef; k.Qty = g.Key.Qty; k.Container1 = g.Key.Container1; k.ContainerDescription = g.Key.ContainerDescription; List<com.Sconit.Entity.KB.RowCellK> rowList = new List<com.Sconit.Entity.KB.RowCellK>(); var minDate = searchModel.StartDate.Value; var maxDate = searchModel.EndDate.Value; while (minDate <= maxDate) { com.Sconit.Entity.KB.RowCellK rc = new com.Sconit.Entity.KB.RowCellK(); var currentKBs = g.Where(c => c.ScanDate == minDate); var currentKB = currentKBs != null && currentKBs.Count() > 0 ? currentKBs.First() : new KanbanCard(); rc.ScanCount = currentKB.ScanCount.HasValue ? currentKB.ScanCount.Value : 0; rowList.Add(rc); minDate = minDate.AddDays(1); } k.RowCellList = rowList; kanbanCardList.Add(k); } #endregion ViewData["columns"] = columns.ToArray(); return PartialView(kanbanCardList); #endregion } } ViewData["columns"] = columns.ToArray(); return Json(null); //return PartialView(new List<KanbanCard>()); }
public void DeleteKanbanCard(KanbanCard card, User user) { this.genericMgr.Delete(card); this.kanbanTransactionMgr.RecordKanbanTransaction(card, user, DateTime.Now, KBTransType.Scan); this.genericMgr.Update("Update KanbanCard Set TotalCount = ? where FlowDetailId = ? ", new object[] { card.TotalCount - 1, card.FlowDetailId }); this.genericMgr.Update("Update FlowDetail Set CycloidAmount = ? where Id = ? ", new object[] { card.TotalCount - 1, card.FlowDetailId }); }
public void SyncKanbanCardFields(KanbanCard card) { FlowDetail fd = this.genericMgr.FindAll<FlowDetail>("from FlowDetail where Id = ? ", card.FlowDetailId).FirstOrDefault(); FlowMaster fm = this.genericMgr.FindAll<FlowMaster>("from FlowMaster where Code = ? ", card.Flow).FirstOrDefault(); com.Sconit.Entity.SCM.FlowStrategy fs = flowMgr.GetFlowStrategy(card.Flow); //Region p = genericMgr.FindAll<Region>("from Party where Code = ?", card.Region).FirstOrDefault(); //Party s = genericMgr.FindAll<Party>("from Party where Code = ?", card.Supplier).FirstOrDefault(); Item i = genericMgr.FindAll<Item>("from Item where Code = ?", card.Item).FirstOrDefault(); LocationBinItem l = genericMgr.FindAll<LocationBinItem>("from LocationBinItem where Location = ? and Item = ?", new object[] { card.Location, card.Item }).FirstOrDefault(); if (fd == null || fs == null || i == null) { throw new BusinessException("找不到部分主数据"); } else { //if (l == null) //{ // throw new BusinessException("没有找到库位" + fm.LocationTo + ",物料编号" + fd.Item + "的库格"); //} if (card.Item != i.Code) { card.Item = i.Code; card.ItemDescription = i.Description; } if (fm.PartyTo != card.Region) { card.Region = fm.PartyTo; card.RegionName = genericMgr.FindById<Region>(fm.PartyTo).Name; } if (fm.LocationTo != card.Location) { card.Location = fm.LocationTo; } if (fm.Type == com.Sconit.CodeMaster.OrderType.Procurement) { Supplier s = genericMgr.FindById<Supplier>(fm.PartyFrom); if (s.Code != card.Supplier) { card.Supplier = s.Code; card.SupplierName = string.IsNullOrEmpty(s.ShortCode) ? s.Name.Substring(0, 4) : s.ShortCode; } //if (s.LogisticsCentre != card.LogisticCenterCode) //{ // card.LogisticCenterCode = s.LogisticsCentre; //} } //if (fs.QiTiaoBian != card.QiTiaoBian) //{ // card.QiTiaoBian = fs.QiTiaoBian; //} if (fd.UnitCount != card.Qty) { card.Qty = fd.UnitCount; } if (fd.UnitCountDescription != card.Container) { card.Container = fd.UnitCountDescription; } if (fd.BinTo != card.OpRef) { card.OpRef = fd.BinTo; } //if (fd.Shelf != card.Shelf) //{ // card.Shelf = fd.Shelf; //} if (l != null && l.Bin != card.LocBin) { card.LocBin = l.Bin; } this.genericMgr.Update(card); } }
public KanbanCard GenerateToDb(KanbanCard cardWithoutCardNoAndSeq, Boolean useNextSeq, int nextSeq, User calcUser, Boolean isAlternative, Region region) { int currentSeq = 0; if (cardWithoutCardNoAndSeq.MultiSupplyGroup == null) { cardWithoutCardNoAndSeq.MultiSupplyGroup = string.Empty; } //if (String.IsNullOrEmpty(region.KbStandardCode) || String.IsNullOrEmpty(region.KbAlternativeCode)) //{ // throw new BusinessException("区域KB标准或异常代码未设置,区域=" + region.Code); //} // string kbcode = isAlternative ? region.KbAlternativeCode : region.KbStandardCode; string nextSeqString = ""; if (useNextSeq) { nextSeqString = nextSeq.ToString(); } else { currentSeq = GetCurrentKanbanNum(cardWithoutCardNoAndSeq.Region, cardWithoutCardNoAndSeq.Supplier, cardWithoutCardNoAndSeq.Item, cardWithoutCardNoAndSeq.MultiSupplyGroup); nextSeqString = (currentSeq + 1).ToString(); } if (currentSeq == 999) { throw new BusinessException("看板当前为999张,不能新增看板"); } if (nextSeqString.Length < 3) { nextSeqString = nextSeqString.PadLeft(3, '0'); } cardWithoutCardNoAndSeq.CardNo = cardWithoutCardNoAndSeq.Flow.Trim() + cardWithoutCardNoAndSeq.Item.Trim() + nextSeqString; cardWithoutCardNoAndSeq.Sequence = nextSeqString; cardWithoutCardNoAndSeq.TotalCount = currentSeq + 1; cardWithoutCardNoAndSeq.NeedReprint = true; this.genericMgr.Create(cardWithoutCardNoAndSeq); this.kanbanTransactionMgr.RecordKanbanTransaction(cardWithoutCardNoAndSeq, calcUser, DateTime.Now, KBTransType.Initialize); return cardWithoutCardNoAndSeq; }
private KanbanCard GetKanbanCardFromKanbanFlow(FlowMaster fm, Entity.SCM.FlowStrategy fs, FlowDetail fd, string multiSupplyGroup, DateTime effDate, User calcUser, Boolean createNow) { KanbanCard card = new KanbanCard(); card.Flow = fm.Code; card.FlowDetailId = fd.Id; //card.KBCalc = fs.KBCalc; card.OpRef = fd.BinTo; //工位 card.LocBin = fd.Dock; // 配送路径 card.Region = fm.PartyTo; card.GroupDesc = fd.ProductionScan;//工位中文描述 Region r = genericMgr.FindById<Region>(fm.PartyTo); card.RegionName = genericMgr.FindById<Region>(fm.PartyTo).Name; card.Supplier = fm.PartyFrom; Party s = genericMgr.FindById<Party>(fm.PartyFrom); if (s != null) { card.SupplierName = s.Name; } if (s is Supplier) { Supplier su = s as Supplier; card.SupplierName = string.IsNullOrEmpty(su.ShortCode) ? s.Name.Substring(0, 4) : su.ShortCode; } card.Item = fd.Item; card.ItemType = fd.ItemType; Item item = genericMgr.FindById<Item>(card.Item); if (item != null) { card.ItemDescription = item.Description; card.ReferenceItemCode = item.ReferenceCode; //零件类型 } card.Status = KBStatus.Initial; card.EffectiveDate = effDate; card.FreezeDate = DateTime.Parse("2999-1-1 00:00:00"); card.LastUseDate = DateTime.Parse("1900-1-1 00:00:00"); card.NeedReprint = true; //上线包装 card.Qty = fd.MinUnitCount; //容器代码 card.Container = fd.Container; card.OpRefSequence = fd.OprefSequence; //看板号 card.KanbanDeltaNum = 1; card.Location = fm.LocationTo; return card; }
private KanbanCard CreateKanbanCardError(string item, KBProcessCode ret, string msg) { KanbanCard card = new KanbanCard(); card.Flow = ""; card.FlowDetailId = 0; card.Region = ""; card.RegionName = ""; card.ItemDescription = ""; card.Supplier = ""; card.SupplierName = ""; card.Qty = 0; card.Status = KBStatus.Initial; card.KanbanDeltaNum = 0; card.KanbanNum = 0; card.NeedReprint = false; card.Item = item; SetCardRetMsg(card, ret, msg); return card; }
public bool HasPassOrderTime(KanbanCard card) { throw new NotImplementedException(); }
public bool IsScanned(KanbanCard card) { if (card != null) { return (card.Status == KBStatus.Scanned); } return false; }
public bool IsFrozenCard(KanbanCard card) { if (card != null) { DateTime dt = DateTime.Now; return (dt >= card.FreezeDate); } return false; }
public bool IsEffectiveCard(KanbanCard card) { if (card != null) { DateTime dt = DateTime.Now; return (card.EffectiveDate <= dt); } return false; }
public KanbanCard UnfreezeByCard(string cardNo, User freezeUser) { KanbanCard card = GetByCardNo(cardNo); //是否存在 if (card == null) { card = new KanbanCard(); card.CardNo = cardNo; card.OpTime = DateTime.Now; SetCardRetMsg(card, KBProcessCode.NonExistingCard, Resources.KB.KanbanCard.Process_NonExistingCard); } else { DateTime dt = DateTime.Now; card.FreezeDate = DateTime.Parse("2999-1-1 00:00:00"); //card.Status = KBStatus.Loop; this.genericMgr.Update(card); card.OpTime = dt; this.kanbanTransactionMgr.RecordKanbanTransaction(card, freezeUser, dt, KBTransType.UnFreeze); SetCardRetMsg(card, KBProcessCode.Ok, Resources.KB.KanbanCard.Process_Ok); } return card; }
//public StartEndTime ForwardCalculateNextDeliveryForSpecificWorkCalendar(WorkingCalendar nStart, DateTime currentOrderTime, FlowMaster matchFlow, Entity.SCM.FlowStrategy matchStrategy) //{ // //首先算出当前的交货时段 // StartEndTime startEndTime = new StartEndTime(DateTime.Parse("1900-01-01 00:00:00"), DateTime.Parse("2999-1-1 00:00:00")); // string sysTime = systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.StandardWorkTime); // for (int k = 0; k < 2; k++) // { // if (nStart != null) // { // IList<FlowShiftDetail> flowShiftDetailList = this.genericMgr.FindAll<FlowShiftDetail>("from FlowShiftDetail where Flow = ? and Shift = ? Order by Sequence asc", // new object[] { matchFlow.Code, nStart.Shift }); // if (flowShiftDetailList != null) // { // int currentOrderTimeIndex = -1; // for (int i = 0; i < flowShiftDetailList.Count; i++) // { // ShiftDetail sd = this.genericMgr.FindAll<ShiftDetail>("from ShiftDetail where Id = ?", // new object[] { flowShiftDetailList[i].ShiftDetailId }).SingleOrDefault(); // DateTime startTime = KanbanUtility.ConvertDateTimeFromWorkDateAndShiftTime(nStart.WorkingDate, flowShiftDetailList[i].StartTime, sysTime); // DateTime endTime = KanbanUtility.ConvertDateTimeFromWorkDateAndShiftTime(nStart.WorkingDate, flowShiftDetailList[i].EndTime, sysTime); // if (currentOrderTime < startTime || (currentOrderTime > startTime && currentOrderTime < endTime)) // { // currentOrderTimeIndex = i; // startEndTime = RecursiveForwardCalculateNextDeliveryForSpecificWorkCalendar(nStart, currentOrderTimeIndex, matchFlow.Code, (int)(matchStrategy.LeadTime)); // break; // } // } // if (!KanbanUtility.IsMinAndMaxDateTime(startEndTime.StartTime, startEndTime.EndTime)) // { // break; // } // nStart = genericMgr.FindAll<WorkingCalendar>("from WorkingCalendar where Type = ? and WorkingDate > ? and Region = ? and FlowStrategy = ?", new object[] { (int)com.Sconit.CodeMaster.WorkingCalendarType.Work, nStart.WorkingDate, matchFlow.PartyTo, CodeMaster.FlowStrategy.KB }).OrderBy(p => p.WorkingDate).FirstOrDefault(); // } // } // } // return startEndTime; //} //private StartEndTime RecursiveForwardCalculateNextDeliveryForSpecificWorkCalendar(WorkingCalendar nStart, int startIndex, string flow, int leftN) //{ // string sysTime = systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.StandardWorkTime); // IList<FlowShiftDetail> flowShiftDetail = this.genericMgr.FindAll<FlowShiftDetail>("from FlowShiftDetail where Flow = ? and Shift = ? Order by Sequence", // new object[] { flow, nStart.Shift }); // if (flowShiftDetail == null) // { // return new StartEndTime(DateTime.Parse("1900-01-01 00:00:00"), DateTime.Parse("2999-1-1 00:00:00")); // } // else // { // if (startIndex + leftN <= flowShiftDetail.Count - 1) // { // //在当天内 // ShiftDetail sd = this.genericMgr.FindAll<ShiftDetail>("from ShiftDetail where Id = ? and Shift = ? ", // new object[] { flowShiftDetail[startIndex + leftN].ShiftDetailId, flowShiftDetail[startIndex + leftN].Shift }).SingleOrDefault(); // DateTime startTime = KanbanUtility.ConvertDateTimeFromWorkDateAndShiftTime(nStart.WorkingDate, flowShiftDetail[startIndex + leftN].StartTime, sysTime); // DateTime endTime = KanbanUtility.ConvertDateTimeFromWorkDateAndShiftTime(nStart.WorkingDate, flowShiftDetail[startIndex + leftN].EndTime, sysTime); // return new StartEndTime(startTime, endTime); // } // else // { // //不在当天,找下一个工作日 // WorkingCalendar w = genericMgr.FindAll<WorkingCalendar>("from WorkingCalendar where Type = ? and WorkingDate > ? and Region = ? ", new object[] { (int)com.Sconit.CodeMaster.WorkingCalendarType.Work, nStart.WorkingDate, nStart.Region }).OrderBy(p => p.WorkingDate).FirstOrDefault(); // if (w != null) // { // return RecursiveForwardCalculateNextDeliveryForSpecificWorkCalendar(w, 0, flow, leftN - 1 - (flowShiftDetail.Count - 1 - startIndex)); // } // else // { // return new StartEndTime(DateTime.Parse("1900-01-01 00:00:00"), DateTime.Parse("2999-1-1 00:00:00")); // } // } // } //} private void SetCardRetMsg(KanbanCard card, KBProcessCode ret, string msg) { card.Ret = ret; card.Msg = msg; }
//取冻结日期 //private DateTime GetFreezeDate(DateTime startDate, FlowMaster flow, int leadTime) //{ // string sysTime = systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.StandardWorkTime); // DateTime freezeDate = DateTime.Now; // WorkingCalendar wc = genericMgr.FindAll<WorkingCalendar>("from WorkingCalendar w where w.WorkingDate < ? and w.Type = ? and w.FlowStrategy = ? and w.Region = ?", new object[] { startDate, (int)com.Sconit.CodeMaster.WorkingCalendarType.Work, (int)com.Sconit.CodeMaster.FlowStrategy.KB, flow.PartyTo }).OrderByDescending(p => p.WorkingDate).FirstOrDefault(); // if (wc != null) // { // IList<FlowShiftDetail> fsdList = genericMgr.FindAll<FlowShiftDetail>(" from FlowShiftDetail d where d.Flow = ? and d.Shift = ? ", new object[] { flow.Code, wc.Shift }).OrderByDescending(p => p.Sequence).ToList(); // if (fsdList.Count > 0) // { // if (fsdList.Count > leadTime - 1) // { // FlowShiftDetail fsd = leadTime - 1 > 0 ? fsdList[leadTime - 1] : fsdList[0]; // freezeDate = KanbanUtility.ConvertDateTimeFromWorkDateAndShiftTime(wc.WorkingDate, fsd.StartTime, sysTime); // } // else // { // return GetFreezeDate(wc.WorkingDate, flow, leadTime - 1 - fsdList.Count); // } // } // } // return freezeDate; //} //取生效日期,计算时段前一天的倒数第4个时段对应的窗口时间 //private DateTime GetEffDate(DateTime startDate, FlowMaster flow, int leadTime) //{ // string sysTime = systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.StandardWorkTime); // DateTime effDate = DateTime.Now; // WorkingCalendar wc = genericMgr.FindAll<WorkingCalendar>("from WorkingCalendar w where w.WorkingDate < ? and w.Type = ? and w.FlowStrategy = ? and w.Region = ?", new object[] { startDate, (int)com.Sconit.CodeMaster.WorkingCalendarType.Work, (int)com.Sconit.CodeMaster.FlowStrategy.KB, flow.PartyTo }).OrderByDescending(p => p.WorkingDate).FirstOrDefault(); // if (wc != null) // { // IList<ShiftDetail> wsdList = genericMgr.FindAll<ShiftDetail>(" from ShiftDetail d where d.Shift = ?", wc.Shift).OrderByDescending(s => s.Sequence).ToList(); // ShiftDetail inShiftDetail = wsdList[3]; //取第4个交货时段 // IList<FlowShiftDetail> fsdList = genericMgr.FindAll<FlowShiftDetail>(" from FlowShiftDetail d where d.Flow = ? and d.Shift = ? and d.Sequence <= ?", new object[] { flow.Code, wc.Shift, inShiftDetail.Sequence }).OrderByDescending(p => p.Sequence).ToList(); // if (fsdList.Count > leadTime) // { // FlowShiftDetail fsd = fsdList[leadTime]; // effDate = KanbanUtility.ConvertDateTimeFromWorkDateAndShiftTime(wc.WorkingDate, fsd.StartTime, sysTime); // } // else // { // //好像直接调冻结那个日期方法就行了 // effDate = GetFreezeDate(wc.WorkingDate, flow, (leadTime - fsdList.Count) == 0 ? 1 : (leadTime - fsdList.Count)); // } // } // return effDate; //} #endregion public string ValidateKanbanCardFields(KanbanCard card) { FlowDetail fd = this.genericMgr.FindAll<FlowDetail>("from FlowDetail where Id = ? ", card.FlowDetailId).FirstOrDefault(); FlowMaster fm = this.genericMgr.FindAll<FlowMaster>("from FlowMaster where Code = ? ", card.Flow).FirstOrDefault(); com.Sconit.Entity.SCM.FlowStrategy fs = flowMgr.GetFlowStrategy(card.Flow); //Region p = genericMgr.FindAll<Region>("from Party where Code = ?", card.Region).FirstOrDefault(); //Party s = genericMgr.FindAll<Party>("from Party where Code = ?", card.Supplier).FirstOrDefault(); Item i = genericMgr.FindAll<Item>("from Item where Code = ?", card.Item).FirstOrDefault(); // LocationBinItem l = genericMgr.FindAll<LocationBinItem>("from LocationBinItem where Location = ? and Item = ?", new object[] { card.Location, card.Item }).FirstOrDefault(); if (fd == null || fs == null || i == null) { return "找不到部分主数据"; } else { string validText = ""; if (card.Item != i.Code) { validText += "原物料代码:" + card.Item + ",现在物料代码:" + i.Code + ","; } if (fm.PartyTo != card.Region) { validText += "原区域代码: " + card.Region + ",现在区域代码:" + fm.PartyTo + ","; } if (fm.LocationTo != card.Location) { validText += "原库位代码: " + card.Location + ",现在库位代码:" + fm.Code + ","; } if (fm.Type == com.Sconit.CodeMaster.OrderType.Procurement) { Supplier s = genericMgr.FindById<Supplier>(fm.PartyFrom); if (s.Code != card.Supplier) { validText += "原厂商代码: " + card.Supplier + ",现在厂商代码:" + s.Code + ","; } //if (s.LogisticsCentre != card.LogisticCenterCode) //{ // validText += "原物流中心代码: " + card.LogisticCenterCode + ",现在物流中心代码:" + s.LogisticsCentre + ","; //} } //if (fs.QiTiaoBian != card.QiTiaoBian) //{ // validText += "原起跳便: " + card.QiTiaoBian + ",现在起跳便:" + fs.QiTiaoBian + ","; //} if (fd.MinUnitCount != card.Qty) { validText += "原包装: " + card.Qty + ",现在包装:" + fd.UnitCount + ","; } if (fd.Container != card.Container) { validText += "原包装规格: " + card.Container + ",现在包装规格:" + fd.UnitCountDescription + ","; } if (fd.BinTo != card.OpRef) { validText += "原站别: " + card.OpRef + ",现在站别:" + fd.BinTo + ","; } //if (fd.Shelf != card.Shelf) //{ // validText += "原架位: " + card.Shelf + ",现在架位:" + fd.Shelf + ","; //} //if (l != null && l.Bin != card.LocBin) //{ // validText += "原库房架位: " + card.LocBin + ",现在库房架位:" + l.Bin + ","; //} return validText; } }
public KanbanCard RotateKanbanCard(KanbanCard card, Boolean deleteAnother) { //Region r = genericMgr.FindAll<Region>("from Party where Code = ?", card.Region).FirstOrDefault(); ////if (String.IsNullOrEmpty(r.KbStandardCode) || String.IsNullOrEmpty(r.KbAlternativeCode)) ////{ //// throw new BusinessException("没有设置KB标准代码或异常代码,区域=" + r.Code); ////} //string oldCardNo = card.CardNo; //string oldSeq = card.Sequence; //string kbcode = oldSeq.Substring(0, 1); //string seqString = oldSeq.Substring(1, 3); //if (kbcode.Equals(r.KbStandardCode)) //{ // card.CardNo = card.Flow + card.Item + r.KbAlternativeCode + seqString; // card.Sequence = r.KbAlternativeCode + seqString; //} //else if (kbcode.Equals(r.KbAlternativeCode)) //{ // card.CardNo = card.Flow + card.Item + r.KbStandardCode + seqString; // card.Sequence = r.KbStandardCode + seqString; //} //KanbanCard card2 = GetByCardNo(card.CardNo); //if (card2 == null) //{ // card.NeedReprint = true; // card.Status = com.Sconit.CodeMaster.KBStatus.Initial; // this.genericMgr.Create(card); // if (deleteAnother) // { // this.genericMgr.DeleteById<KanbanCard>(oldCardNo); // } //} return card; }