本文整理汇总了C#中com.Sconit.Entity.Exception.BusinessException类的典型用法代码示例。如果您正苦于以下问题:C# BusinessException类的具体用法?C# BusinessException怎么用?C# BusinessException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BusinessException类属于com.Sconit.Entity.Exception命名空间,在下文中一共展示了BusinessException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMrpBomList
//得到基本单位用量
protected List<MrpBom> GetMrpBomList(string fgCode, string bomCode, DateTime effdate, BusinessException businessException, bool isOnlyNext = false)
{
var mrpBoms = new List<MrpBom>();
try
{
var bomMaster = this.bomMgr.GetCacheBomMaster(bomCode);
if (bomMaster != null)
{
var fgItem = this.itemMgr.GetCacheItem(fgCode);
IList<BomDetail> bomDetails = new List<BomDetail>();
if (isOnlyNext)
{
bomDetails = bomMgr.GetOnlyNextLevelBomDetail(bomCode, effdate, true);
}
else
{
bomDetails = bomMgr.GetFlatBomDetail(bomCode, effdate, true);
}
foreach (var bomDetail in bomDetails)
{
var item = this.itemMgr.GetCacheItem(bomDetail.Item);
double calculatedQty = 1;
//1.将bomMaster的单位转成基本单位
double fgQty = ConvertItemUomQty(fgItem.Code, bomMaster.Uom, 1, fgItem.Uom, businessException);
//2.将BomDetail的单位转成基本单位
double itemQty = ConvertItemUomQty(item.Code, bomDetail.Uom, (double)bomDetail.CalculatedQty, item.Uom, businessException);
//3.单位成品用量
calculatedQty = itemQty / fgQty;
var mrpBom = new MrpBom();
mrpBom.Bom = bomCode;
mrpBom.Item = bomDetail.Item;
mrpBom.Location = bomDetail.Location;
mrpBom.RateQty = calculatedQty;
mrpBom.IsSection = item.ItemCategory == "ZHDM";
mrpBom.ScrapPercentage = (double)bomDetail.ScrapPercentage;
//if (mrpBom.IsSection)
//{
// mrpBom.ScrapPercentage = fgItem.ScrapPercent;
//}
mrpBoms.Add(mrpBom);
}
}
}
catch (Exception ex)
{
businessException.AddMessage(new Message(CodeMaster.MessageType.Error, string.Format("BomCode {0} Error,{1}", bomCode, ex.Message)));
}
return mrpBoms;
}
示例2: ReadWeeklyMrpPlanFromXls
public void ReadWeeklyMrpPlanFromXls(Stream inputStream, string startWeek, string endWeek, string flowCode, bool isItemRef)
{
#region 判断
DateTime? startDate = null;
DateTime? endDate = null;
if (!string.IsNullOrEmpty(startWeek))
{
startDate = DateTimeHelper.GetWeekIndexDateFrom(startWeek);
}
if (!string.IsNullOrEmpty(endWeek))
{
endDate = DateTimeHelper.GetWeekIndexDateFrom(endWeek);
}
if (startDate.HasValue)
{
if (startDate.Value.Date < DateTime.Now.Date)
{
throw new BusinessException("开始日期必须大于当期日期");
}
}
else
{
startDate = DateTime.Now.Date;
}
if (endDate.HasValue)
{
if (endDate.Value.Date <= DateTime.Now.Date)
{
throw new BusinessException("结束日期必须大于当期日期");
}
}
else
{
endDate = DateTime.MaxValue.Date;
}
if (startDate.Value > endDate.Value)
{
throw new BusinessException("开始日期必须小于结束日期");
}
if (inputStream.Length == 0)
{
throw new BusinessException("Import.Stream.Empty");
}
#endregion 判断
//var flowDetails = GetFlowDetails(flowCode);
List<FlowDetail> flowDetailList = new List<FlowDetail>();
var uomDic = this.genericMgr.FindAll<Uom>().ToDictionary(d => d.Code, d => d);
if (string.IsNullOrWhiteSpace(flowCode))
{
var flowMasters = this.genericMgr.FindAll<FlowMaster>(" from FlowMaster where Type=?",
CodeMaster.OrderType.Distribution).ToList();
foreach (var flowMaster in flowMasters)
{
flowDetailList.AddRange(GetFlowDetails(flowMaster));
}
}
else
{
flowDetailList = GetFlowDetails(flowCode).ToList();
}
var flowDetailDic = flowDetailList.GroupBy(p => p.CurrentFlowMaster.Code, (k, g) => new { k, g }).ToDictionary(d => d.k, d => d.g);
HSSFWorkbook workbook = new HSSFWorkbook(inputStream);
ISheet sheet = workbook.GetSheetAt(0);
IEnumerator rows = sheet.GetRowEnumerator();
IRow dateRow = sheet.GetRow(5);
ImportHelper.JumpRows(rows, 6);
var mrpPlanLogList = new List<MrpPlanLog>();
int days = 7;
try
{
days = (int)sheet.GetRow(4).GetCell(1).NumericCellValue;
}
catch (Exception)
{ }
#region 列定义
//int colFlow = 0;//
int colFlow = 0;//
int colItemCode = 1;//物料代码或参考物料号
//int colItemDescription = 2;//物料描述
int colUom = 3;//单位
#endregion
BusinessException businessException = new BusinessException();
while (rows.MoveNext())
{
string flow = null;
Item item = null;
string uomCode = null;
string itemReference = null;
//.........这里部分代码省略.........
示例3: DoStartVanOrder
private void DoStartVanOrder(string orderNo, string feedOrderNo, IList<string> feedHuIdList, bool isForce)
{
#region 上线
OrderMaster orderMaster = this.genericMgr.FindById<OrderMaster>(orderNo);
#region 判断是否第一辆上线
IList<long> beforeUnstartVanOrderCount = this.genericMgr.FindAll<long>("select count(*) as counter from OrderMaster where Type = ? and Flow = ? and Status = ? and IsPause = ? and Sequence < ?", new object[] { orderMaster.Type, orderMaster.Flow, CodeMaster.OrderStatus.Submit, false, orderMaster.Sequence });
if (beforeUnstartVanOrderCount != null && beforeUnstartVanOrderCount.Count > 0 && beforeUnstartVanOrderCount[0] > 0)
{
throw new BusinessException("生产单{0}不是生产线{1}第一张待上线的生产单。", orderNo, orderMaster.Flow);
}
#endregion
this.StartOrder(orderMaster);
#endregion
#region 子生产单投料
if (!string.IsNullOrWhiteSpace(feedOrderNo))
{
this.productionLineMgr.FeedProductOrder(orderNo, feedOrderNo, isForce);
}
#endregion
#region 物料投料
if (feedHuIdList != null && feedHuIdList.Count > 0)
{
#region 查找投料条码
IList<Hu> huList = this.huMgr.LoadHus(feedHuIdList);
#endregion
#region 查找投料工位
string hql = string.Empty;
IList<object> para = new List<object>();
foreach (string item in huList.Select(h => h.Item).Distinct())
{
if (hql == string.Empty)
{
hql = "from OrderBomDetail where OrderNo = ? and Item in (?";
para.Add(orderNo);
}
else
{
hql += ", ?";
}
para.Add(item);
}
hql += ")";
IList<OrderBomDetail> orderBomDetailList = this.genericMgr.FindAll<OrderBomDetail>(hql, para.ToArray());
#region 判断条码是否在OrderBomDetial中存在
if (!isForce)
{
BusinessException businessException = new BusinessException();
foreach (Hu hu in huList)
{
if (orderBomDetailList.Where(det => det.Item == hu.Item).Count() == 0)
{
businessException.AddMessage("投料的条码{0}在生产单的物料清单中不存在。", hu.HuId);
}
}
if (businessException.HasMessage)
{
throw businessException;
}
}
#endregion
#endregion
#region 投料
foreach (string huId in feedHuIdList)
{
Hu hu = huList.Where(h => h.HuId == huId).Single();
OrderBomDetail orderBomDetail = orderBomDetailList.Where(o => o.Item == hu.Item).OrderBy(o => o.Sequence).First();
FeedInput feedInput = new FeedInput();
feedInput.HuId = huId;
feedInput.Operation = orderBomDetail.Operation;
feedInput.OpReference = orderBomDetail.OpReference;
IList<FeedInput> feedInputList = new List<FeedInput>();
feedInputList.Add(feedInput);
this.productionLineMgr.FeedRawMaterial(orderNo, feedInputList, isForce);
}
#endregion
}
#endregion
#region 释放驾驶室生产单
//由后台Job自动释放
#endregion
#region 递延扣减
//记录递延扣减需求,由后台Job自动扣减
IList<DeferredFeedCounter> deferredFeedCounterList = this.genericMgr.FindAll<DeferredFeedCounter>("from DeferredFeedCounter where Flow = ?", orderMaster.Flow);
if (deferredFeedCounterList != null && deferredFeedCounterList.Count > 0)
{
//.........这里部分代码省略.........
示例4: PackSequenceOrder
public void PackSequenceOrder(SequenceMaster sequenceMaster, IList<string> huIdList)
{
#region 检查
if (sequenceMaster.Status != CodeMaster.SequenceStatus.Submit)
{
throw new BusinessException("状态为{1}的排序装箱单{0}不能装箱。", sequenceMaster.SequenceNo,
systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.SequenceStatus, ((int)sequenceMaster.Status).ToString()));
}
if (huIdList == null || huIdList.Count == 0)
{
throw new BusinessException("排序装箱单{0}的装箱条码为空。", sequenceMaster.SequenceNo);
}
#endregion
#region 库存占用
IList<InventoryOccupy> inventoryOccupyList = (from huId in huIdList
select new InventoryOccupy
{
HuId = huId,
Location = sequenceMaster.LocationFrom,
QualityType = CodeMaster.QualityType.Qualified,
OccupyType = CodeMaster.OccupyType.Sequence,
OccupyReferenceNo = sequenceMaster.SequenceNo
}).ToList();
IList<LocationLotDetail> locationLotDetailList = this.locationDetailMgr.InventoryOccupy(inventoryOccupyList);
#endregion
#region 排序单数量和扫描条码数量匹配
BusinessException businessException = new BusinessException();
TryLoadSequenceDetails(sequenceMaster);
if (sequenceMaster.SequenceDetails.Where(d => !d.IsClose).Count() != huIdList.Count) //过滤掉已经Close的排序件,因为已经暂停
{
businessException.AddMessage("扫描条码的数量和排序装箱单明细的数量不匹配。");
}
#endregion
#region 条码匹配检查,按顺序检查排序件条码
int i = 0;
foreach (SequenceDetail sequenceDetail in sequenceMaster.SequenceDetails.Where(d => !d.IsClose).OrderBy(d => d.Sequence))
{
LocationLotDetail locationLotDetail = locationLotDetailList.Where(l => l.HuId == huIdList[i]).Single();
i++;
if (sequenceDetail.Item != locationLotDetail.Item)
{
businessException.AddMessage("排序装箱单序号{0}所需的零件为{1},扫描的零件为{2}。", sequenceDetail.Sequence.ToString(), sequenceDetail.Item, locationLotDetail.Item);
}
}
if (businessException.HasMessage)
{
throw businessException;
}
#endregion
#region 更新排序装箱单头
sequenceMaster.Status = CodeMaster.SequenceStatus.Pack;
sequenceMaster.PackUserId = SecurityContextHolder.Get().Id;
sequenceMaster.PackUserName = SecurityContextHolder.Get().FullName;
sequenceMaster.PackDate = DateTime.Now;
this.genericMgr.Update(sequenceMaster);
#endregion
#region 装箱操作
i = 0;
foreach (SequenceDetail sequenceDetail in sequenceMaster.SequenceDetails.Where(d => !d.IsClose))
{
LocationLotDetail locationLotDetail = locationLotDetailList.Where(l => l.HuId == huIdList[i]).Single();
i++;
sequenceDetail.HuId = locationLotDetail.HuId;
sequenceDetail.LotNo = locationLotDetail.LotNo;
this.genericMgr.Update(sequenceDetail);
}
#endregion
}
示例5: CloseOrder
private void CloseOrder(OrderMaster orderMaster, bool isForce, bool isThrowException = true)
{
if (orderMaster.Status == CodeMaster.OrderStatus.InProcess
|| orderMaster.Status == CodeMaster.OrderStatus.Complete)
{
DateTime dateTimeNow = DateTime.Now;
User user = SecurityContextHolder.Get();
this.genericMgr.FlushSession();
BusinessException businessException = new BusinessException();
#region 强制关闭生产单,先把状态改为Complete
if (isForce && orderMaster.Status == CodeMaster.OrderStatus.InProcess && orderMaster.Type == CodeMaster.OrderType.Production)
{
//生产先做订单完工
orderMaster.Status = CodeMaster.OrderStatus.Complete;
orderMaster.CompleteDate = dateTimeNow;
orderMaster.CompleteUserId = user.Id;
orderMaster.CompleteUserName = user.FullName;
this.genericMgr.Update(orderMaster);
}
#endregion
#region 条件1所有订单明细收货数大于等于订单数 //强制关闭不用校验这条
if (!isForce)
{
string hql = "select count(*) as counter from OrderDetail where OrderNo = ? and (ReceivedQty+ScrapQty) < OrderedQty";
long counter = this.genericMgr.FindAll<long>(hql, new Object[] { orderMaster.OrderNo })[0];
if (counter > 0)
{
return;
}
}
#endregion
#region 条件2所有送货单明细全部关闭
if (orderMaster.Type != CodeMaster.OrderType.Production)
{
string hql = "select count(*) as counter from IpDetail where OrderNo = ? and IsClose = ?";
long counter = this.genericMgr.FindAll<long>(hql, new Object[] { orderMaster.OrderNo, false })[0];
if (counter > 0)
{
if (!isForce)
{
//非强制关闭直接返回
return;
}
businessException.AddMessage("和订单相关的送货单明细没有全部关闭,不能关闭订单{0}。", orderMaster.OrderNo);
}
}
#endregion
#region 条件3所有的拣货单全部关闭
if (orderMaster.Type == CodeMaster.OrderType.Transfer
|| orderMaster.Type == CodeMaster.OrderType.SubContractTransfer
|| orderMaster.Type == CodeMaster.OrderType.Distribution)
{
string hql = "select count(*) as counter from PickListDetail where OrderNo = ? and IsClose = ?";
long counter = this.genericMgr.FindAll<long>(hql, new Object[] { orderMaster.OrderNo, false })[0];
if (counter > 0)
{
if (!isForce)
{
//非强制关闭直接返回
return;
}
businessException.AddMessage("和订单相关的捡货单明细没有全部关闭,不能关闭订单{0}。", orderMaster.OrderNo);
}
}
#endregion
if (businessException.HasMessage)
{
if (isThrowException)
{
throw businessException;
}
}
else
{
orderMaster.Status = CodeMaster.OrderStatus.Close;
orderMaster.CloseDate = dateTimeNow;
orderMaster.CloseUserId = user.Id;
orderMaster.CloseUserName = user.FullName;
this.genericMgr.Update(orderMaster);
}
}
else if (!isForce)
{
throw new BusinessException("不能关闭状态为{1}的订单{0}。", orderMaster.OrderNo,
systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.OrderStatus, ((int)orderMaster.Status).ToString()));
}
}
示例6: CheckKitIpDetail
private void CheckKitIpDetail(IpMaster ipMaster, bool isCheckKitTraceItem)
{
BusinessException businessException = new BusinessException();
#region 明细行是否收/发货判断
IList<IpDetail> unReceivedIpDetailList = LoadExceptIpDetails(ipMaster.IpNo, ipMaster.IpDetails.Select(det => det.Id).ToArray());
if (unReceivedIpDetailList != null && unReceivedIpDetailList.Count > 0)
{
foreach (IpDetail unReceivedIpDetail in unReceivedIpDetailList)
{
businessException.AddMessage("KIT送货单{0}行号{1}零件号{2}没有收货。", ipMaster.IpNo, unReceivedIpDetail.Sequence.ToString(), unReceivedIpDetail.Item);
}
}
#endregion
#region 收/发货数是否等于订单数判断
foreach (IpDetail ipDetail in ipMaster.IpDetails)
{
if (ipDetail.Qty != ipDetail.ReceiveQtyInput)
{
businessException.AddMessage("KIT送货单{0}行号{1}零件号{2}的收货数和送货数不一致。", ipMaster.IpNo, ipDetail.Sequence.ToString(), ipDetail.Item);
}
}
#endregion
#region KIT中的关键件是否扫描
if (isCheckKitTraceItem)
{
foreach (IpDetail ipDetail in ipMaster.IpDetails.Where(o => o.IsScanHu))
{
if (ipDetail.Qty != ipDetail.IpDetailInputs.Where(o => !string.IsNullOrWhiteSpace(o.HuId)).Count())
{
businessException.AddMessage("KIT送货单{0}行号{1}的关键零件{1}没有扫描。", ipMaster.IpNo, ipDetail.Sequence.ToString(), ipDetail.Item);
}
}
}
#endregion
if (businessException.HasMessage)
{
throw businessException;
}
}
示例7: CheckShipFiFo
private void CheckShipFiFo(IList<OrderMaster> orderMasterList)
{
var orderMaster = orderMasterList.First();
if (!orderMaster.IsShipScanHu || orderMaster.QualityType == CodeMaster.QualityType.Reject)
{
//如果发货不扫描条码,就不校验发货先进先出
return;
}
var isShipFiFo = orderMasterList.Select(p => p.IsShipFifo).Distinct();
if (isShipFiFo.Count() > 1)
{
throw new BusinessException("发货先进先出选项不同不能合并发货。");
}
if (!isShipFiFo.First())
{
//如果不校验发货先进先出
return;
}
var locations = orderMasterList
.SelectMany(p => p.OrderDetails)
.Select(p => p.LocationFrom)
.Where(p => !string.IsNullOrWhiteSpace(p))
.Distinct();
if (locations.Count() > 1)
{
throw new BusinessException("不同的发货库位不能合并发货");
}
var distinctItemCodes = orderMasterList
.SelectMany(p => p.OrderDetails)
.Select(p => p.Item)
.Where(p => !string.IsNullOrWhiteSpace(p))
.Distinct();
#region 查找库存
#region 拼SQL
string statement = string.Empty;
IList<object> detailPara = new List<object>();
foreach (var itemCode in distinctItemCodes)
{
if (statement == string.Empty)
{
statement = @"select l.Item,l.HuId, l.LotNo, l.Direction
from VIEW_LocationLotDet l where l.HuId is not null
and l.Location = ? and l.QualityType = ? and l.OccupyType = ? and l.IsATP = ? and l.IsFreeze = ?";
detailPara.Add(locations.First());
detailPara.Add(orderMaster.QualityType);
detailPara.Add(CodeMaster.OccupyType.None);
detailPara.Add(true);
detailPara.Add(false);
statement += " and l.Item in (?";
}
else
{
statement += ", ?";
}
detailPara.Add(itemCode);
}
statement += ") order by l.LotNo Asc ";
#endregion
var locationDetailsGroup = this.genericMgr.FindAllWithNativeSql<object[]>(statement, detailPara.ToArray())
.Select(p => new
{
Item = (string)p[0],
HuId = (string)p[1],
LotNo = (string)p[2],
Direction = p[3] == null ? string.Empty : (string)p[3]
})
.GroupBy(p => new { p.Item, p.Direction })
.ToDictionary(d => d.Key, d => d.ToList());
#endregion
var orderDetailsGroup = orderMasterList.SelectMany(p => p.OrderDetails)
.GroupBy(p => new { p.Item, p.Direction });
var bussinessException = new BusinessException();
foreach (var orderDetails in orderDetailsGroup)
{
var orderDetailInputs = orderDetails.SelectMany(p => p.OrderDetailInputs).ToList();
var maxLotNo = orderDetailInputs.OrderBy(p => p.LotNo).Last().LotNo;
var huIds = orderDetailInputs.Select(p => p.HuId).ToList();
var locationDetails = locationDetailsGroup.ValueOrDefault(orderDetails.Key);
if (locationDetails == null)
{
throw new BusinessException("没有找到合适的库存");
}
var minLotNoLocationDetail = locationDetails.Where(p => !huIds.Contains(p.HuId)).OrderBy(p => p.LotNo).FirstOrDefault();
string minLotNo = null;
if (minLotNoLocationDetail != null)
{
minLotNo = minLotNoLocationDetail.LotNo;
}
var directionDesc = string.Empty;
//.........这里部分代码省略.........
示例8: CreateInspectMaster
public void CreateInspectMaster(InspectMaster inspectMaster, DateTime effectiveDate)
{
#region 检查
if (inspectMaster.InspectDetails == null || inspectMaster.InspectDetails.Where(i => i.InspectQty > 0 || !string.IsNullOrWhiteSpace(i.HuId)).Count() == 0)
{
throw new BusinessException("报验单明细不能为空。");
}
inspectMaster.InspectDetails = inspectMaster.InspectDetails.Where(i => i.InspectQty > 0 || !string.IsNullOrWhiteSpace(i.HuId)).OrderBy(det => det.Sequence).ToList();
if (inspectMaster.Type == CodeMaster.InspectType.Barcode)
{
BusinessException businessException = new BusinessException();
IList<HuStatus> huStatusList = huMgr.GetHuStatus(inspectMaster.InspectDetails.Select(i => i.HuId).ToList());
#region 查找零件
string hql = string.Empty;
IList<object> paras = new List<object>();
foreach (string itemCode in huStatusList.Select(i => i.Item).Distinct())
{
if (hql == string.Empty)
{
hql = "from Item where Code in (?";
}
else
{
hql += ", ?";
}
paras.Add(itemCode);
}
hql += ")";
IList<Item> itemList = this.genericMgr.FindAll<Item>(hql, paras.ToArray());
#endregion
int seq = 1; //新的序号
foreach (InspectDetail inspectDetail in inspectMaster.InspectDetails)
{
HuStatus huStatus = huStatusList.Where(h => h.HuId == inspectDetail.HuId).SingleOrDefault();
if (huStatus == null)
{
businessException.AddMessage("条码{0}不存在。", inspectDetail.HuId);
}
else if (huStatus.Status == CodeMaster.HuStatus.NA)
{
businessException.AddMessage("条码{0}不在任何库位中,不能报验。", huStatus.HuId);
}
else if (huStatus.Status == CodeMaster.HuStatus.Ip)
{
businessException.AddMessage("条码{0}为库位{1}至库位{2}的在途库存,不能报验。", huStatus.HuId, huStatus.LocationFrom, huStatus.LocationTo);
}
else if (huStatus.OccupyType != CodeMaster.OccupyType.None)
{
businessException.AddMessage("条码{0}已经被占用,不能报验", huStatus.HuId);
}
else
{
inspectDetail.Sequence = seq++;
inspectDetail.Item = huStatus.Item;
inspectDetail.ItemDescription = itemList.Where(i => i.Code == huStatus.Item).Single().Description;
inspectDetail.ReferenceItemCode = huStatus.ReferenceItemCode;
inspectDetail.UnitCount = huStatus.UnitCount;
inspectDetail.Uom = huStatus.Uom;
inspectDetail.BaseUom = huStatus.BaseUom;
inspectDetail.UnitQty = huStatus.UnitQty;
inspectDetail.LotNo = huStatus.LotNo;
inspectDetail.LocationFrom = huStatus.Location;
inspectDetail.CurrentLocation = huStatus.Location;
inspectDetail.InspectQty = huStatus.Qty;
}
}
#region 检查报验零件是否在同一个区域中
IList<string> regionList = huStatusList.Select(l => l.Region).Distinct().ToList();
if (regionList != null && regionList.Count > 1)
{
throw new BusinessException("条码的库位属于不同区域不能合并报验。");
}
inspectMaster.Region = regionList.Single();
#endregion
if (businessException.HasMessage)
{
throw businessException;
}
}
#endregion
#region 创建报验单头
inspectMaster.InspectNo = this.numberControlMgr.GetInspectNo(inspectMaster);
this.genericMgr.Create(inspectMaster);
#endregion
#region 创建报验单明细
foreach (var inspectDetail in inspectMaster.InspectDetails)
{
inspectDetail.InspectNo = inspectMaster.InspectNo;
inspectDetail.ManufactureParty = inspectMaster.ManufactureParty;
this.genericMgr.Create(inspectDetail);
}
#endregion
//.........这里部分代码省略.........
示例9: GenPurchaseRccp
private void GenPurchaseRccp(DateTime planVersion, CodeMaster.TimeUnit dateType, BusinessException businessException,
IList<MrpFlowDetail> mrpFlowDetailList, IEnumerable<RccpTransGroup> rccpTransGroupList, DateTime snapTime, User user)
{
if(businessException.GetMessages().Where(p => p.MessageType == CodeMaster.MessageType.Error).Count() > 0)
{
//如果有错误,退出,不产生采购物料需求
return;
}
var flowDetails = mrpFlowDetailList
.Where(p => p.Type == CodeMaster.OrderType.Procurement || p.Type == CodeMaster.OrderType.CustomerGoods
|| p.Type == CodeMaster.OrderType.SubContract || p.Type == CodeMaster.OrderType.ScheduleLine);
var purchasePlanList = new List<PurchasePlan>();
var rccpTransGroupByIndexList = (from p in rccpTransGroupList
group p by p.DateIndex into g
select new
{
DateIndex = g.Key,
List = g
}).OrderBy(p => p.DateIndex).ToList();
foreach(var rccpTransGroupByIndex in rccpTransGroupByIndexList)
{
DateTime windowTime = DateTime.Now;
if(dateType == CodeMaster.TimeUnit.Week)
{
windowTime = DateTimeHelper.GetWeekIndexDateFrom(rccpTransGroupByIndex.DateIndex);
}
else if(dateType == CodeMaster.TimeUnit.Month)
{
windowTime = DateTime.Parse(rccpTransGroupByIndex.DateIndex + "-01");
}
var mrpFlowDetailDic = flowDetails.Where(p => p.StartDate <= windowTime && p.EndDate > windowTime)
.GroupBy(p => p.Item, (k, g) => new { k, g })
.ToDictionary(d => d.k, d => d.g);
foreach(var groupRccpTrans in rccpTransGroupByIndex.List)
{
var mrpFlowDetails = mrpFlowDetailDic.ValueOrDefault(groupRccpTrans.Item);
if(mrpFlowDetails != null)
{
foreach(var mrpFlowDetail in mrpFlowDetails)
{
var purchasePlan = new PurchasePlan();
purchasePlan.Item = groupRccpTrans.Item;
//purchasePlan.Sequence = mrpFlowDetail.Sequence;
purchasePlan.Flow = mrpFlowDetail.Flow;
purchasePlan.LocationTo = mrpFlowDetail.LocationTo;
purchasePlan.OrderType = mrpFlowDetail.Type;
purchasePlan.WindowTime = windowTime;
var leadDay = Utility.DateTimeHelper.TimeTranfer((decimal)mrpFlowDetail.LeadTime, CodeMaster.TimeUnit.Hour, CodeMaster.TimeUnit.Day);
if(dateType == CodeMaster.TimeUnit.Week)
{
purchasePlan.StartTime = purchasePlan.WindowTime.AddDays(3).AddDays(-leadDay);
purchasePlan.StartTime = Utility.DateTimeHelper.GetWeekStart(purchasePlan.StartTime);
}
else
{
purchasePlan.StartTime = purchasePlan.WindowTime.AddDays(15).AddDays(-leadDay);
purchasePlan.StartTime = Utility.DateTimeHelper.GetStartTime(CodeMaster.TimeUnit.Month, purchasePlan.StartTime);
}
purchasePlan.Qty = (mrpFlowDetail.MrpWeight / mrpFlowDetails.Sum(p => p.MrpWeight)) * groupRccpTrans.Qty;
purchasePlan.PlanQty = purchasePlan.Qty;
purchasePlan.DateType = dateType;
purchasePlan.PlanVersion = planVersion;
purchasePlanList.Add(purchasePlan);
}
}
else
{
if(groupRccpTrans.IsLastLevel)
{
businessException.AddMessage(new Message(CodeMaster.MessageType.Warning, "没有找到物料{0}的采购路线", groupRccpTrans.Item));
}
}
}
}
string hql = string.Empty;
if(dateType == CodeMaster.TimeUnit.Week)
{
hql = "from FlowStrategy where IsCheckMrpWeeklyPlan =? and Flow in(?";
}
else if(dateType == CodeMaster.TimeUnit.Month)
{
hql = "from FlowStrategy where IsCheckMrpMonthlyPlan =? and Flow in(?";
}
var flowStategys = this.genericMgr.FindAllIn<FlowStrategy>
(hql, purchasePlanList.Select(p => p.Flow).Where(p => !string.IsNullOrWhiteSpace(p)).Distinct(),
new object[] { true });
var flowMasterDic = this.genericMgr.FindAllIn<FlowMaster>
("from FlowMaster where Code in(?", flowStategys.Select(p => p.Flow).Distinct())
.GroupBy(p => p.Code, (k, g) => new { k, g.First().Description })
.ToDictionary(d => d.k, d => d.Description);
foreach(var flowStategy in flowStategys)
{
PurchasePlanMaster purchasePlanMaster = new PurchasePlanMaster();
//.........这里部分代码省略.........
示例10: GenMiRccp
private void GenMiRccp(DateTime planVersion, CodeMaster.TimeUnit dateType, string dateIndex,
IList<MrpFlowDetail> mrpFlowDetailList, List<RccpTransGroup> rccpTransGroupList, BusinessException businessException)
{
var itemDiscontinueList = this.genericMgr.FindAll<ItemDiscontinue>();
var rccpMiPlanList = new List<RccpMiPlan>();
var workCalendars = this.genericMgr.FindAll<WorkCalendar>
(@" from WorkCalendar as w where w.DateType =? and w.ResourceGroup=? and w.DateIndex between ? and ? ",
new object[] { dateType, CodeMaster.ResourceGroup.MI, dateIndex, rccpTransGroupList.Max(p => p.DateIndex) });
double cleanTime = double.Parse(systemMgr.GetEntityPreferenceValue(Entity.SYS.EntityPreference.CodeEnum.MiCleanTime));
var miFlowDetailList = mrpFlowDetailList.Where(p => p.ResourceGroup == CodeMaster.ResourceGroup.MI);
foreach(var groupRccpTrans in rccpTransGroupList)
{
DateTime dateFrom = DateTime.Now;
if(dateType == CodeMaster.TimeUnit.Week)
{
dateFrom = Utility.DateTimeHelper.GetWeekIndexDateFrom(groupRccpTrans.DateIndex);
}
else
{
dateFrom = DateTime.Parse(groupRccpTrans.DateIndex + "-01");
}
var mrpFlowDetail = miFlowDetailList.FirstOrDefault(p => p.ResourceGroup == CodeMaster.ResourceGroup.MI
&& p.Item == groupRccpTrans.Item && p.StartDate <= dateFrom && p.EndDate > dateFrom);
if(mrpFlowDetail != null)
{
var workCalendar = workCalendars.FirstOrDefault(p => p.DateIndex == groupRccpTrans.DateIndex
&& p.Flow == mrpFlowDetail.Flow);
var miPlan = new RccpMiPlan();
DateTime planDate = DateTime.Now;
if(workCalendar != null)
{
miPlan.HaltTime = workCalendar.HaltTime * 24 * 60;
miPlan.TrialProduceTime = workCalendar.TrialTime * 24 * 60;
miPlan.Holiday = workCalendar.Holiday * 24 * 60;
miPlan.UpTime = workCalendar.UpTime * 24 * 60;
if(dateType == CodeMaster.TimeUnit.Month)
{
planDate = DateTime.Parse(groupRccpTrans.DateIndex + "-01");
//miPlan.UpTime = DateTime.DaysInMonth(planDate.Year, planDate.Month) * 24 * 60 * ((8 * 60 - cleanTime) / (8 * 60));
//miPlan.UpTime = workCalendar.UpTime * 24 * 60;
}
else if(dateType == CodeMaster.TimeUnit.Week)
{
planDate = Utility.DateTimeHelper.GetWeekIndexDateFrom(groupRccpTrans.DateIndex);
//miPlan.HaltTime = (7 - workCalendar.Holiday) * 24 * 60 * (cleanTime / (8 * 60));
//miPlan.UpTime = (7 - workCalendar.Holiday) * 24 * 60 * ((8 * 60 - cleanTime) / (8 * 60));
}
}
else
{
//出错
businessException.AddMessage("没有找到炼胶的工作日历");
}
miPlan.ProductLine = mrpFlowDetail.Flow;
miPlan.Item = groupRccpTrans.Item;
miPlan.DateIndex = groupRccpTrans.DateIndex;
miPlan.DateType = dateType;
miPlan.PlanVersion = planVersion;
miPlan.Qty = groupRccpTrans.Qty;
var miItem = this.itemMgr.GetCacheItem(groupRccpTrans.Item);
if(miItem == null)
{
businessException.AddMessage(new Message(CodeMaster.MessageType.Error, string.Format("没有找到此物料{0}的对应的工时", groupRccpTrans.Item)));
}
else
{
miPlan.WorkHour = miItem.WorkHour;
}
miPlan.CheRateQty = mrpFlowDetail.UnitCount;
//替代物料
var itemDiscontinues = itemDiscontinueList.Where(p => p.Item == miPlan.Item && p.StartDate <= planDate
&& (!p.EndDate.HasValue || (p.EndDate.HasValue && p.EndDate.Value > planDate))).OrderBy(p => p.Priority).ToList();
var items = new List<string>();
items.Add(miPlan.Item);
items.AddRange(itemDiscontinues.Select(p => p.DiscontinueItem));
//可委外的物料
var flowDetail = mrpFlowDetailList.FirstOrDefault(f => f.Type == CodeMaster.OrderType.SubContract && items.Contains(f.Item));
if(flowDetail != null)
{
miPlan.SubFlowDetail = flowDetail;
}
rccpMiPlanList.Add(miPlan);
//this.genericMgr.Create(miPlan);
}
}
var groupMiPlans = (from p in rccpMiPlanList
group p by new
{
p.ProductLine,
p.DateIndex,
//.........这里部分代码省略.........
示例11: MergePlanBill
public void MergePlanBill(IList<HuStatus> huStatusList)
{
BusinessException businessException = new BusinessException();
if (huStatusList.Where(h => h.PlanBill.HasValue == false).Count() > 0)
{
businessException.AddMessage("所有的条码必须为寄售");
}
IList<PlanBill> planBillList = new List<PlanBill>();
var lastOrderNo = string.Empty;
var total = 0M;
Int32? mergedPlanBill = 0;
for (int i = 0; i < huStatusList.Count;i++)
{
var planBill = this.genericMgr.FindById<PlanBill>(huStatusList[i].PlanBill);
if (string.IsNullOrEmpty(lastOrderNo))
{
//记录第一个订单号
lastOrderNo = planBill.OrderNo;
}
else
{
if (lastOrderNo != planBill.OrderNo)
{
businessException.AddMessage("不允许多个订单合并翻箱");
break;
}
}
if (i < huStatusList.Count - 1)
{
total += huStatusList[i].Qty;
planBill.PlanQty -= huStatusList[i].Qty;
}
else
{
mergedPlanBill = planBill.Id;
planBill.PlanQty += total;
}
planBill.HuId = null;
this.genericMgr.Update(planBill);
}
if (businessException.HasMessage)
{
throw businessException;
}
foreach (var huStatus in huStatusList)
{
huStatus.PlanBill = mergedPlanBill.Value;
}
}
示例12: New
public string New(string checkedIds, string Region)
{
IList<LocationLotDetail> viewLocationList = new List<LocationLotDetail>();
string[] checkedIdArray = checkedIds.Split(',');
string selectStatement = string.Empty;
IList<object> selectPartyPara = new List<object>();
foreach (var para in checkedIdArray)
{
if (selectStatement == string.Empty)
{
selectStatement = "from LocationLotDetail where Id in (?";
}
else
{
selectStatement += ",?";
}
selectPartyPara.Add(para);
}
selectStatement += ")";
viewLocationList = genericMgr.FindAll<LocationLotDetail>(selectStatement, selectPartyPara.ToArray());
BusinessException businessException = new BusinessException();
try
{
#region orderDetailList
IList<InspectDetail> inspectDetailList = new List<InspectDetail>();
if (viewLocationList != null && viewLocationList.Count() > 0)
{
foreach (LocationLotDetail locationlotdetail in viewLocationList)
{
InspectDetail inspectDetail = new InspectDetail();
Item item = this.genericMgr.FindById<Item>(locationlotdetail.Item);
inspectDetail.Item = locationlotdetail.Item;
inspectDetail.HuId = locationlotdetail.HuId;
inspectDetail.LotNo = locationlotdetail.LotNo;
inspectDetail.ItemDescription = item.Description;
inspectDetail.UnitCount = locationlotdetail.UnitCount;
inspectDetail.ReferenceItemCode = item.ReferenceCode;
inspectDetail.Uom = item.Uom;
inspectDetail.LocationFrom =locationlotdetail.Location;
inspectDetail.CurrentLocation = locationlotdetail.Location;
inspectDetail.BaseUom = item.Uom;
inspectDetail.UnitQty = 1;
inspectDetailList.Add(inspectDetail);
}
}
#endregion
if (businessException.HasMessage)
{
throw businessException;
}
if (inspectDetailList != null && inspectDetailList.Count == 0)
{
throw new BusinessException(Resources.INP.InspectDetail.Errors_InspectDetail_Required);
}
InspectMaster inspectMaster = new InspectMaster();
inspectMaster.Region = Region;
inspectMaster.InspectDetails = inspectDetailList;
inspectMaster.Type = com.Sconit.CodeMaster.InspectType.Barcode;
inspectMaster.IsATP = false;
inspectMgr.CreateInspectMaster(inspectMaster);
SaveSuccessMessage(Resources.INP.InspectMaster.InspectMaster_Added);
return inspectMaster.InspectNo;
}
catch (BusinessException ex)
{
Response.TrySkipIisCustomErrors = true;
Response.StatusCode = 500;
string messagesStr = "";
IList<Message> messageList = ex.GetMessages();
foreach (Message message in messageList)
{
messagesStr += message.GetMessageString() ;
}
Response.Write(messagesStr);
return string.Empty;
}
}
示例13: ReadDailyMrpPlanFromXls
public void ReadDailyMrpPlanFromXls(Stream inputStream, DateTime? startDate, DateTime? endDate, string flowCode, bool isItemRef)
{
#region 判断
if (startDate.HasValue)
{
if (startDate.Value.Date < DateTime.Now.Date)
{
throw new BusinessException("开始日期必须大于当期日期");
}
}
else
{
startDate = DateTime.Now.Date;
}
if (endDate.HasValue)
{
if (endDate.Value.Date <= DateTime.Now.Date)
{
throw new BusinessException("结束日期必须大于当期日期");
}
}
else
{
endDate = DateTime.MaxValue.Date;
}
if (startDate.Value > endDate.Value)
{
throw new BusinessException("开始日期必须小于结束日期");
}
if (inputStream.Length == 0)
{
throw new BusinessException("Import.Stream.Empty");
}
#endregion 判断
HSSFWorkbook workbook = new HSSFWorkbook(inputStream);
ISheet sheet = workbook.GetSheetAt(0);
IEnumerator rows = sheet.GetRowEnumerator();
IRow dateRow = sheet.GetRow(5);
ImportHelper.JumpRows(rows, 6);
#region 列定义
int colFlow = 0;
//int colLocation = 0;//库位
int colItemCode = 1;//物料代码或参考物料号
//int colItemDescription = 2;//物料描述
int colUom = 3;//单位
#endregion
List<FlowDetail> flowDetailList = new List<FlowDetail>();
var uomDic = this.genericMgr.FindAll<Uom>().ToDictionary(d => d.Code, d => d);
if (string.IsNullOrWhiteSpace(flowCode))
{
var flowMasters = this.genericMgr.FindAll<FlowMaster>(" from FlowMaster where Type=?",
CodeMaster.OrderType.Distribution).ToList();
foreach (var flowMaster in flowMasters)
{
flowDetailList.AddRange(GetFlowDetails(flowMaster));
}
}
else
{
flowDetailList = GetFlowDetails(flowCode).ToList();
}
var flowDetailDic = flowDetailList.GroupBy(p => p.Flow, (k, g) => new { k, g }).ToDictionary(d => d.k, d => d.g);
List<MrpPlanLog> mrpPlanLogList = new List<MrpPlanLog>();
BusinessException businessException = new BusinessException();
while (rows.MoveNext())
{
Item item = null;
string uomCode = null;
string itemReference = null;
string flow = null;
HSSFRow row = (HSSFRow)rows.Current;
if (!ImportHelper.CheckValidDataRow(row, 0, 3))
{
break;//边界
}
string rowIndex = (row.RowNum + 1).ToString();
#region 读取路线
try
{
string flowCell = ImportHelper.GetCellStringValue(row.GetCell(colFlow));
if (flowCell != null && flowDetailDic.ContainsKey(flowCell))
{
flow = flowCell;
}
else
{
businessException.AddMessage(string.Format("读取路线出错,第{0}行.", rowIndex));
continue;
}
}
//.........这里部分代码省略.........
示例14: ReadShiftPlanFromXls
public List<MrpShiftPlan> ReadShiftPlanFromXls(Stream inputStream, DateTime startDate, DateTime endDate, string flow)
{
if (inputStream.Length == 0)
{
throw new BusinessException("Import.Stream.Empty");
}
HSSFWorkbook workbook = new HSSFWorkbook(inputStream);
ISheet sheet = workbook.GetSheetAt(0);
IEnumerator rows = sheet.GetRowEnumerator();
IRow dateRow = sheet.GetRow(2);
ImportHelper.JumpRows(rows, 3);
#region 列定义
int colFlow = 0;// 路线
int colItemCode = 1;//物料代码或参考物料号
//int colItemDescription = 2;//物料描述
int colUom = 3;//单位
#endregion
var shiftPlanList = new List<MrpShiftPlan>();
#region 读取数据
while (rows.MoveNext())
{
string itemCode = null;
string uomCode = null;
string flowCode = null;
HSSFRow row = (HSSFRow)rows.Current;
if (!ImportHelper.CheckValidDataRow(row, 0, 4))
{
break;//边界
}
string rowIndex = (row.RowNum + 1).ToString();
#region 读取路线
try
{
flowCode = ImportHelper.GetCellStringValue(row.GetCell(colFlow));
if (flowCode == null)
{
throw new BusinessException("生产线不能为空", rowIndex);
}
else
{
if (!string.IsNullOrWhiteSpace(flow) && flow != flowCode)
{
continue;
}
}
}
catch (Exception ex)
{
throw new BusinessException(ex.Message);
}
#endregion
#region 读取物料代码
try
{
itemCode = ImportHelper.GetCellStringValue(row.GetCell(colItemCode));
if (itemCode == null)
{
throw new BusinessException("Import.ShipPlan.ItemCode.Empty", rowIndex);
}
}
catch
{
throw new BusinessException("Import.ShipPlan.ItemCode.Error", rowIndex);
}
#endregion
#region 读取单位
try
{
uomCode = ImportHelper.GetCellStringValue(row.GetCell(colUom));
}
catch (Exception ex)
{
throw new BusinessException(ex.Message);
}
#endregion
#region 读取数量
try
{
for (int i = 5; ; i++)
{
ICell dateCell = dateRow.GetCell(i - ((i - 5) % 3));
#region 读取计划日期
DateTime planDate = DateTime.Now;
string weekOfYear = string.Empty;
if (dateCell != null && dateCell.CellType == CellType.NUMERIC)
{
planDate = dateCell.DateCellValue;
}
else
{
break;
}
//.........这里部分代码省略.........
示例15: ReadRccpPlanFromXls
public void ReadRccpPlanFromXls(Stream inputStream, DateTime startDate, DateTime endDate, bool isItemRef, com.Sconit.CodeMaster.TimeUnit dateType)
{
#region 判断
if (startDate > endDate)
{
throw new BusinessException("开始日期必须小于结束日期");
}
#endregion 判断
#region Import
if (inputStream.Length == 0)
{
throw new BusinessException("Import.Stream.Empty");
}
HSSFWorkbook workbook = new HSSFWorkbook(inputStream);
ISheet sheet = workbook.GetSheetAt(0);
IEnumerator rows = sheet.GetRowEnumerator();
IRow dateRow = sheet.GetRow(5);
ImportHelper.JumpRows(rows, 6);
var rccpPlanLogList = new List<RccpPlanLog>();
#region 列定义
int colFlow = 0;//路线
int colItemCode = 1;//物料代码或参考物料号
int colUom = 3;//单位
#endregion
BusinessException businessException = new BusinessException();
while (rows.MoveNext())
{
Item item = null;
string uomCode = null;
string itemReference = null;
string flowCode = null;
HSSFRow row = (HSSFRow)rows.Current;
if (!ImportHelper.CheckValidDataRow(row, 0, 3))
{
break;//边界
}
string rowIndex = (row.RowNum + 1).ToString();
#region 读取路线代码
flowCode = ImportHelper.GetCellStringValue(row.GetCell(colFlow));
#endregion
#region 读取物料代码
try
{
string itemCode = ImportHelper.GetCellStringValue(row.GetCell(colItemCode));
if (itemCode == null)
{
businessException.AddMessage(string.Format("物料不能为空,第{0}行", rowIndex));
continue;
}
if (isItemRef)
{
item = this.genericMgr.FindAll<Item>("from Item as i where i.ReferenceCode = ? ", new object[] { itemCode }, 0, 1).First();
itemReference = itemCode;
}
else
{
item = this.itemMgr.GetCacheItem(itemCode);
itemReference = item.ReferenceCode;
}
if (item == null)
{
businessException.AddMessage(string.Format("物料号{0}不存在,第{1}行.", itemCode, rowIndex));
continue;
}
if (item.ItemCategory != "MODEL")
{
businessException.AddMessage(string.Format("物料号{0}不是车型,第{1}行.", itemCode, rowIndex));
continue;
}
}
catch
{
businessException.AddMessage(string.Format("读取物料时出错,第{0}行.", rowIndex));
continue;
}
#endregion
#region 读取单位
try
{
string uomCell = ImportHelper.GetCellStringValue(row.GetCell(colUom));
uomCode = this.genericMgr.FindById<Uom>(uomCell).Code;
}
catch (Exception ex)
{
businessException.AddMessage(string.Format("读取单位出错,第{0}行." + ex.Message, rowIndex));
continue;
//.........这里部分代码省略.........