|
|
|
@ -12,6 +12,7 @@ using Tiobon.Core.Common.Helper; |
|
|
|
|
using Tiobon.Core.DataAccess; |
|
|
|
|
using Tiobon.Core.IServices; |
|
|
|
|
using Tiobon.Core.Model; |
|
|
|
|
using Tiobon.Core.Model.Models; |
|
|
|
|
using Tiobon.Core.Services.BASE; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
@ -2136,7 +2137,186 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon |
|
|
|
|
flowReturn.DT_TableDataT1 = await Db.Ado.GetDataTableAsync(sql); |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
return new ServiceResult<FlowReturn>() { Success = true, Message = "查询成功", Data = flowReturn }; |
|
|
|
|
return new ServiceResult<FlowReturn>() { Success = true, Message = "查询成功", result = flowReturn }; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 流程提交处理 |
|
|
|
|
/// <summary> |
|
|
|
|
/// 流程提交处理 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="param"></param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<ServiceResult> CommitFlowAsync(FlowCommitParam param) |
|
|
|
|
{ |
|
|
|
|
var @InitmenuName = param.menuName; |
|
|
|
|
int @FlowID = 0; |
|
|
|
|
int @NeedOPLog = 1; |
|
|
|
|
long @OperateLogID = 0; |
|
|
|
|
|
|
|
|
|
#region 写入日志 |
|
|
|
|
var sql = $@"DECLARE @return_value int;
|
|
|
|
|
|
|
|
|
|
DECLARE @OperateLogID bigint; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET @OperateLogID = NULL; |
|
|
|
|
|
|
|
|
|
EXEC @return_value = GHR30.dbo.[PS_OperateLog] |
|
|
|
|
@OpUserID = {param.userId}, |
|
|
|
|
@OpType = {param.doType}, |
|
|
|
|
@OpMenuNo = {param.menuName}, |
|
|
|
|
@OpTableName = {param.menuName}, |
|
|
|
|
@OpTableID = {param.id}, |
|
|
|
|
@OpDetailInfo = '{param.jsonParam.ToString()}', |
|
|
|
|
@OperateLogID = @OperateLogID out; |
|
|
|
|
|
|
|
|
|
SELECT @OperateLogID as N'@OperateLogID', @return_value as N'@Return Value';";
|
|
|
|
|
await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
sql = $"SELECT FlowID FROM Ghrs_Menu b WHERE b.Menuno = '{param.menuName}' AND b.IsEnable = 1"; |
|
|
|
|
@FlowID = await Db.Ado.GetIntAsync(sql); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (param.menuName) |
|
|
|
|
{ |
|
|
|
|
case "F_ESS_TrainRequestApply": |
|
|
|
|
|
|
|
|
|
#region 写入数据,并判断是否有错误 |
|
|
|
|
switch (param.doType) |
|
|
|
|
{ |
|
|
|
|
case "Apply": |
|
|
|
|
case "BatchApply": |
|
|
|
|
|
|
|
|
|
#region 写入数据,并判断是否有错误 |
|
|
|
|
string json = param.jsonParam.ToString(); |
|
|
|
|
var dict = JsonHelper.JsonToObj<Ghre_Request>(json); |
|
|
|
|
|
|
|
|
|
dict.SponsorId = GetStaffId(); |
|
|
|
|
dict.RequestNo = await GenerateContinuousSequence("Ghre_Request", "RequestNo", "R"); |
|
|
|
|
var id = await Db.Insertable(dict).ExecuteReturnSnowflakeIdAsync(); |
|
|
|
|
|
|
|
|
|
sql = $"SELECT MAX(id)+1 FROM Ghre_Request WHERE Id !='{id}'"; |
|
|
|
|
var id1 = await Db.Ado.GetLongAsync(sql); |
|
|
|
|
sql = $"UPDATE Ghre_Request SET Id={id1} WHERE Id ='{id}'"; |
|
|
|
|
await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
|
|
|
|
|
|
id = id1; |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 生成流程数据 |
|
|
|
|
sql = @$"DECLARE @return_value int;
|
|
|
|
|
|
|
|
|
|
DECLARE @ErrorMsg nvarchar(2000); |
|
|
|
|
|
|
|
|
|
SET @ErrorMsg = NULL; |
|
|
|
|
|
|
|
|
|
EXEC @return_value = GHR30.dbo.[PT_GHR30_FlowApply] |
|
|
|
|
@ID = {id}, |
|
|
|
|
@FlowID = {@FlowID}, |
|
|
|
|
@UserID = {param.userId}, |
|
|
|
|
@LangID = {param.langId}, |
|
|
|
|
@ErrorMsg = @ErrorMsg out; |
|
|
|
|
|
|
|
|
|
SELECT @ErrorMsg as N'@ErrorMsg', @return_value as N'@Return Value';";
|
|
|
|
|
|
|
|
|
|
var message = await Db.Ado.GetStringAsync(sql); |
|
|
|
|
|
|
|
|
|
if (message.IsNotEmptyOrNull()) |
|
|
|
|
return new ServiceResult() { Success = false, Message = message }; |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return new ServiceResult() { Success = true, Message = "提交成功" }; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region MyRegion |
|
|
|
|
public int? GetStaffId() |
|
|
|
|
{ |
|
|
|
|
int? StaffId = null; |
|
|
|
|
string sql = $"SELECT UserStaffID FROM Ghrs_User WHERE UserId='{App.User.ID}'"; |
|
|
|
|
string StaffId1 = Convert.ToString(DbAccess.ExecuteScalar(sql)); |
|
|
|
|
if (!StaffId1.IsNull()) |
|
|
|
|
StaffId = Convert.ToInt32(StaffId1); |
|
|
|
|
return StaffId; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 自动编号 |
|
|
|
|
/// <summary> |
|
|
|
|
/// 自动编号 |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="tableCode">表名</param> |
|
|
|
|
/// <param name="columnCode">栏位名</param> |
|
|
|
|
/// <param name="prefixTemp">前缀</param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public async Task<string> GenerateContinuousSequence(string tableCode, string columnCode, string prefixTemp, int length = 7, int tempLength = 6) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
string result = string.Empty; |
|
|
|
|
int sequence; |
|
|
|
|
|
|
|
|
|
#region 查询 |
|
|
|
|
DbSelect dbSelect = new DbSelect(tableCode + " A", "A", null); |
|
|
|
|
dbSelect.IsInitDefaultValue = false; |
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
|
dbSelect.Select("MAX(SUBSTRING(A." + columnCode + "," + (prefixTemp.Length + 1).ToString() + "," + tempLength.ToString() + "))"); |
|
|
|
|
else |
|
|
|
|
dbSelect.Select("MAX(A." + columnCode + ")"); |
|
|
|
|
//} |
|
|
|
|
//dbSelect.Select("MAX(CONVERT(DECIMAL,SUBSTRING(A.ISSUE_NO," + (prefix.Length + dateString.Length + 1).ToString() + "," + tempLength.ToString() + ")))"); |
|
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
|
dbSelect.Where("SUBSTRING(A." + columnCode + ",1," + (prefixTemp.Length).ToString() + ")", " = ", prefixTemp); |
|
|
|
|
dbSelect.Where("LEN(A." + columnCode + ")", "=", length); |
|
|
|
|
string sql = dbSelect.GetSql(); |
|
|
|
|
//await Db.Ado.GetScalarAsync(sql) |
|
|
|
|
string maxSequence = Convert.ToString(await Db.Ado.GetScalarAsync(sql)); |
|
|
|
|
#endregion |
|
|
|
|
//tempLength = tempLength - dateString.Length; |
|
|
|
|
if (string.IsNullOrEmpty(maxSequence)) |
|
|
|
|
result = prefixTemp + Convert.ToString(1).PadLeft(tempLength, '0'); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
|
{ |
|
|
|
|
if (int.TryParse(maxSequence, out sequence)) |
|
|
|
|
{ |
|
|
|
|
sequence += 1; |
|
|
|
|
if (sequence.ToString().Length > tempLength) |
|
|
|
|
throw new Exception("自动生成字串长度已经超过设定长度!"); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
throw new Exception("表中的数据无法进行自动编号,请联系软件开发商!"); |
|
|
|
|
result = prefixTemp + sequence.ToString().PadLeft(tempLength, '0'); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (int.TryParse(maxSequence, out sequence)) |
|
|
|
|
{ |
|
|
|
|
sequence += 1; |
|
|
|
|
if (sequence.ToString().Length > length) |
|
|
|
|
throw new Exception("自动生成字串长度已经超过设定长度!"); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
throw new Exception("表中的数据无法进行自动编号,请联系软件开发商!"); |
|
|
|
|
result = sequence.ToString().PadLeft(length, '0'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
catch (Exception) { throw; } |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|