添加webservice服务
This commit is contained in:
1 parent
bdaaa0d5d9
commit
eef6df7099
7 files changed
+286
No files matched your search
@@ -44,6 +44,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="protobuf-net" Version="3.2.26" />
|
<PackageReference Include="protobuf-net" Version="3.2.26" />
|
||||||
|
<PackageReference Include="SoapCore" Version="1.1.0.38" />
|
||||||
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="6.16.1" />
|
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="6.16.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.ServiceModel;
|
||||||
|
using System.ServiceModel.Channels;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
namespace MESTOWMSService
|
||||||
|
{
|
||||||
|
[ServiceContract(Namespace ="mestowmsservice")]
|
||||||
|
public interface IContract
|
||||||
|
{
|
||||||
|
[OperationContract]
|
||||||
|
Result MesInWms(string bizData);
|
||||||
|
|
||||||
|
[OperationContract]
|
||||||
|
Result MesOutWms(string bizData);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.ServiceModel;
|
||||||
|
using System.ServiceModel.Channels;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using HHWMS.Web;
|
||||||
|
using HHWMS.Web.Models;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using WalkingTec.Mvvm.Core;
|
||||||
|
using WalkingTec.Mvvm.Mvc;
|
||||||
|
|
||||||
|
namespace MESTOWMSService
|
||||||
|
{
|
||||||
|
public class WmsMesService : IContract
|
||||||
|
{
|
||||||
|
private readonly IUnitWork _unitwork;
|
||||||
|
private readonly WTMContext _wtm;
|
||||||
|
public WmsMesService(IUnitWork unitwork, WTMContext wtm)
|
||||||
|
{
|
||||||
|
_unitwork = unitwork;
|
||||||
|
_wtm = wtm;
|
||||||
|
}
|
||||||
|
public Result MesInWms(string materails)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_wtm.DoLog("", ActionLogTypesEnum.Normal,"mes", request: materails);
|
||||||
|
var data = JsonConvert.DeserializeObject<MesMaterials>(materails);
|
||||||
|
// 插入物料信息表
|
||||||
|
var materialList = new List<Material>();
|
||||||
|
foreach (var item in data.ISSUEMATERIALS.ISSUEITEM)
|
||||||
|
{
|
||||||
|
var material = new Material
|
||||||
|
{
|
||||||
|
MaterialCode = item.MATNR,
|
||||||
|
MaterialName = item.MAKTX,
|
||||||
|
MaterialType = item.BWART,
|
||||||
|
MaterialUnit = item.ERFME,
|
||||||
|
MaterialSpec = item.ZZXHGG,
|
||||||
|
Batch = item.LICHA,
|
||||||
|
QRCode = item.ZMBLNR,
|
||||||
|
Qty = decimal.Parse(item.MENGE),
|
||||||
|
SourceCode = item.AUFNR,
|
||||||
|
SupplierCode = item.ZZSCCJ,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
CreateBy = "mes"
|
||||||
|
};
|
||||||
|
materialList.Add(material);
|
||||||
|
}
|
||||||
|
_unitwork.BatchAdd<Material>(materialList.ToArray());
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
_wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: materails, result: "error");
|
||||||
|
return new Result { Status = "N", Message = ex.Message};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result MesOutWms(string outOrder)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: outOrder);
|
||||||
|
var data = JsonConvert.DeserializeObject<MesOut>(outOrder);
|
||||||
|
// 生成出库单和明细
|
||||||
|
var shipment = new ShipmentHeader
|
||||||
|
{
|
||||||
|
Code = _unitwork.GetSerialNumber("MO",4),
|
||||||
|
BillType = "out",
|
||||||
|
FirstStatus = ShipStatusEnum.新建,
|
||||||
|
ShipmentDetails = new List<ShipmentDetail>(),
|
||||||
|
CreateTime = DateTime.Now
|
||||||
|
};
|
||||||
|
foreach(var item in data.OUTWMS.OUTITEM)
|
||||||
|
{
|
||||||
|
var material = _unitwork.FindSingle<Material>(x => x.UniqueCode.Equals(item.SN));
|
||||||
|
var detail = new ShipmentDetail
|
||||||
|
{
|
||||||
|
UniqueCode = item.SN,
|
||||||
|
MaterialCode = material.MaterialCode,
|
||||||
|
MaterialName = material.MaterialName,
|
||||||
|
MaterialSpec = material.MaterialSpec,
|
||||||
|
MaterialType = material.MaterialType,
|
||||||
|
MaterialUnit = material.MaterialUnit,
|
||||||
|
Batch = material.Batch,
|
||||||
|
Qty = material.Qty,
|
||||||
|
CompanyCode = item.FACTORY,
|
||||||
|
ManufactureDate = Convert.ToDateTime(item.MESDATE),
|
||||||
|
Status = ShipStatusEnum.新建,
|
||||||
|
CreateTime = DateTime.Now
|
||||||
|
};
|
||||||
|
shipment.ShipmentDetails.Add(detail);
|
||||||
|
}
|
||||||
|
_unitwork.Add(shipment);
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: outOrder, result: "error");
|
||||||
|
return new Result { Status = "N", Message = ex.Message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace HHWMS.Web
|
namespace HHWMS.Web
|
||||||
{
|
{
|
||||||
public class RequestMes
|
public class RequestMes
|
||||||
@@ -21,4 +24,130 @@ namespace HHWMS.Web
|
|||||||
public string OverToUnits { get; set; }
|
public string OverToUnits { get; set; }
|
||||||
public string ActivityName { get; set; }
|
public string ActivityName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ISSUEITEMItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// SAP的生产订单
|
||||||
|
/// </summary>
|
||||||
|
public string AUFNR { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料的类型,261表示散料,只用在AUFNR订单上;315表示盘料,通用物料
|
||||||
|
/// </summary>
|
||||||
|
public string BWART { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string CID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string CRDAT { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料的单位
|
||||||
|
/// </summary>
|
||||||
|
public string ERFME { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 检验单号
|
||||||
|
/// </summary>
|
||||||
|
public string JYNUM { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料批次
|
||||||
|
/// </summary>
|
||||||
|
public string LICHA { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料名称
|
||||||
|
/// </summary>
|
||||||
|
public string MAKTX { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料编码
|
||||||
|
/// </summary>
|
||||||
|
public string MATNR { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料数量
|
||||||
|
/// </summary>
|
||||||
|
public string MENGE { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string POSID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string ZFLAG { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料二维码
|
||||||
|
/// </summary>
|
||||||
|
public string ZMBLNR { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string ZSXH { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string ZZLDJ { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 生产厂家
|
||||||
|
/// </summary>
|
||||||
|
public string ZZSCCJ { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 规格
|
||||||
|
/// </summary>
|
||||||
|
public string ZZXHGG { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ISSUEMATERIALS
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<ISSUEITEMItem> ISSUEITEM { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MesMaterials
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ISSUEMATERIALS ISSUEMATERIALS { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OUTITEMItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 车间
|
||||||
|
/// </summary>
|
||||||
|
public string FACTORY { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 时间
|
||||||
|
/// </summary>
|
||||||
|
public string MESDATE { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 需求设备
|
||||||
|
/// </summary>
|
||||||
|
public string RESOURCE { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 唯一码
|
||||||
|
/// </summary>
|
||||||
|
public string SN { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OUTWMS
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<OUTITEMItem> OUTITEM { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MesOut
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public OUTWMS OUTWMS { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace MESTOWMSService
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public class Result
|
||||||
|
{
|
||||||
|
public Result()
|
||||||
|
{
|
||||||
|
Message = "操作成功";
|
||||||
|
Status = "Y";
|
||||||
|
}
|
||||||
|
[DataMember]
|
||||||
|
public string Status { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
public string Message { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,10 @@ namespace HHWMS.Web.Models
|
|||||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||||
public string MaterialCode { get; set; }
|
public string MaterialCode { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Inventory.UniqueCode", Description = "唯一编码")]
|
||||||
|
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||||
|
public string UniqueCode { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Inventory.MaterialType", Description = "物料类型")]
|
[Display(Name = "Inventory.MaterialType", Description = "物料类型")]
|
||||||
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
|
||||||
public string MaterialType { get; set; }
|
public string MaterialType { get; set; }
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ using WalkingTec.Mvvm.Mvc;
|
|||||||
using HHWMS.Web.Support;
|
using HHWMS.Web.Support;
|
||||||
using HHWMS.Web;
|
using HHWMS.Web;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
|
using SoapCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using MESTOWMSService;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Logging.ClearProviders();
|
builder.Logging.ClearProviders();
|
||||||
@@ -50,6 +53,8 @@ builder.Services.AddWtmContext(builder.Configuration, (options) => {
|
|||||||
options.FileSubDirSelector = SubDirSelector;
|
options.FileSubDirSelector = SubDirSelector;
|
||||||
options.ReloadUserFunc = ReloadUser;
|
options.ReloadUserFunc = ReloadUser;
|
||||||
});
|
});
|
||||||
|
builder.Services.TryAddScoped<IContract, WmsMesService>();
|
||||||
|
builder.Services.AddSoapCore();
|
||||||
|
|
||||||
builder.Services.AddScoped(typeof(IUnitWork), typeof(UnitWork));
|
builder.Services.AddScoped(typeof(IUnitWork), typeof(UnitWork));
|
||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||||
@@ -72,6 +77,11 @@ app.UseWtmSwagger(false);
|
|||||||
app.UseSwaggerExt();
|
app.UseSwaggerExt();
|
||||||
app.UseWtm();
|
app.UseWtm();
|
||||||
app.AddQuartzJobs();
|
app.AddQuartzJobs();
|
||||||
|
|
||||||
|
app.UseEndpoints(endpoints => {
|
||||||
|
endpoints.UseSoapEndpoint<IContract>("/wmsMesService.asmx", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer);
|
||||||
|
});
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapControllerRoute(
|
endpoints.MapControllerRoute(
|
||||||
|
|||||||
Reference in new issue
Block a user