129 lines
5.5 KiB
C#
129 lines
5.5 KiB
C#
using AutoMapper;
|
||||
|
|
using JSMachine.WMS.Common;
|
|||
|
|
using JSMachine.WMS.Infrastructure.Attributes;
|
|||
|
|
using JSMachine.WMS.Infrastructure.Enums;
|
|||
|
|
using JSMachine.WMS.Infrastructure.Helper;
|
|||
|
|
using JSMachine.WMS.RPC.PmsRPC.Dto.In;
|
|||
|
|
using JSMachine.WMS.RPC.PmsRPC.Dto.Out;
|
|||
|
|
using JSMachine.WMS.RPC.PmsRPC.Enum;
|
|||
|
|
using JSMachine.WMS.RPC.PmsRPC.IService;
|
|||
|
|
using Newtonsoft.Json;
|
|||
|
|
using Prism.Ioc;
|
|||
|
|
using RestSharp;
|
|||
|
|
|
|||
|
|
namespace JSMachine.WMS.RPC.PmsRPC.Service.DCS
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
[PmsTypeAttribute(PmsType.DCS)]
|
|||
|
|
public class DcsPaperPreparService : IPaperPreparService
|
|||
|
|
{
|
|||
|
|
private static readonly string dcsUrl = "throw new NotImplementedException();";
|
|||
|
|
private static readonly string queryPmsOrdersUrl = "Global.AppSettings.PmsConfig.QueryPmsOrdersUrl;";
|
|||
|
|
private static IMapper mapper = ContainerLocator.Container.Resolve<IMapper>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取Dcs,Token
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
/// <exception cref="NotImplementedException"></exception>
|
|||
|
|
public Task<string> GetACSToken()
|
|||
|
|
{
|
|||
|
|
throw new NotImplementedException();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 处理后的备纸需求
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
/// <exception cref="NotImplementedException"></exception>
|
|||
|
|
public async Task<List<MachinePaperNeedDto>> GetMachinePaperNeeds()
|
|||
|
|
{
|
|||
|
|
ApiResult<PaperPreparDto[]> apiResult = await this.GetPaperPrepars(1, 10000);
|
|||
|
|
PaperPreparDto[] paperPrepars = apiResult?.Data;
|
|||
|
|
|
|||
|
|
if (paperPrepars == null)
|
|||
|
|
return null;
|
|||
|
|
|
|||
|
|
IEnumerable<PaperNeed> hc = paperPrepars
|
|||
|
|
.Where(p => !string.IsNullOrEmpty(p.DC_PaperMass))
|
|||
|
|
.Select(p => new PaperNeed { PaperMassCode = p.DC_PaperMass, Web = p.Web });
|
|||
|
|
IEnumerable<PaperNeed> sc1W = paperPrepars
|
|||
|
|
.Where(p => !string.IsNullOrEmpty(p.SC1_CorrPaperMass))
|
|||
|
|
.Select(p => new PaperNeed { PaperMassCode = p.SC1_CorrPaperMass, Web = p.Web });
|
|||
|
|
IEnumerable<PaperNeed> sc1X = paperPrepars
|
|||
|
|
.Where(p => !string.IsNullOrEmpty(p.SC1_SurfPaperMass))
|
|||
|
|
.Select(p => new PaperNeed { PaperMassCode = p.SC1_SurfPaperMass, Web = p.Web });
|
|||
|
|
IEnumerable<PaperNeed> sc2W = paperPrepars
|
|||
|
|
.Where(p => !string.IsNullOrEmpty(p.SC2_CorrPaperMass))
|
|||
|
|
.Select(p => new PaperNeed { PaperMassCode = p.SC2_CorrPaperMass, Web = p.Web });
|
|||
|
|
IEnumerable<PaperNeed> sc2X = paperPrepars
|
|||
|
|
.Where(p => !string.IsNullOrEmpty(p.SC2_SurfPaperMass))
|
|||
|
|
.Select(p => new PaperNeed { PaperMassCode = p.SC2_SurfPaperMass, Web = p.Web });
|
|||
|
|
|
|||
|
|
|
|||
|
|
List<MachinePaperNeedDto> machinePaperNeeds = new(5)
|
|||
|
|
{
|
|||
|
|
new MachinePaperNeedDto {PlateType=PlateType.HC,PaperNeeds=hc.ToList()},
|
|||
|
|
new MachinePaperNeedDto {PlateType=PlateType.SC1W,PaperNeeds=sc1W.ToList()},
|
|||
|
|
new MachinePaperNeedDto {PlateType=PlateType.SC1X,PaperNeeds=sc1X.ToList()},
|
|||
|
|
new MachinePaperNeedDto {PlateType=PlateType.SC2W,PaperNeeds=sc2W.ToList()},
|
|||
|
|
new MachinePaperNeedDto {PlateType=PlateType.SC2X,PaperNeeds=sc2X.ToList()}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
return machinePaperNeeds;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取DCS湿段+干段备注
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="pageIndex"></param>
|
|||
|
|
/// <param name="pageSize"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
/// <exception cref="NotImplementedException"></exception>
|
|||
|
|
public async Task<ApiResult<PaperPreparDto[]>> GetPaperPrepars(int pageIndex, int pageSize)
|
|||
|
|
{
|
|||
|
|
var apiResultDto = new ApiResult<PaperPreparDto[]> { };
|
|||
|
|
string url = dcsUrl + queryPmsOrdersUrl;
|
|||
|
|
var jsonParam = new
|
|||
|
|
{
|
|||
|
|
num = pageSize,
|
|||
|
|
page = pageIndex
|
|||
|
|
};
|
|||
|
|
string resStr = await HttpRequestHelper.RequestByJson(url, Method.POST, JsonConvert.SerializeObject(jsonParam));
|
|||
|
|
if (string.IsNullOrEmpty(resStr))
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
var tempResultDto = JsonConvert.DeserializeObject<DcsApiResult<DcsPaperPreparDto[]>>(resStr);
|
|||
|
|
if (pageSize > tempResultDto.Data.Count())
|
|||
|
|
{
|
|||
|
|
apiResultDto.Data = new PaperPreparDto[tempResultDto.Data.Count()];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
apiResultDto.Data = new PaperPreparDto[pageSize];
|
|||
|
|
}
|
|||
|
|
for (int i = 0; i < tempResultDto.Data.Count(); i++)
|
|||
|
|
{
|
|||
|
|
var item = tempResultDto.Data[i];
|
|||
|
|
var resultItem = new PaperPreparDto();
|
|||
|
|
|
|||
|
|
resultItem.PaperMassCode = item.Mass;
|
|||
|
|
mapper.Map(item, resultItem);
|
|||
|
|
resultItem.DC_PaperMass = item.DC_PaperMass ?? "";
|
|||
|
|
resultItem.SC1_CorrPaperMass = item.SC1_CorrPaperMass ?? "";
|
|||
|
|
resultItem.SC1_SurfPaperMass = item.SC1_SurfPaperMass ?? "";
|
|||
|
|
resultItem.SC2_CorrPaperMass = item.SC2_CorrPaperMass ?? "";
|
|||
|
|
resultItem.SC2_SurfPaperMass = item.SC2_SurfPaperMass ?? "";
|
|||
|
|
|
|||
|
|
apiResultDto.Data[i] = resultItem;
|
|||
|
|
}
|
|||
|
|
apiResultDto.Code = tempResultDto.ResultCode;
|
|||
|
|
apiResultDto.TotalRecord = tempResultDto.TotalRecord;
|
|||
|
|
apiResultDto.IsSucc = tempResultDto.ResultCode == 1 ? true : false;
|
|||
|
|
//var apiResultDto = JsonConvert.DeserializeObject<ApiResult<PaperPreparDto[]>>(resStr);
|
|||
|
|
return apiResultDto;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|