You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
620 lines
25 KiB
620 lines
25 KiB
using Shentun.Peis.Enums;
|
|
using Shentun.Peis.Models;
|
|
using Shentun.Peis.RegisterCheckSuggestions;
|
|
using Shentun.Peis.RegisterCheckSummarys;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Domain.Services;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Users;
|
|
|
|
namespace Shentun.Peis.RegisterChecks
|
|
{
|
|
/// <summary>
|
|
/// 登记检查单
|
|
/// </summary>
|
|
public class RegisterCheckManager : DomainService
|
|
{
|
|
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository;
|
|
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
|
|
private readonly IRepository<RegisterCheckItem> _registerCheckItemRepository;
|
|
private readonly IRepository<SysParmValue> _sysParmValueRepository;
|
|
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
|
|
private readonly IRepository<PrimarykeyBuilder> _primarykeyBuilderRepository;
|
|
private readonly IRepository<IdentityUser, Guid> _usersRepository;
|
|
private readonly IRepository<IdentityUserOrganizationUnit> _identityUserOrganizationUnitRepository;
|
|
private readonly RegisterCheckSummaryManager _registerCheckSummaryManager;
|
|
private readonly RegisterCheckSuggestionManager _registerCheckSuggestionManager;
|
|
private readonly CurrentUser _currentUser;
|
|
|
|
public RegisterCheckManager(IRepository<RegisterCheck, Guid> registerCheckRepository,
|
|
IRepository<SysParmValue> sysParmValueRepository,
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository,
|
|
IRepository<PrimarykeyBuilder> primarykeyBuilderRepository,
|
|
CurrentUser currentUser,
|
|
IRepository<RegisterCheckItem> registerCheckItemRepository,
|
|
RegisterCheckSummaryManager registerCheckSummaryManager,
|
|
RegisterCheckSuggestionManager registerCheckSuggestionManager,
|
|
IRepository<PatientRegister, Guid> patientRegisterRepository,
|
|
IRepository<IdentityUser, Guid> usersRepository,
|
|
IRepository<IdentityUserOrganizationUnit> identityUserOrganizationUnitRepository)
|
|
{
|
|
this._registerCheckRepository = registerCheckRepository;
|
|
this._sysParmValueRepository = sysParmValueRepository;
|
|
this._customerOrgRepository = customerOrgRepository;
|
|
this._primarykeyBuilderRepository = primarykeyBuilderRepository;
|
|
this._currentUser = currentUser;
|
|
this._registerCheckItemRepository = registerCheckItemRepository;
|
|
this._registerCheckSummaryManager = registerCheckSummaryManager;
|
|
this._registerCheckSuggestionManager = registerCheckSuggestionManager;
|
|
_patientRegisterRepository = patientRegisterRepository;
|
|
_usersRepository = usersRepository;
|
|
_identityUserOrganizationUnitRepository = identityUserOrganizationUnitRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加数据
|
|
/// </summary>
|
|
/// <param name="ent"></param>
|
|
/// <returns></returns>
|
|
public async Task<RegisterCheck> CreateAsync(RegisterCheck ent)
|
|
{
|
|
return await _registerCheckRepository.InsertAsync(ent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改检查状态 0(为未检), 1(已检), 2(弃检)
|
|
/// </summary>
|
|
/// <param name="RegisterCheckId">检查单ID</param>
|
|
/// <param name="CompleteFlag">检查状态</param>
|
|
/// <returns></returns>
|
|
public async Task<RegisterCheck> UpdateCompleteAsync(Guid RegisterCheckId, char CompleteFlag)
|
|
{
|
|
var registerCheckEnt = await _registerCheckRepository.GetAsync(RegisterCheckId);
|
|
|
|
//if (registerCheckEnt == null)
|
|
// throw new UserFriendlyException($"数据有误");
|
|
if (CompleteFlag != RegisterCheckCompleteFlag.UnChecked && CompleteFlag != RegisterCheckCompleteFlag.GiveUpChecked)
|
|
{
|
|
throw new UserFriendlyException("只能删除结果和弃检时使用,禁止调用");
|
|
}
|
|
var patientRegister = await _patientRegisterRepository.GetAsync(registerCheckEnt.PatientRegisterId);
|
|
if (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck)
|
|
{
|
|
throw new UserFriendlyException("已总检,不能修改检查状态");
|
|
}
|
|
if (patientRegister.IsLock == 'Y')
|
|
{
|
|
throw new UserFriendlyException("人员登记信息已加锁,不能修改检查状态");
|
|
}
|
|
if (registerCheckEnt.IsLock == 'Y')
|
|
{
|
|
throw new UserFriendlyException("组合项目已加锁,不能修改检查状态");
|
|
}
|
|
|
|
var count = (await _registerCheckRepository.GetQueryableAsync()).Where(o => o.PatientRegisterId == patientRegister.Id &&
|
|
o.Id != RegisterCheckId && o.CompleteFlag != RegisterCheckCompleteFlag.UnChecked).Count();
|
|
if (count == 0)
|
|
{
|
|
patientRegister.CompleteFlag = PatientRegisterCompleteFlag.Registration;
|
|
await _patientRegisterRepository.UpdateAsync(patientRegister);
|
|
}
|
|
registerCheckEnt.CompleteFlag = CompleteFlag;
|
|
if (registerCheckEnt.CompleteFlag == RegisterCheckCompleteFlag.UnChecked)
|
|
{
|
|
registerCheckEnt.CheckDoctorId = null;
|
|
registerCheckEnt.ExecOrganizationUnitId = null;
|
|
registerCheckEnt.CheckDate = null;
|
|
}
|
|
var result = await _registerCheckRepository.UpdateAsync(registerCheckEnt);
|
|
if (registerCheckEnt.CompleteFlag == RegisterCheckCompleteFlag.UnChecked)
|
|
{
|
|
List<RegisterCheckItem> registerCheckItems = await _registerCheckItemRepository.GetListAsync(m => m.RegisterCheckId == RegisterCheckId);
|
|
foreach (var item in registerCheckItems)
|
|
{
|
|
item.Result = "";
|
|
}
|
|
|
|
await _registerCheckItemRepository.UpdateManyAsync(registerCheckItems);
|
|
|
|
await _registerCheckSummaryManager.CheckAndDeleteAsync(RegisterCheckId);
|
|
await _registerCheckSuggestionManager.CheckAndDeleteAsync(RegisterCheckId);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 更新审核状态 Y 已审核 N 未审核
|
|
/// </summary>
|
|
/// <param name="RegisterCheckId">检查单ID</param>
|
|
/// <param name="IsAudit">审核状态( Y 已审核 N 未审核)</param>
|
|
/// <returns></returns>
|
|
public async Task<RegisterCheck> UpdateIsAuditAsync(Guid RegisterCheckId, char IsAudit)
|
|
{
|
|
var registerCheckEnt = await _registerCheckRepository.GetAsync(RegisterCheckId);
|
|
if (registerCheckEnt == null)
|
|
throw new UserFriendlyException($"数据有误");
|
|
|
|
registerCheckEnt.IsAudit = IsAudit;
|
|
return await _registerCheckRepository.UpdateAsync(registerCheckEnt);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更改检查医生(自动更新完成状态为已检)
|
|
/// </summary>
|
|
/// <param name="entitydto"></param>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
public async Task<RegisterCheck> UpdateCheckDoctorAsync(
|
|
RegisterCheck entitydto,
|
|
RegisterCheck entity)
|
|
{
|
|
if (entity == null)
|
|
{
|
|
throw new UserFriendlyException("请求参数有误");
|
|
}
|
|
if (entitydto.CheckDate == null)
|
|
entity.CheckDate = DateTime.Now;
|
|
else
|
|
entity.CheckDate = entitydto.CheckDate;
|
|
|
|
if (string.IsNullOrWhiteSpace(entitydto.CheckDoctorId))
|
|
{
|
|
entitydto.CheckDoctorId = _currentUser.Id.ToString();
|
|
}
|
|
entity.CheckDoctorId = entitydto.CheckDoctorId;
|
|
entity.CompleteFlag = RegisterCheckCompleteFlag.Checked;
|
|
|
|
return await _registerCheckRepository.UpdateAsync(entity);
|
|
}
|
|
public void UpdateCheckDoctorAndDateAsync(
|
|
PatientRegister patientRegister,
|
|
RegisterCheck entity,
|
|
string checkDoctorId,
|
|
DateTime? checkDate,
|
|
Guid? execOrganizationUnitId
|
|
)
|
|
{
|
|
if (entity == null)
|
|
{
|
|
throw new UserFriendlyException("请求参数有误");
|
|
}
|
|
if (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck)
|
|
{
|
|
throw new UserFriendlyException("已总检不允许修改");
|
|
}
|
|
if (patientRegister.IsLock == 'Y')
|
|
{
|
|
throw new UserFriendlyException("人员已加锁不允许修改");
|
|
}
|
|
if (entity.IsLock == 'Y')
|
|
{
|
|
throw new UserFriendlyException("检查项目已加锁不允许修改");
|
|
}
|
|
if (checkDate == null)
|
|
entity.CheckDate = DateTime.Now;
|
|
else
|
|
entity.CheckDate = checkDate;
|
|
|
|
if (string.IsNullOrWhiteSpace(checkDoctorId))
|
|
{
|
|
checkDoctorId = _currentUser.Id.ToString();
|
|
}
|
|
entity.CheckDoctorId = checkDoctorId;
|
|
entity.CompleteFlag = RegisterCheckCompleteFlag.Checked;
|
|
if(execOrganizationUnitId != null && execOrganizationUnitId != Guid.Empty)
|
|
{
|
|
entity.ExecOrganizationUnitId = execOrganizationUnitId;
|
|
}
|
|
else
|
|
{
|
|
if(Guid.TryParse(entity.CheckDoctorId,out var checkDoctorIdGuid))
|
|
{
|
|
var identityUserOrganizationUnit = _identityUserOrganizationUnitRepository.GetAsync(o => o.UserId == checkDoctorIdGuid).Result;
|
|
entity.ExecOrganizationUnitId = identityUserOrganizationUnit.OrganizationUnitId;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更改危警值内容
|
|
/// </summary>
|
|
/// <param name="entitydto"></param>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
public async Task<RegisterCheck> UpdateCriticalValueAsync(
|
|
RegisterCheck entitydto,
|
|
RegisterCheck entity)
|
|
{
|
|
if (entity == null)
|
|
{
|
|
throw new UserFriendlyException("请求参数有误");
|
|
}
|
|
|
|
entity.CriticalRangeValue = entitydto.CriticalRangeValue;
|
|
//if (entitydto.CriticalValueCreateDate == null)
|
|
// entity.CriticalValueCreateDate = DateTime.Now;
|
|
//else
|
|
// entity.CriticalValueCreateDate = entitydto.CriticalValueCreateDate;
|
|
//entity.CriticalValueContent = entitydto.CriticalValueContent;
|
|
//if (entitydto.CriticalValueProcessDate == null)
|
|
// entity.CriticalValueProcessDate = DateTime.Now;
|
|
//else
|
|
// entity.CriticalValueProcessDate = entitydto.CriticalValueProcessDate;
|
|
entity.IsCriticalValue = entitydto.IsCriticalValue;
|
|
//entity.CriticalValueProcessDoctor = entitydto.CriticalValueProcessDoctor;
|
|
//entity.CriticalValueProcessFlag = entitydto.CriticalValueProcessFlag;
|
|
|
|
return await _registerCheckRepository.UpdateAsync(entity);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 更改审核医生(自动更新审核状态为已审核)
|
|
/// </summary>
|
|
/// <param name="entitydto"></param>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
public async Task<RegisterCheck> UpdateAuditorDoctorAsync(
|
|
RegisterCheck entitydto,
|
|
RegisterCheck entity)
|
|
{
|
|
if (entity == null)
|
|
{
|
|
throw new UserFriendlyException("请求参数有误");
|
|
}
|
|
|
|
//取当前登录用户ID
|
|
entity.AuditorUserId = _currentUser.Id;
|
|
if (entitydto.AuditTime == null)
|
|
entity.AuditTime = DateTime.Now;
|
|
else
|
|
entity.AuditTime = entitydto.AuditTime;
|
|
entity.IsAudit = 'Y';
|
|
|
|
return await _registerCheckRepository.UpdateAsync(entity);
|
|
}
|
|
|
|
///// <summary>
|
|
///// 生成检查单号
|
|
///// </summary>
|
|
///// <param name="CustomerOrgId">单位ID </param>
|
|
///// <returns></returns>
|
|
//public async Task<string> CreateCheckRequestNo(Guid? CustomerOrgId)
|
|
//{
|
|
// string PatientNo = "";
|
|
|
|
// string prefix = ""; //前缀
|
|
// int lastLength = 4;
|
|
|
|
|
|
// List<SysParmValue> spvlist = await _sysParmValueRepository.GetListAsync();
|
|
|
|
// if (CustomerOrgId == null || CustomerOrgId == Guid.Empty)
|
|
// {
|
|
// //个人
|
|
// spvlist = spvlist.Where(m => m.OrganizationUnitId == Guid.Empty).ToList();
|
|
// }
|
|
// else
|
|
// {
|
|
// var OrganizationUnitId = (await _customerOrgRepository.FindAsync(m => m.Id == CustomerOrgId)).OrganizationUnitId;
|
|
// if (OrganizationUnitId == null || OrganizationUnitId == Guid.Empty)
|
|
// {
|
|
// spvlist = spvlist.Where(m => m.OrganizationUnitId == Guid.Empty).ToList();
|
|
// }
|
|
// else
|
|
// {
|
|
// spvlist = spvlist.Where(m => m.OrganizationUnitId == OrganizationUnitId).ToList();
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
// var check_barcode_format_prefix = spvlist.Where(m => m.SysParmId == "check_barcode_format_prefix").FirstOrDefault(); //条码号建立规则--单位登记条码号开始值
|
|
// var check_barcode_format_length = spvlist.Where(m => m.SysParmId == "check_barcode_format_length").FirstOrDefault(); //条码号建立规则--编码方式
|
|
|
|
// if (check_barcode_format_length == null && CustomerOrgId != null && CustomerOrgId != Guid.Empty)
|
|
// {
|
|
// //组织下未找到参数,查找全局
|
|
// spvlist = await _sysParmValueRepository.GetListAsync(m => m.OrganizationUnitId == Guid.Empty);
|
|
|
|
// check_barcode_format_prefix = spvlist.Where(m => m.SysParmId == "check_barcode_format_prefix").FirstOrDefault(); //条码号建立规则--单位登记条码号开始值
|
|
// check_barcode_format_length = spvlist.Where(m => m.SysParmId == "check_barcode_format_length").FirstOrDefault(); //条码号建立规则--编码方式
|
|
// }
|
|
|
|
// if (check_barcode_format_length != null)
|
|
// {
|
|
// lastLength = Convert.ToInt32(check_barcode_format_length.ParmValue); //尾号长度
|
|
// }
|
|
|
|
// if (check_barcode_format_prefix != null)
|
|
// {
|
|
// prefix = check_barcode_format_prefix.ParmValue; //前缀
|
|
// }
|
|
|
|
|
|
// var primarykeyBuilderEnt = await _primarykeyBuilderRepository.FindAsync(f => f.PrimarykeyBuilderId == "register_check");
|
|
|
|
|
|
// string maxnum = "0";
|
|
// string date = DateTime.Now.ToString("yyyyMMdd");// 当天
|
|
|
|
// //日期+尾号 个人1开始
|
|
// #region 日期+尾号
|
|
|
|
// if (primarykeyBuilderEnt != null)
|
|
// {
|
|
|
|
|
|
// if (primarykeyBuilderEnt.DateString == date)
|
|
// {
|
|
// //当天
|
|
// //个人
|
|
// maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString();
|
|
// }
|
|
// else
|
|
// {
|
|
// //已更换日期 重新初始化
|
|
// //个人
|
|
// maxnum = (Convert.ToInt32(maxnum) + 1).ToString();
|
|
// }
|
|
|
|
// //
|
|
|
|
// primarykeyBuilderEnt.DateString = date;
|
|
// primarykeyBuilderEnt.SerialNo = maxnum;
|
|
// await _primarykeyBuilderRepository.UpdateAsync(primarykeyBuilderEnt);
|
|
// }
|
|
// else
|
|
// {
|
|
// //初始写入
|
|
|
|
// maxnum = (Convert.ToInt32(maxnum) + 1).ToString();
|
|
|
|
// primarykeyBuilderEnt = new PrimarykeyBuilder
|
|
// {
|
|
// DateString = date,
|
|
// PrimarykeyBuilderId = "register_check",
|
|
// SerialNo = maxnum,
|
|
// };
|
|
|
|
// await _primarykeyBuilderRepository.InsertAsync(primarykeyBuilderEnt);
|
|
// }
|
|
// #endregion
|
|
|
|
// PatientNo = prefix + DateTime.Now.ToString("yyyyMMdd") + maxnum.PadLeft(lastLength, '0');
|
|
|
|
// return PatientNo;
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 生成检查单号(规则,先找体检中心的配置,如未找到,就直接使用全局的)
|
|
/// 模式(0 日期+尾号 1.顺序递增)
|
|
/// </summary>
|
|
/// <param name="OrganizationUnitId">体检中心ID</param>
|
|
/// <returns></returns>
|
|
public async Task<string> CreateCheckRequestNo(Guid OrganizationUnitId)
|
|
{
|
|
|
|
//register_check CheckRequestNo
|
|
string CheckRequestNo = ""; //检查单号
|
|
|
|
List<SysParmValue> spvlist = await _sysParmValueRepository.GetListAsync();
|
|
|
|
var spv_tjzx = spvlist.Where(m => m.MedicalCenterId == OrganizationUnitId); //体检中心配置
|
|
var spv_global = spvlist.Where(m => m.MedicalCenterId == Guid.Empty); //全局配置
|
|
|
|
var check_request_no_rule_coding = "0"; // 模式(0 日期+尾号 1.顺序递增)
|
|
var check_request_no_rule_tail_len = "4"; //尾号长度
|
|
var check_request_no_rule_prefix = ""; //前缀
|
|
|
|
|
|
if (spv_tjzx.Where(m => m.SysParmId == "check_request_no_rule_coding").Count() > 0)
|
|
{
|
|
//获取体检中心配置
|
|
check_request_no_rule_coding = spv_tjzx.Where(m => m.SysParmId == "check_request_no_rule_coding").FirstOrDefault().ParmValue;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(check_request_no_rule_coding))
|
|
{
|
|
|
|
var check_request_no_rule_coding_ent = spv_global.Where(m => m.SysParmId == "check_request_no_rule_coding").FirstOrDefault();
|
|
if (check_request_no_rule_coding_ent == null)
|
|
{
|
|
throw new UserFriendlyException("全局系统参数check_request_no_rule_coding未配置");
|
|
}
|
|
else
|
|
{
|
|
//获取全局配置
|
|
check_request_no_rule_coding = check_request_no_rule_coding_ent.ParmValue;
|
|
}
|
|
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(check_request_no_rule_coding))
|
|
{
|
|
throw new UserFriendlyException("检查申请单号编码方式不能为空");
|
|
}
|
|
|
|
if (spv_tjzx.Where(m => m.SysParmId == "check_request_no_rule_tail_len").Count() > 0)
|
|
{
|
|
//获取体检中心配置
|
|
check_request_no_rule_tail_len = spv_tjzx.Where(m => m.SysParmId == "check_request_no_rule_tail_len").FirstOrDefault().ParmValue;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(check_request_no_rule_tail_len))
|
|
{
|
|
|
|
var check_request_no_rule_tail_len_ent = spv_global.Where(m => m.SysParmId == "check_request_no_rule_tail_len").FirstOrDefault();
|
|
if (check_request_no_rule_tail_len_ent == null)
|
|
{
|
|
throw new UserFriendlyException("全局系统参数check_request_no_rule_tail_len未配置");
|
|
}
|
|
else
|
|
{
|
|
//获取全局配置
|
|
check_request_no_rule_tail_len = check_request_no_rule_tail_len_ent.ParmValue;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (spv_tjzx.Where(m => m.SysParmId == "check_request_no_rule_prefix").Count() > 0)
|
|
{
|
|
//获取体检中心配置
|
|
check_request_no_rule_prefix = spv_tjzx.Where(m => m.SysParmId == "check_request_no_rule_prefix").FirstOrDefault().ParmValue;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(check_request_no_rule_prefix))
|
|
{
|
|
var check_request_no_rule_prefix_ent = spv_global.Where(m => m.SysParmId == "check_request_no_rule_prefix").FirstOrDefault();
|
|
if (check_request_no_rule_prefix_ent == null)
|
|
{
|
|
throw new UserFriendlyException("全局系统参数check_request_no_rule_prefix未配置");
|
|
}
|
|
else
|
|
{
|
|
//获取全局配置
|
|
check_request_no_rule_prefix = check_request_no_rule_prefix_ent.ParmValue;
|
|
}
|
|
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(check_request_no_rule_tail_len))
|
|
{
|
|
throw new UserFriendlyException("检查申请单号尾号长度不能为空");
|
|
}
|
|
int tailLen;
|
|
if (!int.TryParse(check_request_no_rule_tail_len, out tailLen))
|
|
{
|
|
throw new UserFriendlyException("检查申请单号尾号长度必须是数字");
|
|
};
|
|
if (tailLen < 4)
|
|
{
|
|
throw new UserFriendlyException("检查申请单号尾号长度必须大于等于4");
|
|
}
|
|
|
|
var primarykeyBuilderEnt = await _primarykeyBuilderRepository.FirstOrDefaultAsync(f => f.PrimarykeyBuilderId == "check_request_no");
|
|
|
|
|
|
|
|
|
|
string maxnum = "1";
|
|
string date = DateTime.Now.ToString("yyMMdd");// 当天
|
|
|
|
if (check_request_no_rule_coding == "0")
|
|
{
|
|
//日期+尾号
|
|
#region 模式0 日期+尾号
|
|
|
|
if (primarykeyBuilderEnt != null)
|
|
{
|
|
if (primarykeyBuilderEnt.DateString != date)
|
|
{
|
|
//新的日期 为1 maxnum
|
|
primarykeyBuilderEnt.DateString = date;
|
|
maxnum = "1";
|
|
}
|
|
else
|
|
{
|
|
maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString();
|
|
}
|
|
|
|
|
|
primarykeyBuilderEnt.SerialNo = maxnum; //更新新的序列号
|
|
|
|
CheckRequestNo = check_request_no_rule_prefix + date + maxnum.PadLeft(Convert.ToInt32(check_request_no_rule_tail_len), '0');
|
|
|
|
await _primarykeyBuilderRepository.UpdateAsync(primarykeyBuilderEnt);
|
|
}
|
|
else
|
|
{
|
|
//初始写入
|
|
|
|
CheckRequestNo = check_request_no_rule_prefix + date + maxnum.PadLeft(Convert.ToInt32(check_request_no_rule_tail_len), '0');
|
|
|
|
primarykeyBuilderEnt = new PrimarykeyBuilder
|
|
{
|
|
PrimarykeyBuilderId = "check_request_no",
|
|
DateString = date,
|
|
SerialNo = maxnum
|
|
};
|
|
|
|
await _primarykeyBuilderRepository.InsertAsync(primarykeyBuilderEnt,true);
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
//模式1 顺序递增
|
|
|
|
#region 模式1 顺序递增
|
|
|
|
if (primarykeyBuilderEnt != null)
|
|
{
|
|
maxnum = (Convert.ToInt32(primarykeyBuilderEnt.SerialNo) + 1).ToString();
|
|
primarykeyBuilderEnt.SerialNo = maxnum; //更新num
|
|
await _primarykeyBuilderRepository.UpdateAsync(primarykeyBuilderEnt);
|
|
}
|
|
else
|
|
{
|
|
//初始写入
|
|
|
|
primarykeyBuilderEnt = new PrimarykeyBuilder
|
|
{
|
|
PrimarykeyBuilderId = "check_request_no",
|
|
DateString = "",
|
|
SerialNo = maxnum
|
|
};
|
|
|
|
await _primarykeyBuilderRepository.InsertAsync(primarykeyBuilderEnt,true);
|
|
}
|
|
|
|
|
|
CheckRequestNo = check_request_no_rule_prefix + maxnum.PadLeft(Convert.ToInt32(check_request_no_rule_tail_len), '0');
|
|
#endregion
|
|
|
|
}
|
|
|
|
return CheckRequestNo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 批量
|
|
/// </summary>
|
|
/// <param name="RegisterCheckIds">RegisterCheck表ID 集合</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
public async Task CheckAndDeleteAsync(List<Guid> RegisterCheckIds)
|
|
{
|
|
if (RegisterCheckIds.Count > 0)
|
|
{
|
|
var registerCheckCriticalValueList = await _registerCheckRepository.GetListAsync(m => RegisterCheckIds.Contains(m.Id));
|
|
if (registerCheckCriticalValueList.Any())
|
|
{
|
|
await _registerCheckRepository.DeleteManyAsync(registerCheckCriticalValueList);
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new UserFriendlyException("数据不存在");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|