| | |
| | | .AndIF(!string.IsNullOrWhiteSpace(model.ProductionTime), it => it.ProductionTime >= Convert.ToDateTime(model.ProductionTime)) |
| | | .AndIF(!string.IsNullOrWhiteSpace(model.InspectMark), it => it.InspectMark == model.InspectMark.Trim()) |
| | | .AndIF(!string.IsNullOrWhiteSpace(model.BitBoxMark), it => it.BitBoxMark == model.BitBoxMark.Trim()) |
| | | .AndIF(!string.IsNullOrWhiteSpace(model.Origin), it => it.Origin == model.Origin.Trim()) |
| | | .AndIF(!string.IsNullOrWhiteSpace(model.Origin), it => model.Origin.Trim().Contains(it.Origin)) |
| | | .And(m => m.SkuNo != "100099" && m.IsDel == "0" && m.Status == "0") |
| | | .ToExpression();//注意 这一句 不能少 |
| | | var total = 0; |
| | |
| | | } |
| | | |
| | | //获取标签信息(生成标签) |
| | | public List<BllBoxInfo> AddLabelBox(int imId, string isReset, decimal arriveQty, string productionTime, string expirationTime, string storeTime, int userId) |
| | | public List<BllBoxInfo> AddLabelBox(int imId, string isReset, decimal arriveQty, string productionTime, string expirationTime, string storeTime,string supplierLot, int userId) |
| | | { |
| | | try |
| | | { |
| | |
| | | zNum = Convert.ToInt32(pack.L1Num); |
| | | } |
| | | |
| | | if (packLevel <= 1)//包装等级小于1,按照1级标签打印 |
| | | if (packLevel < 1)//包装等级小于1,按照1级标签打印 |
| | | { |
| | | throw new Exception("包装信息有误,小于一级"); |
| | | } |
| | |
| | | var modelList = new List<BllBoxInfo>(); |
| | | |
| | | var addLotNo = ""; |
| | | if (arriveQty < 0) |
| | | if (arriveQty <= 0) |
| | | { |
| | | throw new Exception("到货数量不能小于0!"); |
| | | throw new Exception("到货数量不能小于等于0!"); |
| | | } |
| | | |
| | | Db.BeginTran(); |
| | | if (packLevel == 1) |
| | | { |
| | | #region 一级包装 |
| | |
| | | |
| | | if (isReset == "0") |
| | | { |
| | | var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList(); |
| | | if (labelCount.Count <=0) |
| | | //判断单据是否是余料退回单 |
| | | if (asn.Type == "4") |
| | | { |
| | | throw new Exception("当前单据明细还未生成标签,请选择重置批次选项为‘是’;"); |
| | | maxLotNoStr = asnList.LotNo; |
| | | maxBoxCode = label.Where(m=>m.LotNo == maxLotNoStr).Max(a => a.BoxNo); |
| | | if (string.IsNullOrWhiteSpace(maxLotNoStr)) |
| | | { |
| | | throw new Exception("车间余料退回单据批次不能为空"); |
| | | } |
| | | } |
| | | maxLotNoStr = label.Max(a => a.LotNo); |
| | | maxBoxCode = label.Max(a => a.BoxNo); |
| | | if (string.IsNullOrWhiteSpace(maxLotNoStr)) |
| | | else |
| | | { |
| | | maxLotNoStr = toDayTime.Substring(2, 6) + "0001"; |
| | | var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList(); |
| | | if (labelCount.Count <= 0) |
| | | { |
| | | throw new Exception("当前单据明细还未生成标签,请选择重置批次选项为‘是’;"); |
| | | } |
| | | maxLotNoStr = labelCount.Max(a => a.LotNo); |
| | | |
| | | if (string.IsNullOrWhiteSpace(maxLotNoStr)) |
| | | { |
| | | maxLotNoStr = toDayTime.Substring(2, 6) + "0001"; |
| | | } |
| | | maxBoxCode = label.Where(m => m.LotNo == maxLotNoStr).Max(a => a.BoxNo); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | LotNo = maxLotNoStr, |
| | | Standard = asnList.Standard, |
| | | PackageStandard = packStr, |
| | | SupplierLot = asnList.SupplierLot, |
| | | SupplierLot = supplierLot, |
| | | InspectMark = "0", |
| | | BitBoxMark = bNum > boxQty ? "1":"0", |
| | | InspectStatus = "", |
| | |
| | | string toDayTime2 = DateTime.Now.ToString("yyyyMMdd"); |
| | | if (isReset == "0") |
| | | { |
| | | var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList(); |
| | | if (labelCount.Count <= 0) |
| | | //判断单据是否是余料退回单 |
| | | if (asn.Type == "4") |
| | | { |
| | | throw new Exception("当前单据明细还未生成标签,请选择重置批次选项为‘是’;"); |
| | | maxCodestr2 = asnList.LotNo; |
| | | maxboxcode2 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo); |
| | | maxboxcode3 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo3);//支号 |
| | | if (string.IsNullOrWhiteSpace(maxCodestr2)) |
| | | { |
| | | throw new Exception("车间余料退回单据批次不能为空"); |
| | | } |
| | | } |
| | | var maxCode = label.Max(a => a.LotNo); |
| | | var boxCode1 = label.Max(a => a.BoxNo);//箱号 |
| | | var boxCode2 = label.Max(a => a.BoxNo3);//支号 |
| | | maxCodestr2 = maxCode; |
| | | maxboxcode2 = boxCode1; |
| | | maxboxcode3 = boxCode2; |
| | | if (string.IsNullOrWhiteSpace(maxCodestr2)) |
| | | else |
| | | { |
| | | maxCodestr2 = toDayTime2.Substring(2, 6) + "0001"; |
| | | var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList(); |
| | | if (labelCount.Count <= 0) |
| | | { |
| | | throw new Exception("当前单据明细还未生成标签,请选择重置批次选项为‘是’;"); |
| | | } |
| | | maxCodestr2 = labelCount.Max(a => a.LotNo); ; |
| | | |
| | | if (string.IsNullOrWhiteSpace(maxCodestr2)) |
| | | { |
| | | maxCodestr2 = toDayTime2.Substring(2, 6) + "0001"; |
| | | } |
| | | maxboxcode2 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo);//箱号; |
| | | maxboxcode3 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo3);//支号; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | Db.Updateable(asnList).ExecuteCommand(); |
| | | } |
| | | } |
| | | |
| | | Db.CommitTran(); |
| | | return modelList; |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Db.RollbackTran(); |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | //根据入库单号过去单据下所有批次号 |
| | | public List<string> GetLotNoListByAsn(string asnNo) |
| | | { |
| | | try |
| | | { |
| | | var data = new List<string>(); |
| | | var asnList = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo).ToList(); |
| | | if (asnList.Count == 0) |
| | | { |
| | | throw new Exception("未查询到该单据号的信息"); |
| | | } |
| | | |
| | | foreach (var item in asnList) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(item.LotNo)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var strList = item.LotNo.Split(";"); |
| | | foreach (var str in strList) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(str)) |
| | | { |
| | | continue; |
| | | } |
| | | data.Add(str); |
| | | } |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | //删除单据下单个或多个批次的标签 |
| | | public void DelLabelByAsnNo(string asnNo,string lotNo, int userId) |
| | | { |
| | | try |
| | | { |
| | | var asnList = Db.Queryable<BllArrivalNoticeDetail>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo).ToList(); |
| | | if (asnList.Count == 0) |
| | | { |
| | | throw new Exception("未查询到该单据号的信息"); |
| | | } |
| | | |
| | | Db.BeginTran(); |
| | | |
| | | //批次为空:当前单据下所有批次的标签全部删除; 有批次:伤处当前单据下当前批次的标签 |
| | | if (string.IsNullOrWhiteSpace(lotNo)) //删除全部标签 |
| | | { |
| | | var labelList = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo).ToList(); |
| | | if (labelList.Count(m => m.Status != "0") >= 1) |
| | | { |
| | | throw new Exception("当前单据批次的标签已有已使用,不能删除"); |
| | | } |
| | | |
| | | foreach (var item in asnList) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(item.LotNo)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | item.LotNo = ""; |
| | | Db.Updateable(item).ExecuteCommand(); |
| | | |
| | | } |
| | | Db.Deleteable(labelList).ExecuteCommand(); |
| | | } |
| | | else //删除固定批次标签 |
| | | { |
| | | var labelList = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo && m.LotNo == lotNo).ToList(); |
| | | if (labelList.Count(m=>m.Status != "0") >= 1 ) |
| | | { |
| | | throw new Exception("当前单据批次的标签已有已使用,不能删除"); |
| | | } |
| | | |
| | | foreach (var item in asnList) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(item.LotNo) || item.LotNo!=lotNo) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var strList = item.LotNo.Split(";"); |
| | | var updateLotNo = ""; |
| | | foreach (var str in strList) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(str) || str == lotNo) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(updateLotNo)) |
| | | { |
| | | updateLotNo = str; |
| | | } |
| | | else |
| | | { |
| | | updateLotNo += ";" + str; |
| | | } |
| | | |
| | | } |
| | | |
| | | item.LotNo = updateLotNo; |
| | | Db.Updateable(item).ExecuteCommand(); |
| | | |
| | | } |
| | | Db.Deleteable(labelList).ExecuteCommand(); |
| | | } |
| | | |
| | | Db.CommitTran(); |
| | | |
| | | var msg = $"删除了单据号:{asnNo}"; |
| | | if (!string.IsNullOrWhiteSpace(lotNo)) |
| | | { |
| | | msg += $"、批次号:{lotNo}"; |
| | | } |
| | | msg += "的标签信息"; |
| | | |
| | | new OperationASNServer().AddLogOperationAsn("入库作业", "物料标签", asnNo, "删除", msg, userId); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Db.RollbackTran(); |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |