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
/// <returns></returns>
[Route("allotlist")]
[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);
}
......@@ -65,21 +66,19 @@ public ApiResponse AllotList([FromBody]UserRequest request)
[HttpPost]
public ApiResponse Import([FromForm] IFormCollection form)
{
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 againid = form.ToDictionary().GetValue("againid", 0);
if (againid <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "againid无效");
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 again = againAllotService.GetAgainallot(againid);
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 ext = FileHelper.GetExtension(file.FileName);
......@@ -96,11 +95,11 @@ public ApiResponse Import([FromForm] IFormCollection form)
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)
if (!againAllotService.Update(allot, againid))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
configService.ClearAgain(flag);
configService.CopyAgain(flag);
configService.ClearAgain(againid);
configService.CopyAgain(againid);
}
return new ApiResponse(ResponseType.OK);
......
......@@ -110,6 +110,7 @@ public AutoMapperConfigs()
CreateMap<res_accountdoctor, DoctorResponse>();
CreateMap<res_accountnurse, NurseResponse>();
//二次绩效
CreateMap<ag_header, PerHeader>();
CreateMap<PerHeader, ag_header>();
......@@ -122,6 +123,8 @@ public AutoMapperConfigs()
CreateMap<PerAgainSituation, ag_againsituation>();
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; }
}
}
......@@ -7,35 +7,35 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("per_againallot")]
public class per_againallot
public class per_againallot
{
/// <summary>
///
/// </summary>
[Key]
public int ID { get; set; }
public int ID { get; set; }
/// <summary>
///
/// </summary>
public Nullable<int> AllotID { get; set; }
/// <summary>
/// 用户ID
/// </summary>
public Nullable<int> CreateUser { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public Nullable<DateTime> CreateDateTime { get; set; }
/// <summary>
/// 上传时间
/// </summary>
......@@ -45,12 +45,12 @@ public class per_againallot
/// 科室名称
/// </summary>
public string Department { get; set; }
/// <summary>
/// 文件路径
/// </summary>
public string Path { get; set; }
/// <summary>
/// 二次分配状态 0 数据未上传 1 数据已上传 2 正在生成绩效 3 绩效生成成功 4 绩效生成失败
/// </summary>
......
......@@ -333,28 +333,22 @@ public bool Generate(AgainAllotRequest request, UserIdentity user)
/// <param name="allot"></param>
/// <param name="userid"></param>
/// <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 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;
var again = perforPeragainallotRepository.GetEntity(t => t.ID == againid);
again.ID = againid;
again.UploadDateTime = DateTime.Now;
again.Path = allot.Path;
again.Remark = allot.Remark;
again.States = 1;
return perforPeragainallotRepository.Update(again);
}
/// <summary>
/// 根据人物角色获取绩效列表
/// </summary>
/// <returns></returns>
public List<AllotResponse> GetAllotList(int userid)
public List<AgainAllotResponse> GetAllotList(int userid)
{
var user = perforUserRepository.GetEntity(t => t.ID == userid);
if (user == null)
......@@ -362,13 +356,49 @@ public List<AllotResponse> GetAllotList(int userid)
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)
var allot = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.CreateUser == userid);
if (allot == null)
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)
{
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
list.ForEach(t => t.Department = user.Department);
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 =>
{
var data = allot.Where(p => p.ID == t.AllotID).FirstOrDefault();
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;
}
}
......
......@@ -430,14 +430,14 @@ public void CopyAgain(int againid)
if (again.AllotID != allot.ID && beforeAgain != null)
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
{
AllotID = allot.ID,
AgainAllotID = againid,
Type = t.Type,
TypeName = t.TypeName,
Value = (t.Type == 3 && beforeAgain != null) ? days : t.Value
Value = t.Value
});
_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