diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/FundsApplyController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/FundsApplyController.cs index d9d239d80..49615b7a5 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/FundsApplyController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/AssetManagementSystem/Controllers/FundsApplyController.cs @@ -136,9 +136,19 @@ namespace Learun.Application.Web.Areas.AssetManagementSystem.Controllers { FundsApplyEntity entity = strEntity.ToObject(); List detailList = fundsApplyDetailList.ToObject>(); - if (entity.EnCode.Length > 15) + var code = entity.EnCode; + var savecode = fundsApplyIBLL.SaveCode(entity.EnCode, keyValue); + + var encode = savecode.Substring(13).ToInt(); + if (encode > 99) + { + return Fail("保存失败,经费开支单今日数量已超上限,请您明日编辑!"); + } + entity.EnCode = savecode; + if (code != entity.EnCode) { - return Fail("保存失败,经费开支单号今日数量已超上限,请明日提交!"); + fundsApplyIBLL.SaveEntity(keyValue, entity, detailList); + return Success("保存成功,经费开支申报单号已重复,系统已为您自动变更!"); } fundsApplyIBLL.SaveEntity(keyValue, entity, detailList); return Success("保存成功!"); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FundsApplyApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FundsApplyApi.cs index db8ecfb68..b8d9c7e6c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FundsApplyApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/FundsApplyApi.cs @@ -129,9 +129,19 @@ namespace Learun.Application.WebApi ReqFormEntity parameter = this.GetReqData(); FundsApplyEntity entity = parameter.strEntity.ToObject(); List detailList = parameter.fundsApplyDetailList.ToObject>(); - if (entity.EnCode.Length > 15) + var code = entity.EnCode; + var savecode = fundsApplyIBLL.SaveCode(entity.EnCode, parameter.keyValue); + + var encode = savecode.Substring(13).ToInt(); + if (encode > 99) + { + return Fail("保存失败,经费开支单今日数量已超上限,请您明日编辑!"); + } + entity.EnCode = savecode; + if (code != entity.EnCode) { - return Fail("保存失败,经费开支单号今日数量已超上限,请明日提交!"); + fundsApplyIBLL.SaveEntity(parameter.keyValue, entity, detailList); + return Success("保存成功,经费开支申报单号已重复,系统已为您自动变更!"); } fundsApplyIBLL.SaveEntity(parameter.keyValue, entity, detailList); return Success("保存成功!"); diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyBLL.cs index 0b2a99972..2aa086974 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyBLL.cs @@ -114,6 +114,30 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem } } } + + /// + /// 获取FundsApply表实体数据 + /// + /// 主键 + /// + public string SaveCode(string Code, string keyValue) + { + try + { + return fundsApplyService.SaveCode(Code,keyValue); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion #region 提交数据 @@ -165,7 +189,7 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem } } - public void ChangeStatusById(string keyValue,int status, string processId) + public void ChangeStatusById(string keyValue, int status, string processId) { try { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyIBLL.cs index 2dc5f4539..af3fbe388 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyIBLL.cs @@ -40,6 +40,11 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem /// /// string GetCode(); + /// + /// 保存判断 + /// + /// + string SaveCode(string Code, string keyValue); #endregion @@ -61,7 +66,7 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem /// /// /// - void ChangeStatusById(string keyValue,int status, string processId); + void ChangeStatusById(string keyValue, int status, string processId); void ChangeStatusByProcessId(string processId, int status); #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyService.cs index 1a3f85156..38205d571 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/AssetManagementSystem/FundsApply/FundsApplyService.cs @@ -160,6 +160,42 @@ namespace Learun.Application.TwoDevelopment.AssetManagementSystem } } } + public string SaveCode(string Code, string keyValue) + { + var result = ""; + var strSql = new StringBuilder(); + strSql.Append(@"select * from FundsApply where 1= 1 and ApplyTime >= '" + DateTime.Now.Date + " and Encode = '" + Code + "''"); + var data = this.BaseRepository("CollegeMIS").FindList(strSql.ToString()).FirstOrDefault(); + var Codes = "JFKZ_" + CommonHelper.StringTime(); + if (data != null && !string.IsNullOrEmpty(data.EnCode)) + { + if (!string.IsNullOrEmpty(keyValue)) + { + if (data.Id == keyValue) + { + result = Code; + } + else if (data.Id != keyValue && Code != data.EnCode) + { + var NCode = data.EnCode.Substring(data.EnCode.Length - 2, 2); + result = Codes + (Convert.ToInt32(NCode) + 1).ToString().PadLeft(2, '0'); + } + } + else + { + if (Code == data.EnCode) + { + var NCode = data.EnCode.Substring(data.EnCode.Length - 2, 2); + result = Codes + (Convert.ToInt32(NCode) + 1).ToString().PadLeft(2, '0'); + } + else if (Code != data.EnCode) + { + result = Code; + } + } + } + return result; + } #endregion #region 提交数据