diff --git a/UFIDA.U8.Framework.Api.Common/Entity/SysU8AccountConfig.cs b/UFIDA.U8.Framework.Api.Common/Entity/SysU8AccountConfig.cs
index 9f3bc0d..932adeb 100644
--- a/UFIDA.U8.Framework.Api.Common/Entity/SysU8AccountConfig.cs
+++ b/UFIDA.U8.Framework.Api.Common/Entity/SysU8AccountConfig.cs
@@ -68,12 +68,6 @@ namespace UFIDA.U8.Framework.Api.Common.Entity
[SugarColumn(ColumnDescription = "状态")]
public virtual StatusEnum Status { get; set; } = StatusEnum.Enable;
- ///
- /// 是否外部登录
- ///
- [SugarColumn(ColumnDescription = "是否外部登录")]
- public virtual bool bOutLogin { get; set; } = false;
-
///
/// 备注
///
diff --git a/UFIDA.U8.Framework.Api.Common/Entity/SysU8FieldDefine.cs b/UFIDA.U8.Framework.Api.Common/Entity/SysU8FieldDefine.cs
new file mode 100644
index 0000000..7913ed7
--- /dev/null
+++ b/UFIDA.U8.Framework.Api.Common/Entity/SysU8FieldDefine.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SqlSugar;
+
+namespace UFIDA.U8.Framework.Api.Common.Entity
+{
+ ///
+ /// 系统U8字段信息表
+ ///
+ [SugarTable("SysU8FieldDefine", "系统U8字段信息表")]
+ [SugarIndex("index_{table}_I", nameof(Id), OrderByType.Asc)]
+ public class SysU8FieldDefine
+ {
+ [SugarColumn(IsIdentity = true, IsPrimaryKey = true, ColumnDescription = "主键", ColumnName = "Id", IsNullable = false)]
+ public int Id { get; set; }
+ [SugarColumn(ColumnName = "FieldName", Length = 200, IsNullable = false)]
+ public string FieldName { get; set; }
+ [SugarColumn(ColumnName = "FieldDesc", Length = 200, IsNullable = true)]
+ public string FieldDesc { get; set; }
+ [SugarColumn(ColumnName = "ModelName", Length = 200, IsNullable = true)]
+ public string ModelName { get; set; }
+ [SugarColumn(ColumnName = "ModelDesc", Length = 200, IsNullable = true)]
+ public string ModelDesc { get; set; }
+ [SugarColumn(ColumnName = "bDefault", IsNullable = true)]
+ public bool? bDefault { get; set; }
+ [SugarColumn(ColumnName = "DefaultValue", Length = 200, IsNullable = true)]
+ public string DefaultValue { get; set; }
+ [SugarColumn(ColumnName = "CardNumber", Length = 200, IsNullable = false)]
+ public string CardNumber { get; set; }
+ [SugarColumn(ColumnName = "cPosition", Length = 200, IsNullable = true)]
+ public string cPosition { get; set; }
+ [SugarColumn(ColumnName = "bArchives", IsNullable = true)]
+ public bool? bArchives { get; set; }
+ [SugarColumn(ColumnName = "bCalc", IsNullable = true)]
+ public bool? bCalc { get; set; }
+ //[SugarColumn(ColumnName = "bCalc", IsNullable = true)]
+ //public bool? bToBody { get; set; }
+ [SugarColumn(ColumnName = "ArchivesTable", Length = 200, IsNullable = true)]
+ public string ArchivesTable { get; set; }
+ [SugarColumn(ColumnName = "ArchivesField", Length = 200, IsNullable = true)]
+ public string ArchivesField { get; set; }
+ [SugarColumn(ColumnName = "ArchivesSource", Length = 200, IsNullable = true)]
+ public string ArchivesSource { get; set; }
+ [SugarColumn(ColumnName = "CalcFormula", Length = 1000, IsNullable = true)]
+ public string CalcFormula { get; set; }
+
+ [SugarColumn(ColumnName = "cPrecision", IsNullable = true)]
+ public int? cPrecision { get; set; }
+
+ [SugarColumn(ColumnName = "bPrice", IsNullable = true)]
+ public bool? bPrice { get; set; }
+
+ [SugarColumn(ColumnName = "bDate", IsNullable = true)]
+ public bool? bDate { get; set; }
+
+ [SugarColumn(ColumnName = "iSort", IsNullable = true)]
+ public int? iSort { get; set; }
+
+ [SugarColumn(ColumnName = "iSort", IsNullable = true)]
+ public bool? bEnable { get; set; }
+
+
+ }
+}
diff --git a/UFIDA.U8.Framework.Api.Common/Entity/SysU8VoucherDefine.cs b/UFIDA.U8.Framework.Api.Common/Entity/SysU8VoucherDefine.cs
new file mode 100644
index 0000000..3ab0f7a
--- /dev/null
+++ b/UFIDA.U8.Framework.Api.Common/Entity/SysU8VoucherDefine.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SqlSugar;
+
+namespace UFIDA.U8.Framework.Api.Common.Entity
+{
+
+ ///
+ /// 系统U8单据信息表
+ ///
+ [SugarTable("SysU8VoucherDefine", "系统U8单据信息表")]
+ [SugarIndex("index_{table}_I", nameof(Id), OrderByType.Asc)]
+ public class SysU8VoucherDefine
+ {
+
+ [SugarColumn(IsIdentity = true, IsPrimaryKey = true, ColumnDescription = "主键", ColumnName = "Id", IsNullable = false)]
+ public int Id { get; set; }
+
+ ///
+ /// 单据类型编号
+ ///
+ [SugarColumn(ColumnDescription = "单据类型编号", Length = 100, IsNullable = false)]
+ public string CardNumber { get; set; }
+
+ ///
+ /// 单据表体字段名称
+ ///
+ [SugarColumn(ColumnDescription = "单据表体字段名称", Length = 100, IsNullable = false)]
+ public string BodyName { get; set; }
+
+ ///
+ /// 单据类型参数值
+ ///
+ [SugarColumn(ColumnDescription = "单据类型参数值", Length = 100)]
+ public string VoucherType { get; set; }
+
+ ///
+ /// 是否自动审核
+ ///
+ [SugarColumn(ColumnDescription = "是否自动审核")]
+ public bool bVerify { get; set; }
+
+ }
+}
diff --git a/UFIDA.U8.Framework.Api.Common/UFIDA.U8.Framework.Api.Common.csproj b/UFIDA.U8.Framework.Api.Common/UFIDA.U8.Framework.Api.Common.csproj
index 6e08b52..db6ee31 100644
--- a/UFIDA.U8.Framework.Api.Common/UFIDA.U8.Framework.Api.Common.csproj
+++ b/UFIDA.U8.Framework.Api.Common/UFIDA.U8.Framework.Api.Common.csproj
@@ -52,7 +52,9 @@
+
+
diff --git a/UFIDA.U8.Framework.Api.ControlObject/Common/CommonHelper.cs b/UFIDA.U8.Framework.Api.ControlObject/Common/CommonHelper.cs
index 81acf8b..bbe2651 100644
--- a/UFIDA.U8.Framework.Api.ControlObject/Common/CommonHelper.cs
+++ b/UFIDA.U8.Framework.Api.ControlObject/Common/CommonHelper.cs
@@ -1,11 +1,17 @@
using System;
using System.Collections.Generic;
+using System.Data;
+using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
+using System.Web.UI.WebControls;
+using ADODB;
using GetComObj;
using MSXML2;
using Newtonsoft.Json.Linq;
+using UFIDA.U8.Framework.Api.Common.Entity;
+using UFIDA.U8.Framework.Api.ControlObject.Entity;
using UFIDA.U8.Framework.Api.ControlObject.Json;
namespace UFIDA.U8.Framework.Api.ControlObject.Common
@@ -314,5 +320,294 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
return rethash + (char)3;
}
+
+ ///
+ /// 获取币种汇率
+ ///
+ /// 日期
+ /// 账套
+ /// 币种
+ /// 连接对象
+ ///
+ public static Exch GetExch(DateTime dDate, string cAccId, string exchName, Connection conn)
+ {
+ var strSql =
+ $@"SELECT a.cexch_name,a.bcal,a.idec,round(convert(decimal(28,20),a.nerror),a.idec) nerror,b.itype,a.iotherused,b.nflat
+ FROM foreigncurrency a
+ left join exch b on b.cexch_name=a.cexch_name
+ left join ufsystem.dbo.UA_Period c on c.iYear=b.iyear and c.iId=b.iperiod and cAcc_Id='{cAccId}' and bIsDelete=0
+ WHERE (a.iotherused=-1 or (b.itype=2 and c.dBegin>='{dDate:yyyy-MM-dd}' and c.dEnd<='{dDate:yyyy-MM-dd}')) and a.cexch_name='{exchName}'
+ order by b.itype ";
+
+ var rs = new Recordset();
+ rs.Open(strSql, conn); //查询档案
+
+ if (rs.BOF || rs.EOF)
+ throw new Exception($"当前币种:{exchName}在当前会计期间未设置汇率");
+
+ rs.MoveFirst();
+
+ var exch = new Exch
+ {
+ cexch_name = $"{rs.Fields["cexch_name"].Value}"
+ };
+
+ if (rs.Fields["bcal"].Value != null)
+ {
+ exch.bcal = Convert.ToBoolean(rs.Fields["bcal"].Value);
+ }
+
+ if (rs.Fields["idec"].Value != null)
+ {
+ exch.idec = Convert.ToInt16(rs.Fields["idec"].Value);
+ }
+
+ if (rs.Fields["nerror"].Value != null)
+ {
+ exch.nerror = Convert.ToDecimal(rs.Fields["nerror"].Value);
+ }
+
+ if (rs.Fields["iotherused"].Value != null)
+ {
+ exch.iotherused = Convert.ToInt32(rs.Fields["iotherused"].Value);
+ }
+
+ if (rs.Fields["nflat"].Value != null && !string.IsNullOrWhiteSpace($"{rs.Fields["nflat"].Value}"))
+ {
+ exch.nflat = Convert.ToDecimal(rs.Fields["nflat"].Value);
+ }
+
+ return exch;
+
+ }
+
+ ///
+ /// 设置字典对象数据
+ ///
+ /// 字典对象
+ /// 实体字段配置信息
+ /// 数据库连接对象
+ /// 新单号
+ /// 行号
+ /// 是否更新
+ ///
+ public static Dictionary SetDictionaryData(this Dictionary dict, List defs, Connection conn = null, string newCode = "", int rowNo = 1, Exch exch = null, bool bUpdate = false)
+ {
+ var adef = defs.Where(s => s.bDefault ?? false).ToList();
+ //var codeField = "";
+ if (adef.Count > 0 && !bUpdate)
+ {
+ foreach (var def in adef)
+ {
+ switch (def.DefaultValue)
+ {
+ case "当前日期":
+ dict[def.FieldName] = $"{DateTime.Today:yyyy-MM-dd}";
+ break;
+ case "当前日期时间":
+ dict[def.FieldName] = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}";
+ break;
+ case "单号":
+ dict[def.FieldName] = newCode; //一直取不到,怀疑是带字段的关系,需要后续研究后确定
+ //codeField = def.FieldName;
+ break;
+ case "行号":
+ dict[def.FieldName] = rowNo;
+ break;
+ case "汇率":
+ if (exch?.nflat != null && string.IsNullOrWhiteSpace($"{dict[def.FieldName]}"))
+ {
+ dict[def.FieldName] = exch.nflat;
+ }
+
+ if (exch?.iotherused == -1)
+ {
+ dict[def.FieldName] = 1;
+ }
+
+ break;
+ default:
+ if (!dict.ContainsKey(def.FieldName) || string.IsNullOrWhiteSpace($"{dict[def.FieldName]}"))
+ dict[def.FieldName] = def.DefaultValue ?? "";
+ break;
+ }
+ }
+ }
+
+ //查找档案关联的字段并赋值
+ var keys = dict.Keys.ToList();
+
+ foreach (var key in keys)
+ {
+ var bdef = defs.Where(s => s.ModelName == key && (s.bArchives ?? false)).ToList(); //获取当前字段的关联信息
+
+ if (bdef.Count <= 0) continue;
+
+ var archivesTablesList = bdef.Select(s => s.ArchivesTable).Distinct().ToList(); //合并关联的档案表
+
+ if (archivesTablesList.Count <= 0) continue;
+
+ foreach (var archives in archivesTablesList) //根据档案表查询
+ {
+ var fieldList = bdef.Where(s => s.ArchivesTable == archives)
+ .Select(s => new { s.FieldName, s.ArchivesField }).ToList(); //获取需要查询的字段
+ var field = bdef.Where(s => s.ArchivesTable == archives).Select(s => s.ArchivesSource).First(); //获取档案与实体的关联字段
+ var strField = string.Join(",", fieldList.Select(s => s.ArchivesField)); //组装需要查询的字段
+
+ var strSql = $"SELECT {strField} FROM {archives} WHERE {field}='{dict[key]}'"; //构建查询语句
+
+ var rs = new Recordset();
+ rs.Open(strSql, conn); //查询档案
+
+ if (rs.BOF || rs.EOF) continue; //无数据不赋值
+
+ rs.MoveFirst();
+ foreach (var f in fieldList)
+ {
+ dict[f.FieldName] = $"{rs.Fields[f.ArchivesField].Value}"; //根据字段值赋值
+ }
+ }
+ }
+
+ var cdef = defs.Where(s => s.bCalc ?? false).OrderBy(s => s.iSort).ToList(); //获取计算列的配置
+
+ if (cdef.Count > 0)
+ {
+ foreach (var def in cdef)
+ {
+ var calcFormula = def.CalcFormula;
+ var cPrecision = def.cPrecision;
+ foreach (var key in dict.Keys.Where(key => calcFormula.Contains($"{{{key}}}"))) //遍历字段来替换公式中的参数
+ {
+ calcFormula = calcFormula.Replace($"{{{key}}}", $"{dict[key]}");
+ }
+
+ //汇率单独处理
+ if (calcFormula.Contains("{汇率:B}") || calcFormula.Contains("{汇率:Y}"))
+ {
+ var YB = "B";
+ var pp = "*";
+ if (calcFormula.Contains("{汇率:Y}"))
+ {
+ YB = "Y";
+ }
+
+ var nflat = 1m;
+ if (exch != null)
+ {
+ if (exch.iotherused != -1)
+ {
+ if (exch.idec != null)
+ cPrecision = Convert.ToInt32(exch.idec);
+
+ nflat = exch.nflat ?? 1;
+
+ if (YB == "Y" && !(exch.bcal ?? false))
+ {
+ pp = "/";
+ }
+
+ if (YB == "B" && (exch.bcal ?? false))
+ {
+ pp = "/";
+ }
+ }
+ else
+ {
+ cPrecision = null;
+ }
+ }
+
+ calcFormula = calcFormula.Replace("{汇率:B}", $"{pp}{nflat}");
+ calcFormula = calcFormula.Replace("{汇率:Y}", $"{pp}{nflat}");
+ }
+
+ try
+ {
+ var dt = new DataTable();
+
+ var val = cPrecision == null
+ ? dt.Compute(calcFormula, "")
+ : Math.Round(Convert.ToDecimal(dt.Compute(calcFormula, "")), cPrecision ?? 6); //计算公式结果
+
+ dict[def.FieldName] = val;
+ }
+ catch (Exception ex)
+ {
+ logInfo.Debug($"字段:{def.FieldName}公式解析失败,公式结果:{calcFormula}");
+ }
+
+
+ }
+ }
+
+ return dict;
+ }
+
+
+ ///
+ /// 把对象转换为Boolean类型
+ ///
+ /// 需要转换的对象
+ ///
+ public static bool ToBoolean(this object obj)
+ {
+ return bool.TryParse($"{obj}", out var re) && re;
+ }
+
+ ///
+ /// 把对象转换为Int类型
+ ///
+ /// 需要转换的对象
+ ///
+ public static int ToShort(this object obj)
+ {
+ if (!short.TryParse($"{obj}", out var re))
+ throw new InvalidCastException($"值:{obj}无法转换为短数字格式!");
+
+ return re;
+ }
+
+ ///
+ /// 把对象转换为Int类型
+ ///
+ /// 需要转换的对象
+ ///
+ public static int ToInt(this object obj)
+ {
+ if (!int.TryParse($"{obj}", out var re))
+ throw new InvalidCastException($"值:{obj}无法转换为数字格式!");
+
+ return re;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string GenRandomString(int length, bool useNum, bool useLow, bool useUpp, bool useSpe,
+ string customerStr)
+ {
+ var b = new byte[4];
+ new RNGCryptoServiceProvider().GetBytes(b);
+ var r = new Random(BitConverter.ToInt32(b, 0));
+ string s = null, str = customerStr;
+ if (useNum) str += "0123456789";
+ if (useLow) str += @"abcdefghijklmnopqrstuvwxyz";
+ if (useUpp) str += @"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ if (useSpe) str += "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
+ for (var i = 0; i < length; i++)
+ {
+ s += str.Substring(r.Next(0, str.Length - 1), 1);
+ }
+
+ return s;
+ }
}
}
diff --git a/UFIDA.U8.Framework.Api.ControlObject/Entity/Exch.cs b/UFIDA.U8.Framework.Api.ControlObject/Entity/Exch.cs
new file mode 100644
index 0000000..17839ce
--- /dev/null
+++ b/UFIDA.U8.Framework.Api.ControlObject/Entity/Exch.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UFIDA.U8.Framework.Api.ControlObject.Entity
+{
+ public class Exch
+ {
+ public string cexch_name { get; set; }
+
+ public bool? bcal { get; set; }
+
+ public short? idec { get; set; }
+
+ public decimal? nerror { get; set; }
+
+ public int? iotherused { get; set; }
+
+ public decimal? nflat { get; set; }
+
+ }
+}
diff --git a/UFIDA.U8.Framework.Api.ControlObject/Entity/LoginParamter.cs b/UFIDA.U8.Framework.Api.ControlObject/Entity/LoginParamter.cs
index 2d34fd6..344a635 100644
--- a/UFIDA.U8.Framework.Api.ControlObject/Entity/LoginParamter.cs
+++ b/UFIDA.U8.Framework.Api.ControlObject/Entity/LoginParamter.cs
@@ -50,5 +50,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Entity
/// 序列号,一般不填
///
public string cSerial { get; set; } = "";
+
+ ///
+ /// 登录的账套id,不填
+ ///
+ public string cAccId { get; set; }
}
}
diff --git a/UFIDA.U8.Framework.Api.ControlObject/ST/USERPCO.cs b/UFIDA.U8.Framework.Api.ControlObject/ST/USERPCO.cs
index 955670e..25e34f5 100644
--- a/UFIDA.U8.Framework.Api.ControlObject/ST/USERPCO.cs
+++ b/UFIDA.U8.Framework.Api.ControlObject/ST/USERPCO.cs
@@ -18,7 +18,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
- public async Task> Insert(BaseLogin baseLogin, Dictionary dictionary,string sVouchType,bool bCheck=true,bool bBeforCheckStock=true,bool bIsRedVouch=false,string sAddedState="", bool bReMote=false)
+ public async Task> Insert(BaseLogin baseLogin, Dictionary dictionary,string sVouchType,bool bGetCode=false,bool bCheck=true,bool bBeforCheckStock=true,bool bIsRedVouch=false,string sAddedState="", bool bReMote=false)
{
try
{
diff --git a/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs b/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs
index 71869c1..73e1ee6 100644
--- a/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs
+++ b/UFIDA.U8.Framework.Api.ControlObject/U8M/BaseLogin.cs
@@ -32,6 +32,18 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
public string userToken => _vbLogin.userToken;
+ public string UfDbName => _vbLogin.UfDbName;
+
+ public string UFDataConnstringForNet => _vbLogin.UFDataConnstringForNet;
+
+ public string UfMetaName => _vbLogin.UfMetaName;
+
+ public string UFMetaConnstringForNet => _vbLogin.UFMetaConnstringForNet;
+
+ public string UfSystemDb => _vbLogin.UfSystemDb;
+
+
+
///
/// 初始化生产制造上下文
///
diff --git a/UFIDA.U8.Framework.Api.ControlObject/UFIDA.U8.Framework.Api.ControlObject.csproj b/UFIDA.U8.Framework.Api.ControlObject/UFIDA.U8.Framework.Api.ControlObject.csproj
index 943e335..962b9b4 100644
--- a/UFIDA.U8.Framework.Api.ControlObject/UFIDA.U8.Framework.Api.ControlObject.csproj
+++ b/UFIDA.U8.Framework.Api.ControlObject/UFIDA.U8.Framework.Api.ControlObject.csproj
@@ -181,6 +181,7 @@
+
@@ -212,5 +213,11 @@
True
+
+
+ {0682DC28-D5F7-4A10-BD3D-20ECD1FC987E}
+ UFIDA.U8.Framework.Api.Common
+
+
\ No newline at end of file
diff --git a/UFIDA.U8.Framework.Api/App_Data/API_Meta.db b/UFIDA.U8.Framework.Api/App_Data/API_Meta.db
index d5c0e21..10c2ab9 100644
Binary files a/UFIDA.U8.Framework.Api/App_Data/API_Meta.db and b/UFIDA.U8.Framework.Api/App_Data/API_Meta.db differ
diff --git a/UFIDA.U8.Framework.Api/App_Data/U8API.xml b/UFIDA.U8.Framework.Api/App_Data/U8API.xml
index 4bb7842..e8015c6 100644
--- a/UFIDA.U8.Framework.Api/App_Data/U8API.xml
+++ b/UFIDA.U8.Framework.Api/App_Data/U8API.xml
@@ -663,6 +663,41 @@
+
+
+ 获取加密字符串
+
+
+
+
+
+
+ 获取解密字符串
+
+
+
+
+
+
+ 新增对接账套设置
+
+
+
+
+
+
+ 更新对接账套设置
+
+
+
+
+
+
+ 获取对接账套设置列表
+
+
+
+
生产订单
diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs
index 589adaf..a7e70a9 100644
--- a/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs
+++ b/UFIDA.U8.Framework.Api/Controllers/U8/DPController.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using log4net;
@@ -69,6 +65,8 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
{
try
{
+ await Task.Delay(1);
+
return new BaseResult() { bSuccess = true, message = "加密成功", result = CommonHelper.U8Encrypt(cPwd) };
}
catch (Exception ex)
@@ -106,5 +104,171 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
}
}
+
+ ///
+ /// 获取加密字符串
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("api/U8/DP/GetEncryptString")]
+ public async Task> GetEncryptString(string input)
+ {
+ try
+ {
+ await Task.Delay(1);
+
+ return new BaseResult { bSuccess = true, message = "加密成功", result = CommUnit.GetEncrypt(input) };
+ }
+ catch (Exception ex)
+ {
+ logInfo.Error(ex.Message, ex);
+
+ return new BaseResult { bSuccess = false, message = "加密失败", result = ex.Message };
+ }
+ }
+
+ ///
+ /// 获取解密字符串
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("api/U8/DP/GetDecryptString")]
+ public async Task> GetDecryptString(string input)
+ {
+ try
+ {
+ await Task.Delay(1);
+
+ return new BaseResult { bSuccess = true, message = "解密成功", result = CommUnit.GetDecrypt(input) };
+ }
+ catch (Exception ex)
+ {
+ logInfo.Error(ex.Message, ex);
+
+ return new BaseResult { bSuccess = false, message = "解密失败", result = ex.Message };
+ }
+ }
+
+ ///
+ /// 新增对接账套设置
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("api/U8/DP/AddAccountConfig")]
+ public async Task> AddAccountConfig([FromBody] AddU8AccountConfigInput input)
+ {
+ try
+ {
+ var db = CommUnit.GetDbClient();
+
+ var isExists = await db.Queryable().AnyAsync(a => a.cAccountNo == input.cAccountNo);
+
+ if (isExists)
+ {
+ throw new Exception($"已存在系统号为{input.cAccountNo}的数据");
+ }
+
+ try
+ {
+ if (!string.IsNullOrWhiteSpace(input.cPassword))
+ {
+ CommUnit.GetDecrypt(input.cPassword);
+ }
+ }
+ catch (Exception ex)
+ {
+ logInfo.Debug($"密码未加密:{ex.Message},将进行密码加密");
+
+ input.cPassword = CommUnit.GetEncrypt(input.cPassword);
+ }
+
+ var id = await db.Insertable(input).ExecuteReturnIdentityAsync();
+
+ return new BaseResult { bSuccess = true, message = "新增成功", result = id };
+ }
+ catch (Exception ex)
+ {
+ logInfo.Error(ex.Message, ex);
+
+ return new BaseResult { bSuccess = false, message = "新增失败", result = ex.Message };
+ }
+
+ }
+
+ ///
+ /// 更新对接账套设置
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("api/U8/DP/UpdateAccountConfig")]
+ public async Task> UpdateAccountConfig([FromBody] AddU8AccountConfigInput input)
+ {
+ try
+ {
+ var db = CommUnit.GetDbClient();
+
+ var isExists = await db.Queryable().AnyAsync(a => a.Id == input.Id);
+
+ if (!isExists)
+ {
+ throw new Exception($"不存在系统号为{input.cAccountNo}的数据");
+ }
+
+ try
+ {
+ if (!string.IsNullOrWhiteSpace(input.cPassword))
+ {
+ CommUnit.GetDecrypt(input.cPassword);
+ }
+ }
+ catch (Exception ex)
+ {
+ logInfo.Debug($"密码未加密:{ex.Message},将进行密码加密");
+
+ input.cPassword = CommUnit.GetEncrypt(input.cPassword);
+ }
+
+ var id = await db.Updateable(input).ExecuteCommandAsync();
+
+ return new BaseResult { bSuccess = true, message = "更新成功", result = id };
+ }
+ catch (Exception ex)
+ {
+ logInfo.Error(ex.Message, ex);
+
+ return new BaseResult { bSuccess = false, message = "更新失败", result = ex.Message };
+ }
+ }
+
+ ///
+ /// 获取对接账套设置列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("api/U8/DP/ListAccountConfig")]
+ public async Task> ListAccountConfig([FromBody] ListU8AccountConfigInput input)
+ {
+ try
+ {
+ var db = CommUnit.GetDbClient();
+
+ var res = await db.Queryable()
+ .WhereIF(!string.IsNullOrWhiteSpace(input.cAccId), a => a.cAccountNo == input.cAccId)
+ .ToListAsync();
+
+ return new BaseResult { bSuccess = true, message = "查询成功", result = res };
+ }
+ catch (Exception ex)
+ {
+ logInfo.Error(ex.Message, ex);
+
+ return new BaseResult { bSuccess = false, message = "查询失败", result = ex.Message };
+ }
+ }
}
}
diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs
index 8860005..dc81a35 100644
--- a/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs
+++ b/UFIDA.U8.Framework.Api/Controllers/U8/STController.cs
@@ -1,13 +1,18 @@
using log4net;
+using log4net.Util;
using Microsoft.Extensions.Caching.Memory;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
+using UFIDA.U8.Framework.Api.Common.Entity;
using UFIDA.U8.Framework.Api.ControlObject.AP;
+using UFIDA.U8.Framework.Api.ControlObject.Common;
using UFIDA.U8.Framework.Api.ControlObject.Entity;
+using UFIDA.U8.Framework.Api.ControlObject.Json;
using UFIDA.U8.Framework.Api.ControlObject.ST;
using UFIDA.U8.Framework.Api.ControlObject.U8M;
using UFIDA.U8.Framework.Api.Unit;
@@ -36,16 +41,26 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
///
///
[HttpPost]
- [Route("api/U8/ST/0411/Insert")]
+ [Route("api/U8/ST/{cCardNum}/Insert")]
public async Task> Insert(string cAccId, string cCardNum,[FromBody] Dictionary input, bool bCheck = true,bool bBeforCheckStock=true,bool bIsRedVouch=false,string sAddedState="",bool bReMote=false)
{
try
{
+ var db = CommUnit.GetDbClient();
+
+ var workId = SnowFlakeSingle.Instance.NextId();
+
+ logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:新增,对接账套:{cAccId},数据:{input.ToJson()}");
+
+ LoginParamter param;
+
if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin))
{
+ logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建");
+
baseLogin = new BaseLogin();
- var param = await CommUnit.GetLoginParamter(cAccId);
+ param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{
@@ -58,11 +73,153 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
_cache.Set($"U8_{cAccId}", baseLogin);
}
+ else
+ {
+ param = await CommUnit.GetLoginParamter(cAccId);
+ }
- var bo = new USERPCO();
+ logInfo.Debug($"作业Id:{workId}-----登录信息获取完成,缓存设置完成,开始加载单据配置信息");
- var res =await bo.Insert(baseLogin, input, "11", bCheck, bBeforCheckStock, bIsRedVouch, sAddedState,
- bReMote);
+ var voucherInfo = db.Queryable().First(s => s.CardNumber == cCardNum);
+
+ var defs = db.Queryable().Where(s => s.CardNumber == cCardNum && s.cPosition == "H" && s.bEnable==true).ToList(); //查询表头字段配置,供后续设置字段值
+
+ var dateKey = "";
+ var exchKey = "";
+ if (defs.Any(a => a.bDate == true && a.cPosition == "H"))
+ dateKey = defs.Where(a => a.bDate == true && a.cPosition == "H").Select(a => a.FieldName).First();
+
+ if (defs.Any(a => a.bPrice == true && a.cPosition == "H"))
+ exchKey = defs.Where(a => a.bPrice == true && a.cPosition == "H").Select(a => a.FieldName).First();
+
+ var dDate = DateTime.Today;
+ if (!string.IsNullOrWhiteSpace(dateKey))
+ {
+ if (!DateTime.TryParse($"{input[dateKey]}", out dDate))
+ {
+ dDate = DateTime.Today;
+ }
+ }
+
+ Exch exch;
+
+ if (!string.IsNullOrWhiteSpace(exchKey) && input.ContainsKey(exchKey))
+ {
+ exch = CommonHelper.GetExch(dDate, param.cAccId, $"{input[exchKey]}", baseLogin.Connection);
+ }
+ else
+ {
+ exch = null;
+ }
+
+
+ var newNumber = "";
+
+ #region 调整日期,去掉时间部分
+
+ if (input.ContainsKey("ddate"))
+ {
+ logInfo.Debug($"作业Id:{workId}-----调整日期,去掉时间部分");
+ input["ddate"] = $"{Convert.ToDateTime(input["ddate"]):yyyy-MM-dd}";
+ }
+
+ if (input.ContainsKey("dtvdate"))
+ {
+ logInfo.Debug($"作业Id:{workId}-----调整日期,去掉时间部分");
+ input["dtvdate"] = $"{Convert.ToDateTime(input["dtvdate"]):yyyy-MM-dd}";
+ }
+
+ #endregion
+ logInfo.Debug($"作业Id:{workId}-----设置表头数据");
+ input.SetDictionaryData(defs, baseLogin.Connection, newNumber, 1, exch);
+
+ logInfo.Debug($"作业Id:{workId}-----读取表体数据");
+ var bodyData = input[voucherInfo.BodyName].ToJson().ToList>(); //读取表体的数据
+
+ if (bodyData == null || bodyData.Count <= 0)
+ throw new Exception("无表体数据!");
+
+ logInfo.Debug($"作业Id:{workId}-----获取表体字段配置");
+ var defsBody = db.Queryable().Where(s => s.CardNumber == cCardNum && s.cPosition == "B" && s.bEnable==true).ToList(); //获取表体的字段配置
+
+ var rowNo = 1;
+
+ foreach (var body in bodyData)
+ {
+ logInfo.Debug($"作业Id:{workId}-----设置第{rowNo}行单据数据");
+ body.SetDictionaryData(defsBody, baseLogin.Connection, newNumber, rowNo, exch);
+
+ rowNo++;
+
+ // 根据存货档案是否批次管理调整批次号
+ if (body.ContainsKey("binvbatch") && body.ContainsKey("cbatch"))
+ {
+ logInfo.Debug($"作业Id:{workId}-----第{rowNo}行根据存货档案是否批次管理调整批次号");
+ if (body["binvbatch"] == null || body["binvbatch"] == DBNull.Value || !body["binvbatch"].ToBoolean())
+ {
+ body["cbatch"] = "";
+ }
+ }
+
+ // 根据存货档案是否批次管理调整批次号(调拨单)
+ if (body.ContainsKey("binvbatch") && body.ContainsKey("ctvbatch"))
+ {
+ logInfo.Debug($"作业Id:{workId}-----第{rowNo}行根据存货档案是否批次管理调整批次号(调拨单)");
+ if (body["binvbatch"] == null || body["binvbatch"] == DBNull.Value || !body["binvbatch"].ToBoolean())
+ {
+ body["ctvbatch"] = "";
+ }
+ }
+
+ // 根据存货档案是否保质期管理调整生产日期和失效日期
+ if (body.ContainsKey("binvquality") && body.ContainsKey("dmadedate"))
+ {
+ logInfo.Debug($"作业Id:{workId}-----第{rowNo}行根据存货档案是否保质期管理调整生产日期和失效日期");
+
+ if (body["binvquality"] == null || body["binvquality"] == DBNull.Value || !body["binvquality"].ToBoolean())
+ {
+ if (cCardNum == "0304")
+ {
+ body["dmadedate"] = "";
+ }
+ else
+ {
+ body["dmadedate"] = "";
+ }
+ }
+ else
+ {
+ if (body.ContainsKey("cmassunit") && body.ContainsKey("imassdate"))
+ {
+ switch ($"{body["cmassunit"]}")
+ {
+ case "1" when cCardNum != "0304":
+ body["dvdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddYears(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}";
+ break;
+ case "1" when cCardNum == "0304":
+ body["ddisdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddYears(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}";
+ break;
+ case "2" when cCardNum != "0304":
+ body["dvdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddMonths(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}";
+ break;
+ case "2" when cCardNum == "0304":
+ body["ddisdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddMonths(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}";
+ break;
+ case "3" when cCardNum != "0304":
+ body["dvdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddDays(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}";
+ break;
+ case "3" when cCardNum == "0304":
+ body["ddisdate"] = $"{Convert.ToDateTime(body["dmadedate"]).AddDays(Convert.ToInt32(body["imassdate"])):yyyy-MM-dd HH:MM:ss}";
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ var co = new USERPCO();
+
+ var res =await co.Insert(baseLogin, input, voucherInfo.VoucherType, bCheck, bBeforCheckStock, bIsRedVouch, sAddedState,bReMote);
return res;
}
@@ -87,7 +244,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
///
///
[HttpPost]
- [Route("api/U8/ST/0411/Update")]
+ [Route("api/U8/ST/{cCardNum}/Update")]
public async Task> Update(string cAccId, string cCardNum, [FromBody] Dictionary input, bool bCheck = true, bool bBeforCheckStock = true, bool bIsRedVouch = false, string sAddedState = "", bool bUpdateNeedEas = true)
{
try
diff --git a/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj b/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj
index 3aaf57b..6a811a4 100644
--- a/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj
+++ b/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj
@@ -47,6 +47,11 @@
4
+
+ False
+ True
+ ..\..\..\U8SOFT\Interop\ADODB.dll
+
..\packages\Autofac.8.1.1\lib\netstandard2.0\Autofac.dll
diff --git a/UFIDA.U8.Framework.Api/Unit/CommUnit.cs b/UFIDA.U8.Framework.Api/Unit/CommUnit.cs
index dd1d553..28a78d2 100644
--- a/UFIDA.U8.Framework.Api/Unit/CommUnit.cs
+++ b/UFIDA.U8.Framework.Api/Unit/CommUnit.cs
@@ -92,7 +92,7 @@ namespace UFIDA.U8.Framework.Api.Unit
///
public static SqlSugarClient GetDbClient()
{
- var db = new SqlSugarClient(CommUnit.GetConnectionConfig());
+ var db = new SqlSugarClient(GetConnectionConfig());
return db;
}
@@ -106,21 +106,22 @@ namespace UFIDA.U8.Framework.Api.Unit
///
public static async Task GetLoginParamter(string cAccId,bool bAP=false,string pDate="")
{
- var db = new SqlSugarClient(CommUnit.GetConnectionConfig());
+ var db = new SqlSugarClient(GetConnectionConfig());
var account=await db.Queryable().FirstAsync(a => a.Status == StatusEnum.Enable && a.cAccountNo == cAccId);
if (account != null)
{
- var param=new LoginParamter()
+ var param = new LoginParamter()
{
cSrv = account.cSrv,
pAccId = account.cAcc_DataSource,
- pDate = string.IsNullOrWhiteSpace(pDate)?$"{DateTime.Today:yyyy-MM-dd}":pDate,
- pPassword = string.IsNullOrWhiteSpace(account.cPassword)?"":GetDecrypt(account.cPassword),
- pYearId = string.IsNullOrWhiteSpace(pDate) ? $"{DateTime.Today.Year}" :$"{DateTime.Parse(pDate).Year}",
+ pDate = string.IsNullOrWhiteSpace(pDate) ? $"{DateTime.Today:yyyy-MM-dd}" : pDate,
+ pPassword = string.IsNullOrWhiteSpace(account.cPassword) ? "" : GetDecrypt(account.cPassword),
+ pYearId = string.IsNullOrWhiteSpace(pDate) ? $"{DateTime.Today.Year}" : $"{DateTime.Parse(pDate).Year}",
pSubId = bAP ? "AP" : "DP",
- pUserId = account.cUser_Id
+ pUserId = account.cUser_Id,
+ cAccId = account.cAcc_Id
};
return param;