Commit 1c4df99b by 李承祥

当前用户医院下绩效列表、二次绩效上传文件、二次绩效基础配置

parent ac20c91e
...@@ -28,11 +28,20 @@ public class AgainAllotController : Controller ...@@ -28,11 +28,20 @@ public class AgainAllotController : Controller
{ {
private AgainAllotService againAllotService; private AgainAllotService againAllotService;
private ClaimService claimService; private ClaimService claimService;
private AllotService allotService;
private IHostingEnvironment evn;
private ConfigService configService;
public AgainAllotController(AgainAllotService againAllotService, public AgainAllotController(AgainAllotService againAllotService,
ClaimService claimService) ClaimService claimService,
AllotService allotService,
IHostingEnvironment evn,
ConfigService configService)
{ {
this.againAllotService = againAllotService; this.againAllotService = againAllotService;
this.claimService = claimService; this.claimService = claimService;
this.allotService = allotService;
this.evn = evn;
this.configService = configService;
} }
/// <summary> /// <summary>
...@@ -41,9 +50,10 @@ public class AgainAllotController : Controller ...@@ -41,9 +50,10 @@ public class AgainAllotController : Controller
/// <returns></returns> /// <returns></returns>
[Route("allotlist")] [Route("allotlist")]
[HttpPost] [HttpPost]
public ApiResponse AllotList() public ApiResponse AllotList([FromBody]UserRequest request)
{ {
throw new NotImplementedException(); var list = againAllotService.GetAllotList(request.ID);
return new ApiResponse(ResponseType.OK, list);
} }
/// <summary> /// <summary>
...@@ -55,7 +65,45 @@ public ApiResponse AllotList() ...@@ -55,7 +65,45 @@ public ApiResponse AllotList()
[HttpPost] [HttpPost]
public ApiResponse Import([FromForm] IFormCollection form) public ApiResponse Import([FromForm] IFormCollection form)
{ {
throw new NotImplementedException(); var allotid = form.ToDictionary().GetValue("allotid", 0);
if (allotid <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
var userid = form.ToDictionary().GetValue("userid", 0);
if (userid <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "userid无效");
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
var allot = allotService.GetAllot(allotid);
if (allot == null)
return new ApiResponse(ResponseType.Fail, "allotid不存在");
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(evn.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}");
using (var stream = file.OpenReadStream())
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
allot.Path = path;
allot.Remark = EnumHelper.GetDescription(AllotStates.FileUploaded);
int flag = againAllotService.Insert(allot, userid);
if (flag == 0)
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
configService.ClearAgain(flag);
configService.CopyAgain(flag);
}
return new ApiResponse(ResponseType.OK);
} }
[Route("generate")] [Route("generate")]
......
...@@ -244,5 +244,60 @@ public ApiResponse WorkyearDelete([CustomizeValidator(RuleSet = "Delete"), FromB ...@@ -244,5 +244,60 @@ public ApiResponse WorkyearDelete([CustomizeValidator(RuleSet = "Delete"), FromB
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
#endregion #endregion
#region cofagain
/// <summary>
/// 获取二次绩效配置列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("cofagainlist")]
[HttpPost]
public ApiResponse GetAgainList([CustomizeValidator(RuleSet = "Select"), FromBody]CofAgainRequest request)
{
var list = _configService.GetAgainList(request.AgainAllotID);
return new ApiResponse(ResponseType.OK, "ok", list);
}
/// <summary>
/// 新增二次绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("cofagaininsert")]
[HttpPost]
public ApiResponse AgainInsert([FromBody]CofAgainRequest request)
{
var workyear = _configService.AgainInsert(request);
return new ApiResponse(ResponseType.OK, workyear);
}
/// <summary>
/// 修改二次绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("cofagainupdate")]
[HttpPost]
public ApiResponse AgainUpdate([CustomizeValidator(RuleSet = "Update"), FromBody]CofAgainRequest request)
{
var workyear = _configService.AgainUpdate(request);
return new ApiResponse(ResponseType.OK, workyear);
}
/// <summary>
/// 删除二次绩效配置
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("cofagaindelete")]
[HttpPost]
public ApiResponse AgainDelete([CustomizeValidator(RuleSet = "Delete"), FromBody]CofAgainRequest request)
{
if (!_configService.AgainDelete(request))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
#endregion
} }
} }
\ No newline at end of file
using System;
using FluentValidation;
namespace Performance.DtoModels
{
public class CofAgainRequest: ApiRequest
{
public int ID { get; set; }
/// <summary>
///
/// </summary>
public int AllotID { get; set; }
/// <summary>
///
/// </summary>
public int AgainAllotID { get; set; }
/// <summary>
/// 1 职称绩效 2 工作量绩效 3 满勤天数
/// </summary>
public int Type { get; set; }
/// <summary>
/// 参数名称
/// </summary>
public string TypeName { get; set; }
/// <summary>
/// 参数值
/// </summary>
public Nullable<decimal> Value { get; set; }
public class CofAgainRequestValidator : AbstractValidator<CofAgainRequest>
{
public CofAgainRequestValidator()
{
RuleSet("Select", () =>
{
RuleFor(x => x.AgainAllotID).NotNull().NotEmpty().GreaterThan(0);
});
RuleSet("Update", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
RuleSet("Delete", () =>
{
RuleFor(x => x.ID).NotNull().GreaterThan(0);
});
}
}
}
}
...@@ -39,8 +39,14 @@ public class AllotResponse ...@@ -39,8 +39,14 @@ public class AllotResponse
public Nullable<DateTime> UploadDate { get; set; } public Nullable<DateTime> UploadDate { get; set; }
/// <summary> /// <summary>
/// /// 0 数据未上传 1 数据已上传 2 正在校验数据 3 数据验证通过 4 数据错误
/// 5 正在生成绩效 6 绩效结果解析成功 7 绩效解析失败 8 归档
/// </summary> /// </summary>
public int States { get; set; } public int States { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
} }
} }
...@@ -36,5 +36,19 @@ public int DeleteData(int allotId) ...@@ -36,5 +36,19 @@ public int DeleteData(int allotId)
return Execute(sql, new { allotId }); return Execute(sql, new { allotId });
} }
public int DelAgain(int againid)
{
List<string> tableArray = new List<string>
{
"ag_data",
"ag_employee",
"ag_header"
};
string sql = "";
tableArray.ForEach(t => sql += $"delete from {t} where againallotid=@againid;");
return Execute(sql, new { againid });
}
} }
} }
using Microsoft.Extensions.Options; using AutoMapper;
using Microsoft.Extensions.Options;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
using Performance.Repository; using Performance.Repository;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -17,11 +19,17 @@ public class AgainAllotService : IAutoInjection ...@@ -17,11 +19,17 @@ public class AgainAllotService : IAutoInjection
private PerforPeragainallotRepository perforPeragainallotRepository; private PerforPeragainallotRepository perforPeragainallotRepository;
private PerforResaccountdoctorRepository perforResaccountdoctorRepository; private PerforResaccountdoctorRepository perforResaccountdoctorRepository;
private PerforResaccountnurseRepository perforResaccountnurseRepository; private PerforResaccountnurseRepository perforResaccountnurseRepository;
private PerforUserRepository perforUserRepository;
private PerforUserhospitalRepository perforUserhospitalRepository;
private PerforPerallotRepository perforPerallotRepository;
public AgainAllotService(IOptions<Application> options, AgainService againService, public AgainAllotService(IOptions<Application> options, AgainService againService,
PerforCofagainRepository perforCofagainRepository, PerforCofagainRepository perforCofagainRepository,
PerforPeragainallotRepository perforPeragainallotRepository, PerforPeragainallotRepository perforPeragainallotRepository,
PerforResaccountdoctorRepository perforResaccountdoctorRepository, PerforResaccountdoctorRepository perforResaccountdoctorRepository,
PerforResaccountnurseRepository perforResaccountnurseRepository) PerforResaccountnurseRepository perforResaccountnurseRepository,
PerforUserRepository perforUserRepository,
PerforUserhospitalRepository perforUserhospitalRepository,
PerforPerallotRepository perforPerallotRepository)
{ {
this.application = options.Value; this.application = options.Value;
this.againService = againService; this.againService = againService;
...@@ -29,6 +37,9 @@ public class AgainAllotService : IAutoInjection ...@@ -29,6 +37,9 @@ public class AgainAllotService : IAutoInjection
this.perforPeragainallotRepository = perforPeragainallotRepository; this.perforPeragainallotRepository = perforPeragainallotRepository;
this.perforResaccountdoctorRepository = perforResaccountdoctorRepository; this.perforResaccountdoctorRepository = perforResaccountdoctorRepository;
this.perforResaccountnurseRepository = perforResaccountnurseRepository; this.perforResaccountnurseRepository = perforResaccountnurseRepository;
this.perforUserRepository = perforUserRepository;
this.perforUserhospitalRepository = perforUserhospitalRepository;
this.perforPerallotRepository = perforPerallotRepository;
} }
/// <summary> /// <summary>
...@@ -216,5 +227,51 @@ public class AgainAllotService : IAutoInjection ...@@ -216,5 +227,51 @@ public class AgainAllotService : IAutoInjection
return (response, situation); return (response, situation);
} }
/// <summary>
/// 二次绩效新增记录
/// </summary>
/// <param name="allot"></param>
/// <param name="userid"></param>
/// <returns></returns>
public int Insert(per_allot allot, int userid)
{
var user = perforUserRepository.GetEntity(t => t.ID == userid);
var model = new per_againallot
{
AllotID = allot.ID,
CreateUser = userid,
CreateDateTime = DateTime.Now,
Department = user.Department,
Path = allot.Path,
Remark = allot.Remark
};
if (!perforPeragainallotRepository.Add(model))
return 0;
return model.ID;
}
/// <summary>
/// 根据人物角色获取绩效列表
/// </summary>
/// <returns></returns>
public List<AllotResponse> GetAllotList(int userid)
{
var user = perforUserRepository.GetEntity(t => t.ID == userid);
if (user == null)
throw new NotImplementedException("人员ID无效");
var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userid);
if (hospital == null)
throw new NotImplementedException("人员未选择医院");
var allot = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID);
List<AllotResponse> list = Mapper.Map<List<AllotResponse>>(allot);
if (list != null && list.Count > 0)
{
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
list.ForEach(t => t.Department = user.Department);
}
return list;
}
} }
} }
...@@ -16,20 +16,26 @@ public class ConfigService : IAutoInjection ...@@ -16,20 +16,26 @@ public class ConfigService : IAutoInjection
private PerforCofdrugpropRepository _drugpropRepository; private PerforCofdrugpropRepository _drugpropRepository;
private PerforCofincomeRepository _incomeRepository; private PerforCofincomeRepository _incomeRepository;
private PerforCofworkyearRepository _workyearRepository; private PerforCofworkyearRepository _workyearRepository;
private PerforCofagainRepository _againRepository;
private PerforPerallotRepository perforPerAllotRepository; private PerforPerallotRepository perforPerAllotRepository;
private PerforPeragainallotRepository perforPeragainallotRepository;
private PerforLogdbugRepository logdbug; private PerforLogdbugRepository logdbug;
public ConfigService(PerforCofdirectorRepository cofdirectorRepository, public ConfigService(PerforCofdirectorRepository cofdirectorRepository,
PerforCofdrugpropRepository cofdrugpropRepository, PerforCofdrugpropRepository cofdrugpropRepository,
PerforCofincomeRepository cofincomeRepository, PerforCofincomeRepository cofincomeRepository,
PerforCofworkyearRepository cofworkyearRepository, PerforCofworkyearRepository cofworkyearRepository,
PerforCofagainRepository againRepository,
PerforPerallotRepository perforPerAllotRepository, PerforPerallotRepository perforPerAllotRepository,
PerforPeragainallotRepository perforPeragainallotRepository,
PerforLogdbugRepository logdbug) PerforLogdbugRepository logdbug)
{ {
this._directorRepository = cofdirectorRepository; this._directorRepository = cofdirectorRepository;
this._drugpropRepository = cofdrugpropRepository; this._drugpropRepository = cofdrugpropRepository;
this._incomeRepository = cofincomeRepository; this._incomeRepository = cofincomeRepository;
this._workyearRepository = cofworkyearRepository; this._workyearRepository = cofworkyearRepository;
this._againRepository = againRepository;
this.perforPerAllotRepository = perforPerAllotRepository; this.perforPerAllotRepository = perforPerAllotRepository;
this.perforPeragainallotRepository = perforPeragainallotRepository;
this.logdbug = logdbug; this.logdbug = logdbug;
} }
...@@ -279,7 +285,7 @@ public void Clear(int allotId) ...@@ -279,7 +285,7 @@ public void Clear(int allotId)
logdbug.Add(allotId, "清理无效数据", $"受影响行数:{count}"); logdbug.Add(allotId, "清理无效数据", $"受影响行数:{count}");
} }
#region Copy
/// <summary> /// <summary>
/// 复制报表基础配置 /// 复制报表基础配置
/// </summary> /// </summary>
...@@ -326,5 +332,115 @@ public void Copy(per_allot allot) ...@@ -326,5 +332,115 @@ public void Copy(per_allot allot)
_workyearRepository.AddRange(newWorkyears.ToArray()); _workyearRepository.AddRange(newWorkyears.ToArray());
} }
} }
#endregion
#region cof_again
/// <summary>
/// 获取cof_drugprop列表
/// </summary>
/// <returns></returns>
public List<cof_again> GetAgainList(int againId)
{
var list = _againRepository.GetEntities(t => t.AgainAllotID == againId);
return list;
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public cof_again AgainInsert(CofAgainRequest request)
{
var workyear = Mapper.Map<cof_again>(request);
if (!_againRepository.Add(workyear))
throw new PerformanceException("保存失败");
return workyear;
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public cof_again AgainUpdate(CofAgainRequest request)
{
var again = _againRepository.GetEntity(t => t.ID == request.ID);
if (null == again)
throw new PerformanceException($"ID不存在 :{request.ID}");
again.Type = request.Type;
again.TypeName = request.TypeName;
again.Value = request.Value;
if (!_againRepository.Update(again))
throw new PerformanceException("保存失败");
return again;
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public bool AgainDelete(CofAgainRequest request)
{
var again = _againRepository.GetEntity(t => t.ID == request.ID);
if (null == again)
throw new PerformanceException($"ID不存在 :{request.ID}");
return _againRepository.Remove(again);
}
#endregion
/// <summary>
/// 清楚二次绩效中无效数据
/// </summary>
/// <param name="againId"></param>
public void ClearAgain(int againId)
{
var count = _directorRepository.DelAgain(againId);
logdbug.Add(againId, "清楚二次绩效中无效数据", $"受影响行数:{count}");
}
#region CopyAgain
/// <summary>
/// 复制报表基础配置
/// </summary>
/// <param name="iD"></param>
public void CopyAgain(int againid)
{
var again = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
if (again == null)
throw new PerformanceException("二次绩效不存在");
var allot = perforPerAllotRepository.GetEntity(t => t.ID == again.AllotID);
if (allot == null)
throw new PerformanceException("绩效不存在");
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId)
.OrderBy(t => t.Year).ThenBy(t => t.Month).ToList();
for (int i = 0; i < list.Count; i++)
{
if (list[i].ID == allot.ID && (i - 1) >= 0)
allot = list[i - 1];
}
//根据上月绩效获取二次绩效信息
var beforeAgain = perforPeragainallotRepository.GetEntity(t => t.AllotID == allot.ID && t.CreateUser == again.CreateUser);
var record = _againRepository.GetEntities(t => t.AgainAllotID == -1);
if (again.AllotID != allot.ID && beforeAgain != null)
record = _againRepository.GetEntities(t => t.AgainAllotID == beforeAgain.ID);
int days = DateTime.DaysInMonth(allot.Year, allot.Month);
var againList = record.Select(t => new cof_again
{
AllotID = allot.ID,
AgainAllotID = againid,
Type = t.Type,
TypeName = t.TypeName,
Value = (t.Type == 3 && beforeAgain != null) ? days : t.Value
});
_againRepository.AddRange(againList.ToArray());
}
#endregion
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment