瀏覽代碼

生产排产调整

heteng 3 年之前
父節點
當前提交
263e6991fc

+ 0 - 22
MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/IProductionScheduleAppService.cs

@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Volo.Abp.Application.Dtos;
-using Volo.Abp.Application.Services;
-using Business.ResourceExamineManagement.Dto;
-
-namespace Business.ResourceExamineManagement
-{
-    /// <summary>
-    /// Éú²úÅŲú
-    /// </summary>
-    public interface IProductionScheduleAppService : IApplicationService
-    {
-        /// <summary>
-        /// Éú²úÅŲú
-        /// </summary>
-        /// <param name="workOrds"></param>
-        /// <returns></returns>
-        Task<string> ProductionSchedule(List<String> workOrds);
-    }
-}

+ 7 - 0
MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/IResourceExamineAppService.cs

@@ -12,6 +12,13 @@ namespace Business.ResourceExamineManagement
     /// </summary>
     public interface IResourceExamineAppService : IApplicationService
     {
+        /// <summary>
+        /// Éú²úÅŲú
+        /// </summary>
+        /// <param name="workOrds"></param>
+        /// <returns></returns>
+        Task<string> ProductionSchedule(List<string> workOrds);
+
         /// <summary>
         /// ×ÊÔ´¼ì²é
         /// </summary>

+ 6 - 8
MicroServices/Business/Business.Application/ResourceExamineManagement/ProdScheduleAppService.cs

@@ -11,6 +11,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using Volo.Abp.Application.Services;
+using Volo.Abp.DependencyInjection;
 using Volo.Abp.Domain.Repositories;
 using Volo.Abp.TenantManagement;
 
@@ -19,7 +20,7 @@ namespace Business.ResourceExamineManagement
     /// <summary>
     /// 生产排产接口实现类
     /// </summary>
-    public class ProdScheduleAppService : ApplicationService, IProductionScheduleAppService
+    public class ProdScheduleAppService : ApplicationService
     {
         /// <summary>
         /// 雪花算法帮助类
@@ -96,7 +97,7 @@ namespace Business.ResourceExamineManagement
                 return "";
             }
             //获取工单数据
-            var mes_morders = _mysql_mes_morder.GetListAsync(p => workOrds.Contains(p.morder_no)).Result;
+            var mes_morders = await _mysql_mes_morder.GetListAsync(p => workOrds.Contains(p.morder_no));
             CreateWorkOrdDates(mes_morders);
 
             return JsonConvert.SerializeObject("ok");
@@ -106,12 +107,12 @@ namespace Business.ResourceExamineManagement
         /// 同步工单等相关数据
         /// </summary>
         /// <param name="morders"></param>
-        public void CreateWorkOrdDates(List<mes_morder> morders)
+        public async void CreateWorkOrdDates(List<mes_morder> morders)
         {
             //获取工艺路线数据:product_code=物料编码
             List<RoutingOpDetail> allRoutings = _routingOpDetail.Select(p => morders.Select(m => m.product_code).Contains(p.RoutingCode));
             //获取标准BOM数据
-            List<ProductStructureMaster> productStructures = GetProductStructure(morders.Select(p => p.product_code).ToList());
+            List<ProductStructureMaster> productStructures = GetProductStructure(morders.Select(p => p.product_code).Distinct().ToList());
             //工单主表
             List<WorkOrdMaster> workOrds = new List<WorkOrdMaster>();
             WorkOrdMaster workOrd;
@@ -178,15 +179,12 @@ namespace Business.ResourceExamineManagement
                 }
             }
 
-            //await _businessDbContext.BulkInsertAsync(workOrds);
-            //await _businessDbContext.BulkInsertAsync(workOrdRoutings);
-            //await _businessDbContext.BulkInsertAsync(workOrdDetails);
             _workOrdMaster.Insert(workOrds);
             _workOrdRouting.Insert(workOrdRoutings);
             _workOrdDetail.Insert(workOrdDetails);
 
             //排产
