小程序接口修改
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -43,114 +44,127 @@ namespace BLL
|
||||
// BLL.FileCabinetAItemService.DeleteFileCabinetAItemByID(dataId);
|
||||
Funs.DB.Sys_CodeRecords.DeleteOnSubmit(codeRecords);
|
||||
}
|
||||
}
|
||||
|
||||
#region 根据菜单id、项目id返回编码 (用于页面新增显示)
|
||||
/// <summary>
|
||||
/// 根据菜单id、项目id返回编码 (用于页面新增显示)
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReturnCodeByMenuIdProjectId(string menuId, string projectId, string unitId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
string code = string.Empty;
|
||||
string ruleCodes = string.Empty;
|
||||
int digit = 4;
|
||||
string symbol = "-"; ///间隔符
|
||||
var codeRecords = (from x in db.Sys_CodeRecords where x.MenuId == menuId && x.ProjectId == projectId orderby x.CompileDate descending select x).FirstOrDefault();
|
||||
if (codeRecords != null && !string.IsNullOrEmpty(codeRecords.RuleCodes))
|
||||
{
|
||||
ruleCodes = codeRecords.RuleCodes;
|
||||
if (codeRecords.Digit.HasValue)
|
||||
{
|
||||
digit = codeRecords.Digit.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
////项目
|
||||
string ruleCode = string.Empty;
|
||||
var project = ProjectService.GetProjectByProjectId(projectId);
|
||||
if (project != null)
|
||||
{
|
||||
string projectCode = project.ProjectCode; ///项目编号
|
||||
////编码规则表
|
||||
var sysCodeTemplateRule = db.ProjectData_CodeTemplateRule.FirstOrDefault(x => x.MenuId == menuId && x.ProjectId == projectId);
|
||||
if (sysCodeTemplateRule != null)
|
||||
{
|
||||
symbol = sysCodeTemplateRule.Symbol;
|
||||
if (sysCodeTemplateRule.Digit.HasValue)
|
||||
{
|
||||
digit = sysCodeTemplateRule.Digit.Value;
|
||||
}
|
||||
if (sysCodeTemplateRule.IsProjectCode == true)
|
||||
{
|
||||
ruleCode = projectCode + symbol;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(sysCodeTemplateRule.Prefix))
|
||||
{
|
||||
ruleCode += sysCodeTemplateRule.Prefix + symbol;
|
||||
}
|
||||
if (sysCodeTemplateRule.IsUnitCode == true)
|
||||
{
|
||||
var unit = UnitService.GetUnitByUnitId(unitId);
|
||||
if (unit != null)
|
||||
{
|
||||
ruleCode += unit.UnitCode + symbol;
|
||||
}
|
||||
}
|
||||
ruleCodes = ruleCode;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var codeTempRule = db.Sys_CodeTemplateRule.FirstOrDefault(x => x.MenuId == menuId);
|
||||
if (codeTempRule != null && !string.IsNullOrEmpty(codeTempRule.Prefix))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(codeTempRule.Symbol))
|
||||
{
|
||||
symbol = codeTempRule.Symbol;
|
||||
}
|
||||
ruleCodes = codeTempRule.Prefix + symbol;
|
||||
if (codeTempRule.Digit.HasValue)
|
||||
{
|
||||
digit = codeTempRule.Digit.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////获取编码记录表最大排列序号
|
||||
int maxNewSortIndex = 0;
|
||||
var maxSortIndex = db.Sys_CodeRecords.Where(x => (x.ProjectId == projectId || projectId == null) && x.MenuId == menuId).Select(x => x.SortIndex).Max();
|
||||
|
||||
if (maxSortIndex.HasValue)
|
||||
{
|
||||
maxNewSortIndex = maxSortIndex.Value;
|
||||
}
|
||||
maxNewSortIndex = maxNewSortIndex + 1;
|
||||
code = (maxNewSortIndex.ToString().PadLeft(digit, '0')); ///字符自动补零
|
||||
if (!string.IsNullOrEmpty(ruleCodes))
|
||||
{
|
||||
code = ruleCodes + code;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
public static void DeleteCodeRecordsByDataIdForApi(string dataId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var codeRecords = db.Sys_CodeRecords.FirstOrDefault(x => x.DataId == dataId);
|
||||
if (codeRecords != null)
|
||||
{
|
||||
///删除文件柜A中数据
|
||||
// BLL.FileCabinetAItemService.DeleteFileCabinetAItemByID(dataId);
|
||||
db.Sys_CodeRecords.DeleteOnSubmit(codeRecords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 根据菜单id、项目id插入一条编码记录(数据新增到数据库 生成编码)
|
||||
/// <summary>
|
||||
/// 根据菜单id、项目id插入一条编码记录(数据新增到数据库 生成编码)
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="unitId"></param>
|
||||
public static string InsertCodeRecordsByMenuIdProjectIdUnitId(string menuId, string projectId, string unitId, string dataId, DateTime? compileDate)
|
||||
#region 根据菜单id、项目id返回编码 (用于页面新增显示)
|
||||
/// <summary>
|
||||
/// 根据菜单id、项目id返回编码 (用于页面新增显示)
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReturnCodeByMenuIdProjectId(string menuId, string projectId, string unitId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
string code = string.Empty;
|
||||
string ruleCodes = string.Empty;
|
||||
int digit = 4;
|
||||
string symbol = "-"; ///间隔符
|
||||
var codeRecords = (from x in db.Sys_CodeRecords where x.MenuId == menuId && x.ProjectId == projectId orderby x.CompileDate descending select x).FirstOrDefault();
|
||||
if (codeRecords != null && !string.IsNullOrEmpty(codeRecords.RuleCodes))
|
||||
{
|
||||
ruleCodes = codeRecords.RuleCodes;
|
||||
if (codeRecords.Digit.HasValue)
|
||||
{
|
||||
digit = codeRecords.Digit.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
////项目
|
||||
string ruleCode = string.Empty;
|
||||
var project = db.Base_Project.FirstOrDefault(e => e.ProjectId == projectId) ;
|
||||
if (project != null)
|
||||
{
|
||||
string projectCode = project.ProjectCode; ///项目编号
|
||||
////编码规则表
|
||||
var sysCodeTemplateRule = db.ProjectData_CodeTemplateRule.FirstOrDefault(x => x.MenuId == menuId && x.ProjectId == projectId);
|
||||
if (sysCodeTemplateRule != null)
|
||||
{
|
||||
symbol = sysCodeTemplateRule.Symbol;
|
||||
if (sysCodeTemplateRule.Digit.HasValue)
|
||||
{
|
||||
digit = sysCodeTemplateRule.Digit.Value;
|
||||
}
|
||||
if (sysCodeTemplateRule.IsProjectCode == true)
|
||||
{
|
||||
ruleCode = projectCode + symbol;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(sysCodeTemplateRule.Prefix))
|
||||
{
|
||||
ruleCode += sysCodeTemplateRule.Prefix + symbol;
|
||||
}
|
||||
if (sysCodeTemplateRule.IsUnitCode == true)
|
||||
{
|
||||
var unit = db.Base_Unit.FirstOrDefault(x => x.UnitId == unitId);
|
||||
if (unit != null)
|
||||
{
|
||||
ruleCode += unit.UnitCode + symbol;
|
||||
}
|
||||
}
|
||||
ruleCodes = ruleCode;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var codeTempRule = db.Sys_CodeTemplateRule.FirstOrDefault(x => x.MenuId == menuId);
|
||||
if (codeTempRule != null && !string.IsNullOrEmpty(codeTempRule.Prefix))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(codeTempRule.Symbol))
|
||||
{
|
||||
symbol = codeTempRule.Symbol;
|
||||
}
|
||||
ruleCodes = codeTempRule.Prefix + symbol;
|
||||
if (codeTempRule.Digit.HasValue)
|
||||
{
|
||||
digit = codeTempRule.Digit.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////获取编码记录表最大排列序号
|
||||
int maxNewSortIndex = 0;
|
||||
var maxSortIndex = db.Sys_CodeRecords.Where(x => (x.ProjectId == projectId || projectId == null) && x.MenuId == menuId).Select(x => x.SortIndex).Max();
|
||||
|
||||
if (maxSortIndex.HasValue)
|
||||
{
|
||||
maxNewSortIndex = maxSortIndex.Value;
|
||||
}
|
||||
maxNewSortIndex = maxNewSortIndex + 1;
|
||||
code = (maxNewSortIndex.ToString().PadLeft(digit, '0')); ///字符自动补零
|
||||
if (!string.IsNullOrEmpty(ruleCodes))
|
||||
{
|
||||
code = ruleCodes + code;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 根据菜单id、项目id插入一条编码记录(数据新增到数据库 生成编码)
|
||||
/// <summary>
|
||||
/// 根据菜单id、项目id插入一条编码记录(数据新增到数据库 生成编码)
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="unitId"></param>
|
||||
public static string InsertCodeRecordsByMenuIdProjectIdUnitId(string menuId, string projectId, string unitId, string dataId, DateTime? compileDate)
|
||||
{
|
||||
string ruleCode = string.Empty;
|
||||
var IsHaveCodeRecords = Funs.DB.Sys_CodeRecords.FirstOrDefault(x => x.DataId == dataId);
|
||||
@@ -276,16 +290,148 @@ namespace BLL
|
||||
|
||||
return ruleCode;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 根据菜单id,项目id 更新编码记录(当编码规则改变的时候 更新编码)
|
||||
/// <summary>
|
||||
/// 根据菜单id 更新编码记录(当编码规则改变的时候 更新编码)
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="unitId"></param>
|
||||
public static void UpdateCodeRecordsByMenuIdProjectId(string menuId, string projectId)
|
||||
|
||||
public static string InsertCodeRecordsByMenuIdProjectIdUnitIdForApi(string menuId, string projectId, string unitId, string dataId, DateTime? compileDate)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
string ruleCode = string.Empty;
|
||||
var IsHaveCodeRecords = db.Sys_CodeRecords.FirstOrDefault(x => x.DataId == dataId);
|
||||
if (IsHaveCodeRecords == null) ///是否已存在编码
|
||||
{
|
||||
string ruleCodeower = string.Empty;
|
||||
int digit = 4; ///流水位数
|
||||
string symbolower = "-"; ///业主间隔符
|
||||
int digitower = 4; ///业主流水位数
|
||||
string symbol = "-"; ///间隔符
|
||||
var project = db.Base_Project.FirstOrDefault(e => e.ProjectId == projectId); ////项目
|
||||
if (project != null && !string.IsNullOrEmpty(dataId))
|
||||
{
|
||||
string projectCode = project.ProjectCode; ///项目编号
|
||||
////编码规则表
|
||||
var sysCodeTemplateRule = db.ProjectData_CodeTemplateRule.FirstOrDefault(x => x.MenuId == menuId && x.ProjectId == projectId);
|
||||
if (sysCodeTemplateRule != null)
|
||||
{
|
||||
symbol = sysCodeTemplateRule.Symbol;
|
||||
symbolower = sysCodeTemplateRule.OwerSymbol;
|
||||
|
||||
if (sysCodeTemplateRule.Digit.HasValue)
|
||||
{
|
||||
digit = sysCodeTemplateRule.Digit.Value;
|
||||
}
|
||||
if (sysCodeTemplateRule.OwerDigit.HasValue)
|
||||
{
|
||||
digitower = sysCodeTemplateRule.OwerDigit.Value;
|
||||
}
|
||||
if (sysCodeTemplateRule.IsProjectCode == true)
|
||||
{
|
||||
ruleCode = projectCode + symbol;
|
||||
}
|
||||
if (sysCodeTemplateRule.OwerIsProjectCode == true)
|
||||
{
|
||||
ruleCodeower = projectCode + symbolower;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(sysCodeTemplateRule.Prefix))
|
||||
{
|
||||
ruleCode += sysCodeTemplateRule.Prefix + symbol;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(sysCodeTemplateRule.OwerPrefix))
|
||||
{
|
||||
ruleCodeower += sysCodeTemplateRule.OwerPrefix + symbolower;
|
||||
}
|
||||
if (sysCodeTemplateRule.IsUnitCode == true || sysCodeTemplateRule.OwerIsUnitCode == true)
|
||||
{
|
||||
var unit = db.Base_Unit.FirstOrDefault(x => x.UnitId == unitId);
|
||||
if (unit != null)
|
||||
{
|
||||
if (sysCodeTemplateRule.IsUnitCode == true)
|
||||
{ ruleCode = unit.UnitCode + symbol; }
|
||||
|
||||
if (sysCodeTemplateRule.OwerIsUnitCode == true)
|
||||
{
|
||||
ruleCodeower = unit.UnitCode + symbolower;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////获取编码记录表最大排列序号
|
||||
int maxNewSortIndex = 0;
|
||||
if (!String.IsNullOrEmpty(projectId))
|
||||
{
|
||||
var maxSortIndex = db.Sys_CodeRecords.Where(x => x.ProjectId == projectId && x.MenuId == menuId).Select(x => x.SortIndex).Max();
|
||||
if (maxSortIndex.HasValue)
|
||||
{
|
||||
maxNewSortIndex = maxSortIndex.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var maxSortIndexNull = db.Sys_CodeRecords.Where(x => x.MenuId == menuId).Select(x => x.SortIndex).Max();
|
||||
if (maxSortIndexNull.HasValue)
|
||||
{
|
||||
maxNewSortIndex = maxSortIndexNull.Value;
|
||||
}
|
||||
}
|
||||
maxNewSortIndex = maxNewSortIndex + 1;
|
||||
////插入数据库
|
||||
Model.Sys_CodeRecords newCodeRecords = new Model.Sys_CodeRecords
|
||||
{
|
||||
CodeRecordId = SQLHelper.GetNewID(typeof(Model.Sys_CodeRecords))
|
||||
};
|
||||
if (project != null)
|
||||
{
|
||||
newCodeRecords.ProjectId = project.ProjectId;
|
||||
}
|
||||
newCodeRecords.MenuId = menuId;
|
||||
newCodeRecords.DataId = dataId;
|
||||
newCodeRecords.UnitId = unitId;
|
||||
newCodeRecords.SortIndex = maxNewSortIndex;
|
||||
newCodeRecords.CompileDate = compileDate;
|
||||
newCodeRecords.RuleCodes = ruleCode;
|
||||
newCodeRecords.Digit = digit;
|
||||
newCodeRecords.OwnerRuleCodes = ruleCodeower;
|
||||
newCodeRecords.OwerDigit = digitower;
|
||||
if (!string.IsNullOrEmpty(ruleCode))
|
||||
{
|
||||
newCodeRecords.Code = ruleCode + (maxNewSortIndex.ToString().PadLeft(digit, '0')); ///字符自动补零 编码
|
||||
}
|
||||
else
|
||||
{
|
||||
newCodeRecords.Code = (maxNewSortIndex.ToString().PadLeft(digit, '0'));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(ruleCodeower))
|
||||
{
|
||||
newCodeRecords.OwnerCode = ruleCodeower + (maxNewSortIndex.ToString().PadLeft(digitower, '0')); ///字符自动补零 业主编码
|
||||
}
|
||||
else
|
||||
{
|
||||
newCodeRecords.OwnerCode = (maxNewSortIndex.ToString().PadLeft(digitower, '0'));
|
||||
}
|
||||
db.Sys_CodeRecords.InsertOnSubmit(newCodeRecords);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
ruleCode = IsHaveCodeRecords.Code;
|
||||
}
|
||||
|
||||
return ruleCode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据菜单id,项目id 更新编码记录(当编码规则改变的时候 更新编码)
|
||||
/// <summary>
|
||||
/// 根据菜单id 更新编码记录(当编码规则改变的时候 更新编码)
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="unitId"></param>
|
||||
public static void UpdateCodeRecordsByMenuIdProjectId(string menuId, string projectId)
|
||||
{
|
||||
var codeRecords = from x in Funs.DB.Sys_CodeRecords where x.MenuId == menuId && x.ProjectId == projectId select x;
|
||||
if (codeRecords.Count() > 0)
|
||||
|
||||
Reference in New Issue
Block a user