添加项目文件。
This commit is contained in:
28
src/BarCode.Web.Domain/BarCode.Web.Domain.csproj
Normal file
28
src/BarCode.Web.Domain/BarCode.Web.Domain.csproj
Normal file
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<DocumentationFile>../BarCode.Web.Api/wwwroot/BarCode.Web.Domain.xml</DocumentationFile>
|
||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCoreRateLimit.Redis" Version="2.0.0" />
|
||||
<PackageReference Include="AutoMapper" Version="12.0.0" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
|
||||
<PackageReference Include="Pomelo.AspNetCore.TimedJob" Version="2.0.0-rtm-10046" />
|
||||
<PackageReference Include="Qiniu" Version="8.5.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BarCode.Web.Core\BarCode.Web.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
195
src/BarCode.Web.Domain/Entitys/Box.cs
Normal file
195
src/BarCode.Web.Domain/Entitys/Box.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
using BarCode.Web.Core.Help;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.Values;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱信息头
|
||||
/// alter table t_barcode_box_details AUTO_INCREMENT=50000;
|
||||
/// </summary>
|
||||
|
||||
[Serializable]
|
||||
[Table("t_barcode_box")]
|
||||
public class Box : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 箱编号
|
||||
/// </summary>
|
||||
[Column("BoxBillNo")]
|
||||
public string BoxBillNo { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 供应商Code
|
||||
/// </summary>
|
||||
[Column("SupplierCode")]
|
||||
public string SupplierCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 组织Code
|
||||
/// </summary>
|
||||
[Column("OrgCode")]
|
||||
public string OrgCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 公司Id
|
||||
/// </summary>
|
||||
[Column("CompanyId")]
|
||||
public int CompanyId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 箱状态
|
||||
/// </summary>
|
||||
[Column("Status")]
|
||||
public BoxStatus Status { get; set; } = BoxStatus.NoUse;
|
||||
/// <summary>
|
||||
/// 装箱开始时间
|
||||
/// </summary>
|
||||
[Column("CartonBeginTime")]
|
||||
public DateTime? CartonBeginTime { get; set; }
|
||||
/// <summary>
|
||||
/// 装箱结束时间(完成装箱时间)
|
||||
/// </summary>
|
||||
[Column("CartonEndTime")]
|
||||
public DateTime? CartonEndTime { get; set; }
|
||||
/// <summary>
|
||||
/// 装箱用户
|
||||
/// </summary>
|
||||
[Column("CartonUserId")]
|
||||
public int CartonUserId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 箱子创建用户
|
||||
/// </summary>
|
||||
[Column("CreatorId")]
|
||||
public int CreatorId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[Column("CreateTime")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// 箱号打印次数
|
||||
/// </summary>
|
||||
[Column("PrintNumber")]
|
||||
public int PrintNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 最新打印时间
|
||||
/// </summary>
|
||||
[Column("PrintTime")]
|
||||
public DateTime? PrintTime { get; set; }
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
public List<BoxDetails> Details { get; set; } = new List<BoxDetails>();
|
||||
|
||||
public void GenerateNo()
|
||||
{
|
||||
//用户手动输入了 就不自动生成了
|
||||
if (!string.IsNullOrEmpty(this.BoxBillNo)) return;
|
||||
|
||||
if (this.Id.ToString().Length >= 8)
|
||||
{
|
||||
this.BoxBillNo = "CTN" + this.Id.ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
string idStr = this.Id.ToString();
|
||||
while (true)
|
||||
{
|
||||
idStr = "0" + idStr;
|
||||
if (idStr.Length >= 8) break;
|
||||
}
|
||||
this.BoxBillNo = "CTN" + idStr;
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印
|
||||
/// </summary>
|
||||
public void Print()
|
||||
{
|
||||
this.PrintNumber++;
|
||||
this.PrintTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 解绑序列号
|
||||
/// </summary>
|
||||
/// <param name="serialNumber"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
public Result UnSerialNumber(string serialNumber, string materialNumber)
|
||||
{
|
||||
var detail = this.Details.FirstOrDefault(f => f.MaterialNumber.Equals(materialNumber));
|
||||
if (detail == null)
|
||||
return Result.ReFailure(ResultCodes.BoxMaterialNoDataError);
|
||||
var serial = detail.SerialNumbers.FirstOrDefault(f => f.Equals(serialNumber));
|
||||
if (serial == null)
|
||||
return Result.ReFailure(ResultCodes.BoxSerialNumberNoDataError);
|
||||
detail.SerialNumbers.Remove(serialNumber);
|
||||
detail.Qty = detail.SerialNumbers.Count();
|
||||
//如果数量为0了就删除这条明细
|
||||
if (detail.SerialNumbers.Count() <= 0)
|
||||
this.Details.Remove(detail);
|
||||
//如果没有明细了 就把状态改成未使用
|
||||
if (this.Details.Count() <= 0)
|
||||
this.Status = BoxStatus.NoUse;
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
this.Details.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// 装箱
|
||||
/// </summary>
|
||||
public Result Carton(bool isComplete, int cartonUserId)
|
||||
{
|
||||
if (this.Status == BoxStatus.Complete)
|
||||
return Result.ReFailure(ResultCodes.CartonCompleteError);
|
||||
if (this.CartonBeginTime == null) this.CartonBeginTime = DateTime.Now;
|
||||
this.CartonUserId = cartonUserId;
|
||||
if (isComplete == true)
|
||||
{
|
||||
//完成装箱
|
||||
this.Status = BoxStatus.Complete;
|
||||
this.CartonEndTime = DateTime.Now;
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
this.Status = BoxStatus.NoComplete;
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 开始装箱
|
||||
/// </summary>
|
||||
/// <param name="cartonUserId"></param>
|
||||
/// <returns></returns>
|
||||
public Result BeginCarton(int cartonUserId)
|
||||
{
|
||||
if (this.Status == BoxStatus.Complete)
|
||||
return Result.ReFailure(ResultCodes.CartonCompleteError);
|
||||
if (this.CartonBeginTime == null)
|
||||
this.CartonBeginTime = DateTime.Now;
|
||||
if (this.CartonUserId == 0)
|
||||
this.CartonUserId = cartonUserId;
|
||||
this.Status = BoxStatus.NoComplete;
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 重置
|
||||
/// </summary>
|
||||
public void Restart()
|
||||
{
|
||||
this.Status = BoxStatus.NoComplete;
|
||||
this.CartonEndTime = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
src/BarCode.Web.Domain/Entitys/BoxDetails.cs
Normal file
45
src/BarCode.Web.Domain/Entitys/BoxDetails.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 老ops箱信息明细
|
||||
/// alter table t_barcode_box_details AUTO_INCREMENT=50000;
|
||||
/// </summary>
|
||||
|
||||
[Serializable]
|
||||
[Table("t_barcode_box_details")]
|
||||
public class BoxDetails : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 单据头ID
|
||||
/// </summary>
|
||||
[Column("Fid")]
|
||||
public int Fid { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[Column("MaterialNumber")]
|
||||
public string MaterialNumber { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 数量(装箱数量)
|
||||
/// </summary>
|
||||
[Column("Qty")]
|
||||
public decimal Qty { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 序列号
|
||||
/// </summary>
|
||||
[Column("SerialNumbers")]
|
||||
public List<string> SerialNumbers { get; set; } = new List<string>();
|
||||
|
||||
}
|
||||
}
|
||||
192
src/BarCode.Web.Domain/Entitys/BoxMark.cs
Normal file
192
src/BarCode.Web.Domain/Entitys/BoxMark.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛表
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_barcode_box_mark")]
|
||||
public class BoxMark : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 供应商Code
|
||||
/// </summary>
|
||||
[Column("SupplierCode")]
|
||||
public string SupplierCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 组织Code
|
||||
/// </summary>
|
||||
[Column("OrgCode")]
|
||||
public string OrgCode { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 订单编号
|
||||
/// </summary>
|
||||
public string OrderBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string MaterialNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品数量
|
||||
/// </summary>
|
||||
public decimal ProductQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 装箱数量
|
||||
/// </summary>
|
||||
public decimal CratingQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 装箱净重
|
||||
/// </summary>
|
||||
public decimal CratingNetWeightQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 装箱毛重
|
||||
/// </summary>
|
||||
public decimal CratingGrossWeightQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尾箱数量
|
||||
/// </summary>
|
||||
public decimal TailboxQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尾箱净重
|
||||
/// </summary>
|
||||
public decimal TailboxNetWeightQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 尾箱毛重
|
||||
/// </summary>
|
||||
public decimal TailboxGrossWeightQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public int CreatorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间(生成时间)
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 流水号(开始)
|
||||
/// </summary>
|
||||
public Int64? BeginNumber { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 流水号(结束)
|
||||
/// </summary>
|
||||
public Int64? EndNumber { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// 编号集合
|
||||
/// </summary>
|
||||
public List<BoxMarkBillNo> BillNos { get; set; } = new List<BoxMarkBillNo>();
|
||||
|
||||
/// <summary>
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <param name="creatorId"></param>
|
||||
public void Create(int creatorId)
|
||||
{
|
||||
this.CreatorId = creatorId;
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成编号
|
||||
/// </summary>
|
||||
/// <param name="firstBillNo"></param>
|
||||
/// <param name="lastBillNo"></param>
|
||||
public void GenerateBillNo(int firstBillNo, int lastBillNo)
|
||||
{
|
||||
if (this.BillNos == null)
|
||||
this.BillNos = new List<BoxMarkBillNo>();
|
||||
|
||||
//计算要装的箱数量
|
||||
var boxCount_tag = this.ProductQty / this.CratingQty;
|
||||
var boxCount = Convert.ToInt32(boxCount_tag);
|
||||
|
||||
//判断是否存在小数点;true表明有尾箱数,false没有尾箱数
|
||||
var hasPart = Math.Floor(boxCount_tag) != boxCount_tag;
|
||||
|
||||
//有小数点向上取整
|
||||
if (hasPart)
|
||||
boxCount = Convert.ToInt32(Math.Ceiling(boxCount_tag));
|
||||
|
||||
for (int i = 1; i <= boxCount; i++)
|
||||
{
|
||||
//添加编号生成
|
||||
var bill = new BoxMarkBillNo();
|
||||
bill.Sort = i;
|
||||
if (hasPart && i == boxCount && boxCount > 1)
|
||||
bill.IsTail = true;
|
||||
bill.GenerateBillNo(firstBillNo, lastBillNo);
|
||||
|
||||
//用户设置了序列号才计算
|
||||
if (this.BeginNumber != null && this.EndNumber != null)
|
||||
{
|
||||
//只有一个箱子 就用产品数量
|
||||
if (boxCount == 1)
|
||||
{
|
||||
//如果是尾箱
|
||||
if (bill.IsTail)
|
||||
{
|
||||
bill.BeginNumber = this.BeginNumber + Convert.ToInt64((i - 1) * ProductQty);
|
||||
bill.EndNumber = this.EndNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
//不是尾箱
|
||||
bill.BeginNumber = this.BeginNumber + Convert.ToInt64((i - 1) * ProductQty);
|
||||
bill.EndNumber = Convert.ToInt64(bill.BeginNumber + ProductQty) - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果是尾箱
|
||||
if (bill.IsTail)
|
||||
{
|
||||
bill.BeginNumber = this.BeginNumber + Convert.ToInt64((i - 1) * CratingQty);
|
||||
bill.EndNumber = this.EndNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
//不是尾箱
|
||||
bill.BeginNumber = this.BeginNumber + Convert.ToInt64((i - 1) * CratingQty);
|
||||
bill.EndNumber = Convert.ToInt64(bill.BeginNumber + CratingQty) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.BillNos.Add(bill);
|
||||
|
||||
//改变前后的billNo值,新的值再一次被使用
|
||||
firstBillNo = bill.FirstBillNo;
|
||||
lastBillNo = bill.LastBillNo;
|
||||
}
|
||||
//判断有小数点,那么它就有尾箱,把当前第一条的编号是否是尾箱字段改为true
|
||||
//if (this.BillNos.Count != 0 && hasPart)
|
||||
// this.BillNos[0].IsTail = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
87
src/BarCode.Web.Domain/Entitys/BoxMarkBillNo.cs
Normal file
87
src/BarCode.Web.Domain/Entitys/BoxMarkBillNo.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛表-编号表
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_barcode_box_mark_billno")]
|
||||
public class BoxMarkBillNo : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public override int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上级ID
|
||||
/// </summary>
|
||||
public int Fid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱唛编号
|
||||
/// </summary>
|
||||
public string BillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱唛编号-首位
|
||||
/// </summary>
|
||||
public int FirstBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱唛编号-末尾序号
|
||||
/// </summary>
|
||||
public int LastBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是尾箱
|
||||
/// </summary>
|
||||
public bool IsTail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
/// <summary>
|
||||
/// 流水号(开始)
|
||||
/// </summary>
|
||||
public Int64? BeginNumber { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 流水号(结束)
|
||||
/// </summary>
|
||||
public Int64? EndNumber { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// 生成编号
|
||||
/// </summary>
|
||||
/// <param name="firstBillNo"></param>
|
||||
/// <param name="lastBillNo"></param>
|
||||
public void GenerateBillNo(int firstBillNo, int lastBillNo)
|
||||
{
|
||||
this.FirstBillNo = Convert.ToInt32(DateTime.Now.ToString("yyMMdd"));
|
||||
if (this.FirstBillNo == firstBillNo)
|
||||
this.LastBillNo = lastBillNo + 1;
|
||||
else
|
||||
this.LastBillNo = 1;
|
||||
|
||||
if (this.LastBillNo.ToString().Length >= 5)
|
||||
{
|
||||
this.BillNo = "XM" + this.FirstBillNo + this.LastBillNo;
|
||||
return;
|
||||
}
|
||||
|
||||
string lastStr = this.LastBillNo.ToString();
|
||||
while (true)
|
||||
{
|
||||
lastStr = "0" + lastStr;
|
||||
if (lastStr.Length >= 5) break;
|
||||
}
|
||||
this.BillNo = "XM" + this.FirstBillNo + lastStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/BarCode.Web.Domain/Entitys/CenerateData.cs
Normal file
40
src/BarCode.Web.Domain/Entitys/CenerateData.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using BarCode.Web.Core;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成计划管理
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_wms_cenerate_date")]
|
||||
public class CenerateData : EntityBase
|
||||
{
|
||||
public CenerateData() { }
|
||||
public CenerateData(CenerateDataType type)
|
||||
{
|
||||
this.Type = type;
|
||||
}
|
||||
/// <summary>
|
||||
/// 主键 订单编号
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 同步类型
|
||||
/// </summary>
|
||||
[Column("Type")]
|
||||
public CenerateDataType Type { get; set; } = CenerateDataType.Serial;
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
[Column("Number")]
|
||||
public int Number { get; set; } = 1;
|
||||
}
|
||||
}
|
||||
90
src/BarCode.Web.Domain/Entitys/FileDownManager.cs
Normal file
90
src/BarCode.Web.Domain/Entitys/FileDownManager.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
using BarCode.Web.Domain.Values;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件下载类型
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_barcode_file_down_manager")]
|
||||
public class FileDownManager : EntityBase
|
||||
{
|
||||
public FileDownManager() { }
|
||||
public FileDownManager(int userId, int companyId, FileDownLoadOrderType type,string orgCode, string path, string supplierCode)
|
||||
{
|
||||
this.UserId = userId;
|
||||
this.CompanyId = companyId;
|
||||
this.Type = type;
|
||||
this.FilePath = path;
|
||||
this.SupplierCode = supplierCode;
|
||||
this.OrgCode = orgCode;
|
||||
}
|
||||
/// <summary>
|
||||
/// 主键 订单编号
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
[Column("Date")]
|
||||
public DateTime? Date { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// 单据类型(任务类型)
|
||||
/// </summary>
|
||||
[Column("Type")]
|
||||
public FileDownLoadOrderType Type { get; set; } = FileDownLoadOrderType.SerialNumbers;
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
[Column("Status")]
|
||||
public ExportStatus Status { get; set; } = ExportStatus.Ing;
|
||||
/// <summary>
|
||||
/// 公司Id
|
||||
/// </summary>
|
||||
[Column("CompanyId")]
|
||||
public int CompanyId { get; set; }
|
||||
/// <summary>
|
||||
/// 组织编码
|
||||
/// </summary>
|
||||
[Column("OrgCode")]
|
||||
public string OrgCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 文件地址
|
||||
/// </summary>
|
||||
[Column("FilePath")]
|
||||
public string FilePath { get; set; }
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
[Column("UserId")]
|
||||
public int UserId { get; set; }
|
||||
/// <summary>
|
||||
/// 失败原因
|
||||
/// </summary>
|
||||
[Column("Reason")]
|
||||
public string Reason { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 供应商编码
|
||||
/// </summary>
|
||||
[Column("SupplierCode")]
|
||||
public string SupplierCode { get; set; } = "";
|
||||
|
||||
public void Finish(bool IsSuccess, string reson)
|
||||
{
|
||||
if (IsSuccess)
|
||||
this.Status = ExportStatus.Success;
|
||||
else
|
||||
{
|
||||
this.Status = ExportStatus.Fail;
|
||||
this.Reason = reson;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
77
src/BarCode.Web.Domain/Entitys/Materials.cs
Normal file
77
src/BarCode.Web.Domain/Entitys/Materials.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_barcode_materials")]
|
||||
public class Materials : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public override int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组织Id
|
||||
/// </summary>
|
||||
public int OrgId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组织编码
|
||||
/// </summary>
|
||||
public string OrgCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public int MaterialId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string MaterialName { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string MaterialNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 物料规格型号
|
||||
/// </summary>
|
||||
public string Specifications { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 基本单位
|
||||
/// </summary>
|
||||
public int BaseUnitId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 基本单位名称
|
||||
/// </summary>
|
||||
public string BaseUnitName { get; set; }
|
||||
/// <summary>
|
||||
/// 基本单位编码
|
||||
/// </summary>
|
||||
public string BaseUnitNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 条码
|
||||
/// </summary>
|
||||
public string BarCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用批号管理
|
||||
/// </summary>
|
||||
public bool IsBatchManage { get; set; }
|
||||
/// <summary>
|
||||
/// 物料Id 32进制字符串
|
||||
/// </summary>
|
||||
public string IdConvertBar { get; set; }
|
||||
}
|
||||
}
|
||||
116
src/BarCode.Web.Domain/Entitys/SecurityNumberGenerateRecord.cs
Normal file
116
src/BarCode.Web.Domain/Entitys/SecurityNumberGenerateRecord.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using BarCode.Web.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 防伪码生成记录
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_barcode_securitynumbergeneraterecord")]
|
||||
public class SecurityNumberGenerateRecord : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 订单编号
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 防伪码批次
|
||||
/// </summary>
|
||||
[Column("LotNumber")]
|
||||
public string LotNumber { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[Column("MaterialNumber")]
|
||||
public string MaterialNumber { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 公司Id
|
||||
/// </summary>
|
||||
[Column("CompanyId")]
|
||||
public int CompanyId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 组织Id
|
||||
/// </summary>
|
||||
[Column("OrgCode")]
|
||||
public string OrgCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 供应商code
|
||||
/// </summary>
|
||||
[Column("SupplierCode")]
|
||||
public string SupplierCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 生成完成 1 生成中 0
|
||||
///</summary>
|
||||
[Column("IsGenerateComplete")]
|
||||
public bool IsGenerateComplete { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 生成条码数量
|
||||
///</summary>
|
||||
[Column("Number")]
|
||||
public int Number { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 下载数
|
||||
///</summary>
|
||||
[Column("DownLoadNumber")]
|
||||
public int DownLoadNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Column("CreatorId")]
|
||||
public int CreatorId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 生成时间
|
||||
/// </summary>
|
||||
[Column("CreateTime")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// 生成完成时间
|
||||
/// </summary>
|
||||
[Column("GenerateCompleteTime")]
|
||||
public DateTime? GenerateCompleteTime { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 生成完成
|
||||
/// </summary>
|
||||
public void Complete()
|
||||
{
|
||||
this.IsGenerateComplete = true;
|
||||
this.GenerateCompleteTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
public void DownLoad(int number)
|
||||
{
|
||||
this.DownLoadNumber = number;
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成批号
|
||||
/// </summary>
|
||||
public void GenerateLotNumber(int number)
|
||||
{
|
||||
//用户手动输入了 就不自动生成了
|
||||
if (!string.IsNullOrEmpty(this.LotNumber)) return;
|
||||
|
||||
if (number.ToString().Length >= 3)
|
||||
{
|
||||
this.LotNumber = "FWM" + DateTime.Now.ToString("yyMMdd") + number;
|
||||
return;
|
||||
}
|
||||
|
||||
string idStr = number.ToString();
|
||||
while (true)
|
||||
{
|
||||
idStr = "0" + idStr;
|
||||
if (idStr.Length >= 3) break;
|
||||
}
|
||||
this.LotNumber = "FWM" + DateTime.Now.ToString("yyMMdd") + idStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
110
src/BarCode.Web.Domain/Entitys/SecurityNumbers.cs
Normal file
110
src/BarCode.Web.Domain/Entitys/SecurityNumbers.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using BarCode.Web.Core;
|
||||
using BarCode.Web.Domain.Services.Public;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 防伪码
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_barcode_securitynumbers")]
|
||||
public class SecurityNumbers : EntityLongBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 订单编号
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 组织Code
|
||||
/// </summary>
|
||||
[Column("OrgCode")]
|
||||
public string OrgCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 供应商code
|
||||
/// </summary>
|
||||
[Column("SupplierCode")]
|
||||
public string SupplierCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 生成记录Id
|
||||
/// </summary>
|
||||
[Column("GenerateRecordId")]
|
||||
public int GenerateRecordId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 防伪码
|
||||
/// </summary>
|
||||
[Column("SecurityNumber")]
|
||||
public string SecurityNumber { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[Column("MaterialNumber")]
|
||||
public string MaterialNumber { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 下载次数
|
||||
/// </summary>
|
||||
[Column("DownLoadNumber")]
|
||||
public int DownLoadNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 最新下载时间
|
||||
/// </summary>
|
||||
[Column("DownLoadTime")]
|
||||
public DateTime? DownLoadTime { get; set; }
|
||||
/// <summary>
|
||||
/// 查询次数
|
||||
/// </summary>
|
||||
[Column("QueryCount")]
|
||||
public int QueryCount { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 第一次查询时间
|
||||
/// </summary>
|
||||
[Column("QueryTime")]
|
||||
public DateTime? QueryTime { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Column("CreatorId")]
|
||||
public int CreatorId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 生成时间
|
||||
/// </summary>
|
||||
[Column("CreateTime")]
|
||||
public DateTime? CreateTime { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
public void DownLoad()
|
||||
{
|
||||
this.DownLoadNumber++;
|
||||
this.DownLoadTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成防伪码
|
||||
/// </summary>
|
||||
public void GenerateSecurityNumber()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.SecurityNumber)) return;
|
||||
string exclude = "WXYZ";
|
||||
int? FLength = 9;
|
||||
|
||||
var idStr = Radix.ConvertRadix36((ulong)this.Id, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0');
|
||||
this.SecurityNumber = "A" + idStr;
|
||||
}
|
||||
/// <summary>
|
||||
/// 被查询
|
||||
/// </summary>
|
||||
public void Get()
|
||||
{
|
||||
if (this.QueryCount <= 0)
|
||||
this.QueryTime = DateTime.Now;
|
||||
this.QueryCount++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
150
src/BarCode.Web.Domain/Entitys/SerialNumberGenerateRecord.cs
Normal file
150
src/BarCode.Web.Domain/Entitys/SerialNumberGenerateRecord.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using BarCode.Web.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列号生成记录
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_barcode_serialnumbergeneraterecord")]
|
||||
public class SerialNumberGenerateRecord : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 订单编号
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 物料Id转32进制
|
||||
/// </summary>
|
||||
[Column("IdConvertBar")]
|
||||
public string IdConvertBar { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[Column("MaterialNumber")]
|
||||
public string MaterialNumber { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 是否更改过物料编码
|
||||
/// </summary>
|
||||
[Column("IsUpdateMaterial")]
|
||||
public bool? IsUpdateMaterial { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 采购单号
|
||||
///</summary>
|
||||
[Column("PurchaseBillNo")]
|
||||
public string PurchaseBillNo { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 供应商code
|
||||
/// </summary>
|
||||
[Column("SupplierCode")]
|
||||
public string SupplierCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 公司Id
|
||||
/// </summary>
|
||||
[Column("CompanyId")]
|
||||
public int CompanyId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 组织Id
|
||||
/// </summary>
|
||||
[Column("OrgCode")]
|
||||
public string OrgCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 生成完成 1 生成中 0
|
||||
///</summary>
|
||||
[Column("IsGenerateComplete")]
|
||||
public bool IsGenerateComplete { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 生成条码数量
|
||||
///</summary>
|
||||
[Column("Number")]
|
||||
public int Number { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 生成条码起始位数量(后端用来做标记)
|
||||
///</summary>
|
||||
[Column("BeginNumber")]
|
||||
public int BeginNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 打印数
|
||||
///</summary>
|
||||
[Column("PrintNumber")]
|
||||
public int PrintNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 下载数
|
||||
///</summary>
|
||||
[Column("DownLoadNumber")]
|
||||
public int DownLoadNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 使用数
|
||||
///</summary>
|
||||
[Column("UseNumber")]
|
||||
public int UseNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Column("CreatorId")]
|
||||
public int CreatorId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 是否套装,默认是为1,1即为单个,不是套装Alter by yzh
|
||||
///</summary>
|
||||
[Column("IsTwo")]
|
||||
public int IsTwo { get; set; } = 1;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成时间
|
||||
/// </summary>
|
||||
[Column("CreateTime")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// 生成完成时间
|
||||
/// </summary>
|
||||
[Column("GenerateCompleteTime")]
|
||||
public DateTime? GenerateCompleteTime { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 生成完成
|
||||
/// </summary>
|
||||
public void Complete()
|
||||
{
|
||||
this.IsGenerateComplete = true;
|
||||
this.GenerateCompleteTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印
|
||||
/// </summary>
|
||||
public void Print(int number)
|
||||
{
|
||||
this.PrintNumber= number;
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
public void DownLoad(int number)
|
||||
{
|
||||
this.DownLoadNumber= number;
|
||||
}
|
||||
/// <summary>
|
||||
/// 反写使用数
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
public void Use(int number)
|
||||
{
|
||||
this.UseNumber = number;
|
||||
}
|
||||
/// <summary>
|
||||
/// 标记修改物料
|
||||
/// </summary>
|
||||
public void UpdateMaterial()
|
||||
{
|
||||
this.IsUpdateMaterial = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
287
src/BarCode.Web.Domain/Entitys/SerialNumbers.cs
Normal file
287
src/BarCode.Web.Domain/Entitys/SerialNumbers.cs
Normal file
@@ -0,0 +1,287 @@
|
||||
using BarCode.Web.Core;
|
||||
using BarCode.Web.Core.Help;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.Services.Public;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列号 默认Id从 200000000 起始
|
||||
/// alter table users AUTO_INCREMENT=200000000;
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_barcode_serialnumbers")]
|
||||
public class SerialNumbers : EntityLongBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键 订单编号
|
||||
/// </summary>
|
||||
[Column("Id")]
|
||||
public override long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 组织Code
|
||||
/// </summary>
|
||||
[Column("OrgCode")]
|
||||
public string OrgCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 供应商code
|
||||
/// </summary>
|
||||
[Column("SupplierCode")]
|
||||
public string SupplierCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 生成记录Id
|
||||
/// </summary>
|
||||
[Column("GenerateRecordId")]
|
||||
public int GenerateRecordId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 序列号
|
||||
/// </summary>
|
||||
[Column("SerialNumber")]
|
||||
public string SerialNumber { get; set; } = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 套装(1代表单套,2代表2套,3代表3套) aLTER BY YZH
|
||||
/// </summary>
|
||||
[Column("IsTwo")]
|
||||
public int IsTwo { get; set; } =1;
|
||||
|
||||
/// <summary>
|
||||
///当次序号,用来记录当次所产生时所处的序列号
|
||||
/// </summary>
|
||||
[Column("thisNumber")]
|
||||
public int thisNumber { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 序列号
|
||||
/// </summary>
|
||||
[Column("SuitNumber")]
|
||||
public string SuitNumber { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 产生第二个
|
||||
/// </summary>
|
||||
[Column("TwoSerialNumber")]
|
||||
public string TwoSerialNumber { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
[Column("MaterialId")]
|
||||
public int MaterialId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
[Column("MaterialNumber")]
|
||||
public string MaterialNumber { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 老物料编码(上一次物料编码)
|
||||
/// </summary>
|
||||
[Column("Old_MaterialNumber")]
|
||||
public string? Old_MaterialNumber { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 箱ID
|
||||
/// </summary>
|
||||
[Column("BoxId")]
|
||||
public int BoxId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 数字序列码
|
||||
/// </summary>
|
||||
[Column("NumberCode")]
|
||||
public string NumberCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 数字序列码(不包含日期)
|
||||
/// </summary>
|
||||
[Column("Number")]
|
||||
public int Number { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// 是否使用
|
||||
/// </summary>
|
||||
[Column("IsUse")]
|
||||
public bool IsUse { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Column("CreatorId")]
|
||||
public int CreatorId { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 生成时间
|
||||
/// </summary>
|
||||
[Column("CreateTime")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// 完成装箱时间
|
||||
/// </summary>
|
||||
[Column("CompleteCartonTime")]
|
||||
public DateTime? CompleteCartonTime { get; set; }
|
||||
/// <summary>
|
||||
/// 打印次数
|
||||
/// </summary>
|
||||
[Column("PrintNumber")]
|
||||
public int PrintNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 下载次数
|
||||
/// </summary>
|
||||
[Column("DownLoadNumber")]
|
||||
public int DownLoadNumber { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 最新打印时间
|
||||
/// </summary>
|
||||
[Column("PrintTime")]
|
||||
public DateTime? PrintTime { get; set; }
|
||||
/// <summary>
|
||||
/// 最新下载时间
|
||||
/// </summary>
|
||||
[Column("DownLoadTime")]
|
||||
public DateTime? DownLoadTime { get; set; }
|
||||
/// <summary>
|
||||
/// 是否使用的是数字序列码未使用null,数字序列码true,序列码false
|
||||
/// </summary>
|
||||
[Column("IsUseNumber")]
|
||||
public bool? IsUseNumber { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 生成序列码
|
||||
/// </summary>
|
||||
public string GenerateSerialNumber()
|
||||
{
|
||||
string exclude = "ISOZ";
|
||||
int? FLength = 6;
|
||||
|
||||
var idStr = Radix.ConvertRadix36((ulong)this.Id, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0');
|
||||
this.SerialNumber = this.SerialNumber + "-" + idStr;
|
||||
return this.SerialNumber;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 生成套装编码 alter by yzh
|
||||
///// </summary>
|
||||
//public void GenerateSuitNumber(string sn,)
|
||||
//{
|
||||
|
||||
|
||||
// string exclude = "ISOZ";
|
||||
// int? FLength = 6;
|
||||
|
||||
// var idStr = Radix.ConvertRadix36((ulong)this.Id, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0');
|
||||
// this.SerialNumber = this.SerialNumber + "-" + idStr;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成时间序列码
|
||||
/// </summary>
|
||||
public void GenerateNumberCode()
|
||||
{
|
||||
//用户手动输入了 就不自动生成了
|
||||
if (!string.IsNullOrEmpty(this.NumberCode)) return;
|
||||
|
||||
if (this.Number.ToString().Length >= 6)
|
||||
{
|
||||
this.NumberCode = this.CreateTime.ToString("yyMMdd") + this.Number.ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
string idStr = this.Number.ToString();
|
||||
while (true)
|
||||
{
|
||||
idStr = "0" + idStr;
|
||||
if (idStr.Length >= 6) break;
|
||||
}
|
||||
this.NumberCode = this.CreateTime.ToString("yyMMdd") + idStr;
|
||||
}
|
||||
/// <summary>
|
||||
/// 产生套装编码 alter by yzh
|
||||
/// </summary>
|
||||
/// <param name="sn"></param>
|
||||
|
||||
public void GenerateSuitNumber(string sn)
|
||||
{
|
||||
this.SuitNumber = sn;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 产生第二个序列号
|
||||
/// </summary>
|
||||
/// <param name="sn"></param>
|
||||
public void GenerateTwoSerialNumber(string sn)
|
||||
{
|
||||
this.TwoSerialNumber = sn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打印
|
||||
/// </summary>
|
||||
public void Print()
|
||||
{
|
||||
//被wms使用的数据不能被打印
|
||||
if (this.BoxId <= 0 && this.IsUse == true) return;
|
||||
|
||||
this.PrintNumber++;
|
||||
this.PrintTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
public void DownLoad()
|
||||
{
|
||||
this.DownLoadNumber++;
|
||||
this.DownLoadTime = DateTime.Now;
|
||||
}
|
||||
/// <summary>
|
||||
/// 装箱
|
||||
/// </summary>
|
||||
/// <param name="boxId"></param>
|
||||
/// <param name="str"></param>
|
||||
public void CompleteBox(int boxId, string str)
|
||||
{
|
||||
//每个序列码延时1毫秒来装箱 这样到时候获取序列码时就可以来排序
|
||||
Thread.Sleep(1);
|
||||
this.BoxId = boxId;
|
||||
this.CompleteCartonTime = DateTime.Now;
|
||||
this.IsUse = true;
|
||||
this.IsUseNumber = this.NumberCode.Equals(str) ? true : false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 解绑箱
|
||||
/// </summary>
|
||||
public void UnBox()
|
||||
{
|
||||
this.BoxId = 0;
|
||||
this.CompleteCartonTime = null;
|
||||
this.IsUse = false;
|
||||
this.IsUseNumber = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// wms系统获取序列码后 序列码调整为已使用
|
||||
/// </summary>
|
||||
public void WmsGet(string str)
|
||||
{
|
||||
this.BoxId = -1;
|
||||
this.IsUse = true;
|
||||
this.IsUseNumber = this.NumberCode.Equals(str) ? true : false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改物料编码
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
public Result UpdateMaterial(string number)
|
||||
{
|
||||
if (this.IsUse)
|
||||
return Result.ReFailure($"序列码 {this.SerialNumber} 已被使用,不允许规格转换", 600007);
|
||||
if (!this.MaterialNumber.Equals(number))
|
||||
{
|
||||
this.Old_MaterialNumber = this.MaterialNumber;
|
||||
this.MaterialNumber = number;
|
||||
}
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/BarCode.Web.Domain/IService/IBoxMarkService.cs
Normal file
32
src/BarCode.Web.Domain/IService/IBoxMarkService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
|
||||
namespace BarCode.Web.Domain.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛-服务接口
|
||||
/// </summary>
|
||||
public interface IBoxMarkService
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<BoxMarkQueryResponse>> Generate(GenerateBoxMarkDto dto, LoginInDto loginInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 列表-分页
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<(List<BoxMarkQueryResponse> list, int total)> GetPagedList(BoxMarkQueryRequest dto, LoginInDto loginInfo);
|
||||
}
|
||||
}
|
||||
60
src/BarCode.Web.Domain/IService/IBoxService.cs
Normal file
60
src/BarCode.Web.Domain/IService/IBoxService.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Box;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SerialNumbers;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱
|
||||
/// </summary>
|
||||
public interface IBoxService
|
||||
{
|
||||
/// <summary>
|
||||
/// wms获取已完成装箱箱信息
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<(List<WmsBoxResponse> list, int total)> GetCartonListAsync(WmsBoxRequest dto);
|
||||
/// <summary>
|
||||
/// 装箱
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Save(SaveBoxRequest dto, LoginInDto loginInfo);
|
||||
/// <summary>
|
||||
/// 生成箱码
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Generate(GenerateBoxRequest dto, LoginInDto loginInfo);
|
||||
/// 打印
|
||||
Task<Result> Print(OperateRequest dto);
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
Task<Result> Delete(DeleteBoxSerialNumberRequest dto, LoginInDto loginInfo);
|
||||
/// <summary>
|
||||
/// 清空
|
||||
/// </summary>
|
||||
/// <param name="boxId"></param>
|
||||
Task<Result> Clear(int boxId, LoginInDto loginInfo);
|
||||
/// 重新装箱
|
||||
Task<Result> Restart(OperateRequest dto, LoginInDto loginInfo);
|
||||
/// <summary>
|
||||
/// 开始装箱
|
||||
/// </summary>
|
||||
/// <param name="boxId"></param>
|
||||
Task<Result> BeginCarton(int boxId, LoginInDto loginInfo);
|
||||
}
|
||||
}
|
||||
56
src/BarCode.Web.Domain/IService/IExportExcelService.cs
Normal file
56
src/BarCode.Web.Domain/IService/IExportExcelService.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Npoi.Mapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
|
||||
namespace BarCode.Web.Domain.IService
|
||||
{
|
||||
public interface IExportExcelService
|
||||
{
|
||||
/// <summary>
|
||||
/// 全字段导出数据
|
||||
/// </summary>
|
||||
/// <typeparam name="Response"></typeparam>
|
||||
/// <typeparam name="Request"></typeparam>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="mapper"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="supplierId"></param>
|
||||
/// <returns></returns>
|
||||
Task ExportAll<Response, Request>(Request request, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null) where Request : PaginationBaseRequestDto;
|
||||
/// <summary>
|
||||
/// 列表字段导出数据
|
||||
/// </summary>
|
||||
/// <typeparam name="Response"></typeparam>
|
||||
/// <typeparam name="Request"></typeparam>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="mapper"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="supplierId"></param>
|
||||
/// <returns></returns>
|
||||
Task ExportList<Response, Request>(Request request, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type,string orgCode, Mapper mapper = null, int? supplierId = null) where Request : PaginationBaseRequestDto;
|
||||
/// <summary>
|
||||
/// 列表页导出数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dataList"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="mapper"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <param name="supplierId"></param>
|
||||
/// <returns></returns>
|
||||
Task Export<T>(List<T> dataList, string fileName,int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null);
|
||||
}
|
||||
}
|
||||
22
src/BarCode.Web.Domain/IService/IQiniuUploadService.cs
Normal file
22
src/BarCode.Web.Domain/IService/IQiniuUploadService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
|
||||
namespace BarCode.Web.Domain.IService
|
||||
{
|
||||
public interface IQiniuUploadService
|
||||
{
|
||||
/// <summary>
|
||||
/// 上传文件
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="isAutoDelte">是否开启自动删除 如果开启 3天后自动删除 导出的execl文件</param>
|
||||
/// <returns></returns>
|
||||
Task<Result<string>> Upload(string fileName, Stream stream,bool isAutoDelte= false);
|
||||
}
|
||||
}
|
||||
32
src/BarCode.Web.Domain/IService/ISecurityNumberService.cs
Normal file
32
src/BarCode.Web.Domain/IService/ISecurityNumberService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SecurityNumbers;
|
||||
using BarCode.Web.Core.Dto.SerialNumbers;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 防伪码
|
||||
/// </summary>
|
||||
public interface ISecurityNumberService
|
||||
{
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> DownLoad(OperateSecurityNumberRequest dto);
|
||||
/// <summary>
|
||||
/// 生成防伪码
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Generate(GenerateSecurityNumberRequest dto, LoginInDto loginInfo);
|
||||
}
|
||||
}
|
||||
50
src/BarCode.Web.Domain/IService/ISerialNumberService.cs
Normal file
50
src/BarCode.Web.Domain/IService/ISerialNumberService.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SerialNumbers;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列号服务
|
||||
/// </summary>
|
||||
public interface ISerialNumberService
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成序列号
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Generate(GenerateSerialNumberRequest dto, LoginInDto loginInfo);
|
||||
/// <summary>
|
||||
/// 打印
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Print(OperateSerialNumberRequest dto);
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> DownLoad(OperateSerialNumberRequest dto);
|
||||
/// <summary>
|
||||
/// 装箱后反写使用数
|
||||
/// </summary>
|
||||
/// <param name="sGIds"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> Use(List<int> sGIds);
|
||||
/// <summary>
|
||||
/// 修改序列号物料
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> UpdateMaterial(UpdateMaterialRequest dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using BarCode.Web.Core.Dto.Erp.Customer;
|
||||
using BarCode.Web.Core.Dto.Erp.Org;
|
||||
using BarCode.Web.Core.Dto.Erp.Supplier;
|
||||
using BarCode.Web.Core.Dto.SingleData;
|
||||
|
||||
namespace BarCode.Web.Domain.IService.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// erp基础数据:扩展服务接口
|
||||
/// </summary>
|
||||
public interface IErpBasicDataExtendService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取物料名称
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
string GetMaterialName(List<ErpMaterialDto> erpMaterials, int materialId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料编码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialNumber(List<ErpMaterialDto> erpMaterials, int materialId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料规格型号
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialSpecifications(List<ErpMaterialDto> erpMaterials, int materialId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料名称
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
string GetMaterialName(List<ErpMaterialDto> erpMaterials, string materialNumber);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料规格型号
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialSpecifications(List<ErpMaterialDto> erpMaterials, string materialNumber);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料基本单位名称
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialUnitName(List<ErpMaterialDto> erpMaterials, int materialId);
|
||||
/// <summary>
|
||||
/// 获取物料基本单位名称
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialnumber"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialUnitName(List<ErpMaterialDto> erpMaterials, string materialnumber);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的条码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialBarCode(List<ErpMaterialDto> erpMaterials, int materialId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的条码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialBarCode(List<ErpMaterialDto> erpMaterials, string materialNumber);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料基本单位id
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
int GetMaterialUnitId(List<ErpMaterialDto> erpMaterials, int materialId);
|
||||
/// <summary>
|
||||
/// 获取物料基本单位编码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialUnitNumber(List<ErpMaterialDto> erpMaterials, int materialId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料基本单位编码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
/// <returns></returns>
|
||||
string GetMaterialUnitNumber(List<ErpMaterialDto> erpMaterials, string materialNumber);
|
||||
/// <summary>
|
||||
/// 获取组织名称
|
||||
/// </summary>
|
||||
/// <param name="erpOrgs"></param>
|
||||
/// <param name="orgId"></param>
|
||||
/// <returns></returns>
|
||||
string GetOrgName(List<ErpOrgDto> erpOrgs, int orgId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取组织名称
|
||||
/// </summary>
|
||||
/// <param name="erpOrgs"></param>
|
||||
/// <param name="orgCode"></param>
|
||||
/// <returns></returns>
|
||||
string GetOrgName(List<ErpOrgDto> erpOrgs, string orgCode);
|
||||
|
||||
/// <summary>
|
||||
/// 获取组织ID
|
||||
/// </summary>
|
||||
/// <param name="erpOrgs"></param>
|
||||
/// <param name="orgCode"></param>
|
||||
int GetOrgId(List<ErpOrgDto> erpOrgs, string orgCode);
|
||||
|
||||
/// <summary>
|
||||
/// 获取供应商名称
|
||||
/// </summary>
|
||||
/// <param name="erpSuppliers"></param>
|
||||
/// <param name="supplierId"></param>
|
||||
/// <returns></returns>
|
||||
string GetSupplierName(List<ErpSupplierDto> erpSuppliers, int supplierId);
|
||||
/// <summary>
|
||||
/// 获取供应商名称
|
||||
/// </summary>
|
||||
/// <param name="erpSuppliers"></param>
|
||||
/// <param name="supplierCode"></param>
|
||||
/// <returns></returns>
|
||||
string GetSupplierName(List<ErpSupplierDto> erpSuppliers, string supplierCode);
|
||||
/// <summary>
|
||||
/// 获取客户名称
|
||||
/// </summary>
|
||||
/// <param name="erpCustomers"></param>
|
||||
/// <param name="customerId"></param>
|
||||
/// <returns></returns>
|
||||
string GetCustomerName(List<ErpCustomerDto> erpCustomers, int customerId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库名称
|
||||
/// </summary>
|
||||
/// <param name="erpStocks"></param>
|
||||
/// <param name="stockId"></param>
|
||||
/// <returns></returns>
|
||||
string GetStockName(List<ErpStockDto> erpStocks, int stockId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库名称
|
||||
/// </summary>
|
||||
/// <param name="erpStocks"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
string GetStockName(List<ErpStockDto> erpStocks, string code);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库编码
|
||||
/// </summary>
|
||||
/// <param name="erpStocks"></param>
|
||||
/// <param name="stockId"></param>
|
||||
/// <returns></returns>
|
||||
string GetStockCode(List<ErpStockDto> erpStocks, int stockId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取子仓库名称
|
||||
/// </summary>
|
||||
/// <param name="erpStocks"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
string GetSubStockName(List<Erp_SubStockDto> erpStocks, string code);
|
||||
/// <summary>
|
||||
/// 获取单点组织名字
|
||||
/// </summary>
|
||||
/// <param name="orgs"></param>
|
||||
/// <param name="code"></param>
|
||||
string GetSingleOrgName(List<SysOrgResponse> orgs, string code);
|
||||
}
|
||||
}
|
||||
100
src/BarCode.Web.Domain/IService/Public/IErpService.cs
Normal file
100
src/BarCode.Web.Domain/IService/Public/IErpService.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using BarCode.Web.Core.Dto.Erp.Customer;
|
||||
using BarCode.Web.Core.Dto.Erp.Org;
|
||||
using BarCode.Web.Core.Dto.Erp.OutStock;
|
||||
using BarCode.Web.Core.Dto.Erp.Supplier;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
|
||||
namespace BarCode.Web.Domain.IService.Public
|
||||
{
|
||||
public interface IErpService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查单据类型的值
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpBaseDto>> BillQueryForBillType();
|
||||
/// <summary>
|
||||
/// erp:单据查询-物料集合
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpMaterialDto>> BillQueryForMaterial(bool isCache = true);
|
||||
/// <summary>
|
||||
/// 获取物料id32进制
|
||||
/// </summary>
|
||||
/// <param name="materialNumbers"></param>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpMaterialDto>> BillQueryForMaterialByNumbers(List<string> materialNumbers);
|
||||
|
||||
/// <summary>
|
||||
/// erp:基础数据-物料信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result<ErpMaterialDto>> BillQueryForMaterial(int id);
|
||||
/// <summary>
|
||||
/// erp:基础数据-物料信息
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result<ErpMaterialDto>> BillQueryForMaterial(string number);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
Task<ErpMaterialDto> BillQueryForMaterialByNumber(string number);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <returns></returns>
|
||||
Task<ErpMaterialDto> BillQueryForMaterialByNumber(string number, string orgCode);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpOrgDto>> BillQueryForOrg();
|
||||
|
||||
/// <summary>
|
||||
/// 供应商
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpSupplierDto>> BillQueryForSupplier();
|
||||
/// <summary>
|
||||
/// 客户
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpCustomerDto>> BillQueryForCustomer();
|
||||
/// <summary>
|
||||
/// 获取仓库信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<ErpStockDto>> BillQueryForStock();
|
||||
/// <summary>
|
||||
/// 获取仓位信息信息 根据仓库编码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ResultList<Erp_SubStockDto>> BillQueryForSubStock();
|
||||
|
||||
//同步数据(保存提交审核)
|
||||
Task<Result<string>> Save<T>(T dto, string formId);
|
||||
//提交
|
||||
Task<Result> Submit(ErpOperateDto dto, string formId);
|
||||
//审核
|
||||
Task<Result> Audit(ErpOperateDto dto, string formId);
|
||||
//反审核
|
||||
Task<Result> NoAudit(ErpOperateDto dto, string formId);
|
||||
//删除
|
||||
Task<Result> Delete(ErpOperateDto dto, string formId);
|
||||
//下推
|
||||
Task<Result<string>> Push(ErpPushDto dto);
|
||||
}
|
||||
}
|
||||
18
src/BarCode.Web.Domain/IService/Public/IHttpClientService.cs
Normal file
18
src/BarCode.Web.Domain/IService/Public/IHttpClientService.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.IService.Public
|
||||
{
|
||||
public interface IHttpClientService
|
||||
{
|
||||
HttpClient BuildHttpClient(Dictionary<string, string> dicDefaultHeaders, int? timeoutSecond = 180);
|
||||
Task<T> GetAsync<T>(string url, int timeoutSecond = 180);
|
||||
Task<T> GetAsync<T>(string url, Dictionary<string, string> dicHeaders, int timeoutSecond = 180);
|
||||
Task<T> PostAsync<T>(string url, string requestBody, int timeoutSecond = 180);
|
||||
Task<T> PostAsync<T>(string url, string requestBody, Dictionary<string, string> dicHeaders, int timeoutSecond = 180);
|
||||
Task<T> ExecuteAsync<T>(string url, HttpMethod method, string requestBody, Dictionary<string, string> dicHeaders, int timeoutSecond = 180);
|
||||
}
|
||||
}
|
||||
77
src/BarCode.Web.Domain/IService/Public/ILoginService.cs
Normal file
77
src/BarCode.Web.Domain/IService/Public/ILoginService.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.Login.Temp;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
|
||||
namespace BarCode.Web.Domain.IService.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录服务接口
|
||||
/// </summary>
|
||||
public interface ILoginService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 创建token
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="tempDto"></param>
|
||||
/// <param name="NewToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<AccessTokenDto> CreateToken(UserInfoDto data, LoginTempDto tempDto, string NewToken);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result<LoginInDto>> GetUserInfoByCode(string code);
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点用户信息
|
||||
/// </summary>
|
||||
/// <param name="username"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result<LoginInDto>> GetUserInfo(string username, string password);
|
||||
|
||||
/// <summary>
|
||||
/// 登录退出
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result> LoginOut(LoginOutDto dto);
|
||||
|
||||
/// <summary>
|
||||
/// 刷新token
|
||||
/// </summary>
|
||||
/// <param name="Token"></param>
|
||||
/// <param name="RefreshToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result<LoginInDto>> RefreshTokenNew(string Token, string RefreshToken);
|
||||
|
||||
/// <summary>
|
||||
/// 单点退出通知token失效
|
||||
/// </summary>
|
||||
/// <param name="SeesionId"></param>
|
||||
/// <returns></returns>
|
||||
Task LoginOutSingleAsync(string SeesionId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取登录后的信息
|
||||
/// </summary>
|
||||
/// <param name="authorization"></param>
|
||||
/// <returns></returns>
|
||||
LoginInDto GetLoginInfo(string authorization);
|
||||
|
||||
/// <summary>
|
||||
/// 获取菜单
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<MenuResponse>> GetMenuList(int userId);
|
||||
}
|
||||
}
|
||||
25
src/BarCode.Web.Domain/IService/Public/IMaterialService.cs
Normal file
25
src/BarCode.Web.Domain/IService/Public/IMaterialService.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
|
||||
namespace BarCode.Web.Domain.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料服务接口
|
||||
/// </summary>
|
||||
public interface IMaterialService
|
||||
{
|
||||
/// <summary>
|
||||
/// 同步金蝶新物料
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<Result> SyncNewMaterials();
|
||||
/// <summary>
|
||||
/// 同步物料id32进制
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<Result> SyncBar();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.IService.Public
|
||||
{
|
||||
public interface IRedisConcurrentProcessService
|
||||
{
|
||||
bool CanAccessMethod(string cacheKey);
|
||||
|
||||
bool GetRedisKeyValue(string cacheKey);
|
||||
|
||||
void UpdateAccessStatus(string cacheKey, bool canAccess);
|
||||
}
|
||||
}
|
||||
128
src/BarCode.Web.Domain/IService/Public/ISingleDataService.cs
Normal file
128
src/BarCode.Web.Domain/IService/Public/ISingleDataService.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Domain.Values.Single;
|
||||
|
||||
namespace BarCode.Web.Domain.IService.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// 单点数据返回服务接口
|
||||
/// </summary>
|
||||
public interface ISingleDataService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取单点数据:根据方法名和公司ID
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
string GetSingleData(SingleAction action, int companyId, int id);
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据:根据方法名和公司ID
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
decimal GetSingleDataNumber(SingleAction action, int companyId, int id);
|
||||
/// <summary>
|
||||
/// 获取单点数据:根据方法名和公司ID
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
string GetSingleDataCode(SingleAction action, int companyId, int id);
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据:根据方法名和公司ID
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="id">加上ID防止编码重复</param>
|
||||
/// <returns></returns>
|
||||
string GetSingleData(SingleAction action, int companyId, string code);
|
||||
/// <summary>
|
||||
/// 根据名字模糊匹配
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
List<int> GetIdsBySingleName(SingleAction action, int companyId, string name);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据集合:泛型-同步
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
List<T> GetSingleData<T>(SingleAction action, int companyId) where T : class;
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据集合:泛型-异步
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<T>> GetSingleDataAsync<T>(SingleAction action, int companyId) where T : class;
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据集合:泛型-异步-无缓存
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<T>> GetSingleDataNoCacheAsync<T>(SingleAction action, int companyId) where T : class;
|
||||
|
||||
/// <summary>
|
||||
/// 单点数据:可对接全部接口
|
||||
/// </summary>
|
||||
/// <typeparam name="T">返回对象</typeparam>
|
||||
/// <typeparam name="X">请求对象</typeparam>
|
||||
/// <typeparam name="Y">方法名称</typeparam>
|
||||
/// <param name="dto">请求对象</param>
|
||||
/// <param name="action">方法名称</param>
|
||||
/// <param name="type">控制器名称</param>
|
||||
/// <returns></returns>
|
||||
Task<T> GetSingleData<T, X, Y>(X dto, Y action, SingleControllerType type = SingleControllerType.Single) where T : class;
|
||||
|
||||
/// <summary>
|
||||
/// 单点数据:可对接全部接口-无缓存
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="X"></typeparam>
|
||||
/// <typeparam name="Y"></typeparam>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> GetSingleDataNoCache<T, X, Y>(X dto, Y action, SingleControllerType type = SingleControllerType.Single) where T : class;
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据:请求对象和接口方法名
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="X"></typeparam>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> GetSysConfigData<T, X>(X dto, SysConfigAction action);
|
||||
|
||||
/// <summary>
|
||||
/// 获取客户仓库
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="customerStockCode"></param>
|
||||
/// <returns></returns>
|
||||
string GetCustomerStock(int companyId, string customerStockCode);
|
||||
}
|
||||
}
|
||||
22
src/BarCode.Web.Domain/IService/Public/IWmsService.cs
Normal file
22
src/BarCode.Web.Domain/IService/Public/IWmsService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
|
||||
namespace BarCode.Web.Domain.IService.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// wms重置箱信息
|
||||
/// </summary>
|
||||
public interface IWmsService
|
||||
{
|
||||
/// <summary>
|
||||
/// 重置wms箱信息
|
||||
/// </summary>
|
||||
/// <param name="boxBillNos"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result<List<string>>> Restart(List<string> boxBillNos);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
public interface IAllFielRepositories<Request>
|
||||
{
|
||||
/// <summary>
|
||||
/// 全字段导出接口
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
//Task<(object obj, int total)> GetListAllField(Request dto, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 列表字段导出接口
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<(object obj, int total)> GetListField(Request dto, LoginInDto loginInfo);
|
||||
}
|
||||
}
|
||||
93
src/BarCode.Web.Domain/Infrastructure/IBasicsRepositories.cs
Normal file
93
src/BarCode.Web.Domain/Infrastructure/IBasicsRepositories.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto.SingleData;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础数据
|
||||
/// </summary>
|
||||
public interface IBasicsRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据用户精确搜索用户
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<int>> GetUserIdsAsync(string name, int companyId);
|
||||
/// <summary>
|
||||
/// 获取所有人员-根据主体
|
||||
/// </summary>
|
||||
/// <param name="CompanyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SysStaffResponse>> GetStaffListAsync(int CompanyId);
|
||||
/// <summary>
|
||||
/// 根据仓库获取子仓库
|
||||
/// </summary>
|
||||
/// <param name="id">仓库id</param>
|
||||
/// <returns></returns>
|
||||
Task<List<UcStockResponse>> GetSubUcStockAsync(int stockId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓位:根据name模糊,和系统code和公司
|
||||
/// </summary>
|
||||
/// <param name="systemCode"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<UcSubStockResponse>> GetSubUcStockAsync(string systemCode, string name, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓位详情:根据仓位ID和公司ID
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<UcSubStockResponse> GetSubUcStockAsync(int id, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓位集合:根据仓位ID集合和公司ID
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<UcSubStockResponse>> GetSubUcStockAsync(List<int> ids, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓位详情:根据仓位ID和公司ID
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<UcSubStockResponse> GetSubUcStockAsync(string code, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓位集合:根据仓位编码集合和公司ID
|
||||
/// </summary>
|
||||
/// <param name="codes"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<UcSubStockResponse>> GetSubUcStockAsync(List<string> codes, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<UcStockResponse>> GetUcStockAsync(string systemCode,string name, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取事务 用来处理即时库存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IDbContextTransaction GetTransaction();
|
||||
|
||||
/// <summary>
|
||||
/// 获取事务 用来处理即时库存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool CommitTransaction(bool isRollback, IDbContextTransaction transaction);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛-仓储接口
|
||||
/// </summary>
|
||||
public interface IBoxMarkRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 列表分页
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<(List<BoxMarkQueryResponse> list, int total)> GetPagedList(BoxMarkQueryRequest dto, LoginInDto loginInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<BoxMark> Add(BoxMark entity, bool isTransaction = true);
|
||||
|
||||
/// <summary>
|
||||
/// 详情-根据最新的ID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<BoxMark> GetBy();
|
||||
|
||||
/// <summary>
|
||||
/// 列表-详情信息列表
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<BoxMarkQueryResponse>> GetListInfoBy(int id, int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取最新的编号实体
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<BoxMarkBillNo> GetLastBillNo();
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DeleteRange(List<int> ids, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
47
src/BarCode.Web.Domain/Infrastructure/IBoxRepositories.cs
Normal file
47
src/BarCode.Web.Domain/Infrastructure/IBoxRepositories.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Box;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SerialNumbers;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 老ops箱信息
|
||||
/// </summary>
|
||||
public interface IBoxRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<(List<BoxInfoResponse> list, int total)> GetListAsync(BoxQueryRequest dto, LoginInDto loginInfo);
|
||||
Task<Box?> Get(int id);
|
||||
Task<Box?> GetByNo(string billNo);
|
||||
//根据箱号搜索 用来比对确定是否箱号信息是否存在
|
||||
Task<List<string>> GetByNos(List<string> billNos);
|
||||
//编辑
|
||||
Task<Box> Edit(Box entity, bool isTransaction = true);
|
||||
//批量修改
|
||||
Task<bool> EditEntityList(List<Box> entitys, bool isTransaction = true);
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddRange(List<Box> entitys, bool isTransaction = true);
|
||||
/// 查询实体集合
|
||||
Task<List<Box>> GetEntityList(List<int> ids);
|
||||
|
||||
Task<List<Box>> GetEntityListByNos(List<string> billNos);
|
||||
/// 查询实体集合
|
||||
Task<(List<Box>, int tota)> GetEntityByWmsList(WmsBoxRequest dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成数据管理
|
||||
/// </summary>
|
||||
public interface ICenerateDataRepositories
|
||||
{
|
||||
///获取最新一次更新时间
|
||||
Task<CenerateData> Get(CenerateDataType type);
|
||||
///定时任务执行后更新时间
|
||||
Task<CenerateData> Edit(CenerateData entity, bool isTransaction = true);
|
||||
///定时任务执行后创建
|
||||
Task<CenerateData> Add(CenerateData entity, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
public interface IFileDownManagerRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
Task<FileDownManager> Add(FileDownManager entity);
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
Task<FileDownManager> Edit(FileDownManager entity);
|
||||
/// <summary>
|
||||
/// 获取销售列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<FileDownManagerResponse> GetList(FileDownManagerRequest dto, LoginInDto loginInfo);
|
||||
}
|
||||
}
|
||||
24
src/BarCode.Web.Domain/Infrastructure/ILoginRepositories.cs
Normal file
24
src/BarCode.Web.Domain/Infrastructure/ILoginRepositories.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
public interface ILoginRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 公司Id
|
||||
/// </summary>
|
||||
int CompanyId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 员工ID
|
||||
/// </summary>
|
||||
int StaffId { get; set; }
|
||||
/// <summary>
|
||||
/// 登录用户信息
|
||||
/// </summary>
|
||||
LoginInDto loginInfo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料仓储接口
|
||||
/// </summary>
|
||||
public interface IMaterialsRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddRange(List<Materials> entitys, bool isTransaction = true);
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<Materials>> GetEntityList(int? orgId = null);
|
||||
|
||||
/// <summary>
|
||||
/// 物料
|
||||
/// </summary>
|
||||
/// <param name="mid"></param>
|
||||
/// <returns></returns>
|
||||
Task<Materials> Get(int mid);
|
||||
|
||||
/// <summary>
|
||||
/// 物料
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="orgId"></param>
|
||||
/// <returns></returns>
|
||||
Task<Materials> Get(string code, int orgId);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<string>> GetAllNumbers();
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="materNumbers"></param>
|
||||
/// <param name="isBatchManage"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<Materials>> GetEntityList(List<string> materNumbers, bool isBatchManage);
|
||||
|
||||
/// <summary>
|
||||
/// 列表(获取所有没有id32进制的物料)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<Materials>> GetEntityListByNoBar();
|
||||
|
||||
/// <summary>
|
||||
/// 修改物料
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateRange(List<Materials> entitys, bool isTransaction = true);
|
||||
/// <summary>
|
||||
/// 集合
|
||||
/// </summary>
|
||||
/// <param name="materNumbers"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<Materials>> GetEntityList(List<string> materNumbers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SerialNumbers;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
public interface ISGenerateRecordRepositories
|
||||
{
|
||||
// 获取列表
|
||||
Task<(List<SGenerateRecordInfoResponse> list, int total)> GetListAsync(SGenerateRecordQueryRequest dto, LoginInDto loginInfo);
|
||||
// 新增
|
||||
Task<SerialNumberGenerateRecord> Add(SerialNumberGenerateRecord entity, bool isTransaction = true);
|
||||
//编辑
|
||||
Task<SerialNumberGenerateRecord> Edit(SerialNumberGenerateRecord entity, bool isTransaction = true);
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddRange(List<SerialNumberGenerateRecord> entitys, bool isTransaction = true);
|
||||
/// 修改实体集合
|
||||
Task<bool> EditEntityList(List<SerialNumberGenerateRecord> entitys, bool isTransaction = true);
|
||||
/// 查询实体集合
|
||||
Task<List<SerialNumberGenerateRecord?>> GetEntityList(List<int> ids);
|
||||
/// 查询实体
|
||||
Task<SerialNumberGenerateRecord?> GetEntity(int id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SecurityNumbers;
|
||||
using BarCode.Web.Core.Dto.SerialNumbers;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 防伪码生成记录
|
||||
/// </summary>
|
||||
public interface ISecurityGenerateRecordRepositories
|
||||
{
|
||||
/// 获取列表
|
||||
Task<(List<SecurityGenerateRecordInfoResponse> list, int total)> GetListAsync(SecurityGenerateRecordQueryRequest dto, LoginInDto loginInfo);
|
||||
/// 新增
|
||||
Task<SecurityNumberGenerateRecord> Add(SecurityNumberGenerateRecord entity, bool isTransaction = true);
|
||||
///编辑
|
||||
Task<SecurityNumberGenerateRecord> Edit(SecurityNumberGenerateRecord entity, bool isTransaction = true);
|
||||
/// 批量添加
|
||||
Task<bool> AddRange(List<SecurityNumberGenerateRecord> entitys, bool isTransaction = true);
|
||||
/// 修改实体集合
|
||||
Task<bool> EditEntityList(List<SecurityNumberGenerateRecord> entitys, bool isTransaction = true);
|
||||
/// 查询实体集合
|
||||
Task<List<SecurityNumberGenerateRecord>> GetEntityList(List<int> ids);
|
||||
/// 查询实体
|
||||
Task<SecurityNumberGenerateRecord?> GetEntity(int id);
|
||||
/// 获取当天生成记录条数
|
||||
Task<int> GetGenerateRecordDayCount();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SecurityNumbers;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 防伪码
|
||||
/// </summary>
|
||||
public interface ISecurityNumbersRepositories
|
||||
{
|
||||
/// 获取列表
|
||||
Task<(List<SecurityNumberInfoResponse> list, int total)> GetListAsync(SecurityNumberQueryRequest dto, LoginInDto loginInfo);
|
||||
|
||||
/// 批量添加
|
||||
Task<bool> AddRange(List<SecurityNumbers> entitys, bool isTransaction = true);
|
||||
/// 修改实体集合
|
||||
Task<bool> EditEntityList(List<SecurityNumbers> entitys, bool isTransaction = true);
|
||||
/// 查询实体集合
|
||||
Task<List<SecurityNumbers>> GetEntityList(List<string> SecurityNumbers);
|
||||
/// 根据生成记录id查询序列码
|
||||
Task<List<SecurityNumbers>> GetEntityListByGRIds(List<int> gRIds);
|
||||
/// 根据生成记录id查询序列码
|
||||
Task<List<SecurityNumbers>> GetEntityListByGRId(int gRId);
|
||||
/// 查询实体
|
||||
Task<SecurityNumbers> GetEntity(string securityNumbers);
|
||||
/// 修改实体
|
||||
Task<SecurityNumbers> Edit(SecurityNumbers entity, bool isTransaction = true);
|
||||
|
||||
/// <summary>
|
||||
/// 下载反写 执行sql语句
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> DownLoad(List<int> ids, bool isTransaction = true);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SerialNumbers;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Org.BouncyCastle.Bcpg.OpenPgp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列码
|
||||
/// </summary>
|
||||
public interface ISerialNumbersRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
Task<(List<SerialNumberInfoResponse> list, int total)> GetListAsync(SerialNumberQueryRequest dto, LoginInDto loginInfo);
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddRange(List<SerialNumbers> entitys, bool isTransaction = true);
|
||||
/// 修改实体集合
|
||||
Task<bool> EditEntityList(List<SerialNumbers> entitys, bool isTransaction = true);
|
||||
/// 查询实体集合
|
||||
Task<List<SerialNumbers>> GetEntityList(List<string> serialNumbers);
|
||||
/// 查询实体集合
|
||||
Task<List<SerialNumbers>> GetEntityListContainNumber(List<string> serialNumbers);
|
||||
/// 根据箱Id查询序列码
|
||||
Task<List<SerialNumbers>> GetEntityListByBoxIds(List<int> boxIds);
|
||||
/// 根据生成记录id查询序列码
|
||||
Task<List<SerialNumbers>> GetEntityListBySuitNumber(string suitNumber);
|
||||
/// 根据套装码查询序列码
|
||||
Task<List<SerialNumbers>> GetEntityListByGRIds(List<int> gRIds);
|
||||
/// 根据生成记录id查询序列码
|
||||
Task<List<SerialNumbers>> GetEntityListByGRId(int gRId);
|
||||
/// 根据箱号查询序列码
|
||||
Task<(List<SerialNumbersResponse> list, int total)> GetEntityListByBoxId(SerialNumberByBoxIdQueryRequest dto);
|
||||
/// 查询实体
|
||||
Task<SerialNumbersResponse?> GetEntity(string serialNumber, string orgCode, LoginInDto loginInfo);
|
||||
/// 查询实体
|
||||
Task<List<SerialNumbersResponse>> GetEntityList(string serialNumber, string orgCode, LoginInDto loginInfo);
|
||||
/// WMS查询实体
|
||||
Task<SerialNumbers> GetEntityWms(string serialNumbers);
|
||||
/// <summary>
|
||||
/// 根据序列号搜索信息
|
||||
/// </summary>
|
||||
/// <param name="serialNumber"></param>
|
||||
/// <returns></returns>
|
||||
Task<SerialNumbersExternalResponse> GetExternal(string serialNumber);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Infrastructure
|
||||
{
|
||||
public interface ITransactionRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取事务 用来处理即时库存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IDbContextTransaction GetTransaction();
|
||||
|
||||
/// <summary>
|
||||
/// 获取事务 用来处理即时库存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool CommitTransaction(bool isRollback, IDbContextTransaction transaction);
|
||||
}
|
||||
}
|
||||
74
src/BarCode.Web.Domain/Mappers/AppMapper.cs
Normal file
74
src/BarCode.Web.Domain/Mappers/AppMapper.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using AutoMapper;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.Login.Temp;
|
||||
using BarCode.Web.Core.Dto.Login.Temp.v3;
|
||||
using BarCode.Web.Core.Help;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
|
||||
namespace BarCode.Web.Domain.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// mapper映射
|
||||
/// </summary>
|
||||
public class AppMapper : Profile
|
||||
{
|
||||
public AppMapper()
|
||||
{
|
||||
//pc端登录的相关dto
|
||||
CreateMap<LoginJsonTokenTempDto, UserInfoDto>()
|
||||
.ForMember(x => x.Email, ops => ops.MapFrom(x => x.email))
|
||||
.ForMember(x => x.Avatar, ops => ops.MapFrom(x => x.avatar))
|
||||
.ForMember(x => x.RoleId, ops => ops.MapFrom(x => x.role_id))
|
||||
.ForMember(x => x.CreatedAt, ops => ops.MapFrom(x => x.created_at))
|
||||
.ForMember(x => x.SigninAt, ops => ops.MapFrom(x => x.signin_at))
|
||||
.ForMember(x => x.UpdatedAt, ops => ops.MapFrom(x => x.updated_at))
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<LoginJsonDeptTempDto, DeptInfoDto>()
|
||||
.ForMember(x => x.Id, ops => ops.MapFrom(x => x.id))
|
||||
.ForMember(x => x.DeptCode, ops => ops.MapFrom(x => x.dept_code))
|
||||
.ForMember(x => x.DeptName, ops => ops.MapFrom(x => x.dept_name))
|
||||
.ForMember(x => x.ManagerId, ops => ops.MapFrom(x => x.manager)).ReverseMap();
|
||||
|
||||
//app端和小程序端登录的相关dto
|
||||
|
||||
|
||||
CreateMap<LoginJsonDeptV3TempDto, TagInfoDto>()
|
||||
.ForMember(x => x.Id, ops => ops.MapFrom(x => x.dept_id))
|
||||
.ForMember(x => x.Name, ops => ops.MapFrom(x => x.dept_name))
|
||||
.ForMember(x => x.Code, ops => ops.MapFrom(x => x.dept_code)).ReverseMap();
|
||||
CreateMap<LoginJsonCompanyTempDto, TagInfoDto>()
|
||||
.ForMember(x => x.Id, ops => ops.MapFrom(x => x.company_id))
|
||||
.ForMember(x => x.Name, ops => ops.MapFrom(x => x.company_name))
|
||||
.ForMember(x => x.Code, ops => ops.MapFrom(x => x.company_code)).ReverseMap();
|
||||
CreateMap<LoginJsonRoleTempDto, TagInfoDto>()
|
||||
.ForMember(x => x.Id, ops => ops.MapFrom(x => x.role_id))
|
||||
.ForMember(x => x.Name, ops => ops.MapFrom(x => x.role_name))
|
||||
.ForMember(x => x.Code, ops => ops.MapFrom(x => x.role_code)).ReverseMap();
|
||||
|
||||
CreateMap<LoginJsonTokenV3TempDto, UserInfoV3Dto>()
|
||||
.ForMember(x => x.Id, ops => ops.MapFrom(x => x.id))
|
||||
.ForMember(x => x.DingtalkUid, ops => ops.MapFrom(x => x.dingtalk_uid))
|
||||
.ForMember(x => x.DingtalkUnionid, ops => ops.MapFrom(x => x.dingtalk_unionid))
|
||||
.ForMember(x => x.Nickname, ops => ops.MapFrom(x => x.nickname))
|
||||
.ForMember(x => x.Realname, ops => ops.MapFrom(x => x.realname))
|
||||
.ForMember(x => x.Mobile, ops => ops.MapFrom(x => x.mobile))
|
||||
.ForMember(x => x.Identity, ops => ops.MapFrom(x => x.identity))
|
||||
.ForMember(x => x.Company, ops => ops.MapFrom(x => x.company))
|
||||
.ForMember(x => x.Orgs, opt => opt.Ignore())
|
||||
.ForMember(x => x.Depts, opt => opt.Ignore())
|
||||
.ForMember(x => x.Roles, opt => opt.Ignore()).ReverseMap();
|
||||
|
||||
|
||||
CreateMap<FileDownManager, FileDownInfoManagerResponse>()
|
||||
.ForMember(x => x.Date, ops => ops.MapFrom(x => x.Date.DateToStringSeconds()))
|
||||
//.ForMember(x => x.StatusKey, ops => ops.MapFrom(x => (int)x.Status))
|
||||
// .ForMember(x => x.Status, ops => ops.MapFrom(x => x.Status.GetRemark()))
|
||||
.ForMember(x => x.Type, ops => ops.MapFrom(x => (int)x.Type));
|
||||
}
|
||||
}
|
||||
}
|
||||
36
src/BarCode.Web.Domain/Mappers/BoxMapper.cs
Normal file
36
src/BarCode.Web.Domain/Mappers/BoxMapper.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using AutoMapper;
|
||||
using BarCode.Web.Core;
|
||||
using BarCode.Web.Core.Dto.Box;
|
||||
using BarCode.Web.Core.Help;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱mapper映射
|
||||
/// </summary>
|
||||
public class BoxMapper: Profile
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱mapper映射
|
||||
/// </summary>
|
||||
public BoxMapper()
|
||||
{
|
||||
CreateMap<Box, Box>().ReverseMap();
|
||||
CreateMap<BoxDetails, BoxDetails>().ReverseMap();
|
||||
|
||||
CreateMap<Box, BoxResponse>()
|
||||
.ForMember(x => x.Status, ops => ops.MapFrom(x => x.Status.GetRemark()))
|
||||
.ForMember(x => x.CreateTime, ops => ops.MapFrom(x => x.CreateTime.DateToStringSeconds()))
|
||||
.ForMember(x => x.PrintTime, ops => ops.MapFrom(x => x.PrintTime.DateToStringSeconds()))
|
||||
.ForMember(x => x.CartonEndTime, ops => ops.MapFrom(x => x.CartonEndTime.DateToStringSeconds()))
|
||||
.ForMember(x => x.CartonBeginTime, ops => ops.MapFrom(x => x.CartonBeginTime.DateToStringSeconds()));
|
||||
CreateMap<BoxDetails, BoxDetailsResponse>();
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/BarCode.Web.Domain/Mappers/BoxMarkMapper.cs
Normal file
20
src/BarCode.Web.Domain/Mappers/BoxMarkMapper.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
|
||||
namespace BarCode.Web.Domain.Mappers
|
||||
{
|
||||
public class BoxMarkMapper : Profile
|
||||
{
|
||||
public BoxMarkMapper()
|
||||
{
|
||||
CreateMap<GenerateBoxMarkDto, BoxMark>();
|
||||
|
||||
CreateMap<BoxMark, BoxMark>()
|
||||
.ForMember(x => x.BillNos, opt => opt.Ignore());
|
||||
}
|
||||
}
|
||||
}
|
||||
98
src/BarCode.Web.Domain/Mappers/MapperList.cs
Normal file
98
src/BarCode.Web.Domain/Mappers/MapperList.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
/// 集合映射
|
||||
/// </summary>
|
||||
public static class MapperList
|
||||
{
|
||||
/// <summary>
|
||||
/// 映射实体里 集合属性
|
||||
/// </summary>
|
||||
/// <typeparam name="ST"></typeparam>
|
||||
/// <typeparam name="DT"></typeparam>
|
||||
/// <param name="mapper"></param>
|
||||
/// <param name="sourcList"></param>
|
||||
/// <param name="destinationList"></param>
|
||||
/// <returns></returns>
|
||||
public static List<DT> ToMapList<DT, ST>(this IMapper mapper, List<ST> sourcList, List<DT> destinationList)
|
||||
where ST : EntityBase
|
||||
where DT : EntityBase
|
||||
{
|
||||
for (int i = 0; i < destinationList.Count; i++)
|
||||
{
|
||||
int id = destinationList[i].Id;
|
||||
var detail = sourcList.FirstOrDefault(f => f.Id == id);
|
||||
if (detail == null)
|
||||
{
|
||||
destinationList.Remove(destinationList[i]);
|
||||
i--;//在列表移除掉一条数据后 必须把index回拨一位 因为数据在移除一条后会调整下标
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var st in sourcList)
|
||||
{
|
||||
if (st.Id == 0)
|
||||
destinationList.Add(mapper.Map<DT>(st));
|
||||
else
|
||||
{
|
||||
var detail = destinationList.FirstOrDefault(f => f.Id == st.Id);
|
||||
|
||||
if (detail != null)
|
||||
mapper.Map(st, detail);
|
||||
//如果在目标数据里没找到这条id的数据 则不作处理
|
||||
}
|
||||
}
|
||||
|
||||
return destinationList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 映射实体里 集合属性
|
||||
/// </summary>
|
||||
/// <typeparam name="ST"></typeparam>
|
||||
/// <typeparam name="DT"></typeparam>
|
||||
/// <param name="mapper"></param>
|
||||
/// <param name="sourcList"></param>
|
||||
/// <param name="destinationList"></param>
|
||||
/// <returns></returns>
|
||||
public static List<DT> ToMapLongList<DT, ST>(this IMapper mapper, List<ST> sourcList, List<DT> destinationList)
|
||||
where ST : EntityLongBase
|
||||
where DT : EntityLongBase
|
||||
{
|
||||
for (int i = 0; i < destinationList.Count; i++)
|
||||
{
|
||||
long id = destinationList[i].Id;
|
||||
var detail = sourcList.FirstOrDefault(f => f.Id == id);
|
||||
if (detail == null)
|
||||
{
|
||||
destinationList.Remove(destinationList[i]);
|
||||
i--;//在列表移除掉一条数据后 必须把index回拨一位 因为数据在移除一条后会调整下标
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var st in sourcList)
|
||||
{
|
||||
if (st.Id == 0)
|
||||
destinationList.Add(mapper.Map<DT>(st));
|
||||
else
|
||||
{
|
||||
var detail = destinationList.FirstOrDefault(f => f.Id == st.Id);
|
||||
|
||||
if (detail != null)
|
||||
mapper.Map(st, detail);
|
||||
//如果在目标数据里没找到这条id的数据 则不作处理
|
||||
}
|
||||
}
|
||||
|
||||
return destinationList;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
src/BarCode.Web.Domain/Mappers/MaterialMapper.cs
Normal file
21
src/BarCode.Web.Domain/Mappers/MaterialMapper.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
|
||||
namespace BarCode.Web.Domain.Mappers
|
||||
{
|
||||
public class MaterialMapper : Profile
|
||||
{
|
||||
public MaterialMapper()
|
||||
{
|
||||
CreateMap<ErpMaterialDto, Materials>()
|
||||
.ForMember(x => x.IdConvertBar, ops => ops.MapFrom(x => x.IdConvertBar.Trim()))
|
||||
.ReverseMap();
|
||||
|
||||
CreateMap<Materials, Materials>();
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/BarCode.Web.Domain/Mappers/SecurityNumberMapper.cs
Normal file
20
src/BarCode.Web.Domain/Mappers/SecurityNumberMapper.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Mappers
|
||||
{
|
||||
public class SecurityNumberMapper: Profile
|
||||
{
|
||||
public SecurityNumberMapper()
|
||||
{
|
||||
CreateMap<SecurityNumbers, SecurityNumbers>().ReverseMap();
|
||||
|
||||
CreateMap<SecurityNumberGenerateRecord, SecurityNumberGenerateRecord>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
src/BarCode.Web.Domain/Mappers/SerialNumberMapper.cs
Normal file
21
src/BarCode.Web.Domain/Mappers/SerialNumberMapper.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using AutoMapper;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Mappers
|
||||
{
|
||||
public class SerialNumberMapper : Profile
|
||||
{
|
||||
public SerialNumberMapper()
|
||||
{
|
||||
CreateMap<SerialNumbers, SerialNumbers>().ReverseMap();
|
||||
|
||||
CreateMap<SerialNumberGenerateRecord, SerialNumberGenerateRecord>().ReverseMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
44
src/BarCode.Web.Domain/Options/AppOptions.cs
Normal file
44
src/BarCode.Web.Domain/Options/AppOptions.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Options
|
||||
{
|
||||
public class AppOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库
|
||||
/// </summary>
|
||||
public string DBConnectionString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// redis
|
||||
/// </summary>
|
||||
public string RedisConnectionString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单点数据请求地址-后端使用接口地址
|
||||
/// </summary>
|
||||
public string SingleBaseUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// redis数据目录
|
||||
/// </summary>
|
||||
public string RedisDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据库类型
|
||||
/// </summary>
|
||||
public string DBType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否允许缓存
|
||||
/// </summary>
|
||||
public bool AllowCache { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 公司ID
|
||||
/// </summary>
|
||||
public int CompanyId { get; set; }
|
||||
}
|
||||
}
|
||||
42
src/BarCode.Web.Domain/Options/EmailOptions.cs
Normal file
42
src/BarCode.Web.Domain/Options/EmailOptions.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Options
|
||||
{
|
||||
/// <summary>
|
||||
/// 邮箱
|
||||
/// </summary>
|
||||
public class EmailOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// SMTP 服务器地址
|
||||
/// </summary>
|
||||
public string SmtpServer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SMTP 服务器端口号
|
||||
/// </summary>
|
||||
public int SmtpPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string SenderName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主题
|
||||
/// </summary>
|
||||
public string SendTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发件人邮箱地址
|
||||
/// </summary>
|
||||
public string SenderEmail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发件人邮箱密码
|
||||
/// </summary>
|
||||
public string SenderEmailPwd { get; set; }
|
||||
}
|
||||
}
|
||||
39
src/BarCode.Web.Domain/Options/ErpOptions.cs
Normal file
39
src/BarCode.Web.Domain/Options/ErpOptions.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Options
|
||||
{
|
||||
/// <summary>
|
||||
/// erp相关配置文件
|
||||
/// </summary>
|
||||
public class ErpOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// erp-请求地址
|
||||
/// </summary>
|
||||
public string EndpointAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 账号
|
||||
/// </summary>
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// erp-Id
|
||||
/// </summary>
|
||||
public string ErpId { get; set; }
|
||||
public readonly string cache_materail_all_key = "erp_materials_list_all";
|
||||
public readonly string cache_materail_key = "erp_materials_list";
|
||||
public readonly string cache_org_key = "erp_org_list";
|
||||
public readonly string cache_supplier_key = "erp_supplier_list";
|
||||
public readonly string cache_customer_key = "erp_customer_list";
|
||||
public readonly string cache_stock_key = "erp_stock_list";
|
||||
public readonly string cache_substock_key = "erp_substock_list";
|
||||
}
|
||||
}
|
||||
31
src/BarCode.Web.Domain/Options/QiniuOptions.cs
Normal file
31
src/BarCode.Web.Domain/Options/QiniuOptions.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Options
|
||||
{
|
||||
/// <summary>
|
||||
/// 七牛云 配置
|
||||
/// </summary>
|
||||
public class QiniuOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 访问key
|
||||
/// </summary>
|
||||
public string AccessKey { get; set; }
|
||||
/// <summary>
|
||||
/// 秘钥
|
||||
/// </summary>
|
||||
public string SecretKey { get; set; }
|
||||
/// <summary>
|
||||
/// 区块文件夹
|
||||
/// </summary>
|
||||
public string Bucket { get; set; }
|
||||
/// <summary>
|
||||
/// 访问域名
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
//导出数据一页条数
|
||||
public int PageSize { get; set; } = 50000;
|
||||
}
|
||||
}
|
||||
155
src/BarCode.Web.Domain/Options/QuartzJobOptions.cs
Normal file
155
src/BarCode.Web.Domain/Options/QuartzJobOptions.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Options
|
||||
{
|
||||
/// <summary>
|
||||
/// Quartz定时任务-配置项
|
||||
/// </summary>
|
||||
public class QuartzJobOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 存储类型:键
|
||||
/// </summary>
|
||||
public string JobStoreTypeKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 存储类型:值
|
||||
/// </summary>
|
||||
public string JobStoreTypeValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据库驱动类型-这里是mysql:键
|
||||
/// </summary>
|
||||
public string JobStoreDriverDelegateTypeKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据库驱动类型-这里是mysql:值
|
||||
/// </summary>
|
||||
public string JobStoreDriverDelegateTypeValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据库表名前缀:键
|
||||
/// </summary>
|
||||
public string JobStoreTablePrefixKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据库表名前缀:值
|
||||
/// </summary>
|
||||
public string JobStoreTablePrefixValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据源的名称:键
|
||||
/// </summary>
|
||||
public string JobStoreDataSourceKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据源的名称:值
|
||||
/// </summary>
|
||||
public string JobStoreDataSourceValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 连接字符串:键
|
||||
/// </summary>
|
||||
public string JobStoreConnectionStringKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 连接字符串:值
|
||||
/// </summary>
|
||||
public string JobStoreConnectionStringValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// mysql提供器:键
|
||||
/// </summary>
|
||||
public string JobStoreProviderKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// mysql提供器:值
|
||||
/// </summary>
|
||||
public string JobStoreProviderValue { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 几点后开始执行
|
||||
/// </summary>
|
||||
public List<int> JobStartHour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 几分钟后开始执行
|
||||
/// </summary>
|
||||
public List<int> JobStartMinute { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行Cron表达式:可以是几小时or几分钟or几秒钟or几天or几周
|
||||
/// </summary>
|
||||
public string JobStartExpre { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string JobStartExpreAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发送通知执行cron表达式:每天12,16,20整点发送
|
||||
/// </summary>
|
||||
public string JobStartExpreSend { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 同步新物料执行cron表达式:每天23:30整点同步
|
||||
/// </summary>
|
||||
public string JobStartExpreMaterial { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 同步新物料执行cron表达式:每天0:01执行
|
||||
/// </summary>
|
||||
public string JobStartExpreCenerateData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用集群:键
|
||||
/// </summary>
|
||||
public string JobStoreClusteredKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用集群:值
|
||||
/// </summary>
|
||||
public string JobStoreClusteredValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点都必须有一个唯一ID:键
|
||||
/// </summary>
|
||||
public string JobStoreInstanceIdKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点都必须有一个唯一ID:值
|
||||
/// </summary>
|
||||
public string JobStoreInstanceIdValue { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工作名称:键
|
||||
/// </summary>
|
||||
public string QuartzJobKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工作名称:值
|
||||
/// </summary>
|
||||
public string QuartzJobValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工作描述
|
||||
/// </summary>
|
||||
public string QuartzJobDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 触发器身份认证信息
|
||||
/// </summary>
|
||||
public string QuartzTriggerIdentity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 触发器描述
|
||||
/// </summary>
|
||||
public string QuartzTriggerDescription { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
32
src/BarCode.Web.Domain/Options/SmsOptions.cs
Normal file
32
src/BarCode.Web.Domain/Options/SmsOptions.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Options
|
||||
{
|
||||
/// <summary>
|
||||
/// 短信配置项
|
||||
/// </summary>
|
||||
public class SmsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 访问凭证ID
|
||||
/// </summary>
|
||||
public string AccessKeyId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问秘钥
|
||||
/// </summary>
|
||||
public string AccessKeySecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 短信签名
|
||||
/// </summary>
|
||||
public string SignName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 短信模板编号
|
||||
/// </summary>
|
||||
public string TemplateCode { get; set; }
|
||||
}
|
||||
}
|
||||
47
src/BarCode.Web.Domain/Options/SoaOptions.cs
Normal file
47
src/BarCode.Web.Domain/Options/SoaOptions.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Options
|
||||
{
|
||||
public class SoaOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 单点系统地址
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单点系统地址
|
||||
/// </summary>
|
||||
public string Url_V3 { get; set; }
|
||||
/// <summary>
|
||||
/// admin账号的Id
|
||||
/// </summary>
|
||||
public List<int> AdminUser { get; set; } = new List<int>();
|
||||
/// <summary>
|
||||
/// 应用id
|
||||
/// </summary>
|
||||
public int ModuleID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// AppId
|
||||
/// </summary>
|
||||
public string AppId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// AppSecret
|
||||
/// </summary>
|
||||
public string AppSecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 公钥
|
||||
/// </summary>
|
||||
public string PublicKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 私钥
|
||||
/// </summary>
|
||||
public string PrivateKey { get; set; }
|
||||
}
|
||||
}
|
||||
14
src/BarCode.Web.Domain/Options/WmsOptions.cs
Normal file
14
src/BarCode.Web.Domain/Options/WmsOptions.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Options
|
||||
{
|
||||
/// <summary>
|
||||
/// 老ops对接
|
||||
/// </summary>
|
||||
public class WmsOptions
|
||||
{
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
||||
48
src/BarCode.Web.Domain/QuartzJob/CenerateDataQuartzJob.cs
Normal file
48
src/BarCode.Web.Domain/QuartzJob/CenerateDataQuartzJob.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using BarCode.Web.Domain.Infrastructure;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.QuartzJob
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动生成数据维护 凌晨清空
|
||||
/// </summary>
|
||||
public class CenerateDataQuartzJob : IJob
|
||||
{
|
||||
private readonly ILogger<MaterialsQuartzJob> _logger;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly ICenerateDataRepositories _cenerateDataRepositories;
|
||||
|
||||
public CenerateDataQuartzJob(ILogger<MaterialsQuartzJob> logger,
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
IMaterialService materialService,
|
||||
ICenerateDataRepositories cenerateDataRepositories)
|
||||
{
|
||||
this._logger = logger;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_cenerateDataRepositories = cenerateDataRepositories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行方法
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
_logger.LogInformation("定时维护自动生成数据");
|
||||
//每天凌晨对数据进行清空
|
||||
var entity = await _cenerateDataRepositories.Get(CenerateDataType.Serial);
|
||||
entity.Number = 1;
|
||||
await _cenerateDataRepositories.Edit(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/BarCode.Web.Domain/QuartzJob/MaterialsBarQuartzJob.cs
Normal file
39
src/BarCode.Web.Domain/QuartzJob/MaterialsBarQuartzJob.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using BarCode.Web.Domain.IService;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.QuartzJob
|
||||
{
|
||||
public class MaterialsBarQuartzJob:IJob
|
||||
{
|
||||
private readonly ILogger<MaterialsBarQuartzJob> _logger;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly IMaterialService _materialService;
|
||||
|
||||
public MaterialsBarQuartzJob(ILogger<MaterialsBarQuartzJob> logger,
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
IMaterialService materialService)
|
||||
{
|
||||
this._logger = logger;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_materialService = materialService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行方法
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
_logger.LogInformation("定时维护物料id32进制");
|
||||
await _materialService.SyncBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
42
src/BarCode.Web.Domain/QuartzJob/MaterialsQuartzJob.cs
Normal file
42
src/BarCode.Web.Domain/QuartzJob/MaterialsQuartzJob.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using Quartz.Logging;
|
||||
|
||||
namespace BarCode.Web.Domain.QuartzJob
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料同步执行定时任务
|
||||
/// </summary>
|
||||
public class MaterialsQuartzJob : IJob
|
||||
{
|
||||
private readonly ILogger<MaterialsQuartzJob> _logger;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly IMaterialService _materialService;
|
||||
|
||||
public MaterialsQuartzJob(ILogger<MaterialsQuartzJob> logger,
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
IMaterialService materialService)
|
||||
{
|
||||
this._logger = logger;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_materialService = materialService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行方法
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
_logger.LogInformation("定时维护物料数据");
|
||||
await _materialService.SyncNewMaterials();
|
||||
}
|
||||
}
|
||||
}
|
||||
131
src/BarCode.Web.Domain/Services/BoxMarkService.cs
Normal file
131
src/BarCode.Web.Domain/Services/BoxMarkService.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using BarCode.Web.Domain.Infrastructure;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Values;
|
||||
|
||||
namespace BarCode.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱唛-服务
|
||||
/// </summary>
|
||||
public class BoxMarkService : IBoxMarkService
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
public readonly IBasicsRepositories _transactionRepositories;
|
||||
private readonly IBoxMarkRepositories _boxMarkRepositories;
|
||||
private readonly ILogger<BoxMarkService> _logger;
|
||||
public BoxMarkService(IMapper mapper, ILogger<BoxMarkService> logger,
|
||||
IBasicsRepositories transactionRepositories,
|
||||
IBoxMarkRepositories boxMarkRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_logger = logger;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_boxMarkRepositories = boxMarkRepositories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResultList<BoxMarkQueryResponse>> Generate(GenerateBoxMarkDto dto, LoginInDto loginInfo)
|
||||
{
|
||||
_logger.LogInformation($"箱唛生成:{JsonConvert.SerializeObject(dto)} 操作人:{loginInfo.UserInfo.UcId + loginInfo.UserInfo.Nickname}");
|
||||
string supplierCode = "";
|
||||
string orgCode = "";
|
||||
if (dto.OrgCode.Substring(0, 1).Equals("s"))
|
||||
supplierCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2);
|
||||
else
|
||||
orgCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2);
|
||||
//1.获取最新的箱唛信息
|
||||
var billNo_new = await _boxMarkRepositories.GetLastBillNo();
|
||||
|
||||
//2.dto映射实体
|
||||
var entity = new BoxMark();
|
||||
entity= _mapper.Map(dto, entity);
|
||||
entity.Create(loginInfo.UserInfo.UcId);
|
||||
entity.SupplierCode = supplierCode;
|
||||
entity.OrgCode = orgCode;
|
||||
int new_firstBillNo = billNo_new == null ? 0 : billNo_new.FirstBillNo;
|
||||
int new_lastBillNo = billNo_new == null ? 0 : billNo_new.LastBillNo;
|
||||
entity.GenerateBillNo(new_firstBillNo, new_lastBillNo);
|
||||
|
||||
//添加
|
||||
var model = await _boxMarkRepositories.Add(entity);
|
||||
if (model==null)
|
||||
return ResultList<BoxMarkQueryResponse>.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
//返回列表-对应刚刚生成的数据和编号集合
|
||||
var list= await _boxMarkRepositories.GetListInfoBy(model.Id, loginInfo.UserInfo.CompanyId);
|
||||
|
||||
if (list != null && list.Count != 0)
|
||||
{
|
||||
//处理-总数量
|
||||
list.ForEach(x =>
|
||||
{
|
||||
x.BoxSortCount = this.GetSortCount(x.ProductQty, x.CratingQty);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return ResultList<BoxMarkQueryResponse>.ReSuccess(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表分页
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<(List<BoxMarkQueryResponse> list, int total)> GetPagedList(BoxMarkQueryRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
var (list, count) = await _boxMarkRepositories.GetPagedList(dto, loginInfo);
|
||||
|
||||
if (list != null && list.Count != 0)
|
||||
{
|
||||
list.ForEach(x =>
|
||||
{
|
||||
x.BoxSortCount = this.GetSortCount(x.ProductQty, x.CratingQty);
|
||||
});
|
||||
}
|
||||
|
||||
return (list, count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 装箱总数
|
||||
/// </summary>
|
||||
/// <param name="productQty"></param>
|
||||
/// <param name="cratingQty"></param>
|
||||
/// <returns></returns>
|
||||
private int GetSortCount(decimal productQty, decimal cratingQty)
|
||||
{
|
||||
//计算要装的箱数量
|
||||
var boxCount_tag = productQty / cratingQty;
|
||||
var boxCount = Convert.ToInt32(boxCount_tag);
|
||||
//判断是否存在小数点;true表明有尾箱数,false没有尾箱数
|
||||
var hasPart = Math.Floor(boxCount_tag) != boxCount_tag;
|
||||
|
||||
//有小数点向上取整
|
||||
if (hasPart)
|
||||
boxCount = Convert.ToInt32(Math.Ceiling(boxCount_tag));
|
||||
return boxCount;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
459
src/BarCode.Web.Domain/Services/BoxService.cs
Normal file
459
src/BarCode.Web.Domain/Services/BoxService.cs
Normal file
@@ -0,0 +1,459 @@
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Box;
|
||||
using BarCode.Web.Core.Dto.Erp.Org;
|
||||
using BarCode.Web.Core.Dto.Erp.Supplier;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SingleData;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using BarCode.Web.Domain.Infrastructure;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Services.Public;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using BarCode.Web.Domain.Values.Single;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npoi.Mapper;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱信息
|
||||
/// </summary>
|
||||
public class BoxService : IBoxService
|
||||
{
|
||||
private readonly ILogger<BoxService> _logger;
|
||||
private IBasicsRepositories _transactionRepositories;
|
||||
private readonly IBoxRepositories _boxRepositories;
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly ISerialNumbersRepositories _serialNumbersRepositories;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly IWmsService _wmsService;
|
||||
private readonly ISerialNumberService _serialNumberService;
|
||||
public BoxService(ILogger<BoxService> logger, IBasicsRepositories transactionRepositories,
|
||||
IBoxRepositories boxRepositories, ISingleDataService singleDataService, ISerialNumbersRepositories serialNumbersRepositories,
|
||||
IErpService erpService, IWmsService wmsService, ISerialNumberService serialNumberService)
|
||||
{
|
||||
_logger = logger;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_boxRepositories = boxRepositories;
|
||||
_singleDataService = singleDataService;
|
||||
_serialNumbersRepositories = serialNumbersRepositories;
|
||||
_erpService = erpService;
|
||||
_wmsService = wmsService;
|
||||
_serialNumberService = serialNumberService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成箱码
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> Generate(GenerateBoxRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
_logger.LogInformation($"生成箱码:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}");
|
||||
string supplierCode = "";
|
||||
string orgCode = "";
|
||||
if (dto.OrgCode.Substring(0, 1).Equals("s"))
|
||||
supplierCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2);
|
||||
else
|
||||
orgCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2);
|
||||
|
||||
List<Box> boxs = new List<Box>();
|
||||
for (int i = 1; i <= dto.Number; i++)
|
||||
{
|
||||
Box b = new Box()
|
||||
{
|
||||
CreatorId = loginInfo.UserInfo.UcId,
|
||||
OrgCode = orgCode,
|
||||
SupplierCode = supplierCode,
|
||||
CompanyId = loginInfo.UserInfo.CompanyId
|
||||
};
|
||||
boxs.Add(b);
|
||||
}
|
||||
var res = await _boxRepositories.AddRange(boxs);
|
||||
if (!res) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 装箱
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> Save(SaveBoxRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
_logger.LogInformation($"装箱:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}");
|
||||
var box = await _boxRepositories.Get(dto.BoxId);
|
||||
if (box == null)
|
||||
return Result.ReFailure(ResultCodes.NoDateError);
|
||||
if (box.Status == BoxStatus.Complete)
|
||||
return Result.ReFailure(ResultCodes.CartonCompleteError);
|
||||
//去重
|
||||
dto.Details = dto.Details.Distinct().ToList();
|
||||
var sAll = dto.Details.Select(s => s.SerialNumber).ToList();
|
||||
var serialNumberList = await _serialNumbersRepositories.GetEntityListContainNumber(sAll);
|
||||
List<SerialNumbers> serialList;
|
||||
if (serialNumberList.Count() != sAll.Count())
|
||||
return Result.ReFailure(ResultCodes.SerialNumberNoDateError);
|
||||
if (serialNumberList.Where(w => w.BoxId != 0 || w.IsUse == true).Any())
|
||||
return Result.ReFailure(ResultCodes.SerialNumberBindBox);
|
||||
//新的序列号以存在于箱中
|
||||
var bs = box.Details.SelectMany(s => s.SerialNumbers).ToList();
|
||||
var jj = sAll.Intersect(bs);
|
||||
if (jj.Count() > 0)
|
||||
return Result.ReFailure(ResultCodes.SerialNumberBindBox);
|
||||
//装箱状态
|
||||
var resCarton = box.Carton(dto.IsCarton, loginInfo.UserInfo.UcId);
|
||||
if (!resCarton.IsSuccess) return resCarton;
|
||||
|
||||
var materialNumbers = dto.Details.GroupBy(g => g.MaterialNumber).Select(s => s.Key).ToList();
|
||||
foreach (var m in materialNumbers)
|
||||
{
|
||||
var detail = box.Details.FirstOrDefault(f => f.MaterialNumber.Equals(m));
|
||||
var serialNumbers = dto.Details.Where(w => w.MaterialNumber.Equals(m)).Select(s => s.SerialNumber).ToList();
|
||||
if (detail == null)
|
||||
{
|
||||
detail = new BoxDetails()
|
||||
{
|
||||
MaterialNumber = m,
|
||||
Qty = serialNumbers.Count(),
|
||||
SerialNumbers = serialNumbers
|
||||
};
|
||||
box.Details.Add(detail);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail.Qty += serialNumbers.Count();
|
||||
detail.SerialNumbers.AddRange(serialNumbers);
|
||||
}
|
||||
}
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool res_Rollback = false;
|
||||
bool isSuccess = true;
|
||||
//装箱
|
||||
foreach (var d in dto.Details.Select(s => s.SerialNumber).Reverse())
|
||||
{
|
||||
////原来的
|
||||
//var serial = serialNumberList.FirstOrDefault(f => f.SerialNumber.Equals(d)
|
||||
//|| f.NumberCode.Equals(d));
|
||||
//if (serial == null) return Result.ReFailure(ResultCodes.SerialNumberNoDateError);
|
||||
//serial.CompleteBox(box.Id, d);
|
||||
////原来的到此
|
||||
|
||||
|
||||
serialList = await _serialNumbersRepositories.GetEntityListBySuitNumber(d);
|
||||
|
||||
|
||||
if (serialList == null) return Result.ReFailure(ResultCodes.SerialNumberNoDateError);
|
||||
if (serialList.Count == 0) return Result.ReFailure(ResultCodes.SerialNumberNoDateError);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < serialList.Count; i++)
|
||||
{
|
||||
if(serialList[i].SerialNumber.ToString() == d)
|
||||
{
|
||||
serialList[i].CompleteBox(box.Id, d);
|
||||
}
|
||||
else
|
||||
{
|
||||
serialList[i].CompleteBox(0, d);
|
||||
}
|
||||
|
||||
}
|
||||
if (!res_Rollback)
|
||||
{
|
||||
isSuccess = await _serialNumbersRepositories.EditEntityList(serialList, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
var res = await _boxRepositories.Edit(box, false);
|
||||
if (res == null) res_Rollback = true;
|
||||
//if (!res_Rollback)
|
||||
//{
|
||||
// isSuccess = await _serialNumbersRepositories.EditEntityList(serialNumberList, false);
|
||||
// if (!isSuccess) res_Rollback = true;
|
||||
//}
|
||||
|
||||
|
||||
if (!res_Rollback)
|
||||
{
|
||||
var ids = serialNumberList.Select(s => s.GenerateRecordId).ToList();
|
||||
var resUse = await _serialNumberService.Use(ids);
|
||||
if (!resUse.IsSuccess) res_Rollback = true;
|
||||
}
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
|
||||
if (res_Rollback || !isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> Print(OperateRequest dto)
|
||||
{
|
||||
var boxs = await _boxRepositories.GetEntityList(dto.Ids);
|
||||
boxs.ForEach(f => f.Print());
|
||||
var res = await _boxRepositories.EditEntityList(boxs);
|
||||
if (!res) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> Delete(DeleteBoxSerialNumberRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
_logger.LogInformation($"删除箱物料:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}");
|
||||
var box = await _boxRepositories.Get(dto.BoxId);
|
||||
if (box == null)
|
||||
return Result.ReFailure(ResultCodes.BoxNoDataError);
|
||||
if (box.Status == BoxStatus.Complete)
|
||||
return Result.ReFailure(ResultCodes.CartonCompleteError);
|
||||
|
||||
var sList = await _serialNumbersRepositories.GetEntityList(new List<string>() { dto.SerialNumber });
|
||||
var s = sList.FirstOrDefault(f => f.SerialNumber.Equals(dto.SerialNumber));
|
||||
if (s == null)
|
||||
return Result.ReFailure(ResultCodes.SerialNumberNoDateError);
|
||||
//判断使用的是数字序列码还是序列码
|
||||
var sStr = s.IsUseNumber == true ? s.NumberCode : s.SerialNumber;
|
||||
|
||||
var resUn = box.UnSerialNumber(sStr, dto.MaterialNumber);
|
||||
if (!resUn.IsSuccess) return resUn;
|
||||
|
||||
//var sList = await _serialNumbersRepositories.GetEntityListContainNumber(new List<string>() { dto.SerialNumber });
|
||||
//sList.ForEach(f => f.UnBox());
|
||||
s.UnBox();//解绑
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool res_Rollback = false;
|
||||
bool isSuccess = true;
|
||||
var res = await _boxRepositories.Edit(box, false);
|
||||
if (res == null) res_Rollback = true;
|
||||
if (!res_Rollback)
|
||||
{
|
||||
isSuccess = await _serialNumbersRepositories.EditEntityList(sList, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
}
|
||||
if (!res_Rollback)
|
||||
{
|
||||
var ids = sList.Select(s => s.GenerateRecordId).ToList();
|
||||
var resUse = await _serialNumberService.Use(ids);
|
||||
if (!resUse.IsSuccess) res_Rollback = true;
|
||||
}
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
|
||||
if (res_Rollback || !isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 清空装箱信息
|
||||
/// </summary>
|
||||
/// <param name="boxId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> Clear(int boxId, LoginInDto loginInfo)
|
||||
{
|
||||
_logger.LogInformation($"清空装箱信息:{boxId},用户:{loginInfo.UserInfo.Nickname}");
|
||||
var box = await _boxRepositories.Get(boxId);
|
||||
if (box == null)
|
||||
return Result.ReFailure(ResultCodes.BoxNoDataError);
|
||||
|
||||
var s = box.Details.SelectMany(s => s.SerialNumbers).ToList();
|
||||
box.Details.Clear();
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool res_Rollback = false;
|
||||
bool isSuccess = true;
|
||||
var sList = await _serialNumbersRepositories.GetEntityListByBoxIds(new List<int>() { boxId });
|
||||
foreach (var f in sList)
|
||||
{
|
||||
if( f.IsTwo>1)
|
||||
{
|
||||
//说明是两件装的产品,那么要分别清除
|
||||
var sList2 = await _serialNumbersRepositories.GetEntityListBySuitNumber(f.SerialNumber);
|
||||
for(int i=0;i<sList2.Count;i++)
|
||||
{
|
||||
sList2[i].UnBox();
|
||||
|
||||
if (!res_Rollback)
|
||||
{
|
||||
isSuccess = await _serialNumbersRepositories.EditEntityList(sList2, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
f.UnBox();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// sList.ForEach(f => f.UnBox());
|
||||
|
||||
|
||||
var res = await _boxRepositories.Edit(box, false);
|
||||
if (res == null) res_Rollback = true;
|
||||
if (!res_Rollback)
|
||||
{
|
||||
isSuccess = await _serialNumbersRepositories.EditEntityList(sList, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
}
|
||||
if (!res_Rollback)
|
||||
{
|
||||
var ids = sList.Select(s => s.GenerateRecordId).ToList();
|
||||
var resUse = await _serialNumberService.Use(ids);
|
||||
if (!resUse.IsSuccess) res_Rollback = true;
|
||||
}
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
|
||||
if (res_Rollback || !isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// wms系统调用 获取完成装箱箱信息
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<(List<WmsBoxResponse> list, int total)> GetCartonListAsync(WmsBoxRequest dto)
|
||||
{
|
||||
var org_result = await _erpService.BillQueryForOrg();
|
||||
List<ErpOrgDto> orgs = new List<ErpOrgDto>();
|
||||
if (org_result.IsSuccess)
|
||||
orgs = org_result.Data.ToList();
|
||||
|
||||
var supplier_result = await _erpService.BillQueryForSupplier();
|
||||
List<ErpSupplierDto> suppliers = new List<ErpSupplierDto>();
|
||||
if (supplier_result.IsSuccess)
|
||||
suppliers = supplier_result.Data.ToList();
|
||||
|
||||
var (list, count) = await _boxRepositories.GetEntityByWmsList(dto);
|
||||
var ids = list.Select(s => s.Id).ToList();
|
||||
var serialList = await _serialNumbersRepositories.GetEntityListByBoxIds(ids);
|
||||
List<WmsBoxResponse> response = new List<WmsBoxResponse>();
|
||||
foreach (var box in list)
|
||||
{
|
||||
WmsBoxResponse res = new WmsBoxResponse()
|
||||
{
|
||||
BoxBillNo = box.BoxBillNo,
|
||||
OpsBoxId = box.Id,
|
||||
CompleteCartonTime = box.CartonEndTime ?? DateTime.Now,
|
||||
CompleteCartonUser = _singleDataService.GetSingleData(SingleAction.Users, box.CompanyId, box.CartonUserId),
|
||||
CreateTime = box.CreateTime,
|
||||
OrgId = orgs.FirstOrDefault(f => f.Number.Equals(box.OrgCode))?.Id ?? 0,
|
||||
SupplierId = suppliers.FirstOrDefault(f => f.Number.Equals(box.SupplierCode))?.Id ?? 0,
|
||||
CreateUser = _singleDataService.GetSingleData(SingleAction.Users, box.CompanyId, box.CreatorId),
|
||||
};
|
||||
|
||||
foreach (var bd in box.Details)
|
||||
{
|
||||
//var bdsList = serialList.Where(w => w.BoxId == box.Id && w.MaterialNumber.Equals(bd.MaterialNumber)).ToList();
|
||||
var bdsList = bd.SerialNumbers;
|
||||
List<Core.Dto.Box.OpsSerialNumbersResponse> sList = new List<Core.Dto.Box.OpsSerialNumbersResponse>();
|
||||
foreach (var s in bdsList)
|
||||
{
|
||||
var sentity = serialList.FirstOrDefault(f => f.SerialNumber.Equals(s) || f.NumberCode.Equals(s));
|
||||
sList.Add(new Core.Dto.Box.OpsSerialNumbersResponse()
|
||||
{
|
||||
SerialNumber = s,
|
||||
BarCereateUser = _singleDataService.GetSingleData(SingleAction.Users, box.CompanyId, sentity == null ? 0 : sentity.CreatorId),
|
||||
BarCreateTime = sentity == null ? null : sentity.CreateTime
|
||||
});
|
||||
}
|
||||
Core.Dto.Box.OpsBoxDetailsResponse Detail = new Core.Dto.Box.OpsBoxDetailsResponse()
|
||||
{
|
||||
MaterialNumber = bd.MaterialNumber,
|
||||
Qty = bd.Qty,
|
||||
SerialNumbers = sList
|
||||
};
|
||||
res.Details.Add(Detail);
|
||||
}
|
||||
|
||||
response.Add(res);
|
||||
}
|
||||
return (response, count);
|
||||
}
|
||||
/// <summary>
|
||||
/// 重新装箱
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> Restart(OperateRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
_logger.LogInformation($"重新装箱的箱:{JsonConvert.SerializeObject(dto.Ids)} 操作人:{loginInfo.UserInfo.Nickname}");
|
||||
var boxList = await _boxRepositories.GetEntityList(dto.Ids);
|
||||
if (boxList.Where(w => w.Status != BoxStatus.Complete).Any())
|
||||
return Result.ReFailure(ResultCodes.BoxNoComplete);
|
||||
var nos = boxList.Select(s => s.BoxBillNo).ToList();
|
||||
|
||||
List<string> failBox = new List<string>();
|
||||
var res = await _wmsService.Restart(nos);
|
||||
if (!res.IsSuccess)
|
||||
return res;
|
||||
//已收货的箱返回在数据里带过来
|
||||
failBox = res.Data;
|
||||
//把已收货的箱排除出去 然后重置
|
||||
boxList.Where(w => !failBox.Contains(w.BoxBillNo)).ForEach(f => f.Restart());
|
||||
var isSuccess = await _boxRepositories.EditEntityList(boxList);
|
||||
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
if (failBox.Count() > 0)
|
||||
{
|
||||
return Result.ReFailure($"箱号:{string.Join(",", failBox)} 已收货,不允许重新装箱,请和仓库人员沟通", 3433535);
|
||||
}
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 开始装箱
|
||||
/// </summary>
|
||||
/// <param name="boxId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> BeginCarton(int boxId, LoginInDto loginInfo)
|
||||
{
|
||||
_logger.LogInformation($"开始装箱:{boxId},用户:{loginInfo.UserInfo.Nickname}");
|
||||
var box = await _boxRepositories.Get(boxId);
|
||||
if (box == null)
|
||||
return Result.ReFailure(ResultCodes.BoxNoDataError);
|
||||
if (box.Status == BoxStatus.Complete)
|
||||
return Result.ReFailure(ResultCodes.CartonCompleteError);
|
||||
var res = box.BeginCarton(loginInfo.UserInfo.UcId);
|
||||
if (!res.IsSuccess)
|
||||
return res;
|
||||
var res_box = await _boxRepositories.Edit(box, true);
|
||||
if (res_box == null) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
229
src/BarCode.Web.Domain/Services/ExportExcelService.cs
Normal file
229
src/BarCode.Web.Domain/Services/ExportExcelService.cs
Normal file
@@ -0,0 +1,229 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Npoi.Mapper;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using BarCode.Web.Domain.Options;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using BarCode.Web.Domain.Infrastructure;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
|
||||
namespace BarCode.Web.Domain.Services
|
||||
{
|
||||
public class ExportExcelService : IExportExcelService
|
||||
{
|
||||
private readonly IQiniuUploadService _qiniuUploadService;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly ILogger<ExportExcelService> _logger;
|
||||
private readonly QiniuOptions _option;
|
||||
public ExportExcelService(IQiniuUploadService qiniuUploadService, IServiceScopeFactory serviceScopeFactory,
|
||||
ILogger<ExportExcelService> logger, IOptions<QiniuOptions> option)
|
||||
{
|
||||
_qiniuUploadService = qiniuUploadService;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_logger = logger;
|
||||
_option = option?.Value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 列表页导出
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dataList"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="mapper"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Export<T>(List<T> dataList, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null)
|
||||
{
|
||||
FileDownManager entity = new FileDownManager(userId, loginInfo.UserInfo.CompanyId, type,orgCode, _option.Url + fileName, loginInfo.UserInfo.SupplierCode);
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var _fileDownManagerService = scope.ServiceProvider.GetRequiredService<IFileDownManagerRepositories>();
|
||||
entity = await _fileDownManagerService.Add(entity);
|
||||
List<List<T>> listz = new List<List<T>>();
|
||||
listz.Add(dataList);
|
||||
|
||||
string msg = await Upload(listz, fileName, userId, type);
|
||||
|
||||
entity.Finish(string.IsNullOrEmpty(msg) == true ? true : false, msg);
|
||||
await _fileDownManagerService.Edit(entity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 全字段导出
|
||||
/// </summary>
|
||||
/// <typeparam name="Response"></typeparam>
|
||||
/// <typeparam name="Request"></typeparam>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="mapper"></param>
|
||||
/// <returns></returns>
|
||||
public Task ExportAll<Response, Request>(Request request, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null) where Request : PaginationBaseRequestDto
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
//FileDownManager entity = new FileDownManager(userId, companyId, type, _option.Url + fileName, supplierId);
|
||||
|
||||
//request.PageNo = 1;
|
||||
//request.PageSize = _option.PageSize;
|
||||
//List<List<Response>> listz = new List<List<Response>>();
|
||||
//string msg = "";
|
||||
//using (var scope = _serviceScopeFactory.CreateScope())
|
||||
//{
|
||||
// var _fileDownManagerService = scope.ServiceProvider.GetRequiredService<IFileDownManagerRepositories>();
|
||||
// entity = await _fileDownManagerService.Add(entity);
|
||||
// try
|
||||
// {
|
||||
// var _service = scope.ServiceProvider.GetRequiredService<IAllFielRepositories<Request>>();
|
||||
// _logger.LogInformation($"{DateTime.Now}--开始访问数据");
|
||||
// var (obj, total) = await _service.GetListAllField(request, companyId);
|
||||
// var list = (List<Response>)obj;
|
||||
// var page = Math.Ceiling(Convert.ToDecimal(total) / _option.PageSize);
|
||||
|
||||
// listz.Add(list);
|
||||
// for (int i = 1; i < page; i++)
|
||||
// {
|
||||
// request.PageNo++;
|
||||
// var (obj_f, total_f) = await _service.GetListAllField(request, companyId);
|
||||
// var list_f = (List<Response>)obj_f;
|
||||
// listz.Add(list_f);
|
||||
// }
|
||||
// _logger.LogInformation($"{DateTime.Now}--访问数据成功 总数:{total}");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// msg = $"未找到数据 {ex.ToString()}";
|
||||
// _logger.LogError($"导出异常:{ex.ToString()}");
|
||||
// }
|
||||
|
||||
// if (!string.IsNullOrEmpty(msg))
|
||||
// {
|
||||
// entity.Finish(false, msg);
|
||||
// await _fileDownManagerService.Edit(entity);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// msg = await Upload(listz, fileName, userId, type);
|
||||
|
||||
// entity.Finish(string.IsNullOrEmpty(msg) == true ? true : false, msg);
|
||||
// await _fileDownManagerService.Edit(entity);
|
||||
// return;
|
||||
//}
|
||||
}
|
||||
|
||||
public async Task ExportList<Response, Request>(Request request, string fileName, int userId, LoginInDto loginInfo, FileDownLoadOrderType type, string orgCode, Mapper mapper = null, int? supplierId = null) where Request : PaginationBaseRequestDto
|
||||
{
|
||||
FileDownManager entity = new FileDownManager(userId, loginInfo.UserInfo.CompanyId, type,orgCode, _option.Url + fileName, loginInfo.UserInfo.SupplierCode);
|
||||
|
||||
request.PageNo = 1;
|
||||
request.PageSize = _option.PageSize;
|
||||
List<List<Response>> listz = new List<List<Response>>();
|
||||
string msg = "";
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var _fileDownManagerService = scope.ServiceProvider.GetRequiredService<IFileDownManagerRepositories>();
|
||||
entity = await _fileDownManagerService.Add(entity);
|
||||
try
|
||||
{
|
||||
var _service = scope.ServiceProvider.GetRequiredService<IAllFielRepositories<Request>>();
|
||||
_logger.LogInformation($"{DateTime.Now}--开始访问数据");
|
||||
var (obj, total) = await _service.GetListField(request, loginInfo);
|
||||
var list = (List<Response>)obj;
|
||||
var page = Math.Ceiling(Convert.ToDecimal(total) / _option.PageSize);
|
||||
|
||||
listz.Add(list);
|
||||
for (int i = 1; i < page; i++)
|
||||
{
|
||||
request.PageNo++;
|
||||
var (obj_f, total_f) = await _service.GetListField(request, loginInfo);
|
||||
var list_f = (List<Response>)obj_f;
|
||||
listz.Add(list_f);
|
||||
}
|
||||
_logger.LogInformation($"{DateTime.Now}--访问数据成功 总数:{total}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
msg = "未找到数据";
|
||||
_logger.LogError($"导出数据查询异常 {ex.ToString()}");
|
||||
}
|
||||
|
||||
if (listz.Count <= 0)
|
||||
{
|
||||
entity.Finish(false, msg);
|
||||
await _fileDownManagerService.Edit(entity);
|
||||
return;
|
||||
}
|
||||
|
||||
msg = await Upload(listz, fileName, userId, type);
|
||||
|
||||
entity.Finish(string.IsNullOrEmpty(msg) == true ? true : false, msg);
|
||||
await _fileDownManagerService.Edit(entity);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<string> Upload<T>(List<List<T>> dataList, string fileName, int userId, FileDownLoadOrderType type, Mapper mapper = null)
|
||||
{
|
||||
if (mapper == null)
|
||||
mapper = new Mapper();
|
||||
|
||||
//第一个参数为导出Excel名称
|
||||
//第二个参数为Excel数据来源
|
||||
//第三个参数为导出的Sheet名称
|
||||
//overwrite参数如果是要覆盖已存在的Excel或者新建Excel则为true,如果在原有Excel上追加数据则为false
|
||||
//xlsx参数是用于区分导出的数据格式为xlsx还是xls
|
||||
MemoryStream stream = new MemoryStream();
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
mapper.Put<T>(dataList[i], "sheet" + (i + 1), true);
|
||||
}
|
||||
mapper.Save(stream);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "数据导入Execl异常";
|
||||
}
|
||||
|
||||
|
||||
//mapper.Save(stream, dataList, "sheet1", overwrite: true, xlsx: true);
|
||||
//,但是这里也踩到了一个坑,不过这个是 Npoi 的坑并不是 Npoi.Mapper 的坑,
|
||||
// 那就是 Workbook.Write(stream)的时候会将 stream 关闭,如果继续操作这个 Stream 会报流已关闭的错误
|
||||
//所以这里 是把流先转成byte[] 再转回使用的流
|
||||
try
|
||||
{
|
||||
var middleByte = stream.ToArray();
|
||||
using (MemoryStream streamUpload = new MemoryStream(middleByte))
|
||||
{
|
||||
var res = await _qiniuUploadService.Upload(fileName, streamUpload, true);
|
||||
if (!res.Success)
|
||||
{
|
||||
_logger.LogError($"{DateTime.Now}--上传千牛云失败 原因:{res.Message}");
|
||||
return res.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return "数据上传云端异常";
|
||||
}
|
||||
|
||||
_logger.LogInformation($"{DateTime.Now}--导出成功");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
83
src/BarCode.Web.Domain/Services/Public/ErpBaseDataSync.cs
Normal file
83
src/BarCode.Web.Domain/Services/Public/ErpBaseDataSync.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// 同步erp基础数据
|
||||
/// </summary>
|
||||
public static class ErpBaseDataSync
|
||||
{
|
||||
public static Task Sync(IServiceProvider serviceProvider)
|
||||
{
|
||||
var sercice = serviceProvider.GetRequiredService<IErpService>();
|
||||
//Task.Run(() =>
|
||||
//{
|
||||
// //异步-同步下物料数据
|
||||
// sercice.BillQueryForMaterial().GetAwaiter().GetResult();
|
||||
//});
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下组织数据
|
||||
sercice.BillQueryForOrg().GetAwaiter().GetResult();
|
||||
});
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下客户数据
|
||||
sercice.BillQueryForCustomer().GetAwaiter().GetResult();
|
||||
});
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下供应商数据
|
||||
sercice.BillQueryForSupplier().GetAwaiter().GetResult();
|
||||
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public static Task SyncMaterial(IErpService sercice)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下物料数据
|
||||
sercice.BillQueryForMaterial().GetAwaiter().GetResult();
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public static Task SyncOrg(IErpService sercice)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下组织数据
|
||||
sercice.BillQueryForOrg().GetAwaiter().GetResult();
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public static Task SyncCustomer(IErpService sercice)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下客户数据
|
||||
sercice.BillQueryForCustomer().GetAwaiter().GetResult();
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public static Task SyncSupplier(IErpService sercice)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下供应商数据
|
||||
sercice.BillQueryForSupplier().GetAwaiter().GetResult();
|
||||
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using BarCode.Web.Core.Dto.Erp.Customer;
|
||||
using BarCode.Web.Core.Dto.Erp.Org;
|
||||
using BarCode.Web.Core.Dto.Erp.Supplier;
|
||||
using BarCode.Web.Domain.Infrastructure;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Core.Dto.SingleData;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// erp基础数据:扩展服务
|
||||
/// </summary>
|
||||
public class ErpBasicDataExtendService: IErpBasicDataExtendService
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly ILoginService _loginService;
|
||||
private readonly IBasicsRepositories _basicsRepositories;
|
||||
|
||||
public ErpBasicDataExtendService(IMapper mapper, ILoginService loginService, IErpService erpService,
|
||||
IBasicsRepositories basicsRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_erpService = erpService;
|
||||
_loginService = loginService;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料名称
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialName(List<ErpMaterialDto> erpMaterials,int materialId)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
|
||||
var mat= erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result= _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult();
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.MaterialName;
|
||||
}
|
||||
return mat.MaterialName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料编码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialNumber(List<ErpMaterialDto> erpMaterials, int materialId)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.MaterialNumber;
|
||||
}
|
||||
return mat.MaterialNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料规格型号
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialSpecifications(List<ErpMaterialDto> erpMaterials, int materialId)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.Specifications;
|
||||
}
|
||||
return mat.Specifications;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料名称
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialName(List<ErpMaterialDto> erpMaterials, string materialNumber)
|
||||
{
|
||||
if (string.IsNullOrEmpty(materialNumber)) return "";
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
|
||||
var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult();
|
||||
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.MaterialName;
|
||||
}
|
||||
return mat.MaterialName;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取物料编码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialSpecifications(List<ErpMaterialDto> erpMaterials, string materialNumber)
|
||||
{
|
||||
if (string.IsNullOrEmpty(materialNumber)) return "";
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.Specifications;
|
||||
}
|
||||
return mat.Specifications;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料基本单位名称
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialUnitName(List<ErpMaterialDto> erpMaterials, int materialId)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.BaseUnitName;
|
||||
}
|
||||
return mat.BaseUnitName;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取物料基本单位名称
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialUnitName(List<ErpMaterialDto> erpMaterials, string materialNumber)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.BaseUnitName;
|
||||
}
|
||||
return mat.BaseUnitName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的条码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialBarCode(List<ErpMaterialDto> erpMaterials, int materialId)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.BarCode;
|
||||
}
|
||||
return mat.BarCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料的条码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialBarCode(List<ErpMaterialDto> erpMaterials, string materialNumber)
|
||||
{
|
||||
if (string.IsNullOrEmpty(materialNumber)) return "";
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.BarCode;
|
||||
}
|
||||
return mat.BarCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取物料基本单位Id
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
public int GetMaterialUnitId(List<ErpMaterialDto> erpMaterials, int materialId)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return 0;
|
||||
var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return 0;
|
||||
return result.Data == null ? 0 : result.Data.BaseUnitId;
|
||||
}
|
||||
return mat.BaseUnitId;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取物料基本单位编码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialUnitNumber(List<ErpMaterialDto> erpMaterials, int materialId)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialId == materialId).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialId).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.BaseUnitNumber;
|
||||
}
|
||||
return mat.BaseUnitNumber;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取物料基本单位编码
|
||||
/// </summary>
|
||||
/// <param name="erpMaterials"></param>
|
||||
/// <param name="materialNumber"></param>
|
||||
/// <returns></returns>
|
||||
public string GetMaterialUnitNumber(List<ErpMaterialDto> erpMaterials, string materialNumber)
|
||||
{
|
||||
if (erpMaterials == null || erpMaterials.Count == 0)
|
||||
return "";
|
||||
var mat = erpMaterials.Where(x => x.MaterialNumber == materialNumber).FirstOrDefault();
|
||||
if (mat == null)
|
||||
{
|
||||
var result = _erpService.BillQueryForMaterial(materialNumber).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccess)
|
||||
return "";
|
||||
return result.Data == null ? "" : result.Data.BaseUnitNumber;
|
||||
}
|
||||
return mat.BaseUnitNumber;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取组织名称
|
||||
/// </summary>
|
||||
/// <param name="erpOrgs"></param>
|
||||
/// <param name="orgId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetOrgName(List<ErpOrgDto> erpOrgs, int orgId)
|
||||
{
|
||||
if (erpOrgs == null || erpOrgs.Count == 0)
|
||||
return "";
|
||||
var org = erpOrgs.Where(x => x.Id == orgId).FirstOrDefault();
|
||||
return org == null ? "" : org.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组织名称
|
||||
/// </summary>
|
||||
/// <param name="erpOrgs"></param>
|
||||
/// <param name="orgCode"></param>
|
||||
/// <returns></returns>
|
||||
public string GetOrgName(List<ErpOrgDto> erpOrgs, string orgCode)
|
||||
{
|
||||
if (erpOrgs == null || erpOrgs.Count == 0)
|
||||
return "";
|
||||
var org = erpOrgs.Where(x => x.Number == orgCode).FirstOrDefault();
|
||||
return org == null ? "" : org.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组织id
|
||||
/// </summary>
|
||||
/// <param name="erpOrgs"></param>
|
||||
/// <param name="orgCode"></param>
|
||||
/// <returns></returns>
|
||||
public int GetOrgId(List<ErpOrgDto> erpOrgs, string orgCode)
|
||||
{
|
||||
if (erpOrgs == null || erpOrgs.Count == 0)
|
||||
return 0;
|
||||
var org = erpOrgs.Where(x => x.Number == orgCode).FirstOrDefault();
|
||||
return org == null ? 0 : org.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取供应商名称
|
||||
/// </summary>
|
||||
/// <param name="erpSuppliers"></param>
|
||||
/// <param name="supplierId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetSupplierName(List<ErpSupplierDto> erpSuppliers, int supplierId)
|
||||
{
|
||||
if (erpSuppliers == null || erpSuppliers.Count == 0)
|
||||
return "";
|
||||
var supplier = erpSuppliers.Where(x => x.Id == supplierId).FirstOrDefault();
|
||||
return supplier == null ? "" : supplier.Name;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取供应商名称
|
||||
/// </summary>
|
||||
/// <param name="erpSuppliers"></param>
|
||||
/// <param name="supplierCode"></param>
|
||||
/// <returns></returns>
|
||||
public string GetSupplierName(List<ErpSupplierDto> erpSuppliers, string supplierCode)
|
||||
{
|
||||
if (erpSuppliers == null || erpSuppliers.Count == 0)
|
||||
return "";
|
||||
var supplier = erpSuppliers.Where(x => x.Number.Equals(supplierCode)).FirstOrDefault();
|
||||
return supplier == null ? "" : supplier.Name;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取客户名称
|
||||
/// </summary>
|
||||
/// <param name="erpCustomers"></param>
|
||||
/// <param name="customerId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetCustomerName(List<ErpCustomerDto> erpCustomers, int customerId)
|
||||
{
|
||||
if (erpCustomers == null || erpCustomers.Count == 0)
|
||||
return "";
|
||||
var supplier = erpCustomers.Where(x => x.Id == customerId).FirstOrDefault();
|
||||
return supplier == null ? "" : supplier.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库名称
|
||||
/// </summary>
|
||||
/// <param name="erpStocks"></param>
|
||||
/// <param name="stockId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetStockName(List<ErpStockDto> erpStocks, int stockId)
|
||||
{
|
||||
if (erpStocks == null || erpStocks.Count == 0)
|
||||
return "";
|
||||
var stock = erpStocks.Where(x => x.Id == stockId).FirstOrDefault();
|
||||
return stock == null ? "" : stock.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库名称
|
||||
/// </summary>
|
||||
/// <param name="erpStocks"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public string GetStockName(List<ErpStockDto> erpStocks, string code)
|
||||
{
|
||||
if (erpStocks == null || erpStocks.Count == 0)
|
||||
return "";
|
||||
var stock = erpStocks.Where(x => x.Code == code).FirstOrDefault();
|
||||
return stock == null ? "" : stock.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库编码
|
||||
/// </summary>
|
||||
/// <param name="erpStocks"></param>
|
||||
/// <param name="stockId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetStockCode(List<ErpStockDto> erpStocks, int stockId)
|
||||
{
|
||||
if (erpStocks == null || erpStocks.Count == 0)
|
||||
return "";
|
||||
var stock = erpStocks.Where(x => x.Id == stockId).FirstOrDefault();
|
||||
return stock == null ? "" : stock.Code;
|
||||
}
|
||||
/// <summary>
|
||||
/// 子仓库
|
||||
/// </summary>
|
||||
/// <param name="erpStocks"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public string GetSubStockName(List<Erp_SubStockDto> erpStocks, string code)
|
||||
{
|
||||
if (erpStocks == null || erpStocks.Count == 0)
|
||||
return "";
|
||||
var stock = erpStocks.Where(x => x.Code == code).FirstOrDefault();
|
||||
return stock == null ? "" : stock.Name;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取单点组织名字
|
||||
/// </summary>
|
||||
/// <param name="orgs"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public string GetSingleOrgName(List<SysOrgResponse> orgs, string code)
|
||||
{
|
||||
if (orgs == null || orgs.Count == 0)
|
||||
return "";
|
||||
var org = orgs.Where(x => x.ErpOrgCode == code).FirstOrDefault();
|
||||
return org == null ? "" : org.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
1207
src/BarCode.Web.Domain/Services/Public/ErpService.cs
Normal file
1207
src/BarCode.Web.Domain/Services/Public/ErpService.cs
Normal file
File diff suppressed because it is too large
Load Diff
55
src/BarCode.Web.Domain/Services/Public/HostedService.cs
Normal file
55
src/BarCode.Web.Domain/Services/Public/HostedService.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
public class HostedService : IHostedService
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
public HostedService(IServiceProvider serviceProvider, IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var scope = _serviceScopeFactory.CreateScope();
|
||||
var sercice = scope.ServiceProvider.GetRequiredService<IErpService>();
|
||||
Console.WriteLine("开始加载初始数据...");
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下物料数据
|
||||
sercice.BillQueryForMaterial().GetAwaiter().GetResult();
|
||||
Console.WriteLine("物料加载完成");
|
||||
});
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下组织数据
|
||||
sercice.BillQueryForOrg().GetAwaiter().GetResult();
|
||||
Console.WriteLine("组织加载完成");
|
||||
});
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
//异步-同步下供应商数据
|
||||
sercice.BillQueryForSupplier().GetAwaiter().GetResult();
|
||||
Console.WriteLine("供应商加载完成");
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
230
src/BarCode.Web.Domain/Services/Public/HttpClientService.cs
Normal file
230
src/BarCode.Web.Domain/Services/Public/HttpClientService.cs
Normal file
@@ -0,0 +1,230 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Exceptions;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
public class HttpClientService : IHttpClientService
|
||||
{
|
||||
private readonly IHttpClientFactory _clientFactory;
|
||||
private readonly ILogger<HttpClientService> _logger;
|
||||
private Dictionary<string, string> headers;
|
||||
private Dictionary<string, string> contentHeaders;
|
||||
public HttpClientService(IHttpClientFactory clientFactory, ILogger<HttpClientService> logger)
|
||||
{
|
||||
_clientFactory = clientFactory;
|
||||
_logger = logger;
|
||||
headers = new Dictionary<string, string>();
|
||||
headers.Add("Accept", "application/json");
|
||||
headers.Add("User-Agent", "HttpClientFactory-Sample");
|
||||
|
||||
contentHeaders = new Dictionary<string, string>();
|
||||
contentHeaders.Add("Content-Type", "application/json; charset=utf-8");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get方法
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="dicHeaders"></param>
|
||||
/// <param name="timeoutSecond"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> GetAsync<T>(string url, int timeoutSecond = 180)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = BuildHttpClient(headers, timeoutSecond);
|
||||
var response = await client.GetAsync(url);
|
||||
//var responseContent = await response.Content.ReadAsStreamAsync();//1.相比ReadAsString这个方法返回要快点,效率高
|
||||
var responseContent = await response.Content.ReadAsStringAsync(); //2.当前使用这里是为了迎合错误信息观看
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var t = JsonSerializer.Deserialize<T>(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
//var t = await JsonSerializer.DeserializeAsync<T>(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });//3.配合1的ReadAsStream使用
|
||||
return t;
|
||||
}
|
||||
|
||||
throw new WebHttpException(response.StatusCode.ToString(), "请求出错");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"HttpGet:{url} Error:{ex.Message}");
|
||||
throw new Exception($"HttpGet:{url} Error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get方法
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="dicHeaders"></param>
|
||||
/// <param name="timeoutSecond"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> GetAsync<T>(string url, Dictionary<string, string> dicHeaders, int timeoutSecond = 180)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = BuildHttpClient(dicHeaders, timeoutSecond);
|
||||
var response = await client.GetAsync(url);
|
||||
//var responseContent = await response.Content.ReadAsStreamAsync();//1.相比ReadAsString这个方法返回要快点,效率高
|
||||
var responseContent = await response.Content.ReadAsStringAsync(); //2.当前使用这里是为了迎合错误信息观看
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var t = JsonSerializer.Deserialize<T>(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
//var t = await JsonSerializer.DeserializeAsync<T>(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });//3.配合1的ReadAsStream使用
|
||||
return t;
|
||||
}
|
||||
|
||||
throw new WebHttpException(response.StatusCode.ToString(), "请求出错");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"HttpGet:{url} Error:{ex.Message}");
|
||||
throw new Exception($"HttpGet:{url} Error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post方法
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="requestBody"></param>
|
||||
/// <param name="dicHeaders"></param>
|
||||
/// <param name="timeoutSecond"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> PostAsync<T>(string url, string requestBody, Dictionary<string, string> dicHeaders, int timeoutSecond = 180)
|
||||
{
|
||||
var client = BuildHttpClient(dicHeaders, timeoutSecond);
|
||||
var requestContent = GenerateStringContent(requestBody, contentHeaders);
|
||||
var response = await client.PostAsync(url, requestContent);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var t = JsonSerializer.Deserialize<T>(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
return t;
|
||||
}
|
||||
|
||||
_logger.LogError($"HttpGet:{url} Error:{responseContent}");
|
||||
throw new WebHttpException(response.StatusCode.ToString(), responseContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post方法
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="requestBody"></param>
|
||||
/// <param name="timeoutSecond"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> PostAsync<T>(string url, string requestBody, int timeoutSecond = 180)
|
||||
{
|
||||
var client = BuildHttpClient(null, timeoutSecond);
|
||||
var requestContent = GenerateStringContent(requestBody, contentHeaders);
|
||||
var response = await client.PostAsync(url, requestContent);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var t = JsonSerializer.Deserialize<T>(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
if (t == null)
|
||||
_logger.LogInformation($"获取单点数据为空---{responseContent}");
|
||||
return t;
|
||||
}
|
||||
|
||||
_logger.LogError($"HttpGet:{url} Error:{responseContent}");
|
||||
throw new WebHttpException(response.StatusCode.ToString(), responseContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 公共http请求
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="method"></param>
|
||||
/// <param name="requestBody"></param>
|
||||
/// <param name="dicHeaders"></param>
|
||||
/// <param name="timeoutSecond"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> ExecuteAsync<T>(string url, HttpMethod method, string requestBody, Dictionary<string, string> dicHeaders, int timeoutSecond = 180)
|
||||
{
|
||||
var client = BuildHttpClient(null, timeoutSecond);
|
||||
var request = GenerateHttpRequestMessage(url, requestBody, method, dicHeaders);
|
||||
var response = await client.SendAsync(request);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var t = JsonSerializer.Deserialize<T>(responseContent, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
throw new WebHttpException(response.StatusCode.ToString(), responseContent);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置HttpRequestMessage
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="requestBody"></param>
|
||||
/// <param name="method"></param>
|
||||
/// <param name="dicHeaders"></param>
|
||||
/// <returns></returns>
|
||||
private HttpRequestMessage GenerateHttpRequestMessage(string url, string requestBody, HttpMethod method, Dictionary<string, string> dicHeaders)
|
||||
{
|
||||
var request = new HttpRequestMessage(method, url);
|
||||
if (!string.IsNullOrEmpty(requestBody)) request.Content = new StringContent(requestBody);
|
||||
if (dicHeaders != null)
|
||||
foreach (var headerItme in dicHeaders)
|
||||
request.Headers.Add(headerItme.Key, headerItme.Value);
|
||||
return request;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置请求内容
|
||||
/// </summary>
|
||||
/// <param name="requestBody"></param>
|
||||
/// <param name="dicHeaders"></param>
|
||||
/// <returns></returns>
|
||||
private StringContent GenerateStringContent(string requestBody, Dictionary<string, string> dicHeaders)
|
||||
{
|
||||
var content = new StringContent(requestBody);
|
||||
if (dicHeaders != null)
|
||||
content.Headers.Remove("content-type");
|
||||
foreach (var headerItme in dicHeaders)
|
||||
content.Headers.Add(headerItme.Key, headerItme.Value);
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置请求头和超时时间:返回client
|
||||
/// </summary>
|
||||
/// <param name="dicDefaultHeaders"></param>
|
||||
/// <param name="timeoutSecond"></param>
|
||||
/// <returns></returns>
|
||||
public HttpClient BuildHttpClient(Dictionary<string, string> dicDefaultHeaders, int? timeoutSecond=180)
|
||||
{
|
||||
var httpClient = _clientFactory.CreateClient("ops_client");
|
||||
httpClient.DefaultRequestHeaders.Clear(); //为了使客户端不受最后一个请求的影响,它需要清除DefaultRequestHeaders
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
if (dicDefaultHeaders != null)
|
||||
foreach (var headItem in dicDefaultHeaders)
|
||||
if (!httpClient.DefaultRequestHeaders.Contains(headItem.Key))
|
||||
httpClient.DefaultRequestHeaders.Add(headItem.Key, headItem.Value);
|
||||
|
||||
if (timeoutSecond != null) httpClient.Timeout = TimeSpan.FromSeconds(timeoutSecond.Value);
|
||||
return httpClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
567
src/BarCode.Web.Domain/Services/Public/LoginService.cs
Normal file
567
src/BarCode.Web.Domain/Services/Public/LoginService.cs
Normal file
@@ -0,0 +1,567 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Json;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.Login.Temp;
|
||||
using BarCode.Web.Core.Dto.Login.Temp.v3;
|
||||
using BarCode.Web.Core.Dto.SingleData;
|
||||
using BarCode.Web.Core.Help;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Core.Internal.Security;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Options;
|
||||
using BarCode.Web.Domain.Values.Single;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
public class LoginService : ILoginService
|
||||
{
|
||||
private IMapper _mapper;
|
||||
private SoaOptions _soaOptions;
|
||||
private ILogger<LoginService> _logger;
|
||||
private HttpClientHelp _httpClientHelp;
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly RedisClientService _redisClientService;
|
||||
public LoginService(
|
||||
IMapper mapper,
|
||||
IOptions<SoaOptions> soaOptions,
|
||||
ILogger<LoginService> logger,
|
||||
HttpClientHelp httpClientHelp,
|
||||
ISingleDataService singleDataService,
|
||||
RedisClientService redisClientService)
|
||||
{
|
||||
this._redisClientService = redisClientService;
|
||||
this._singleDataService = singleDataService;
|
||||
this._soaOptions = soaOptions?.Value;
|
||||
this._mapper = mapper;
|
||||
this._logger = logger;
|
||||
this._httpClientHelp = httpClientHelp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建token
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="tempDto"></param>
|
||||
/// <param name="NewToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AccessTokenDto> CreateToken(UserInfoDto data, LoginTempDto tempDto, string NewToken)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
|
||||
DateTime expires_time = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)).AddSeconds(tempDto.expires_in);
|
||||
AccessTokenDto accessToken = new AccessTokenDto()
|
||||
{
|
||||
Token = NewToken,
|
||||
PhpToken = tempDto.access_token,
|
||||
RefreshToken = tempDto.refresh_token,
|
||||
Expired = expires_time
|
||||
};
|
||||
return accessToken;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建token
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="tempDto"></param>
|
||||
/// <param name="NewToken"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<AccessTokenDto> CreateToken(UserInfoDto data, LoginTempV2Dto tempDto, string NewToken)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
|
||||
DateTime expires_time = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)).AddSeconds(tempDto.access_expired_at);
|
||||
AccessTokenDto accessToken = new AccessTokenDto()
|
||||
{
|
||||
Token = NewToken,
|
||||
PhpToken = tempDto.access_token,
|
||||
RefreshToken = tempDto.refresh_token,
|
||||
Expired = expires_time
|
||||
};
|
||||
return accessToken;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点登录信息
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result<LoginInDto>> GetUserInfoByCode(string code)
|
||||
{
|
||||
var reqData = new LoginAuthorizeCodeRequest();
|
||||
reqData.ClientId = _soaOptions.AppId;
|
||||
reqData.ClientSecret = _soaOptions.AppSecret;
|
||||
reqData.GrantType = "authorization_code";
|
||||
reqData.Code = code;
|
||||
reqData.Scope = "credentials";
|
||||
|
||||
//这个是登录的时候给前端验证的token,以及传给php单点那边的一个session值,用于单点退出时,通知ops退出
|
||||
string NewToken = Guid.NewGuid().ToString("N");
|
||||
try
|
||||
{
|
||||
string result = _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/authorize", reqData);
|
||||
var jObject = JsonObject.Parse(result);
|
||||
LoginInDto r = new LoginInDto();
|
||||
r.UserInfo = new UserInfoDto();
|
||||
r.TokenInfo = new AccessTokenDto();
|
||||
var login_result = jObject["code"] == 0 ? "成功" : "失败";
|
||||
|
||||
if (jObject["code"] == 0)
|
||||
{
|
||||
string datajson = jObject["data"].ToString();
|
||||
var _loginDto = JsonConvert.DeserializeObject<LoginTempV2Dto>(datajson);
|
||||
|
||||
#region 解码
|
||||
string enptStr = _loginDto.encrypted_data;
|
||||
List<string> enptlist = enptStr.Trim().Split(',').ToList();
|
||||
string str = RSA.DecryptSection(_soaOptions.PrivateKey, enptlist);
|
||||
var entity = JsonConvert.DeserializeObject<LoginJsonTokenV3TempDto>(str);
|
||||
#endregion
|
||||
|
||||
//映射登录信息
|
||||
var userInfo_v3 = _mapper.Map<UserInfoV3Dto>(entity);
|
||||
_logger.LogInformation($"登录信息:用户ID->{entity.id}");
|
||||
_logger.LogInformation($"登录信息->{str}");
|
||||
//HTTP请求获取登录信息:人员,客户,供应商,公司
|
||||
var loginRequest = new LoginSingleRequest()
|
||||
{
|
||||
UserId = entity.id,
|
||||
|
||||
};
|
||||
var loginResponse_result = await _singleDataService.GetSingleDataNoCache<Result<SingleDataResponse>, LoginSingleRequest, SingleLoginAction>
|
||||
(loginRequest, SingleLoginAction.Staff, type: SingleControllerType.Login);
|
||||
|
||||
//绑定返回对象的登录信息
|
||||
var staffName = "Null";
|
||||
var token = await CreateToken(r.UserInfo, _loginDto, NewToken);
|
||||
r.TokenInfo = token;
|
||||
if (loginResponse_result.Success && loginResponse_result.Data != null)
|
||||
{
|
||||
var loginResponse = loginResponse_result.Data;
|
||||
if (loginResponse != null)
|
||||
{
|
||||
r.UserInfo.StaffId = loginResponse.Id;
|
||||
staffName = loginResponse.Name;
|
||||
}
|
||||
}
|
||||
r.UserInfo.CompanyId = userInfo_v3.Company.Id;
|
||||
r.UserInfo.CompanyName = userInfo_v3.Company.Name;
|
||||
r.UserInfo.UcId = userInfo_v3.Id;
|
||||
r.UserInfo.SeesionId = "";//app和程序类型登录授权没有这个字段
|
||||
r.UserInfo.Nickname = userInfo_v3.Nickname;
|
||||
r.UserInfo.Mobile = userInfo_v3.Mobile;
|
||||
r.UserInfo.Identity = userInfo_v3.Identity;//1.组织 2.供应商 3.客户
|
||||
r.UserInfo.CustomerId = null;
|
||||
r.UserInfo.SupplierId = null;
|
||||
r.SignedIn = true;
|
||||
if (entity != null && entity.orgs != null)
|
||||
r.UserInfo.OrgId = entity.orgs.FirstOrDefault()?.org_id;
|
||||
|
||||
if (userInfo_v3.Identity == 2)
|
||||
{//供应商获取供应商信息
|
||||
var result_supplier = await _singleDataService.GetSingleDataNoCache<ResultList<SupplierInfoResponse>, UserRequest, SysConfigAction>(
|
||||
new UserRequest(loginRequest.UserId), SysConfigAction.GetSupplierByUser, SingleControllerType.SysConfig);
|
||||
if (!result_supplier.IsSuccess)
|
||||
return Result<LoginInDto>.ReFailure("授权失败,请重新登录", 401);
|
||||
if (result_supplier.Data.Count() <= 0)
|
||||
return Result<LoginInDto>.ReFailure("授权失败,用户没有对应供应商", 401);
|
||||
SupplierInfoResponse supplier = result_supplier.Data.First();
|
||||
|
||||
r.UserInfo.SupplierId = supplier.Id;
|
||||
r.UserInfo.SupplierName = supplier.Name;
|
||||
r.UserInfo.SupplierCode = supplier.Code;
|
||||
}
|
||||
//判断是否是管理员账号
|
||||
var isAdmin = _soaOptions.AdminUser.Exists(f => f == r.UserInfo.UcId);
|
||||
if (isAdmin)
|
||||
r.UserInfo.IsAdmin = true;
|
||||
|
||||
|
||||
//登录后缓存登录的用户信息和token信息
|
||||
var loginInfo = new LoginInDto();
|
||||
loginInfo.UserInfo = r.UserInfo;
|
||||
loginInfo.TokenInfo = token;
|
||||
loginInfo.TokenInfo.ClientName = "PC";
|
||||
|
||||
var ops_login_time = token.Expired.AddDays(1) - DateTime.Now;//用于正式
|
||||
//var ops_login_time = token.Expired - DateTime.Now;//用于正式
|
||||
_redisClientService.SetStringKey<LoginInDto>($"wms_login_{token.Token}", loginInfo, ops_login_time);
|
||||
|
||||
_logger.LogInformation($"登录信息:用户人员信息->{staffName}({r.UserInfo.StaffId}),公司名称->{r.UserInfo.CompanyName}" + ",过期时间:" + token.Expired.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
//登录成功移出对应的用户token黑名单:应为新的token产生,移除登录的信息
|
||||
string blacktoken = _redisClientService.GetStringKey($"wms_black_token_{r.UserInfo.UcId}");
|
||||
if (!string.IsNullOrEmpty(blacktoken))
|
||||
{
|
||||
this.RemoveLoginInfo(blacktoken);
|
||||
_redisClientService.RemoveStringKey($"wms_black_token_{r.UserInfo.UcId}");
|
||||
}
|
||||
if (r == null || r.UserInfo == null || r.TokenInfo == null)
|
||||
return Result<LoginInDto>.ReFailure("授权失败,请重新登录", 401);
|
||||
return Result<LoginInDto>.ReSuccess(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
var errno_text = "登录失败:" + jObject["message"];
|
||||
_logger.LogInformation("登陆失败:" + errno_text);
|
||||
return Result<LoginInDto>.ReFailure(errno_text, 401);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogInformation("登录错误信息:" + ex.Message);
|
||||
return Result<LoginInDto>.ReFailure("授权失败,请重新登录", 401);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点用户信息
|
||||
/// </summary>
|
||||
/// <param name="username"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result<LoginInDto>> GetUserInfo(string username, string password)
|
||||
{
|
||||
var reqData = new LoginAuthorizeRequest();
|
||||
reqData.ClientId = _soaOptions.AppId;
|
||||
reqData.ClientSecret = _soaOptions.AppSecret;
|
||||
reqData.GrantType = "password";
|
||||
reqData.UserName = username;
|
||||
reqData.Scope = "credentials";
|
||||
_logger.LogInformation($"username:" + username + ";password:" + password);
|
||||
var md5 = System.Security.Cryptography.MD5.Create();
|
||||
var md5Pwd = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(password)));
|
||||
md5Pwd = md5Pwd.Replace("-", string.Empty);
|
||||
reqData.Password = md5Pwd.ToLower();
|
||||
|
||||
//这个是登录的时候给前端验证的token,以及传给php单点那边的一个session值,用于单点退出时,通知ops退出
|
||||
string NewToken = Guid.NewGuid().ToString("N");
|
||||
try
|
||||
{
|
||||
string result = _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/authorize", reqData);
|
||||
var jObject = JsonObject.Parse(result);
|
||||
LoginInDto r = new LoginInDto();
|
||||
r.UserInfo = new UserInfoDto();
|
||||
r.TokenInfo = new AccessTokenDto();
|
||||
var login_result = jObject["code"] == 0 ? "成功" : "失败";
|
||||
|
||||
if (jObject["code"] == 0)
|
||||
{
|
||||
string datajson = jObject["data"].ToString();
|
||||
var _loginDto = JsonConvert.DeserializeObject<LoginTempV2Dto>(datajson);
|
||||
|
||||
#region 解码
|
||||
string enptStr = _loginDto.encrypted_data;
|
||||
List<string> enptlist = enptStr.Trim().Split(',').ToList();
|
||||
string str = RSA.DecryptSection(_soaOptions.PrivateKey, enptlist);
|
||||
var entity = JsonConvert.DeserializeObject<LoginJsonTokenV3TempDto>(str);
|
||||
#endregion
|
||||
|
||||
//映射登录信息
|
||||
var userInfo_v3 = _mapper.Map<UserInfoV3Dto>(entity);
|
||||
_logger.LogInformation($"登录信息:用户ID->{entity.id}");
|
||||
//HTTP请求获取登录信息:人员,客户,供应商,公司
|
||||
var loginRequest = new LoginSingleRequest()
|
||||
{
|
||||
UserId = entity.id,
|
||||
|
||||
};
|
||||
var loginResponse_result = await _singleDataService.GetSingleDataNoCache<Result<SingleDataResponse>, LoginSingleRequest, SingleLoginAction>
|
||||
(loginRequest, SingleLoginAction.Staff, type: SingleControllerType.Login);
|
||||
|
||||
//绑定返回对象的登录信息
|
||||
var staffName = "Null";
|
||||
var token = await CreateToken(r.UserInfo, _loginDto, NewToken);
|
||||
r.TokenInfo = token;
|
||||
if (loginResponse_result.Success && loginResponse_result.Data != null)
|
||||
{
|
||||
var loginResponse = loginResponse_result.Data;
|
||||
if (loginResponse != null)
|
||||
{
|
||||
r.UserInfo.StaffId = loginResponse.Id;
|
||||
staffName = loginResponse.Name;
|
||||
}
|
||||
}
|
||||
r.UserInfo.CompanyId = userInfo_v3.Company.Id;
|
||||
r.UserInfo.CompanyName = userInfo_v3.Company.Name;
|
||||
r.UserInfo.UcId = userInfo_v3.Id;
|
||||
r.UserInfo.SeesionId = "";//app和程序类型登录授权没有这个字段
|
||||
r.UserInfo.Nickname = userInfo_v3.Nickname;
|
||||
r.UserInfo.Mobile = userInfo_v3.Mobile;
|
||||
r.UserInfo.Identity = userInfo_v3.Identity;
|
||||
r.UserInfo.OrgId = entity.orgs.FirstOrDefault()?.org_id;
|
||||
r.UserInfo.CustomerId = null;
|
||||
r.UserInfo.SupplierId = null;
|
||||
r.SignedIn = true;
|
||||
_logger.LogInformation($"登录信息:用户人员信息->{staffName}({r.UserInfo.StaffId}),公司名称->{r.UserInfo.CompanyName}");
|
||||
|
||||
//登录后缓存登录的用户信息和token信息
|
||||
var loginInfo = new LoginInDto();
|
||||
loginInfo.UserInfo = r.UserInfo;
|
||||
loginInfo.TokenInfo = token;
|
||||
loginInfo.TokenInfo.ClientName = "PDA";
|
||||
|
||||
var ops_login_time = token.Expired.AddDays(1) - DateTime.Now;//用于正式
|
||||
//var ops_login_time = token.Expired - DateTime.Now;//用于正式
|
||||
_redisClientService.SetStringKey<LoginInDto>($"wms_login_{token.Token}", loginInfo, ops_login_time);
|
||||
|
||||
//登录成功移出对应的用户token黑名单:应为新的token产生,移除登录的信息
|
||||
string blacktoken = _redisClientService.GetStringKey($"wms_black_token_{r.UserInfo.UcId}");
|
||||
if (!string.IsNullOrEmpty(blacktoken))
|
||||
{
|
||||
this.RemoveLoginInfo(blacktoken);
|
||||
_redisClientService.RemoveStringKey($"wms_black_token_{r.UserInfo.UcId}");
|
||||
}
|
||||
if (r == null || r.UserInfo == null || r.TokenInfo == null)
|
||||
return Result<LoginInDto>.ReFailure("授权失败,请重新登录", 401);
|
||||
return Result<LoginInDto>.ReSuccess(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
var errno_text = "登录失败:" + jObject["message"];
|
||||
_logger.LogInformation("登陆失败:" + errno_text);
|
||||
return Result<LoginInDto>.ReFailure(errno_text, 4001);
|
||||
//r.SignedIn = false;
|
||||
//string datajson_sessid = jObject["data"]["uc_sessid"];
|
||||
////调用单点的退出接口
|
||||
//result = _httpClientHelp.GetHttp(_soaOptions.Url + "/uc/authorize/signin_out", true, cookieValue: datajson_sessid);
|
||||
//jObject = JsonObject.Parse(result);
|
||||
//if (jObject["errno"] == 0)
|
||||
//{
|
||||
// return Result<LoginInDto>.ReFailure("拒绝用户证书试图访问此web站点,请与站点管理员联系以建立用户证书权限", 403);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return Result<LoginInDto>.ReFailure(jObject["errmsg"], jObject["errno"]);
|
||||
//}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogInformation("登录错误信息:" + ex.Message);
|
||||
return Result<LoginInDto>.ReFailure("授权失败,请重新登录", 401);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录退出
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> LoginOut(LoginOutDto dto)
|
||||
{
|
||||
//2.请求PHP单点登出接口
|
||||
var reqData = new LoginOutAuthorizeRequest();
|
||||
reqData.AccessToken = dto.AccessToken;
|
||||
reqData.RefreshToken = dto.RefreshToken;
|
||||
string result = _httpClientHelp.GetHttpOut(_soaOptions.Url_V3 + "/uc/logout", reqData);
|
||||
_logger.LogInformation($"退出参数:{JsonConvert.SerializeObject(dto)}->退出登录单点返回:" + result);
|
||||
var jObject = JsonObject.Parse(result);
|
||||
if (jObject["code"] == 0)
|
||||
{
|
||||
//设置本地token的缓存:为黑名单的token做存储
|
||||
await CacheOutToken(dto);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Result.ReFailure(BaseResultCodes.UnAuthorized);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新token
|
||||
/// </summary>
|
||||
/// <param name="oldToken"></param>
|
||||
/// <param name="RefreshToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result<LoginInDto>> RefreshTokenNew(string oldToken, string RefreshToken)
|
||||
{
|
||||
|
||||
//1.根据旧token 找到登录对象
|
||||
var loginInfo = _redisClientService.GetStringKey<LoginInDto>($"wms_login_{oldToken}");
|
||||
var reqData = new LoginAuthorizeRefreshTokenRequest();
|
||||
reqData.ClientId = _soaOptions.AppId;
|
||||
reqData.ClientSecret = _soaOptions.AppSecret;
|
||||
reqData.GrantType = "refresh_token";
|
||||
reqData.RefreshToken = RefreshToken;
|
||||
reqData.Scope = "credentials";
|
||||
|
||||
var clientName = loginInfo?.TokenInfo?.ClientName;
|
||||
var oldExpired = loginInfo?.TokenInfo?.Expired.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
try
|
||||
{
|
||||
string result = _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/authorize", reqData);
|
||||
var jObject = JsonObject.Parse(result);
|
||||
|
||||
LoginInDto r = new LoginInDto();
|
||||
r.UserInfo = new UserInfoDto();
|
||||
r.TokenInfo = new AccessTokenDto();
|
||||
|
||||
if (jObject["code"] == 0)
|
||||
{
|
||||
string datajson = jObject["data"].ToString();
|
||||
var _loginDto = JsonConvert.DeserializeObject<LoginTempV2Dto>(datajson);
|
||||
|
||||
r.UserInfo = loginInfo.UserInfo;
|
||||
r.SignedIn = true;
|
||||
//string NewToken = Guid.NewGuid().ToString("N");
|
||||
var token = await CreateToken(loginInfo.UserInfo, _loginDto, oldToken);
|
||||
r.TokenInfo = token;
|
||||
loginInfo.TokenInfo = token;
|
||||
loginInfo.TokenInfo.ClientName = clientName;
|
||||
//_logger.LogInformation("RefreshToken:我在刷新登录:刷新后的过期时间-1>" + token.Expired.ToString());
|
||||
var ops_login_time = token.Expired.AddDays(1) - DateTime.Now;//用于正式
|
||||
//var ops_login_time = token.Expired - DateTime.Now;//用于正式
|
||||
_redisClientService.SetStringKey<LoginInDto>($"wms_login_{token.Token}", loginInfo, ops_login_time);
|
||||
_logger.LogInformation($"刷新Token->用户信息:{JsonConvert.SerializeObject(loginInfo)}->老时间->" + $"{oldExpired}" + ",新时间->" + $"wms_login_{token.Token}->过期时间:{token.Expired.ToString("yyyy-MM-dd HH:mm:ss")}");
|
||||
//移除老的redis缓存
|
||||
//_redisClientService.RemoveStringKey($"wms_login_{oldToken}");
|
||||
//_logger.LogInformation("RefreshToken:我在刷新登录:刷新后的过期时间-小时->" + ops_login_time.Hours);
|
||||
return Result<LoginInDto>.ReSuccess(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
//失败了1:就把登录的token清除 2: ucid添加到黑名单
|
||||
var time = new TimeSpan(r.TokenInfo.Expired.Day, r.TokenInfo.Expired.Hour, r.TokenInfo.Expired.Minute, r.TokenInfo.Expired.Second, r.TokenInfo.Expired.Millisecond);
|
||||
_redisClientService.SetStringKey($"wms_black_token_{r.UserInfo.UcId}", r.TokenInfo.Token, time);
|
||||
this.RemoveLoginInfo(r.TokenInfo.Token);
|
||||
r.SignedIn = false;
|
||||
return Result<LoginInDto>.ReFailure(jObject["message"], jObject["code"]);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogInformation("RefreshTokenNew:" + _soaOptions.Url_V3 + "/uc/authorize" + ":Data:" + JsonConvert.SerializeObject(reqData));
|
||||
_logger.LogInformation("RefreshTokenNew:Error" + ex.Message);
|
||||
return Result<LoginInDto>.ReFailure(ex.Message, 50001);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单点退出通知token失效
|
||||
/// </summary>
|
||||
/// <param name="SeesionId">这个是单点传过来的SeesionId</param>
|
||||
/// <returns></returns>
|
||||
public async Task LoginOutSingleAsync(string SeesionId)
|
||||
{
|
||||
var logininfo = _redisClientService.GetStringKey<LoginInDto>($"wms_login_{SeesionId}");
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (logininfo != null)
|
||||
{
|
||||
var cache_token = _redisClientService.GetStringKey($"wms_black_token_{logininfo.UserInfo.UcId}");
|
||||
if (string.IsNullOrEmpty(cache_token))
|
||||
{
|
||||
DateTime expires_time = logininfo.TokenInfo.Expired;
|
||||
var time = new TimeSpan(expires_time.Day, expires_time.Hour, expires_time.Minute, expires_time.Second, expires_time.Millisecond);
|
||||
_redisClientService.SetStringKey($"wms_black_token_{logininfo.UserInfo.UcId}", logininfo.TokenInfo.Token, time);
|
||||
this.RemoveLoginInfo(logininfo.TokenInfo.Token);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 缓存退出的token
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
private async Task CacheOutToken(LoginOutDto dto)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(dto.AccessToken))
|
||||
{
|
||||
var time = new TimeSpan(dto.ExpiresIn.Day, dto.ExpiresIn.Hour, dto.ExpiresIn.Minute, dto.ExpiresIn.Second, dto.ExpiresIn.Millisecond);
|
||||
_redisClientService.SetStringKey($"wms_black_token_{dto.UcId}", dto.AccessToken, time);
|
||||
this.RemoveLoginInfo(dto.Token);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取登录后的信息
|
||||
/// </summary>
|
||||
/// <param name="authorization"></param>
|
||||
/// <returns></returns>
|
||||
public LoginInDto GetLoginInfo(string authorization)
|
||||
{
|
||||
string token = string.Empty;
|
||||
if (authorization.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
token = authorization.Substring("Bearer ".Length).Trim();
|
||||
}
|
||||
var logininfo = _redisClientService.GetStringKey<LoginInDto>($"wms_login_{token}");
|
||||
return logininfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除登录后的用户信息
|
||||
/// </summary>
|
||||
/// <param name="token"></param>
|
||||
private void RemoveLoginInfo(string token)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
var info = _redisClientService.GetStringKey<LoginInDto>($"wms_login_{token}");
|
||||
if (info != null)
|
||||
{
|
||||
_redisClientService.RemoveStringKey($"wms_login_{token}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取菜单数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MenuResponse>> GetMenuList(int userId)
|
||||
{
|
||||
int module = _soaOptions.ModuleID;
|
||||
var result = await _singleDataService.GetSingleDataNoCache<ResultList<MenuResponse>, MenuRequest, SingleLoginAction>
|
||||
(new MenuRequest(userId, module), SingleLoginAction.Menus, type: SingleControllerType.Login);
|
||||
if (result.Success)
|
||||
return result.Data.ToList();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="accessToken"></param>
|
||||
/// <param name="refreshToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Online(string accessToken, string refreshToken)
|
||||
{
|
||||
string result = await _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/online", accessToken, refreshToken);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="accessToken"></param>
|
||||
/// <param name="refreshToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Offline(string accessToken, string refreshToken)
|
||||
{
|
||||
string result = await _httpClientHelp.PostHttp(_soaOptions.Url_V3 + "/uc/offline", accessToken, refreshToken);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
150
src/BarCode.Web.Domain/Services/Public/MaterialService.cs
Normal file
150
src/BarCode.Web.Domain/Services/Public/MaterialService.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using BarCode.Web.Domain.Infrastructure;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using NPOI.OpenXmlFormats.Spreadsheet;
|
||||
using Newtonsoft.Json;
|
||||
using BarCode.Web.Domain.Options;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using BarCode.Web.Domain.Services.Public;
|
||||
using ERP;
|
||||
using Microsoft.AspNetCore.Builder.Extensions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using BarCode.Web.Core.Help;
|
||||
|
||||
namespace BarCode.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料服务
|
||||
/// </summary>
|
||||
public class MaterialService : IMaterialService
|
||||
{
|
||||
private IMapper _mapper;
|
||||
private ILogger<MaterialService> _logger;
|
||||
private IErpService _erpService;
|
||||
private IMaterialsRepositories _materialsRepositories;
|
||||
private ErpOptions _erpOptions;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
public MaterialService(IMapper mapper, ILogger<MaterialService> logger, IErpService erpService,
|
||||
IMaterialsRepositories materialsRepositories, IOptions<ErpOptions> erpOptions, IMemoryCache memoryCache)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_logger = logger;
|
||||
_erpService = erpService;
|
||||
_materialsRepositories = materialsRepositories;
|
||||
this._erpOptions = erpOptions.Value;
|
||||
this._memoryCache = memoryCache;
|
||||
}
|
||||
/// <summary>
|
||||
/// 同步物料32进制
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> SyncBar()
|
||||
{
|
||||
var list = await _materialsRepositories.GetEntityListByNoBar();
|
||||
if (list.Count() <= 0) return Result.ReSuccess();
|
||||
var numbers = list.Select(s => s.MaterialNumber).ToList();
|
||||
var mDtos = await _erpService.BillQueryForMaterialByNumbers(numbers);
|
||||
if (!mDtos.IsSuccess) return Result.ReFailure(mDtos.Message, mDtos.Status);
|
||||
if (mDtos.Data.Count() <= 0) return Result.ReSuccess();
|
||||
_logger.LogInformation($"物料更新id32进制:{JsonConvert.SerializeObject(mDtos.Data)}");
|
||||
|
||||
var materials = _memoryCache.Get<List<ErpMaterialDto>>(_erpOptions.cache_materail_key);
|
||||
|
||||
|
||||
List<Materials> update_list = new List<Materials>();
|
||||
foreach (var m in mDtos.Data)
|
||||
{
|
||||
var entity = list.FirstOrDefault(f => f.MaterialNumber.Equals(m.MaterialNumber));
|
||||
if (entity == null) continue;
|
||||
entity.IdConvertBar = m.IdConvertBar.Trim();
|
||||
update_list.Add(entity);
|
||||
|
||||
//修改缓存
|
||||
if (materials == null) continue;
|
||||
var entity_cache = materials.FirstOrDefault(f => f.MaterialNumber.Equals(m.MaterialNumber));
|
||||
if (entity_cache == null) continue;
|
||||
entity_cache.IdConvertBar = m.IdConvertBar.Trim();
|
||||
}
|
||||
//修改缓存
|
||||
if (materials != null && materials.Count() > 0)
|
||||
{
|
||||
_logger.LogInformation($"物料缓存总数:{materials.Count()}");
|
||||
_memoryCache.Set(_erpOptions.cache_materail_key, materials, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan())));
|
||||
}
|
||||
await _materialsRepositories.UpdateRange(update_list);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步金蝶新的物料
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> SyncNewMaterials()
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("同步金蝶新物料:开始->" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
//1.获取全部物料编码
|
||||
var materialNumbers = await _materialsRepositories.GetAllNumbers();
|
||||
//1.1通过hash处理
|
||||
var materialNumberSet = new HashSet<string>(materialNumbers);
|
||||
|
||||
//2.获取金蝶物料:不取缓存的
|
||||
var mats_result = await _erpService.BillQueryForMaterial(false);
|
||||
var mats = new List<ErpMaterialDto>();
|
||||
if (mats_result.IsSuccess)
|
||||
mats = mats_result.Data.ToList();
|
||||
|
||||
//3.通过hash,更快的时间内判断元素是否存在于集合中,提高性能(10W数据十几毫秒级别)
|
||||
var entitys = mats
|
||||
.Where(item => !materialNumberSet.Contains(item.MaterialNumber))
|
||||
.Select(item => _mapper.Map<Materials>(item))
|
||||
.ToList();
|
||||
|
||||
//4.添加数据库
|
||||
if (entitys.Count != 0)
|
||||
{
|
||||
var isSuccess = await _materialsRepositories.AddRange(entitys);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
}
|
||||
//5.修改物料数据
|
||||
if (mats.Count != 0)
|
||||
{
|
||||
var isBatchManageMatNumbs = mats.Where(x => x.IsBatchManage == true).Select(x => x.MaterialNumber).ToList();
|
||||
//取:金蝶拉取的已启用批号管理的物料并且本地数据库中的未启用批号管理的物料;来更新批号管理修改为true
|
||||
var updateList = await _materialsRepositories.GetEntityList(isBatchManageMatNumbs, false);
|
||||
if (updateList.Count != 0)
|
||||
{
|
||||
updateList.ForEach(x => { x.IsBatchManage = true; });
|
||||
var isSuccess = await _materialsRepositories.UpdateRange(updateList);
|
||||
if (!isSuccess)
|
||||
_logger.LogInformation("同步金蝶新物料-修改物料:失败");
|
||||
else
|
||||
_logger.LogInformation("同步金蝶新物料-修改物料:成功->" + updateList.Count + "条");
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("同步金蝶新物料:结束->" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->添加数量:" + entitys.Count);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogInformation("同步金蝶新物料:失败->" + ex.Message);
|
||||
return Result.ReFailure(ex.Message, ex.HResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
344
src/BarCode.Web.Domain/Services/Public/Radix.cs
Normal file
344
src/BarCode.Web.Domain/Services/Public/Radix.cs
Normal file
@@ -0,0 +1,344 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
// string exclude = "ISOZ";//ISOZ
|
||||
// streamNo = Radix.ConvertRadix36((ulong)decstreamNo, exclude.ToCharArray()).PadLeft(FLength ?? 0, '0');
|
||||
public static class Radix
|
||||
{
|
||||
//36进制
|
||||
static string[] radixs = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
||||
|
||||
"I", "J", "K","L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
|
||||
|
||||
/// <summary>
|
||||
/// 进制转换
|
||||
/// </summary>
|
||||
/// <param name="lg">整形数字</param>
|
||||
/// <param name="excepts">排除的字符"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
|
||||
/// "C", "D", "E", "F", "G", "H", "I", "J", "K","L", "M", "N", "O", "P", "Q", "R", "S",
|
||||
/// "T", "U", "V", "W", "X", "Y", "Z"</param>
|
||||
/// <returns></returns>
|
||||
public static string ConvertRadix(ulong lg, string[] excepts)
|
||||
|
||||
{
|
||||
|
||||
var data = new List<string>();
|
||||
|
||||
foreach (var rd in radixs)
|
||||
|
||||
{
|
||||
|
||||
var isexists = false;
|
||||
|
||||
foreach (var ex in excepts)
|
||||
|
||||
{
|
||||
|
||||
if (rd.Equals(ex.ToUpper()))
|
||||
|
||||
{
|
||||
|
||||
isexists = true;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isexists)
|
||||
|
||||
{
|
||||
|
||||
data.Add(rd);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var rds = data.ToArray();
|
||||
|
||||
|
||||
|
||||
//进制
|
||||
|
||||
uint radix = (uint)rds.Length;
|
||||
|
||||
//long lg = 800000000853;
|
||||
|
||||
|
||||
|
||||
var s1 = lg / radix;
|
||||
|
||||
var s2 = lg % radix;
|
||||
|
||||
var rt = rds[radix];
|
||||
|
||||
while (s1 > 0)
|
||||
|
||||
{
|
||||
|
||||
var temp = s1;
|
||||
|
||||
s1 = temp / radix;
|
||||
|
||||
s2 = temp % radix;
|
||||
|
||||
rt = rds[s2] + rt;
|
||||
|
||||
}
|
||||
|
||||
//Q91VEGTN
|
||||
|
||||
//Console.WriteLine(rt);
|
||||
|
||||
return rt;
|
||||
|
||||
}
|
||||
|
||||
public static string ConvertRadix36(ulong val, char[] excepts)
|
||||
|
||||
{
|
||||
|
||||
string BaseChar = "0123456789ABCDEFGHIJKLMNPQRSTUVWXYZ";
|
||||
|
||||
foreach (var v in excepts)
|
||||
|
||||
{
|
||||
|
||||
BaseChar = BaseChar.Replace(v.ToString().ToUpper(), "");
|
||||
|
||||
}
|
||||
|
||||
List<string> r = new List<string>();
|
||||
|
||||
do
|
||||
|
||||
{
|
||||
|
||||
ulong y = val % (ulong)BaseChar.Length;
|
||||
|
||||
r.Add(BaseChar[Convert.ToInt32(y)].ToString());
|
||||
|
||||
val = Convert.ToUInt64(Math.Floor(val / (decimal)BaseChar.Length));
|
||||
|
||||
} while (val > 0);
|
||||
|
||||
r.Reverse();
|
||||
|
||||
return string.Join("", r.ToArray());
|
||||
|
||||
}
|
||||
|
||||
public static string Main(long lg)
|
||||
|
||||
{
|
||||
|
||||
string[] data = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||
|
||||
"A", "B", "C", "D", "E", "F","G", "H", "J", "K", "L", "M", "N", "Q", "R", "T", "U", "V", "W", "X", "Y" };
|
||||
|
||||
var s1 = lg / 32;
|
||||
|
||||
var s2 = lg % 32;
|
||||
|
||||
var rt = data[s2];
|
||||
|
||||
while (s1 > 0)
|
||||
|
||||
{
|
||||
|
||||
var temp = s1;
|
||||
|
||||
s1 = temp / 32;
|
||||
|
||||
s2 = temp % 32;
|
||||
|
||||
rt = data[s2] + rt;
|
||||
|
||||
}
|
||||
|
||||
//Q91VEGTN
|
||||
|
||||
return rt;
|
||||
|
||||
}
|
||||
|
||||
public static string IntToi32(long xx)
|
||||
|
||||
{
|
||||
|
||||
string a = "";
|
||||
|
||||
while (xx >= 1)
|
||||
|
||||
{
|
||||
|
||||
int index = Convert.ToInt16(xx - (xx / 32) * 32);
|
||||
|
||||
a = Base64Code[index] + a;
|
||||
|
||||
xx = xx / 32;
|
||||
|
||||
}
|
||||
|
||||
return a;
|
||||
|
||||
}
|
||||
|
||||
public static long i32ToInt(string xx)
|
||||
|
||||
{
|
||||
|
||||
long a = 0;
|
||||
|
||||
int power = xx.Length - 1;
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i <= power; i++)
|
||||
|
||||
{
|
||||
|
||||
a += _Base64Code[xx[power - i].ToString()] * Convert.ToInt64(Math.Pow(32, i));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return a;
|
||||
|
||||
}
|
||||
|
||||
public static string IntToi64(long xx)
|
||||
|
||||
{
|
||||
|
||||
string a = "";
|
||||
|
||||
while (xx >= 1)
|
||||
|
||||
{
|
||||
|
||||
int index = Convert.ToInt16(xx - (xx / 64) * 64);
|
||||
|
||||
a = Base64Code[index] + a;
|
||||
|
||||
xx = xx / 64;
|
||||
|
||||
}
|
||||
|
||||
return a;
|
||||
|
||||
}
|
||||
|
||||
public static long i64ToInt(string xx)
|
||||
|
||||
{
|
||||
|
||||
long a = 0;
|
||||
|
||||
int power = xx.Length - 1;
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i <= power; i++)
|
||||
|
||||
{
|
||||
|
||||
a += _Base64Code[xx[power - i].ToString()] * Convert.ToInt64(Math.Pow(64, i));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return a;
|
||||
|
||||
}
|
||||
|
||||
public static Dictionary<int, string> Base64Code = new Dictionary<int, string>() {
|
||||
|
||||
{ 0 ,"z"}, { 1 ,"1"}, { 2 ,"2"}, { 3 ,"3"}, { 4 ,"4"}, { 5 ,"5"}, { 6 ,"6"}, { 7 ,"7"}, { 8 ,"8"}, { 9 ,"9"},
|
||||
|
||||
{ 10 ,"a"}, { 11 ,"b"}, { 12 ,"c"}, { 13 ,"d"}, { 14 ,"e"}, { 15 ,"f"}, { 16 ,"g"}, { 17 ,"h"}, { 18 ,"i"}, { 19 ,"j"},
|
||||
|
||||
{ 20 ,"k"}, { 21 ,"x"}, { 22 ,"m"}, { 23 ,"n"}, { 24 ,"y"}, { 25 ,"p"}, { 26 ,"q"}, { 27 ,"r"}, { 28 ,"s"}, { 29 ,"t"},
|
||||
|
||||
{ 30 ,"u"}, { 31 ,"v"}, { 32 ,"w"}, { 33 ,"x"}, { 34 ,"y"}, { 35 ,"z"}, { 36 ,"A"}, { 37 ,"B"}, { 38 ,"C"}, { 39 ,"D"},
|
||||
|
||||
{ 40 ,"E"}, { 41 ,"F"}, { 42 ,"G"}, { 43 ,"H"}, { 44 ,"I"}, { 45 ,"J"}, { 46 ,"K"}, { 47 ,"L"}, { 48 ,"M"}, { 49 ,"N"},
|
||||
|
||||
{ 50 ,"O"}, { 51 ,"P"}, { 52 ,"Q"}, { 53 ,"R"}, { 54 ,"S"}, { 55 ,"T"}, { 56 ,"U"}, { 57 ,"V"}, { 58 ,"W"}, { 59 ,"X"},
|
||||
|
||||
{ 60 ,"Y"}, { 61 ,"Z"}, { 62 ,"-"}, { 63 ,"_"},
|
||||
|
||||
};
|
||||
|
||||
public static Dictionary<string, int> _Base64Code
|
||||
|
||||
{
|
||||
|
||||
get
|
||||
|
||||
{
|
||||
|
||||
return Enumerable.Range(0, Base64Code.Count()).ToDictionary(i => Base64Code[i], i => i);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//36进制转10进制
|
||||
public static int int32Convert10(string str)
|
||||
|
||||
{
|
||||
|
||||
int d = 0;
|
||||
|
||||
int b;
|
||||
|
||||
char[] ch = str.ToCharArray();
|
||||
|
||||
int j = 0;
|
||||
|
||||
for (int i = ch.Length - 1; i >= 0; i--)
|
||||
|
||||
{
|
||||
|
||||
char c = ch[i];
|
||||
|
||||
b = 1;
|
||||
|
||||
for (int t = 0; t < j; t++)
|
||||
|
||||
b = b * 32;
|
||||
|
||||
j++;
|
||||
|
||||
int cc;
|
||||
|
||||
if (c >= '0' && c <= '9')
|
||||
|
||||
cc = Convert.ToInt32(c) - 48;
|
||||
|
||||
else
|
||||
|
||||
cc = Convert.ToInt32(c) - 65 + 10;
|
||||
|
||||
d += cc * b;
|
||||
|
||||
}
|
||||
|
||||
return d;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
93
src/BarCode.Web.Domain/Services/Public/RedisClientService.cs
Normal file
93
src/BarCode.Web.Domain/Services/Public/RedisClientService.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Domain.Options;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
public class RedisClientService
|
||||
{
|
||||
private static readonly object Locker = new object();
|
||||
|
||||
private ConnectionMultiplexer redisMultiplexer;
|
||||
IDatabase db = null;
|
||||
private readonly AppOptions _options;
|
||||
public RedisClientService(IOptions<AppOptions> options)
|
||||
{
|
||||
_options = options?.Value;
|
||||
redisMultiplexer = ConnectionMultiplexer.Connect(_options.RedisConnectionString);
|
||||
db = redisMultiplexer.GetDatabase();
|
||||
}
|
||||
|
||||
#region String
|
||||
/// <summary>
|
||||
/// 保存单个key value
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <returns></returns>
|
||||
public bool SetStringKey(string key, string value, TimeSpan? expiry = default(TimeSpan?))
|
||||
{
|
||||
var lastKey = _options.RedisDirectory + ":" + key;
|
||||
return db.StringSet(lastKey, value, expiry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个key的值
|
||||
/// </summary>
|
||||
public RedisValue GetStringKey(string key)
|
||||
{
|
||||
var lastKey = _options.RedisDirectory + ":" + key;
|
||||
return db.StringGet(lastKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除redis
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public bool RemoveStringKey(string key)
|
||||
{
|
||||
var lastKey = _options.RedisDirectory + ":" + key;
|
||||
return db.KeyDelete(lastKey);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取一个key的对象
|
||||
/// </summary>
|
||||
public T GetStringKey<T>(string key)
|
||||
{
|
||||
if (db == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
var lastKey = _options.RedisDirectory + ":" + key;
|
||||
var value = db.StringGet(lastKey);
|
||||
if (value.IsNullOrEmpty)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
return JsonConvert.DeserializeObject<T>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存一个对象
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public bool SetStringKey<T>(string key, T obj, TimeSpan? expiry = default(TimeSpan?))
|
||||
{
|
||||
if (db == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var lastKey = _options.RedisDirectory + ":" + key;
|
||||
string json = JsonConvert.SerializeObject(obj);
|
||||
return db.StringSet(lastKey, json, expiry);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
public class RedisConcurrentProcessService: IRedisConcurrentProcessService
|
||||
{
|
||||
private readonly RedisClientService _redisClientService;
|
||||
public RedisConcurrentProcessService(RedisClientService redisClientService)
|
||||
{
|
||||
this._redisClientService = redisClientService;
|
||||
}
|
||||
|
||||
public bool CanAccessMethod(string cacheKey)
|
||||
{
|
||||
// 使用 Redis 来存储并发控制标记
|
||||
return _redisClientService.SetStringKey<bool>(cacheKey, true, TimeSpan.FromMinutes(1));
|
||||
}
|
||||
|
||||
|
||||
public bool GetRedisKeyValue(string cacheKey)
|
||||
{
|
||||
// 使用 Redis 来存储并发控制标记
|
||||
var isSuccess= _redisClientService.GetStringKey<bool>(cacheKey);
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
public void UpdateAccessStatus(string cacheKey, bool canAccess)
|
||||
{
|
||||
// 更新 Redis 缓存项的值
|
||||
_redisClientService.SetStringKey<bool>(cacheKey, canAccess, TimeSpan.FromMinutes(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
476
src/BarCode.Web.Domain/Services/Public/SingleDataService.cs
Normal file
476
src/BarCode.Web.Domain/Services/Public/SingleDataService.cs
Normal file
@@ -0,0 +1,476 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto.SingleData;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Options;
|
||||
using BarCode.Web.Domain.Values.Single;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// 单点数据返回服务
|
||||
/// </summary>
|
||||
public class SingleDataService : ISingleDataService
|
||||
{
|
||||
private readonly AppOptions _options;
|
||||
private readonly IHttpClientService _httpClientService;
|
||||
private readonly ILogger<SingleDataService> _logger;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private int hours = 10;//过期时间 默认10小时
|
||||
|
||||
public SingleDataService(IOptions<AppOptions> options, IHttpClientService httpClientService, ILogger<SingleDataService> logger, IMemoryCache memoryCache)
|
||||
{
|
||||
this._memoryCache = memoryCache;
|
||||
this._options = options?.Value;
|
||||
this._httpClientService = httpClientService;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据:根据接口方法名和公司ID
|
||||
/// 后端列表查询统一使用
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetSingleData(SingleAction action, int companyId, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id == 0)
|
||||
return "";
|
||||
|
||||
var cache_key = action + "_" + companyId + "_IdGetName";
|
||||
var dic = _memoryCache.Get<Dictionary<int, string>>(cache_key);
|
||||
if (dic == null || dic.Count <= 0 || !dic.ContainsKey(id))
|
||||
{
|
||||
if (dic != null)
|
||||
{
|
||||
|
||||
string no_data_key = cache_key + "_NoData";
|
||||
var cache_id = _memoryCache.Get<bool>(no_data_key);
|
||||
if (cache_id == true) return "";
|
||||
//未找到数据请求
|
||||
if (!dic.ContainsKey(id))
|
||||
{
|
||||
_memoryCache.Set(no_data_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30)));
|
||||
}
|
||||
}
|
||||
var list = SingleDataPost<SingleDataResponse>(action, companyId, cache_key);
|
||||
if (list.Count() <= 0) return "";
|
||||
dic = list.ToDictionary(s => s.Id, s => s.Name);
|
||||
_memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours)));
|
||||
}
|
||||
if (!dic.ContainsKey(id)) return "";
|
||||
return dic[id];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:Action->{action.ToString()},CompanyeId->{companyId},Id->{id},(错误原因)=>{ex.Message}");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据:根据接口方法名和公司ID
|
||||
/// 后端列表查询统一使用
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public decimal GetSingleDataNumber(SingleAction action, int companyId, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id == 0)
|
||||
return 0;
|
||||
|
||||
var cache_key = action + "_" + companyId + "_IdGetNumber";
|
||||
var dic = _memoryCache.Get<Dictionary<int, decimal>>(cache_key);
|
||||
if (dic == null || dic.Count <= 0 || !dic.ContainsKey(id))
|
||||
{
|
||||
if (dic != null)
|
||||
{
|
||||
string no_data_key = cache_key + "_NoData";
|
||||
var cache_id = _memoryCache.Get<bool>(no_data_key);
|
||||
if (cache_id == true) return 0;
|
||||
//未找到数据请求
|
||||
if (!dic.ContainsKey(id))
|
||||
{
|
||||
_memoryCache.Set(no_data_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30)));
|
||||
}
|
||||
}
|
||||
|
||||
var list = SingleDataPost<SingleDataResponse>(action, companyId, cache_key);
|
||||
if (list.Count() <= 0) return 0;
|
||||
|
||||
dic = list.ToDictionary(s => s.Id, s => s.Number);
|
||||
_memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours)));
|
||||
}
|
||||
|
||||
if (!dic.ContainsKey(id)) return 0;
|
||||
return dic[id];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据:根据接口方法名和公司ID
|
||||
/// 后端列表查询统一使用
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetSingleDataCode(SingleAction action, int companyId, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id == 0)
|
||||
return "";
|
||||
|
||||
var cache_key = action + "_" + companyId + "_IdGetCode";
|
||||
var dic = _memoryCache.Get<Dictionary<int, string>>(cache_key);
|
||||
if (dic == null || dic.Count <= 0 || !dic.ContainsKey(id))
|
||||
{
|
||||
if (dic != null)
|
||||
{
|
||||
string no_data_key = cache_key + "_NoData";
|
||||
var cache_id = _memoryCache.Get<bool>(no_data_key);
|
||||
if (cache_id == true) return "";
|
||||
//未找到数据请求
|
||||
if (!dic.ContainsKey(id))
|
||||
{
|
||||
_memoryCache.Set(no_data_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30)));
|
||||
}
|
||||
}
|
||||
|
||||
var list = SingleDataPost<SingleDataResponse>(action, companyId, cache_key);
|
||||
if (list.Count() <= 0) return "";
|
||||
|
||||
dic = list.ToDictionary(s => s.Id, s => s.Code);
|
||||
_memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours)));
|
||||
}
|
||||
|
||||
if (!dic.ContainsKey(id)) return "";
|
||||
return dic[id];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据名字模糊匹配
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public List<int> GetIdsBySingleName(SingleAction action, int companyId, string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cache_key = action + "_" + companyId + "_NameGetIds";
|
||||
var dic = _memoryCache.Get<Dictionary<int, string>>(cache_key);
|
||||
if (dic == null || dic.Count <= 0)
|
||||
{
|
||||
var list = SingleDataPost<SingleDataResponse>(action, companyId, cache_key);
|
||||
if (list.Count() <= 0) return new List<int>();
|
||||
|
||||
dic = list.ToDictionary(s => s.Id, s => s.Name);
|
||||
_memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours)));
|
||||
}
|
||||
var res = from d in dic where d.Value.Contains(name) select d;
|
||||
return res.Select(s => s.Key).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return new List<int>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据:根据接口方法名和公司ID
|
||||
/// 后端列表查询统一使用
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public string GetSingleData(SingleAction action, int companyId, string code)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(code))
|
||||
return "";
|
||||
|
||||
var cache_key = action + "_" + companyId + "_CodeGetName";
|
||||
var dic = _memoryCache.Get<Dictionary<string, string>>(cache_key);
|
||||
//仓库和客户仓库 不能为空了就重新请求 应为 这里是从仓库和客户仓库取值 有一个必然取不到
|
||||
if (dic == null || dic.Count <= 0)
|
||||
{
|
||||
if (dic != null)
|
||||
{
|
||||
string no_data_key = cache_key + "_NoData";
|
||||
var cache_id = _memoryCache.Get<bool>(no_data_key);
|
||||
if (cache_id == true) return "";
|
||||
//未找到数据请求
|
||||
if (!dic.ContainsKey(code))
|
||||
{
|
||||
_memoryCache.Set(no_data_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30)));
|
||||
}
|
||||
}
|
||||
|
||||
var list = SingleDataPost<SingleDataResponse>(action, companyId, cache_key);
|
||||
|
||||
var json = JsonConvert.SerializeObject(list);
|
||||
if (list.Count() <= 0) return "";
|
||||
|
||||
dic = list.ToDictionary(s => s.Code, s => s.Name);
|
||||
_memoryCache.Set(cache_key, dic, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours)));
|
||||
}
|
||||
|
||||
if (!dic.ContainsKey(code)) return "";
|
||||
var name = dic[code];
|
||||
return dic[code];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据集合:泛型-同步
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public List<T> GetSingleData<T>(SingleAction action, int companyId) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
var cache_key = action + "_list_" + companyId;
|
||||
var list = _memoryCache.Get<List<T>>(cache_key);
|
||||
if (list == null || list.Count <= 0)
|
||||
list = SingleDataPost<T>(action, companyId, cache_key);
|
||||
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据集合:泛型-异步
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<T>> GetSingleDataAsync<T>(SingleAction action, int companyId) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
var cache_key = action + "_list_" + companyId;
|
||||
var list = _memoryCache.Get<List<T>>(cache_key);
|
||||
if (list == null || list.Count <= 0)
|
||||
list = await SingleDataPostAsync<T>(action, companyId, cache_key);
|
||||
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据集合:泛型-异步-无缓存
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<T>> GetSingleDataNoCacheAsync<T>(SingleAction action, int companyId) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = await SingleDataPostAsync<T>(action, companyId, "");
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单点数据:可对接全部接口
|
||||
/// </summary>
|
||||
/// <typeparam name="T">返回对象</typeparam>
|
||||
/// <typeparam name="X">请求对象</typeparam>
|
||||
/// <typeparam name="Y">方法名称</typeparam>
|
||||
/// <param name="dto">请求对象</param>
|
||||
/// <param name="action">方法名称</param>
|
||||
/// <param name="type">控制器名称</param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> GetSingleData<T, X, Y>(X dto, Y action, SingleControllerType type = SingleControllerType.Single) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
var para = JsonConvert.SerializeObject(dto);
|
||||
var cache_key = action + "_list_" + type + "_" + para;
|
||||
var list = _memoryCache.Get<T>(cache_key);
|
||||
if (list == null)
|
||||
{
|
||||
var url = _options.SingleBaseUrl + "/" + type.ToString() + "/" + action.ToString();
|
||||
var result = await _httpClientService.PostAsync<T>(url, para);
|
||||
_memoryCache.Set(cache_key, result, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours)));
|
||||
}
|
||||
return _memoryCache.Get<T>(cache_key);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单点数据:可对接全部接口
|
||||
/// </summary>
|
||||
/// <typeparam name="T">返回对象</typeparam>
|
||||
/// <typeparam name="X">请求对象</typeparam>
|
||||
/// <typeparam name="Y">方法名称</typeparam>
|
||||
/// <param name="dto">请求对象</param>
|
||||
/// <param name="action">方法名称</param>
|
||||
/// <param name="type">控制器名称</param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> GetSingleDataNoCache<T, X, Y>(X dto, Y action, SingleControllerType type = SingleControllerType.Single) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
var para = JsonConvert.SerializeObject(dto);
|
||||
var url = _options.SingleBaseUrl + "/" + type.ToString() + "/" + action.ToString();
|
||||
var result = await _httpClientService.PostAsync<T>(url, para);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单点数据:配置项接口
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="X"></typeparam>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<T> GetSysConfigData<T, X>(X dto, SysConfigAction action)
|
||||
{
|
||||
try
|
||||
{
|
||||
var para = JsonConvert.SerializeObject(dto);
|
||||
var url = _options.SingleBaseUrl + "/" + SingleControllerType.SysConfig.ToString() + "/" + action.ToString();
|
||||
var result = await _httpClientService.PostAsync<T>(url, para);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"请求单点数据错误:{action.ToString()}=>{ex.Message}");
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 私有方法
|
||||
|
||||
/// <summary>
|
||||
/// 请求单点服务接口:同步
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
private List<T> SingleDataPost<T>(SingleAction action, int companyId, string cache_key)
|
||||
{
|
||||
var dto = new SingleDataRequest(companyId);
|
||||
//var para = JsonExtensions.SerializeToJson(dto);
|
||||
var para = JsonConvert.SerializeObject(dto);
|
||||
var url = _options.SingleBaseUrl + "/" + SingleControllerType.Single.ToString() + "/" + action.ToString();
|
||||
var result = _httpClientService.PostAsync<ResultList<T>>(url, para).GetAwaiter().GetResult();
|
||||
if (!result.Success)
|
||||
return new List<T>();
|
||||
return result.Data.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 请求单点服务接口:异步
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<T>> SingleDataPostAsync<T>(SingleAction action, int companyId, string cache_key)
|
||||
{
|
||||
var dto = new SingleDataRequest(companyId);
|
||||
var para = JsonConvert.SerializeObject(dto);
|
||||
var url = _options.SingleBaseUrl + "/" + SingleControllerType.Single.ToString() + "/" + action.ToString();
|
||||
var result = await _httpClientService.PostAsync<ResultList<T>>(url, para);
|
||||
if (result.Success)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(cache_key))
|
||||
{
|
||||
_memoryCache.Set(cache_key, result.Data.ToList(), new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(hours)));
|
||||
return _memoryCache.Get<List<T>>(cache_key);
|
||||
}
|
||||
return result.Data.ToList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 获取客户仓库
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <param name="customerStockCode"></param>
|
||||
/// <returns></returns>
|
||||
public string GetCustomerStock(int companyId, string customerStockCode)
|
||||
{
|
||||
return string.IsNullOrEmpty(this.GetSingleData(SingleAction.CustomerStocks, companyId, customerStockCode)) ?
|
||||
this.GetSingleData(SingleAction.Stocks, companyId, customerStockCode) :
|
||||
this.GetSingleData(SingleAction.CustomerStocks, companyId, customerStockCode);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
57
src/BarCode.Web.Domain/Services/Public/WmsService.cs
Normal file
57
src/BarCode.Web.Domain/Services/Public/WmsService.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Options;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Core.Dto.Box;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using BarCode.Web.Domain.Values;
|
||||
|
||||
namespace BarCode.Web.Domain.Services.Public
|
||||
{
|
||||
/// <summary>
|
||||
/// ops服务
|
||||
/// </summary>
|
||||
public class WmsService : IWmsService
|
||||
{
|
||||
private readonly IHttpClientService _httpClientService;
|
||||
private readonly ILogger<WmsService> _logger;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private int hours = 10;//过期时间 默认10小时
|
||||
private readonly WmsOptions _option;
|
||||
|
||||
public WmsService(IHttpClientService httpClientService, ILogger<WmsService> logger,
|
||||
IMemoryCache memoryCache, IOptions<WmsOptions> option)
|
||||
{
|
||||
this._memoryCache = memoryCache;
|
||||
this._httpClientService = httpClientService;
|
||||
this._logger = logger;
|
||||
_option = option.Value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 重置箱信息
|
||||
/// </summary>
|
||||
/// <param name="boxBillNos"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result<List<string>>> Restart(List<string> boxBillNos)
|
||||
{
|
||||
OperateStrRequest request = new OperateStrRequest()
|
||||
{
|
||||
Ids = boxBillNos
|
||||
};
|
||||
|
||||
_logger.LogInformation($"重置箱 请求参数:{JsonConvert.SerializeObject(request)}");
|
||||
var res = await _httpClientService.PostAsync<Result<List<string>>>(_option.Url + "api/BarCode/Restart", JsonConvert.SerializeObject(request));
|
||||
_logger.LogInformation($"重置箱 返回参数:{JsonConvert.SerializeObject(res)}");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
73
src/BarCode.Web.Domain/Services/QiniuUploadService.cs
Normal file
73
src/BarCode.Web.Domain/Services/QiniuUploadService.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Qiniu.Http;
|
||||
using Qiniu.Storage;
|
||||
using Qiniu.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using BarCode.Web.Domain.Options;
|
||||
|
||||
namespace BarCode.Web.Domain.Services
|
||||
{
|
||||
public class QiniuUploadService : IQiniuUploadService
|
||||
{
|
||||
private readonly QiniuOptions _option;
|
||||
public QiniuUploadService(IOptions<QiniuOptions> option)
|
||||
{
|
||||
_option = option?.Value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 上传文件
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="isAutoDelte"></param>
|
||||
/// <returns></returns>
|
||||
public Task<Result<string>> Upload(string fileName, Stream stream, bool isAutoDelte = false)
|
||||
{
|
||||
// 生成(上传)凭证时需要使用此Mac
|
||||
// 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey
|
||||
// 实际应用中,请自行设置您的AccessKey和SecretKey
|
||||
Mac mac = new Mac(_option.AccessKey, _option.SecretKey);
|
||||
|
||||
PutPolicy putPolicy = new PutPolicy();
|
||||
// 如果需要设置为"覆盖"上传(如果云端已有同名文件则覆盖),请使用 SCOPE = "BUCKET:KEY"
|
||||
putPolicy.Scope = _option.Bucket + ":" + fileName;
|
||||
// putPolicy.Scope = bucket;
|
||||
// 上传策略有效期(对应于生成的凭证的有效期)
|
||||
putPolicy.SetExpires(3600);
|
||||
// 上传到云端多少天后自动删除该文件,如果不设置(即保持默认默认)则不删除
|
||||
if (isAutoDelte)
|
||||
putPolicy.DeleteAfterDays = 7;
|
||||
string jstr = putPolicy.ToJsonString();
|
||||
string token = Auth.CreateUploadToken(mac, jstr);
|
||||
|
||||
Config config = new Config();
|
||||
// 空间对应的机房 华 东 ZONE_CN_East 华 北 ZONE_CN_North 华 南 ZONE_CN_Sout 北 美 ZONE_US_North 东南亚 ZONE_AS_Singapore
|
||||
config.Zone = Zone.ZONE_CN_South;
|
||||
// 是否使用https域名
|
||||
config.UseHttps = true;
|
||||
// 上传是否使用cdn加速
|
||||
config.UseCdnDomains = true;
|
||||
HttpResult result = null;
|
||||
try
|
||||
{
|
||||
FormUploader fu = new FormUploader(config);
|
||||
result = fu.UploadStream(stream, fileName, token, null);
|
||||
if (result.Code == 200)
|
||||
return Task.FromResult(Result<string>.ReSuccess(_option.Url + fileName));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
return Task.FromResult(Result<string>.ReFailure("上传文件失败" + ex.ToString(), 0));
|
||||
}
|
||||
return Task.FromResult(Result<string>.ReFailure("上传文件失败" + JsonConvert.SerializeObject(result), 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
234
src/BarCode.Web.Domain/Services/SecurityNumberService.cs
Normal file
234
src/BarCode.Web.Domain/Services/SecurityNumberService.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SecurityNumbers;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using BarCode.Web.Domain.Infrastructure;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Services.Public;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using BarCode.Web.Domain.Values.Single;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 防伪码
|
||||
/// </summary>
|
||||
public class SecurityNumberService : ISecurityNumberService
|
||||
{
|
||||
private readonly ISecurityNumbersRepositories _securityNumbersRepositories;
|
||||
private readonly ISecurityGenerateRecordRepositories _sGenerateRecordRepositories;
|
||||
private readonly RedisClientService _redisClientService;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly ILogger<SecurityNumberService> _logger;
|
||||
private IBasicsRepositories _transactionRepositories;
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
/// <summary>
|
||||
/// 序列号服务
|
||||
/// </summary>
|
||||
/// <param name="SecurityNumbersRepositories"></param>
|
||||
/// <param name="sGenerateRecordRepositories"></param>
|
||||
/// <param name="redisClientService"></param>
|
||||
/// <param name="serviceScopeFactory"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="transactionRepositories"></param>
|
||||
public SecurityNumberService(ISecurityNumbersRepositories securityNumbersRepositories,
|
||||
ISecurityGenerateRecordRepositories sGenerateRecordRepositories,
|
||||
RedisClientService redisClientService,
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
ILogger<SecurityNumberService> logger, IBasicsRepositories transactionRepositories,
|
||||
ISingleDataService singleDataService)
|
||||
{
|
||||
_securityNumbersRepositories = securityNumbersRepositories;
|
||||
_sGenerateRecordRepositories = sGenerateRecordRepositories;
|
||||
_redisClientService = redisClientService;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_logger = logger;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_singleDataService = singleDataService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> DownLoad(OperateSecurityNumberRequest dto)
|
||||
{
|
||||
//取出所有的生成记录
|
||||
var generateRecords = await _sGenerateRecordRepositories.GetEntityList(dto.GenerateRecordIds);
|
||||
if (generateRecords.Count() != dto.GenerateRecordIds.Count())
|
||||
return Result.ReFailure(ResultCodes.NoDateError);
|
||||
var snGRList = await _securityNumbersRepositories.GetEntityListByGRIds(dto.GenerateRecordIds);
|
||||
//修改序列号下载数
|
||||
List<SecurityNumbers> olist = new List<SecurityNumbers>();
|
||||
if (dto.IsAll)
|
||||
olist = snGRList;
|
||||
else
|
||||
{
|
||||
olist = snGRList.Where(w => dto.SecurityNumbers.Contains(w.SecurityNumber)).ToList();
|
||||
}
|
||||
olist.ForEach(f => f.DownLoad());
|
||||
|
||||
|
||||
foreach (var g in generateRecords)
|
||||
{
|
||||
int downLoad = snGRList.Where(w => w.GenerateRecordId == g.Id && w.DownLoadNumber > 0).Count();
|
||||
g.DownLoad(downLoad);
|
||||
}
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool res_Rollback = false;
|
||||
bool isSuccess = true;
|
||||
if (dto.IsAll)
|
||||
{
|
||||
//为了增加速度 执行所有时直接执行sql语句
|
||||
isSuccess = await _securityNumbersRepositories.DownLoad(dto.GenerateRecordIds, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isSuccess = await _securityNumbersRepositories.EditEntityList(olist, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
}
|
||||
if (!res_Rollback)
|
||||
{
|
||||
var res = await _sGenerateRecordRepositories.EditEntityList(generateRecords, false);
|
||||
if (!res) res_Rollback = true;
|
||||
}
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成防伪码
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public Task<Result> Generate(GenerateSecurityNumberRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
_logger.LogInformation($"生成防伪码:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}");
|
||||
var info = _redisClientService.GetStringKey<bool>($"barcode_cenerate_security");
|
||||
if (info == true) return Task.FromResult(Result.ReFailure(ResultCodes.SecurityNumberG));
|
||||
_redisClientService.SetStringKey($"barcode_cenerate_security", true, TimeSpan.FromMinutes(5));
|
||||
|
||||
string supplierCode = "";
|
||||
string orgCode = "";
|
||||
if (dto.OrgCode.Substring(0, 1).Equals("s"))
|
||||
supplierCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2);
|
||||
else
|
||||
orgCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2);
|
||||
|
||||
var number = _sGenerateRecordRepositories.GetGenerateRecordDayCount().GetAwaiter().GetResult();
|
||||
number = number + 1;//从1开始
|
||||
SecurityNumberGenerateRecord sg = new SecurityNumberGenerateRecord()
|
||||
{
|
||||
CompanyId = loginInfo.UserInfo.CompanyId,
|
||||
CreateTime = DateTime.Now,
|
||||
CreatorId = loginInfo.UserInfo.UcId,
|
||||
OrgCode = orgCode,
|
||||
SupplierCode = supplierCode,
|
||||
MaterialNumber = dto.MaterialNumber,
|
||||
Number = dto.Number
|
||||
};
|
||||
sg.GenerateLotNumber(number);
|
||||
var isRes = _sGenerateRecordRepositories.Add(sg).GetAwaiter().GetResult();
|
||||
if (isRes == null) Task.FromResult(Result.ReFailure(ResultCodes.DateWriteError));
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await GenerateSecurityNumber(new List<SecurityNumberGenerateRecord>() { sg });
|
||||
});
|
||||
|
||||
_redisClientService.SetStringKey($"barcode_cenerate_security", false, TimeSpan.FromMinutes(5));
|
||||
return Task.FromResult(Result.ReSuccess());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 循环生成序列码
|
||||
/// </summary>
|
||||
/// <param name="sgList"></param>
|
||||
private async Task GenerateSecurityNumber(List<SecurityNumberGenerateRecord> sgList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var info = _redisClientService.GetStringKey<bool>($"cenerate_security_exec");
|
||||
if (info == true)
|
||||
{
|
||||
//如果当前有在生成的计划 则挂起 等生成完成
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
info = _redisClientService.GetStringKey<bool>($"cenerate_security_exec");
|
||||
if (info != true)
|
||||
break;
|
||||
}
|
||||
}
|
||||
_redisClientService.SetStringKey($"cenerate_security_exec", true, TimeSpan.FromMinutes(30));
|
||||
_logger.LogInformation($"生成防伪码开始:{DateTime.Now}-{JsonConvert.SerializeObject(sgList)}");
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
bool isSuccess = true;
|
||||
bool res_Rollback = false;
|
||||
var _snRepositories = scope.ServiceProvider.GetRequiredService<ISecurityNumbersRepositories>();
|
||||
var _sgRepositories = scope.ServiceProvider.GetRequiredService<ISecurityGenerateRecordRepositories>();
|
||||
_transactionRepositories = scope.ServiceProvider.GetRequiredService<IBasicsRepositories>();
|
||||
|
||||
foreach (var sg in sgList)
|
||||
{
|
||||
List<SecurityNumbers> sList = new List<SecurityNumbers>();
|
||||
for (int i = 1; i <= sg.Number; i++)
|
||||
{
|
||||
SecurityNumbers s = new SecurityNumbers()
|
||||
{
|
||||
CreateTime = DateTime.Now,
|
||||
CreatorId = sg.CreatorId,
|
||||
OrgCode = sg.OrgCode,
|
||||
SupplierCode = sg.SupplierCode,
|
||||
MaterialNumber = sg.MaterialNumber,
|
||||
GenerateRecordId = sg.Id
|
||||
};
|
||||
sList.Add(s);
|
||||
}
|
||||
|
||||
//一个生成记录一个事物,这样能一条条记录对应的生成下去 成功一个是一个
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
var isRes = await _snRepositories.AddRange(sList, false);
|
||||
if (!isRes)
|
||||
res_Rollback = true;
|
||||
|
||||
if (!res_Rollback)
|
||||
{
|
||||
sg.Complete();//生成完成
|
||||
var sg_entity = await _sgRepositories.Edit(sg, false);
|
||||
if (sg_entity == null)
|
||||
res_Rollback = true;
|
||||
}
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
|
||||
if (res_Rollback || !isSuccess)
|
||||
_logger.LogError("生成防伪码数据操作失败");
|
||||
}
|
||||
}
|
||||
_redisClientService.SetStringKey($"cenerate_security_exec", false, TimeSpan.FromMinutes(30));
|
||||
_logger.LogInformation($"生成防伪码结束 {DateTime.Now}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($" 生成防伪码异常:{ex.ToString} {JsonConvert.SerializeObject(sgList)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
423
src/BarCode.Web.Domain/Services/SerialNumberService.cs
Normal file
423
src/BarCode.Web.Domain/Services/SerialNumberService.cs
Normal file
@@ -0,0 +1,423 @@
|
||||
using BarCode.Web.Core.Dto;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using BarCode.Web.Core.Dto.Login;
|
||||
using BarCode.Web.Core.Dto.SerialNumbers;
|
||||
using BarCode.Web.Core.Internal.Results;
|
||||
using BarCode.Web.Domain.Entitys;
|
||||
using BarCode.Web.Domain.Infrastructure;
|
||||
using BarCode.Web.Domain.IService;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Services.Public;
|
||||
using BarCode.Web.Domain.Values;
|
||||
using BarCode.Web.Domain.Values.Single;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.HPSF;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列号服务
|
||||
/// </summary>
|
||||
public class SerialNumberService : ISerialNumberService
|
||||
{
|
||||
private readonly ISerialNumbersRepositories _serialNumbersRepositories;
|
||||
private readonly ISGenerateRecordRepositories _sGenerateRecordRepositories;
|
||||
private readonly RedisClientService _redisClientService;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly ILogger<SerialNumberService> _logger;
|
||||
private IBasicsRepositories _transactionRepositories;
|
||||
private ICenerateDataRepositories _cenerateDataRepositories;
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly IErpService _erpService;
|
||||
/// <summary>
|
||||
/// 序列号服务
|
||||
/// </summary>
|
||||
/// <param name="serialNumbersRepositories"></param>
|
||||
/// <param name="sGenerateRecordRepositories"></param>
|
||||
/// <param name="redisClientService"></param>
|
||||
/// <param name="serviceScopeFactory"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="transactionRepositories"></param>
|
||||
/// <param name="cenerateDataRepositories"></param>
|
||||
public SerialNumberService(ISerialNumbersRepositories serialNumbersRepositories,
|
||||
ISGenerateRecordRepositories sGenerateRecordRepositories,
|
||||
RedisClientService redisClientService,
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
ILogger<SerialNumberService> logger, IBasicsRepositories transactionRepositories,
|
||||
ICenerateDataRepositories cenerateDataRepositories, ISingleDataService singleDataService, IErpService erpService)
|
||||
{
|
||||
_serialNumbersRepositories = serialNumbersRepositories;
|
||||
_sGenerateRecordRepositories = sGenerateRecordRepositories;
|
||||
_redisClientService = redisClientService;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_logger = logger;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_cenerateDataRepositories = cenerateDataRepositories;
|
||||
_singleDataService = singleDataService;
|
||||
_erpService = erpService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成序列号
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="loginInfo"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public Task<Result> Generate(GenerateSerialNumberRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
if (dto.Details.Count() == 0) return Task.FromResult(Result.ReSuccess());
|
||||
//if (dto.Details.Count() > 1000) return Task.FromResult(Result.ReFailure(ResultCodes.SerialGenerateBigNumber));
|
||||
|
||||
_logger.LogInformation($"生成序列号:{JsonConvert.SerializeObject(dto)},用户:{loginInfo.UserInfo.Nickname}");
|
||||
var info = _redisClientService.GetStringKey<bool>($"barcode_cenerate_serial");
|
||||
if (info == true) return Task.FromResult(Result.ReFailure(ResultCodes.SerialNumberG));
|
||||
_redisClientService.SetStringKey($"barcode_cenerate_serial", true, TimeSpan.FromMinutes(5));
|
||||
|
||||
var materials_result = _erpService.BillQueryForMaterial().GetAwaiter().GetResult();
|
||||
List<ErpMaterialDto> materials = new List<ErpMaterialDto>();
|
||||
if (materials_result.IsSuccess)
|
||||
materials = materials_result.Data.ToList();
|
||||
|
||||
|
||||
|
||||
var cList = dto.Details.GroupBy(g => g.Specifications).Select(s => s.Key).ToList();
|
||||
foreach (var s in cList)
|
||||
{
|
||||
var m = materials.FirstOrDefault(w => w.Specifications.Equals(s));
|
||||
var details = dto.Details.Where(w => w.Specifications.Equals(s)).ToList();
|
||||
if (m == null)
|
||||
{
|
||||
details.ForEach(f => dto.Details.Remove(f));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var de in details)
|
||||
{
|
||||
de.MaterialNumber = m.MaterialNumber;
|
||||
de.IdConvertBar = m.IdConvertBar;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string supplierCode = "";
|
||||
string orgCode = "";
|
||||
if (dto.OrgCode.Substring(0, 1).Equals("s"))
|
||||
supplierCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2);
|
||||
else
|
||||
orgCode = dto.OrgCode.Substring(2, dto.OrgCode.Length - 2);
|
||||
|
||||
|
||||
|
||||
var dataEntity = _cenerateDataRepositories.Get(CenerateDataType.Serial).GetAwaiter().GetResult();
|
||||
int beginNumber = dataEntity.Number;
|
||||
if (beginNumber == 0)
|
||||
dataEntity.Number = dto.Details.Sum(s => s.Number);
|
||||
else
|
||||
dataEntity.Number += dto.Details.Sum(s => s.Number);
|
||||
|
||||
|
||||
List<SerialNumberGenerateRecord> sgList = new List<SerialNumberGenerateRecord>();
|
||||
foreach (var d in dto.Details)
|
||||
{
|
||||
if (d.isTwo == 0)//如果套装数为0,那么自动变成1
|
||||
{
|
||||
d.isTwo = 1;
|
||||
}
|
||||
else if(d.isTwo==2)
|
||||
{
|
||||
int result = d.Number % d.isTwo;
|
||||
|
||||
if (result !=0)//
|
||||
{
|
||||
return Task.FromResult(Result.ReFailure(ResultCodes.IsTwoError));
|
||||
}
|
||||
}
|
||||
else if(d.isTwo>2)
|
||||
{
|
||||
return Task.FromResult(Result.ReFailure(ResultCodes.IsTwoError));
|
||||
}
|
||||
|
||||
SerialNumberGenerateRecord sg = new SerialNumberGenerateRecord()
|
||||
{
|
||||
CompanyId = loginInfo.UserInfo.CompanyId,
|
||||
CreateTime = DateTime.Now,
|
||||
CreatorId = loginInfo.UserInfo.UcId,
|
||||
OrgCode = orgCode,
|
||||
IdConvertBar = d.IdConvertBar,
|
||||
MaterialNumber = d.MaterialNumber,
|
||||
Number = d.Number,
|
||||
BeginNumber = beginNumber,
|
||||
PurchaseBillNo = d.PurchaseBillNo,
|
||||
SupplierCode = supplierCode,
|
||||
IsTwo=d.isTwo//alter by yzh
|
||||
|
||||
};
|
||||
//下一个物料开始数量要重新赋值
|
||||
beginNumber = beginNumber + d.Number;
|
||||
sgList.Add(sg);
|
||||
}
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool res_Rollback = false;
|
||||
|
||||
var isSuccess = _sGenerateRecordRepositories.AddRange(sgList, false).GetAwaiter().GetResult();
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
|
||||
if (!res_Rollback)
|
||||
{
|
||||
var entity = _cenerateDataRepositories.Edit(dataEntity, false).GetAwaiter().GetResult();
|
||||
if (entity == null) res_Rollback = true;
|
||||
}
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
if (!isSuccess) return Task.FromResult(Result.ReFailure(ResultCodes.DateWriteError));
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await GenerateSerialNumber(sgList);
|
||||
});
|
||||
|
||||
_redisClientService.SetStringKey($"barcode_cenerate_serial", false, TimeSpan.FromMinutes(5));
|
||||
return Task.FromResult(Result.ReSuccess());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 循环生成序列码
|
||||
/// </summary>
|
||||
/// <param name="sgList"></param>
|
||||
/// <param name="beginNumber"></param>
|
||||
private async Task GenerateSerialNumber(List<SerialNumberGenerateRecord> sgList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var info = _redisClientService.GetStringKey<bool>($"cenerate_serial_exec");
|
||||
if (info == true)
|
||||
{
|
||||
//如果当前有在生成的计划 则挂起 等生成完成
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
info = _redisClientService.GetStringKey<bool>($"cenerate_serial_exec");
|
||||
if (info != true)
|
||||
break;
|
||||
}
|
||||
}
|
||||
_redisClientService.SetStringKey($"cenerate_serial_exec", true, TimeSpan.FromMinutes(30));
|
||||
|
||||
_logger.LogInformation($"生成序列码开始:{DateTime.Now}-{JsonConvert.SerializeObject(sgList)}");
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
bool isSuccess = true;
|
||||
bool res_Rollback = false;
|
||||
var _snRepositories = scope.ServiceProvider.GetRequiredService<ISerialNumbersRepositories>();
|
||||
var _sgRepositories = scope.ServiceProvider.GetRequiredService<ISGenerateRecordRepositories>();
|
||||
_transactionRepositories = scope.ServiceProvider.GetRequiredService<IBasicsRepositories>();
|
||||
|
||||
foreach (var sg in sgList)
|
||||
{
|
||||
List<SerialNumbers> sList = new List<SerialNumbers>();
|
||||
for (int i = 0; i < sg.Number; i++)
|
||||
{
|
||||
SerialNumbers s = new SerialNumbers()
|
||||
{
|
||||
CreateTime = DateTime.Now,
|
||||
CreatorId = sg.CreatorId,
|
||||
OrgCode = sg.OrgCode,
|
||||
SupplierCode = sg.SupplierCode,
|
||||
SerialNumber = sg.IdConvertBar,
|
||||
MaterialNumber = sg.MaterialNumber,
|
||||
Number = sg.BeginNumber + i,
|
||||
IsTwo = sg.IsTwo,
|
||||
thisNumber = i+1,//alter by yzh
|
||||
GenerateRecordId = sg.Id
|
||||
};
|
||||
sList.Add(s);
|
||||
}
|
||||
|
||||
//一个生成记录一个事物,这样能一条条记录对应的生成下去 成功一个是一个
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
var isRes = await _snRepositories.AddRange(sList, false);
|
||||
if (!isRes)
|
||||
res_Rollback = true;
|
||||
|
||||
if (!res_Rollback)
|
||||
{
|
||||
sg.Complete();//生成完成
|
||||
var sg_entity = await _sgRepositories.Edit(sg, false);
|
||||
if (sg_entity == null)
|
||||
res_Rollback = true;
|
||||
}
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
|
||||
if (res_Rollback || !isSuccess)
|
||||
_logger.LogError("生成序列码数据操作失败");
|
||||
}
|
||||
}
|
||||
_redisClientService.SetStringKey($"cenerate_serial_exec", false, TimeSpan.FromMinutes(30));
|
||||
_logger.LogInformation($"生成序列码结束{DateTime.Now}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"生成序列码异常:{ex.ToString}");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> DownLoad(OperateSerialNumberRequest dto)
|
||||
{
|
||||
//取出所有的生成记录
|
||||
var generateRecords = await _sGenerateRecordRepositories.GetEntityList(dto.GenerateRecordIds);
|
||||
if (generateRecords.Count() != dto.GenerateRecordIds.Count())
|
||||
return Result.ReFailure(ResultCodes.NoDateError);
|
||||
var snGRList = await _serialNumbersRepositories.GetEntityListByGRIds(dto.GenerateRecordIds);
|
||||
//修改序列号下载数
|
||||
List<SerialNumbers> olist = new List<SerialNumbers>();
|
||||
if (dto.IsAll)
|
||||
olist = snGRList;
|
||||
else
|
||||
{
|
||||
olist = snGRList.Where(w => dto.SerialNumbers.Contains(w.SerialNumber)).ToList();
|
||||
}
|
||||
olist.ForEach(f => f.DownLoad());
|
||||
|
||||
|
||||
foreach (var g in generateRecords)
|
||||
{
|
||||
int downLoad = snGRList.Where(w => w.GenerateRecordId == g.Id && w.DownLoadNumber > 0).Count();
|
||||
g.DownLoad(downLoad);
|
||||
}
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool res_Rollback = false;
|
||||
|
||||
var isSuccess = await _serialNumbersRepositories.EditEntityList(olist, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
if (!res_Rollback)
|
||||
{
|
||||
var res = await _sGenerateRecordRepositories.EditEntityList(generateRecords, false);
|
||||
if (!res) res_Rollback = true;
|
||||
}
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> Print(OperateSerialNumberRequest dto)
|
||||
{
|
||||
//取出所有的生成记录
|
||||
var generateRecords = await _sGenerateRecordRepositories.GetEntityList(dto.GenerateRecordIds);
|
||||
if (generateRecords.Count() != dto.GenerateRecordIds.Count())
|
||||
return Result.ReFailure(ResultCodes.NoDateError);
|
||||
var snGRList = await _serialNumbersRepositories.GetEntityListByGRIds(dto.GenerateRecordIds);
|
||||
//修改序列号下载数
|
||||
List<SerialNumbers> olist = new List<SerialNumbers>();
|
||||
if (dto.IsAll)
|
||||
olist = snGRList;
|
||||
else
|
||||
{
|
||||
olist = snGRList.Where(w => dto.SerialNumbers.Contains(w.SerialNumber)).ToList();
|
||||
}
|
||||
olist.ForEach(f => f.Print());
|
||||
|
||||
foreach (var g in generateRecords)
|
||||
{
|
||||
int printNumber = snGRList.Where(w => w.GenerateRecordId == g.Id && w.PrintNumber > 0).Count();
|
||||
g.Print(printNumber);
|
||||
|
||||
}
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool res_Rollback = false;
|
||||
|
||||
var isSuccess = await _serialNumbersRepositories.EditEntityList(olist, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
if (!res_Rollback)
|
||||
{
|
||||
var res = await _sGenerateRecordRepositories.EditEntityList(generateRecords, false);
|
||||
if (!res) res_Rollback = true;
|
||||
}
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 反写使用数
|
||||
/// </summary>
|
||||
/// <param name="sGIds"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Use(List<int> sGIds)
|
||||
{
|
||||
var sGList = await _sGenerateRecordRepositories.GetEntityList(sGIds);
|
||||
var sGSNumberList = await _serialNumbersRepositories.GetEntityListByGRIds(sGIds);
|
||||
|
||||
foreach (var sg in sGList)
|
||||
{
|
||||
int number = sGSNumberList.Where(w => w.GenerateRecordId == sg.Id && w.BoxId > 0).Count();
|
||||
sg.Use(number);
|
||||
}
|
||||
|
||||
var isSuccess = await _sGenerateRecordRepositories.EditEntityList(sGList, false);
|
||||
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改序列码物料
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<Result> UpdateMaterial(UpdateMaterialRequest dto)
|
||||
{
|
||||
//取出所有的生成记录
|
||||
var generateRecord = await _sGenerateRecordRepositories.GetEntity(dto.GenerateRecordId);
|
||||
if (generateRecord == null)
|
||||
return Result.ReFailure(ResultCodes.NoDateError);
|
||||
var serialNumbers = await _serialNumbersRepositories.GetEntityList(dto.SerialNumbers);
|
||||
|
||||
var exec_m = serialNumbers.Where(w => w.MaterialNumber == dto.MaterialNumber).Select(s => s.MaterialNumber).ToList();
|
||||
if (exec_m.Count() > 0)
|
||||
return Result.ReFailure($"序列号{string.Join(",", exec_m)}对应物料跟需要修改的物料一致", 611007);
|
||||
|
||||
//修改物料
|
||||
foreach (var s in serialNumbers)
|
||||
{
|
||||
var res = s.UpdateMaterial(dto.MaterialNumber);
|
||||
if (!res.IsSuccess) return res;
|
||||
}
|
||||
generateRecord.UpdateMaterial();
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool res_Rollback = false;
|
||||
|
||||
var isSuccess = await _serialNumbersRepositories.EditEntityList(serialNumbers, false);
|
||||
if (!isSuccess) res_Rollback = true;
|
||||
if (!res_Rollback)
|
||||
{
|
||||
var res = await _sGenerateRecordRepositories.Edit(generateRecord, false);
|
||||
if (res == null) res_Rollback = true;
|
||||
}
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
76
src/BarCode.Web.Domain/TimedJob/ErpBaseDataSyncJob.cs
Normal file
76
src/BarCode.Web.Domain/TimedJob/ErpBaseDataSyncJob.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Pomelo.AspNetCore.TimedJob;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core.Dto.Erp;
|
||||
using BarCode.Web.Core.Dto.Erp.Customer;
|
||||
using BarCode.Web.Core.Dto.Erp.Org;
|
||||
using BarCode.Web.Core.Dto.Erp.Supplier;
|
||||
using BarCode.Web.Domain.IService.Public;
|
||||
using BarCode.Web.Domain.Options;
|
||||
using BarCode.Web.Domain.Services.Public;
|
||||
|
||||
namespace BarCode.Web.Domain.TimedJob
|
||||
{
|
||||
/// <summary>
|
||||
/// erp基础数据-同步定时任务
|
||||
/// </summary>
|
||||
public class ErpBaseDataSyncJob : Job
|
||||
{
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private readonly ErpOptions _erpOptions;
|
||||
private ILogger<ErpBaseDataSyncJob> _logger;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
public ErpBaseDataSyncJob(IServiceProvider serviceProvider,IMemoryCache memoryCache, IOptions<ErpOptions> erpOptions, ILogger<ErpBaseDataSyncJob> logger)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_memoryCache = memoryCache;
|
||||
this._erpOptions = erpOptions?.Value;
|
||||
this._logger = logger;
|
||||
}
|
||||
|
||||
//[Invoke(Begin = "2022-03-02 01:01", Interval = 1000 * 60 * 60 * 24, SkipWhileExecuting = true)]
|
||||
//30分钟执行一次
|
||||
[Invoke(Begin = "2024-01-15 17:43", Interval = 1000 * 60 * 30, SkipWhileExecuting = true)]
|
||||
public void Run()
|
||||
{
|
||||
//this.SyscErpBaseData();
|
||||
}
|
||||
|
||||
public void SyscErpBaseData()
|
||||
{
|
||||
string tip = "";
|
||||
_logger.LogInformation($"----------异步:定时任务拉取---------");
|
||||
var sercice = _serviceProvider.GetRequiredService<IErpService>();
|
||||
var materials = _memoryCache.Get<List<ErpMaterialDto>>(_erpOptions.cache_materail_key);
|
||||
if (materials == null || materials.Count == 0)
|
||||
ErpBaseDataSync.SyncMaterial(sercice);
|
||||
else
|
||||
tip = tip + "物料缓存未失效;";
|
||||
|
||||
var orgs = _memoryCache.Get<List<ErpOrgDto>>(_erpOptions.cache_org_key);
|
||||
if (orgs == null || orgs.Count == 0)
|
||||
ErpBaseDataSync.SyncOrg(sercice);
|
||||
else
|
||||
tip = tip + "组织缓存未失效;";
|
||||
var suppliers = _memoryCache.Get<List<ErpSupplierDto>>(_erpOptions.cache_supplier_key);
|
||||
if (suppliers == null || suppliers.Count == 0)
|
||||
ErpBaseDataSync.SyncSupplier(sercice);
|
||||
else
|
||||
tip = tip + "供应商缓存未失效;";
|
||||
var customers = _memoryCache.Get<List<ErpCustomerDto>>(_erpOptions.cache_customer_key);
|
||||
if (customers == null || customers.Count == 0)
|
||||
ErpBaseDataSync.SyncCustomer(sercice);
|
||||
else
|
||||
tip = tip + "客户缓存未失效;";
|
||||
|
||||
if (!string.IsNullOrEmpty(tip))
|
||||
_logger.LogInformation($"异步:定时任务拉取-->" + tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/BarCode.Web.Domain/Values/BoxStatus.cs
Normal file
32
src/BarCode.Web.Domain/Values/BoxStatus.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using BarCode.Web.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarCode.Web.Domain.Values
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱状态
|
||||
/// </summary>
|
||||
public enum BoxStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 未使用
|
||||
/// </summary>
|
||||
[EnumRemark("未使用")]
|
||||
NoUse = 0,
|
||||
/// <summary>
|
||||
/// 未完成
|
||||
/// </summary>
|
||||
[EnumRemark("未完成")]
|
||||
NoComplete = 1,
|
||||
/// <summary>
|
||||
/// 已完成
|
||||
/// </summary>
|
||||
[EnumRemark("已完成")]
|
||||
Complete = 2,
|
||||
|
||||
}
|
||||
}
|
||||
19
src/BarCode.Web.Domain/Values/CenerateDataType.cs
Normal file
19
src/BarCode.Web.Domain/Values/CenerateDataType.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Values
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动生成数据 序列码和防伪码
|
||||
/// </summary>
|
||||
public enum CenerateDataType
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列码生成
|
||||
/// </summary>
|
||||
[EnumRemark("序列码生成")]
|
||||
Serial = 1
|
||||
}
|
||||
}
|
||||
85
src/BarCode.Web.Domain/Values/Erp/FormIdParam.cs
Normal file
85
src/BarCode.Web.Domain/Values/Erp/FormIdParam.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Values.Erp
|
||||
{
|
||||
/// <summary>
|
||||
/// 业务对象表单Id:对应erp的单据表的名称
|
||||
/// </summary>
|
||||
public enum FormIdParam
|
||||
{
|
||||
/// <summary>
|
||||
/// 采购订单
|
||||
/// </summary>
|
||||
PUR_PurchaseOrder = 1,
|
||||
/// <summary>
|
||||
/// 采购入库单
|
||||
/// </summary>
|
||||
STK_InStock = 2,
|
||||
/// <summary>
|
||||
/// 其他入库单
|
||||
/// </summary>
|
||||
STK_MISCELLANEOUS = 3,
|
||||
/// <summary>
|
||||
/// 直接调拨单-里面包含出和入
|
||||
/// </summary>
|
||||
STK_TransferDirect = 4,
|
||||
/// <summary>
|
||||
/// 分步式调入单
|
||||
/// </summary>
|
||||
STK_TRANSFERIN = 5,
|
||||
/// <summary>
|
||||
/// 组装拆卸单:里面包含出和入
|
||||
/// </summary>
|
||||
STK_AssembledApp = 6,
|
||||
/// <summary>
|
||||
/// 组织
|
||||
/// </summary>
|
||||
ORG_Organizations = 7,
|
||||
/// <summary>
|
||||
/// 供应商
|
||||
/// </summary>
|
||||
BD_Supplier = 8,
|
||||
/// <summary>
|
||||
/// 仓库
|
||||
/// </summary>
|
||||
BD_STOCK = 9,
|
||||
/// <summary>
|
||||
/// 盘盈单
|
||||
/// </summary>
|
||||
STK_StockCountGain = 10,
|
||||
/// <summary>
|
||||
/// 盘亏单
|
||||
/// </summary>
|
||||
STK_StockCountLoss = 11,
|
||||
/// <summary>
|
||||
/// 物料
|
||||
/// </summary>
|
||||
BD_MATERIAL = 12,
|
||||
/// <summary>
|
||||
/// 销售发货通知单
|
||||
/// </summary>
|
||||
SAL_DELIVERYNOTICE = 13,
|
||||
/// <summary>
|
||||
/// 其他出库单
|
||||
/// </summary>
|
||||
STK_MisDelivery = 14,
|
||||
/// <summary>
|
||||
/// 分布式调出单
|
||||
/// </summary>
|
||||
STK_TRANSFEROUT = 15,
|
||||
/// <summary>
|
||||
/// 客户
|
||||
/// </summary>
|
||||
BD_Customer = 16,
|
||||
/// <summary>
|
||||
/// 销售出库单
|
||||
/// </summary>
|
||||
SAL_OUTSTOCK = 17,
|
||||
/// <summary>
|
||||
/// 即时库存
|
||||
/// </summary>
|
||||
STK_Inventory = 18
|
||||
}
|
||||
}
|
||||
30
src/BarCode.Web.Domain/Values/ExportStatus.cs
Normal file
30
src/BarCode.Web.Domain/Values/ExportStatus.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Values
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件导出状态
|
||||
/// </summary>
|
||||
public enum ExportStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 正在导出
|
||||
/// </summary>
|
||||
[EnumRemark("正在导出")]
|
||||
Ing = 0,
|
||||
/// <summary>
|
||||
/// 导出成功
|
||||
/// </summary>
|
||||
[EnumRemark("导出成功")]
|
||||
Success = 1,
|
||||
/// <summary>
|
||||
/// 导出失败
|
||||
/// </summary>
|
||||
[EnumRemark("导出失败")]
|
||||
Fail = 2
|
||||
}
|
||||
}
|
||||
34
src/BarCode.Web.Domain/Values/FileDownLoadOrderType.cs
Normal file
34
src/BarCode.Web.Domain/Values/FileDownLoadOrderType.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Values
|
||||
{
|
||||
/// <summary>
|
||||
/// 导出单据类型
|
||||
/// </summary>
|
||||
public enum FileDownLoadOrderType
|
||||
{
|
||||
/// <summary>
|
||||
/// 条码下载
|
||||
/// </summary>
|
||||
[EnumRemark("条码下载")]
|
||||
SerialNumbers = 1,
|
||||
/// <summary>
|
||||
/// 条码详情下载
|
||||
/// </summary>
|
||||
[EnumRemark("条码详情下载")]
|
||||
SerialNumberInfo = 2,
|
||||
/// <summary>
|
||||
/// 防伪码下载
|
||||
/// </summary>
|
||||
[EnumRemark("防伪码下载")]
|
||||
SecurityNumbers = 3,
|
||||
/// <summary>
|
||||
/// 防伪码详情下载
|
||||
/// </summary>
|
||||
[EnumRemark("防伪码详情下载")]
|
||||
SecurityNumberInfo = 4
|
||||
}
|
||||
}
|
||||
64
src/BarCode.Web.Domain/Values/ResultCodes.cs
Normal file
64
src/BarCode.Web.Domain/Values/ResultCodes.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Values
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误提示信息
|
||||
/// </summary>
|
||||
public partial class ResultCodes
|
||||
{
|
||||
public static ValueTuple<int, string> Erp_Login_Error = (1001, "同步金蝶登录错误,请稍候再试");
|
||||
|
||||
public static ValueTuple<int, string> Erp_BillQuery_Error = (1002, "同步金蝶数据出错,请稍等再试");
|
||||
public static ValueTuple<int, string> Erp_Inventory_Error = (1003, "获取金蝶即时库存数据出错,请稍等再试");
|
||||
/// <summary>
|
||||
/// 无效
|
||||
/// </summary>
|
||||
public static ValueTuple<int, string> Token_Invalid_Error = (401, "验证Token无效,请重新登录");
|
||||
/// <summary>
|
||||
/// 数据操作失败
|
||||
/// </summary>
|
||||
public static ValueTuple<int, string> DateWriteError = (40004, "数据操作失败");
|
||||
public static ValueTuple<int, string> NoDateError = (40005, "数据不存在");
|
||||
public static ValueTuple<int, string> NoOrgError = (40006, "组织信息不存在");
|
||||
public static ValueTuple<int, string> IsTwoError = (70001, "两件装产品,数量需填双数");
|
||||
|
||||
/// <summary>
|
||||
/// 没有菜单权限,无法登录
|
||||
/// </summary>
|
||||
public static ValueTuple<int, string> NoRoot = (40005, "没有菜单权限,无法登录");
|
||||
public static ValueTuple<int, string> ErpSyns = (40006, "正在同步金蝶数据,请稍候再试!");
|
||||
public static ValueTuple<int, string> ErpSynsError = (40006, "同步金蝶数据失败!");
|
||||
public static ValueTuple<int, string> ErpOrgError = (80004, "获取Erp相关组织数据失败,请稍候再试!");
|
||||
public static ValueTuple<int, string> ErpSupplierError = (80005, "获取Erp相关供应商数据失败,请稍候再试!");
|
||||
public static ValueTuple<int, string> ErpStockError = (80006, "获取Erp相关仓库数据失败,请稍候再试!");
|
||||
public static ValueTuple<int, string> ErpSubStockError = (80006, "获取Erp相关子仓库数据失败,请稍候再试!");
|
||||
public static ValueTuple<int, string> ErpMaterialError = (80007, "获取Erp相关物料数据失败,请稍候再试!");
|
||||
public static ValueTuple<int, string> BoxHaveError = (80008, "箱号已收货");
|
||||
public static ValueTuple<int, string> AdjustError = (80009, "与金蝶校准发生错误,请稍候再试!");
|
||||
public static ValueTuple<int, string> MateriaNoData = (800011, "产品信息不存在");
|
||||
public static ValueTuple<int, string> SerialNumberNoDateError = (500001, "序列号数据不存在");
|
||||
public static ValueTuple<int, string> SerialNumberG = (400007, "当前有序列号正在生成,请稍后再试");
|
||||
public static ValueTuple<int, string> SecurityNumberG = (400008, "当前有防伪码正在生成,请稍后再试");
|
||||
public static ValueTuple<int, string> SerialGenerateBigNumber = (400009, "生成条码一次最多不能超过1000个物料");
|
||||
public static ValueTuple<int, string> CartonCompleteError = (600001, "该箱已完成装箱, 需再次装箱请操作重新装箱");
|
||||
public static ValueTuple<int, string> SerialNumberBindBox = (600002, "序列号已装过箱");
|
||||
public static ValueTuple<int, string> SerialNumberIsUse = (600002, "序列号已被扫描使用");
|
||||
public static ValueTuple<int, string> BoxNoDataError = (600003, "请扫描系统存在的箱号");
|
||||
public static ValueTuple<int, string> BoxMaterialNoDataError = (600004, "箱信息不包含该物料");
|
||||
public static ValueTuple<int, string> BoxSerialNumberNoDataError = (600005, "箱信息不包含该序列号");
|
||||
public static ValueTuple<int, string> SerialNumberNoData = (600006, "请扫描系统存在的序列号");
|
||||
/// <summary>
|
||||
/// 箱号不符合规则
|
||||
/// </summary>
|
||||
public static ValueTuple<int, string> BoxNO_Invalid_Error = (600006, "箱号只能包含CTN和数字");
|
||||
public static ValueTuple<int, string> BoxNoComplete = (600007, "箱没有完成装箱,不能重新装箱");
|
||||
public static ValueTuple<int, string> SerialNumbersNoData = (610000, "序列号不存在");
|
||||
public static ValueTuple<int, string> NumberCode_Invalid_Error = (600008, "数字序列号必须是大于11位的纯数字");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
122
src/BarCode.Web.Domain/Values/Single/SingleAction.cs
Normal file
122
src/BarCode.Web.Domain/Values/Single/SingleAction.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BarCode.Web.Core;
|
||||
|
||||
namespace BarCode.Web.Domain.Values.Single
|
||||
{
|
||||
/// <summary>
|
||||
/// 对接单点的接口方法-枚举
|
||||
/// </summary>
|
||||
public enum SingleAction
|
||||
{
|
||||
/// <summary>
|
||||
/// 组织集合
|
||||
/// </summary>
|
||||
[EnumRemark("组织")]
|
||||
Orgs = 1,
|
||||
/// <summary>
|
||||
/// 用户集合
|
||||
/// </summary>
|
||||
[EnumRemark("用户")]
|
||||
Users = 2,
|
||||
/// <summary>
|
||||
/// 人员集合
|
||||
/// </summary>
|
||||
[EnumRemark("人员")]
|
||||
Staffs = 3,
|
||||
/// <summary>
|
||||
/// 供应商集合
|
||||
/// </summary>
|
||||
[EnumRemark("供应商")]
|
||||
Suppliers = 4,
|
||||
/// <summary>
|
||||
/// 客户集合
|
||||
/// </summary>
|
||||
[EnumRemark("客户")]
|
||||
Customers = 5,
|
||||
/// <summary>
|
||||
/// 收款条件集合
|
||||
/// </summary>
|
||||
[EnumRemark("收款条件")]
|
||||
CollectionTerms = 6,
|
||||
/// <summary>
|
||||
/// 付款条件集合
|
||||
/// </summary>
|
||||
[EnumRemark("付款条件")]
|
||||
PaymentTerms = 7,
|
||||
/// <summary>
|
||||
/// 结算方式集合
|
||||
/// </summary>
|
||||
[EnumRemark("结算方式")]
|
||||
SettlementMethods = 8,
|
||||
/// <summary>
|
||||
/// 结算币别集合
|
||||
/// </summary>
|
||||
[EnumRemark("结算币别")]
|
||||
SettlementCurrencys = 9,
|
||||
/// <summary>
|
||||
/// 税率集合
|
||||
/// </summary>
|
||||
[EnumRemark("税率")]
|
||||
TaxRates = 10,
|
||||
/// <summary>
|
||||
/// 汇率集合
|
||||
/// </summary>
|
||||
[EnumRemark("汇率")]
|
||||
ExchangeRates = 11,
|
||||
/// <summary>
|
||||
/// 仓库集合
|
||||
/// </summary>
|
||||
[EnumRemark("仓库")]
|
||||
Stocks = 12,
|
||||
/// <summary>
|
||||
/// 单位集合
|
||||
/// </summary>
|
||||
[EnumRemark("单位")]
|
||||
Units = 13,
|
||||
/// <summary>
|
||||
/// 客户仓库集合
|
||||
/// </summary>
|
||||
[EnumRemark("客户仓库")]
|
||||
CustomerStocks = 14,
|
||||
/// <summary>
|
||||
/// 部门集合
|
||||
/// </summary>
|
||||
[EnumRemark("部门")]
|
||||
Depts = 15,
|
||||
/// <summary>
|
||||
/// 仓库211集合
|
||||
/// </summary>
|
||||
[EnumRemark("仓库211")]
|
||||
StocksWith211 = 16,
|
||||
/// <summary>
|
||||
/// 供应商默认联系人集合
|
||||
/// </summary>
|
||||
[EnumRemark("供应商默认联系人")]
|
||||
SuppliersContacts = 17,
|
||||
/// <summary>
|
||||
/// 菜单集合
|
||||
/// </summary>
|
||||
[EnumRemark("菜单")]
|
||||
Menus = 18,
|
||||
/// <summary>
|
||||
/// 仓位集合
|
||||
/// </summary>
|
||||
[EnumRemark("仓位")]
|
||||
SubStocks = 19,
|
||||
|
||||
/// <summary>
|
||||
/// 仓库:编码与组织编码结合
|
||||
/// </summary>
|
||||
[EnumRemark("仓库")]
|
||||
StocksJoinOrgCode=20,
|
||||
|
||||
/// <summary>
|
||||
/// 仓库:编码与组织编码结合
|
||||
/// </summary>
|
||||
[EnumRemark("仓位与仓库与组织")]
|
||||
SubStocksJoinOrgCode
|
||||
|
||||
}
|
||||
}
|
||||
29
src/BarCode.Web.Domain/Values/Single/SingleControllerType.cs
Normal file
29
src/BarCode.Web.Domain/Values/Single/SingleControllerType.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Values.Single
|
||||
{
|
||||
/// <summary>
|
||||
/// 单点-控制器枚举
|
||||
/// </summary>
|
||||
public enum SingleControllerType
|
||||
{
|
||||
/// <summary>
|
||||
/// 单点OPS列表数据-控制器
|
||||
/// </summary>
|
||||
Single = 1,
|
||||
/// <summary>
|
||||
/// 单点配置项数据-控制器
|
||||
/// </summary>
|
||||
SysConfig = 2,
|
||||
/// <summary>
|
||||
/// 单点登录项数据-控制器
|
||||
/// </summary>
|
||||
Login = 3,
|
||||
/// <summary>
|
||||
/// 单点公共接口数据-控制器
|
||||
/// </summary>
|
||||
Public = 4
|
||||
}
|
||||
}
|
||||
42
src/BarCode.Web.Domain/Values/Single/SingleLoginAction.cs
Normal file
42
src/BarCode.Web.Domain/Values/Single/SingleLoginAction.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Values.Single
|
||||
{
|
||||
/// <summary>
|
||||
/// 单点数据接口-登录要使用的数据接口-方法枚举
|
||||
/// </summary>
|
||||
public enum SingleLoginAction
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单
|
||||
/// </summary>
|
||||
Menus = 1,
|
||||
/// <summary>
|
||||
/// 人员
|
||||
/// </summary>
|
||||
Staff = 2,
|
||||
/// <summary>
|
||||
/// 公司
|
||||
/// </summary>
|
||||
Company = 3,
|
||||
/// <summary>
|
||||
/// 供应商
|
||||
/// </summary>
|
||||
Supplier = 4,
|
||||
/// <summary>
|
||||
/// 客户
|
||||
/// </summary>
|
||||
Customer = 5,
|
||||
/// <summary>
|
||||
/// 全部信息
|
||||
/// </summary>
|
||||
All = 6,
|
||||
/// <summary>
|
||||
/// 公司信息
|
||||
/// </summary>
|
||||
CompanyInfo = 7,
|
||||
|
||||
}
|
||||
}
|
||||
223
src/BarCode.Web.Domain/Values/Single/SysConfigAction.cs
Normal file
223
src/BarCode.Web.Domain/Values/Single/SysConfigAction.cs
Normal file
@@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BarCode.Web.Domain.Values.Single
|
||||
{
|
||||
/// <summary>
|
||||
/// 单点数据:配置项和公共接口的方法枚举值
|
||||
/// </summary>
|
||||
public enum SysConfigAction
|
||||
{
|
||||
/// <summary>
|
||||
/// 供应商-根据名称和公司
|
||||
/// </summary>
|
||||
GetSupplierByNameAndCompany = 1,
|
||||
/// <summary>
|
||||
/// 组织-根据公司
|
||||
/// </summary>
|
||||
GetOrgByCompany = 2,
|
||||
/// <summary>
|
||||
/// 部门-根据组织和公司
|
||||
/// </summary>
|
||||
GetDeptByOrgAndCompany = 3,
|
||||
/// <summary>
|
||||
/// 人员-根据公司
|
||||
/// </summary>
|
||||
GetStaffByCompany = 4,
|
||||
/// <summary>
|
||||
/// 人员-根据部门和公司
|
||||
/// </summary>
|
||||
GetStaffByDeptAndCompany = 5,
|
||||
/// <summary>
|
||||
/// 人员-根据组织和公司
|
||||
/// </summary>
|
||||
GetStaffByOrgAndCompany = 6,
|
||||
/// <summary>
|
||||
/// 客户-根据公司
|
||||
/// </summary>
|
||||
GetCustomerByCompany = 7,
|
||||
/// <summary>
|
||||
/// 客户-根据客户和组织和公司
|
||||
/// </summary>
|
||||
GetCustomerByCustomerAndOrgAndCompany = 8,
|
||||
/// <summary>
|
||||
/// 客户信息-根据客户和组织和公司
|
||||
/// </summary>
|
||||
GetCustomerInfoByCustomerAndOrgAndCompany = 9,
|
||||
/// <summary>
|
||||
/// 收款条件-根据公司
|
||||
/// </summary>
|
||||
GetCollectionTermsByCompany = 10,
|
||||
/// <summary>
|
||||
/// 付款条件-根据公司
|
||||
/// </summary>
|
||||
GetPaymentTermByCompany = 11,
|
||||
/// <summary>
|
||||
/// 结算方式-根据公司
|
||||
/// </summary>
|
||||
GetSettlementMethodByCompany = 12,
|
||||
/// <summary>
|
||||
/// 结算币别-根据公司
|
||||
/// </summary>
|
||||
GetSettlementCurrencyByCompany = 13,
|
||||
/// <summary>
|
||||
/// 单位-根据公司
|
||||
/// </summary>
|
||||
GetUnitByCompany = 14,
|
||||
/// <summary>
|
||||
/// 单位(部分属性)-根据公司
|
||||
/// </summary>
|
||||
GetUnitPropertyByCompany = 15,
|
||||
/// <summary>
|
||||
/// 税率-根据公司
|
||||
/// </summary>
|
||||
GetTaxRateByCompany = 16,
|
||||
/// <summary>
|
||||
/// 仓库-根据名称和公司
|
||||
/// </summary>
|
||||
GetWarehouseByNameAndCompany = 17,
|
||||
/// <summary>
|
||||
/// 仓库-根据组织和公司
|
||||
/// </summary>
|
||||
GetWarehouseByOrgAndCompany = 18,
|
||||
/// <summary>
|
||||
/// 仓库(不是调拨中转仓)-根据组织和公司
|
||||
/// </summary>
|
||||
GetWarehouseByOrgAndCompanyForNotTransfer = 19,
|
||||
/// <summary>
|
||||
/// 仓库(211)-根据组织和公司
|
||||
/// </summary>
|
||||
GetWarehouseByOrgAndCompanyFor211 = 20,
|
||||
/// <summary>
|
||||
/// 仓库-根据客户和公司
|
||||
/// </summary>
|
||||
GetWareouseByCustomerAndCompany = 21,
|
||||
|
||||
/// <summary>
|
||||
/// 仓位-根据仓库
|
||||
/// </summary>
|
||||
GetChildWarehouseByPid = 22,
|
||||
/// <summary>
|
||||
/// 仓位-根据-
|
||||
/// </summary>
|
||||
GetChildWarehouse = 23,
|
||||
/// <summary>
|
||||
/// 汇率信息-根据原币、目标币和公司
|
||||
/// </summary>
|
||||
GetRateInfoByFromToAndCompany = 24,
|
||||
/// <summary>
|
||||
/// 客户仓库-根据客户和组织和公司
|
||||
/// </summary>
|
||||
GetCustomerStockByCustomerAndOrgAndCompany = 25,
|
||||
/// <summary>
|
||||
/// 付款条件,结算币别,结算方式,采购员,采购部门-根据供应商和组织
|
||||
/// </summary>
|
||||
GetPtAndScAndSmAndBuyerAndDeptBySupplierAndOrg = 26,
|
||||
/// <summary>
|
||||
/// 获取仓库:根据仓库id
|
||||
/// </summary>
|
||||
GetWarehouseByIds = 27,
|
||||
/// <summary>
|
||||
/// 获取库存:根据组织和公司
|
||||
/// </summary>
|
||||
GetCustomerByOrgAndCompany = 28,
|
||||
|
||||
/// <summary>
|
||||
/// 获取客户仓库:根据客户IDS和组织和公司
|
||||
/// </summary>
|
||||
GetCustomerStockByCustomerListAndOrgAndCompany = 29,
|
||||
/// <summary>
|
||||
/// 汇率(所有)
|
||||
/// </summary>
|
||||
GetRateListByFromToAndCompany = 30,
|
||||
|
||||
/// <summary>
|
||||
/// 供应商选择后获取:付款条件,结算币别,结算方式,采购员,采购部门,根据组织IDS
|
||||
/// </summary>
|
||||
GetPtAndScAndSmAndBuyerAndDeptByOrgs = 31,
|
||||
/// <summary>
|
||||
/// 获取客户仓库:根据code集合
|
||||
/// </summary>
|
||||
GetCustomerStockListByCodes = 32,
|
||||
/// <summary>
|
||||
/// 供应商:根据ids
|
||||
/// </summary>
|
||||
GetSupperByIds = 33,
|
||||
/// <summary>
|
||||
/// 根据公司搜索所有仓库(计算补货频次)
|
||||
/// </summary>
|
||||
GetWarehouseReplenDatebyCompany = 34,
|
||||
/// <summary>
|
||||
/// 获取仓库:根据codes
|
||||
/// </summary>
|
||||
GetWarehouseByCodes = 35,
|
||||
/// <summary>
|
||||
/// 获取客户仓库:根据codes
|
||||
/// </summary>
|
||||
GetCustomerStockByCodes = 36,
|
||||
|
||||
/// <summary>
|
||||
/// 获取调拨中转仓库:根据公司
|
||||
/// </summary>
|
||||
GetWarehouseTransferByCompany = 37,
|
||||
/// <summary>
|
||||
/// 获取供应商数据根据ids
|
||||
/// </summary>
|
||||
GetSupperAbout1ByIds = 38,
|
||||
/// <summary>
|
||||
/// 获取仓库:根据默认补货客户
|
||||
/// </summary>
|
||||
GetWarehouseByDefaultReplenishCustomer = 39,
|
||||
/// <summary>
|
||||
/// 获取用户(ID和Name):根据公司
|
||||
/// </summary>
|
||||
GetUsersByCompany = 40,
|
||||
/// <summary>
|
||||
/// 全部部门-根据组织和公司:不处理子级
|
||||
/// </summary>
|
||||
GetDeptAllByOrgAndCompany = 41,
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部员工:根据公司和组织
|
||||
/// </summary>
|
||||
GetStaffAllByOrgAndCompany = 42,
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库::根据管理系统code和仓库名称和公司ID,备注系统code和公司ID是必填
|
||||
/// </summary>
|
||||
GetWmsWarehouseBySystemCodeAndNameAndCompany = 43,
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓库::根据管理系统code和仓位名称和公司ID,备注系统code和公司ID是必填
|
||||
/// </summary>
|
||||
GetWmsSubWarehouseBySystemCodeAndNameAndCompany = 44,
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓位详情:根据仓位ID和公司ID
|
||||
/// </summary>
|
||||
GetWmsSubWarehouseByIdAndCompany = 45,
|
||||
/// <summary>
|
||||
/// 获取仓位详情:根据仓位ID集合和公司ID
|
||||
/// </summary>
|
||||
GetWmsSubWarehouseByIdsAndCompany = 46,
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓位详情:根据仓位Code和公司ID
|
||||
/// </summary>
|
||||
GetWmsSubWarehouseByCodeAndCompany = 47,
|
||||
|
||||
/// <summary>
|
||||
/// 获取仓位详情:根据仓位Codes集合和公司ID
|
||||
/// </summary>
|
||||
GetWmsSubWarehouseByCodesAndCompany = 48,
|
||||
/// <summary>
|
||||
/// 根据用户获取组织
|
||||
/// </summary>
|
||||
GetOrgByUser = 49,
|
||||
/// <summary>
|
||||
/// 根据用户获取供应商
|
||||
/// </summary>
|
||||
GetSupplierByUser = 50
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user