-            _productionScheduleAppService.DoProductShcedule(workOrds);
+            await _productionScheduleAppService.DoProductShcedule(workOrds);
         }
 
         /// <summary>

+ 15 - 3
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -277,7 +277,7 @@ namespace Business.ResourceExamineManagement
         /// <summary>
         /// 生产排产
         /// </summary>
-        private readonly ProductionScheduleAppService _productionScheduleAppService;
+        private readonly ProdScheduleAppService _prodScheduleAppService;
 
         /// <summary>
         /// 优先级
@@ -357,7 +357,7 @@ namespace Business.ResourceExamineManagement
             MorderAppService morderAppService,
             BusinessBangDbContext businessBangDbContext,
             BusinessDbContext businessDbContext,
-            ProductionScheduleAppService productionScheduleAppService,
+            ProdScheduleAppService prodScheduleAppService,
             ISqlRepository<RoutingOpDetail> routingOpDetail,
             ISqlRepository<ProductStructureMaster> productStructureMaster,
             ISqlRepository<WorkOrdRouting> workOrdRouting,
@@ -429,7 +429,7 @@ namespace Business.ResourceExamineManagement
             _morderAppService = morderAppService;
             _businessBangDbContext = businessBangDbContext;
             _businessDbContext = businessDbContext;
-            _productionScheduleAppService = productionScheduleAppService;
+            _prodScheduleAppService = prodScheduleAppService;
             _routingOpDetail = routingOpDetail;
             _productStructureMaster = productStructureMaster;
             _workOrdRouting = workOrdRouting;
@@ -2153,5 +2153,17 @@ namespace Business.ResourceExamineManagement
             _rf_serialnumber.Update(model);
             return Wildcard.Replace(serialNumber, formData);
         }
+
+        /// <summary>
+        /// 生产排产
+        /// </summary>
+        /// <param name="workOrds"></param>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public async Task<string> ProductionSchedule(List<string> workOrds)
+        {
+            await _prodScheduleAppService.ProductionSchedule(workOrds);
+            return "ok";
+        }
     }
 }

+ 0 - 44
MicroServices/Business/Business.HttpApi/Controllers/ProductionScheduleController.cs

@@ -1,44 +0,0 @@
-using Business.ResourceExamineManagement;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Volo.Abp;
-using Volo.Abp.AspNetCore.Mvc;
-
-namespace Business.Controllers
-{
-    /// <summary>
-    /// 生产排产
-    /// </summary>
-    [RemoteService]
-    [Area("Business")]
-    [Route("api/business/production_schedule")]
-    public class ProductionScheduleController : AbpController
-    {
-        private readonly IProductionScheduleAppService _ProductionScheduleAppService;
-
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="ProductionScheduleAppService"></param>
-        public ProductionScheduleController(IProductionScheduleAppService ProductionScheduleAppService)
-        {
-            _ProductionScheduleAppService = ProductionScheduleAppService;
-        }
-
-        /// <summary>
-        /// 生产排产
-        /// </summary>
-        /// <param name="workOrds"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [Route("productionschedule")]
-        public Task<string> ProductionSchedule(String workOrds)
-        {
-            return _ProductionScheduleAppService.ProductionSchedule(new List<string>());
-        }
-    }
-}

+ 12 - 0
MicroServices/Business/Business.HttpApi/Controllers/ResourceExamineController.cs

@@ -26,6 +26,18 @@ namespace Business.Controllers
             _ResourceExamineAppService = ResourceExamineAppService;
         }
 
+        /// <summary>
+        /// 生产排产
+        /// </summary>
+        /// <param name="workOrds"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("productionschedule")]
+        public Task<string> ProductionSchedule(List<string> workOrds)
+        {
+            return _ResourceExamineAppService.ProductionSchedule(workOrds);
+        }
+
         /// <summary>
         /// 资源检查
         /// </summary>