Browse Source

1、修改命名空间

2、增加UTF-8空格强转校验
master
陈宜阳 7 months ago
parent
commit
4d66753980
  1. 4
      src/WmsWebApi.Application.Contracts/Boms/BomDetailDto.cs
  2. 5
      src/WmsWebApi.Application.Contracts/Boms/BomDto.cs
  3. 3
      src/WmsWebApi.Application.Contracts/Boms/IBomService.cs
  4. 3
      src/WmsWebApi.Application.Contracts/Boms/ReturnResult.cs
  5. 4
      src/WmsWebApi.Application.Contracts/OtherZll/IOtherZllService.cs
  6. 6
      src/WmsWebApi.Application.Contracts/OtherZll/OtherZllDto.cs
  7. 3
      src/WmsWebApi.Application.Contracts/OtherZll/ReturnResult.cs
  8. 20
      src/WmsWebApi.Application.Contracts/PPLan/IPPlanService.cs
  9. 168
      src/WmsWebApi.Application.Contracts/PPLan/PPlanDto.cs
  10. 14
      src/WmsWebApi.Application.Contracts/PPLan/ReturnResult.cs
  11. 3
      src/WmsWebApi.Application.Contracts/Parts/IPartService.cs
  12. 3
      src/WmsWebApi.Application.Contracts/Parts/PartDetailDto.cs
  13. 4
      src/WmsWebApi.Application.Contracts/Parts/PartDto.cs
  14. 18
      src/WmsWebApi.Application.Contracts/Parts/ReturnResult.cs
  15. 20
      src/WmsWebApi.Application.Contracts/ProductRecieve/IProductRecieveService.cs
  16. 40
      src/WmsWebApi.Application.Contracts/ProductRecieve/PRDetailDto.cs
  17. 86
      src/WmsWebApi.Application.Contracts/ProductRecieve/PRDto.cs
  18. 14
      src/WmsWebApi.Application.Contracts/ProductRecieve/ReturnResult.cs
  19. 3
      src/WmsWebApi.Application.Contracts/Purchase/IPurchaseService.cs
  20. 3
      src/WmsWebApi.Application.Contracts/Purchase/PurchaseDetailDto.cs
  21. 3
      src/WmsWebApi.Application.Contracts/Purchase/PurchaseDto.cs
  22. 14
      src/WmsWebApi.Application.Contracts/Purchase/ReturnResult.cs
  23. 20
      src/WmsWebApi.Application.Contracts/StockMove/IStockMoveService.cs
  24. 3
      src/WmsWebApi.Application.Contracts/StockMove/ReturnResult.cs
  25. 3
      src/WmsWebApi.Application.Contracts/StockMove/SSDetailDto.cs
  26. 3
      src/WmsWebApi.Application.Contracts/StockMove/SSDto.cs
  27. 5
      src/WmsWebApi.Application.Contracts/ZlldcjLogs/IZlldcjLogAppService.cs
  28. 3
      src/WmsWebApi.Application.Contracts/ZlldcjLogs/ReturnResult.cs
  29. 11
      src/WmsWebApi.Application.Contracts/ZlldcjLogs/ZlldcjLog.cs
  30. 474
      src/WmsWebApi.Application/Boms/BomService.cs
  31. 700
      src/WmsWebApi.Application/OtherZll/OtherZllService.cs
  32. 404
      src/WmsWebApi.Application/PPlan/PPlanService.cs
  33. 3
      src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs
  34. 23
      src/WmsWebApi.Application/Purchase/PurchaseService.cs
  35. 3
      src/WmsWebApi.Application/StockMove/StockMoveService.cs
  36. 16
      src/WmsWebApi.Application/TbParts/PartService.cs
  37. 3
      src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs
  38. 70
      src/WmsWebApi.Domain/Boms/BomManager.cs
  39. 14
      src/WmsWebApi.Domain/Boms/IBomManager.cs
  40. 10
      src/WmsWebApi.Domain/OtherZll/IOtherZllManager.cs
  41. 30
      src/WmsWebApi.Domain/OtherZll/OtherZllManager.cs
  42. 10
      src/WmsWebApi.Domain/PPlan/IPPlanManager.cs
  43. 30
      src/WmsWebApi.Domain/PPlan/PPlanManager.cs
  44. 10
      src/WmsWebApi.Domain/Parts/IPartManager.cs
  45. 30
      src/WmsWebApi.Domain/Parts/PartManager.cs
  46. 10
      src/WmsWebApi.Domain/ProductRecieve/IProductRecieveManager.cs
  47. 30
      src/WmsWebApi.Domain/ProductRecieve/ProductRecieveManager.cs
  48. 10
      src/WmsWebApi.Domain/Purchase/IPurchaseManager.cs
  49. 3
      src/WmsWebApi.Domain/Purchase/PurchaseManager.cs
  50. 3
      src/WmsWebApi.Domain/StockMove/IStockMoveManager.cs
  51. 3
      src/WmsWebApi.Domain/StockMove/StockMoveManager.cs
  52. 5
      src/WmsWebApi.Domain/TbOrfers/TbOrder.cs
  53. 62
      src/WmsWebApi.Domain/WMS/TbBillExtensions.cs
  54. 3
      src/WmsWebApi.Domain/ZlldcjLogs/IZlldcjLogManager.cs
  55. 3
      src/WmsWebApi.Domain/ZlldcjLogs/WmsWebApiZLLDCJDTO.cs
  56. 5
      src/WmsWebApi.Domain/ZlldcjLogs/ZlldcjLog.cs
  57. 5
      src/WmsWebApi.Domain/ZlldcjLogs/ZlldcjLogExtensions.cs
  58. 270
      src/WmsWebApi.Domain/ZlldcjLogs/ZlldcjLogManager.cs
  59. 12
      src/WmsWebApi.Domain/ZlldgbLogs/IZlldgbLogManager.cs
  60. 5
      src/WmsWebApi.Domain/ZlldgbLogs/ZlldgbLog.cs
  61. 5
      src/WmsWebApi.Domain/ZlldgbLogs/ZlldgbLogExtensions.cs
  62. 9
      src/WmsWebApi.Domain/ZlldgbLogs/ZlldgbLogManager.cs

4
src/WmsWebApi.Application.Contracts/Boms/BomDetailDto.cs

@ -2,7 +2,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.Boms; namespace WmsWebApi.Boms
{
public class BomDetailDto : EntityDto public class BomDetailDto : EntityDto
{ {
@ -38,3 +39,4 @@ public class BomDetailDto : EntityDto
public string SANKA { get; set; } public string SANKA { get; set; }
public string SANFE { get; set; } public string SANFE { get; set; }
} }
}

5
src/WmsWebApi.Application.Contracts/Boms/BomDto.cs

@ -5,8 +5,8 @@ using System.Runtime.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.Boms; namespace WmsWebApi.Boms
{
public class BomDto : EntityDto public class BomDto : EntityDto
{ {
/// <summary> /// <summary>
@ -60,3 +60,4 @@ public class BomDto : EntityDto
public virtual List<BomDetailDto> items { get; set; } public virtual List<BomDetailDto> items { get; set; }
} }
}

3
src/WmsWebApi.Application.Contracts/Boms/IBomService.cs

@ -2,7 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace WmsWebApi.Boms; namespace WmsWebApi.Boms {
public interface IBomService : IApplicationService public interface IBomService : IApplicationService
{ {
@ -13,3 +13,4 @@ public interface IBomService : IApplicationService
public Task<ReturnResult> AddAsync(object content); public Task<ReturnResult> AddAsync(object content);
} }
}

3
src/WmsWebApi.Application.Contracts/Boms/ReturnResult.cs

@ -1,6 +1,6 @@
using System; using System;
namespace WmsWebApi.Boms; namespace WmsWebApi.Boms {
public class ReturnResult public class ReturnResult
{ {
@ -10,3 +10,4 @@ public class ReturnResult
public string REQUEST_SYSTEM { get; set; } = "WinWMS"; public string REQUEST_SYSTEM { get; set; } = "WinWMS";
} }
}

4
src/WmsWebApi.Application.Contracts/OtherZll/IOtherZllService.cs

@ -2,7 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace WmsWebApi.OtherZll; namespace WmsWebApi.OtherZll {
/// <summary> /// <summary>
/// 其他领物料 /// 其他领物料
@ -16,3 +16,5 @@ public interface IOtherZllService : IApplicationService
public Task<ReturnResult> AddAsync(object content); public Task<ReturnResult> AddAsync(object content);
} }
}

6
src/WmsWebApi.Application.Contracts/OtherZll/OtherZllDto.cs

@ -5,7 +5,9 @@ using System.Runtime.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.OtherZll; namespace WmsWebApi.OtherZll
{
public class OtherZllDto : EntityDto public class OtherZllDto : EntityDto
{ {
@ -61,3 +63,5 @@ public class OtherZllDto : EntityDto
public string LGORT1 { get; set; } public string LGORT1 { get; set; }
} }
}

3
src/WmsWebApi.Application.Contracts/OtherZll/ReturnResult.cs

@ -1,6 +1,6 @@
using System; using System;
namespace WmsWebApi.OtherZll; namespace WmsWebApi.OtherZll {
public class ReturnResult public class ReturnResult
{ {
@ -10,3 +10,4 @@ public class ReturnResult
public string REQUEST_SYSTEM { get; set; } = "WinWMS"; public string REQUEST_SYSTEM { get; set; } = "WinWMS";
} }
}

20
src/WmsWebApi.Application.Contracts/PPLan/IPPlanService.cs

@ -2,17 +2,19 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace WmsWebApi.PPLan; namespace WmsWebApi.PPLan
/// <summary>
/// 计划
/// </summary>
public interface IPPlanService : IApplicationService
{ {
/// <summary> /// <summary>
/// 是否是请求重试 /// 计划
/// </summary> /// </summary>
public bool IsRequestRetry { get; set; } public interface IPPlanService : IApplicationService
{
/// <summary>
/// 是否是请求重试
/// </summary>
public bool IsRequestRetry { get; set; }
public Task<ReturnResult> AddAsync(object content); public Task<ReturnResult> AddAsync(object content);
}
} }

168
src/WmsWebApi.Application.Contracts/PPLan/PPlanDto.cs

@ -5,92 +5,94 @@ using System.Runtime.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.PPLan; namespace WmsWebApi.PPLan
public class PPlanDto : EntityDto
{ {
/// <summary>
/// 计划订单中的订单结束日期
/// </summary>
[Display(Name = "计划订单中的订单结束日期")]
public string PEDTR { get; set; }
/// <summary>
/// 分组
/// </summary>
[Display(Name = "分组")]
public string SCHGRUP { get; set; }
/// <summary> public class PPlanDto : EntityDto
/// 班次 {
/// </summary> /// <summary>
[Display(Name = "班次")] /// 计划订单中的订单结束日期
public string KAPTPROG { get; set; } /// </summary>
[Display(Name = "计划订单中的订单结束日期")]
public string PEDTR { get; set; }
/// <summary>
/// 分组
/// </summary>
[Display(Name = "分组")]
public string SCHGRUP { get; set; }
/// <summary>
/// 班次
/// </summary>
[Display(Name = "班次")]
public string KAPTPROG { get; set; }
/// <summary> /// <summary>
/// 物料号 /// 物料号
/// </summary> /// </summary>
[Display(Name = "物料号 ")] [Display(Name = "物料号 ")]
public string MATNR { get; set; } public string MATNR { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 物料描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "物料描述")]
public string MAKTX { get; set; } public string MAKTX { get; set; }
/// <summary> /// <summary>
/// 工厂 /// 工厂
/// </summary> /// </summary>
[Display(Name = "工厂")] [Display(Name = "工厂")]
public string WERKS { get; set; } public string WERKS { get; set; }
/// <summary> /// <summary>
/// 生产版本 /// 生产版本
/// </summary> /// </summary>
[Display(Name = "生产版本")] [Display(Name = "生产版本")]
public string VERID { get; set; } public string VERID { get; set; }
/// <summary> /// <summary>
/// 生产顺序 /// 生产顺序
/// </summary> /// </summary>
[Display(Name = "生产顺序")] [Display(Name = "生产顺序")]
public string ZSCSX { get; set; } public string ZSCSX { get; set; }
/// <summary> /// <summary>
/// 机器代码 /// 机器代码
/// </summary> /// </summary>
[Display(Name = "机器代码")] [Display(Name = "机器代码")]
public string ZMACD { get; set; } public string ZMACD { get; set; }
/// <summary> /// <summary>
/// 机器描述 /// 机器描述
/// </summary> /// </summary>
[Display(Name = "机器描述")] [Display(Name = "机器描述")]
public string ZMATX { get; set; } public string ZMATX { get; set; }
/// <summary> /// <summary>
/// MRP 控制者(物料计划人) /// MRP 控制者(物料计划人)
/// </summary> /// </summary>
[Display(Name = "MRP 控制者(物料计划人)")] [Display(Name = "MRP 控制者(物料计划人)")]
public string DISPO { get; set; } public string DISPO { get; set; }
/// <summary> /// <summary>
/// 全部的计划订单数量 /// 全部的计划订单数量
/// </summary> /// </summary>
[Display(Name = "全部的计划订单数量 ")] [Display(Name = "全部的计划订单数量 ")]
public decimal GSMNG { get; set; } = 0; public decimal GSMNG { get; set; } = 0;
/// <summary> /// <summary>
/// 备注 /// 备注
/// </summary> /// </summary>
[Display(Name = "备注")] [Display(Name = "备注")]
public string ZBZSM { get; set; } public string ZBZSM { get; set; }
/// <summary> /// <summary>
/// 用户主记录中的用户名称 /// 用户主记录中的用户名称
/// </summary> /// </summary>
[Display(Name = "用户主记录中的用户名称 ")] [Display(Name = "用户主记录中的用户名称 ")]
public string XUBNAME { get; set; } public string XUBNAME { get; set; }
/// <summary> /// <summary>
/// 更改日期 /// 更改日期
/// </summary> /// </summary>
[Display(Name = "生产顺序")] [Display(Name = "生产顺序")]
public string ZCDATE { get; set; } public string ZCDATE { get; set; }
/// <summary> /// <summary>
/// 更改时间 /// 更改时间
/// </summary> /// </summary>
[Display(Name = "更改时间")] [Display(Name = "更改时间")]
public string ZCTIME { get; set; } public string ZCTIME { get; set; }
}
} }

14
src/WmsWebApi.Application.Contracts/PPLan/ReturnResult.cs

@ -1,12 +1,14 @@
using System; using System;
namespace WmsWebApi.PPLan; namespace WmsWebApi.PPLan
public class ReturnResult
{ {
public char TYPE { get; set; } = 'S';
public string MESSAGE { get; set; } = "接收成功!"; public class ReturnResult
{
public char TYPE { get; set; } = 'S';
public string MESSAGE { get; set; } = "接收成功!";
public string REQUEST_SYSTEM { get; set; } = "WinWMS"; public string REQUEST_SYSTEM { get; set; } = "WinWMS";
}
} }

3
src/WmsWebApi.Application.Contracts/Parts/IPartService.cs

@ -2,7 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace WmsWebApi.Parts; namespace WmsWebApi.Parts {
/// <summary> /// <summary>
/// 零件 /// 零件
@ -16,3 +16,4 @@ public interface IPartService : IApplicationService
public Task<ReturnResult> AddAsync(object content); public Task<ReturnResult> AddAsync(object content);
} }
}

3
src/WmsWebApi.Application.Contracts/Parts/PartDetailDto.cs

@ -2,7 +2,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.Parts; namespace WmsWebApi.Parts {
public class PartDetailDto : EntityDto public class PartDetailDto : EntityDto
{ {
@ -19,3 +19,4 @@ public class PartDetailDto : EntityDto
public string CHARACT_DESCR { get; set; } public string CHARACT_DESCR { get; set; }
} }
}

4
src/WmsWebApi.Application.Contracts/Parts/PartDto.cs

@ -5,8 +5,7 @@ using System.Runtime.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.Parts; namespace WmsWebApi.Parts {
public class PartDto : EntityDto public class PartDto : EntityDto
{ {
@ -518,3 +517,4 @@ public class PartDto : EntityDto
[DataMember, XmlArray("partDetails")] [DataMember, XmlArray("partDetails")]
public virtual List<PartDetailDto> zzchar { get; set; } public virtual List<PartDetailDto> zzchar { get; set; }
} }
}

18
src/WmsWebApi.Application.Contracts/Parts/ReturnResult.cs

@ -1,16 +1,18 @@
using System; using System;
namespace WmsWebApi.Parts; namespace WmsWebApi.Parts
public class ReturnResult
{ {
public char TYPE { get; set; } = 'S';
public string MESSAGE { get; set; } = "接收成功!"; public class ReturnResult
{
public char TYPE { get; set; } = 'S';
public string MESSAGE { get; set; } = "接收成功!";
public string MESSAGE_V1 { get; set; } = DateTime.Now.ToString("yyyyMMdd"); public string MESSAGE_V1 { get; set; } = DateTime.Now.ToString("yyyyMMdd");
public string MESSAGE_V2 { get; set; } = DateTime.Now.ToString("HH:mm:ss"); public string MESSAGE_V2 { get; set; } = DateTime.Now.ToString("HH:mm:ss");
public string REQUEST_SYSTEM { get; set; } = "WinWMS"; public string REQUEST_SYSTEM { get; set; } = "WinWMS";
}
} }

20
src/WmsWebApi.Application.Contracts/ProductRecieve/IProductRecieveService.cs

@ -2,17 +2,19 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace WmsWebApi.ProductRecieve; namespace WmsWebApi.ProductRecieve
/// <summary>
/// Agv完工收货入库
/// </summary>
public interface IProductRecieveService : IApplicationService
{ {
/// <summary> /// <summary>
/// 是否是请求重试 /// Agv完工收货入库
/// </summary> /// </summary>
public bool IsRequestRetry { get; set; } public interface IProductRecieveService : IApplicationService
{
/// <summary>
/// 是否是请求重试
/// </summary>
public bool IsRequestRetry { get; set; }
public Task<ReturnResult> AddAsync(object content); public Task<ReturnResult> AddAsync(object content);
}
} }

40
src/WmsWebApi.Application.Contracts/ProductRecieve/PRDetailDto.cs

@ -2,40 +2,42 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.ProductRecieve; namespace WmsWebApi.ProductRecieve
public class PRDetailDto : EntityDto
{ {
public string BarCode { get; set; } public class PRDetailDto : EntityDto
{
public string BarCode { get; set; }
public string Batch { get; set; } public string Batch { get; set; }
public string PartCode { get; set; } public string PartCode { get; set; }
public string PartDesc { get; set; } = ""; public string PartDesc { get; set; } = "";
public string PpBillNum { get; set; } public string PpBillNum { get; set; }
public decimal PpLine { get; set; } = 0; public decimal PpLine { get; set; } = 0;
public string ProduceDate { get; set; } public string ProduceDate { get; set; }
public decimal Qty { get; set; } public decimal Qty { get; set; }
public string ReceiveDate { get; set; } public string ReceiveDate { get; set; }
public string ScrapQty { get; set; } public string ScrapQty { get; set; }
public string ShiftName { get; set; } public string ShiftName { get; set; }
public string State { get; set; } public string State { get; set; }
public string FromLocCode { get; set; } public string FromLocCode { get; set; }
public string ToLocCode { get; set; } public string ToLocCode { get; set; }
public string TraceBackCode { get; set; } public string TraceBackCode { get; set; }
public string Unit { get; set; } public string Unit { get; set; }
}
} }

86
src/WmsWebApi.Application.Contracts/ProductRecieve/PRDto.cs

@ -5,47 +5,49 @@ using System.Runtime.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.ProductRecieve; namespace WmsWebApi.ProductRecieve
public class PRDto : EntityDto
{ {
/// <summary>
/// 过账日期 public class PRDto : EntityDto
/// </summary> {
[Display(Name = "过账日期")] /// <summary>
public string AccountDate { get; set; } /// 过账日期
/// <summary> /// </summary>
/// 单据类型 901完工收货,902上架,903下架 [Display(Name = "过账日期")]
/// </summary> public string AccountDate { get; set; }
[Display(Name = "单据类型")] /// <summary>
public string BillType { get; set; } /// 单据类型 901完工收货,902上架,903下架
/// </summary>
/// <summary> [Display(Name = "单据类型")]
/// 接收日期 public string BillType { get; set; }
/// </summary>
[Display(Name = "接收日期")] /// <summary>
public string ReceiveDate { get; set; } /// 接收日期
/// </summary>
[Display(Name = "GUID")] [Display(Name = "接收日期")]
public string GUID { get; set; } public string ReceiveDate { get; set; }
/// <summary> [Display(Name = "GUID")]
/// 操作者 public string GUID { get; set; }
/// </summary>
[Display(Name = "操作者")] /// <summary>
public string OperName { get; set; } /// 操作者
/// </summary>
/// <summary> [Display(Name = "操作者")]
/// 单据时间 public string OperName { get; set; }
/// </summary>
[Display(Name = "单据时间")] /// <summary>
public string BillTime { get; set; } /// 单据时间
/// </summary>
/// <summary> [Display(Name = "单据时间")]
/// IWMS单号 public string BillTime { get; set; }
/// </summary>
[Display(Name = "IWMS单号")] /// <summary>
public string SourceBillNum { get; set; } /// IWMS单号
/// </summary>
public virtual List<PRDetailDto> items { get; set; } [Display(Name = "IWMS单号")]
public string SourceBillNum { get; set; }
public virtual List<PRDetailDto> items { get; set; }
}
} }

14
src/WmsWebApi.Application.Contracts/ProductRecieve/ReturnResult.cs

@ -1,12 +1,14 @@
using System; using System;
namespace WmsWebApi.ProductRecieve; namespace WmsWebApi.ProductRecieve
public class ReturnResult
{ {
public char TYPE { get; set; } = 'S';
public string MESSAGE { get; set; } = "接收成功!"; public class ReturnResult
{
public char TYPE { get; set; } = 'S';
public string MESSAGE { get; set; } = "接收成功!";
public string REQUEST_SYSTEM { get; set; } = "WinWMS"; public string REQUEST_SYSTEM { get; set; } = "WinWMS";
}
} }

3
src/WmsWebApi.Application.Contracts/Purchase/IPurchaseService.cs

@ -2,7 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace WmsWebApi.Purchase; namespace WmsWebApi.Purchase {
/// <summary> /// <summary>
/// 采购 /// 采购
@ -16,3 +16,4 @@ public interface IPurchaseService : IApplicationService
public Task<ReturnResult> AddAsync(object content); public Task<ReturnResult> AddAsync(object content);
} }
}

3
src/WmsWebApi.Application.Contracts/Purchase/PurchaseDetailDto.cs

@ -2,7 +2,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.Purchase; namespace WmsWebApi.Purchase {
public class PurchaseDetailDto : EntityDto public class PurchaseDetailDto : EntityDto
{ {
@ -24,3 +24,4 @@ public class PurchaseDetailDto : EntityDto
public string EBELP { get; set; } public string EBELP { get; set; }
public string BWART { get; set; } public string BWART { get; set; }
} }
}

3
src/WmsWebApi.Application.Contracts/Purchase/PurchaseDto.cs

@ -5,7 +5,7 @@ using System.Runtime.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.Purchase; namespace WmsWebApi.Purchase {
public class PurchaseDto : EntityDto public class PurchaseDto : EntityDto
{ {
@ -28,3 +28,4 @@ public class PurchaseDto : EntityDto
public virtual List<PurchaseDetailDto> zzmseg { get; set; } public virtual List<PurchaseDetailDto> zzmseg { get; set; }
} }
}

14
src/WmsWebApi.Application.Contracts/Purchase/ReturnResult.cs

@ -1,12 +1,14 @@
using System; using System;
namespace WmsWebApi.Purchase; namespace WmsWebApi.Purchase
public class ReturnResult
{ {
public char TYPE { get; set; } = 'S';
public string MESSAGE { get; set; } = "接收成功!"; public class ReturnResult
{
public char TYPE { get; set; } = 'S';
public string MESSAGE { get; set; } = "接收成功!";
public string REQUEST_SYSTEM { get; set; } = "WinWMS"; public string REQUEST_SYSTEM { get; set; } = "WinWMS";
}
} }

20
src/WmsWebApi.Application.Contracts/StockMove/IStockMoveService.cs

@ -2,17 +2,19 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace WmsWebApi.StockMove; namespace WmsWebApi.StockMove
/// <summary>
/// Agv出入库
/// </summary>
public interface IStockMoveService : IApplicationService
{ {
/// <summary> /// <summary>
/// 是否是请求重试 /// Agv出入库
/// </summary> /// </summary>
public bool IsRequestRetry { get; set; } public interface IStockMoveService : IApplicationService
{
/// <summary>
/// 是否是请求重试
/// </summary>
public bool IsRequestRetry { get; set; }
public Task<ReturnResult> AddAsync(object content); public Task<ReturnResult> AddAsync(object content);
}
} }

3
src/WmsWebApi.Application.Contracts/StockMove/ReturnResult.cs

@ -1,6 +1,6 @@
using System; using System;
namespace WmsWebApi.StockMove; namespace WmsWebApi.StockMove {
public class ReturnResult public class ReturnResult
{ {
@ -10,3 +10,4 @@ public class ReturnResult
public string REQUEST_SYSTEM { get; set; } = "WinWMS"; public string REQUEST_SYSTEM { get; set; } = "WinWMS";
} }
}

3
src/WmsWebApi.Application.Contracts/StockMove/SSDetailDto.cs

@ -2,7 +2,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.StockMove; namespace WmsWebApi.StockMove {
public class SSDetailDto : EntityDto public class SSDetailDto : EntityDto
{ {
@ -39,3 +39,4 @@ public class SSDetailDto : EntityDto
public string Unit { get; set; } public string Unit { get; set; }
} }
}

3
src/WmsWebApi.Application.Contracts/StockMove/SSDto.cs

@ -5,7 +5,7 @@ using System.Runtime.Serialization;
using System.Xml.Serialization; using System.Xml.Serialization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.StockMove; namespace WmsWebApi.StockMove {
public class SSDto : EntityDto public class SSDto : EntityDto
{ {
@ -49,3 +49,4 @@ public class SSDto : EntityDto
public virtual List<SSDetailDto> items { get; set; } public virtual List<SSDetailDto> items { get; set; }
} }
}

5
src/WmsWebApi.Application.Contracts/ZlldcjLogs/IZlldcjLogAppService.cs

@ -3,12 +3,12 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs {
/// <summary> /// <summary>
/// 领物料 /// 领物料
/// </summary> /// </summary>
public interface IZlldcjLogAppService :IApplicationService public interface IZlldcjLogAppService : IApplicationService
{ {
/// <summary> /// <summary>
/// 是否是请求重试 /// 是否是请求重试
@ -21,3 +21,4 @@ public interface IZlldcjLogAppService :IApplicationService
public Task<ReturnResult> CloseAsync(object content); public Task<ReturnResult> CloseAsync(object content);
} }
}

3
src/WmsWebApi.Application.Contracts/ZlldcjLogs/ReturnResult.cs

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs {
public class ReturnResult public class ReturnResult
{ {
@ -16,3 +16,4 @@ public class ReturnResult
} }
} }
}

11
src/WmsWebApi.Application.Contracts/ZlldcjLogs/ZlldcjLog.cs

@ -2,9 +2,9 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs {
public class ZlldcjLogDto:EntityDto public class ZlldcjLogDto : EntityDto
{ {
/// <summary> /// <summary>
/// 单据号 /// 单据号
@ -161,7 +161,8 @@ public class ZlldcjLogDto:EntityDto
/// </summary> /// </summary>
[Display(Name = "交货项目")] [Display(Name = "交货项目")]
public string POSNR { get; set; } public string POSNR { get; set; }
/* /*
[Display(Name = "接口类型")] [Display(Name = "接口类型")]
public string IType { get; set; }*/ public string IType { get; set; }*/
}
} }

474
src/WmsWebApi.Application/Boms/BomService.cs

@ -16,291 +16,293 @@ using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Jsons; using WmsWebApi.Jsons;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Boms; namespace WmsWebApi.Boms
[Route("/api/bom")]
public class BomService : ApplicationService, IBomService
{ {
private readonly ITmPgPartgroupRepository _tmPgPartgroupRepository;
private readonly ITaBomRepository _taBomRepository;
private readonly ITaPartRepository _taPartRepository;
private readonly IBomManager _bomDtoRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry;
private readonly IBomJsonRepository _bomJsonRepository;
private readonly AsyncRetryPolicy _asyncRetryPolicy;
/// <summary>
/// 是否是请求重试
/// </summary>
public bool IsRequestRetry { get; set; } = false;
public BomService(ITmPgPartgroupRepository tmPgPartgroupRepository, [Route("/api/bom")]
ITaBomRepository taBomRepository, public class BomService : ApplicationService, IBomService
ITaPartRepository taPartRepository,
IBomManager bomDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager,
IBackgroundJobRequestRetry backgroundJobRequestRetry,
IBomJsonRepository bomJsonRepository)
{ {
_tmPgPartgroupRepository = tmPgPartgroupRepository; private readonly ITmPgPartgroupRepository _tmPgPartgroupRepository;
_taBomRepository = taBomRepository; private readonly ITaBomRepository _taBomRepository;
_taPartRepository = taPartRepository; private readonly ITaPartRepository _taPartRepository;
_bomDtoRepository = bomDtoRepository; private readonly IBomManager _bomDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate; private readonly TmPgWmsUpdate _tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager; private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
_backgroundJobRequestRetry = backgroundJobRequestRetry; private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry;
_bomJsonRepository = bomJsonRepository; private readonly IBomJsonRepository _bomJsonRepository;
_asyncRetryPolicy = Policy.Handle<Exception>() private readonly AsyncRetryPolicy _asyncRetryPolicy;
.WaitAndRetryAsync(new[] {
/// <summary>
/// 是否是请求重试
/// </summary>
public bool IsRequestRetry { get; set; } = false;
public BomService(ITmPgPartgroupRepository tmPgPartgroupRepository,
ITaBomRepository taBomRepository,
ITaPartRepository taPartRepository,
IBomManager bomDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate
, Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager,
IBackgroundJobRequestRetry backgroundJobRequestRetry,
IBomJsonRepository bomJsonRepository)
{
_tmPgPartgroupRepository = tmPgPartgroupRepository;
_taBomRepository = taBomRepository;
_taPartRepository = taPartRepository;
_bomDtoRepository = bomDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
_backgroundJobRequestRetry = backgroundJobRequestRetry;
_bomJsonRepository = bomJsonRepository;
_asyncRetryPolicy = Policy.Handle<Exception>()
.WaitAndRetryAsync(new[] {
TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5) TimeSpan.FromSeconds(5)
}, (exception, timeSpan, retryCount, context) => }, (exception, timeSpan, retryCount, context) =>
{ {
Logger.LogInformation($"执行失败,第 {retryCount} 次重试"); Logger.LogInformation($"执行失败,第 {retryCount} 次重试");
}); });
}
[HttpPost("add")]
//[UnitOfWork(false)]
public async Task<ReturnResult> AddAsync([FromBody] object content)
{
var result = new ReturnResult();
BomDto _bom;
bool bUpdate = false, bOtherWork = false, bDel = false, bNotFind = false, bPartGroup = false;
try
{
_bom = JsonConvert.DeserializeObject<BomDto>(content.ToString());
}
catch (Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
}
if (string.IsNullOrEmpty(_bom.MATNR))
{
result.TYPE = 'E';
result.MESSAGE = "物料号不能为空";
return result;
} }
WmsWebApiBOMDTO bomdto = new WmsWebApiBOMDTO() [HttpPost("add")]
//[UnitOfWork(false)]
public async Task<ReturnResult> AddAsync([FromBody] object content)
{ {
MATNR = _bom.MATNR, var result = new ReturnResult();
MAKTX = _bom.MAKTX, BomDto _bom;
WERKS = _bom.WERKS, bool bUpdate = false, bOtherWork = false, bDel = false, bNotFind = false, bPartGroup = false;
STLAN = _bom.STLAN, try
STLAL = _bom.STLAL, {
DATUV = _bom.DATUV, _bom = JsonConvert.DeserializeObject<BomDto>(content.ToString());
BMENG = _bom.BMENG, }
STLST = _bom.STLST, catch (Exception ex)
LOEKZ = _bom.LOEKZ, {
JSON = content.ToString() result.TYPE = 'E';
}; result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
bomdto.SetId(GuidGenerator); return result;
}
if (string.IsNullOrEmpty(_bom.MATNR))
{
result.TYPE = 'E';
result.MESSAGE = "物料号不能为空";
return result;
}
try WmsWebApiBOMDTO bomdto = new WmsWebApiBOMDTO()
{
var _remark = DateTime.Now.ToString("yyyy-MM-dd") + "!" + Guid.NewGuid();
if (_bom.WERKS == "1000")
{ {
var partgrouplist = _tmPgPartgroupRepository.Where(p => p.IsBom == true); MATNR = _bom.MATNR,
MAKTX = _bom.MAKTX,
WERKS = _bom.WERKS,
STLAN = _bom.STLAN,
STLAL = _bom.STLAL,
DATUV = _bom.DATUV,
BMENG = _bom.BMENG,
STLST = _bom.STLST,
LOEKZ = _bom.LOEKZ,
JSON = content.ToString()
};
bomdto.SetId(GuidGenerator);
var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _bom.MATNR); try
if (part == null) {
{ var _remark = DateTime.Now.ToString("yyyy-MM-dd") + "!" + Guid.NewGuid();
bNotFind = true; if (_bom.WERKS == "1000")
result.MESSAGE = $"没有找到物料号!{_bom.MATNR}";
}
else
{ {
WmsWebApiBom b = new WmsWebApiBom() var partgrouplist = _tmPgPartgroupRepository.Where(p => p.IsBom == true);
{
MATNR = _bom.MATNR,
MAKTX = _bom.MAKTX,
WERKS = _bom.WERKS,
STLAN = _bom.STLAN,
STLAL = _bom.STLAL,
DATUV = _bom.DATUV,
BMENG = _bom.BMENG,
STLST = _bom.STLST,
LOEKZ = _bom.LOEKZ,
IsFisRead = false,
IsDelete = false,
};
b.SetId(GuidGenerator);
//判断是删除还是增加
if (_bom.LOEKZ == "1" || _bom.items.Count == 0)
{
bDel = true;
bPartGroup = false;
//var bom = new TA_BOM();
//bom.PartCode = _bom.MATNR;
//await _tmPgWmsUpdate.DelTaBomAsync(bom); var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _bom.MATNR);
b.IsDelete = true; if (part == null)
await _bomDtoRepository.AddBomAsync(b); {
bNotFind = true;
result.MESSAGE = $"没有找到物料号!{_bom.MATNR}";
} }
else else
{ {
#region BOM信息更新 WmsWebApiBom b = new WmsWebApiBom()
{
MATNR = _bom.MATNR,
MAKTX = _bom.MAKTX,
WERKS = _bom.WERKS,
STLAN = _bom.STLAN,
STLAL = _bom.STLAL,
DATUV = _bom.DATUV,
BMENG = _bom.BMENG,
STLST = _bom.STLST,
LOEKZ = _bom.LOEKZ,
IsFisRead = false,
IsDelete = false,
};
b.SetId(GuidGenerator);
//判断是删除还是增加
if (_bom.LOEKZ == "1" || _bom.items.Count == 0)
{
bDel = true;
bPartGroup = false;
//var bom = new TA_BOM();
//bom.PartCode = _bom.MATNR;
if (partgrouplist.Select(p => p.PARTGROUP).Contains(part.PartGroup)) //await _tmPgWmsUpdate.DelTaBomAsync(bom);
b.IsDelete = true;
await _bomDtoRepository.AddBomAsync(b);
}
else
{ {
List<WmsWebApiBomDetail> bDetail = new List<WmsWebApiBomDetail>(); #region BOM信息更新
foreach (var item in _bom.items)
if (partgrouplist.Select(p => p.PARTGROUP).Contains(part.PartGroup))
{ {
/*var bom = new TA_BOM(); List<WmsWebApiBomDetail> bDetail = new List<WmsWebApiBomDetail>();
foreach (var item in _bom.items)
{
/*var bom = new TA_BOM();
bom.PartCode = _bom.MATNR; bom.PartCode = _bom.MATNR;
bom.BeginDate = DateTime.ParseExact(_bom.DATUV, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);//DateTime.Parse(_bom.DATUV); bom.BeginDate = DateTime.ParseExact(_bom.DATUV, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);//DateTime.Parse(_bom.DATUV);
bom.Remark = _remark; bom.Remark = _remark;
bom.SubPartCode = item.IDNRK; bom.SubPartCode = item.IDNRK;
bom.Qty = item.MENGE; bom.Qty = item.MENGE;
var tmp = await _taBomRepository.FirstOrDefaultAsync(p => p.PartCode == _bom.MATNR var tmp = await _taBomRepository.FirstOrDefaultAsync(p => p.PartCode == _bom.MATNR
&& p.SubPartCode == item.IDNRK && p.SubPartCode == item.IDNRK
&& p.BeginDate == bom.BeginDate); && p.BeginDate == bom.BeginDate);
if (tmp == null) if (tmp == null)
{ {
await _taBomRepository.UpsertAsync(bom); await _taBomRepository.UpsertAsync(bom);
}
else
{
bUpdate = true;
await _tmPgWmsUpdate.UpdateTaBomAsync(bom);
}*/
WmsWebApiBomDetail tmp = new WmsWebApiBomDetail()
{
PId = b.Id,
POSNR = item.POSNR,
POSTP = item.POSTP,
IDNRK = item.IDNRK,
MAKTX_1 = item.MAKTX_1,
DUMPS = item.DUMPS,
MENGE = item.MENGE,
MEINS = item.MEINS,
SORTF = item.SORTF,
ALPGR = item.ALPGR,
ALPRF = item.ALPRF,
ALPST = item.ALPST,
EWAHR = item.EWAHR,
ITSOB = item.ITSOB,
LGORT = item.LGORT,
SANKA = item.SANKA,
SANFE = item.SANFE,
};
tmp.SetId(GuidGenerator);
bDetail.Add(tmp);
} }
else
{
bUpdate = true;
await _tmPgWmsUpdate.UpdateTaBomAsync(bom);
}*/
WmsWebApiBomDetail tmp = new WmsWebApiBomDetail() await _bomDtoRepository.AddBomAsync(b);
{ await _bomDtoRepository.AddBomDetailAsync(bDetail);
PId = b.Id, }
POSNR = item.POSNR, else
POSTP = item.POSTP, {
IDNRK = item.IDNRK, bPartGroup = true;
MAKTX_1 = item.MAKTX_1, result.MESSAGE = "没有对应物料组数据";
DUMPS = item.DUMPS,
MENGE = item.MENGE,
MEINS = item.MEINS,
SORTF = item.SORTF,
ALPGR = item.ALPGR,
ALPRF = item.ALPRF,
ALPST = item.ALPST,
EWAHR = item.EWAHR,
ITSOB = item.ITSOB,
LGORT = item.LGORT,
SANKA = item.SANKA,
SANFE = item.SANFE,
};
tmp.SetId(GuidGenerator);
bDetail.Add(tmp);
} }
await _bomDtoRepository.AddBomAsync(b); #endregion
await _bomDtoRepository.AddBomDetailAsync(bDetail);
} }
else
{
bPartGroup = true;
result.MESSAGE = "没有对应物料组数据";
}
#endregion
} }
} }
else
{
bOtherWork = true;
result.MESSAGE = "非长春工厂数据!";
}
await CurrentUnitOfWork.SaveChangesAsync();
} }
else catch (Exception ex)
{
bOtherWork = true;
result.MESSAGE = "非长春工厂数据!";
}
await CurrentUnitOfWork.SaveChangesAsync();
}
catch (Exception ex)
{
bomdto.ITYPE = ex.GetBaseException().Message;
bomdto.EnumRetryStatus = Enums.EnumRetryStatus.WaitRetry;
result.TYPE = 'E';
result.MESSAGE = ex.GetBaseException().Message;
if (IsRequestRetry == false)
{
//await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.BomAdd, content.ToString());
}
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
finally
{
if (IsRequestRetry == false)
{ {
Logger.LogInformation(bomdto.JSON); bomdto.ITYPE = ex.GetBaseException().Message;
bomdto.EnumRetryStatus = Enums.EnumRetryStatus.WaitRetry;
result.TYPE = 'E';
result.MESSAGE = ex.GetBaseException().Message;
if (bNotFind) if (IsRequestRetry == false)
{
bomdto.ITYPE = result.MESSAGE;
}
if (bUpdate)
{
bomdto.ITYPE = "更新!";
}
if (bOtherWork)
{
bomdto.ITYPE = "非长春工厂数据!";
}
if (bPartGroup)
{
bomdto.ITYPE = "没有对应物料组数据!";
}
if (bDel)
{
bomdto.ITYPE += "删除!";
}
try
{ {
await AddWmsWebApiBOMDtoNowUnitOfWorkAsync(bomdto); //await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.BomAdd, content.ToString());
} }
catch (Exception)
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
}
finally
{
if (IsRequestRetry == false)
{ {
Logger.LogInformation(bomdto.JSON);
if (bNotFind)
{
bomdto.ITYPE = result.MESSAGE;
}
if (bUpdate)
{
bomdto.ITYPE = "更新!";
}
if (bOtherWork)
{
bomdto.ITYPE = "非长春工厂数据!";
}
if (bPartGroup)
{
bomdto.ITYPE = "没有对应物料组数据!";
}
if (bDel)
{
bomdto.ITYPE += "删除!";
}
try try
{ {
await _asyncRetryPolicy.ExecuteAsync(async () => await AddJsonNowUnitOfWorkAsync(bomdto)); await AddWmsWebApiBOMDtoNowUnitOfWorkAsync(bomdto);
} }
catch (Exception ex) catch (Exception)
{ {
Logger.LogError("Bom JSON记录失败"); try
Logger.LogError(bomdto.JSON); {
Logger.LogError(ex.Message); await _asyncRetryPolicy.ExecuteAsync(async () => await AddJsonNowUnitOfWorkAsync(bomdto));
}
catch (Exception ex)
{
Logger.LogError("Bom JSON记录失败");
Logger.LogError(bomdto.JSON);
Logger.LogError(ex.Message);
}
} }
} }
} }
return result;
} }
return result;
}
private async Task AddWmsWebApiBOMDtoNowUnitOfWorkAsync(WmsWebApiBOMDTO wmsWebApiBOMDTO)
{
if (wmsWebApiBOMDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) private async Task AddWmsWebApiBOMDtoNowUnitOfWorkAsync(WmsWebApiBOMDTO wmsWebApiBOMDTO)
{ {
await _bomDtoRepository.AddAsync(wmsWebApiBOMDTO); if (wmsWebApiBOMDTO == null) { return; }
await uow.SaveChangesAsync();
}
}
private async Task AddJsonNowUnitOfWorkAsync(WmsWebApiBOMDTO wmsWebApiBOMDTO) using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{ {
if (wmsWebApiBOMDTO == null) { return; } await _bomDtoRepository.AddAsync(wmsWebApiBOMDTO);
await uow.SaveChangesAsync();
}
}
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) private async Task AddJsonNowUnitOfWorkAsync(WmsWebApiBOMDTO wmsWebApiBOMDTO)
{ {
await _bomJsonRepository.InsertAsync(wmsWebApiBOMDTO); if (wmsWebApiBOMDTO == null) { return; }
await uow.SaveChangesAsync();
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _bomJsonRepository.InsertAsync(wmsWebApiBOMDTO);
await uow.SaveChangesAsync();
}
} }
} }
} }

700
src/WmsWebApi.Application/OtherZll/OtherZllService.cs

@ -18,429 +18,431 @@ using WmsWebApi.Jsons;
using WmsWebApi.Options; using WmsWebApi.Options;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.OtherZll; namespace WmsWebApi.OtherZll
/// <summary>
/// 其他领物料
/// </summary>
[Route("/api/OtherZll")]
public class OtherZllService : ApplicationService, IOtherZllService
{ {
private readonly ITsStockDetailRepository _tsStockDetailRepository;
private readonly ITbProductReceiveRepository _tbProductReceiveRepository;
private readonly ITbBillRepository _tbBillRepository;
private readonly ITaPartRepository _taPartRepository;
private readonly ITaStoreLocationRepository _taStoreLocationRepository;
private readonly IOtherZllManager _otherZllManager;
private readonly ITLTransactionRepository _tlTransactionRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry;
private readonly IOtherZllJsonRepository _otherZllJsonRepository;
private readonly AsyncRetryPolicy _asyncRetryPolicy;
private readonly OtherZllConfigOptions _otherZllConfigOptions;
/// <summary> /// <summary>
/// 是否是请求重试 /// 其他领物料
/// </summary> /// </summary>
public bool IsRequestRetry { get; set; } = false; [Route("/api/OtherZll")]
public class OtherZllService : ApplicationService, IOtherZllService
public OtherZllService(ITsStockDetailRepository tsStockDetailRepository,
ITbProductReceiveRepository tbProductReceiveRepository,
ITbBillRepository tbBillRepository,
ITaPartRepository taPartRepository,
ITaStoreLocationRepository taStoreLocationRepository,
IOtherZllManager otherZllManager,
ITLTransactionRepository tlTransactionRepository,
TmPgWmsUpdate tmPgWmsUpdate,
Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager,
IBackgroundJobRequestRetry backgroundJobRequestRetry,
IOtherZllJsonRepository otherZllJsonRepository,
IOptionsMonitor<CustomConfigOptions> customConfigOptions,
IOptionsMonitor<OtherZllConfigOptions> otherZllConfigOptions)
{ {
_tsStockDetailRepository = tsStockDetailRepository; private readonly ITsStockDetailRepository _tsStockDetailRepository;
_tbProductReceiveRepository = tbProductReceiveRepository; private readonly ITbProductReceiveRepository _tbProductReceiveRepository;
_tbBillRepository = tbBillRepository; private readonly ITbBillRepository _tbBillRepository;
_taPartRepository = taPartRepository; private readonly ITaPartRepository _taPartRepository;
_taStoreLocationRepository = taStoreLocationRepository; private readonly ITaStoreLocationRepository _taStoreLocationRepository;
_otherZllManager = otherZllManager; private readonly IOtherZllManager _otherZllManager;
_tlTransactionRepository = tlTransactionRepository; private readonly ITLTransactionRepository _tlTransactionRepository;
_tmPgWmsUpdate = tmPgWmsUpdate; private readonly TmPgWmsUpdate _tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager; private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
_backgroundJobRequestRetry = backgroundJobRequestRetry; private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry;
_otherZllJsonRepository = otherZllJsonRepository; private readonly IOtherZllJsonRepository _otherZllJsonRepository;
_asyncRetryPolicy = Policy.Handle<Exception>() private readonly AsyncRetryPolicy _asyncRetryPolicy;
.WaitAndRetryAsync(new[] { private readonly OtherZllConfigOptions _otherZllConfigOptions;
/// <summary>
/// 是否是请求重试
/// </summary>
public bool IsRequestRetry { get; set; } = false;
public OtherZllService(ITsStockDetailRepository tsStockDetailRepository,
ITbProductReceiveRepository tbProductReceiveRepository,
ITbBillRepository tbBillRepository,
ITaPartRepository taPartRepository,
ITaStoreLocationRepository taStoreLocationRepository,
IOtherZllManager otherZllManager,
ITLTransactionRepository tlTransactionRepository,
TmPgWmsUpdate tmPgWmsUpdate,
Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager,
IBackgroundJobRequestRetry backgroundJobRequestRetry,
IOtherZllJsonRepository otherZllJsonRepository,
IOptionsMonitor<CustomConfigOptions> customConfigOptions,
IOptionsMonitor<OtherZllConfigOptions> otherZllConfigOptions)
{
_tsStockDetailRepository = tsStockDetailRepository;
_tbProductReceiveRepository = tbProductReceiveRepository;
_tbBillRepository = tbBillRepository;
_taPartRepository = taPartRepository;
_taStoreLocationRepository = taStoreLocationRepository;
_otherZllManager = otherZllManager;
_tlTransactionRepository = tlTransactionRepository;
_tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
_backgroundJobRequestRetry = backgroundJobRequestRetry;
_otherZllJsonRepository = otherZllJsonRepository;
_asyncRetryPolicy = Policy.Handle<Exception>()
.WaitAndRetryAsync(new[] {
TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5) TimeSpan.FromSeconds(5)
}, (exception, timeSpan, retryCount, context) => }, (exception, timeSpan, retryCount, context) =>
{ {
Logger.LogInformation($"执行失败,第 {retryCount} 次重试"); Logger.LogInformation($"执行失败,第 {retryCount} 次重试");
}); });
_otherZllConfigOptions = otherZllConfigOptions.CurrentValue; _otherZllConfigOptions = otherZllConfigOptions.CurrentValue;
}
[HttpPost("add")]
public async Task<ReturnResult> AddAsync([FromBody] object content)
{
var result = new ReturnResult();
List<OtherZllDto> _dtoList;
bool bTypeErr = false, bErr = false;
try
{
_dtoList = JsonConvert.DeserializeObject<List<OtherZllDto>>(content.ToString());
}
catch (Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
} }
if (_dtoList == null || _dtoList.Count() <= 0) [HttpPost("add")]
public async Task<ReturnResult> AddAsync([FromBody] object content)
{ {
bErr = true; var result = new ReturnResult();
result.MESSAGE = "err:没有1000工厂数据"; List<OtherZllDto> _dtoList;
return result; bool bTypeErr = false, bErr = false;
} try
{
WmsWebApiOtherZLLDTO dto = new WmsWebApiOtherZLLDTO(); _dtoList = JsonConvert.DeserializeObject<List<OtherZllDto>>(content.ToString());
dto.JSON = content.ToString(); }
dto.SetId(GuidGenerator); catch (Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
}
try if (_dtoList == null || _dtoList.Count() <= 0)
{
if (_dtoList[0].ZDJLX == "20")
{ {
var _dtoDetails = _dtoList.Where(p => p.WERKS == "1000").ToList(); bErr = true;
result.MESSAGE = "err:没有1000工厂数据";
return result;
}
if (_dtoDetails != null || _dtoDetails.Count() > 0) WmsWebApiOtherZLLDTO dto = new WmsWebApiOtherZLLDTO();
{ dto.JSON = content.ToString();
if (_otherZllConfigOptions.IsEnableErnamFilter == true) dto.SetId(GuidGenerator);
{
//根据配置文件过滤ERNAM
List<string> ernamFilters = _otherZllConfigOptions.ErnamFilters;
_dtoDetails = _dtoDetails.FindAll(e => ernamFilters.Contains(e.ERNAM));
}
}
if (_dtoDetails == null || _dtoDetails.Count() == 0) try
{ {
bErr = true; if (_dtoList[0].ZDJLX == "20")
result.MESSAGE = "err:没有1000工厂数据";
}
else
{ {
dto.ZLLDJ = _dtoDetails[0].ZLLDJ; var _dtoDetails = _dtoList.Where(p => p.WERKS == "1000").ToList();
dto.MBLNR = _dtoDetails[0].MBLNR;
dto.MJAHR = _dtoDetails[0].MJAHR;
dto.ZLLR = _dtoDetails[0].ZLLR;
var _billNumList = _dtoDetails.Select(p => p.MBLNR).Distinct().ToList(); if (_dtoDetails != null || _dtoDetails.Count() > 0)
foreach (var _billNum in _billNumList)
{ {
List<TB_BILL> _billList = new List<TB_BILL>(); if (_otherZllConfigOptions.IsEnableErnamFilter == true)
List<TB_PRODUCT_RECEIVE> _recieveList = new List<TB_PRODUCT_RECEIVE>(); {
List<TS_STOCK_DETAIL> _stockList = new List<TS_STOCK_DETAIL>(); //根据配置文件过滤ERNAM
List<TS_STOCK_DETAIL> _stockUpdateList = new List<TS_STOCK_DETAIL>(); List<string> ernamFilters = _otherZllConfigOptions.ErnamFilters;
List<TS_STOCK_DETAIL> _stockDelList = new List<TS_STOCK_DETAIL>(); _dtoDetails = _dtoDetails.FindAll(e => ernamFilters.Contains(e.ERNAM));
List<TL_TRANSACTION> _transList = new List<TL_TRANSACTION>(); }
}
var bill = await _tbBillRepository.FirstOrDefaultAsync(p => p.SourceBillNum2 == _billNum); if (_dtoDetails == null || _dtoDetails.Count() == 0)
{
bErr = true;
result.MESSAGE = "err:没有1000工厂数据";
}
else
{
dto.ZLLDJ = _dtoDetails[0].ZLLDJ;
dto.MBLNR = _dtoDetails[0].MBLNR;
dto.MJAHR = _dtoDetails[0].MJAHR;
dto.ZLLR = _dtoDetails[0].ZLLR;
if (bill == null) var _billNumList = _dtoDetails.Select(p => p.MBLNR).Distinct().ToList();
foreach (var _billNum in _billNumList)
{ {
var newDtoList = _dtoDetails.Where(p => p.MBLNR == _billNum).ToList(); List<TB_BILL> _billList = new List<TB_BILL>();
List<TB_PRODUCT_RECEIVE> _recieveList = new List<TB_PRODUCT_RECEIVE>();
List<TS_STOCK_DETAIL> _stockList = new List<TS_STOCK_DETAIL>();
List<TS_STOCK_DETAIL> _stockUpdateList = new List<TS_STOCK_DETAIL>();
List<TS_STOCK_DETAIL> _stockDelList = new List<TS_STOCK_DETAIL>();
List<TL_TRANSACTION> _transList = new List<TL_TRANSACTION>();
var tbBill = new TB_BILL var bill = await _tbBillRepository.FirstOrDefaultAsync(p => p.SourceBillNum2 == _billNum);
{
BillNum = _billNum + "." + newDtoList[0].ZLLDJ,
SourceBillNum2 = _billNum,
BillTime = DateTime.Now,
StartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
FinishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
OperName = "SAP",
DetailQty = newDtoList.Count,
BillType = 201,
SubBillType = 10100,
State = 2,
Remark = "otherzll",
AccountDate = DateTime.ParseExact(newDtoList[0].BUDAT, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture)
};
_billList.Add(tbBill);
var sumDetailList = newDtoList.Where(p => p.MBLNR == _billNum).GroupBy(x => new { x.MATNR, x.CHARG, x.LGORT1 }). if (bill == null)
Select(group => new
{
MATNR = group.Key.MATNR,
CHARG = group.Key.CHARG,
ERFMG = group.Sum(t => t.ERFMG),
LGORT = group.Key.LGORT1,
BUDAT = group.FirstOrDefault().BUDAT
});
foreach (var item in sumDetailList)
{ {
//判断物料信息 var newDtoList = _dtoDetails.Where(p => p.MBLNR == _billNum).ToList();
var part = await _taPartRepository.FirstOrDefaultAsync(p => p.PartCode == item.MATNR);
if (part == null)
{
//result.TYPE = 'E';
bTypeErr = true;
result.MESSAGE += $"err:物料 {item.MATNR} 不在WinWMS管理!";
continue;
}
if (!part.IsDeposit)
{
//result.TYPE = 'E';
bTypeErr = true;
result.MESSAGE += $"err:物料 {item.MATNR} 不属于其他领用件!";
continue;
}
if (string.IsNullOrEmpty(part.DefaultReceiveLocCode))
{
bTypeErr = true;
result.MESSAGE += $"err:物料 {item.MATNR} 未设置收货库位!";
continue;
}
var partLoc = await _taStoreLocationRepository.FirstOrDefaultAsync(p => p.LocCode == part.DefaultReceiveLocCode); var tbBill = new TB_BILL
if (partLoc == null)
{
bTypeErr = true;
result.MESSAGE += $"err:物料 {item.MATNR} 的默认收货库位未配置ERP库位!";
continue;
}
if (partLoc.ErpLocCode != item.LGORT)
{
bTypeErr = true;
result.MESSAGE += $"物料 {item.MATNR} 减库存!";
}
var _barcode = $"{item.MATNR}_{item.CHARG}";
var tmp = (OtherZllDto)newDtoList[0];
//插入productrecieve
var tbRecieve = new TB_PRODUCT_RECEIVE
{ {
BillNum = tbBill.BillNum, BillNum = _billNum + "." + newDtoList[0].ZLLDJ,
BarCode = _barcode, SourceBillNum2 = _billNum,
PartCode = item.MATNR, BillTime = DateTime.Now,
Batch = item.CHARG, StartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
FromLocCode = "", FinishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
ToLocCode = part.DefaultReceiveLocCode, OperName = "SAP",
Remark = part.QLevel, DetailQty = newDtoList.Count,
Qty = item.ERFMG, BillType = 201,
GoodQty = item.ERFMG, SubBillType = 10100,
State = 2, State = 2,
ReceiveDate = DateTime.Now, Remark = "otherzll",
ProduceDate = DateTime.Now, AccountDate = DateTime.ParseExact(newDtoList[0].BUDAT, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture)
LineId = tmp.ZLTLX, //领/退类型
ShiftName = tmp.ZLLDJ, //单据号
TeamName = tmp.ZEILE, //物料凭证中的项目
Unit = tmp.ZDJLX, //单据类型
TraceBackCode = tmp.MEINS, //基本计量单位
}; };
if (partLoc.ErpLocCode != item.LGORT) _billList.Add(tbBill);
{
tbRecieve.FromLocCode = part.DefaultReceiveLocCode; var sumDetailList = newDtoList.Where(p => p.MBLNR == _billNum).GroupBy(x => new { x.MATNR, x.CHARG, x.LGORT1 }).
tbRecieve.ToLocCode = item.LGORT; Select(group => new
tbRecieve.Qty = 0 - tbRecieve.Qty; {
} MATNR = group.Key.MATNR,
_recieveList.Add(tbRecieve); CHARG = group.Key.CHARG,
//插入ts_stock_detail ERFMG = group.Sum(t => t.ERFMG),
var tsStock = new TS_STOCK_DETAIL LGORT = group.Key.LGORT1,
BUDAT = group.FirstOrDefault().BUDAT
});
foreach (var item in sumDetailList)
{ {
BarCode = _barcode, //判断物料信息
PartCode = item.MATNR, var part = await _taPartRepository.FirstOrDefaultAsync(p => p.PartCode == item.MATNR);
Batch = item.CHARG, if (part == null)
EqptCode = "", {
LocCode = part.DefaultReceiveLocCode, //result.TYPE = 'E';
AreaCode = partLoc.AreaCode,//"FG", bTypeErr = true;
Qty = item.ERFMG, result.MESSAGE += $"err:物料 {item.MATNR} 不在WinWMS管理!";
UpdateQty = item.ERFMG, continue;
VendId = "", }
ProduceDate = DateTime.Now, if (!part.IsDeposit)
OverdueDate = (DateTime.Now).AddDays(part.ValidityDays), {
ReceiveDate = DateTime.Now, //result.TYPE = 'E';
VendBatch = item.CHARG, bTypeErr = true;
Remark = "", result.MESSAGE += $"err:物料 {item.MATNR} 不属于其他领用件!";
State = EnumStockState., continue;
Amount = 0, }
VinState = 0, if (string.IsNullOrEmpty(part.DefaultReceiveLocCode))
{
bTypeErr = true;
result.MESSAGE += $"err:物料 {item.MATNR} 未设置收货库位!";
continue;
}
}; var partLoc = await _taStoreLocationRepository.FirstOrDefaultAsync(p => p.LocCode == part.DefaultReceiveLocCode);
if (partLoc == null)
{
bTypeErr = true;
result.MESSAGE += $"err:物料 {item.MATNR} 的默认收货库位未配置ERP库位!";
continue;
}
if (partLoc.ErpLocCode != item.LGORT)
{
bTypeErr = true;
result.MESSAGE += $"物料 {item.MATNR} 减库存!";
}
var _barcode = $"{item.MATNR}_{item.CHARG}";
var tmp = (OtherZllDto)newDtoList[0];
//插入productrecieve
var tbRecieve = new TB_PRODUCT_RECEIVE
{
BillNum = tbBill.BillNum,
BarCode = _barcode,
PartCode = item.MATNR,
Batch = item.CHARG,
FromLocCode = "",
ToLocCode = part.DefaultReceiveLocCode,
Remark = part.QLevel,
Qty = item.ERFMG,
GoodQty = item.ERFMG,
State = 2,
ReceiveDate = DateTime.Now,
ProduceDate = DateTime.Now,
LineId = tmp.ZLTLX, //领/退类型
ShiftName = tmp.ZLLDJ, //单据号
TeamName = tmp.ZEILE, //物料凭证中的项目
Unit = tmp.ZDJLX, //单据类型
TraceBackCode = tmp.MEINS, //基本计量单位
};
if (partLoc.ErpLocCode != item.LGORT)
{
tbRecieve.FromLocCode = part.DefaultReceiveLocCode;
tbRecieve.ToLocCode = item.LGORT;
tbRecieve.Qty = 0 - tbRecieve.Qty;
}
_recieveList.Add(tbRecieve);
//插入ts_stock_detail
var tsStock = new TS_STOCK_DETAIL
{
BarCode = _barcode,
PartCode = item.MATNR,
Batch = item.CHARG,
EqptCode = "",
LocCode = part.DefaultReceiveLocCode,
AreaCode = partLoc.AreaCode,//"FG",
Qty = item.ERFMG,
UpdateQty = item.ERFMG,
VendId = "",
ProduceDate = DateTime.Now,
OverdueDate = (DateTime.Now).AddDays(part.ValidityDays),
ReceiveDate = DateTime.Now,
VendBatch = item.CHARG,
Remark = "",
State = EnumStockState.,
Amount = 0,
VinState = 0,
var stock = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode };
&& p.LocCode == part.DefaultReceiveLocCode
&& p.State == EnumStockState.); var stock = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode
if (partLoc.ErpLocCode != item.LGORT)//出库 && p.LocCode == part.DefaultReceiveLocCode
{ && p.State == EnumStockState.);
if (stock == null || stock.Qty - item.ERFMG < 0) if (partLoc.ErpLocCode != item.LGORT)//出库
{ {
result.TYPE = 'E'; if (stock == null || stock.Qty - item.ERFMG < 0)
bErr = true; {
result.MESSAGE = $"err:物料 {item.MATNR} 批次 {item.CHARG} 的库存不足!"; result.TYPE = 'E';
break; bErr = true;
result.MESSAGE = $"err:物料 {item.MATNR} 批次 {item.CHARG} 的库存不足!";
break;
}
else if (stock.Qty - item.ERFMG == 0)
{
_stockDelList.Add(tsStock);
}
else
{
tsStock.Qty = 0 - tsStock.Qty;
tsStock.UpdateQty = tsStock.Qty;
_stockUpdateList.Add(tsStock);
}
} }
else if (stock.Qty - item.ERFMG == 0) else//入库
{ {
_stockDelList.Add(tsStock); if (stock == null)
{
_stockList.Add(tsStock);
}
else
{
_stockUpdateList.Add(tsStock);
}
} }
else //插入tl_transaction
var tlTrans = new TL_TRANSACTION
{
OperName = "SAP",
LogTime = tbBill.AccountDate ?? DateTime.Now,
BillNum = tbBill.BillNum,
BillType = tbBill.BillType,
SubBillType = tbBill.SubBillType,
PartCode = item.MATNR,
Batch = item.CHARG,
Qty = item.ERFMG,
BarCode = _barcode,
LocCode = part.DefaultReceiveLocCode,
EqptCode = item.LGORT,
Remark = "In",
State = 2,
TransType = 1
};
try
{ {
tsStock.Qty = 0 - tsStock.Qty; tlTrans.LogTime = DateTime.ParseExact(item.BUDAT, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
tsStock.UpdateQty = tsStock.Qty;
_stockUpdateList.Add(tsStock);
} }
} catch (Exception)
else//入库
{
if (stock == null)
{ {
_stockList.Add(tsStock); tlTrans.LogTime = tbBill.AccountDate ?? DateTime.Now;
} }
else if (partLoc.ErpLocCode != item.LGORT)
{ {
_stockUpdateList.Add(tsStock); tlTrans.Qty = 0 - tlTrans.Qty;
tlTrans.Remark = "Out";
tlTrans.TransType = 0;
} }
_transList.Add(tlTrans);
} }
//插入tl_transaction if (!bErr)
var tlTrans = new TL_TRANSACTION
{
OperName = "SAP",
LogTime = tbBill.AccountDate ?? DateTime.Now,
BillNum = tbBill.BillNum,
BillType = tbBill.BillType,
SubBillType = tbBill.SubBillType,
PartCode = item.MATNR,
Batch = item.CHARG,
Qty = item.ERFMG,
BarCode = _barcode,
LocCode = part.DefaultReceiveLocCode,
EqptCode = item.LGORT,
Remark = "In",
State = 2,
TransType = 1
};
try
{
tlTrans.LogTime = DateTime.ParseExact(item.BUDAT, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
}
catch (Exception)
{ {
tlTrans.LogTime = tbBill.AccountDate ?? DateTime.Now; if (_recieveList.Count > 0)
} {
if (partLoc.ErpLocCode != item.LGORT) await _tbBillRepository.AddManyAsync(_billList);
{ await _tbProductReceiveRepository.AddAsync(_recieveList);
tlTrans.Qty = 0 - tlTrans.Qty; }
tlTrans.Remark = "Out"; if (_stockList != null && _stockList.Count() > 0)
tlTrans.TransType = 0; await _tsStockDetailRepository.AddAsync(_stockList);
if (_stockUpdateList != null && _stockUpdateList.Count() > 0)
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList);
if (_stockDelList != null && _stockDelList.Count() > 0)
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList);
await _tlTransactionRepository.AddAsync(_transList);
} }
_transList.Add(tlTrans);
} }
if (!bErr) else
{ {
if (_recieveList.Count > 0) result.TYPE = 'E';
{ bErr = true;
await _tbBillRepository.AddManyAsync(_billList); result.MESSAGE = $"err:单据 {_billNum} 已存在";
await _tbProductReceiveRepository.AddAsync(_recieveList); break;
}
if (_stockList != null && _stockList.Count() > 0)
await _tsStockDetailRepository.AddAsync(_stockList);
if (_stockUpdateList != null && _stockUpdateList.Count() > 0)
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList);
if (_stockDelList != null && _stockDelList.Count() > 0)
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList);
await _tlTransactionRepository.AddAsync(_transList);
} }
} }
else }
{ if (bErr || bTypeErr)
result.TYPE = 'E'; {
bErr = true; dto.ITYPE = result.MESSAGE;
result.MESSAGE = $"err:单据 {_billNum} 已存在";
break;
}
} }
} }
if (bErr || bTypeErr) else
{ {
dto.ITYPE = result.MESSAGE; result.MESSAGE = "err:非物流领料单";
} }
await CurrentUnitOfWork.SaveChangesAsync();
} }
else catch (Exception ex)
{ {
result.MESSAGE = "err:非物流领料单"; dto.ITYPE = ex.GetBaseException().Message;
} dto.EnumRetryStatus = Enums.EnumRetryStatus.WaitRetry;
await CurrentUnitOfWork.SaveChangesAsync();
}
catch (Exception ex)
{
dto.ITYPE = ex.GetBaseException().Message;
dto.EnumRetryStatus = Enums.EnumRetryStatus.WaitRetry;
if (IsRequestRetry == false) if (IsRequestRetry == false)
{
try
{ {
await _asyncRetryPolicy.ExecuteAsync(async () => await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.OtherZllAdd, content.ToString())); try
} {
catch (Exception) await _asyncRetryPolicy.ExecuteAsync(async () => await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.OtherZllAdd, content.ToString()));
{ }
throw new Exception("操作数据库失败,请稍后重试。", ex); catch (Exception)
{
throw new Exception("操作数据库失败,请稍后重试。", ex);
}
} }
}
throw new Exception("操作数据库失败,稍后系统自动重试。", ex); throw new Exception("操作数据库失败,稍后系统自动重试。", ex);
} }
finally finally
{
if (IsRequestRetry == false)
{ {
Logger.LogInformation(dto.JSON); if (IsRequestRetry == false)
try
{
await AddOtherZLLDtoNowUnitOfWorkAsync(dto);
}
catch (Exception)
{ {
Logger.LogInformation(dto.JSON);
try try
{ {
await _asyncRetryPolicy.ExecuteAsync(async () => await AddJsonNowUnitOfWorkAsync(dto)); await AddOtherZLLDtoNowUnitOfWorkAsync(dto);
} }
catch (Exception ex) catch (Exception)
{ {
Logger.LogError("OtherZll JSON记录失败"); try
Logger.LogError(dto.JSON); {
Logger.LogError(ex.Message); await _asyncRetryPolicy.ExecuteAsync(async () => await AddJsonNowUnitOfWorkAsync(dto));
}
catch (Exception ex)
{
Logger.LogError("OtherZll JSON记录失败");
Logger.LogError(dto.JSON);
Logger.LogError(ex.Message);
}
} }
} }
} }
}
return result;
}
private async Task AddOtherZLLDtoNowUnitOfWorkAsync(WmsWebApiOtherZLLDTO wmsWebApiOtherZLLDTO) return result;
{ }
if (wmsWebApiOtherZLLDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) private async Task AddOtherZLLDtoNowUnitOfWorkAsync(WmsWebApiOtherZLLDTO wmsWebApiOtherZLLDTO)
{ {
await _otherZllManager.AddAsync(wmsWebApiOtherZLLDTO); if (wmsWebApiOtherZLLDTO == null) { return; }
await uow.SaveChangesAsync();
}
}
private async Task AddJsonNowUnitOfWorkAsync(WmsWebApiOtherZLLDTO wmsWebApiOtherZLLDTO) using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{ {
if (wmsWebApiOtherZLLDTO == null) { return; } await _otherZllManager.AddAsync(wmsWebApiOtherZLLDTO);
await uow.SaveChangesAsync();
}
}
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) private async Task AddJsonNowUnitOfWorkAsync(WmsWebApiOtherZLLDTO wmsWebApiOtherZLLDTO)
{ {
await _otherZllJsonRepository.InsertAsync(wmsWebApiOtherZLLDTO); if (wmsWebApiOtherZLLDTO == null) { return; }
await uow.SaveChangesAsync();
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _otherZllJsonRepository.InsertAsync(wmsWebApiOtherZLLDTO);
await uow.SaveChangesAsync();
}
} }
} }
} }

