|
@@ -108,7 +108,6 @@ namespace OASystem.API.Controllers
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> GetWageSheetMonthWorkdaysAddOrEdit(WageSheetMonthWorkdaysAddOrEditDto dto)
|
|
|
{
|
|
|
-
|
|
|
//参数处理
|
|
|
string yearFormat = "yyyy-MM";
|
|
|
string dtFormat = "yyyy-MM-dd";
|
|
@@ -127,6 +126,11 @@ namespace OASystem.API.Controllers
|
|
|
pm_WageIssueWorkingDay1 = _mapper.Map<Pm_WageIssueWorkingDay>(dto);
|
|
|
List<Sys_Calendar> sys_Calendars = new List<Sys_Calendar>();
|
|
|
sys_Calendars = _mapper.Map<List<Sys_Calendar>>(dto.CalendarInfos);
|
|
|
+ if (sys_Calendars.Count > 0)
|
|
|
+ {
|
|
|
+ sys_Calendars = sys_Calendars.OrderBy(it => it.Dt).ToList();
|
|
|
+ }
|
|
|
+
|
|
|
pm_WageIssueWorkingDay1.Workdays = sys_Calendars.Where(it => it.IsWorkDay == true).ToList().Count();
|
|
|
foreach (var item in sys_Calendars)
|
|
|
{
|
|
@@ -142,13 +146,50 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
try
|
|
|
{
|
|
|
+ List<Sys_Calendar> sys_Calendars_add = new List<Sys_Calendar>();
|
|
|
+ List<Sys_Calendar> sys_Calendars_update = new List<Sys_Calendar>();
|
|
|
+ sys_Calendars_add = sys_Calendars.Where(it => it.Id == 0).OrderBy(it => it.Dt).ToList();
|
|
|
+ sys_Calendars_update = sys_Calendars.Where(it => it.Id != 0).OrderBy(it => it.Dt).ToList();
|
|
|
+
|
|
|
+ int add1 = 0;
|
|
|
+ int upd = 0;
|
|
|
+ if (sys_Calendars_add.Count > 0)
|
|
|
+ {
|
|
|
+ var calendarsAdd = await _sqlSugar.Insertable(sys_Calendars_add).ExecuteReturnIdentityAsync();
|
|
|
+
|
|
|
+ if (calendarsAdd < 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, "工作日/节假日/休息日添加失败!"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sys_Calendars_update.Count > 0)
|
|
|
+ {
|
|
|
+ var calendarsUpdate = await _sqlSugar.Updateable<Sys_Calendar>(sys_Calendars)
|
|
|
+ .UpdateColumns(it => new { it.Dt, it.IsWorkDay, it.IsHoliDay, it.HoliName })
|
|
|
+ .WhereColumns(it => it.Id)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+ if (calendarsUpdate < 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, "工作日/节假日/休息日编辑失败!"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var calendarsDatas = await _sqlSugar.Queryable<Sys_Calendar>()
|
|
|
+ .Where(it => Convert.ToDateTime(it.Dt) >= Convert.ToDateTime(dto.StartDate) && Convert.ToDateTime(it.Dt) <= Convert.ToDateTime(dto.EndDate)).ToListAsync();
|
|
|
+ if (calendarsDatas.Count < 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, "日期包暂无工作日/节假日/休息日的信息!"));
|
|
|
+ }
|
|
|
//月份表是否存在
|
|
|
Pm_WageIssueWorkingDay pm_WageIssueWorkingDay = new Pm_WageIssueWorkingDay()
|
|
|
{
|
|
|
YearMonth = dto.YearMonth,
|
|
|
StartDate = dto.StartDate,
|
|
|
EndDate = dto.EndDate,
|
|
|
- Workdays = dto.CalendarInfos.Where(it => it.IsWorkDay == true).ToList().Count()
|
|
|
+ Workdays = calendarsDatas.Where(it => it.IsWorkDay == true).ToList().Count()
|
|
|
};
|
|
|
|
|
|
string sql = string.Format("Select * From Pm_WageIssueWorkingDay Where Isdel = 0 And YearMonth='{0}'", dto.YearMonth);
|
|
@@ -159,8 +200,12 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
if (workdsys == null) //添加
|
|
|
{
|
|
|
-
|
|
|
int addId = await _sqlSugar.Insertable(pm_WageIssueWorkingDay).ExecuteReturnIdentityAsync();
|
|
|
+ if (addId < 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, "工作日设置添加失败!"));
|
|
|
+ }
|
|
|
}
|
|
|
else //更新
|
|
|
{
|
|
@@ -168,25 +213,11 @@ namespace OASystem.API.Controllers
|
|
|
.IgnoreColumns(z => new { z.CreateUserId, z.CreateTime, z.DeleteUserId, z.DeleteTime, z.IsDel })
|
|
|
.WhereColumns(it => it.YearMonth)
|
|
|
.ExecuteCommandAsync();
|
|
|
- }
|
|
|
-
|
|
|
- List<Sys_Calendar> sys_Calendars_add = new List<Sys_Calendar>();
|
|
|
- List<Sys_Calendar> sys_Calendars_update = new List<Sys_Calendar>();
|
|
|
- sys_Calendars_add = sys_Calendars.Where(it => it.Id == 0).OrderBy(it => it.Dt).ToList();
|
|
|
- sys_Calendars_update = sys_Calendars.Where(it => it.Id != 0).OrderBy(it => it.Dt).ToList();
|
|
|
-
|
|
|
- int add1 = 0;
|
|
|
- int upd = 0;
|
|
|
- if (sys_Calendars_add.Count > 0)
|
|
|
- {
|
|
|
- await _sqlSugar.Insertable(sys_Calendars_add).ExecuteReturnIdentityAsync();
|
|
|
- }
|
|
|
- if (sys_Calendars_update.Count > 0)
|
|
|
- {
|
|
|
- await _sqlSugar.Updateable<Sys_Calendar>(sys_Calendars)
|
|
|
- .UpdateColumns(it => new { it.Dt, it.IsWorkDay, it.IsHoliDay, it.HoliName })
|
|
|
- .WhereColumns(it => it.Id)
|
|
|
- .ExecuteCommandAsync();
|
|
|
+ if (updCount < 0)
|
|
|
+ {
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ return Ok(JsonView(false, "工作日设置编辑失败!"));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
_sqlSugar.CommitTran();
|