فهرست منبع

代码提交。

tangdi 2 سال پیش
والد
کامیت
8094df37ba

+ 29 - 0
MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/Dto/ProcurementForecast.cs

@@ -0,0 +1,29 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.ResourceExamineManagement.Dto
+{
+    [Keyless]
+    public class ProcurementForecast
+    {
+        public string wlh { get; set; }
+
+        public string wlmc { get; set; }
+
+        public string wlgg { get; set; }
+
+        public string gysdm { get; set; }
+
+        public string gysmc { get; set; }
+
+        public string jbdw { get; set; }
+
+        public decimal? sl { get; set; }
+
+        public string cgyf { get; set; }
+    }
+}

+ 2 - 0
MicroServices/Business/Business.Application.Contracts/SystemJob/ISystemJobAppService.cs

@@ -48,5 +48,7 @@ namespace Business.SystemJob
         Task<string> SyncItemStockOccupyClear();
 
         string TestTimeOut();
+
+        Task<string> GetProcurementForecastApi(string purchasenumber);
     }
 }

+ 38 - 0
MicroServices/Business/Business.Application/SystemJobManagement/SystemJobAppService.cs

@@ -10,10 +10,13 @@ using EFCore.BulkExtensions;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
 using MongoDB.Driver.Linq;
+using Newtonsoft.Json;
 using NLog;
 using System;
 using System.Collections.Generic;
+using System.Data;
 using System.Linq;
+using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using Volo.Abp.Application.Services;
@@ -1371,5 +1374,40 @@ namespace Business.SystemJobManagement
                 return ex.Message;
             }
         }
+
+
+        /// <summary>
+        /// 获取采购预测数据,提供供应商代码查询
+        /// </summary>
+        /// <returns></returns>
+        public async Task<string> GetProcurementForecastApi(string purchasenumber)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(purchasenumber))
+                {
+                    return "请求的供应商编码无效,请检查。";
+                }
+                //首先根据发布表,提取对应的物料号,供应商信息。
+                string sql = string.Format("SELECT p.wlh,p.wlmc,p.wlgg,p.gysdm,p.gysmc,p.jbdw,p.sl,p.cgyf from (" +
+                    "select wlh, wlmc, wlgg, gysdm, gysmc, jbdw, sl, left(rq, 4) + '-' + substring(rq, 5, 2) cgyf from scm_cgyc WHERE gysdm = '{0}'" +
+                    " union " +
+                    "SELECT i.number wlh, i.name wlmc, i.model wlgg, pr_purchasenumber gysdm, pr_purchasename gysmc, i.unit jbdw, p.pr_aqty sl, convert(varchar(7), p.pr_sarrive_date, 120) cgyf FROM srm_pr_main p left join ic_item i on p.icitem_id = i.id and p.company_id = i.company_id AND p.factory_id = i.factory_id " +
+                    "WHERE p.state = 1 AND p.pr_sarrive_date is not null AND p.pr_purchasenumber = '{0}') p left join scm_cgycfb m on p.wlh = m.wlh and p.gysdm = m.gysdm WHERE m.fbrq is not null", purchasenumber);
+
+                var list = _businessDbContext.ProcurementForecast.FromSqlRaw(sql).ToList();
+                string result = "OK";
+                if (list.Any())
+                {
+                    result += JsonConvert.SerializeObject(list);
+                }
+                return result;
+            }
+            catch (Exception ex)
+            {
+                new NLogHelper("SystemJobAppService").WriteLog("GetProcurementForecastApi", "瑞奇采购预测获取失败:" + ex.Message);
+                return "NG瑞奇采购预测获取失败,请联系管理员。";
+            }
+        }
     }
 }

+ 2 - 0
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/DOP/BusinessDbContext.cs

@@ -34,6 +34,8 @@ namespace Business.EntityFrameworkCore
 
         public DbSet<GetNbr> GetNbr { get; set; }
 
+        public DbSet<ProcurementForecast> ProcurementForecast { get; set; }
+
         public DbSet<InvTransHistDto> InvTransHistDto { get; set; }
 
         public DbSet<InvTransHistDetailDto> InvTransHistDetailDto { get; set; }

+ 11 - 0
MicroServices/Business/Business.HttpApi/Controllers/SystemJobController.cs

@@ -108,5 +108,16 @@ namespace Business.Controllers
         {
             return "V2.7.9";
         }
+
+        /// <summary>
+        /// 获取采购预测数据
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [Route("GetProcurementForecastApi")]
+        public Task<string> GetProcurementForecastApi(string purchasenumber)
+        {
+            return _SystemJobAppService.GetProcurementForecastApi(purchasenumber);
+        }
     }
 }