|
@@ -5,6 +5,7 @@ using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using wispro.sp.api.Job;
|
|
using wispro.sp.entity;
|
|
using wispro.sp.entity;
|
|
using wispro.sp.share;
|
|
using wispro.sp.share;
|
|
|
|
|
|
@@ -72,7 +73,7 @@ namespace wispro.sp.api.Controllers
|
|
return Context.ProjectContentRecords
|
|
return Context.ProjectContentRecords
|
|
.Include(p=>p.CalMonth)
|
|
.Include(p=>p.CalMonth)
|
|
.Include(p => p.Reviewer)
|
|
.Include(p => p.Reviewer)
|
|
- .Include(p => p.Project)
|
|
|
|
|
|
+ .Include(p => p.Project).ThenInclude(p => p.Customer)
|
|
.Include(p=>p.ProjectWorkContents)
|
|
.Include(p=>p.ProjectWorkContents)
|
|
.Where(p => p.Staff.Name == User.Identity.Name).ToList();
|
|
.Where(p => p.Staff.Name == User.Identity.Name).ToList();
|
|
}
|
|
}
|
|
@@ -82,7 +83,7 @@ namespace wispro.sp.api.Controllers
|
|
var retObj = Context.ProjectContentRecords
|
|
var retObj = Context.ProjectContentRecords
|
|
.Include(p => p.CalMonth)
|
|
.Include(p => p.CalMonth)
|
|
.Include(p => p.Reviewer)
|
|
.Include(p => p.Reviewer)
|
|
- .Include(p => p.Project)
|
|
|
|
|
|
+ .Include(p => p.Project).ThenInclude(p=>p.Customer)
|
|
.Include(p => p.ProjectWorkContents)
|
|
.Include(p => p.ProjectWorkContents)
|
|
.FirstOrDefault(p=>p.Id == Id);
|
|
.FirstOrDefault(p=>p.Id == Id);
|
|
|
|
|
|
@@ -97,6 +98,7 @@ namespace wispro.sp.api.Controllers
|
|
{
|
|
{
|
|
ViewProjectWorkContent tem = new ViewProjectWorkContent();
|
|
ViewProjectWorkContent tem = new ViewProjectWorkContent();
|
|
tem.modifyState = ModifyState.UnChanged;
|
|
tem.modifyState = ModifyState.UnChanged;
|
|
|
|
+ tem.Id = wContent.Id;
|
|
tem.Content = wContent.Content;
|
|
tem.Content = wContent.Content;
|
|
tem.ActualPerformance = wContent.ActualPerformance;
|
|
tem.ActualPerformance = wContent.ActualPerformance;
|
|
tem.ContentRecordId = wContent.ContentRecordId;
|
|
tem.ContentRecordId = wContent.ContentRecordId;
|
|
@@ -108,6 +110,8 @@ namespace wispro.sp.api.Controllers
|
|
ret.ProjectWorkContents.Add(tem);
|
|
ret.ProjectWorkContents.Add(tem);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ret.ProjectContentRecord.ProjectWorkContents = null;
|
|
|
|
+
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -117,7 +121,157 @@ namespace wispro.sp.api.Controllers
|
|
|
|
|
|
public ApiSaveResponse SaveProjectWorkContent(ProjectContents saveObj)
|
|
public ApiSaveResponse SaveProjectWorkContent(ProjectContents saveObj)
|
|
{
|
|
{
|
|
- return null;
|
|
|
|
|
|
+ ApiSaveResponse ret = new ApiSaveResponse();
|
|
|
|
+ ret.Success = true;
|
|
|
|
+
|
|
|
|
+ using (var t = Context.Database.BeginTransaction())
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ if (saveObj.ProjectContentRecord.Id == 0)
|
|
|
|
+ {
|
|
|
|
+ if(string.IsNullOrEmpty(saveObj.ProjectContentRecord.ProjectNo))
|
|
|
|
+ {
|
|
|
|
+ ret.Success = false;
|
|
|
|
+ ret.ErrorMessage = "没有选择专案!";
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ saveObj.ProjectContentRecord.Project = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var currentUser = Context.Staffs.FirstOrDefault(s=>s.Name == User.Identity.Name);
|
|
|
|
+ saveObj.ProjectContentRecord.StaffId = currentUser.Id;
|
|
|
|
+
|
|
|
|
+ Context.ProjectContentRecords.Add(saveObj.ProjectContentRecord);
|
|
|
|
+ Context.SaveChanges();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ var temObj = Context.ProjectContentRecords.FirstOrDefault(p => p.Id == saveObj.ProjectContentRecord.Id);
|
|
|
|
+ temObj.CaseCoefficient = saveObj.ProjectContentRecord.CaseCoefficient;
|
|
|
|
+ temObj.Point = saveObj.ProjectContentRecord.Point;
|
|
|
|
+ temObj.ReviewerId = saveObj.ProjectContentRecord.ReviewerId;
|
|
|
|
+ //temObj.StaffId = saveObj.ProjectContentRecord.StaffId;
|
|
|
|
+ temObj.State = saveObj.ProjectContentRecord.State;
|
|
|
|
+ Context.SaveChanges();
|
|
|
|
+ saveObj.ProjectContentRecord = temObj;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach (var temContent in saveObj.ProjectWorkContents)
|
|
|
|
+ {
|
|
|
|
+ switch (temContent.modifyState)
|
|
|
|
+ {
|
|
|
|
+ case ModifyState.Deleted:
|
|
|
|
+ Context.Database.ExecuteSqlRaw($"Delete from ProjectWorkContent where id={temContent.Id}");
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case ModifyState.Modified:
|
|
|
|
+ var modifyContent = Context.ProjectWorkContents.FirstOrDefault(p => p.Id == temContent.Id);
|
|
|
|
+ if (modifyContent != null)
|
|
|
|
+ {
|
|
|
|
+ modifyContent.Content = temContent.Content;
|
|
|
|
+ modifyContent.ActualPerformance = temContent.ActualPerformance;
|
|
|
|
+ modifyContent.DifficultFactor = temContent.DifficultFactor;
|
|
|
|
+ modifyContent.FinalPerformance = temContent.FinalPerformance;
|
|
|
|
+ modifyContent.TakeTime = temContent.TakeTime;
|
|
|
|
+ modifyContent.TimeSpan = temContent.TimeSpan;
|
|
|
|
+ modifyContent.WorkDate = temContent.WorkDate;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case ModifyState.New:
|
|
|
|
+ var newContent = new ProjectWorkContent();
|
|
|
|
+ newContent.Content = temContent.Content;
|
|
|
|
+ newContent.ActualPerformance = temContent.ActualPerformance;
|
|
|
|
+ newContent.DifficultFactor = temContent.DifficultFactor;
|
|
|
|
+ newContent.FinalPerformance = temContent.FinalPerformance;
|
|
|
|
+ newContent.TakeTime = temContent.TakeTime;
|
|
|
|
+ newContent.TimeSpan = temContent.TimeSpan;
|
|
|
|
+ newContent.WorkDate = temContent.WorkDate;
|
|
|
|
+ newContent.ContentRecordId = saveObj.ProjectContentRecord.Id;
|
|
|
|
+
|
|
|
|
+ Context.ProjectWorkContents.Add(newContent);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ Context.SaveChanges();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ t.Commit();
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex)
|
|
|
|
+ {
|
|
|
|
+ t.Rollback();
|
|
|
|
+ ret.Success = false;
|
|
|
|
+ ret.ErrorMessage = ex.Message;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ApiSaveResponse SubmitToReview(int Id, int reviewerId)
|
|
|
|
+ {
|
|
|
|
+ ApiSaveResponse ret = new ApiSaveResponse();
|
|
|
|
+ ret.Success = true;
|
|
|
|
+ using (var t = Context.Database.BeginTransaction())
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ var temObj = Context.ProjectContentRecords.FirstOrDefault(p=>p.Id == Id);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(temObj != null)
|
|
|
|
+ {
|
|
|
|
+ temObj.State = 1;
|
|
|
|
+
|
|
|
|
+ var temStaff = Context.Staffs.FirstOrDefault(s=>s.Id == reviewerId);
|
|
|
|
+
|
|
|
|
+ if(temStaff == null)
|
|
|
|
+ {
|
|
|
|
+ ret.Success = false;
|
|
|
|
+ ret.ErrorMessage = "指定审核人不存在!";
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var calMonth = Context.CalMonths.FirstOrDefault(f=>f.Status ==0);
|
|
|
|
+
|
|
|
|
+ if(calMonth == null)
|
|
|
|
+ {
|
|
|
|
+ ret.Success = false;
|
|
|
|
+ ret.ErrorMessage = "当前没有正在处理的绩效核算月份!";
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ temObj.ReviewerId = reviewerId;
|
|
|
|
+ temObj.CalMonthId = calMonth.Id;
|
|
|
|
+ Context.SaveChanges();
|
|
|
|
+ t.Commit();
|
|
|
|
+
|
|
|
|
+ #region 邮件通知
|
|
|
|
+ string strSubject = $"{User.Identity.Name}{calMonth.Month}月份专案工作内容";
|
|
|
|
+ string strBody = $"<html><body>{temStaff.Name},您好!<br/></br/> <div>{User.Identity.Name}提交了专案{temObj.ProjectNo} {calMonth.Year}年{calMonth.Month}月工作内容,请在尽快确认完成!</div></body></html>";
|
|
|
|
+ string strTo = temStaff.Mail;
|
|
|
|
+
|
|
|
|
+ _ = QuartzUtil.AddMailJob(strSubject, strBody, temStaff.Name, strTo);
|
|
|
|
+ #endregion
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ ret.Success = false;
|
|
|
|
+ ret.ErrorMessage = "指定项目工作内容Id不存在!";
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ t.Rollback();
|
|
|
|
+ ret.Success = false;
|
|
|
|
+ ret.ErrorMessage = ex.Message;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|