|
|
@@ -1,17 +1,21 @@
|
|
|
-using Bussiness.Model.SystemData;
|
|
|
+using Business.Core.Utilities;
|
|
|
+using Bussiness.Model.SystemData;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
using System;
|
|
|
+using System.Configuration;
|
|
|
+using System.Net.Http;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using Volo.Abp.Application.Services;
|
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
+using Volo.Abp.Modularity;
|
|
|
|
|
|
namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
public class SerialNumberAppService : ApplicationService, ISerialNumberAppService
|
|
|
{
|
|
|
- private readonly IRepository<sys_serial_number, long> _sys_serial_number;
|
|
|
-
|
|
|
- public SerialNumberAppService(IRepository<sys_serial_number, long> sys_serial_number) {
|
|
|
- _sys_serial_number = sys_serial_number;
|
|
|
+ public SerialNumberAppService() {
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -22,81 +26,20 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
public string GetSerialNumber(long id)
|
|
|
{
|
|
|
- var model = Get(id);
|
|
|
- if (model == null)
|
|
|
- {
|
|
|
- return string.Empty;
|
|
|
- }
|
|
|
- int max = model.current_number + 1;
|
|
|
- var date = DateTime.Now;
|
|
|
- var lastDate = model.last_time;
|
|
|
- switch (model.number_type)
|
|
|
+ string sn = string.Empty;
|
|
|
+ if (id > long.MinValue)
|
|
|
{
|
|
|
- case 1: //年流水
|
|
|
- if (date.Year > lastDate.Year)
|
|
|
- {
|
|
|
- max = 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2: //月流水
|
|
|
- if (date.Year > lastDate.Year || date.Month > lastDate.Month)
|
|
|
- {
|
|
|
- max = 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 3: //日流水
|
|
|
- if (date.Year > lastDate.Year || date.Month > lastDate.Month || date.Day > lastDate.Day)
|
|
|
- {
|
|
|
- max = 1;
|
|
|
- }
|
|
|
- break;
|
|
|
+ IConfiguration configuration = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
|
|
|
+ var tfSite = configuration["appSettings:ThinkFlow"];
|
|
|
+ string url = tfSite + "/ThinkFlowApi/SerialNumber/GetMaxSerialNumber?id=" + id.ToString();
|
|
|
+ /*JObject jobect = new() {
|
|
|
+ { "id", id }
|
|
|
+ };
|
|
|
+ string postJson = jobect.ToString();*/
|
|
|
+ string json = HttpHelper.HttpPost(url, "");
|
|
|
+ sn = json;
|
|
|
}
|
|
|
- model.last_time = date;
|
|
|
- model.current_number = max;
|
|
|
- string number = max.ToString().PadLeft(model.number_size, '0');
|
|
|
- string sn = model.format;
|
|
|
- sn = Replace(sn);
|
|
|
- if (sn.Contains("{number}"))
|
|
|
- {
|
|
|
- sn = Regex.Replace(sn, "{number}", number);
|
|
|
- }
|
|
|
- Update(model);
|
|
|
return sn;
|
|
|
}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 获取流水号规则配置信息
|
|
|
- /// </summary>
|
|
|
- /// <param name="id"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private sys_serial_number Get(long id)
|
|
|
- {
|
|
|
- return _sys_serial_number.FindAsync(id).Result;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 替换通配符
|
|
|
- /// </summary>
|
|
|
- private string Replace(string str)
|
|
|
- {
|
|
|
- if (str.Contains("{DateTime<"))
|
|
|
- {
|
|
|
- string key = str.Substring(str.IndexOf("{DateTime<") + 10);
|
|
|
- string key1 = key.Substring(0, key.IndexOf(">}"));
|
|
|
- if (!string.IsNullOrWhiteSpace(key1))
|
|
|
- {
|
|
|
- string newChar = DateTime.Now.ToString(key1);
|
|
|
- string old = "{DateTime<" + key1 + ">}";
|
|
|
- return str.Replace(old, newChar);
|
|
|
- }
|
|
|
- }
|
|
|
- return str;
|
|
|
- }
|
|
|
-
|
|
|
- public void Update(sys_serial_number model)
|
|
|
- {
|
|
|
- _sys_serial_number.UpdateAsync(model);
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
}
|