/// <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> /// 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()); }