404
src/WmsWebApi.Application/PPlan/PPlanService.cs

@ -14,252 +14,254 @@ using WmsWebApi.Jsons;
using WmsWebApi.PPLan; using WmsWebApi.PPLan;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.PPlan; namespace WmsWebApi.PPlan
/// <summary>
/// 计划
/// </summary>
[Route("/api/PPlan")]
public class PPlanService : ApplicationService, IPPlanService
{ {
private readonly ITmPgPartgroupRepository _tmPgPartgroupRepository;
private readonly ITmPgPlanRepository _tmPgPlanRepository;
private readonly ITbBillRepository _tbBillRepository;
private readonly ITaPartRepository _taPartRepository;
private readonly IPPlanManager _pplanDtoRepository;
private readonly TmPgWmsUpdate _tmPgWmsUpdate;
private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry;
private readonly IPPlanJsonRepository _pPlanJsonRepository;
private readonly AsyncRetryPolicy _asyncRetryPolicy;
/// <summary> /// <summary>
/// 是否是请求重试 /// 计划
/// </summary> /// </summary>
public bool IsRequestRetry { get; set; } = false; [Route("/api/PPlan")]
public class PPlanService : ApplicationService, IPPlanService
public PPlanService(ITmPgPartgroupRepository tmPgPartgroupRepository,
ITmPgPlanRepository tmPgPlanRepository,
ITbBillRepository tbBillRepository,
ITaPartRepository taPartRepository,
IPPlanManager pplanDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate,
Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager,
IBackgroundJobRequestRetry backgroundJobRequestRetry,
IPPlanJsonRepository pPlanJsonRepository)
{ {
_tmPgPartgroupRepository = tmPgPartgroupRepository; private readonly ITmPgPartgroupRepository _tmPgPartgroupRepository;
_tmPgPlanRepository = tmPgPlanRepository; private readonly ITmPgPlanRepository _tmPgPlanRepository;
_tbBillRepository = tbBillRepository; private readonly ITbBillRepository _tbBillRepository;
_taPartRepository = taPartRepository; private readonly ITaPartRepository _taPartRepository;
_pplanDtoRepository = pplanDtoRepository; private readonly IPPlanManager _pplanDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate; private readonly TmPgWmsUpdate _tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager; private readonly Volo.Abp.Uow.IUnitOfWorkManager _unitOfWorkManager;
_backgroundJobRequestRetry = backgroundJobRequestRetry; private readonly IBackgroundJobRequestRetry _backgroundJobRequestRetry;
_pPlanJsonRepository = pPlanJsonRepository; private readonly IPPlanJsonRepository _pPlanJsonRepository;
_asyncRetryPolicy = Policy.Handle<Exception>() private readonly AsyncRetryPolicy _asyncRetryPolicy;
.WaitAndRetryAsync(new[] {
/// <summary>
/// 是否是请求重试
/// </summary>
public bool IsRequestRetry { get; set; } = false;
public PPlanService(ITmPgPartgroupRepository tmPgPartgroupRepository,
ITmPgPlanRepository tmPgPlanRepository,
ITbBillRepository tbBillRepository,
ITaPartRepository taPartRepository,
IPPlanManager pplanDtoRepository,
TmPgWmsUpdate tmPgWmsUpdate,
Volo.Abp.Uow.IUnitOfWorkManager unitOfWorkManager,
IBackgroundJobRequestRetry backgroundJobRequestRetry,
IPPlanJsonRepository pPlanJsonRepository)
{
_tmPgPartgroupRepository = tmPgPartgroupRepository;
_tmPgPlanRepository = tmPgPlanRepository;
_tbBillRepository = tbBillRepository;
_taPartRepository = taPartRepository;
_pplanDtoRepository = pplanDtoRepository;
_tmPgWmsUpdate = tmPgWmsUpdate;
_unitOfWorkManager = unitOfWorkManager;
_backgroundJobRequestRetry = backgroundJobRequestRetry;
_pPlanJsonRepository = pPlanJsonRepository;
_asyncRetryPolicy = Policy.Handle<Exception>()
.WaitAndRetryAsync(new[] {
TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5) TimeSpan.FromSeconds(5)
}, (exception, timeSpan, retryCount, context) => }, (exception, timeSpan, retryCount, context) =>
{ {
Logger.LogInformation($"执行失败,第 {retryCount} 次重试"); Logger.LogInformation($"执行失败,第 {retryCount} 次重试");
}); });
}
[HttpPost("add")]
//[UnitOfWork(false)]
public async Task<ReturnResult> AddAsync([FromBody] object content)
{
var result = new ReturnResult();
PPlanDto _planDto;
bool bUpdate = false,bOtherWork = false,bErr = false;
try
{
_planDto = JsonConvert.DeserializeObject<PPlanDto>(content.ToString());
}
catch (Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
} }
WmsWebApiPPLANDTO dto = new WmsWebApiPPLANDTO() [HttpPost("add")]
{ //[UnitOfWork(false)]
PEDTR = _planDto.PEDTR, public async Task<ReturnResult> AddAsync([FromBody] object content)
SCHGRUP = _planDto.SCHGRUP,
KAPTPROG = _planDto.KAPTPROG,
MATNR = _planDto.MATNR,
MAKTX = _planDto.MAKTX,
WERKS = _planDto.WERKS,
VERID = _planDto.VERID,
ZSCSX = _planDto.ZSCSX,
ZMACD = _planDto.ZMACD,
ZMATX = _planDto.ZMATX,
DISPO = _planDto.DISPO,
GSMNG = _planDto.GSMNG,
ZBZSM = _planDto.ZBZSM,
XUBNAME = _planDto.XUBNAME,
ZCDATE = _planDto.ZCDATE,
ZCTIME = _planDto.ZCTIME,
JSON = content.ToString()
};
dto.SetId(GuidGenerator);
try
{ {
if (_planDto.WERKS != "1000") var result = new ReturnResult();
PPlanDto _planDto;
bool bUpdate = false, bOtherWork = false, bErr = false;
try
{ {
bOtherWork = true; _planDto = JsonConvert.DeserializeObject<PPlanDto>(content.ToString());
result.MESSAGE = "其他工厂数据";
} }
else catch (Exception ex)
{
result.TYPE = 'E';
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result;
}
WmsWebApiPPLANDTO dto = new WmsWebApiPPLANDTO()
{
PEDTR = _planDto.PEDTR,
SCHGRUP = _planDto.SCHGRUP,
KAPTPROG = _planDto.KAPTPROG,
MATNR = _planDto.MATNR,
MAKTX = _planDto.MAKTX,
WERKS = _planDto.WERKS,
VERID = _planDto.VERID,
ZSCSX = _planDto.ZSCSX,
ZMACD = _planDto.ZMACD,
ZMATX = _planDto.ZMATX,
DISPO = _planDto.DISPO,
GSMNG = _planDto.GSMNG,
ZBZSM = _planDto.ZBZSM,
XUBNAME = _planDto.XUBNAME,
ZCDATE = _planDto.ZCDATE,
ZCTIME = _planDto.ZCTIME,
JSON = content.ToString()
};
dto.SetId(GuidGenerator);
try
{ {
if (string.IsNullOrEmpty(_planDto.PEDTR) || string.IsNullOrEmpty(_planDto.SCHGRUP) || if (_planDto.WERKS != "1000")
string.IsNullOrEmpty(_planDto.KAPTPROG) || string.IsNullOrEmpty(_planDto.MATNR))
throw new Exception($"计划中 订单日期、分组、班次、物料号均不能为空!");
//var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _planDto.MATNR);
//if (part == null)
// throw new Exception($"没有找到物料号!{_planDto.MATNR}");
if (_planDto.MATNR.StartsWith("3"))
{ {
// 查找是否有该计划 bOtherWork = true;
var _billnum = _planDto.PEDTR + "-" + _planDto.SCHGRUP + "-" + _planDto.KAPTPROG; result.MESSAGE = "其他工厂数据";
var bill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == _billnum); }
if (bill == null) else
{
if (string.IsNullOrEmpty(_planDto.PEDTR) || string.IsNullOrEmpty(_planDto.SCHGRUP) ||
string.IsNullOrEmpty(_planDto.KAPTPROG) || string.IsNullOrEmpty(_planDto.MATNR))
throw new Exception($"计划中 订单日期、分组、班次、物料号均不能为空!");
//var part = _taPartRepository.FirstOrDefault(p => p.PartCode == _planDto.MATNR);
//if (part == null)
// throw new Exception($"没有找到物料号!{_planDto.MATNR}");
if (_planDto.MATNR.StartsWith("3"))
{ {
var tbBill = new TB_BILL // 查找是否有该计划
var _billnum = _planDto.PEDTR + "-" + _planDto.SCHGRUP + "-" + _planDto.KAPTPROG;
var bill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == _billnum);
if (bill == null)
{ {
BillNum = _billnum, var tbBill = new TB_BILL
BillTime = DateTime.Now, {
OperName = _planDto.XUBNAME, BillNum = _billnum,
DetailQty = 1, BillTime = DateTime.Now,
BillType = 605, OperName = _planDto.XUBNAME,
SubBillType = 60101, DetailQty = 1,
State = 1, BillType = 605,
StartTime = _planDto.PEDTR.Replace("-", ""), SubBillType = 60101,
GateName = _planDto.KAPTPROG, State = 1,
DockCode = String.Empty StartTime = _planDto.PEDTR.Replace("-", ""),
}; GateName = _planDto.KAPTPROG,
await _tbBillRepository.UpsertAsync(tbBill); DockCode = String.Empty
} };
await _tbBillRepository.UpsertAsync(tbBill);
}
var tmPlan = new TM_PG_PLAN var tmPlan = new TM_PG_PLAN
{ {
BillNum = _billnum, BillNum = _billnum,
PlanTime = _planDto.PEDTR, PlanTime = _planDto.PEDTR,
Group = _planDto.SCHGRUP, Group = _planDto.SCHGRUP,
PlanShiftName = _planDto.KAPTPROG, PlanShiftName = _planDto.KAPTPROG,
PartCode = _planDto.MATNR, PartCode = _planDto.MATNR,
House = _planDto.WERKS, House = _planDto.WERKS,
BomVersion = _planDto.VERID, BomVersion = _planDto.VERID,
Qty = _planDto.GSMNG, Qty = _planDto.GSMNG,
Remark = _planDto.ZBZSM, Remark = _planDto.ZBZSM,
IsProduct = 1, IsProduct = 1,
}; };
//判断是增加还是更新 //判断是增加还是更新
var plan = await _tmPgPlanRepository.FirstOrDefaultAsync(p => p.PlanTime == _planDto.PEDTR var plan = await _tmPgPlanRepository.FirstOrDefaultAsync(p => p.PlanTime == _planDto.PEDTR
&& p.Group == _planDto.SCHGRUP && p.Group == _planDto.SCHGRUP
&& p.PlanShiftName == _planDto.KAPTPROG && p.PlanShiftName == _planDto.KAPTPROG
&& p.PartCode == _planDto.MATNR); && p.PartCode == _planDto.MATNR);
if (plan == null) if (plan == null)
{ {
await _tmPgPlanRepository.AddAsync(tmPlan); await _tmPgPlanRepository.AddAsync(tmPlan);
await _tmPgWmsUpdate.UpdateTbBillDetailQtyAsync(_billnum); await _tmPgWmsUpdate.UpdateTbBillDetailQtyAsync(_billnum);
}
else
{
bUpdate = true;
await _tmPgWmsUpdate.UpdateTmPlanAsync(tmPlan);
}
} }
else else
{ {
bUpdate = true; bErr = true;
await _tmPgWmsUpdate.UpdateTmPlanAsync(tmPlan); result.MESSAGE = $"非WinWMS使用的物料号!{_planDto.MATNR}";
} }
} }
else await CurrentUnitOfWork.SaveChangesAsync();
{
bErr = true;
result.MESSAGE = $"非WinWMS使用的物料号!{_planDto.MATNR}";
}
} }
await CurrentUnitOfWork.SaveChangesAsync(); catch (Exception ex)
}
catch (Exception ex)
{
bErr = true;
dto.EnumRetryStatus = Enums.EnumRetryStatus.WaitRetry;
result.TYPE = 'E';
result.MESSAGE = ex.GetBaseException().Message;
if (IsRequestRetry == false)
{ {
//await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.PPlanAdd, content.ToString()); bErr = true;
} dto.EnumRetryStatus = Enums.EnumRetryStatus.WaitRetry;
result.TYPE = 'E';
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex); result.MESSAGE = ex.GetBaseException().Message;
}
finally
{
if (IsRequestRetry == false)
{
Logger.LogInformation(dto.JSON);
if (bUpdate) if (IsRequestRetry == false)
{ {
dto.ITYPE = "更新!"; //await _backgroundJobRequestRetry.AddBackgroundJobAsync(EnumActionName.PPlanAdd, content.ToString());
} }
if (bOtherWork)
{ throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
dto.ITYPE = "非长春工厂数据!"; }
} finally
if (bErr) {
{ if (IsRequestRetry == false)
dto.ITYPE = result.MESSAGE;
}
try
{
await AddWmsWebApiPPLANDTONowUnitOfWorkAsync(dto);
}
catch (Exception)
{ {
Logger.LogInformation(dto.JSON);
if (bUpdate)
{
dto.ITYPE = "更新!";
}
if (bOtherWork)
{
dto.ITYPE = "非长春工厂数据!";
}
if (bErr)
{
dto.ITYPE = result.MESSAGE;
}
try try
{ {
await _asyncRetryPolicy.ExecuteAsync(async () => await AddJsonNowUnitOfWorkAsync(dto)); await AddWmsWebApiPPLANDTONowUnitOfWorkAsync(dto);
} }
catch (Exception ex) catch (Exception)
{ {
Logger.LogError("PPlan JSON记录失败"); try
Logger.LogError(dto.JSON); {
Logger.LogError(ex.Message); await _asyncRetryPolicy.ExecuteAsync(async () => await AddJsonNowUnitOfWorkAsync(dto));
}
catch (Exception ex)
{
Logger.LogError("PPlan JSON记录失败");
Logger.LogError(dto.JSON);
Logger.LogError(ex.Message);
}
} }
} }
} }
}
return result; return result;
} }
private async Task AddWmsWebApiPPLANDTONowUnitOfWorkAsync(WmsWebApiPPLANDTO wmsWebApiPPLANDTO)
{
if (wmsWebApiPPLANDTO == null) { return; }
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) private async Task AddWmsWebApiPPLANDTONowUnitOfWorkAsync(WmsWebApiPPLANDTO wmsWebApiPPLANDTO)
{ {
await _pplanDtoRepository.AddAsync(wmsWebApiPPLANDTO); if (wmsWebApiPPLANDTO == null) { return; }
await uow.SaveChangesAsync();
}
}
private async Task AddJsonNowUnitOfWorkAsync(WmsWebApiPPLANDTO wmsWebApiPPLANDTO) using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{ {
if (wmsWebApiPPLANDTO == null) { return; } await _pplanDtoRepository.AddAsync(wmsWebApiPPLANDTO);
await uow.SaveChangesAsync();
}
}
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) private async Task AddJsonNowUnitOfWorkAsync(WmsWebApiPPLANDTO wmsWebApiPPLANDTO)
{ {
await _pPlanJsonRepository.InsertAsync(wmsWebApiPPLANDTO); if (wmsWebApiPPLANDTO == null) { return; }
await uow.SaveChangesAsync();
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
await _pPlanJsonRepository.InsertAsync(wmsWebApiPPLANDTO);
await uow.SaveChangesAsync();
}
} }
} }
} }

