|
|
@@ -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瑞奇采购预测获取失败,请联系管理员。";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|