| | |
| | | using Masuit.Tools; |
| | | using AngleSharp.Dom; |
| | | using Masuit.Tools; |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.webApi; |
| | | using MES.Service.Modes; |
| | |
| | | // 插入或更新数据的方法 |
| | | private bool SaveOrUpdateData(SqlSugarScope db, MesRohIn mesRohIn,List<MesRohInData> mesRohInDatas, string type) |
| | | { |
| | | ////传什么,c就改成什么 |
| | | //传什么,c就改成什么 |
| | | //if (type == "3" || (mesRohIn.DocumentStatus != null && mesRohIn.DocumentStatus != "C"))//C表示已审核状态 |
| | | //{ |
| | | // mesRohIn.BillNo = mesRohIn.BillNo + "F" + mesRohIn.EbelnK3id.ToString(); |
| | | //} |
| | | |
| | | //传什么,c就改成什么 |
| | | if (type == "3" || (mesRohIn.DocumentStatus != null && mesRohIn.DocumentStatus != "Y"))//Y表示已审核状态 |
| | | { |
| | | mesRohIn.BillNo = mesRohIn.BillNo + "F" + mesRohIn.EbelnK3id.ToString(); |
| | | } |
| | | ////传什么,c就改成什么 |
| | | //if (type == "3" || (mesRohIn.DocumentStatus != null && mesRohIn.DocumentStatus != "Y"))//Y表示已审核状态 |
| | | //{ |
| | | // mesRohIn.BillNo = mesRohIn.BillNo + "F" + mesRohIn.EbelnK3id.ToString(); |
| | | //} |
| | | |
| | | if (mesRohIn.Guid != null) |
| | | db.Deleteable<MesRohIn>().Where(s => s.Guid == mesRohIn.Guid) |
| | |
| | | |
| | | mesRohIn.EbelnK3id = eid; |
| | | mesRohIn.BillNo = rohIn.FBillNo; |
| | | mesRohIn.DocumentStatus = rohIn.FDocumentStatus; |
| | | |
| | | mesRohIn.DocumentType = rohIn.FBillTypeID; |
| | | mesRohIn.BusinessType = rohIn.FBusinessType; |
| | | |
| | | |
| | | ////erp传过来的Y->C,表示审核。N->A。(与金蝶逻辑保持一致) |
| | | //mesRohIn.DocumentStatus = rohIn.FDocumentStatus; |
| | | |
| | | //erp传过来的Y->C,表示审核。N->A。(与金蝶逻辑保持一致) |
| | | if (string.IsNullOrEmpty(rohIn.FDocumentStatus)) |
| | | { |
| | | mesRohIn.DocumentStatus = "A"; |
| | | } |
| | | else |
| | | { |
| | | mesRohIn.DocumentStatus = rohIn.FDocumentStatus == "Y" ? "C" : "A"; |
| | | } |
| | | |
| | | |
| | | |
| | | if (rohIn.FDate != null) |
| | | mesRohIn.PurchaseDate = DateTime.ParseExact(rohIn.FDate, |
| | | "yyyy-MM-dd HH:mm:ss", null); |
| | | |
| | | |
| | | |
| | | //供应商编码转ID |
| | | var mesRohInSupplier = Db.Queryable<MesSupplier>() |
| | |
| | | if (!string.IsNullOrWhiteSpace(mesRohInPurchaseDept)) |
| | | { |
| | | mesRohIn.PurchaseDept = mesRohInPurchaseDept; |
| | | } |
| | | else if (!string.IsNullOrWhiteSpace(rohIn.FPurchaseDeptId)) |
| | | { |
| | | mesRohIn.PurchaseDept = rohIn.FPurchaseDeptId; |
| | | } |
| | | else |
| | | { |
| | |
| | | SalesOrderId = s.F_UNW_Text_xsddh |
| | | }; |
| | | |
| | | //库存单位编码转ID |
| | | //InventoryUnit = s.FStockUnitID, |
| | | var entityInventoryUnit = Db.Queryable<MesUnit>() |
| | | .Where(x => x.Fnumber == s.FUnitId) |
| | | .Select(x => x.Id.ToString()) |
| | | .First(); |
| | | if (!string.IsNullOrWhiteSpace(entityInventoryUnit)) |
| | | { |
| | | entity.InventoryUnit = entityInventoryUnit; |
| | | } |
| | | else |
| | | { |
| | | entity.InventoryUnit = "0"; |
| | | } |
| | | |
| | | //采购单位编码转ID |
| | | var entityPurchaseUnit = Db.Queryable<MesUnit>() |
| | | .Where(x => x.Fnumber == s.FUnitId) |
| | |
| | | if (!string.IsNullOrWhiteSpace(entityPurchaseUnit)) |
| | | { |
| | | entity.PurchaseUnit = entityPurchaseUnit; |
| | | } |
| | | else if (!string.IsNullOrWhiteSpace(s.FUnitId)) |
| | | { |
| | | entity.PurchaseUnit = s.FUnitId; |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | entity.PricingUnit = entityPricingUnit; |
| | | } |
| | | else if (!string.IsNullOrWhiteSpace(s.FPriceUnitId)) |
| | | { |
| | | entity.PricingUnit = s.FPriceUnitId; |
| | | } |
| | | else |
| | | { |
| | | entity.PricingUnit = "0"; |
| | |
| | | if (!string.IsNullOrWhiteSpace(entityItemId)) |
| | | { |
| | | entity.ItemId = entityItemId; |
| | | } |
| | | else if (!string.IsNullOrWhiteSpace(s.FMaterialId)) |
| | | { |
| | | entity.ItemId = s.FMaterialId; |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | |
| | | //查询EbelnK3id对应的Guid,赋值给entity.Guid。实现主键复用 |
| | | var single = rohInDataManager.GetSingle(it =>it.EbelnK3id == entity.EbelnK3id); |
| | | var single = rohInDataManager.GetSingle(it => it.EbelnK3id == entity.EbelnK3id); |
| | | if (single != null) entity.Guid = single.Guid; |
| | | |
| | | return entity; |
| | |
| | | { |
| | | try |
| | | { |
| | | // 替换为: |
| | | // 获取当前表中已存在的最大 EBELN_K3ID |
| | | //var maxId = Db.Queryable<MesRohInData>().Max(x => (decimal?)x.EbelnK3id) ?? 0m; |
| | | |
| | | // 先取一个序列值 |
| | | var sequenceValueObj = Db.Ado.GetScalar("SELECT NEXT VALUE FOR MES_ROH_IN_DATA_seq"); |
| | | var sequenceValue = Convert.ToDecimal(sequenceValueObj); |
| | | // 验证序列值是否有效 |
| | | |
| | | if (sequenceValue <= 0) |
| | | { |
| | | throw new InvalidOperationException($"数据库序列 MES_ROH_IN_DATA_seq 返回了无效的值: {sequenceValue}"); |
| | | } |
| | | |
| | | //// 如果序列值落后于当前最大ID,持续获取直到超过 maxId |
| | | //while (sequenceValue <= maxId || Db.Queryable<MesRohInData>().Where(x => x.EbelnK3id == sequenceValue).Any()) |
| | | //{ |
| | | // sequenceValueObj = Db.Ado.GetScalar("SELECT NEXT VALUE FOR MES_ROH_IN_DATA_seq"); |
| | | // sequenceValue = Convert.ToDecimal(sequenceValueObj); |
| | | |
| | | // if (sequenceValue <= 0) |
| | | // { |
| | | // throw new InvalidOperationException($"数据库序列 MES_ROH_IN_DATA_seq 连续返回无效的值: {sequenceValue}"); |
| | | // } |
| | | //} |
| | | |
| | | return sequenceValue; |
| | | } |
| | |
| | | /// <returns>被删除的单号</returns> |
| | | public (int outSum, string outMsg) Delete(string FBillNo, string FBillTypeID) |
| | | { |
| | | try |
| | | { |
| | | var outMsg = string.Empty; |
| | | var outSum = 0; |
| | | |
| | |
| | | Db.Ado.UseStoredProcedure().ExecuteCommand("ERP_DeleteMesRohInByBillNo", parameters); |
| | | |
| | | outMsg = parameters[2].Value?.ToString() ?? ""; |
| | | outSum = parameters[3].Value != null ? Convert.ToInt32(parameters[2].Value) : -1; |
| | | |
| | | return (outSum, outMsg); |
| | | outSum = parameters[3].Value != null ? Convert.ToInt32(parameters[index: 3].Value) : -1; |
| | | return (outSum, outMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new InvalidOperationException($"调用存储过程 ERP_DeleteMesRohInByBillNo 失败: {ex.Message}", ex); |
| | | } |
| | | } |
| | | |
| | | |