3
src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs

@ -21,7 +21,7 @@ using WmsWebApi.Wms;
using WmsWebApi.WMS; using WmsWebApi.WMS;
using WmsWebApi.WMS.IRepository; using WmsWebApi.WMS.IRepository;
namespace WmsWebApi.ProductRecieve; namespace WmsWebApi.ProductRecieve {
/// <summary> /// <summary>
/// Agv完工收货入库 /// Agv完工收货入库
@ -401,3 +401,4 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
} }
} }
} }
}

23
src/WmsWebApi.Application/Purchase/PurchaseService.cs

@ -17,7 +17,7 @@ using WmsWebApi.Jsons;
using WmsWebApi.Purchase; using WmsWebApi.Purchase;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.PPlan; namespace WmsWebApi.PPlan {
/// <summary> /// <summary>
/// 采购 /// 采购
@ -58,7 +58,7 @@ public class PurchaseService : ApplicationService, IPurchaseService
_tsStockDetailRepository = tsStockDetailRepository; _tsStockDetailRepository = tsStockDetailRepository;
_tbProductReceiveRepository = tbProductReceiveRepository; _tbProductReceiveRepository = tbProductReceiveRepository;
_tbBillRepository = tbBillRepository; _tbBillRepository = tbBillRepository;
_taPartRepository = taPartRepository; _taPartRepository = taPartRepository;
_taStoreLocationRepository = taStoreLocationRepository; _taStoreLocationRepository = taStoreLocationRepository;
_purchaseManager = purchaseManager; _purchaseManager = purchaseManager;
_tlTransactionRepository = tlTransactionRepository; _tlTransactionRepository = tlTransactionRepository;
@ -84,7 +84,7 @@ public class PurchaseService : ApplicationService, IPurchaseService
{ {
var result = new ReturnResult(); var result = new ReturnResult();
PurchaseDto _purchaseDto; PurchaseDto _purchaseDto;
bool bUpdate = false,bOtherWork = false,bErr = false; bool bUpdate = false, bOtherWork = false, bErr = false;
bool bTypeErr = false; bool bTypeErr = false;
try try
{ {
@ -110,7 +110,7 @@ public class PurchaseService : ApplicationService, IPurchaseService
try try
{ {
var _dtoDetails = _purchaseDto.zzmseg.Where(p => p.WERKS == "1000"); var _dtoDetails = _purchaseDto.zzmseg.Where(p => p.WERKS == "1000");
if(_dtoDetails == null || _dtoDetails.Count() == 0) if (_dtoDetails == null || _dtoDetails.Count() == 0)
{ {
bOtherWork = true; bOtherWork = true;
result.MESSAGE = "err:没有1000工厂数据!"; result.MESSAGE = "err:没有1000工厂数据!";
@ -132,7 +132,7 @@ public class PurchaseService : ApplicationService, IPurchaseService
{ {
var tbBill = new TB_BILL var tbBill = new TB_BILL
{ {
BillNum = _purchaseDto.MBLNR+"."+po, BillNum = _purchaseDto.MBLNR + "." + po,
SourceBillNum2 = _purchaseDto.MBLNR, SourceBillNum2 = _purchaseDto.MBLNR,
BillTime = DateTime.Now, BillTime = DateTime.Now,
StartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), StartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
@ -148,7 +148,7 @@ public class PurchaseService : ApplicationService, IPurchaseService
//_billList.Add(tbBill); //_billList.Add(tbBill);
bool bHaveDetails = false; bool bHaveDetails = false;
var newDtoList = _dtoDetails.Where(p=>p.EBELN == po).GroupBy(x => new { x.MATNR, x.CHARG }). var newDtoList = _dtoDetails.Where(p => p.EBELN == po).GroupBy(x => new { x.MATNR, x.CHARG }).
Select(group => new Select(group => new
{ {
MATNR = group.Key.MATNR, MATNR = group.Key.MATNR,
@ -167,7 +167,7 @@ public class PurchaseService : ApplicationService, IPurchaseService
result.MESSAGE += $"err:物料 {item.MATNR} 不在WinWMS管理!"; result.MESSAGE += $"err:物料 {item.MATNR} 不在WinWMS管理!";
continue; continue;
} }
if(!part.IsAskMerge) if (!part.IsAskMerge)
{ {
//result.TYPE = 'E'; //result.TYPE = 'E';
bTypeErr = true; bTypeErr = true;
@ -341,7 +341,7 @@ public class PurchaseService : ApplicationService, IPurchaseService
} }
bHaveDetails = true; bHaveDetails = true;
} }
if(bHaveDetails) if (bHaveDetails)
_billList.Add(tbBill); _billList.Add(tbBill);
} }
if (!bErr) if (!bErr)
@ -350,9 +350,9 @@ public class PurchaseService : ApplicationService, IPurchaseService
await _tbProductReceiveRepository.AddAsync(_recieveList); await _tbProductReceiveRepository.AddAsync(_recieveList);
if (_stockList != null && _stockList.Count() > 0) if (_stockList != null && _stockList.Count() > 0)
await _tsStockDetailRepository.AddAsync(_stockList); await _tsStockDetailRepository.AddAsync(_stockList);
if(_stockUpdateList != null && _stockUpdateList.Count() > 0) if (_stockUpdateList != null && _stockUpdateList.Count() > 0)
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList);
if(_stockDelList != null && _stockDelList.Count() > 0) if (_stockDelList != null && _stockDelList.Count() > 0)
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList); await _tmPgWmsUpdate.DeleteTsStock(_stockDelList);
await _tlTransactionRepository.AddAsync(_transList); await _tlTransactionRepository.AddAsync(_transList);
} }
@ -366,7 +366,7 @@ public class PurchaseService : ApplicationService, IPurchaseService
} }
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
} }
catch(Exception ex) catch (Exception ex)
{ {
bErr = true; bErr = true;
dto.EnumRetryStatus = Enums.EnumRetryStatus.WaitRetry; dto.EnumRetryStatus = Enums.EnumRetryStatus.WaitRetry;
@ -450,3 +450,4 @@ public class PurchaseService : ApplicationService, IPurchaseService
} }
} }
} }
}

3
src/WmsWebApi.Application/StockMove/StockMoveService.cs

@ -23,7 +23,7 @@ using WmsWebApi.Wms;
using WmsWebApi.WMS; using WmsWebApi.WMS;
using WmsWebApi.WMS.IRepository; using WmsWebApi.WMS.IRepository;
namespace WmsWebApi.StockMove; namespace WmsWebApi.StockMove {
/// <summary> /// <summary>
/// Agv出入库 /// Agv出入库
@ -570,3 +570,4 @@ public class StockMoveService : ApplicationService, IStockMoveService
} }
} }
} }
}

16
src/WmsWebApi.Application/TbParts/PartService.cs

@ -5,6 +5,7 @@ using Polly;
using Polly.Retry; using Polly.Retry;
using System; using System;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
@ -14,8 +15,8 @@ using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Jsons; using WmsWebApi.Jsons;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Parts; namespace WmsWebApi.Parts
{
/// <summary> /// <summary>
/// 零件 /// 零件
/// </summary> /// </summary>
@ -71,11 +72,15 @@ public class PartService : ApplicationService, IPartService
{ {
var result = new ReturnResult(); var result = new ReturnResult();
PartDto _part; PartDto _part;
bool bUpdate = false,bOtherWork = false,bErr = false; bool bUpdate = false, bOtherWork = false, bErr = false;
try try
{ {
_part = JsonConvert.DeserializeObject<PartDto>(content.ToString()); string contentstr = content.ToString();
} byte[] space = new byte[] { 0xc2, 0xa0 };
string UTFSpace = Encoding.GetEncoding("UTF-8").GetString(space);
contentstr = contentstr.Replace(UTFSpace, " ");
_part = JsonConvert.DeserializeObject<PartDto>(contentstr.ToString());
}
catch (Exception ex) catch (Exception ex)
{ {
result.TYPE = 'E'; result.TYPE = 'E';
@ -365,3 +370,4 @@ public class PartService : ApplicationService, IPartService
} }
} }
} }
}

3
src/WmsWebApi.Application/ZlldcjLogs/ZlldcjLogAppService.cs

@ -18,7 +18,7 @@ using WmsWebApi.Enums;
using WmsWebApi.Jsons; using WmsWebApi.Jsons;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs {
/// <summary> /// <summary>
/// 领物料 /// 领物料
@ -447,3 +447,4 @@ public class ZlldcjLogAppService : ApplicationService, IZlldcjLogAppService
return result; return result;
} }
} }
}

70
src/WmsWebApi.Domain/Boms/BomManager.cs

