Commit 741530f5 by ruyun.zhang@suvalue.com

Merge branch 'develop' of http://192.168.0.110:8880/zry/performance into develop

# Conflicts:
#	performance/Performance.DtoModels/AutoMapper/AutoMapperConfigs.cs
parents 13971029 d54d5350
...@@ -50,9 +50,10 @@ public class AgainAllotController : Controller ...@@ -50,9 +50,10 @@ public class AgainAllotController : Controller
/// <returns></returns> /// <returns></returns>
[Route("allotlist")] [Route("allotlist")]
[HttpPost] [HttpPost]
public ApiResponse AllotList([FromBody]UserRequest request) public ApiResponse AllotList([FromBody]ApiRequest request)
{ {
var list = againAllotService.GetAllotList(request.ID); var user = claimService.At(request);
var list = againAllotService.GetAllotList(user.UserID);
return new ApiResponse(ResponseType.OK, list); return new ApiResponse(ResponseType.OK, list);
} }
...@@ -65,21 +66,19 @@ public ApiResponse AllotList([FromBody]UserRequest request) ...@@ -65,21 +66,19 @@ public ApiResponse AllotList([FromBody]UserRequest request)
[HttpPost] [HttpPost]
public ApiResponse Import([FromForm] IFormCollection form) public ApiResponse Import([FromForm] IFormCollection form)
{ {
var allotid = form.ToDictionary().GetValue("allotid", 0); var againid = form.ToDictionary().GetValue("againid", 0);
if (allotid <= 0) if (againid <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "againid无效");
var userid = form.ToDictionary().GetValue("userid", 0);
if (userid <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "userid无效");
var file = ((FormFileCollection)form.Files).FirstOrDefault(); var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null) if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
var allot = allotService.GetAllot(allotid);
if (allot == null) var again = againAllotService.GetAgainallot(againid);
return new ApiResponse(ResponseType.Fail, "allotid不存在"); if (again == null)
return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在");
var allot = allotService.GetAllot(again.AllotID.Value);
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff"); var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName); var ext = FileHelper.GetExtension(file.FileName);
...@@ -96,11 +95,11 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -96,11 +95,11 @@ public ApiResponse Import([FromForm] IFormCollection form)
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败"); return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传失败");
allot.Path = path; allot.Path = path;
allot.Remark = EnumHelper.GetDescription(AllotStates.FileUploaded); allot.Remark = EnumHelper.GetDescription(AllotStates.FileUploaded);
int flag = againAllotService.Insert(allot, userid);
if (flag == 0) if (!againAllotService.Update(allot, againid))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败"); return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
configService.ClearAgain(flag); configService.ClearAgain(againid);
configService.CopyAgain(flag); configService.CopyAgain(againid);
} }
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
......
...@@ -110,6 +110,7 @@ public AutoMapperConfigs() ...@@ -110,6 +110,7 @@ public AutoMapperConfigs()
CreateMap<res_accountdoctor, DoctorResponse>(); CreateMap<res_accountdoctor, DoctorResponse>();
CreateMap<res_accountnurse, NurseResponse>(); CreateMap<res_accountnurse, NurseResponse>();
//二次绩效 //二次绩效
CreateMap<ag_header, PerHeader>(); CreateMap<ag_header, PerHeader>();
CreateMap<PerHeader, ag_header>(); CreateMap<PerHeader, ag_header>();
...@@ -122,6 +123,8 @@ public AutoMapperConfigs() ...@@ -122,6 +123,8 @@ public AutoMapperConfigs()
CreateMap<PerAgainSituation, ag_againsituation>(); CreateMap<PerAgainSituation, ag_againsituation>();
CreateMap<ag_againsituation, PerAgainSituation>(); CreateMap<ag_againsituation, PerAgainSituation>();
CreateMap<per_againallot, AgainAllotResponse>();
} }
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class AgainAllotResponse
{
/// <summary>
///
/// </summary>
public int ID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
/// 绩效发放年
/// </summary>
public int Year { get; set; }
/// <summary>
/// 绩效发放月
/// </summary>
public int Month { get; set; }
/// <summary>
/// 科室名称
/// </summary>
public string Department { get; set; }
/// <summary>
/// 上传时间
/// </summary>
public Nullable<DateTime> UploadDateTime { get; set; }
/// <summary>
/// 文件路径
/// </summary>
public string Path { get; set; }
/// <summary>
/// 二次分配状态 0 数据未上传 1 数据已上传 2 正在生成绩效 3 绩效生成成功 4 绩效生成失败
/// </summary>
public Nullable<int> States { get; set; }
}
}
...@@ -333,28 +333,22 @@ public bool Generate(AgainAllotRequest request, UserIdentity user) ...@@ -333,28 +333,22 @@ public bool Generate(AgainAllotRequest request, UserIdentity user)
/// <param name="allot"></param> /// <param name="allot"></param>
/// <param name="userid"></param> /// <param name="userid"></param>
/// <returns></returns> /// <returns></returns>
public int Insert(per_allot allot, int userid) public bool Update(per_allot allot, int againid)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userid); var again = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
var model = new per_againallot again.ID = againid;
{ again.UploadDateTime = DateTime.Now;
AllotID = allot.ID, again.Path = allot.Path;
CreateUser = userid, again.Remark = allot.Remark;
CreateDateTime = DateTime.Now, again.States = 1;
Department = user.Department, return perforPeragainallotRepository.Update(again);
Path = allot.Path,
Remark = allot.Remark
};
if (!perforPeragainallotRepository.Add(model))
return 0;
return model.ID;
} }
/// <summary> /// <summary>
/// 根据人物角色获取绩效列表 /// 根据人物角色获取绩效列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<AllotResponse> GetAllotList(int userid) public List<AgainAllotResponse> GetAllotList(int userid)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userid); var user = perforUserRepository.GetEntity(t => t.ID == userid);
if (user == null) if (user == null)
...@@ -362,13 +356,49 @@ public List<AllotResponse> GetAllotList(int userid) ...@@ -362,13 +356,49 @@ public List<AllotResponse> GetAllotList(int userid)
var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userid); var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userid);
if (hospital == null) if (hospital == null)
throw new NotImplementedException("人员未选择医院"); throw new NotImplementedException("人员未选择医院");
var allot = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID); var allot = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.CreateUser == userid);
List<AllotResponse> list = Mapper.Map<List<AllotResponse>>(allot); if (allot == null)
if (list != null && list.Count > 0) throw new NotImplementedException("该医院未生成绩效");
var allotId = allot.Select(t => t.ID).ToList();
var again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.CreateUser == userid);
var arrId = again == null ? new List<int>() : again.Select(t => t.AllotID.Value).ToList();
//取得未生成二次绩效的绩效id
var exceptId = allotId.Except(arrId).ToList();
if (exceptId.Count > 0)
{
allot = allot.Where(t => exceptId.Contains(t.ID)).ToList();
var model = allot.Select(t => new per_againallot
{
AllotID = t.ID,
CreateUser = userid,
CreateDateTime = DateTime.Now,
Department = user.Department,
States = 0
});
//生成二次绩效
perforPeragainallotRepository.AddRange(model.ToArray());
}
again = perforPeragainallotRepository.GetEntities(t => allotId.Contains(t.AllotID.Value) && t.CreateUser == userid);
List<AgainAllotResponse> list = Mapper.Map<List<AgainAllotResponse>>(again);
list.ForEach(t =>
{ {
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList(); var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault();
list.ForEach(t => t.Department = user.Department); t.Year = data.Year;
t.Month = data.Month;
});
return list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
} }
/// <summary>
/// 获取二次绩效的记录
/// </summary>
/// <param name="againid"></param>
/// <returns></returns>
public per_againallot GetAgainallot(int againid)
{
var list = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
return list; return list;
} }
} }
......
...@@ -430,14 +430,14 @@ public void CopyAgain(int againid) ...@@ -430,14 +430,14 @@ public void CopyAgain(int againid)
if (again.AllotID != allot.ID && beforeAgain != null) if (again.AllotID != allot.ID && beforeAgain != null)
record = _againRepository.GetEntities(t => t.AgainAllotID == beforeAgain.ID); record = _againRepository.GetEntities(t => t.AgainAllotID == beforeAgain.ID);
int days = DateTime.DaysInMonth(allot.Year, allot.Month); //int days = DateTime.DaysInMonth(allot.Year, allot.Month);
var againList = record.Select(t => new cof_again var againList = record.Select(t => new cof_again
{ {
AllotID = allot.ID, AllotID = allot.ID,
AgainAllotID = againid, AgainAllotID = againid,
Type = t.Type, Type = t.Type,
TypeName = t.TypeName, TypeName = t.TypeName,
Value = (t.Type == 3 && beforeAgain != null) ? days : t.Value Value = t.Value
}); });
_againRepository.AddRange(againList.ToArray()); _againRepository.AddRange(againList.ToArray());
} }
......
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