|
@@ -13,6 +13,7 @@ using OASystem.Infrastructure.Repositories.Groups;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Diagnostics.Eventing.Reader;
|
|
|
+using System.Drawing;
|
|
|
using System.Linq.Expressions;
|
|
|
using TencentCloud.Ocr.V20181119.Models;
|
|
|
|
|
@@ -86,6 +87,12 @@ namespace OASystem.API.OAMethodLib
|
|
|
return _result;
|
|
|
}
|
|
|
|
|
|
+ //查询工作日
|
|
|
+ List<Sys_Calendar> sys_Calendars = new List<Sys_Calendar>();
|
|
|
+
|
|
|
+ string sys_sql = string.Format("Select * From Sys_Calendar Where Isdel = 0 And Dt between '{0}' And '{1}'",
|
|
|
+ startDt.ToString("yyyy-MM-dd"), endDt.ToString("yyyy-MM-dd"));
|
|
|
+ sys_Calendars = await _usersRep._sqlSugar.SqlQueryable<Sys_Calendar>(sys_sql).ToListAsync();
|
|
|
|
|
|
//筛选出工作日日报
|
|
|
List<Root> workday_userRoots = checkInDayDataView.datas.Where(it => it.base_info.day_type == 0 && it.base_info.record_type == 1).ToList();
|
|
@@ -149,6 +156,7 @@ namespace OASystem.API.OAMethodLib
|
|
|
List<Ex_Items> ex_Items = new List<Ex_Items>();//假勤 And 打卡备注集合
|
|
|
Ex_Items ex_Items_dk = new Ex_Items() { Type = "打卡" }; //打卡
|
|
|
Ex_Items ex_Items_jq = new Ex_Items() { Type = "假勤" }; //假勤
|
|
|
+ Ex_Items ex_Items_cc = new Ex_Items() { Type = "出差" }; //出差
|
|
|
#endregion
|
|
|
|
|
|
|
|
@@ -430,7 +438,7 @@ namespace OASystem.API.OAMethodLib
|
|
|
foreach (var checkInData in checkInDatas)
|
|
|
{
|
|
|
//当前时间是上午还是下午
|
|
|
- int timeLong = 0;
|
|
|
+ decimal timelength = 0.00M;
|
|
|
string thisTime = string.Format(@"12:00:00");
|
|
|
string wcdkTime = checkInData.checkin_time_dt.ToString("HH:mm:ss");
|
|
|
DateTime wcdkDt = Convert.ToDateTime(wcdkTime);
|
|
@@ -438,14 +446,16 @@ namespace OASystem.API.OAMethodLib
|
|
|
if (Convert.ToDateTime(thisTime) > wcdkDt) //上午
|
|
|
{
|
|
|
DateTime amDt = Convert.ToDateTime("09:00:00");
|
|
|
+ timelength = (decimal)(wcdkDt - amDt).TotalMinutes;
|
|
|
if (wcdkDt <= amDt)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else //下午
|
|
|
{
|
|
|
DateTime pmDt = Convert.ToDateTime("18:00:00");
|
|
|
+ timelength = (decimal)(pmDt - wcdkDt).TotalMinutes;
|
|
|
if (wcdkDt >= pmDt)
|
|
|
{
|
|
|
continue;
|
|
@@ -453,6 +463,72 @@ namespace OASystem.API.OAMethodLib
|
|
|
}
|
|
|
|
|
|
|
|
|
+ decimal day_deduction = 0.00M;
|
|
|
+
|
|
|
+ Ex_Item beLate_belate_ex = new Ex_Item()
|
|
|
+ {
|
|
|
+ SubTypeId = 4,
|
|
|
+ SubType = "旷工",
|
|
|
+ Duration = timelength,
|
|
|
+ StartTimeDt = wcdkDt,
|
|
|
+ Unit = "分钟",
|
|
|
+ Reason = "[外出打卡]"
|
|
|
+ };
|
|
|
+
|
|
|
+ if (timelength >= 1 && timelength < 10)
|
|
|
+ {
|
|
|
+ user_cd_zt_num++;
|
|
|
+ beLate_belate_ex.SubTypeId = 1;
|
|
|
+ beLate_belate_ex.SubType = "迟到/早退";
|
|
|
+ string thisStartDt = wcdkDt.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisStartDt);
|
|
|
+
|
|
|
+ if (user_cd_zt_num >= 3)
|
|
|
+ {
|
|
|
+ day_deduction = 50.00M;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ day_deduction = 0.00M;
|
|
|
+ }
|
|
|
+ beLate_belate_ex.Reason += "迟到/早退";
|
|
|
+ beLate_deduction += day_deduction; //迟到扣款 总额
|
|
|
+ }
|
|
|
+ else if (timelength >= 10 && timelength <= 60)
|
|
|
+ {
|
|
|
+ beLate_belate_ex.SubType = "迟到/早退";
|
|
|
+ string thisStartDt = wcdkDt.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisStartDt);
|
|
|
+
|
|
|
+ day_deduction = 50.00M;
|
|
|
+ beLate_deduction += day_deduction; //迟到扣款 总额
|
|
|
+ beLate_belate_ex.SubTypeId = 1;
|
|
|
+ beLate_belate_ex.Reason += "迟到/早退";
|
|
|
+ }
|
|
|
+ else if (timelength > 60 && timelength <= 180)
|
|
|
+ {
|
|
|
+ day_deduction = ConvertToDecimal(((dailyWage / 7.50M) * 3.00M)); //3小时
|
|
|
+ meal_deduction += 10.00M; //餐补扣款
|
|
|
+ absenteeism_deduction += day_deduction; //矿工半日
|
|
|
+ beLate_belate_ex.Reason += " 迟到/早退(60分钟) 视为旷工上午(3小时)";
|
|
|
+ }
|
|
|
+ else if (timelength > 180 && timelength <= 270)
|
|
|
+ {
|
|
|
+ day_deduction = ConvertToDecimal(((dailyWage / 7.50M) * 4.50M)); //4小时
|
|
|
+ meal_deduction += 10.00M; //餐补扣款
|
|
|
+ absenteeism_deduction += day_deduction; //矿工半日
|
|
|
+ beLate_belate_ex.Reason += " 迟到/早退(60分钟) 视为旷工下午(4.5小时)";
|
|
|
+ }
|
|
|
+ else if(timelength > 270)
|
|
|
+ {
|
|
|
+ day_deduction = ConvertToDecimal(dailyWage);
|
|
|
+ absenteeism_deduction += day_deduction; //矿工一日
|
|
|
+ meal_deduction += 10.00M;
|
|
|
+ beLate_belate_ex.Reason += " 迟到/早退 视为旷工一天(7.5小时)";
|
|
|
+ }
|
|
|
+
|
|
|
+ beLate_belate_ex.Deduction = day_deduction;
|
|
|
+ ex_reissuecard_Items.Add(beLate_belate_ex);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -461,10 +537,14 @@ namespace OASystem.API.OAMethodLib
|
|
|
#region 假勤/补卡次数 审批
|
|
|
|
|
|
int leaveNum = 0; //请假次数
|
|
|
- int reissuecardNum = 0; //补卡次数\
|
|
|
+ int reissuecardNum = 0; //补卡次数
|
|
|
+ int evectionNum = 0; //出差次数
|
|
|
//类型:1 - 请假;2 - 补卡;3 - 出差;4 - 外出;100 - 外勤
|
|
|
leaveNum = acc_sp_items.Where(it => it.type == 1).ToList().Count();
|
|
|
reissuecardNum = acc_sp_items.Where(it => it.type == 2).ToList().Count();
|
|
|
+ List<Sp_items> acc_sp_items_evection = new List<Sp_items>();
|
|
|
+ acc_sp_items_evection = acc_sp_items.Where(it => it.type == 3).ToList();
|
|
|
+ evectionNum = acc_sp_items_evection.Count();
|
|
|
|
|
|
//请假审批
|
|
|
if (leaveNum > 0)
|
|
@@ -686,6 +766,143 @@ namespace OASystem.API.OAMethodLib
|
|
|
ex_Items.Add(ex_Items_dk);
|
|
|
}
|
|
|
|
|
|
+ //出差申请
|
|
|
+ if (evectionNum > 0)
|
|
|
+ {
|
|
|
+ List<Sp_Detail> sp_leave_details = new List<Sp_Detail>();
|
|
|
+ sp_leave_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 3); //时间段内所有 已同意的 出差 审批数据
|
|
|
+ if (sp_leave_details.Count <= 0)
|
|
|
+ {
|
|
|
+ _result.Msg += startDt + " - " + endDt + " " + itemName + " 请假 审批数据获取未获取到!\r\n";
|
|
|
+ //continue;
|
|
|
+ }
|
|
|
+ List<Ex_Item> cc_ex_ItemInfos = new List<Ex_Item>();
|
|
|
+
|
|
|
+ foreach (Sp_Detail sp_item in sp_leave_details)
|
|
|
+ {
|
|
|
+ Apply_data? apply_data = sp_item.apply_data;
|
|
|
+ if (apply_data != null)
|
|
|
+ {
|
|
|
+ List<ContentsItem> contents = apply_data.contents;
|
|
|
+ ContentsItem content_Vacation = contents.Where(it => it.control == "Attendance").FirstOrDefault(); //出差类型
|
|
|
+ ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault(); //多行文本
|
|
|
+
|
|
|
+ if (content_Vacation != null)
|
|
|
+ {
|
|
|
+ //Vacation vacation = content_Vacation.value.vacation;
|
|
|
+ Attendance attendance = content_Vacation.value.attendance; //假勤组件
|
|
|
+ //Selector selector = vacation.selector; //请假类型
|
|
|
+
|
|
|
+ //List<OptionsItem> optionsItems = selector.options; //key 请假类型 id
|
|
|
+ //List<TitleItem> value = optionsItems[0].value; // value 文本描述值
|
|
|
+
|
|
|
+ int leaveType = int.Parse("3"); //key 请假子类型 id
|
|
|
+ Date_range date_Range = attendance.date_range;
|
|
|
+
|
|
|
+ //筛选 不在工作日内的假勤申请
|
|
|
+ if (startDt >= date_Range.new_begin_dt || Convert.ToDateTime(date_Range.new_end_dt.ToString("yyyy-MM-dd")) > endDt)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ string leave_starttime = date_Range.new_begin_dt.ToString("HH:mm");
|
|
|
+ string leave_endtime = date_Range.new_end_dt.ToString("HH:mm");
|
|
|
+
|
|
|
+ string typeName = string.Empty;
|
|
|
+ string unit = string.Empty;
|
|
|
+ int leaveTypeId = leaveType;
|
|
|
+ typeName = "出差";
|
|
|
+
|
|
|
+ string startTime = string.Empty;
|
|
|
+ string endTime = string.Empty;
|
|
|
+ string startTime1 = string.Empty;
|
|
|
+ string endTime1 = string.Empty;
|
|
|
+ //计算请假类型扣款金额
|
|
|
+ decimal new_duration = 0.00M;
|
|
|
+ if (date_Range.type == "halfday")
|
|
|
+ {
|
|
|
+ new_duration = Convert.ToDecimal(date_Range.new_duration) / 86400.00M;
|
|
|
+ unit = "天";
|
|
|
+ startTime = date_Range.new_begin_dt.ToString("yyyy-MM-dd") + " 09:00";
|
|
|
+ endTime = date_Range.new_begin_dt.ToString("yyyy-MM-dd") + " 18:00";
|
|
|
+ startTime1 = "09:00:00";
|
|
|
+ endTime1 = "18:00:00";
|
|
|
+ }
|
|
|
+ else if (date_Range.type == "hour")
|
|
|
+ {
|
|
|
+ new_duration = Convert.ToDecimal(date_Range.new_duration) / 3600.00M;
|
|
|
+ unit = "小时";
|
|
|
+ startTime = date_Range.new_begin_dt.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ endTime = date_Range.new_end_dt.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ startTime1 = date_Range.new_begin_dt.ToString("HH:mm:ss");
|
|
|
+ endTime1 = date_Range.new_end_dt.ToString("HH:mm:ss");
|
|
|
+ }
|
|
|
+
|
|
|
+ //出差扣款
|
|
|
+ decimal cckk = 0.00M;
|
|
|
+
|
|
|
+ int days = (int)(date_Range.new_end_dt - date_Range.new_begin_dt).TotalDays;
|
|
|
+ for (int i = 0; i <= days; i++)
|
|
|
+ {
|
|
|
+ DateTime thisDt = date_Range.new_begin_dt.AddDays(i);
|
|
|
+ if (thisDt > date_Range.new_end_dt)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Sys_Calendar sys_Calendar = new Sys_Calendar();
|
|
|
+ sys_Calendar = sys_Calendars.Where(it => it.Dt == thisDt.ToString("yyyy-MM-dd")).FirstOrDefault();
|
|
|
+ if (sys_Calendar != null) {
|
|
|
+ if (sys_Calendar.IsWorkDay)
|
|
|
+ {
|
|
|
+ cckk += 10.00M;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ meal_deduction += cckk;
|
|
|
+
|
|
|
+
|
|
|
+ Ex_Item ex_Item = new Ex_Item()
|
|
|
+ {
|
|
|
+ SubTypeId = leaveType,
|
|
|
+ SubType = typeName,
|
|
|
+ StartTimeDt = Convert.ToDateTime(date_Range.new_begin_dt.ToString("yyyy-MM-dd") + " " + startTime1),
|
|
|
+ EndTimeDt = Convert.ToDateTime(date_Range.new_end_dt.ToString("yyyy-MM-dd") + " " + endTime1),
|
|
|
+ Duration = new_duration,
|
|
|
+ Unit = unit,
|
|
|
+ Deduction = 0.00M,
|
|
|
+ //Reason = apply_data.reason,
|
|
|
+ Apply_time_dt = Convert.ToDateTime(sp_item.apply_time_dt.ToString("yyyy-MM-dd HH:mm:ss"))
|
|
|
+ //Approval_name = sp_item.approval_name,
|
|
|
+ };
|
|
|
+
|
|
|
+ cc_ex_ItemInfos.Add(ex_Item);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cc_ex_ItemInfos.Count > 0)
|
|
|
+ {
|
|
|
+ //ex_Items_cc.Ex_ItemInfo = cc_ex_ItemInfos.OrderBy(it => it.StartTimeDt).ThenBy(it => it.Apply_time_dt).ToList();
|
|
|
+ //ex_Items.Add(ex_Items_cc);
|
|
|
+ List<Ex_Item> ex_jq_Items = new List<Ex_Item>();
|
|
|
+ ex_jq_Items = (List<Ex_Item>)ex_Items_jq.Ex_ItemInfo;
|
|
|
+ ex_jq_Items.AddRange(cc_ex_ItemInfos);
|
|
|
+ ex_Items.Remove(ex_Items_jq);
|
|
|
+ ex_Items.Add(
|
|
|
+ new Ex_Items()
|
|
|
+ {
|
|
|
+ Type = "假勤",
|
|
|
+ Ex_ItemInfo = ex_jq_Items.OrderBy(it => it.StartTimeDt).ThenBy(it => it.Apply_time_dt).ToList()
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
@@ -741,10 +958,10 @@ namespace OASystem.API.OAMethodLib
|
|
|
pm_wsInfo.Ex_ItemsRemark = JsonConvert.SerializeObject(ex_Items); //
|
|
|
pm_wsInfo.Mealsupplement = mealTotal; //餐补
|
|
|
|
|
|
- pm_wsInfo.Should = salaryTotal; //应发合计
|
|
|
- pm_wsInfo.TotalDeductions = eductionTotal; //扣款合计
|
|
|
- pm_wsInfo.TotalRealHair = actualReleaseTotal - pm_wsInfo.WithholdingTax; //实发合计
|
|
|
- pm_wsInfo.AfterTax = actualReleaseTotal - pm_wsInfo.WithholdingTax; //税后工资
|
|
|
+ pm_wsInfo.Should = ConvertToDecimal( salaryTotal); //应发合计
|
|
|
+ pm_wsInfo.TotalDeductions = ConvertToDecimal(eductionTotal); //扣款合计
|
|
|
+ pm_wsInfo.TotalRealHair = ConvertToDecimal(actualReleaseTotal - pm_wsInfo.WithholdingTax); //实发合计
|
|
|
+ pm_wsInfo.AfterTax = ConvertToDecimal(actualReleaseTotal - pm_wsInfo.WithholdingTax); //税后工资
|
|
|
|
|
|
pm_wsInfo.LastUpdateUserId = userId;
|
|
|
pm_wsInfo.LastUpdateDt = DateTime.Now;
|