@ -9,42 +9,44 @@ using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Boms; namespace WmsWebApi.Boms
public class BomManager : DomainService, IBomManager
{ {
private readonly IRepository<WmsWebApiBOMDTO, Guid> _bomDtoRepository;
private readonly IRepository<WmsWebApiBom, Guid> _bomRepository;
private readonly IRepository<WmsWebApiBomDetail, Guid> _bomDetailRepository;
public BomManager(
IRepository<WmsWebApiBOMDTO, Guid> bomDtoRepository,
IRepository<WmsWebApiBom, Guid> bomRepository,
IRepository<WmsWebApiBomDetail, Guid> bomDetailRepository
)
{
_bomDtoRepository = bomDtoRepository;
_bomRepository = bomRepository;
_bomDetailRepository = bomDetailRepository;
}
public async Task<WmsWebApiBOMDTO> AddAsync(WmsWebApiBOMDTO part)
{
await _bomDtoRepository.InsertAsync(part);
return part;
}
public async Task<WmsWebApiBom> AddBomAsync(WmsWebApiBom bom)
{
await _bomRepository.InsertAsync(bom);
return bom;
}
public async Task<WmsWebApiBomDetail> AddBomDetailAsync(List<WmsWebApiBomDetail> bomDetails) public class BomManager : DomainService, IBomManager
{ {
await _bomDetailRepository.InsertManyAsync(bomDetails); private readonly IRepository<WmsWebApiBOMDTO, Guid> _bomDtoRepository;
return bomDetails[0]; private readonly IRepository<WmsWebApiBom, Guid> _bomRepository;
private readonly IRepository<WmsWebApiBomDetail, Guid> _bomDetailRepository;
public BomManager(
IRepository<WmsWebApiBOMDTO, Guid> bomDtoRepository,
IRepository<WmsWebApiBom, Guid> bomRepository,
IRepository<WmsWebApiBomDetail, Guid> bomDetailRepository
)
{
_bomDtoRepository = bomDtoRepository;
_bomRepository = bomRepository;
_bomDetailRepository = bomDetailRepository;
}
public async Task<WmsWebApiBOMDTO> AddAsync(WmsWebApiBOMDTO part)
{
await _bomDtoRepository.InsertAsync(part);
return part;
}
public async Task<WmsWebApiBom> AddBomAsync(WmsWebApiBom bom)
{
await _bomRepository.InsertAsync(bom);
return bom;
}
public async Task<WmsWebApiBomDetail> AddBomDetailAsync(List<WmsWebApiBomDetail> bomDetails)
{
await _bomDetailRepository.InsertManyAsync(bomDetails);
return bomDetails[0];
}
} }
} }

14
src/WmsWebApi.Domain/Boms/IBomManager.cs

@ -1,12 +1,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.Boms; namespace WmsWebApi.Boms
public interface IBomManager
{ {
Task<WmsWebApiBOMDTO> AddAsync(WmsWebApiBOMDTO part);
Task<WmsWebApiBom> AddBomAsync(WmsWebApiBom bom); public interface IBomManager
Task<WmsWebApiBomDetail> AddBomDetailAsync(List<WmsWebApiBomDetail> bomDetails); {
Task<WmsWebApiBOMDTO> AddAsync(WmsWebApiBOMDTO part);
Task<WmsWebApiBom> AddBomAsync(WmsWebApiBom bom);
Task<WmsWebApiBomDetail> AddBomDetailAsync(List<WmsWebApiBomDetail> bomDetails);
}
} }

10
src/WmsWebApi.Domain/OtherZll/IOtherZllManager.cs

@ -1,9 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.OtherZll; namespace WmsWebApi.OtherZll
public interface IOtherZllManager
{ {
Task<WmsWebApiOtherZLLDTO> AddAsync(WmsWebApiOtherZLLDTO dto);
public interface IOtherZllManager
{
Task<WmsWebApiOtherZLLDTO> AddAsync(WmsWebApiOtherZLLDTO dto);
}
} }

30
src/WmsWebApi.Domain/OtherZll/OtherZllManager.cs

@ -9,25 +9,27 @@ using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.OtherZll; namespace WmsWebApi.OtherZll
public class OtherZllManager : DomainService, IOtherZllManager
{ {
private readonly IRepository<WmsWebApiOtherZLLDTO, Guid> _otherZLLDTORepository;
public OtherZllManager( public class OtherZllManager : DomainService, IOtherZllManager
IRepository<WmsWebApiOtherZLLDTO, Guid> otherZLLDTORepository
)
{ {
_otherZLLDTORepository = otherZLLDTORepository; private readonly IRepository<WmsWebApiOtherZLLDTO, Guid> _otherZLLDTORepository;
}
public OtherZllManager(
IRepository<WmsWebApiOtherZLLDTO, Guid> otherZLLDTORepository
)
{
_otherZLLDTORepository = otherZLLDTORepository;
}
public async Task<WmsWebApiOtherZLLDTO> AddAsync(WmsWebApiOtherZLLDTO dto)
{
await _otherZLLDTORepository.InsertAsync(dto); public async Task<WmsWebApiOtherZLLDTO> AddAsync(WmsWebApiOtherZLLDTO dto)
return dto; {
}
await _otherZLLDTORepository.InsertAsync(dto);
return dto;
}
}
} }

10
src/WmsWebApi.Domain/PPlan/IPPlanManager.cs

@ -1,9 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.PPlan; namespace WmsWebApi.PPlan
public interface IPPlanManager
{ {
Task<WmsWebApiPPLANDTO> AddAsync(WmsWebApiPPLANDTO pplan);
public interface IPPlanManager
{
Task<WmsWebApiPPLANDTO> AddAsync(WmsWebApiPPLANDTO pplan);
}
} }

30
src/WmsWebApi.Domain/PPlan/PPlanManager.cs

@ -9,25 +9,27 @@ using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.PPlan; namespace WmsWebApi.PPlan
public class PPlanManager : DomainService, IPPlanManager
{ {
private readonly IRepository<WmsWebApiPPLANDTO, Guid> _bomDtoRepository;
public PPlanManager( public class PPlanManager : DomainService, IPPlanManager
IRepository<WmsWebApiPPLANDTO, Guid> bomDtoRepository
)
{ {
_bomDtoRepository = bomDtoRepository; private readonly IRepository<WmsWebApiPPLANDTO, Guid> _bomDtoRepository;
}
public PPlanManager(
IRepository<WmsWebApiPPLANDTO, Guid> bomDtoRepository
)
{
_bomDtoRepository = bomDtoRepository;
}
public async Task<WmsWebApiPPLANDTO> AddAsync(WmsWebApiPPLANDTO pplan)
{
await _bomDtoRepository.InsertAsync(pplan); public async Task<WmsWebApiPPLANDTO> AddAsync(WmsWebApiPPLANDTO pplan)
return pplan; {
}
await _bomDtoRepository.InsertAsync(pplan);
return pplan;
}
}
} }

10
src/WmsWebApi.Domain/Parts/IPartManager.cs

@ -1,9 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.Parts; namespace WmsWebApi.Parts
public interface IPartManager
{ {
Task<WmsWebApiPARTDTO> AddAsync(WmsWebApiPARTDTO part);
public interface IPartManager
{
Task<WmsWebApiPARTDTO> AddAsync(WmsWebApiPARTDTO part);
}
} }

30
src/WmsWebApi.Domain/Parts/PartManager.cs

@ -9,25 +9,27 @@ using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Parts; namespace WmsWebApi.Parts
public class PartManager : DomainService, IPartManager
{ {
private readonly IRepository<WmsWebApiPARTDTO, Guid> _partDtoRepository;
public PartManager( public class PartManager : DomainService, IPartManager
IRepository<WmsWebApiPARTDTO, Guid> partDtoRepository
)
{ {
_partDtoRepository = partDtoRepository; private readonly IRepository<WmsWebApiPARTDTO, Guid> _partDtoRepository;
}
public PartManager(
IRepository<WmsWebApiPARTDTO, Guid> partDtoRepository
)
{
_partDtoRepository = partDtoRepository;
}
public async Task<WmsWebApiPARTDTO> AddAsync(WmsWebApiPARTDTO part)
{
await _partDtoRepository.InsertAsync(part); public async Task<WmsWebApiPARTDTO> AddAsync(WmsWebApiPARTDTO part)
return part; {
}
await _partDtoRepository.InsertAsync(part);
return part;
}
}
} }

10
src/WmsWebApi.Domain/ProductRecieve/IProductRecieveManager.cs

@ -1,9 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.Domain; namespace WmsWebApi.Domain
public interface IProductRecieveManager
{ {
Task<WmsWebApiProductRecieveDTO> AddAsync(WmsWebApiProductRecieveDTO part);
public interface IProductRecieveManager
{
Task<WmsWebApiProductRecieveDTO> AddAsync(WmsWebApiProductRecieveDTO part);
}
} }

30
src/WmsWebApi.Domain/ProductRecieve/ProductRecieveManager.cs

@ -9,25 +9,27 @@ using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Domain; namespace WmsWebApi.Domain
public class ProductRecieveManager : DomainService, IProductRecieveManager
{ {
private readonly IRepository<WmsWebApiProductRecieveDTO, Guid> _partDtoRepository;
public ProductRecieveManager( public class ProductRecieveManager : DomainService, IProductRecieveManager
IRepository<WmsWebApiProductRecieveDTO, Guid> partDtoRepository
)
{ {
_partDtoRepository = partDtoRepository; private readonly IRepository<WmsWebApiProductRecieveDTO, Guid> _partDtoRepository;
}
public ProductRecieveManager(
IRepository<WmsWebApiProductRecieveDTO, Guid> partDtoRepository
)
{
_partDtoRepository = partDtoRepository;
}
public async Task<WmsWebApiProductRecieveDTO> AddAsync(WmsWebApiProductRecieveDTO part)
{
await _partDtoRepository.InsertAsync(part); public async Task<WmsWebApiProductRecieveDTO> AddAsync(WmsWebApiProductRecieveDTO part)
return part; {
}
await _partDtoRepository.InsertAsync(part);
return part;
}
}
} }

10
src/WmsWebApi.Domain/Purchase/IPurchaseManager.cs

@ -1,9 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.Purchase; namespace WmsWebApi.Purchase
public interface IPurchaseManager
{ {
Task<WmsWebApiPURCHASEDTO> AddAsync(WmsWebApiPURCHASEDTO dto);
public interface IPurchaseManager
{
Task<WmsWebApiPURCHASEDTO> AddAsync(WmsWebApiPURCHASEDTO dto);
}
} }

3
src/WmsWebApi.Domain/Purchase/PurchaseManager.cs

@ -9,7 +9,7 @@ using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Purchase; namespace WmsWebApi.Purchase {
public class PurchaseManager : DomainService, IPurchaseManager public class PurchaseManager : DomainService, IPurchaseManager
{ {
@ -31,3 +31,4 @@ public class PurchaseManager : DomainService, IPurchaseManager
} }
} }
}

3
src/WmsWebApi.Domain/StockMove/IStockMoveManager.cs

@ -1,9 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.Domain; namespace WmsWebApi.Domain {
public interface IStockMoveManager public interface IStockMoveManager
{ {
Task<WmsWebApiStockMoveDTO> AddAsync(WmsWebApiStockMoveDTO part); Task<WmsWebApiStockMoveDTO> AddAsync(WmsWebApiStockMoveDTO part);
} }
}

3
src/WmsWebApi.Domain/StockMove/StockMoveManager.cs

@ -9,7 +9,7 @@ using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Domain; namespace WmsWebApi.Domain {
public class StockMoveManager : DomainService, IStockMoveManager public class StockMoveManager : DomainService, IStockMoveManager
{ {
@ -31,3 +31,4 @@ public class StockMoveManager : DomainService, IStockMoveManager
} }
} }
}

5
src/WmsWebApi.Domain/TbOrfers/TbOrder.cs

@ -1,11 +1,12 @@
using System; using System;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
namespace WmsWebApi.TbOrfers; namespace WmsWebApi.TbOrfers {
public class TbOrder:BasicAggregateRoot<Guid> public class TbOrder : BasicAggregateRoot<Guid>
{ {
public string OrderNumber { get; set; } public string OrderNumber { get; set; }
public int Status { get; set; } public int Status { get; set; }
} }
}

62
src/WmsWebApi.Domain/WMS/TbBillExtensions.cs

@ -1,48 +1,50 @@
using Volo.Abp; using Volo.Abp;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.Wms; namespace WmsWebApi.Wms
public static class TbBillExtensions
{ {
public static void CheckStatusIsOpen(this TB_BILL exist)
public static class TbBillExtensions
{ {
if (exist.State == 9) public static void CheckStatusIsOpen(this TB_BILL exist)
{
throw new UserFriendlyException($"{exist.BillNum} 单据已关闭");
}
else if (exist.State == -1)
{ {
throw new UserFriendlyException($"{exist.BillNum} 单据已作废"); if (exist.State == 9)
{
throw new UserFriendlyException($"{exist.BillNum} 单据已关闭");
}
else if (exist.State == -1)
{
throw new UserFriendlyException($"{exist.BillNum} 单据已作废");
}
else if (exist.State == 2)
{
throw new UserFriendlyException($"{exist.BillNum} 单据已完成");
}
} }
else if (exist.State == 2)
{
throw new UserFriendlyException($"{exist.BillNum} 单据已完成");
}
}
public static void CheckIsExist(this TB_BILL exist,string orderNumber) public static void CheckIsExist(this TB_BILL exist, string orderNumber)
{
if (exist == null)
{ {
throw new UserFriendlyException($"{orderNumber} 单据不存在"); if (exist == null)
{
throw new UserFriendlyException($"{orderNumber} 单据不存在");
}
} }
}
public static void CheckIsNotExist(this TB_BILL exist) public static void CheckIsNotExist(this TB_BILL exist)
{
if (exist != null)
{ {
throw new UserFriendlyException($"{exist.BillNum} 单据已存在"); if (exist != null)
{
throw new UserFriendlyException($"{exist.BillNum} 单据已存在");
}
} }
}
public static void CheckDetailIsExist(this TM_PG_OTHER_INOUT_ASK exist) public static void CheckDetailIsExist(this TM_PG_OTHER_INOUT_ASK exist)
{
if (exist != null)
{ {
throw new UserFriendlyException($"{exist.BillNum}单据, {exist.BillLineID}行项不存在"); if (exist != null)
{
throw new UserFriendlyException($"{exist.BillNum}单据, {exist.BillLineID}行项不存在");
}
} }
}
}
} }

3
src/WmsWebApi.Domain/ZlldcjLogs/IZlldcjLogManager.cs

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs {
public interface IZlldcjLogManager public interface IZlldcjLogManager
{ {
@ -9,3 +9,4 @@ public interface IZlldcjLogManager
Task<ZlldcjLog> CloseAsync(List<ZlldcjLog> zlldcjLogs); Task<ZlldcjLog> CloseAsync(List<ZlldcjLog> zlldcjLogs);
Task<WmsWebApiZLLDCJDTO> AddDtoAsync(WmsWebApiZLLDCJDTO dto); Task<WmsWebApiZLLDCJDTO> AddDtoAsync(WmsWebApiZLLDCJDTO dto);
} }
}

3
src/WmsWebApi.Domain/ZlldcjLogs/WmsWebApiZLLDCJDTO.cs

@ -6,7 +6,7 @@ using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Guids; using Volo.Abp.Guids;
using WmsWebApi.Enums; using WmsWebApi.Enums;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs {
public class WmsWebApiZLLDCJDTO : BasicAggregateRoot<Guid> public class WmsWebApiZLLDCJDTO : BasicAggregateRoot<Guid>
{ {
@ -43,3 +43,4 @@ public class WmsWebApiZLLDCJDTO : BasicAggregateRoot<Guid>
this.Id = guidGenerator.Create(); this.Id = guidGenerator.Create();
} }
} }
}

5
src/WmsWebApi.Domain/ZlldcjLogs/ZlldcjLog.cs

@ -3,9 +3,9 @@ using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Guids; using Volo.Abp.Guids;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs {
public class ZlldcjLog:CreationAuditedAggregateRoot<Guid> public class ZlldcjLog : CreationAuditedAggregateRoot<Guid>
{ {
/// <summary> /// <summary>
/// 单据号 /// 单据号
@ -174,3 +174,4 @@ public class ZlldcjLog:CreationAuditedAggregateRoot<Guid>
[Display(Name = "接口类型")] [Display(Name = "接口类型")]
public string IType { get; set; } public string IType { get; set; }
} }
}

5
src/WmsWebApi.Domain/ZlldcjLogs/ZlldcjLogExtensions.cs

