Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn
	
		
		已添加10个文件
	
		
		已修改26个文件
	
		
		已删除9个文件
	
		
		已重命名1个文件
	
	
 
	
	
	
	
	
	
	
	
|  |  |  | 
|---|
|  |  |  | </PropertyGroup> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ItemGroup> | 
|---|
|  |  |  | <PackageReference Include="WIDESEAWCS_QuartzJob" Version="1.0.0" /> | 
|---|
|  |  |  | <PackageReference Include="WIDESEAWCS_QuartzJob" Version="3.0.1" /> | 
|---|
|  |  |  | </ItemGroup> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ItemGroup> | 
|---|
|  |  |  | 
|---|
|  |  |  | InQuality = 540, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// çäº§éæ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("ç产éæ")] | 
|---|
|  |  |  | ProductionReturn = 550, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// å··éå
ç§»åº | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("å··éå
ç§»åº")] | 
|---|
| ¶Ô±ÈÐÂÎļþ | 
|  |  |  | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | using System.ComponentModel; | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEAWCS_Common.WareHouseEnum | 
|---|
|  |  |  | { | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä»åº | 
|---|
|  |  |  | /// HA57 = æ·®å®äºå - æ¿æä»<br/> | 
|---|
|  |  |  | /// HA58 = æ·®å®äºå - PPä»<br/> | 
|---|
|  |  |  | /// HA60 = æ·®å®äºå - è¾
æä»<br/> | 
|---|
|  |  |  | /// HA64 = æ·®å®äºå - æµè¯æ¶ä»<br/> | 
|---|
|  |  |  | /// HA71 = æ·®å®äºå - æåä»<br/> | 
|---|
|  |  |  | /// HA72 = æ·®å®äºå - å°¾æ°ä»<br/> | 
|---|
|  |  |  | /// HA73 = æ·®å®äºå - ç åä»<br/> | 
|---|
|  |  |  | /// HA101 = æ·®å®äºå - æåä»å¹³åº<br/> | 
|---|
|  |  |  | /// HA152 = æ·®å®äºå - å¹²èä»<br/> | 
|---|
|  |  |  | /// HA153 = æ·®å®äºå - æ²¹å¢¨ä»<br/> | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public enum WarehouseEnum | 
|---|
|  |  |  | { | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æ¿æä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("æ¿æä»")] | 
|---|
|  |  |  | HA57, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// PPä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("PPä»")] | 
|---|
|  |  |  | HA58, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// è¾
æä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("è¾
æä»")] | 
|---|
|  |  |  | HA60, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æµè¯æ¶ä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("æµè¯æ¶ä»")] | 
|---|
|  |  |  | HA64, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æåä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("æåä»")] | 
|---|
|  |  |  | HA71, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// å°¾æ°ä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("å°¾æ°ä»")] | 
|---|
|  |  |  | HA72, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ç åä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("ç åä»")] | 
|---|
|  |  |  | HA73, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æåä»å¹³åº | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("æåä»å¹³åº")] | 
|---|
|  |  |  | HA101, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// å¹²èä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("å¹²èä»")] | 
|---|
|  |  |  | HA152, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æ²¹å¢¨ä» | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("油墨ä»")] | 
|---|
|  |  |  | HA153 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /// ä¼å
级 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public int Grade { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int WarehouseId { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public string AGVArea { get; set; } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | <ProjectReference Include="..\WIDESEAWCS_Model\WIDESEAWCS_Model.csproj" /> | 
|---|
|  |  |  | </ItemGroup> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ItemGroup> | 
|---|
|  |  |  | <Folder Include="BasicInfo\" /> | 
|---|
|  |  |  | </ItemGroup> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </Project> | 
|---|
| ÎļþÃû´Ó ´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/BasicInfo/WarehouseDTO.cs ÐÞ¸Ä | 
|  |  |  | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  | using WIDESEAWCS_Core.DB.Models; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEAWCS_DTO.BasicInfo | 
|---|
|  |  |  | namespace WIDESEAWCS_Model.Models | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public class WarehouseDTO | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä»åºä¿¡æ¯ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarTable(nameof(Dt_Warehouse), "ä»åºä¿¡æ¯")] | 
|---|
|  |  |  | public class Dt_Warehouse : BaseEntity | 
|---|
|  |  |  | { | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä¸»é® | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] | 
|---|
|  |  |  | [SugarColumn(IsPrimaryKey = true, ColumnDescription = "主é®")] | 
|---|
|  |  |  | public int WarehouseId { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
| ¶Ô±ÈÐÂÎļþ | 
|  |  |  | 
|---|
|  |  |  | using SqlSugar; | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  | using WIDESEAWCS_Core.DB.Models; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEAWCS_Model.Models | 
|---|
|  |  |  | { | 
|---|
|  |  |  | [SugarTable(nameof(Dt_WarehouseDevice))] | 
|---|
|  |  |  | public class Dt_WarehouseDevice : BaseEntity | 
|---|
|  |  |  | { | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä¸»é® | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsIdentity = true, IsPrimaryKey = true)] | 
|---|
|  |  |  | public int Id { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// è®¾å¤ä¸»é® | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsNullable = false, ColumnDescription = "")] | 
|---|
|  |  |  | public int DeviceId { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// è®¾å¤ç¼å· | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "")] | 
|---|
|  |  |  | public string DeviceCode { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// è®¾å¤åç§° | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "")] | 
|---|
|  |  |  | public string DeviceName { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä»åºä¸»é® | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "")] | 
|---|
|  |  |  | public int WarehouseId { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä»åºç¼å· | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "")] | 
|---|
|  |  |  | public string WarehouseCode { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ä»åºåç§° | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "")] | 
|---|
|  |  |  | public string WarehouseName { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// å¤æ³¨ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [SugarColumn(IsNullable = true, ColumnDescription = "")] | 
|---|
|  |  |  | public string Remark { get; set; } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | using SqlSugar; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Helper; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Seed; | 
|---|
|  |  |  | using WIDESEAWCS_DTO.BasicInfo; | 
|---|
|  |  |  | using WIDESEAWCS_Model.Models; | 
|---|
|  |  |  | using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEAWCS_Server.HostedService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public class WarehouseHostedService : IHostedService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | private readonly ICacheService _cacheService; | 
|---|
|  |  |  | private readonly DBContext _dbContext; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public WarehouseHostedService(ICacheService cacheService, DBContext dbContext) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _cacheService = cacheService; | 
|---|
|  |  |  | _dbContext = dbContext; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Task StartAsync(CancellationToken cancellationToken) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string connStr = AppSettings.GetValue("WMSConnectionStrings"); | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception("WMSè¿æ¥å符串é误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig() | 
|---|
|  |  |  | SqlSugarClient sugarClient = new(new ConnectionConfig() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ConnectionString = connStr, | 
|---|
|  |  |  | IsAutoCloseConnection = true, | 
|---|
|  |  |  | DbType = DbType.SqlServer | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WarehouseDTO> warehouses = sugarClient.Queryable<WarehouseDTO>().ToList(); | 
|---|
|  |  |  | List<Dt_Warehouse> warehouses = sugarClient.Queryable<Dt_Warehouse>().ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _dbContext.Db.Deleteable<Dt_Warehouse>().ExecuteCommand(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _dbContext.Db.Insertable(warehouses).ExecuteCommand(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return Task.CompletedTask; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | using Autofac.Core; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.QuartzExtensions; | 
|---|
|  |  |  | using Microsoft.AspNetCore.Builder; | 
|---|
|  |  |  | using WIDESEAWCS_Server.HostedService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var builder = WebApplication.CreateBuilder(args); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | builder.Services.AddInitializationHostServiceSetup();//åºç¨åå§åæå¡æ³¨å
¥ | 
|---|
|  |  |  | builder.Services.AddDbSetup();//Db å¯å¨æå¡ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddScoped<QuartzJobCreateDataTabel>(); | 
|---|
|  |  |  | builder.Services.AddHostedService<QuartzJobDataTableHostedService>(); | 
|---|
|  |  |  | //builder.Services.AddScoped<QuartzJobCreateDataTabel>(); | 
|---|
|  |  |  | builder.Services.AddHostedService<WarehouseHostedService>(); | 
|---|
|  |  |  | //builder.Services.AddHostedService<QuartzJobDataTableHostedService>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddAutoMapperSetup(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddHttpContextSetup(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddHostedService<QuartzJobHostedService>(); | 
|---|
|  |  |  | //builder.Services.AddHostedService<QuartzJobHostedService>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddMvc(options => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | using WIDESEAWCS_Core.BaseServices; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Enums; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Helper; | 
|---|
|  |  |  | using WIDESEAWCS_DTO.BasicInfo; | 
|---|
|  |  |  | using WIDESEAWCS_DTO.TaskInfo; | 
|---|
|  |  |  | using WIDESEAWCS_IBasicInfoRepository; | 
|---|
|  |  |  | using WIDESEAWCS_ITaskInfoRepository; | 
|---|
|  |  |  | using WIDESEAWCS_ITaskInfoService; | 
|---|
|  |  |  | using WIDESEAWCS_Model.Models; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.Models; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.Repository; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.Service; | 
|---|
|  |  |  | using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEAWCS_TaskInfoService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public partial class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | private readonly IMapper _mapper; | 
|---|
|  |  |  | private readonly ICacheService _cacheService; | 
|---|
|  |  |  | private readonly IRouterService _routerService; | 
|---|
|  |  |  | private readonly ITaskExecuteDetailService _taskExecuteDetailService; | 
|---|
|  |  |  | private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository; | 
|---|
|  |  |  | private readonly IMapper _mapper; | 
|---|
|  |  |  | private readonly IStationMangerRepository _stationMangerRepository; | 
|---|
|  |  |  | private readonly IRouterRepository _routerRepository; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Dictionary<string, OrderByType> _taskOrderBy = new() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | {nameof(Dt_Task.CreateDate),OrderByType.Asc}, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<Dt_Warehouse>? Warehouses = new List<Dt_Warehouse>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Dictionary<string, OrderByType> TaskOrderBy { get { return _taskOrderBy; } set { _taskOrderBy = value; } } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<int> TaskInboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 500 && x < 900).ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, IStationMangerRepository stationMangerRepository) : base(BaseDal) | 
|---|
|  |  |  | public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository) : base(BaseDal) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _mapper = mapper; | 
|---|
|  |  |  | _cacheService = cacheService; | 
|---|
|  |  |  | _routerService = routerService; | 
|---|
|  |  |  | _taskExecuteDetailService = taskExecuteDetailService; | 
|---|
|  |  |  | _taskExecuteDetailRepository = taskExecuteDetailRepository; | 
|---|
|  |  |  | _mapper = mapper; | 
|---|
|  |  |  | _stationMangerRepository = stationMangerRepository; | 
|---|
|  |  |  | _routerRepository = routerRepository; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string? cacheStr = _cacheService.Get(nameof(Dt_Warehouse)); | 
|---|
|  |  |  | if (!string.IsNullOrEmpty(cacheStr)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Warehouses = JsonConvert.DeserializeObject<List<Dt_Warehouse>>(cacheStr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æ¥æ¶WMSä»»å¡ä¿¡æ¯ | 
|---|
|  |  |  | 
|---|
|  |  |  | WebResponseContent content = new WebResponseContent(); | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<Dt_WarehouseDevice> warehouseDevices = Db.Queryable<Dt_WarehouseDevice>().ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_Task> tasks = new List<Dt_Task>(); | 
|---|
|  |  |  | foreach (var item in taskDTOs) | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (BaseDal.QueryFirst(x => x.TaskNum == item.TaskNum || x.PalletCode == item.PalletCode) != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | 
|---|
|  |  |  | task.CurrentAddress = item.SourceAddress; | 
|---|
|  |  |  | task.NextAddress = item.TargetAddress; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_WarehouseDevice> wades = warehouseDevices.Where(x => x.WarehouseId == item.WarehouseId).ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (string.IsNullOrEmpty(item.AGVArea)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == item.SourceAddress || x.StackerCraneCode == item.RoadWay); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //stationManger.AGVStationCode | 
|---|
|  |  |  | //stationManger.StackerCraneCode | 
|---|
|  |  |  | //stationManger.StationDeviceCode | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (stationManger.StationDeviceCode == x.StartPosi || stationManger.StackerCraneCode == x.StartPosi)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.StartPosi); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | tasks.Add(task); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BaseDal.AddData(tasks); | 
|---|
|  |  |  | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.HoisterJob; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.StackerCraneJob; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.é»çä»; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEAWCS_Tasks | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | </PropertyGroup> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ItemGroup> | 
|---|
|  |  |  | <PackageReference Include="WIDESEAWCS_QuartzJob" Version="3.0.0" /> | 
|---|
|  |  |  | <PackageReference Include="WIDESEAWCS_QuartzJob" Version="3.0.1" /> | 
|---|
|  |  |  | </ItemGroup> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ItemGroup> | 
|---|
|  |  |  | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.HoisterJob; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.StackerCraneJob; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.é»çä»; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEAWCS_Tasks | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.HoisterJob; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.StackerCraneJob; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks.é»çä»; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEAWCS_Tasks | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | /// ERPç©æåºåºæ¥å£è°ç¨ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("ERPç©æåºåºæ¥å£è°ç¨")] | 
|---|
|  |  |  | InvokeOutboundOrderApi | 
|---|
|  |  |  | InvokeOutboundOrderApi, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// MES忥æµè¯æ¶å°è´¦ä¿¡æ¯ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("MES忥æµè¯æ¶å°è´¦ä¿¡æ¯")] | 
|---|
|  |  |  | WMS_MES_TestToolSync, | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | [Description("é»çä»å
¥åº")] | 
|---|
|  |  |  | SolderInbound = 2350, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æµè¯æ¶éåº | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("æµè¯æ¶éåº")] | 
|---|
|  |  |  | TestBackbound=2400, | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// åºåº | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Description("åºåº")] | 
|---|
|  |  |  | 
|---|
|  |  |  | namespace WIDESEA_Core | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public sealed class SeedDataHostedService : IHostedService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | private readonly DBContext _dbContext; | 
|---|
|  |  |  | { | 
|---|
|  |  |  | private readonly DBContext _dbContext; | 
|---|
|  |  |  | private readonly ILogger<SeedDataHostedService> _logger; | 
|---|
|  |  |  | private readonly string _webRootPath; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | public int Grade { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int WarehouseId { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public string AGVArea { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /// <param name="inboundModel"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | string InvokeInboundOrderApi(ERPInboundModel inboundModel); | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// ERPç©æåºåºæ¥å£è°ç¨ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="outboundModel"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | string InvokeOutboundOrderApi(ERPOutboundModel outboundModel); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> GetOutStockLockInfos(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outboundOrderDetail, List<Dt_StockInfo> outStocks, int? taskNum = null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_OutStockLockInfo GetOutStockLockInfo(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outboundOrderDetail, Dt_StockInfo outStock, float assignQuantity, int? taskNum = null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> GetByOrderDetailId(int orderDetailId, OutLockStockStatusEnum outStockStatus); | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> GetStockOutboundOrder(SaveModel saveModel); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /// <param name="taskNum">ä»»å¡å·</param> | 
|---|
|  |  |  | /// <param name="locationCode">å
¥åºæåºåºçè´§ä½å·</param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | MesResponseContent TestReturnStock(TestToolBackModel backModel); | 
|---|
|  |  |  | MesResponseContent TestToolBack(TestToolBackModel backModel); | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æµè¯æ¶æ¥åº | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | 
|---|
|  |  |  | return outStockLockInfos; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Dt_OutStockLockInfo GetOutStockLockInfo(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outboundOrderDetail, Dt_StockInfo outStock, float assignQuantity, int? taskNum = null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_OutStockLockInfo outStockLockInfo = new Dt_OutStockLockInfo() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | PalletCode = outStock.PalletCode, | 
|---|
|  |  |  | AssignQuantity = assignQuantity, | 
|---|
|  |  |  | MaterielCode = outboundOrderDetail.MaterielCode, | 
|---|
|  |  |  | BatchNo = outboundOrderDetail.BatchNo, | 
|---|
|  |  |  | LocationCode = outStock.LocationCode, | 
|---|
|  |  |  | MaterielName = outboundOrderDetail.MaterielName, | 
|---|
|  |  |  | OrderDetailId = outboundOrderDetail.Id, | 
|---|
|  |  |  | OrderNo = outboundOrder.OrderNo, | 
|---|
|  |  |  | OrderType = outboundOrder.OrderType, | 
|---|
|  |  |  | OriginalQuantity = outStock.Details.Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode).Sum(x => x.StockQuantity), | 
|---|
|  |  |  | Status = taskNum == null ? OutLockStockStatusEnum.å·²åé
.ObjToInt() : OutLockStockStatusEnum.åºåºä¸.ObjToInt(), | 
|---|
|  |  |  | StockId = outStock.Id, | 
|---|
|  |  |  | TaskNum = taskNum, | 
|---|
|  |  |  | OrderQuantity = outboundOrderDetail.OrderQuantity | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return outStockLockInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<Dt_OutStockLockInfo> GetByOrderDetailId(int orderDetailId, OutLockStockStatusEnum outStockStatus) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return BaseDal.QueryData(x => x.OrderDetailId == orderDetailId && x.Status == outStockStatus.ObjToInt()); | 
|---|
| ¶Ô±ÈÐÂÎļþ | 
|  |  |  | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  | using WIDESEA_Common.StockEnum; | 
|---|
|  |  |  | using WIDESEA_Core; | 
|---|
|  |  |  | using WIDESEA_Core.BaseServices; | 
|---|
|  |  |  | using WIDESEA_Core.Enums; | 
|---|
|  |  |  | using WIDESEA_Core.Helper; | 
|---|
|  |  |  | using WIDESEA_IOutboundRepository; | 
|---|
|  |  |  | using WIDESEA_IStockService; | 
|---|
|  |  |  | using WIDESEA_Model.Models; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEA_IOutboundService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public partial class OutStockLockInfoService : ServiceBase<Dt_OutStockLockInfo, IOutStockLockInfoRepository>, IOutStockLockInfoService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | IStockService _stockService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public WebResponseContent MaterialPick(string palletCode) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode); | 
|---|
|  |  |  | if (stockInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥æçåºåä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> outStockLockInfos = Repository.QueryData(x => x.PalletCode == palletCode); | 
|---|
|  |  |  | for (int i = 0; i < outStockLockInfos.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | float assignQuantity = outStockLockInfos[i].AssignQuantity; | 
|---|
|  |  |  | List<Dt_StockInfoDetail> stockInfoDetails = stockInfo.Details.Where(x => x.MaterielCode == outStockLockInfos[i].MaterielCode).ToList(); | 
|---|
|  |  |  | for (int j = 0; j < stockInfoDetails.Count; j++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | // if(assignQuantity > stockInfoDetails[j]) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | float needQuantity = originalNeedQuantity; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, outboundOrder.WarehouseId); | 
|---|
|  |  |  | if (!stockInfos.Any()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"æªæ¾å°å¯åé
åºå"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out float residueQuantity); | 
|---|
|  |  |  | item.LockQuantity += needQuantity - residueQuantity; | 
|---|
|  |  |  | outStocks.AddRange(autoAssignStocks); | 
|---|
|  |  |  | float assignQuantity = needQuantity - residueQuantity; | 
|---|
|  |  |  | //for (int i = 0; i < outboundOrderDetails.Count; i++) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //    for (int j = 0; j < outStocks.Count; j++) | 
|---|
|  |  |  | //    { | 
|---|
|  |  |  | //        if(assignQuantity > 0) | 
|---|
|  |  |  | //        { | 
|---|
|  |  |  | //            if (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity >= outStocks[j].) | 
|---|
|  |  |  | //            { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | List<Dt_OutboundOrderDetail> details = outboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    if (assignQuantity > 0 && outboundOrderDetails[i].LockQuantity < outboundOrderDetails[i].OrderQuantity) | 
|---|
|  |  |  | //    { | 
|---|
|  |  |  | //        outStockLockInfos.AddRange(_outStockLockInfoService.GetOutStockLockInfos(outboundOrder, outboundOrderDetails[i], outStocks)); | 
|---|
|  |  |  | //        if (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity >= assignQuantity) | 
|---|
|  |  |  | //        { | 
|---|
|  |  |  | //            outboundOrderDetails[i].LockQuantity += assignQuantity; | 
|---|
|  |  |  | //            break; | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        else | 
|---|
|  |  |  | //        { | 
|---|
|  |  |  | //            assignQuantity -= (outboundOrderDetails[i].OrderQuantity - outboundOrderDetails[i].LockQuantity); | 
|---|
|  |  |  | //            outboundOrderDetails[i].LockQuantity = outboundOrderDetails[i].OrderQuantity; | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | for (int i = 0; i < details.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | float orderQuantity = details[i].OrderQuantity; | 
|---|
|  |  |  | for (int j = 0; j < autoAssignStocks.Count; j++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | float detailAssignQuantity = outStockLockInfos.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity);//åºåºè®¢åæç»å·²åé
æ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | float palletAssignQuantity = outStockLockInfos.Where(x => x.BatchNo == item.BatchNo && x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é | 
|---|
|  |  |  | if (string.IsNullOrEmpty(item.BatchNo)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//åºåºè¯¦æ
å·²åé
æ°é | 
|---|
|  |  |  | } | 
|---|
|  |  |  | float palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity); | 
|---|
|  |  |  | if (palletAssignQuantity < palletOutboundQuantity)//妿åºåºè¯¦æ
å·²åé
æ°éå°äºæçå·²åé
æ°éï¼åå¯ä»¥ç»§ç»æ·»å è¯¥æçåºåºä¿¡æ¯ | 
|---|
|  |  |  | { | 
|---|
|  |  |  | float orderDetailNeedQuantity = details[i].OrderQuantity - detailAssignQuantity; | 
|---|
|  |  |  | if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | details[i].LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity; | 
|---|
|  |  |  | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, details[i], autoAssignStocks[j], autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity); | 
|---|
|  |  |  | outStockLockInfos.Add(outStockLockInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, details[i], autoAssignStocks[j], details[i].OrderQuantity - details[i].LockQuantity); | 
|---|
|  |  |  | outStockLockInfos.Add(outStockLockInfo); | 
|---|
|  |  |  | details[i].LockQuantity = details[i].OrderQuantity; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> addOutStockLockInfos = outStockLockInfos.Where(x => x.Id == 0).ToList(); | 
|---|
|  |  |  | if (addOutStockLockInfos != null && addOutStockLockInfos.Any()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if(tasks != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | addOutStockLockInfos.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.TaskNum = tasks.FirstOrDefault(v => v.PalletCode == x.PalletCode)?.TaskNum; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _outStockLockInfoService.Repository.AddData(addOutStockLockInfos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Dt_OutStockLockInfo> updateOutStockLockInfos = outStockLockInfos.Where(x => x.Id > 0).ToList(); | 
|---|
|  |  |  | 
|---|
|  |  |  | private readonly IStockInfoRepository _stockInfoRepository; | 
|---|
|  |  |  | public IOutboundOrderRepository Repository => BaseDal; | 
|---|
|  |  |  | private readonly IInvokeERPService _invokeERPService; | 
|---|
|  |  |  | private readonly IOutStockLockInfoService _outStockLockInfoService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper,IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IStockInfoService stockInfoService, | 
|---|
|  |  |  | IStockInfoRepository stockInfoRepository, IInvokeERPService invokeERPService) : base(BaseDal) | 
|---|
|  |  |  | IStockInfoRepository stockInfoRepository, IInvokeERPService invokeERPService, IOutStockLockInfoService outStockLockInfoService) : base(BaseDal) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _mapper = mapper; | 
|---|
|  |  |  | _unitOfWorkManage=unitOfWorkManage; | 
|---|
|  |  |  | _unitOfWorkManage = unitOfWorkManage; | 
|---|
|  |  |  | _basicService = basicService; | 
|---|
|  |  |  | _outboundOrderDetailRepository = outboundOrderDetailRepository; | 
|---|
|  |  |  | _stockInfoService = stockInfoService; | 
|---|
|  |  |  | _stockInfoRepository = stockInfoRepository; | 
|---|
|  |  |  | _invokeERPService = invokeERPService; | 
|---|
|  |  |  | _outStockLockInfoService = outStockLockInfoService; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public WebResponseContent ReceiveOutOrder(ErpOutOrderDTO model) | 
|---|
|  |  |  | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using SqlSugar.Extensions; | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  | using WIDESEA_Common.APIEnum; | 
|---|
|  |  |  | using WIDESEA_Common.CommonEnum; | 
|---|
|  |  |  | using WIDESEA_Common.LocationEnum; | 
|---|
|  |  |  | using WIDESEA_Common.OtherEnum; | 
|---|
|  |  |  | 
|---|
|  |  |  | using WIDESEA_Common.WareHouseEnum; | 
|---|
|  |  |  | using WIDESEA_Core; | 
|---|
|  |  |  | using WIDESEA_Core.BaseServices; | 
|---|
|  |  |  | using WIDESEA_Core.Enums; | 
|---|
|  |  |  | using WIDESEA_DTO; | 
|---|
|  |  |  | using WIDESEA_DTO.ERP; | 
|---|
|  |  |  | using WIDESEA_DTO.MES; | 
|---|
|  |  |  | 
|---|
|  |  |  | BaseDal.AddData(taskOut); | 
|---|
|  |  |  | //å å
¥è´§ä½åå¨è®°å½ | 
|---|
|  |  |  | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, locationStatus, LocationChangeType.OutboundAssignLocation, stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", taskOut.TaskNum); | 
|---|
|  |  |  | //å å
¥åºååå¨è®°å½ | 
|---|
|  |  |  | //_recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfoDetails, beforeQuantity, totalQuantity, StockChangeTypeEnum.MaterielGroup); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | //å°ä»»å¡æ¨éå°WCS | 
|---|
|  |  |  | PushTasksToWCS(); | 
|---|
|  |  |  | 
|---|
|  |  |  | /// æµè¯æ¶éåº | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public MesResponseContent TestReturnStock(TestToolBackModel backModel) | 
|---|
|  |  |  | public MesResponseContent TestToolBack(TestToolBackModel backModel) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | MesResponseContent responseContent = new MesResponseContent(); | 
|---|
|  |  |  | try | 
|---|
|  |  |  | 
|---|
|  |  |  | x.WarehouseId == warehouse.WarehouseId && | 
|---|
|  |  |  | x.StockStatus == (int)StockStatusEmun.åºåºå®æ) | 
|---|
|  |  |  | .Includes(x => x.Details).Where(x => x.Details.Any(x => x.BatchNo == backModel.TestToolCode)).First(); | 
|---|
|  |  |  | if (stockInfo==null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return responseContent.Error($"{backModel.TestToolCode}åºåä¿¡æ¯ä¸åå¨"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //çæéåºä»»å¡ | 
|---|
|  |  |  | Dt_Task taskIn = new() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | CurrentAddress = backModel.SourceAddressCode, | 
|---|
|  |  |  | Grade = 0, | 
|---|
|  |  |  | PalletCode = stockInfo.PalletCode, | 
|---|
|  |  |  | NextAddress = "", | 
|---|
|  |  |  | Roadway = "", | 
|---|
|  |  |  | SourceAddress = backModel.SourceAddressCode, | 
|---|
|  |  |  | TargetAddress = "", | 
|---|
|  |  |  | TaskStatus = (int)TaskStatusEnum.New, | 
|---|
|  |  |  | TaskType = (int)TaskTypeEnum.TestBackbound, | 
|---|
|  |  |  | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), | 
|---|
|  |  |  | PalletType = stockInfo.PalletType, | 
|---|
|  |  |  | WarehouseId = stockInfo.WarehouseId, | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | //æ´æ¹åºåç¶æ | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  | _stockRepository.StockInfoRepository.UpdateData(stockInfo); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | //å°ä»»å¡æ¨éå°WCS | 
|---|
|  |  |  | PushTasksToWCS(); | 
|---|
|  |  |  | responseContent.OK(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | responseContent.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return responseContent; | 
|---|
|  |  |  | 
|---|
|  |  |  | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA64.ToString()); | 
|---|
|  |  |  | //è·ååºåè®°å½ | 
|---|
|  |  |  | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => | 
|---|
|  |  |  | x.WarehouseId == warehouse.WarehouseId) | 
|---|
|  |  |  | x.WarehouseId == warehouse.WarehouseId && x.StockStatus==StockStatusEmun.åºåºå®æ.ObjToInt()) | 
|---|
|  |  |  | .Includes(x => x.Details).Where(x => x.Details.Any(x => x.BatchNo == toolScrap.ToolCode)).First(); | 
|---|
|  |  |  | if (stockInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return responseContent.Error($"{toolScrap.ToolCode}åºåä¿¡æ¯ä¸åå¨"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //æ¸
é¤åºåä¿¡æ¯ | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _stockRepository.StockInfoRepository.DeleteData(stockInfo); | 
|---|
|  |  |  | _stockRepository.StockInfoDetailRepository.DeleteData(stockInfo.Details); | 
|---|
|  |  |  | _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfo,OperateTypeEnum.èªå¨å é¤); | 
|---|
|  |  |  | _stockRepository.StockInfoDetailRepository.DeleteAndMoveIntoHty(stockInfo.Details, OperateTypeEnum.èªå¨å é¤); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | responseContent.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return responseContent; | 
|---|
|  |  |  | 
|---|
|  |  |  | WebResponseContent content= new WebResponseContent(); | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x=>x.ApiCode==APIEnum.WMS_MES_TestToolSync.ToString()); | 
|---|
|  |  |  | Root<TestToolSynInfo> root = new Root<TestToolSynInfo>() | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | From = "WMS", | 
|---|
|  |  |  | DateTime = DateTime.Now.ToString(), | 
|---|
|  |  |  | Content=toolSynInfo | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | //è°ç¨æ¥å£ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | using WIDESEA_DTO.Inbound; | 
|---|
|  |  |  | using WIDESEA_DTO.Stock; | 
|---|
|  |  |  | using WIDESEA_DTO.Task; | 
|---|
|  |  |  | using WIDESEA_External.ERPService; | 
|---|
|  |  |  | using WIDESEA_IBasicRepository; | 
|---|
|  |  |  | using WIDESEA_IBasicService; | 
|---|
|  |  |  | using WIDESEA_IInboundService; | 
|---|
|  |  |  | 
|---|
|  |  |  | private readonly IOutboundService _outboundService; | 
|---|
|  |  |  | private readonly IStockService _stockService; | 
|---|
|  |  |  | private readonly IBasicRepository _basicRepository; | 
|---|
|  |  |  | private readonly IApiInfoRepository _apiInfoRepository; | 
|---|
|  |  |  | private readonly IInvokeERPService _invokeERPService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public ITaskRepository Repository => BaseDal; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService, IBasicRepository basicRepository) : base(BaseDal) | 
|---|
|  |  |  | public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IStockRepository stockRepository, IBasicService basicService, IRecordService recordService, IOutboundService outboundService, IStockService stockService, IBasicRepository basicRepository, IApiInfoRepository apiInfoRepository, IInvokeERPService invokeERPService) : base(BaseDal) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _mapper = mapper; | 
|---|
|  |  |  | _unitOfWorkManage = unitOfWorkManage; | 
|---|
|  |  |  | 
|---|
|  |  |  | _outboundService = outboundService; | 
|---|
|  |  |  | _stockService = stockService; | 
|---|
|  |  |  | _basicRepository = basicRepository; | 
|---|
|  |  |  | _apiInfoRepository = apiInfoRepository; | 
|---|
|  |  |  | _invokeERPService = invokeERPService; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | 
|---|
|  |  |  | if (task.TaskType == TaskTypeEnum.TestInbound.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | stockInfo.StockStatus = StockStatusEmun.å
¥åºå®ææªå»ºåºåºå.ObjToInt(); | 
|---|
|  |  |  | stockInfo.Details.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.Status = StockStatusEmun.å
¥åºå®æ.ObjToInt(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | _basicService.LocationInfoService.Repository.UpdateData(locationInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _stockRepository.StockInfoRepository.UpdateData(stockInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details); | 
|---|
|  |  |  | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationChangeType.InboundCompleted); | 
|---|
|  |  |  | _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum); | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | 
|---|
|  |  |  | </PropertyGroup> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ItemGroup> | 
|---|
|  |  |  | <ProjectReference Include="..\WIDESEA_External\WIDESEA_External.csproj" /> | 
|---|
|  |  |  | <ProjectReference Include="..\WIDESEA_IBasicService\WIDESEA_IBasicService.csproj" /> | 
|---|
|  |  |  | <ProjectReference Include="..\WIDESEA_IInboundService\WIDESEA_IInboundService.csproj" /> | 
|---|
|  |  |  | <ProjectReference Include="..\WIDESEA_IOutboundService\WIDESEA_IOutboundService.csproj" /> | 
|---|
|  |  |  | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="model"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [HttpPost, Route("TestReturnStock"), AllowAnonymous, MethodParamsValidate] | 
|---|
|  |  |  | public MesResponseContent TestReturnStock([FromBody] Root<TestToolBackModel> model) | 
|---|
|  |  |  | [HttpPost, Route("TestToolBack"), AllowAnonymous, MethodParamsValidate] | 
|---|
|  |  |  | public MesResponseContent TestToolBack([FromBody] Root<TestToolBackModel> model) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return _taskService.TestReturnStock(model.Content); | 
|---|
|  |  |  | return _taskService.TestToolBack(model.Content); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// æµè¯æ¶æ¥åº | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="model"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [HttpPost, Route("TestScrap"), AllowAnonymous, MethodParamsValidate] | 
|---|
|  |  |  | [HttpPost, Route("TestToolScrap"), AllowAnonymous, MethodParamsValidate] | 
|---|
|  |  |  | public MesResponseContent TestScrap([FromBody] Root<TestToolScrap> model) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return _taskService.TestScrap(model.Content); | 
|---|