测试
This commit is contained in:
@@ -68,12 +68,6 @@ namespace UFIDA.U8.Framework.Api.Common.Entity
|
||||
[SugarColumn(ColumnDescription = "状态")]
|
||||
public virtual StatusEnum Status { get; set; } = StatusEnum.Enable;
|
||||
|
||||
/// <summary>
|
||||
/// 是否外部登录
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否外部登录")]
|
||||
public virtual bool bOutLogin { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统U8字段信息表
|
||||
/// </summary>
|
||||
[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; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 系统U8单据信息表
|
||||
/// </summary>
|
||||
[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; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型编号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "单据类型编号", Length = 100, IsNullable = false)]
|
||||
public string CardNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据表体字段名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "单据表体字段名称", Length = 100, IsNullable = false)]
|
||||
public string BodyName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单据类型参数值
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "单据类型参数值", Length = 100)]
|
||||
public string VoucherType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否自动审核
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否自动审核")]
|
||||
public bool bVerify { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Entity\SysU8AccountConfig.cs" />
|
||||
<Compile Include="Entity\SysU8FieldDefine.cs" />
|
||||
<Compile Include="Entity\SysU8MTask.cs" />
|
||||
<Compile Include="Entity\SysU8VoucherDefine.cs" />
|
||||
<Compile Include="Enum\StatusEnum.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Unit\GM\GM.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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取币种汇率
|
||||
/// </summary>
|
||||
/// <param name="dDate">日期</param>
|
||||
/// <param name="cAccId">账套</param>
|
||||
/// <param name="exchName">币种</param>
|
||||
/// <param name="conn">连接对象</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置字典对象数据
|
||||
/// </summary>
|
||||
/// <param name="dict">字典对象</param>
|
||||
/// <param name="defs">实体字段配置信息</param>
|
||||
/// <param name="conn">数据库连接对象</param>
|
||||
/// <param name="newCode">新单号</param>
|
||||
/// <param name="rowNo">行号</param>
|
||||
/// <param name="bUpdate">是否更新</param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, object> SetDictionaryData(this Dictionary<string, object> dict, List<SysU8FieldDefine> 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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 把对象转换为Boolean类型
|
||||
/// </summary>
|
||||
/// <param name="obj">需要转换的对象</param>
|
||||
/// <returns></returns>
|
||||
public static bool ToBoolean(this object obj)
|
||||
{
|
||||
return bool.TryParse($"{obj}", out var re) && re;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 把对象转换为Int类型
|
||||
/// </summary>
|
||||
/// <param name="obj">需要转换的对象</param>
|
||||
/// <returns></returns>
|
||||
public static int ToShort(this object obj)
|
||||
{
|
||||
if (!short.TryParse($"{obj}", out var re))
|
||||
throw new InvalidCastException($"值:{obj}无法转换为短数字格式!");
|
||||
|
||||
return re;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 把对象转换为Int类型
|
||||
/// </summary>
|
||||
/// <param name="obj">需要转换的对象</param>
|
||||
/// <returns></returns>
|
||||
public static int ToInt(this object obj)
|
||||
{
|
||||
if (!int.TryParse($"{obj}", out var re))
|
||||
throw new InvalidCastException($"值:{obj}无法转换为数字格式!");
|
||||
|
||||
return re;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="length"></param>
|
||||
/// <param name="useNum"></param>
|
||||
/// <param name="useLow"></param>
|
||||
/// <param name="useUpp"></param>
|
||||
/// <param name="useSpe"></param>
|
||||
/// <param name="customerStr"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -50,5 +50,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Entity
|
||||
/// 序列号,一般不填
|
||||
/// </summary>
|
||||
public string cSerial { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 登录的账套id,不填
|
||||
/// </summary>
|
||||
public string cAccId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.ST
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
|
||||
public async Task<BaseResult<string>> Insert(BaseLogin baseLogin, Dictionary<string, object> dictionary,string sVouchType,bool bCheck=true,bool bBeforCheckStock=true,bool bIsRedVouch=false,string sAddedState="", bool bReMote=false)
|
||||
public async Task<BaseResult<string>> Insert(BaseLogin baseLogin, Dictionary<string, object> dictionary,string sVouchType,bool bGetCode=false,bool bCheck=true,bool bBeforCheckStock=true,bool bIsRedVouch=false,string sAddedState="", bool bReMote=false)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化生产制造上下文
|
||||
/// </summary>
|
||||
|
||||
@@ -181,6 +181,7 @@
|
||||
<Compile Include="Common\APARHelper.cs" />
|
||||
<Compile Include="Common\BEHelper.cs" />
|
||||
<Compile Include="Common\CommonHelper.cs" />
|
||||
<Compile Include="Entity\Exch.cs" />
|
||||
<Compile Include="Json\JsonHelper.cs" />
|
||||
<Compile Include="Entity\BaseResult.cs" />
|
||||
<Compile Include="Entity\LoginParamter.cs" />
|
||||
@@ -212,5 +213,11 @@
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\UFIDA.U8.Framework.Api.Common\UFIDA.U8.Framework.Api.Common.csproj">
|
||||
<Project>{0682DC28-D5F7-4A10-BD3D-20ECD1FC987E}</Project>
|
||||
<Name>UFIDA.U8.Framework.Api.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Binary file not shown.
@@ -663,6 +663,41 @@
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.DPController.GetEncryptString(System.String)">
|
||||
<summary>
|
||||
获取加密字符串
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.DPController.GetDecryptString(System.String)">
|
||||
<summary>
|
||||
获取解密字符串
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.DPController.AddAccountConfig(UFIDA.U8.Framework.Api.Models.AddU8AccountConfigInput)">
|
||||
<summary>
|
||||
新增对接账套设置
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.DPController.UpdateAccountConfig(UFIDA.U8.Framework.Api.Models.AddU8AccountConfigInput)">
|
||||
<summary>
|
||||
更新对接账套设置
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:UFIDA.U8.Framework.Api.Controllers.U8.DPController.ListAccountConfig(UFIDA.U8.Framework.Api.Models.ListU8AccountConfigInput)">
|
||||
<summary>
|
||||
获取对接账套设置列表
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:UFIDA.U8.Framework.Api.Controllers.U8.MOController">
|
||||
<summary>
|
||||
生产订单
|
||||
|
||||
@@ -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<string>() { bSuccess = true, message = "加密成功", result = CommonHelper.U8Encrypt(cPwd) };
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -106,5 +104,171 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加密字符串
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("api/U8/DP/GetEncryptString")]
|
||||
public async Task<BaseResult<string>> GetEncryptString(string input)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(1);
|
||||
|
||||
return new BaseResult<string> { bSuccess = true, message = "加密成功", result = CommUnit.GetEncrypt(input) };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "加密失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取解密字符串
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("api/U8/DP/GetDecryptString")]
|
||||
public async Task<BaseResult<string>> GetDecryptString(string input)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(1);
|
||||
|
||||
return new BaseResult<string> { bSuccess = true, message = "解密成功", result = CommUnit.GetDecrypt(input) };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<string> { bSuccess = false, message = "解密失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增对接账套设置
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/U8/DP/AddAccountConfig")]
|
||||
public async Task<BaseResult<dynamic>> AddAccountConfig([FromBody] AddU8AccountConfigInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = CommUnit.GetDbClient();
|
||||
|
||||
var isExists = await db.Queryable<SysU8AccountConfig>().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<dynamic> { bSuccess = true, message = "新增成功", result = id };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = "新增失败", result = ex.Message };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新对接账套设置
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/U8/DP/UpdateAccountConfig")]
|
||||
public async Task<BaseResult<dynamic>> UpdateAccountConfig([FromBody] AddU8AccountConfigInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = CommUnit.GetDbClient();
|
||||
|
||||
var isExists = await db.Queryable<Common.Entity.SysU8AccountConfig>().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<dynamic> { bSuccess = true, message = "更新成功", result = id };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = "更新失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对接账套设置列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/U8/DP/ListAccountConfig")]
|
||||
public async Task<BaseResult<dynamic>> ListAccountConfig([FromBody] ListU8AccountConfigInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = CommUnit.GetDbClient();
|
||||
|
||||
var res = await db.Queryable<Common.Entity.SysU8AccountConfig>()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.cAccId), a => a.cAccountNo == input.cAccId)
|
||||
.ToListAsync();
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = true, message = "查询成功", result = res };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logInfo.Error(ex.Message, ex);
|
||||
|
||||
return new BaseResult<dynamic> { bSuccess = false, message = "查询失败", result = ex.Message };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/// <param name="bReMote"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/U8/ST/0411/Insert")]
|
||||
[Route("api/U8/ST/{cCardNum}/Insert")]
|
||||
public async Task<BaseResult<string>> Insert(string cAccId, string cCardNum,[FromBody] Dictionary<string, object> 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<SysU8VoucherDefine>().First(s => s.CardNumber == cCardNum);
|
||||
|
||||
var defs = db.Queryable<SysU8FieldDefine>().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<Dictionary<string, object>>(); //读取表体的数据
|
||||
|
||||
if (bodyData == null || bodyData.Count <= 0)
|
||||
throw new Exception("无表体数据!");
|
||||
|
||||
logInfo.Debug($"作业Id:{workId}-----获取表体字段配置");
|
||||
var defsBody = db.Queryable<SysU8FieldDefine>().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
|
||||
/// <param name="bUpdateNeedEas"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/U8/ST/0411/Update")]
|
||||
[Route("api/U8/ST/{cCardNum}/Update")]
|
||||
public async Task<BaseResult<string>> Update(string cAccId, string cCardNum, [FromBody] Dictionary<string, object> input, bool bCheck = true, bool bBeforCheckStock = true, bool bIsRedVouch = false, string sAddedState = "", bool bUpdateNeedEas = true)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -47,6 +47,11 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
<HintPath>..\..\..\U8SOFT\Interop\ADODB.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac, Version=8.1.1.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Autofac.8.1.1\lib\netstandard2.0\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace UFIDA.U8.Framework.Api.Unit
|
||||
/// <returns></returns>
|
||||
public static SqlSugarClient GetDbClient()
|
||||
{
|
||||
var db = new SqlSugarClient(CommUnit.GetConnectionConfig());
|
||||
var db = new SqlSugarClient(GetConnectionConfig());
|
||||
|
||||
return db;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ namespace UFIDA.U8.Framework.Api.Unit
|
||||
/// <returns></returns>
|
||||
public static async Task<LoginParamter> GetLoginParamter(string cAccId,bool bAP=false,string pDate="")
|
||||
{
|
||||
var db = new SqlSugarClient(CommUnit.GetConnectionConfig());
|
||||
var db = new SqlSugarClient(GetConnectionConfig());
|
||||
|
||||
var account=await db.Queryable<SysU8AccountConfig>().FirstAsync(a => a.Status == StatusEnum.Enable && a.cAccountNo == cAccId);
|
||||
|
||||
@@ -120,7 +120,8 @@ namespace UFIDA.U8.Framework.Api.Unit
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user