@ -1,7 +1,7 @@
using Volo.Abp; using Volo.Abp;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs {
public static class ZlldcjLogExtensions public static class ZlldcjLogExtensions
{ {
@ -13,7 +13,7 @@ public static class ZlldcjLogExtensions
} }
} }
public static void CheckIsExist(this TbOrder exist,string orderNumber) public static void CheckIsExist(this TbOrder exist, string orderNumber)
{ {
if (exist == null) if (exist == null)
{ {
@ -30,3 +30,4 @@ public static class ZlldcjLogExtensions
} }
} }
}

270
src/WmsWebApi.Domain/ZlldcjLogs/ZlldcjLogManager.cs

@ -9,165 +9,167 @@ using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
using WmsWebApi.Wms; using WmsWebApi.Wms;
namespace WmsWebApi.ZlldcjLogs; namespace WmsWebApi.ZlldcjLogs
public class ZlldcjLogManager:DomainService,IZlldcjLogManager
{ {
private readonly IRepository<ZlldcjLog, Guid> _zlldcjLogsRepository;
private readonly IRepository<WmsWebApiZLLDCJDTO, Guid> _zlldcjDtoRepository;
private readonly ITbBillRepository _tbBillRepository;
private readonly ITmSapMoveTypeRepository _tbSapMoveTypeRepository;
private readonly ITmOtherAskRepository _tbOtherInOutAskRepository;
//private readonly ITmOtherAskRepositoryUpdate _tmOtherAskRepositoryUpdate;
public ZlldcjLogManager(
IRepository<ZlldcjLog,Guid> zlldcjLogsRepository
, IRepository<WmsWebApiZLLDCJDTO, Guid> zlldcjDtoRepository
, ITbBillRepository tbBillRepository
, ITmSapMoveTypeRepository tbSapMoveTypeRepository
, ITmOtherAskRepository tbOtherInOutAskRepository
//, ITmOtherAskRepositoryUpdate tmOtherAskRepositoryUpdate
)
{
_zlldcjLogsRepository = zlldcjLogsRepository;
_zlldcjDtoRepository = zlldcjDtoRepository;
_tbBillRepository = tbBillRepository;
_tbSapMoveTypeRepository = tbSapMoveTypeRepository;
_tbOtherInOutAskRepository = tbOtherInOutAskRepository;
}
public class ZlldcjLogManager : DomainService, IZlldcjLogManager
public async Task<ZlldcjLog> AddAsync(List<ZlldcjLog> zlldcjLogs)
{ {
private readonly IRepository<ZlldcjLog, Guid> _zlldcjLogsRepository;
private readonly IRepository<WmsWebApiZLLDCJDTO, Guid> _zlldcjDtoRepository;
private readonly ITbBillRepository _tbBillRepository;
private readonly ITmSapMoveTypeRepository _tbSapMoveTypeRepository;
private readonly ITmOtherAskRepository _tbOtherInOutAskRepository;
//private readonly ITmOtherAskRepositoryUpdate _tmOtherAskRepositoryUpdate;
public ZlldcjLogManager(
IRepository<ZlldcjLog, Guid> zlldcjLogsRepository
, IRepository<WmsWebApiZLLDCJDTO, Guid> zlldcjDtoRepository
, ITbBillRepository tbBillRepository
, ITmSapMoveTypeRepository tbSapMoveTypeRepository
, ITmOtherAskRepository tbOtherInOutAskRepository
//, ITmOtherAskRepositoryUpdate tmOtherAskRepositoryUpdate
)
{
_zlldcjLogsRepository = zlldcjLogsRepository;
_zlldcjDtoRepository = zlldcjDtoRepository;
_tbBillRepository = tbBillRepository;
_tbSapMoveTypeRepository = tbSapMoveTypeRepository;
_tbOtherInOutAskRepository = tbOtherInOutAskRepository;
}
//检查是否为存在
var tbBill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == zlldcjLogs[0].ZLLDJ);
tbBill.CheckIsNotExist();
//TODO 创建 tbOrder public async Task<ZlldcjLog> AddAsync(List<ZlldcjLog> zlldcjLogs)
tbBill = new TB_BILL
{
BillNum = zlldcjLogs[0].ZLLDJ,
BillTime = DateTime.Now,
OperName = zlldcjLogs[0].ERNAM,
DetailQty = zlldcjLogs.Count,
BillType = 309,
State = 0
//...
};
//确定SubBillType
var sapMoveType = await _tbSapMoveTypeRepository.FirstOrDefaultAsync(p=> p.SAPBillType == zlldcjLogs[0].ZDJLX
&& p.GetOrBack == zlldcjLogs[0].ZLTLX
&& p.MoveType == zlldcjLogs[0].BWART);
var sapBillDesc = "";
if (sapMoveType != null)
{ {
tbBill.SubBillType = sapMoveType.SubBillType;
tbBill.Remark = sapMoveType.SAPBillDesc;
sapBillDesc = sapMoveType.SAPBillDesc;
List<TM_PG_OTHER_INOUT_ASK> askList = new List<TM_PG_OTHER_INOUT_ASK>(); //检查是否为存在
foreach (var item in zlldcjLogs) var tbBill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == zlldcjLogs[0].ZLLDJ);
tbBill.CheckIsNotExist();
//TODO 创建 tbOrder
tbBill = new TB_BILL
{ {
TM_PG_OTHER_INOUT_ASK ask = new TM_PG_OTHER_INOUT_ASK BillNum = zlldcjLogs[0].ZLLDJ,
BillTime = DateTime.Now,
OperName = zlldcjLogs[0].ERNAM,
DetailQty = zlldcjLogs.Count,
BillType = 309,
State = 0
//...
};
//确定SubBillType
var sapMoveType = await _tbSapMoveTypeRepository.FirstOrDefaultAsync(p => p.SAPBillType == zlldcjLogs[0].ZDJLX
&& p.GetOrBack == zlldcjLogs[0].ZLTLX
&& p.MoveType == zlldcjLogs[0].BWART);
var sapBillDesc = "";
if (sapMoveType != null)
{
tbBill.SubBillType = sapMoveType.SubBillType;
tbBill.Remark = sapMoveType.SAPBillDesc;
sapBillDesc = sapMoveType.SAPBillDesc;
List<TM_PG_OTHER_INOUT_ASK> askList = new List<TM_PG_OTHER_INOUT_ASK>();
foreach (var item in zlldcjLogs)
{ {
BillNum = item.ZLLDJ, TM_PG_OTHER_INOUT_ASK ask = new TM_PG_OTHER_INOUT_ASK
BillLineID = item.ZLLITEM.ToString(), {
BillType = item.ZDJLX, BillNum = item.ZLLDJ,
BillTypeDesc = sapBillDesc, BillLineID = item.ZLLITEM.ToString(),
GetOrBack = item.ZLTLX, BillType = item.ZDJLX,
PartCode = item.MATNR, BillTypeDesc = sapBillDesc,
Qty = item.BDMNG, GetOrBack = item.ZLTLX,
BUn = item.MEINS, PartCode = item.MATNR,
CostCenter = item.KOSTL, Qty = item.BDMNG,
BaseOrder = item.AUFNR, BUn = item.MEINS,
MoveType = item.BWART, CostCenter = item.KOSTL,
OrderReason = item.GRUND.ToString(), BaseOrder = item.AUFNR,
MoveReason = sapBillDesc, MoveType = item.BWART,
Creator = item.ERNAM, OrderReason = item.GRUND.ToString(),
CreatDate = item.ERDAT + " " + item.ERZET, MoveReason = sapBillDesc,
Remark = item.ZBZSM, Creator = item.ERNAM,
RejecteQty = item.BKNUM, CreatDate = item.ERDAT + " " + item.ERZET,
Remark = item.ZBZSM,
PickLocation = item.LGORT1, RejecteQty = item.BKNUM,
RejecteLocation = item.LGORT2,
ClaimLocation = item.LGORT3, PickLocation = item.LGORT1,
PickPerson = item.ZLLR RejecteLocation = item.LGORT2,
}; ClaimLocation = item.LGORT3,
askList.Add(ask); PickPerson = item.ZLLR
item.IType = "新增"; };
askList.Add(ask);
item.IType = "新增";
}
//新增本地单据
await _tbBillRepository.InsertAsync(tbBill);
await _tbOtherInOutAskRepository.InsertManyAsync(askList);
} }
//新增本地单据 else
await _tbBillRepository.InsertAsync(tbBill);
await _tbOtherInOutAskRepository.InsertManyAsync(askList);
}
else
{
foreach (var item in zlldcjLogs)
{ {
item.IType = "WMS 不需要的接口"; foreach (var item in zlldcjLogs)
{
item.IType = "WMS 不需要的接口";
}
} }
//新增日志记录
await _zlldcjLogsRepository.InsertManyAsync(zlldcjLogs);
return zlldcjLogs[0];
} }
//新增日志记录
await _zlldcjLogsRepository.InsertManyAsync(zlldcjLogs);
return zlldcjLogs[0];
}
public async Task<ZlldcjLog> CloseAsync(List<ZlldcjLog> zlldcjLogs) public async Task<ZlldcjLog> CloseAsync(List<ZlldcjLog> zlldcjLogs)
{ {
/*var tbBill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == zlldcjLog.ZLLDJ); /*var tbBill = await _tbBillRepository.FirstOrDefaultAsync(p => p.BillNum == zlldcjLog.ZLLDJ);
var tbOtherAskList = _tbOtherInOutAskRepository.Where(p => p.BillNum == zlldcjLog.ZLLDJ); var tbOtherAskList = _tbOtherInOutAskRepository.Where(p => p.BillNum == zlldcjLog.ZLLDJ);
//检查tbOrder是否存在 //检查tbOrder是否存在
tbBill.CheckIsExist(zlldcjLog.ZLLDJ); tbBill.CheckIsExist(zlldcjLog.ZLLDJ);
//检查tbOrder状态是否为开启 //检查tbOrder状态是否为开启
tbBill.CheckStatusIsOpen(); tbBill.CheckStatusIsOpen();
bool bClose = true,bFind = false; bool bClose = true,bFind = false;
foreach (var item in tbOtherAskList) foreach (var item in tbOtherAskList)
{
if (item.BillLineID.Trim() == zlldcjLog.ZLLITEM.ToString().Trim())
{ {
bFind = true; if (item.BillLineID.Trim() == zlldcjLog.ZLLITEM.ToString().Trim())
item.IsClosed = true; {
await _tmOtherAskRepositoryUpdate.UpdateCustPart(item); bFind = true;
item.IsClosed = true;
await _tmOtherAskRepositoryUpdate.UpdateCustPart(item);
}
else
{
if (item.IsClosed == false)
bClose = false;
}
} }
else if (!bFind)
{ {
if (item.IsClosed == false) throw new UserFriendlyException($"{zlldcjLog.ZLLDJ}单据, {zlldcjLog.ZLLITEM}行项不存在");
bClose = false;
} }
if (bClose)
{
tbBill.State = 9;
await _tmOtherAskRepositoryUpdate.UpdateBillState(tbBill);
}*/
//新增日志记录
foreach (var zlldcjLog in zlldcjLogs)
{
zlldcjLog.IType = "关闭";
}
await _zlldcjLogsRepository.InsertManyAsync(zlldcjLogs);
return zlldcjLogs[0];
} }
if (!bFind)
public async Task<WmsWebApiZLLDCJDTO> AddDtoAsync(WmsWebApiZLLDCJDTO dto)
{ {
throw new UserFriendlyException($"{zlldcjLog.ZLLDJ}单据, {zlldcjLog.ZLLITEM}行项不存在");
await _zlldcjDtoRepository.InsertAsync(dto);
return dto;
} }
if (bClose)
{
tbBill.State = 9;
await _tmOtherAskRepositoryUpdate.UpdateBillState(tbBill);
}*/
//新增日志记录 public async Task<int> AddZlldcjAsync(List<ZlldcjLog> dtos)
foreach (var zlldcjLog in zlldcjLogs)
{ {
zlldcjLog.IType = "关闭"; await _zlldcjLogsRepository.InsertManyAsync(dtos);
return dtos.Count;
} }
await _zlldcjLogsRepository.InsertManyAsync(zlldcjLogs);
return zlldcjLogs[0];
}
public async Task<WmsWebApiZLLDCJDTO> AddDtoAsync(WmsWebApiZLLDCJDTO dto)
{
await _zlldcjDtoRepository.InsertAsync(dto);
return dto;
}
public async Task<int> AddZlldcjAsync(List<ZlldcjLog> dtos)
{
await _zlldcjLogsRepository.InsertManyAsync(dtos);
return dtos.Count;
} }
} }

12
src/WmsWebApi.Domain/ZlldgbLogs/IZlldgbLogManager.cs

@ -1,9 +1,11 @@
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WmsWebApi.ZlldgbLogs; namespace WmsWebApi.ZlldgbLogs
public interface IZlldgbLogManager
{ {
Task<ZlldgbLog> AddAsync(ZlldgbLog zlldcjLog);
Task<ZlldgbLog> CloseAsync(ZlldgbLog zlldcjLog); public interface IZlldgbLogManager
{
Task<ZlldgbLog> AddAsync(ZlldgbLog zlldcjLog);
Task<ZlldgbLog> CloseAsync(ZlldgbLog zlldcjLog);
}
} }

5
src/WmsWebApi.Domain/ZlldgbLogs/ZlldgbLog.cs

@ -3,9 +3,9 @@ using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Guids; using Volo.Abp.Guids;
namespace WmsWebApi.ZlldgbLogs; namespace WmsWebApi.ZlldgbLogs {
public class ZlldgbLog:CreationAuditedAggregateRoot<Guid> public class ZlldgbLog : CreationAuditedAggregateRoot<Guid>
{ {
/// <summary> /// <summary>
/// 单据号 /// 单据号
@ -168,3 +168,4 @@ public class ZlldgbLog:CreationAuditedAggregateRoot<Guid>
this.Id = guidGenerator.Create(); this.Id = guidGenerator.Create();
} }
} }
}

5
src/WmsWebApi.Domain/ZlldgbLogs/ZlldgbLogExtensions.cs

@ -1,7 +1,7 @@
using Volo.Abp; using Volo.Abp;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
namespace WmsWebApi.ZlldgbLogs; namespace WmsWebApi.ZlldgbLogs {
public static class ZlldgbLogExtensions public static class ZlldgbLogExtensions
{ {
@ -13,7 +13,7 @@ public static class ZlldgbLogExtensions
} }
} }
public static void CheckIsExist(this TbOrder exist,string orderNumber) public static void CheckIsExist(this TbOrder exist, string orderNumber)
{ {
if (exist == null) if (exist == null)
{ {
@ -30,3 +30,4 @@ public static class ZlldgbLogExtensions
} }
} }
}

9
src/WmsWebApi.Domain/ZlldgbLogs/ZlldgbLogManager.cs

@ -6,16 +6,16 @@ using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services; using Volo.Abp.Domain.Services;
using WmsWebApi.TbOrfers; using WmsWebApi.TbOrfers;
namespace WmsWebApi.ZlldgbLogs; namespace WmsWebApi.ZlldgbLogs {
public class ZlldgbLogManager:DomainService,IZlldgbLogManager public class ZlldgbLogManager : DomainService, IZlldgbLogManager
{ {
private readonly IRepository<ZlldgbLog, Guid> _zlldcjLogsRepository; private readonly IRepository<ZlldgbLog, Guid> _zlldcjLogsRepository;
private readonly IRepository<TbOrder, Guid> _tbOrderRepository; private readonly IRepository<TbOrder, Guid> _tbOrderRepository;
public ZlldgbLogManager( public ZlldgbLogManager(
IRepository<ZlldgbLog,Guid> zlldcjLogsRepository IRepository<ZlldgbLog, Guid> zlldcjLogsRepository
,IRepository<TbOrder,Guid> tbOrderRepository) , IRepository<TbOrder, Guid> tbOrderRepository)
{ {
_zlldcjLogsRepository = zlldcjLogsRepository; _zlldcjLogsRepository = zlldcjLogsRepository;
_tbOrderRepository = tbOrderRepository; _tbOrderRepository = tbOrderRepository;
@ -63,3 +63,4 @@ public class ZlldgbLogManager:DomainService,IZlldgbLogManager
} }
}
Loading…
Cancel
Save