/// <summary> /// 撤销条码状态 /// </summary> /// <param name="barcode"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool UndoBarcodeStatus(string barcode, string loginUser) { List <BarcodeStatusInfo> barcodeStatusInfos = new BarcodeStatusDAL().GetListByPage("[BARCODE_DATA] = N'" + barcode + "'", "[ID] desc", 1, 2); if (barcodeStatusInfos.Count == 0) { throw new Exception("MC:0x00000276");///标签信息错误 } if (barcodeStatusInfos.Count == 1) { throw new Exception("MC:0x00000276");///标签信息错误 } ///获取上一个条码状态 BarcodeStatusInfo barcodeStatusInfo = barcodeStatusInfos[1]; string sql = BarcodeDAL.GetBarcodeUpdateSql(barcodeStatusInfo.BarcodeStatus.GetValueOrDefault() , barcodeStatusInfo.WmNo , barcodeStatusInfo.ZoneNo , barcodeStatusInfo.Dloc , barcodeStatusInfo.AsnRunsheetNo , barcodeStatusInfo.BarcodeFid.GetValueOrDefault() , loginUser); if (!CommonDAL.ExecuteNonQueryBySql(sql)) { throw new Exception("MC:0x00000276");///标签信息错误 } return(true); }
/// <summary> /// WMM-006 标签拣配 /// </summary> /// <param name="PickupInfos"></param> /// <returns></returns> public bool PickupInfos(List <string> rowsKeyValues, string loginUser) { List <BarcodeInfo> barcodeInfos = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ") ", string.Empty); if (barcodeInfos.Count == 0) { throw new Exception("MC:0x00000276");///标签信息错误 } string sql = string.Empty; foreach (var barcodeInfo in barcodeInfos) { if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Invalid) { throw new Exception("MC:0x00000277");///标签已作废 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Frozen) { throw new Exception("MC:0x00000361");///标签已冻结 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Outbound) { throw new Exception("MC:0x00000364");///标签已出库 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Shiped) { throw new Exception("MC:0x00000365");///标签已发货 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Scaned) { throw new Exception("MC:0x00000366");///标签已扫描 } sql += BarcodeDAL.GetBarcodeUpdateSql((int)BarcodeStatusConstants.PickedUp , barcodeInfo.WmNo , barcodeInfo.ZoneNo , barcodeInfo.Dloc , barcodeInfo.AsnRunsheetNo , barcodeInfo.Fid.GetValueOrDefault() , loginUser); } ///是否在客户端扫描标签条码后更新状态为已扫描 string client_scaned_barcode_update_barcode_status_flag = new ConfigDAL().GetValueByCode("CLIENT_SCANED_BARCODE_UPDATE_BARCODE_STATUS_FLAG"); ///执行 using (TransactionScope trans = new TransactionScope()) { if (!string.IsNullOrEmpty(sql) && client_scaned_barcode_update_barcode_status_flag.ToLower() == "true") { CommonDAL.ExecuteNonQueryBySql(sql); } trans.Complete(); } return(true); }
/// <summary> /// 撤销发布 /// </summary> /// <param name="rowsKeyValues"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool CancelInfos(List <string> rowsKeyValues, string loginUser) { ///入库单 List <OutputInfo> outputInfos = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", "[ID]"); if (outputInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } //if (outputInfos.Count(d => d.Status.GetValueOrDefault() != (int)WmmOrderStatusConstants.Published) > 0) // throw new Exception("MC:0x00000457");///状态必须为已发布 ///入库单明细 List <OutputDetailInfo> outputDetailInfos = new OutputDetailDAL().GetList("[OUTPUT_FID] in ('" + string.Join("','", outputInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", "[ID]"); if (outputDetailInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } int cnt = new BarcodeDAL().GetCounts("" + "[CREATE_SOURCE_FID] in ('" + string.Join("','", outputDetailInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "') and " + "[BARCODE_STATUS] = " + (int)BarcodeStatusConstants.PickedUp + ""); if (cnt > 0) { throw new Exception("MC:0x00000458");///条码已被扫描无法撤销 } string sql = "update [LES].[TT_WMM_OUTPUT] set " + "[STATUS] = " + (int)WmmOrderStatusConstants.Created + "," + "[MODIFY_USER] = N'" + loginUser + "' ," + "[MODIFY_DATE] = GETDATE() where " + "[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ");"; sql += "update [LES].[TT_WMM_OUTPUT_DETAIL] set " + "[ROW_NO] = NULL," + "[MODIFY_DATE] = GETDATE()," + "[MODIFY_USER] = N'" + loginUser + "' where " + "[ID] in (" + string.Join(",", outputDetailInfos.Select(d => d.Id).ToArray()) + ");"; ///执行 using (TransactionScope trans = new TransactionScope()) { if (!string.IsNullOrEmpty(sql)) { CommonDAL.ExecuteNonQueryBySql(sql); } trans.Complete(); } return(true); }
/// <summary> /// WMM-007 提交入库单 /// </summary> /// <param name="orderlist"></param> /// <param name="barCodeList"></param> /// <returns></returns> //public bool SubmitReceiveOrder(List<ReceiveAndOutputInfo> importOrderList, List<BarcodeInfo> barCodeList, bool emergencyFlag, string loginUser) //{ // ///TODO:条码状态使用枚举 // StringBuilder SqlStrBuilder = new StringBuilder(); // string receiveSqlStr = string.Empty; // string receiveDetilsSqlStr = string.Empty; // string barCodeSqlStr = string.Empty; // List<ReceiveInfo> orderList = new ReceiveDAL().GetList(string.Format("[ID] IN ({0})", string.Join(",", importOrderList.Select(w => w.OrderId).ToArray())), string.Empty); // List<ReceiveDetailInfo> detailList = new ReceiveDetailDAL().GetList(string.Format("[ID] IN ({0})", string.Join(",", importOrderList.Select(w => w.DetailId).ToArray())), string.Empty); // ///获取明细零件所有的检验模式 // List<PartInspectionModeInfo> qmischeckmodeinfolist = new PartInspectionModeDAL().GetList(string.Format("[PART_NO] IN ({0})", string.Join("','", detailList.GroupBy(w => new { w.PartNo }).Select(w => w.Key.PartNo).ToArray())), string.Empty); // ///获取检验模式变更数据 // var differencelist = from e in detailList // join o in qmischeckmodeinfolist on new { e.PartNo, B = e.SupplierNum } equals new { o.PartNo, B = o.SupplierNum } into ords // from o in ords.DefaultIfEmpty() // select new // { // e.Fid, // e.Id, // e.InspectionMode // }; // foreach (ReceiveInfo receiveInfo in orderList) // { // #region 更新入库单状态 // receiveSqlStr = @"UPDATE [LES].[TT_WMM_RECEIVE] SET [STATUS] = 50 ,[MODIFY_DATE] = GETDATE(),[MODIFY_USER] = N'{0}' WHERE [ID] ={1};"; //入库单Sql脚本拼接 // receiveSqlStr = string.Format(receiveSqlStr, loginUser, receiveInfo.Id); // SqlStrBuilder.AppendLine(receiveSqlStr); // #endregion // foreach (ReceiveDetailInfo receiveDetailInfo in detailList.Where(w => w.ReceiveFid.GetValueOrDefault() == receiveInfo.Fid.GetValueOrDefault())) // { // ReceiveAndOutputInfo orderItem = importOrderList.FirstOrDefault(w => w.DetailId == receiveDetailInfo.Id); // if (orderItem != null) // { // #region 更新实际箱数和实际数 为差异做准备 // receiveDetailInfo.ActualBoxNum = orderItem.ActualBoxNum; // receiveDetailInfo.ActualQty = orderItem.ActualQty; // #endregion // #region 扫箱更新条码信息 // if (orderItem.IsScanBox) // { // foreach (BarcodeInfo barcodeItem in barCodeList.Where(w => w.AsnRunsheetNo == receiveDetailInfo.OrderNo && w.PartNo == receiveDetailInfo.PartNo && w.SupplierNum == receiveDetailInfo.SupplierNum && w.RunsheetNo == receiveDetailInfo.RunsheetNo)) // { // barCodeSqlStr = @"UPDATE [LES].[TT_WMM_BARCODE] SET [BARCODE_STATUS] = 20,[WM_NO] = '{0}',[ZONE_NO] = '{1}',[DLOC] = '{2}', [MODIFY_USER] = N'{3}',[MODIFY_DATE] = GETDATE() WHERE [ID] = {4};";//条码表明细拼接 // barCodeSqlStr = string.Format(barCodeSqlStr, orderItem.TargetWm, orderItem.TargetZone, orderItem.TargetDloc, loginUser, barcodeItem.Id); // SqlStrBuilder.AppendLine(barCodeSqlStr); // } // } // #endregion // #region 更新入库单明细信息 // receiveDetilsSqlStr = @"UPDATE [LES].[TT_WMM_RECEIVE_DETAIL] SET [ACTUAL_BOX_NUM] = {0} , [ACTUAL_QTY] = {1} , [MODIFY_USER] = N'{2}',MODIFY_DATE = GETDATE() WHERE ID = {3};";//入库单明细Sql脚本拼接 // //更新入库单明细实际箱数、实际数量、修改人、修改时间 // receiveDetilsSqlStr = string.Format(receiveDetilsSqlStr, orderItem.ActualBoxNum, orderItem.ActualQty, loginUser, receiveDetailInfo.Id); // SqlStrBuilder.AppendLine(receiveDetilsSqlStr); // #endregion // } // else // { // #region 更新入库单明细信息 // receiveDetilsSqlStr = @"UPDATE [LES].[TT_WMM_RECEIVE_DETAIL] SET [MODIFY_USER] = N'{0}',MODIFY_DATE = GETDATE() WHERE ID = {1};";//入库单明细Sql脚本拼接 // //更新入库单明细实际箱数、实际数量、修改人、修改时间 // receiveDetilsSqlStr = string.Format(receiveDetilsSqlStr, loginUser, receiveDetailInfo.Id); // SqlStrBuilder.AppendLine(receiveDetilsSqlStr); // #endregion // } // #region 新增交易记录 // TranDetailsInfo tranInfo = new TranDetailsInfo(); // new BLL.LES.TranDetailsBLL().GetTranDetailsInfo(receiveInfo, ref tranInfo); // new BLL.LES.TranDetailsBLL().GetTranDetailsInfo(receiveDetailInfo, ref tranInfo); // string tranSqlStr = new TranDetailsDAL().GetInsertSql(tranInfo); // SqlStrBuilder.AppendLine(tranSqlStr); // #endregion // } // #region 若检验模式有变化则需要将变化的物料提交至QMIS检验任务中间表,并生成同步数据任务 // string receiveMaterialRecheckInspectMode = new ConfigDAL().GetValueByCode("RECEIVE_MATERIAL_RECHECK_INSPECT_MODE"); // if (bool.TryParse(receiveMaterialRecheckInspectMode, out bool receiveMaterialRecheckInspectModeTF)) // throw new Exception("MC:1x00000031");///系统配置错误 // if (receiveMaterialRecheckInspectModeTF) // { // #region 插入脚本初始化 // string qmisSqlStr = @"INSERT INTO [LES].[TI_IFM_QMIS_ASN_PULL_SHEET] ( //FID, //LOG_FID, //PLANT, //ASN_NO, //ORDER_NO, //PART_NO, //SUPPLIER_NO, //TOTAL_NO, //CHECK_MODE, //ARRIVAL_DATE, //ZS_FLAG, //VALID_FLAG, //PROCESS_FLAG, //PROCESS_TIME, //CREATE_USER, //CREATE_DATE, //MODIFY_USER, //MODIFY_DATE // ) // VALUES ({0});"; // #endregion // long[] ids = differencelist.Where(w => w.Fid.GetValueOrDefault() == receiveInfo.Fid.GetValueOrDefault()).Select(w => w.Id).ToArray(); // if (detailList.Where(w => ids.Contains(w.Id)).Count() > 0) // { // #region 生成日志 // Guid logFid = Guid.NewGuid();///定义日志关联键 // SqlStrBuilder.AppendLine(CommonBLL.GetCreateOutboundLogSql("QMIS", logFid, "LES-QMIS-002", receiveInfo.ReceiveNo, loginUser)); // #endregion // foreach (ReceiveDetailInfo receiveDetailInfo in detailList.Where(w => ids.Contains(w.Id))) // { // #region 生成检验中间表 // string sqltiifmqmischeckmode = "NEWID()"///FID // + ",N'" + logFid.ToString() + "'"///LOG_FID // + ",N'" + receiveInfo.Plant + "'"///Plant // + ",N'" + receiveInfo.ReceiveNo + "'"///ASN_NO // + ",N'" + receiveDetailInfo.RunsheetNo + "'"///ORDER_NO // + ",N'" + receiveDetailInfo.PartNo + "'"///PART_NO // + ",N'" + receiveDetailInfo.SupplierNum + "'"///SUPPLIER_NO // + ",N'" + receiveDetailInfo.ActualQty + "'"///TOTAL_NO // + ",'" + differencelist.FirstOrDefault(w => w.Id == receiveDetailInfo.Id).InspectionMode + "'" ///CHECK_MODE // + ",null"///ARRIVAL_DATE // + ",null"///ZS_FLAG // + ",1"///VALID_FLAG // + "," + (int)ProcessFlagResuitsConstants.Created///ORDER_STATUS // + ",null" // + ",N'" + loginUser + "'" // + ",GETDATE()"///CREATE_DATE // + ",null"///MODIFY_USER // + ",null";///MODIFY_DATE // #endregion // SqlStrBuilder.AppendLine(string.Format(qmisSqlStr, sqltiifmqmischeckmode)); // } // } // } // #endregion // #region 生成出库单 // //将入库明细中是否产生出库单标记㊵为true的数据过滤出来,系统配置中SAME_ZONE_SAME_FINAL_ZONE_VALID_FLAG相同存储区相同中转存储区验证标记, // //默认为true,控制了同一张入库单的明细中不会出现不同的出库目标存储区㊷, // //所以此时只需直接根据入库单及明细复制出相应的出库单及明细,并以出库目标存储区㊷作为出库单的目标存储区入库实际数量⑱作为出库需求数量, // //若系统配置标记为false,则将过滤出来的入库明细数据根据其出库目标存储区进行分组,并按分组情况生成多个出库单,出库单状态为已发布WMM - 011 // string sameZoneSameFinalZoneValidFlag = new ConfigDAL().GetValueByCode("SAME_ZONE_SAME_FINAL_ZONE_VALID_FLAG"); // if (bool.TryParse(sameZoneSameFinalZoneValidFlag, out bool sameZoneSameFinalZoneValidFlagTF)) // throw new Exception("MC:1x00000031");///系统配置错误 // bool isoutput = receiveInfo.IsOutput ?? false; // if (sameZoneSameFinalZoneValidFlagTF) // { // #region 根据入库单赋值出库单 // ///出库单号 // string outputNo = new SeqDefineDAL().GetCurrentCode("OUTPUT_NO"); // int rowNo = 0; // if (isoutput) // { // Guid outputFid = Guid.NewGuid(); // string finalWm = string.Empty; // string finalZone = string.Empty; // string fargetDloc = string.Empty; // foreach (ReceiveDetailInfo receiveDetailInfo in detailList.Where(w => w.ReceiveFid.GetValueOrDefault() == receiveInfo.Fid.GetValueOrDefault())) // { // ReceiveAndOutputInfo orderItem = importOrderList.FirstOrDefault(w => w.DetailId == receiveDetailInfo.Id); // rowNo++; // if (orderItem != null) // { // finalWm = receiveDetailInfo.FinalWm; // finalZone = receiveDetailInfo.FinalZone; // fargetDloc = receiveDetailInfo.Dloc; // string detailsStr = "insert into LES.[TT_WMM_OUTPUT_DETAIL] " // + "(FID, OUTPUT_FID, PLANT, SUPPLIER_NUM, WM_NO, ZONE_NO, DLOC, TRAN_NO, TARGET_WM, TARGET_ZONE, TARGET_DLOC, PART_NO, PART_CNAME, REQUIRED_BOX_NUM, REQUIRED_QTY, ACTUAL_BOX_NUM, ACTUAL_QTY, PACKAGE, PACKAGE_MODEL, BARCODE_DATA, MEASURING_UNIT_NO, IDENTIFY_PART_NO, PART_ENAME, DOCK, ASSEMBLY_LINE, BOX_PARTS, SEQUENCE_NO, PICKUP_SEQ_NO, RDC_DLOC, INHOUSE_PACKAGE, INHOUSE_PACKAGE_MODEL, SUPPLIER_NUM_SHEET, BOX_PARTS_SHEET, ORDER_NO, ITEM_NO, RUNSHEET_NO, REPACKAGE_FLAG, ROW_NO, ORIGIN_PLACE, SALE_UNIT_PRICE, PART_PRICE, PART_CLS, PICKUP_NUM, PICKUP_QTY, IS_SCAN_BOX, PACKAGE_LENGTH, PACKAGE_WIDTH, PACKAGE_HEIGHT, PERPACKAGE_GROSS_WEIGHT, COMMENTS, VALID_FLAG, CREATE_USER, CREATE_DATE) select " // + "'" + receiveDetailInfo.Fid // + "', N'" // + outputFid // + "', PLANT, SUPPLIER_NUM, N'" // + receiveDetailInfo.TargetWm // + "', N'" // + receiveDetailInfo.TargetZone // + "', N'" // + receiveDetailInfo.TargetDloc // + "', N'" // + outputNo + "', N'" // + receiveDetailInfo.FinalWm // + "', N'" // + receiveDetailInfo.FinalZone // + "', N'" // + receiveDetailInfo.Dloc + "'" // + ", PART_NO, PART_CNAME, " // + orderItem.ActualBoxNum + ", " // + orderItem.ActualQty + ", NULL, NULL, PACKAGE, PACKAGE_MODEL, NULL, MEASURING_UNIT_NO, IDENTIFY_PART_NO, PART_ENAME, DOCK, ASSEMBLY_LINE, BOX_PARTS, SEQUENCE_NO, PICKUP_SEQ_NO, RDC_DLOC, INHOUSE_PACKAGE, INHOUSE_PACKAGE_MODEL, SUPPLIER_NUM_SHEET, BOX_PARTS_SHEET, ORDER_NO, ITEM_NO" + ", N'" // + receiveInfo.ReceiveNo + "', NULL, " // + rowNo + ", ORIGIN_PLACE, NULL, NULL, PART_CLS, NULL, NULL, IS_SCAN_BOX, PACKAGE_LENGTH, PACKAGE_WIDTH, PACKAGE_HEIGHT, PERPACKAGE_GROSS_WEIGHT" // + ", NULL, 1, N'" // + loginUser + "', GETDATE() " // + "from LES.TT_WMM_RECEIVE_DETAIL with(nolock) where [FID] = N'" + receiveDetailInfo.Fid.GetValueOrDefault() + "';"; // SqlStrBuilder.AppendLine(detailsStr); // } // } // string outPutOrderStr = "insert into LES.[TT_WMM_OUTPUT] " // + "(FID, OUTPUT_NO, PLANT, SUPPLIER_NUM, WM_NO, ZONE_NO, T_WM_NO, T_ZONE_NO, T_DOCK, PART_BOX_CODE, SEND_TIME, OUTPUT_TYPE, TRAN_TIME, OUTPUT_REASON, BOOK_KEEPER, CONFIRM_FLAG, PLAN_NO, ASN_NO, RUNSHEET_NO, ASSEMBLY_LINE, PLANT_ZONE, WORKSHOP, TRANS_SUPPLIER_NUM, PART_TYPE, SUPPLIER_TYPE, RUNSHEET_CODE, ERP_FLAG, LOGICAL_PK, BUSINESS_PK, ROUTE, REQUEST_TIME, CUST_CODE, CUST_NAME, COST_CENTER, ORGANIZATION_FID, CONFIRM_USER, CONFIRM_DATE, LIABLE_USER, LIABLE_DATE, FINANCE_USER, FINANCE_DATE, SUM_PART_QTY, SUM_OF_PRICE, STATUS, CONVEYANCE, CARRIER_TEL, SUM_WEIGHT, SUM_VOLUME, PLAN_SHIPPING_TIME, PLAN_DELIVERY_TIME, COMMENTS, VALID_FLAG, CREATE_USER, CREATE_DATE) select " // + "N'" // + outputFid // + "', N'" // + outputNo // + "', PLANT, SUPPLIER_NUM, N'" // + receiveInfo.WmNo // + "', N'" // + receiveInfo.ZoneNo // + "', N'" // + finalWm // + "', N'" // + finalZone // + "'" // + ", DOCK, PART_BOX_CODE, GETDATE(), " // + (int)OutboundTypeConstants.NormalOutbound // + ", NULL, NULL, BOOK_KEEPER, NULL, NULL, NULL, N'" // + receiveInfo.ReceiveNo // + "'" // + ", NULL, NULL, NULL, NULL, NULL, SUPPLIER_TYPE, NULL, NULL, NULL, NULL" // + ", ROUTE, NULL, CUST_CODE, CUST_NAME, COST_CENTER, N'" // + receiveInfo.OrganizationFid + "', NULL, NULL, NULL, NULL, NULL, NULL" // + ", " // + importOrderList.Where(w => w.OrderId == receiveInfo.Id).Sum(w => w.ActualQty).ToString("F0") // + ", NULL, " // + (int)WmmOrderStatusConstants.Published + ", N'" // + string.Empty + "', N'" ///conveyance // + string.Empty + "'" ///carrierTel // + ", " // + receiveInfo.SumWeight + ", " // + receiveInfo.SumVolume + ", N'" // + receiveInfo.PlanShippingTime + "', N'" // + receiveInfo.PlanDeliveryTime + "', NULL, 1, N'" // + loginUser + "', GETDATE() " // + "from LES.[TT_WMM_RECEIVE] with(nolock) where [FID] = N'" // + receiveInfo.Fid.GetValueOrDefault() + "';"; // SqlStrBuilder.AppendLine(outPutOrderStr); // } // #endregion // } // else // { // #region 根据入库单分单并复制出库单 // if (isoutput) // { // var list = detailList.Where(w => w.ReceiveFid.GetValueOrDefault() == receiveInfo.Fid.GetValueOrDefault()).GroupBy(w => new { w.FinalWm, w.FinalZone, w.FinalDloc }).Select(w => new { w.Key.FinalWm, w.Key.FinalZone, w.Key.FinalDloc }); // foreach (var item in list) // { // Guid outputFid = Guid.NewGuid(); // string finalWm = string.Empty; // string finalZone = string.Empty; // string fargetDloc = string.Empty; // int rowNo = 0; // string outputNo = new SeqDefineDAL().GetCurrentCode("OUTPUT_NO"); // foreach (var receiveDetailInfo in detailList.Where(w => w.FinalWm == item.FinalWm && w.FinalZone == item.FinalZone && w.Dloc == item.FinalDloc)) // { // ReceiveAndOutputInfo orderItem = importOrderList.FirstOrDefault(w => w.DetailId == receiveDetailInfo.Id); // rowNo++; // if (orderItem != null) // { // finalWm = receiveDetailInfo.FinalWm; // finalZone = receiveDetailInfo.FinalZone; // fargetDloc = receiveDetailInfo.Dloc; // string detailsStr = "insert into LES.[TT_WMM_OUTPUT_DETAIL] " // + "(FID, OUTPUT_FID, PLANT, SUPPLIER_NUM, WM_NO, ZONE_NO, DLOC, TRAN_NO, TARGET_WM, TARGET_ZONE, TARGET_DLOC, PART_NO, PART_CNAME, REQUIRED_BOX_NUM, REQUIRED_QTY, ACTUAL_BOX_NUM, ACTUAL_QTY, PACKAGE, PACKAGE_MODEL, BARCODE_DATA, MEASURING_UNIT_NO, IDENTIFY_PART_NO, PART_ENAME, DOCK, ASSEMBLY_LINE, BOX_PARTS, SEQUENCE_NO, PICKUP_SEQ_NO, RDC_DLOC, INHOUSE_PACKAGE, INHOUSE_PACKAGE_MODEL, SUPPLIER_NUM_SHEET, BOX_PARTS_SHEET, ORDER_NO, ITEM_NO, RUNSHEET_NO, REPACKAGE_FLAG, ROW_NO, ORIGIN_PLACE, SALE_UNIT_PRICE, PART_PRICE, PART_CLS, PICKUP_NUM, PICKUP_QTY, IS_SCAN_BOX, PACKAGE_LENGTH, PACKAGE_WIDTH, PACKAGE_HEIGHT, PERPACKAGE_GROSS_WEIGHT, COMMENTS, VALID_FLAG, CREATE_USER, CREATE_DATE) select " // + "'" + receiveDetailInfo.Fid // + "', N'" // + outputFid // + "', PLANT, SUPPLIER_NUM, N'" // + receiveDetailInfo.TargetWm // + "', N'" // + receiveDetailInfo.TargetZone // + "', N'" // + receiveDetailInfo.TargetDloc // + "', N'" // + outputNo + "', N'" // + receiveDetailInfo.FinalWm // + "', N'" // + receiveDetailInfo.FinalZone // + "', N'" // + receiveDetailInfo.Dloc + "'" // + ", PART_NO, PART_CNAME, " // + orderItem.ActualBoxNum + ", " // + orderItem.ActualQty + ", NULL, NULL, PACKAGE, PACKAGE_MODEL, NULL, MEASURING_UNIT_NO, IDENTIFY_PART_NO, PART_ENAME, DOCK, ASSEMBLY_LINE, BOX_PARTS, SEQUENCE_NO, PICKUP_SEQ_NO, RDC_DLOC, INHOUSE_PACKAGE, INHOUSE_PACKAGE_MODEL, SUPPLIER_NUM_SHEET, BOX_PARTS_SHEET, ORDER_NO, ITEM_NO" + ", N'" // + receiveInfo.ReceiveNo + "', NULL, " // + rowNo + ", ORIGIN_PLACE, NULL, NULL, PART_CLS, NULL, NULL, IS_SCAN_BOX, PACKAGE_LENGTH, PACKAGE_WIDTH, PACKAGE_HEIGHT, PERPACKAGE_GROSS_WEIGHT" // + ", NULL, 1, N'" // + loginUser + "', GETDATE() " // + "from LES.TT_WMM_RECEIVE_DETAIL with(nolock) where [FID] = N'" + receiveDetailInfo.Fid.GetValueOrDefault() + "';"; // SqlStrBuilder.AppendLine(detailsStr); // } // } // string outPutOrderStr = "insert into LES.[TT_WMM_OUTPUT] " // + "(FID, OUTPUT_NO, PLANT, SUPPLIER_NUM, WM_NO, ZONE_NO, T_WM_NO, T_ZONE_NO, T_DOCK, PART_BOX_CODE, SEND_TIME, OUTPUT_TYPE, TRAN_TIME, OUTPUT_REASON, BOOK_KEEPER, CONFIRM_FLAG, PLAN_NO, ASN_NO, RUNSHEET_NO, ASSEMBLY_LINE, PLANT_ZONE, WORKSHOP, TRANS_SUPPLIER_NUM, PART_TYPE, SUPPLIER_TYPE, RUNSHEET_CODE, ERP_FLAG, LOGICAL_PK, BUSINESS_PK, ROUTE, REQUEST_TIME, CUST_CODE, CUST_NAME, COST_CENTER, ORGANIZATION_FID, CONFIRM_USER, CONFIRM_DATE, LIABLE_USER, LIABLE_DATE, FINANCE_USER, FINANCE_DATE, SUM_PART_QTY, SUM_OF_PRICE, STATUS, CONVEYANCE, CARRIER_TEL, SUM_WEIGHT, SUM_VOLUME, PLAN_SHIPPING_TIME, PLAN_DELIVERY_TIME, COMMENTS, VALID_FLAG, CREATE_USER, CREATE_DATE) select " // + "N'" // + outputFid // + "', N'" // + outputNo // + "', PLANT, SUPPLIER_NUM, N'" // + receiveInfo.WmNo // + "', N'" // + receiveInfo.ZoneNo // + "', N'" // + finalWm // + "', N'" // + finalZone // + "'" // + ", DOCK, PART_BOX_CODE, GETDATE(), " // + (int)OutboundTypeConstants.NormalOutbound // + ", NULL, NULL, BOOK_KEEPER, NULL, NULL, NULL, N'" // + receiveInfo.ReceiveNo // + "'" // + ", NULL, NULL, NULL, NULL, NULL, SUPPLIER_TYPE, NULL, NULL, NULL, NULL" // + ", ROUTE, NULL, CUST_CODE, CUST_NAME, COST_CENTER, N'" // + receiveInfo.OrganizationFid + "', NULL, NULL, NULL, NULL, NULL, NULL" // + ", " // + importOrderList.Where(w => w.OrderId == receiveInfo.Id).Sum(w => w.ActualQty).ToString("F0") // + ", NULL, " // + (int)WmmOrderStatusConstants.Published + ", N'" // + string.Empty + "', N'" ///conveyance // + string.Empty + "'" ///carrierTel // + "," // + receiveInfo.SumWeight + ", " // + receiveInfo.SumVolume + ", N'" // + receiveInfo.PlanShippingTime + "', N'" // + receiveInfo.PlanDeliveryTime + "', NULL, 1, N'" // + loginUser + "', GETDATE() " // + "from LES.[TT_WMM_RECEIVE] with(nolock) where [FID] = N'" // + receiveInfo.Fid.GetValueOrDefault() + "';"; // SqlStrBuilder.AppendLine(outPutOrderStr); // } // } // #endregion // } // #endregion // #region 器具包装随货入库交易数据 // //系统配置ENABLE_PACKAGE_MANAGEMENT_FLAG是否启用器具管理标记,默认为true,⑰以及包装型号⑲等数据产生器具包装随货入库交易数据PKG-000 // string enablePackageManagementFlag = new ConfigDAL().GetValueByCode("ENABLE_PACKAGE_MANAGEMENT_FLAG"); // if (bool.TryParse(enablePackageManagementFlag, out bool enablePackageManagementFlagTF)) // throw new Exception("MC:1x00000031");///系统配置错误 // if (enablePackageManagementFlagTF) // { // } // #endregion // #region 不满足需求物料生成新拉动单 // if (emergencyFlag) // { // ///TODO: // } // #endregion // } // using (TransactionScope trans = new TransactionScope()) // { // if (!CommonDAL.ExecuteNonQueryBySql(SqlStrBuilder.ToString())) // throw new Exception("MC:3x00000013");///TODO:提示是信息修改 // trans.Complete(); // } // return true; //} /// <summary> /// WMM-024 出库单提交 /// </summary> /// <param name="orderJsonStr"></param> /// <param name="barJsonStr"></param> /// <param name="emergencyFlag"></param> /// <param name="loginUser"></param> /// <returns></returns> //public bool SubmitOutputOrder(List<ReceiveAndOutputInfo> importOrderList, List<BarcodeInfo> barCodeList, bool emergencyFlag, string loginUser) //{ // ///TODO:条码状态使用枚举 // StringBuilder SqlStrBuilder = new StringBuilder(); // string outSqlStr = string.Empty; // string outDetilsSqlStr = string.Empty; // string barCodeSqlStr = string.Empty; // List<OutputInfo> orderList = new OutputDAL().GetList(string.Format("[ID] IN ({0})", string.Join(",", importOrderList.Select(w => w.OrderId).ToArray())), string.Empty); // List<OutputDetailInfo> detailList = new OutputDetailDAL().GetList(string.Format("[ID] IN ({0})", string.Join(",", importOrderList.Select(w => w.DetailId).ToArray())), string.Empty); // foreach (OutputInfo outputInfo in orderList) // { // outSqlStr = @"UPDATE [LES].[TT_WMM_OUTPUT] SET [STATUS] = 50 ,[MODIFY_DATE] = GETDATE(),[MODIFY_USER] = N'{0}' WHERE [ID] ={1};"; // outSqlStr = string.Format(outSqlStr, loginUser, outputInfo.Id); // SqlStrBuilder.AppendLine(outSqlStr); // ///TODO:并更新对应的拉动单或ASN单据状态 // foreach (OutputDetailInfo outDetailInfo in detailList.Where(w => w.Fid == outputInfo.Fid)) // { // ReceiveAndOutputInfo orderItem = importOrderList.FirstOrDefault(w => w.DetailId == outputInfo.Id); // if (orderItem != null) // { // #region 更新实际箱数和实际数 为差异做准备 // outDetailInfo.ActualBoxNum = orderItem.ActualBoxNum; // outDetailInfo.ActualQty = orderItem.ActualQty; // #endregion // #region 扫箱更新条码信息 // if (orderItem.IsScanBox) // { // foreach (BarcodeInfo barcodeItem in barCodeList.Where(w => w.AsnRunsheetNo == orderItem.OrderNo && w.PartNo == orderItem.PartNo && w.SupplierNum == orderItem.SupplierNum)) // { // barCodeSqlStr = "UPDATE [LES].[TT_WMM_BARCODE] SET [BARCODE_STATUS] = 40,[WM_NO] = '{0}',[ZONE_NO] = '{1}',[DLOC] = '{2}', [MODIFY_USER] = '{3}',[MODIFY_DATE] = GETDATE() WHERE [BARCODE_DATA] = '{4}'";//条码表明细拼接 // barCodeSqlStr = string.Format(barCodeSqlStr, orderItem.TargetWm, orderItem.TargetZone, orderItem.TargetDloc, loginUser, barcodeItem.BarcodeData); // SqlStrBuilder.AppendLine(barCodeSqlStr); // } // } // #endregion // #region 新增交易记录 // TranDetailsInfo tranInfo = new TranDetailsInfo(); // new BLL.LES.TranDetailsBLL().GetTranDetailsInfo(outputInfo, ref tranInfo); // new BLL.LES.TranDetailsBLL().GetTranDetailsInfo(outDetailInfo, ref tranInfo); // string tranSqlStr = new TranDetailsDAL().GetInsertSql(tranInfo); // SqlStrBuilder.AppendLine(tranSqlStr); // #endregion // } // } // } // using (TransactionScope trans = new TransactionScope()) // { // if (!CommonDAL.ExecuteNonQueryBySql(SqlStrBuilder.ToString())) // throw new Exception("MC:0x00000173");///TODO:提示信息修改 // trans.Complete(); // } // return true; //} /// <summary> /// WMM-028 拣配提交 /// </summary> /// <param name="outputIds"></param> /// <param name="barcodeIds"></param> /// <returns></returns> public bool SubmitPickupData(List <long> outputIds, List <long> barcodeIds, string loginUser) { ///TODO:状态替换为枚举 StringBuilder stringBuilder = new StringBuilder(); string outSqlStr = string.Empty; string outDetilsSqlStr = string.Empty; string barCodeSqlStr = string.Empty; List <OutputInfo> orderList = new OutputDAL().GetList(string.Format("[ID] IN ({0})", string.Join(",", outputIds)), string.Empty); List <OutputDetailInfo> detailList = new OutputDetailDAL().GetList(string.Format("[OUTPUT_FID] IN ('{0}')", string.Join("','", orderList.Select(w => w.Fid).ToArray())), string.Empty); List <BarcodeInfo> barcodelist = new BarcodeDAL().GetList(string.Format("[ID] IN ({0})", string.Join(",", barcodeIds)), string.Empty); foreach (OutputInfo outputinfo in orderList) { #region 更新出库单 outSqlStr = "UPDATE [LES].[TT_WMM_OUTPUT] SET [STATUS] = 30 ,[MODIFY_DATE] = GETDATE(),[MODIFY_USER] = '{0}' WHERE [ID] ={1};"; outSqlStr = string.Format(outSqlStr, loginUser, outputinfo.OutputId); stringBuilder.AppendLine(outSqlStr); #endregion foreach (OutputDetailInfo outputdetailinfo in detailList) { int actualBoxNum = (outputdetailinfo.ActualBoxNum ?? 0); decimal actualQty = (outputdetailinfo.ActualQty ?? 0); foreach (BarcodeInfo barcodeinfo in barcodelist.Where(w => w.AsnRunsheetNo == outputinfo.OutputNo && w.RunsheetNo == outputdetailinfo.RunsheetNo && w.PartNo == outputdetailinfo.PartNo && w.SupplierNum == outputdetailinfo.SupplierNum )) { #region 累加实出箱数和实出数量 actualBoxNum += 1; actualQty += (barcodeinfo.CurrentQty ?? 0); #endregion #region 更新标签表 barCodeSqlStr = @"UPDATE [LES].[TT_WMM_BARCODE] SET [BARCODE_STATUS] = 30,[MODIFY_USER] = N'{0}',[MODIFY_DATE] = GETDATE() WHERE [ID] = {1};";//条码表明细拼接 barCodeSqlStr = string.Format(barCodeSqlStr, loginUser, barcodeinfo.Id); stringBuilder.AppendLine(barCodeSqlStr); #endregion } #region 更新出库单明细 outDetilsSqlStr = "UPDATE [LES].[TT_WMM_OUTPUT_DETAIL] SET [PICKUP_NUM] = {0},[PICKUP_QTY] = {1},[MODIFY_DATE]= GETDATE() ,[MODIFY_USER] = N'{2}' WHERE ID = {3};"; outDetilsSqlStr = string.Format(outDetilsSqlStr, actualBoxNum, actualQty, loginUser, outputdetailinfo.Id); stringBuilder.AppendLine(outDetilsSqlStr); #endregion } } using (TransactionScope trans = new TransactionScope()) { if (!CommonDAL.ExecuteNonQueryBySql(stringBuilder.ToString())) { throw new Exception("MC:0x00000173");///TODO:提示信息修改 } trans.Complete(); } return(true); }
/// <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 ResendInfos(List <string> rowsKeyValues, string loginUser) { ///入库单 List <OutputInfo> outputInfos = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", "[ID]"); if (outputInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } //int cnt = outputInfos.Count(d => d.Status.GetValueOrDefault() != (int)WmmOrderStatusConstants.Closed); //if (cnt > 0) // throw new Exception("MC:0x00000342");///状态为已关闭时才能进行发货 List <OutputDetailInfo> outputDetailInfos = new OutputDetailDAL().GetList("[OUTPUT_FID] in ('" + string.Join("','", outputInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", string.Empty); if (outputDetailInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } List <BarcodeInfo> barcodeInfos = new BarcodeDAL().GetList("" + "[CREATE_SOURCE_FID] in ('" + string.Join("','", outputDetailInfos.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 outputInfo in outputInfos) { List <OutputDetailInfo> outputDetails = outputDetailInfos.Where(d => d.OutputFid.GetValueOrDefault() == outputInfo.Fid.GetValueOrDefault()).ToList(); if (outputDetails.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } List <BarcodeInfo> barcodes = barcodeInfos.Where(d => outputDetails.Select(r => r.Fid.GetValueOrDefault()).Contains(d.CreateSourceFid.GetValueOrDefault())).ToList(); if (barcodes.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } sql += CreateOutputByOutputSql( outputInfo, outputDetails, barcodes, "", "", null, loginUser, outputInfo.Fid, "", "", null, null); sql += "update [LES].[TT_WMM_OUTPUT] " + "set [STATUS] = " + (int)WmmOrderStatusConstants.Closed + ",[MODIFY_USER] = N'" + loginUser + "',[MODIFY_DATE] = GETDATE() " + "where [ID] = " + outputInfo.OutputId + ";"; } ///执行 using (TransactionScope trans = new TransactionScope()) { if (!string.IsNullOrEmpty(sql)) { CommonDAL.ExecuteNonQueryBySql(sql); } trans.Complete(); } return(true); }
/// <summary> /// GetReceiveCompleteDealSql /// </summary> /// <param name="vmiReceiveInfo"></param> /// <param name="vmiReceiveDetailInfos"></param> /// <param name="barcodeInfos"></param> /// <param name="loginUser"></param> /// <param name="emergencyFlag"></param> /// <returns></returns> public string GetReceiveCompleteDealSql(VmiReceiveInfo vmiReceiveInfo, List <VmiReceiveDetailInfo> vmiReceiveDetailInfos, List <BarcodeInfo> barcodeInfos, string loginUser) { ///获取系统配置 Dictionary <string, string> configs = new ConfigDAL().GetValuesByCodes(new string[] { "VALID_VMI_RECEIVE_ACTUAL_QTY_EQUAL_SCANED_QTY_FLAG", "LES_TRAN_DATA_ENABLE_FLAG", "VMI_RECEIVE_MATERIAL_RECHECK_INSPECT_MODE", "INBOUND_SYNC_OUTBOUND_ENABLE_FLAG", "ENABLE_VMI_PACKAGE_MANAGEMENT_FLAG" }); ///入库单客户端提交时处理语句 ///WEB端为完成操作 ///TODO:考虑增加是否支持单据多次收货的开关 StringBuilder @string = new StringBuilder(); ///更新入库单状态 @string.AppendLine(GetReceiveStatusUpdateSql(vmiReceiveInfo.Id, WmmOrderStatusConstants.Completed, loginUser)); /// foreach (VmiReceiveDetailInfo vmiReceiveDetailInfo in vmiReceiveDetailInfos) { List <BarcodeInfo> barcodes = barcodeInfos.Where(d => d.CreateSourceFid.GetValueOrDefault() == vmiReceiveDetailInfo.Fid.GetValueOrDefault()).ToList(); if (barcodes.Count == 0) { barcodes = barcodeInfos.Where(w => w.AsnRunsheetNo == vmiReceiveDetailInfo.TranNo && w.PartNo == vmiReceiveDetailInfo.PartNo && w.SupplierNum == vmiReceiveDetailInfo.SupplierNum && w.RunsheetNo == vmiReceiveDetailInfo.RunsheetNo).ToList(); } ///是否校验VMI实收数量等于扫描数量 configs.TryGetValue("VALID_VMI_RECEIVE_ACTUAL_QTY_EQUAL_SCANED_QTY_FLAG", out string valid_vmi_receive_actual_qty_equal_scaned_qty_flag); if (!string.IsNullOrEmpty(valid_vmi_receive_actual_qty_equal_scaned_qty_flag) && valid_vmi_receive_actual_qty_equal_scaned_qty_flag.ToLower() == "true") { if (barcodes.Sum(d => d.CurrentQty.GetValueOrDefault()) != vmiReceiveDetailInfo.ActualQty.GetValueOrDefault()) { throw new Exception("MC:0x00000258");///标签扫描数量与单据不一致 } if (barcodes.Count != vmiReceiveDetailInfo.ActualBoxNum.GetValueOrDefault()) { throw new Exception("MC:0x00000258");///标签扫描数量与单据不一致 } } ///入库单号、零件号、供应商、单号 foreach (BarcodeInfo barcodeInfo in barcodes) { ///来源不为空时获取来源 if (!string.IsNullOrEmpty(vmiReceiveDetailInfo.WmNo) && !string.IsNullOrEmpty(vmiReceiveDetailInfo.ZoneNo)) { @string.AppendLine(BarcodeDAL.GetBarcodeUpdateSql( (int)BarcodeStatusConstants.Inbound, vmiReceiveDetailInfo.WmNo, vmiReceiveDetailInfo.ZoneNo, vmiReceiveDetailInfo.Dloc, vmiReceiveDetailInfo.TranNo, barcodeInfo.Fid.GetValueOrDefault(), loginUser)); } else { @string.AppendLine(BarcodeDAL.GetBarcodeUpdateSql( (int)BarcodeStatusConstants.Inbound, vmiReceiveDetailInfo.TargetWm, vmiReceiveDetailInfo.TargetZone, vmiReceiveDetailInfo.TargetDloc, vmiReceiveDetailInfo.TranNo, barcodeInfo.Fid.GetValueOrDefault(), loginUser)); } } ///更新入库单明细信息 @string.AppendLine(GetReceiveDetailActualQtyUpdateSql( vmiReceiveDetailInfo.Id, vmiReceiveDetailInfo.ActualBoxNum.GetValueOrDefault(), vmiReceiveDetailInfo.ActualQty.GetValueOrDefault(), loginUser)); } ///转换为普通入库单进行处理 List <ReceiveDetailInfo> receiveDetailInfos = ReceiveDetailBLL.GetReceiveDetailInfos(vmiReceiveDetailInfos); ReceiveInfo receiveInfo = ReceiveBLL.CreateReceiveInfo(loginUser); ReceiveBLL.GetReceiveInfo(vmiReceiveInfo, ref receiveInfo); ///是否启用LES交易记录创建 configs.TryGetValue("LES_TRAN_DATA_ENABLE_FLAG", out string les_tran_data_enable_flag); if (!string.IsNullOrEmpty(les_tran_data_enable_flag) && les_tran_data_enable_flag.ToLower() == "true") { @string.AppendLine(ReceiveBLL.GetTranDetailsInsertSql(receiveInfo, receiveDetailInfos, (int)WmmTranTypeConstants.Inbound, loginUser)); } ///系统配置中RECEIVE_MATERIAL_RECHECK_INSPECT_MODE入库免检物料重新校验检验模式标记,默认为true ///若该标记为true时将入库明细中的㊺免检物料比对检验模式基础数据中物料的当前检验模式 ///若检验模式有变化则需要将变化的物料提交至QMIS检验任务中间表,并生成同步数据任务,否则忽略此逻辑(此项逻辑可以考虑异步实现) ///VMI入库免检物料重新校验检验模式标记 configs.TryGetValue("VMI_RECEIVE_MATERIAL_RECHECK_INSPECT_MODE", out string vmi_receive_material_recheck_inspect_mode); if (!string.IsNullOrEmpty(vmi_receive_material_recheck_inspect_mode) && vmi_receive_material_recheck_inspect_mode.ToLower() == "true") { @string.AppendLine(PartInspectionModeBLL.ReloadInspectionMode(receiveInfo, ref receiveDetailInfos, loginUser)); } ///将入库明细中是否产生出库单标记㊵为true的数据过滤出来,系统配置中SAME_ZONE_SAME_FINAL_ZONE_VALID_FLAG相同存储区相同中转存储区验证标记, ///默认为true,控制了同一张入库单的明细中不会出现不同的出库目标存储区㊷, ///所以此时只需直接根据入库单及明细复制出相应的出库单及明细,并以出库目标存储区㊷作为出库单的目标存储区入库实际数量⑱作为出库需求数量, ///若系统配置标记为false,则将过滤出来的入库明细数据根据其出库目标存储区进行分组,并按分组情况生成多个出库单,出库单状态为已发布WMM - 011 ///入库后同步生成出库指令启用标记 configs.TryGetValue("INBOUND_SYNC_OUTBOUND_ENABLE_FLAG", out string inboundSyncOutboundEnableFlag); if (!string.IsNullOrEmpty(inboundSyncOutboundEnableFlag) && inboundSyncOutboundEnableFlag.ToLower() == "true") { @string.AppendLine(OutputBLL.CreateOutputByReceiveSql(receiveInfo, receiveDetailInfos, barcodeInfos, loginUser)); } ///系统配置ENABLE_PACKAGE_MANAGEMENT_FLAG是否启用器具管理标记,默认为true ///若该标记为ture时需要根据实收包装数量⑰以及包装型号⑲等数据产生器具包装随货入库交易数据PCM-002 ///是否启用VMI器具管理标记 configs.TryGetValue("ENABLE_VMI_PACKAGE_MANAGEMENT_FLAG", out string enablePackageManagementFlag); if (!string.IsNullOrEmpty(enablePackageManagementFlag) && enablePackageManagementFlag.ToLower() == "true") { @string.AppendLine(PackageTranDetailBLL.CreatePackageTranDetailsSql(receiveDetailInfos, loginUser)); } return(@string.ToString()); }
/// <summary> /// 完成 /// </summary> /// <param name="rowsKeyValues"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool CompleteInfos(List <string> rowsKeyValues, string loginUser) { ///入库单必须为已发布状态⑫才可以进行完成操作 ///根据单据中物料需求数量进行物料入库,并标记状态⑫为50.已完成 List <VmiReceiveInfo> vmiReceiveInfos = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", "[ID]"); if (vmiReceiveInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } List <VmiReceiveDetailInfo> vmiReceiveDetailInfos = new VmiReceiveDetailDAL().GetList("[RECEIVE_FID] in ('" + string.Join("','", vmiReceiveInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", "[ID]"); if (vmiReceiveDetailInfos.Count == 0) { throw new Exception("MC:0x00000367");///入库单没有明细 } ///获取系统配置 Dictionary <string, string> configs = new ConfigDAL().GetValuesByCodes(new string[] { "CLIENT_SCANED_BARCODE_UPDATE_BARCODE_STATUS_FLAG", "COMPLETE_VMI_RECEIVE_ACTUAL_QTY_EQUALS_REQUIRED_WHEN_NULL" }); ///完成VMI入库单时实收数量为空则等于需求数量 configs.TryGetValue("COMPLETE_VMI_RECEIVE_ACTUAL_QTY_EQUALS_REQUIRED_WHEN_NULL", out string complete_vmi_receive_actual_qty_equals_required_when_null); if (!string.IsNullOrEmpty(complete_vmi_receive_actual_qty_equals_required_when_null) && complete_vmi_receive_actual_qty_equals_required_when_null.ToLower() == "true") { foreach (var vmiReceiveDetailInfo in vmiReceiveDetailInfos) { if (vmiReceiveDetailInfo.ActualBoxNum == null) { vmiReceiveDetailInfo.ActualBoxNum = vmiReceiveDetailInfo.RequiredBoxNum; } if (vmiReceiveDetailInfo.ActualQty == null) { vmiReceiveDetailInfo.ActualQty = vmiReceiveDetailInfo.RequiredQty; } } } /// List <BarcodeInfo> barcodeInfos = new List <BarcodeInfo>(); ///是否在客户端扫描标签条码后更新状态为已扫描 configs.TryGetValue("CLIENT_SCANED_BARCODE_UPDATE_BARCODE_STATUS_FLAG", out string client_scaned_barcode_update_barcode_status_flag); if (!string.IsNullOrEmpty(client_scaned_barcode_update_barcode_status_flag) && client_scaned_barcode_update_barcode_status_flag.ToLower() == "true") { ///获取已扫描的标签 barcodeInfos = new BarcodeDAL().GetList("[ASN_RUNSHEET_NO] in ('" + string.Join("','", vmiReceiveInfos.Select(d => d.ReceiveNo).ToArray()) + "') and [BARCODE_STATUS] = " + (int)BarcodeStatusConstants.Scaned + "", string.Empty); } /// StringBuilder @string = new StringBuilder(); foreach (var vmiReceiveInfo in vmiReceiveInfos) { if (vmiReceiveInfo.Status.GetValueOrDefault() != (int)WmmOrderStatusConstants.Published) { throw new Exception("MC:0x00000148");///已提交的入库单才能进行确认操作 } List <VmiReceiveDetailInfo> detailInfos = vmiReceiveDetailInfos.Where(d => d.ReceiveFid.GetValueOrDefault() == vmiReceiveInfo.Fid.GetValueOrDefault()).ToList(); if (detailInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } ///获取已扫描的标签 List <BarcodeInfo> barcodes = barcodeInfos.Where(d => d.AsnRunsheetNo == vmiReceiveInfo.ReceiveNo).ToList(); ///拼接多张入库单 @string.AppendLine(GetReceiveCompleteDealSql(vmiReceiveInfo, detailInfos, barcodes, loginUser)); } using (TransactionScope trans = new TransactionScope()) { if (@string.Length > 0) { CommonDAL.ExecuteNonQueryBySql(@string.ToString()); } trans.Complete(); } return(true); }
/// <summary> /// 发布(提交) /// </summary> /// <param name="id"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool ReleaseInfos(List <string> rowsKeyValues, string loginUser) { ///入库单 List <VmiReceiveInfo> vmiReceiveInfos = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", "[ID]"); if (vmiReceiveInfos.Count == 0) { throw new Exception("MC:0x00000084");///数据错误 } ///入库单明细 List <VmiReceiveDetailInfo> vmiReceiveDetailInfos = new VmiReceiveDetailDAL().GetList("[RECEIVE_FID] in ('" + string.Join("','", vmiReceiveInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", "[ID]"); if (vmiReceiveDetailInfos.Count == 0) { throw new Exception("MC:0x00000367");///入库单没有明细 } ///获取系统配置 Dictionary <string, string> configs = new ConfigDAL().GetValuesByCodes(new string[] { "RELEASE_VMI_RECEIVE_ACTUAL_QTY_EQUALS_REQUIRED", "MANUAL_VMI_RECEIVE_ORDER_RELEASE_CREATE_BARCODE", "RELEASE_VMI_RECEIVE_LOAD_PART_INSPECTION_MODE" }); ///已生成的标签 List <BarcodeInfo> barcodeInfos = new BarcodeDAL().GetList("" + "[BARCODE_STATUS] = " + (int)BarcodeStatusConstants.Created + " and " + "[CREATE_SOURCE_FID] in ('" + string.Join("','", vmiReceiveDetailInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", string.Empty); ///执行语句 StringBuilder @string = new StringBuilder(); foreach (var vmiReceiveInfo in vmiReceiveInfos) { ///一般手工创建入库单会用到此功能,入库单必须为10.已创建状态⑫ if (vmiReceiveInfo.Status.GetValueOrDefault() != (int)WmmOrderStatusConstants.Created) { throw new Exception("MC:0x00000683");///状态必须为已创建 } ///VMI入库单明细 List <VmiReceiveDetailInfo> vmiReceiveDetails = vmiReceiveDetailInfos.Where(d => d.ReceiveFid.GetValueOrDefault() == vmiReceiveInfo.Fid.GetValueOrDefault()).ToList(); ///VMI入库单对应的标签数据 List <BarcodeInfo> barcodes = barcodeInfos.Where(d => vmiReceiveDetails.Select(f => f.Fid.GetValueOrDefault()).Contains(d.CreateSourceFid.GetValueOrDefault())).ToList(); ///将VMI入库单明细对象转换为普通入库单对象,方便后续函数处理 List <ReceiveDetailInfo> receiveDetailInfos = ReceiveDetailBLL.GetReceiveDetailInfos(vmiReceiveDetails); ///手工创建VMI入库单时创建条码标签 configs.TryGetValue("MANUAL_VMI_RECEIVE_ORDER_RELEASE_CREATE_BARCODE", out string manual_vmi_receive_order_release_create_barcode); if (!string.IsNullOrEmpty(manual_vmi_receive_order_release_create_barcode) && manual_vmi_receive_order_release_create_barcode.ToLower() == "true") { @string.AppendLine(MaterialPullingCommonBLL.GetCreateBarcodesSql(receiveDetailInfos, barcodes, loginUser)); } /// ReceiveInfo receiveInfo = ReceiveBLL.CreateReceiveInfo(loginUser); ///VmiReceiveInfo -> ReceiveInfo ReceiveBLL.GetReceiveInfo(vmiReceiveInfo, ref receiveInfo); ///VMI入库单发布时是否加载物料检验模式,TODO:此处函数内有与入库单共用的系统配置 configs.TryGetValue("RELEASE_VMI_RECEIVE_LOAD_PART_INSPECTION_MODE", out string release_vmi_receive_load_part_inspection_mode); if (!string.IsNullOrEmpty(release_vmi_receive_load_part_inspection_mode) && release_vmi_receive_load_part_inspection_mode.ToLower() == "true") { @string.AppendLine(PartInspectionModeBLL.LoadInspectionMode(ref receiveInfo, ref receiveDetailInfos, loginUser)); } ///行号更新 int rowNo = 0; ///发布VMI入库单时实收数量默认等于需求数量 configs.TryGetValue("RELEASE_VMI_RECEIVE_ACTUAL_QTY_EQUALS_REQUIRED", out string release_vmi_receive_actual_qty_equals_required); foreach (var receiveDetailInfo in receiveDetailInfos) { if (!string.IsNullOrEmpty(release_vmi_receive_actual_qty_equals_required) && release_vmi_receive_actual_qty_equals_required.ToLower() == "true") { if (receiveDetailInfo.ActualBoxNum == null) { receiveDetailInfo.ActualBoxNum = receiveDetailInfo.RequiredBoxNum; } if (receiveDetailInfo.ActualQty == null) { receiveDetailInfo.ActualQty = receiveDetailInfo.RequiredQty; } } ///更新入库单明细需要注意不能覆盖明细中原内容 @string.AppendLine("update [LES].[TT_WMM_VMI_RECEIVE_DETAIL] set " + "[ROW_NO] = " + ++rowNo + "," + (receiveDetailInfo.ActualBoxNum == null ? string.Empty : "[ACTUAL_BOX_NUM] = " + receiveDetailInfo.ActualBoxNum.GetValueOrDefault() + ",") + (receiveDetailInfo.ActualQty == null ? string.Empty : "[ACTUAL_QTY] = " + receiveDetailInfo.ActualQty.GetValueOrDefault() + ",") + (receiveDetailInfo.InspectionMode == null ? string.Empty : "[INSPECTION_MODE] = " + receiveDetailInfo.InspectionMode.GetValueOrDefault() + ",") + (string.IsNullOrEmpty(receiveDetailInfo.SupplierNum) ? "[SUPPLIER_NUM] = N'" + receiveInfo.SupplierNum + "'," : string.Empty) + "[WM_NO] = N'" + receiveInfo.WmNo + "'," + "[ZONE_NO] = N'" + receiveInfo.ZoneName + "'," + "[TARGET_WM] = N'" + receiveInfo.WmNo + "'," + "[TARGET_ZONE] = N'" + receiveInfo.ZoneNo + "'," + (string.IsNullOrEmpty(receiveDetailInfo.RunsheetNo) ? "[RUNSHEET_NO] = N'" + receiveInfo.RunsheetNo + "'," : string.Empty) + "[MODIFY_DATE] = GETDATE()," + "[MODIFY_USER] = N'" + loginUser + "' where " + "[ID] = " + receiveDetailInfo.Id + ";"); } ///更新入库单 @string.AppendLine("update [LES].[TT_WMM_VMI_RECEIVE] set " + "[SUM_PART_QTY] = " + vmiReceiveDetails.Sum(d => d.RequiredQty.GetValueOrDefault()) + "," + "[SUM_OF_PRICE] = " + vmiReceiveDetails.Sum(d => d.PartPrice.GetValueOrDefault()) + "," + "[SUM_WEIGHT] = " + vmiReceiveDetails.Sum(d => d.SumWeight.GetValueOrDefault()) + "," + "[SUM_VOLUME] = " + vmiReceiveDetails.Sum(d => d.SumVolume.GetValueOrDefault()) + "," + "[SUM_PACKAGE_QTY] = " + vmiReceiveDetails.Sum(d => d.RequiredBoxNum.GetValueOrDefault()) + "," + //"[INSPECTION_FLAG] = " + (receiveInfo.InspectionFlag.GetValueOrDefault() ? 1 : 0) + "," + "[STATUS] = " + (int)WmmOrderStatusConstants.Published + "," + "[MODIFY_USER] = N'" + loginUser + "' ," + "[MODIFY_DATE] = GETDATE() where " + "[ID] = " + vmiReceiveInfo.Id + ";"); } ///删除已删除VMI入库单明细的标签 @string.AppendLine("update [LES].[TT_WMM_BARCODE] " + "set [VALID_FLAG] = 0 " + "where [CREATE_SOURCE_FID] in (select [FID] from [LES].[TT_WMM_VMI_RECEIVE_DETAIL] with(nolock) " + "where [VALID_FLAG] = 0 and [RECEIVE_FID] in ('" + string.Join("','", vmiReceiveInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "'));"); ///执行 using (TransactionScope trans = new TransactionScope()) { if (@string.Length > 0) { CommonDAL.ExecuteNonQueryBySql(@string.ToString()); } trans.Complete(); } return(true); }
/// <summary> /// 同步 /// </summary> /// <param name="loginUser"></param> public static void Sync(string loginUser) { ///获取没有处理的送货单数据 List <SrmBarcodeInfo> srmBarcodeInfos = new SrmBarcodeBLL().GetList("[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty); if (srmBarcodeInfos.Count == 0) { return; } ///获取对应的ASN单据,TODO:单据类型过滤?原始单据号是指? List <ReceiveInfo> receiveInfos = new ReceiveBLL().GetList("[ASN_NO] in ('" + string.Join("','", srmBarcodeInfos.Select(d => d.SourceOrderCode).ToArray()) + "')", string.Empty); if (receiveInfos.Count == 0) { return; } List <ReceiveDetailInfo> receiveDetailInfos = new ReceiveDetailBLL().GetList("[RECEIVE_FID] in ('" + string.Join("','", receiveInfos.Select(d => d.Fid.GetValueOrDefault()).ToArray()) + "')", string.Empty); if (receiveDetailInfos.Count == 0) { return; } ///供应商 List <SupplierInfo> supplierInfos = new SupplierBLL().GetList("[SUPPLIER_NUM] in ('" + string.Join("','", receiveInfos.Select(d => d.SupplierNum).ToArray()) + "')", string.Empty); if (supplierInfos.Count == 0) { return; } ///获取相关物料仓储信息 List <PartsStockInfo> partsStockInfos = new PartsStockBLL().GetList("" + "[PART_NO] in ('" + string.Join("','", srmBarcodeInfos.Select(d => d.PartNo).ToArray()) + "') and " + "[WM_NO] in ('" + string.Join("','", receiveInfos.Select(d => d.WmNo).ToArray()) + "')", string.Empty); ///获取相关包装器具基础信息 List <PackageApplianceInfo> packageApplianceInfos = new List <PackageApplianceInfo>(); if (partsStockInfos.Count > 0) { ///标准包装 List <string> packageModels = partsStockInfos. Where(d => !string.IsNullOrEmpty(d.PackageModel)). Select(d => d.PackageModel).ToList(); ///入库包装 packageModels.AddRange(partsStockInfos. Where(d => !string.IsNullOrEmpty(d.InboundPackageModel) && !packageModels.Contains(d.InboundPackageModel)). Select(d => d.InboundPackageModel).ToList()); ///上线包装 packageModels.AddRange(partsStockInfos. Where(d => !string.IsNullOrEmpty(d.InhousePackageModel) && !packageModels.Contains(d.InhousePackageModel)). Select(d => d.InhousePackageModel).ToList()); /// packageApplianceInfos = new PackageApplianceBLL().GetList("[PAKCAGE_NO] in ('" + string.Join("','", packageModels.ToArray()) + "')", string.Empty); } /// StringBuilder @string = new StringBuilder(); /// List <long> dealedIds = new List <long>(); /// foreach (SrmBarcodeInfo srmBarcodeInfo in srmBarcodeInfos) { ///获取入库单。TODO:需要两个编号才能定位到唯一明细数据 ReceiveInfo receiveInfo = receiveInfos.FirstOrDefault(d => d.AsnNo == srmBarcodeInfo.SourceOrderCode); ///标签数据与ASN单据数据到达LES可能存在先后顺序 if (receiveInfo == null) { continue; } ReceiveDetailInfo receiveDetailInfo = receiveDetailInfos.FirstOrDefault(d => d.PartNo == srmBarcodeInfo.PartNo && d.ReceiveFid.GetValueOrDefault() == receiveInfo.Fid.GetValueOrDefault() && d.RunsheetNo == srmBarcodeInfo.SourceOrderCode); if (receiveDetailInfo == null) { continue; } ///供应商 SupplierInfo supplierInfo = supplierInfos.FirstOrDefault(d => d.SupplierNum == receiveInfo.SupplierNum); if (supplierInfo == null) { @string.AppendLine("update [LES].[TI_IFM_SRM_BARCODE] set " + "[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Suspend + "," + "[PROCESS_TIME] = GETDATE()," + "[COMMENTS] = N'0x00000229' where " +///供应商信息不存在 "[ID] = " + srmBarcodeInfo.Id + ";"); continue; } ///物料仓储信息 PartsStockInfo partsStockInfo = partsStockInfos.FirstOrDefault(d => d.PartNo == srmBarcodeInfo.PartNo && d.SupplierNum == supplierInfo.SupplierNum && d.WmNo == receiveInfo.WmNo && d.ZoneNo == receiveInfo.ZoneNo); if (partsStockInfo == null) { partsStockInfo = partsStockInfos.FirstOrDefault(d => d.PartNo == srmBarcodeInfo.PartNo && d.WmNo == receiveInfo.WmNo && d.ZoneNo == receiveInfo.ZoneNo); } if (partsStockInfo == null) { @string.AppendLine("update [LES].[TI_IFM_SRM_BARCODE] set " + "[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Suspend + "," + "[PROCESS_TIME] = GETDATE()," + "[COMMENTS] = N'0x00000370' where " +///没有相关的物料仓储信息 "[ID] = " + srmBarcodeInfo.Id + ";"); continue; } ///创建标签对象 BarcodeInfo barcodeInfo = BarcodeBLL.CreateBarcodeInfo(loginUser); ///SrmBarcodeInfo -> BarcodeInfo BarcodeBLL.GetBarcodeInfo(srmBarcodeInfo, ref barcodeInfo); ///SupplierInfo -> BarcodeInfo BarcodeBLL.GetBarcodeInfo(supplierInfo, ref barcodeInfo); ///PartsStockInfo -> BarcodeInfo BarcodeBLL.GetBarcodeInfo(partsStockInfo, ref barcodeInfo); ///PackageApplianceInfo -> BarcodeInfo PackageApplianceInfo packageApplianceInfo = packageApplianceInfos.FirstOrDefault(d => d.PackageNo == partsStockInfo.InboundPackageModel); BarcodeBLL.GetBarcodeInfo(packageApplianceInfo, ref barcodeInfo); /// barcodeInfo.CreateSourceFid = receiveDetailInfo.Fid; /// @string.AppendLine(BarcodeDAL.GetInsertSql(barcodeInfo)); dealedIds.Add(srmBarcodeInfo.Id); } if (dealedIds.Count > 0) { ///已处理的中间表数据更新为已处理状态 @string.AppendLine("update [LES].[TI_IFM_SRM_BARCODE] set " + "[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Processed + "," + "[PROCESS_TIME] = GETDATE() where " + "[ID] in (" + string.Join(",", dealedIds.ToArray()) + ");"); } ///执行 using (TransactionScope trans = new TransactionScope()) { if (@string.Length > 0) { BLL.SYS.CommonBLL.ExecuteNonQueryBySql(@string.ToString()); } trans.Complete(); } }
/// <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="barcodeInfos"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool CancelBarcodes(List <BarcodeInfo> barcodeInfos, string loginUser) { List <BarcodeStatusInfo> barcodeStatusInfos = new BarcodeStatusDAL().GetList("[BARCODE_DATA] in ('" + string.Join(",", barcodeInfos.Select(d => d.BarcodeData).ToArray()) + "')", string.Empty); string sql = string.Empty; foreach (var barcodeInfo in barcodeInfos) { if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Created) { continue; } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Invalid) { throw new Exception("MC:0x00000277");///标签已作废 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Frozen) { throw new Exception("MC:0x00000361");///标签已冻结 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Inbound) { throw new Exception("MC:0x00000362");///标签已入库 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Outbound) { throw new Exception("MC:0x00000364");///标签已出库 } if (barcodeInfo.BarcodeStatus.GetValueOrDefault() == (int)BarcodeStatusConstants.Shiped) { throw new Exception("MC:0x00000365");///标签已发货 } List <BarcodeStatusInfo> barcodeStatuses = barcodeStatusInfos.Where(d => d.BarcodeFid.GetValueOrDefault() == barcodeInfo.Fid.GetValueOrDefault()).OrderByDescending(d => d.Id).ToList(); if (barcodeStatuses.Count == 0) { throw new Exception("MC:0x00000276");///标签信息错误 } if (barcodeStatuses.Count == 1) { throw new Exception("MC:0x00000276");///标签信息错误 } ///获取上一个条码状态 BarcodeStatusInfo barcodeStatusInfo = barcodeStatuses.FirstOrDefault(); sql += BarcodeDAL.GetBarcodeUpdateSql(barcodeStatusInfo.BarcodeStatus.GetValueOrDefault() , barcodeStatusInfo.WmNo , barcodeStatusInfo.ZoneNo , barcodeStatusInfo.Dloc , barcodeStatusInfo.AsnRunsheetNo , barcodeStatusInfo.BarcodeFid.GetValueOrDefault() , loginUser); } ///执行 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); }