/// <summary> /// WMM-006 获取标签信息 /// </summary> /// <param name="barcodeData">箱条码</param> /// <returns>返回条码表实体</returns> public BarcodeInfo GetBarcode(string barcodeData, string asnRunsheetNo, BarcodeStatusConstants scanType, string loginUser, int scanMode = 1) { List <BarcodeInfo> barcodeInfos = dal.GetList("[BARCODE_DATA] = N'" + barcodeData + "' ", string.Empty); if (barcodeInfos.Count == 0) { throw new Exception("MC:0x00000276");///标签信息错误 } BarcodeInfo barcodeInfo = barcodeInfos.FirstOrDefault(); if (barcodeInfo == null) { throw new Exception("MC:0x00000276");///标签信息错误 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Invalid) { throw new Exception("MC:0x00000277");///标签已作废 } ///单号需要改变时则会有内容传输进行 if (!string.IsNullOrEmpty(asnRunsheetNo)) { barcodeInfo.AsnRunsheetNo = asnRunsheetNo; } ///校验标签创建单据是否与当前扫描单据相同 string validBarcodeCreateOrderSameAsAsnrunsheeno = new ConfigDAL().GetValueByCode("VALID_BARCODE_CREATE_ORDER_SAME_AS_ASNRUNSHEETNO"); if (validBarcodeCreateOrderSameAsAsnrunsheeno.ToLower() == "true") { if (scanType == BarcodeStatusConstants.Scaned && scanMode == 1) { int cnt = new ReceiveDetailDAL().GetCounts("[FID] = N'" + barcodeInfo.CreateSourceFid.GetValueOrDefault() + "' and [TRAN_NO] = N'" + asnRunsheetNo + "'"); if (cnt == 0) { throw new Exception("MC:0x00000278");///条码不属于本单据 } } } ///物料交接,使用出库单进行目标库区的收货操作 if (scanMode == 2) { OutputDetailInfo outputDetailInfo = new OutputDetailDAL().GetInfo(barcodeInfo.CreateSourceFid.GetValueOrDefault()); if (outputDetailInfo != null) { barcodeInfo.WmNo = outputDetailInfo.TargetWm; barcodeInfo.ZoneNo = outputDetailInfo.TargetZone; barcodeInfo.Dloc = outputDetailInfo.TargetDloc; } } ///是否在客户端扫描标签条码后更新状态为已扫描 string clientScanedBarcodeUpdateBarcodeStatusFlag = new ConfigDAL().GetValueByCode("CLIENT_SCANED_BARCODE_UPDATE_BARCODE_STATUS_FLAG"); if (clientScanedBarcodeUpdateBarcodeStatusFlag.ToLower() == "true") { string sql = BarcodeDAL.GetBarcodeUpdateSql((int)scanType , barcodeInfo.WmNo , barcodeInfo.ZoneNo , barcodeInfo.Dloc , barcodeInfo.AsnRunsheetNo , barcodeInfo.Fid.GetValueOrDefault() , loginUser); if (!CommonDAL.ExecuteNonQueryBySql(sql)) { throw new Exception("MC:0x00000276");///标签信息错误 } } return(barcodeInfo); }
/// <summary> /// 发货 /// </summary> /// <param name="rowsKeyValues"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool ResendInfos(List <string> rowsKeyValues, string loginUser) { ///入库单 List <ReceiveInfo> receiveInfos = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", "[ID]"); if (receiveInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } //int cnt = receiveInfos.Count(d => d.Status.GetValueOrDefault() != (int)WmmOrderStatusConstants.Completed); //if (cnt > 0) // throw new Exception("MC:0x00000344");///状态为已完成时才能进行发货 List <ReceiveDetailInfo> receiveDetailInfos = new ReceiveDetailDAL().GetList("[RECEIVE_FID] in ('" + string.Join("','", receiveInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", string.Empty); if (receiveDetailInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } List <BarcodeInfo> barcodeInfos = new BarcodeDAL().GetList("" + "[CREATE_SOURCE_FID] in ('" + string.Join("','", receiveDetailInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "') and " + "[BARCODE_STATUS] = " + (int)BarcodeStatusConstants.Inbound + "", string.Empty); if (barcodeInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } string sql = string.Empty; foreach (var receiveInfo in receiveInfos) { List <ReceiveDetailInfo> receiveDetails = receiveDetailInfos.Where(d => d.ReceiveFid.GetValueOrDefault() == receiveInfo.Fid.GetValueOrDefault()).ToList(); if (receiveDetails.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } List <BarcodeInfo> barcodes = barcodeInfos.Where(d => receiveDetails.Select(r => r.Fid.GetValueOrDefault()).Contains(d.CreateSourceFid.GetValueOrDefault())).ToList(); if (barcodes.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } sql += OutputBLL.CreateOutputByReceiveSql( receiveInfo, ///入库单 receiveDetails, ///入库单明细 barcodes, ///标签 string.Empty, ///目标仓库 string.Empty, ///目标存储区 null, ///出库类型 loginUser, ///操作用户 //receiveInfo.OrganizationFid,///操作机构 Guid.NewGuid(), string.Empty, ///承运人 string.Empty, ///联系电话 null, ///计划发货时间 null); ///计划到达时间 sql += "update [LES].[TT_WMM_RECEIVE] " + "set [STATUS] = " + (int)WmmOrderStatusConstants.Closed + ",[MODIFY_USER] = N'" + loginUser + "',[MODIFY_DATE] = GETDATE() " + "where [ID] = " + receiveInfo.ReceiveId + ";"; } ///执行 using (TransactionScope trans = new TransactionScope()) { if (!string.IsNullOrEmpty(sql)) { CommonDAL.ExecuteNonQueryBySql(sql); } trans.Complete(); } return(true); }
/// <summary> /// 提交(发布) /// </summary> /// <param name="rowsKeyValues"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool ReleaseInfos(List <string> rowsKeyValues, string loginUser) { ///入库单 List <PlanPullOrderInfo> planPullOrderInfos = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", "[ID]"); if (planPullOrderInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } StringBuilder @string = new StringBuilder(); foreach (var planPullOrderInfo in planPullOrderInfos) { if (planPullOrderInfo.OrderStatus.GetValueOrDefault() != (int)PullOrderStatusConstants.Created) { throw new Exception("MC:0x00000683");///状态必须为已创建 } ///当出入库单的拉动单号为空时,根据客户委托编号更新出入库单的进仓编号 if (!string.IsNullOrEmpty(planPullOrderInfo.CustTrustNo)) { List <ReceiveInfo> receiveInfos = new ReceiveDAL().GetList("" + "[ASN_NO] = N'" + planPullOrderInfo.CustTrustNo + "' and " + "LEN(ISNULL([RUNSHEET_NO],'')) = 0", string.Empty); List <ReceiveDetailInfo> receiveDetailInfos = new List <ReceiveDetailInfo>(); if (receiveInfos.Count > 0) { receiveDetailInfos = new ReceiveDetailDAL().GetList("" + "[RECEIVE_FID] in ('" + string.Join("','", receiveInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", string.Empty); } List <BarcodeInfo> barcodeInfos = new List <BarcodeInfo>(); if (receiveDetailInfos.Count > 0) { barcodeInfos = new BarcodeDAL().GetList("" + "[CREATE_SOURCE_FID] in ('" + string.Join("','", receiveDetailInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", string.Empty); } foreach (var receiveInfo in receiveInfos) { @string.AppendLine("update [LES].[TT_WMM_RECEIVE] " + "set [RUNSHEET_NO] = N'" + planPullOrderInfo.OrderCode + "' " + "where [ReceiveId] = " + receiveInfo.ReceiveId + ";"); foreach (var receiveDetailInfo in receiveDetailInfos) { @string.AppendLine("update [LES].[TT_WMM_RECEIVE_DETAIL] " + "set [RUNSHEET_NO] = N'" + planPullOrderInfo.OrderCode + "' " + "where [FID] = " + receiveDetailInfo.Fid + ";"); List <BarcodeInfo> barcodes = barcodeInfos.Where(d => d.CreateSourceFid.GetValueOrDefault() == receiveDetailInfo.Fid.GetValueOrDefault()).ToList(); foreach (var barcode in barcodes) { @string.AppendLine("update [LES].[TT_WMM_BARCODE] " + "set [RUNSHEET_NO] = N'" + planPullOrderInfo.OrderCode + "' " + "where [ID] = " + barcode.Id + ";"); } } } List <OutputInfo> outputInfos = new OutputDAL().GetList("[ASN_NO] = N'" + planPullOrderInfo.CustTrustNo + "' and LEN(ISNULL([RUNSHEET_NO],'')) = 0", string.Empty); foreach (var outputInfo in outputInfos) { @string.AppendLine("update [LES].[TT_WMM_OUTPUT] " + "set [RUNSHEET_NO] = N'" + planPullOrderInfo.OrderCode + "' " + "where [ID] = " + outputInfo.OutputId + ";"); @string.AppendLine("update [LES].[TT_WMM_OUTPUT_DETAIL] " + "set [RUNSHEET_NO] = N'" + planPullOrderInfo.OrderCode + "' " + "where [OUTPUT_FID] = N'" + outputInfo.Fid.GetValueOrDefault() + "' and [VALID_FLAG] = 1 and LEN(ISNULL([RUNSHEET_NO],'')) = 0;"); } } } @string.AppendLine("update [LES].[TT_MPM_PLAN_PULL_ORDER] set " + "[ORDER_STATUS] = " + (int)PullOrderStatusConstants.Released + "," + "[PUBLISH_TIME] = GETDATE()," + "[MODIFY_USER] = N'" + loginUser + "'," + "[MODIFY_DATE] = GETDATE() where " + "[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ");"); ///执行 using (TransactionScope trans = new TransactionScope()) { if (@string.Length > 0) { CommonDAL.ExecuteNonQueryBySql(@string.ToString()); } trans.Complete(); } return(true); }