123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265 |
- using Google.Protobuf.WellKnownTypes;
- using NPOI.HPSF;
- using NPOI.OpenXmlFormats.Dml.Diagram;
- using NPOI.OpenXmlFormats.Spreadsheet;
- using NPOI.SS.Formula.Functions;
- using NPOI.Util;
- using OASystem.API.OAMethodLib.QiYeWeChatAPI;
- using OASystem.Domain;
- using OASystem.Domain.Entities.PersonnelModule;
- using OASystem.Domain.ViewModels.PersonnelModule;
- using OASystem.Domain.ViewModels.QiYeWeChat;
- 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;
- namespace OASystem.API.OAMethodLib
- {
-
-
-
- public static class PayrollComputation
- {
- private static Result _result = new Result();
- private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
- private static readonly UsersRepository _usersRep = AutofacIocManager.Instance.GetService<UsersRepository>();
- private static readonly IMapper _mapper = AutofacIocManager.Instance.GetService<IMapper>();
- private static readonly decimal _chengDuMinimumWage = 2100.00M * 0.80M;
-
-
-
-
-
-
-
-
-
- public static async Task<Result> SalaryCalculatorAsync(
- List<Pm_WageSheet> pm_WageSheetDattaSources, List<UserNameView> userNames, int userId, string thisYearMonth, DateTime startDt, DateTime endDt)
- {
- if (pm_WageSheetDattaSources.Count <= 0)
- {
- _result.Msg = "计算工资传入数据为空!";
- return _result;
- }
- if (userNames.Count <= 0)
- {
- var nameData = await _usersRep.GetUserNameList(1);
- userNames = nameData.Data;
- }
-
- int work_days = await GetWorkDays(thisYearMonth);
- if (work_days <=0)
- {
- _result.Msg = thisYearMonth+" 工作日未设置,请前往《工作日管理页面》设置!";
- return _result;
- }
- UserIdListView userIdListView = await _qiYeWeChatApiService.GetUserIdListAsync();
- if (userIdListView.errcode != 0)
- {
- _result.Msg = "【企业微信】【打卡】【获取员工ID】【Msg】" + userIdListView.errmsg;
- return _result;
- }
- List<string> qyWhchatIdList = new List<string>();
- qyWhchatIdList = userIdListView.dept_user.Select(it => it.userid).ToList();
- CheckInDayDataView checkInDayDataView = await _qiYeWeChatApiService.GetCheckInDayDataAsync(qyWhchatIdList, startDt, endDt);
- if (checkInDayDataView.errcode != 0)
- {
- _result.Msg = "【企业微信】【打卡】【获取时间段内所有日打卡】【Msg】" + checkInDayDataView.errmsg;
- return _result;
- }
-
- CheckInDataView checkInDataView = new CheckInDataView();
- checkInDataView = await _qiYeWeChatApiService.GetCheckinDataAsync(qyWhchatIdList, 3,startDt, endDt);
- if (checkInDataView.errcode != 0)
- {
- _result.Msg = "【企业微信】【打卡】【获取时间段内所有日打卡记录】【Msg】" + checkInDataView.errmsg;
- 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();
-
- workday_userRoots = workday_userRoots.OrderBy(it => it.base_info.date).ToList();
-
- string leave_template_id = "C4NzTJCh1onCUK915rRkvy7Fh5Vqz4YbiEV9jrBY1";
- List<VacationLeaveTypeView> vacationLeaveTypes = await GetVacationLeaveTypes(leave_template_id);
- if (vacationLeaveTypes.Count <= 0)
- {
- _result.Msg = "【企业微信】【审批】【获取审批类型】【Msg】" + startDt + " - " + endDt + "请假 类型数据 获取失败!";
- return _result;
- }
- string name = "";
- try
- {
- foreach (var pm_wsInfo in pm_WageSheetDattaSources)
- {
- string itemName = userNames.Where(it => it.Id == pm_wsInfo.UserId).FirstOrDefault().CnName;
- name = itemName;
-
- decimal meal_subsidy = 0.00M;
-
- decimal personalLeaveTotal = 0.00M,
- sickLeaveTotal = 0.00M;
-
- decimal beLate_deduction = 0.00M,
-
-
-
- early_deduction = 0.00M,
- absenteeism_deduction = 0.00M,
- unprinted_deduction = 0.00M,
-
-
- sickLeave_deduction = 0.00M,
- other_deduction = 0.00M;
- decimal meal_deduction = 0.00M;
- decimal reissuecard_deduction = 0.00M;
- #region 计算日工资 正常日薪 事假日薪 病假日薪
-
- decimal amountPayable = pm_wsInfo.Basic + pm_wsInfo.Floats + pm_wsInfo.PostAllowance + pm_wsInfo.InformationSecurityFee +
- pm_wsInfo.OtherSubsidies;
-
- decimal dailyWage = amountPayable / work_days;
-
- decimal sickLeave_dailywage = _chengDuMinimumWage / work_days;
-
- sickLeave_deduction = dailyWage - sickLeave_dailywage;
- List<Ex_Items> ex_Items = new List<Ex_Items>();
- 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
- List<Root> userRoots = new List<Root>();
- if (itemName == "蔡雯")
- {
- userRoots = workday_userRoots.Where(it => it.base_info.name == "蔡蔡" || it.base_info.name == "蔡雯").ToList();
- }
- else
- {
- userRoots = workday_userRoots.Where(it => it.base_info.name == itemName).ToList();
- }
-
- userRoots = userRoots.OrderBy(it => it.base_info.date).ToList();
- int dk_work_days = userRoots.Count;
- if (dk_work_days > work_days)
- {
- dk_work_days = work_days;
- }
- meal_subsidy = dk_work_days * 10;
- if (!itemName.Equals("张海麟"))
- {
- if (userRoots.Count <= 0)
- {
- _result.Msg = "【企业微信】【打卡】【获取打卡数据】【Msg】" + startDt + " - " + endDt + "打卡日数据 获取失败!";
- continue;
- }
- string acctid = userRoots[0].base_info.acctid;
- List<Ex_Item> ex_reissuecard_Items = new List<Ex_Item>();
- List<Sp_items> acc_sp_items = new List<Sp_items>();
- int user_probationary_bk_num = 0;
-
- decimal user_probationary_bk_decimal = pm_wsInfo.Floats;
-
- List<CheckInDataInfo> checkInData1 = new List<CheckInDataInfo>();
- checkInData1 = checkInDataView.checkindata;
- List<CheckInDataInfo> checkInDatas = new List<CheckInDataInfo>();
- checkInDatas = checkInData1.Where(it => it.userid == acctid).ToList();
-
- List<CheckInDataInfo> checkInData2 = new List<CheckInDataInfo>();
- checkInData2 = checkInDatas.Where(it => it.exception_type.Equals("未打卡")).ToList();
-
- List<CheckInDataInfo> checkInData_outPunch = new List<CheckInDataInfo>();
- checkInData_outPunch = checkInDatas.Where(it => it.checkin_type.Equals("外出打卡")).ToList();
- #region 迟到 早退 旷工
- int user_cd_zt_num = 0;
- foreach (var root in userRoots)
- {
- List<Holiday_infos> holiday_Infos = root.holiday_infos;
- List<Exception_infos> exception_infos = root.exception_infos;
- List<Sp_items> sp_Items = root.sp_items;
- if (sp_Items.Count > 0)
- {
- sp_Items = sp_Items.Where(it => it.count > 0).ToList();
- acc_sp_items.AddRange(sp_Items);
- }
- foreach (var exception_info in exception_infos)
- {
- decimal timelength = ConvertToDecimal((Convert.ToDecimal(exception_info.duration) / 3600.00M) * 60.00M);
- if (timelength == 9) timelength = 7.50M;
- int exception = exception_info.exception;
- decimal day_miner_unit = dailyWage / 15;
-
-
-
- long date = root.base_info.date;
- long earliest_time = root.summary_info.earliest_time;
- long lastest_time = root.summary_info.lastest_time;
- long this_date = date + earliest_time;
- DateTime thisDt = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddTicks(this_date * 10000000);
- string thisDtStr = thisDt.ToString("yyyy-MM-dd");
- Ex_Item beLate_belate_ex = new Ex_Item()
- {
- SubTypeId = 4,
- SubType = "旷工",
- Duration = timelength,
- StartTimeDt = Convert.ToDateTime(root.base_info.dateDt.ToString("yyyy-MM-dd HH:mm:ss")),
- Unit = "分钟",
- };
- decimal day_deduction = 0.00M;
-
- if (exception == 1)
- {
- if (timelength < 10)
- {
- user_cd_zt_num++;
- beLate_belate_ex.SubTypeId = 1;
- beLate_belate_ex.SubType = "迟到";
- string thisStartDt = (TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddTicks((date + earliest_time) * 10000000))
- .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_deduction += day_deduction;
- }
- else if (timelength >= 10 && timelength < 60)
- {
- string thisStartDt = (TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))
- .AddTicks((date + earliest_time) * 10000000))
- .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.SubType = "迟到";
- }
- else if (timelength >= 60 && timelength <= 180)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)缺卡/未打卡视为旷工半天";
- }
- else
- {
- day_deduction = ConvertToDecimal(dailyWage);
- absenteeism_deduction += day_deduction;
- meal_deduction += 10.00M;
- beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
- }
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- else if (exception == 2)
- {
- if (timelength < 10)
- {
- user_cd_zt_num++;
- beLate_belate_ex.SubTypeId = 2;
- beLate_belate_ex.SubType = "早退";
- string thisEndDt = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))
- .AddTicks((date + lastest_time) * 10000000)
- .ToString("yyyy-MM-dd HH:mm:ss");
- beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisEndDt);
- if (user_cd_zt_num >= 3)
- {
- day_deduction = 50.00M;
- }
- else
- {
- day_deduction = 0.00M;
- }
- early_deduction += day_deduction;
- }
- else if (timelength >= 10 && timelength < 60)
- {
- day_deduction = 50.00M;
- early_deduction += day_deduction;
- beLate_belate_ex.SubTypeId = 2;
- beLate_belate_ex.SubType = "早退";
- string thisEndDt = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))
- .AddTicks((date + lastest_time) * 10000000)
- .ToString("yyyy-MM-dd HH:mm:ss");
- beLate_belate_ex.StartTimeDt = Convert.ToDateTime(thisEndDt);
- }
- else if (timelength >= 60 && timelength <= 180)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- }
- else
- {
- day_deduction = ConvertToDecimal(dailyWage);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- }
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- else if (exception == 3)
- {
- if (root.exception_infos.Count == 2)
- {
- if (ex_reissuecard_Items.Where(it => it.StartTimeDt.ToString("yyyy-MM-dd").Equals(thisDtStr)).Count() > 0)
- {
- if (earliest_time == lastest_time)
- {
- DateTime thisDt1 = Convert.ToDateTime(thisDtStr + " 12:00");
- if (thisDt >= thisDt1)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- meal_deduction += 10.00M;
- beLate_belate_ex.Duration = 270;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Reason = thisDtStr + " 下午(18:00)缺卡/未打卡视为旷工半天";
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- else if (thisDt <= thisDt1)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Duration = 180;
- beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)缺卡/未打卡视为旷工半天";
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- else
- {
- day_deduction = ConvertToDecimal(dailyWage);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- }
- }
- else
- {
- day_deduction = dailyWage;
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Reason = "上午-下午 缺卡/未打卡为旷工一天";
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- }
- else if (root.exception_infos.Count == 1)
- {
- if (earliest_time == lastest_time)
- {
- DateTime thisDt1 = Convert.ToDateTime(thisDtStr + " 12:00");
- if (thisDt <= thisDt1)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- meal_deduction += 10.00M;
- beLate_belate_ex.Duration = 270;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Reason = thisDtStr + " 下午(18:00)缺卡/未打卡视为下午旷工(4.5小时)";
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- else if (thisDt >= thisDt1)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Duration = 180;
- beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)缺卡/未打卡视为上午旷工(3小时)";
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- else
- {
- day_deduction = ConvertToDecimal(dailyWage);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- }
- }
- }
- else if (exception == 4)
- {
- if (timelength >= 60 && timelength <= 180)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- beLate_belate_ex.Reason = thisDtStr + " 缺卡/未打视为旷工半天";
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- }
- else if (timelength > 180 && timelength <= 270)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- beLate_belate_ex.Reason = thisDtStr + " 缺卡/未打视为旷工半天";
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- }
- else
- {
- day_deduction = ConvertToDecimal(dailyWage);
- beLate_belate_ex.Reason = thisDtStr + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- }
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- }
- }
- #endregion
- #region 外出打卡 迟到 早退 旷工
- if (checkInData_outPunch.Count > 0)
- {
- List<Sp_Detail> sp_gooutpunch_details = new List<Sp_Detail>();
- sp_gooutpunch_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 4);
- if (sp_gooutpunch_details.Count <= 0)
- {
- _result.Msg += startDt + " - " + endDt + " " + itemName + " 外出打卡 审批数据获取未获取到!\r\n";
- }
- List<LeaveDetails> goOutPunchDetails = new List<LeaveDetails>();
- foreach (Sp_Detail sp_item in sp_gooutpunch_details)
- {
- Apply_data? apply_data = sp_item.apply_data;
- if (apply_data != null)
- {
- List<ContentsItem> contents = apply_data.contents;
- ContentsItem content_Attendance = contents.Where(it => it.control == "Attendance").FirstOrDefault();
- ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault();
- if (content_Attendance != null)
- {
- Attendance attendance = content_Attendance.value.attendance;
- string goOutText = string.Empty;
- if (content_Textarea!=null)
- {
- goOutText = content_Textarea.value.text;
- }
- Date_range date_Range = attendance.date_range;
-
- if (Convert.ToDateTime(date_Range.new_begin_dt) < startDt || Convert.ToDateTime(date_Range.new_end_dt.ToString("yyyy-MM-dd")) > endDt)
- {
- continue;
- }
- LeaveDetails leaveDetails1 = new LeaveDetails()
- {
- TypeId = 0,
- TypeName = "外出打卡",
- StartDt = date_Range.new_begin_dt,
- EndDt = date_Range.new_end_dt,
- DtType = date_Range.type,
- New_Duration = date_Range.new_duration
- };
- goOutPunchDetails.Add(leaveDetails1);
- }
- }
- }
- foreach (var goOutPunchItem in goOutPunchDetails)
- {
- string thisDay = goOutPunchItem.StartDt.ToString("yyyy-MM-dd");
- TimeSpan sp_gooutpunchStartTime = goOutPunchItem.StartDt.TimeOfDay;
- TimeSpan sp_gooutpunchEndTime = goOutPunchItem.EndDt.TimeOfDay;
- List<CheckInDataInfo> goOut_checkInDataInfos = checkInData_outPunch.Where(it => it.checkin_time_dt.ToString("yyyy-MM-dd").Equals(thisDay)).ToList();
-
- if (goOut_checkInDataInfos.Count > 1)
- {
- DateTime gooutStartDt = goOut_checkInDataInfos[0].checkin_time_dt;
- DateTime gooutendDt = goOut_checkInDataInfos[goOut_checkInDataInfos.Count-1].checkin_time_dt;
- Ex_Item beLate_belate_ex = new Ex_Item()
- {
- SubTypeId = 4,
- SubType = "旷工",
- Duration = 0,
- StartTimeDt = Convert.ToDateTime(thisDay),
- Unit = "分钟",
- Reason ="数据来源【外出打卡】"
- };
- decimal day_deduction = 0.00M;
-
- if (gooutStartDt.TimeOfDay > sp_gooutpunchStartTime)
- {
- int timeLong = gooutStartDt.Subtract(goOutPunchItem.StartDt).Minutes;
- beLate_belate_ex.Duration = timeLong;
- if (timeLong > 0 && timeLong < 10)
- {
- user_cd_zt_num++;
- beLate_belate_ex.SubTypeId = 1;
- beLate_belate_ex.SubType = "迟到";
- if (user_cd_zt_num >= 3)
- {
- day_deduction = 50.00M;
- }
- else
- {
- day_deduction = 0.00M;
- }
- beLate_deduction += day_deduction;
- }
- else if (timeLong >= 10 && timeLong < 60)
- {
- day_deduction = 50.00M;
- beLate_deduction += day_deduction;
- beLate_belate_ex.SubTypeId = 1;
- beLate_belate_ex.SubType = "迟到";
- }
- else if (timeLong >= 60 && timeLong <= 180)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Reason = "数据来源【外出打卡】" + thisDay + " 上午(09:00)缺卡/未打卡视为旷工半天";
- }
- else
- {
- day_deduction = ConvertToDecimal(dailyWage);
- absenteeism_deduction += day_deduction;
- meal_deduction += 10.00M;
- beLate_belate_ex.Reason = "数据来源【外出打卡】" +thisDay + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
- }
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
-
- if (gooutendDt.TimeOfDay < sp_gooutpunchEndTime)
- {
- int timeLong = goOutPunchItem.EndDt.Subtract(gooutendDt).Minutes;
- beLate_belate_ex.Duration = timeLong;
- if (timeLong > 0 && timeLong < 10)
- {
- user_cd_zt_num++;
- beLate_belate_ex.SubTypeId = 1;
- beLate_belate_ex.SubType = "早退";
- if (user_cd_zt_num >= 3)
- {
- day_deduction = 50.00M;
- }
- else
- {
- day_deduction = 0.00M;
- }
- beLate_deduction += day_deduction;
- }
- else if (timeLong >= 10 && timeLong < 60)
- {
- day_deduction = 50.00M;
- beLate_deduction += day_deduction;
- beLate_belate_ex.SubTypeId = 1;
- beLate_belate_ex.SubType = "早退";
- }
- else if (timeLong >= 60 && timeLong <= 180)
- {
- day_deduction = ConvertToDecimal(dailyWage / 2);
- meal_deduction += 10.00M;
- absenteeism_deduction += day_deduction;
- beLate_belate_ex.Reason = "数据来源【外出打卡】" + thisDay + " 上午(09:00)缺卡/未打卡视为旷工半天";
- }
- else
- {
- day_deduction = ConvertToDecimal(dailyWage);
- absenteeism_deduction += day_deduction;
- meal_deduction += 10.00M;
- beLate_belate_ex.Reason = "数据来源【外出打卡】" + thisDay + " 上午(09:00)-下午(18:00) 缺卡/未打视为旷工一天(7.5小时)";
- }
- beLate_belate_ex.Deduction = day_deduction;
- ex_reissuecard_Items.Add(beLate_belate_ex);
- }
- }
-
- }
- }
- #endregion
- #region 迟到早团旷工 日期排序
- if (ex_reissuecard_Items.Count > 0)
- {
- ex_reissuecard_Items = ex_reissuecard_Items.OrderBy(it => it.StartTimeDt).ToList();
- }
- #endregion
- #region 假勤/补卡次数 审批
- int leaveNum = 0;
- int reissuecardNum = 0;
- int evectionNum = 0;
-
- 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)
- {
- List<Sp_Detail> sp_leave_details = new List<Sp_Detail>();
- sp_leave_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 1);
- if (sp_leave_details.Count <= 0)
- {
- _result.Msg += startDt + " - " + endDt + " " + itemName + " 请假 审批数据获取未获取到!\r\n";
-
- }
- List<Ex_Item> ex_ItemInfos = new List<Ex_Item>();
- List<LeaveDetails> leaveDetails = new List<LeaveDetails>();
- 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 == "Vacation").FirstOrDefault();
- ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault();
- if (content_Vacation != null)
- {
- Vacation vacation = content_Vacation.value.vacation;
- Attendance attendance = vacation.attendance;
- Selector selector = vacation.selector;
- List<OptionsItem> optionsItems = selector.options;
- List<TitleItem> value = optionsItems[0].value;
- int leaveType = int.Parse(optionsItems[0].key);
- Date_range date_Range = attendance.date_range;
-
- if ( Convert.ToDateTime(date_Range.new_begin_dt) < startDt || 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;
- var leaveTypeData = vacationLeaveTypes.Where(it => it.id == leaveTypeId).FirstOrDefault();
- if (leaveTypeData != null) { typeName = leaveTypeData.name; }
- string startTime = string.Empty;
- string endTime = string.Empty;
- string startTime1 = string.Empty;
- string endTime1 = string.Empty;
- Slice_info slice_info = new Slice_info();
-
- if (leaveTypeId == 2 || leaveTypeId ==3)
- {
- slice_info = vacation.attendance.slice_info;
- }
- DateTime date_Range_new_begin_dt = date_Range.new_begin_dt;
- DateTime date_Range_new_end_dt = date_Range.new_end_dt;
-
- 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_end_dt.ToString("yyyy-MM-dd") + " 18:00";
- if (new_duration >= 0.50M)
- {
- if (slice_info != null)
- {
- if (slice_info.day_items != null)
- {
- if (slice_info.day_items.Count > 1)
- {
- date_Range_new_begin_dt = slice_info.day_items[0].daytimeDt;
- date_Range_new_end_dt = slice_info.day_items[slice_info.day_items.Count - 1].daytimeDt;
- decimal startTime11 = slice_info.day_items[0].duration;
- decimal startTime11_11 = startTime11 / 3600.00M;
- decimal endTime11 = slice_info.day_items[slice_info.day_items.Count - 1].duration;
- decimal endTime11_11 = endTime11 / 3600.00M;
- if (startTime11_11 == 3.00M)
- {
- startTime1 = "09:00";
- }
- else if (startTime11_11 == 4.50M)
- {
- startTime1 = "12:00";
- }
- else if (startTime11_11 == 7.50M)
- {
- startTime1 = "09:00";
- }
- if (endTime11_11 == 3.00M)
- {
- endTime1 = "12:00";
- }
- else if (endTime11_11 == 4.50M)
- {
- endTime1 = "18:00";
- }
- else if (endTime11_11 == 7.50M)
- {
- endTime1 = "18:00";
- }
- }
- else
- {
- decimal qjLongTime = slice_info.duration / 3600.00M;
- if (qjLongTime == 4.50M)
- {
- startTime1 = "12:00";
- endTime1 = "18:00:00";
- }
- else if (qjLongTime == 3.00M)
- {
- startTime1 = "09:00";
- endTime1 = "12:00:00";
- }
- else if (qjLongTime % 7.50M == 0)
- {
- startTime1 = "09:00";
- endTime1 = "18:00:00";
- }
- }
- }
- else
- {
- if (new_duration % 1 == 0)
- {
- startTime1 = "09:00";
- endTime1 = "18:00";
- }
- }
- }
- else
- {
- if (new_duration % 1 == 0)
- {
- startTime1 = "09:00";
- endTime1 = "18:00";
- }
- }
-
- }
- else
- {
- if (new_duration % 1 == 0)
- {
- startTime1 = "09:00";
- endTime1 = "18:00";
- }
- else
- {
- startTime1 = date_Range_new_begin_dt.ToString("HH:mm:ss");
- endTime1 = date_Range_new_end_dt.ToString("HH:mm:ss");
- }
- }
- }
- 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");
- }
- LeaveDetails leaveDetails1 = new LeaveDetails()
- {
- TypeId = leaveType,
- TypeName = typeName,
- StartDt = Convert.ToDateTime(date_Range_new_begin_dt.ToString("yyyy-MM-dd") + " " + startTime1),
- EndDt = Convert.ToDateTime(date_Range_new_end_dt.ToString("yyyy-MM-dd") + " " + endTime1),
- DtType = date_Range.type,
- Unit = unit,
- New_Duration = new_duration,
- SliceInfo = slice_info
- };
- leaveDetails.Add(leaveDetails1);
- }
- }
- }
- #region 年假测试数据
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
- if (leaveDetails.Count > 0)
- {
- leaveDetails = leaveDetails.OrderBy(it => it.StartDt).OrderBy(it => it.EndDt).ToList();
- foreach (LeaveDetails leave_item in leaveDetails)
- {
- decimal leave_meals = 0.00M;
- decimal thisTypeDeduction = 0.00M;
- int leaveType = leave_item.TypeId;
- decimal new_duration = leave_item.New_Duration;
-
- CalculateTypeFee1(leaveDetails,leaveType, leave_item.DtType, leave_item.StartDt, leave_item.EndDt, amountPayable, work_days,
- new_duration,out leave_meals, out thisTypeDeduction);
- if (leave_meals != 0)
- {
- leave_item.IsDeduction = true;
- }
- #region 累计类型扣款
-
- if (leaveType == 2)
- {
- personalLeaveTotal += thisTypeDeduction;
- }
- else if (leaveType == 3)
- {
- sickLeaveTotal += thisTypeDeduction;
- }
- #endregion
- meal_deduction += leave_meals;
- Ex_Item ex_Item = new Ex_Item()
- {
- SubTypeId = leaveType,
- SubType = leave_item.TypeName,
- StartTimeDt = leave_item.StartDt,
- EndTimeDt = leave_item.EndDt,
- Duration = new_duration,
- Unit = leave_item.Unit,
- Deduction = thisTypeDeduction,
-
- Apply_time_dt = leave_item.ApplyDt,
-
- };
- ex_ItemInfos.Add(ex_Item);
- }
- }
- if (ex_ItemInfos.Count > 0)
- {
- ex_Items_jq.Ex_ItemInfo = ex_ItemInfos.OrderBy(it => it.StartTimeDt).ThenBy(it => it.Apply_time_dt).ToList();
- ex_Items.Add(ex_Items_jq);
- }
- }
-
-
-
-
- if (reissuecardNum > 0)
- {
- List<Sp_Detail> sp_buka_details = new List<Sp_Detail>();
- sp_buka_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 2);
-
- List<Sp_Detail> sp_goout_details = new List<Sp_Detail>();
- sp_goout_details = await _qiYeWeChatApiService.GetApprovalDetailsAsync(startDt, endDt, acctid, 2, 4);
-
- List<CheckInDataInfo> filtratePrefix_checkInData = new List<CheckInDataInfo>();
-
- if (sp_goout_details.Count > 0)
- {
-
- List<string> goOutDts = new List<string>();
- foreach (var goOutItem in sp_goout_details)
- {
- Apply_data? apply_data = goOutItem.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)
- {
- var attendance = content_Vacation.value.attendance;
- DateTime goOutDt = attendance.date_range.new_begin_dt;
- DateTime goOutDtJudge = Convert.ToDateTime(goOutDt.ToString("yyyy-MM-dd"));
-
- if (startDt >= goOutDtJudge || goOutDtJudge > endDt)
- {
- continue;
- }
- goOutDts.Add(goOutDt.ToString("yyyy-MM-dd"));
- }
- }
- }
- if (goOutDts.Count > 0)
- {
- foreach (var goOutDtItem in goOutDts)
- {
- List<CheckInDataInfo> filtrate_checkInData = new List<CheckInDataInfo>();
- filtrate_checkInData = checkInData2.Where(it => it.checkin_time_dt.ToString("yyyy-MM-dd").Equals(goOutDtItem)).ToList();
- if (filtrate_checkInData.Count > 0)
- {
- filtratePrefix_checkInData.AddRange(filtrate_checkInData);
- }
- }
- }
- }
- int bukaNum = 1;
- foreach (var item in sp_buka_details)
- {
- Apply_data? apply_data = item.apply_data;
- if (apply_data != null)
- {
- List<ContentsItem> contents = apply_data.contents;
- ContentsItem content_Vacation = contents.Where(it => it.control == "PunchCorrection").FirstOrDefault();
- ContentsItem content_Textarea = contents.Where(it => it.control == "Textarea").FirstOrDefault();
- if (content_Vacation != null)
- {
- var punch_correction = content_Vacation.value.punch_correction;
- DateTime bukaDt = punch_correction.time_dt;
- DateTime bukaDtJudge = Convert.ToDateTime(bukaDt.ToString("yyyy-MM-dd"));
-
- if (startDt > bukaDtJudge || bukaDtJudge > endDt)
- {
- continue;
- }
-
- decimal bukaPrice = 0.00M;
- if (user_probationary_bk_decimal == 0)
- {
- if (bukaNum <= 2) bukaPrice = 0.00M;
- else if (bukaNum <= 4 && bukaNum > 2) bukaPrice = 10.00M;
- else bukaPrice = 50.00M;
- }
- else
- {
- if (bukaNum <= 2) bukaPrice = 10.00M;
- else bukaPrice = 50.00M;
- }
- var app_data = item.apply_data;
- var punch_correction1 = app_data.contents[0].value.punch_correction;
- var punch_correction2 = app_data.contents[1].value;
- #region 处理未打卡记录表数据 已补卡的数据
- if (filtratePrefix_checkInData.Count > 0)
- {
- var filtratePrefix_checkInItems = filtratePrefix_checkInData.Where(it => it.sch_checkin_time_dt.ToString("yyyy-MM-dd")
- .Equals(punch_correction1.time_dt.ToString("yyyy-MM-dd"))).ToList();
- if (filtratePrefix_checkInItems.Count > 0)
- {
-
- TimeSpan _strWorkingDayAM = DateTime.Parse("09:00").TimeOfDay;
- TimeSpan _endWorkingDayAM = DateTime.Parse("12:00").TimeOfDay;
- TimeSpan _strWorkingDayPM = DateTime.Parse("13:30").TimeOfDay;
- TimeSpan _endWorkingDayPM = DateTime.Parse("18:00").TimeOfDay;
- TimeSpan _dspNow = punch_correction1.time_dt.TimeOfDay;
-
- var filtratePrefix_checkInItemAMs = filtratePrefix_checkInItems.Where(it => it.sch_checkin_time_dt.TimeOfDay >= _strWorkingDayAM &&
- it.sch_checkin_time_dt.TimeOfDay <= _endWorkingDayAM ).ToList();
- if (filtratePrefix_checkInItemAMs.Count > 0)
- {
- foreach (var filtratePrefix_checkInItem1 in filtratePrefix_checkInItemAMs)
- {
- filtratePrefix_checkInData.Remove(filtratePrefix_checkInItem1);
- }
- }
-
- var filtratePrefix_checkInItemPMs = filtratePrefix_checkInItems.Where(it => it.sch_checkin_time_dt.TimeOfDay >= _strWorkingDayPM &&
- it.sch_checkin_time_dt.TimeOfDay <= _endWorkingDayPM).ToList();
- if (filtratePrefix_checkInItemPMs.Count > 0)
- {
- foreach (var filtratePrefix_checkInItem1 in filtratePrefix_checkInItemPMs)
- {
- filtratePrefix_checkInData.Remove(filtratePrefix_checkInItem1);
- }
- }
- }
- }
- #endregion
- Ex_Item ex_reissueCard = new Ex_Item()
- {
- SubTypeId = 7,
- SubType = "打卡补卡",
- StartTimeDt = Convert.ToDateTime(punch_correction1.time_dt.ToString("yyyy-MM-dd HH:mm:ss")),
- Deduction = bukaPrice,
- Reason = punch_correction2.text,
- Unit = string.Empty
- };
- unprinted_deduction += bukaPrice;
- ex_reissuecard_Items.Add(ex_reissueCard);
- bukaNum++;
- }
- }
- }
-
- foreach (var item in filtratePrefix_checkInData)
- {
- decimal bukaPrice = 0.00M;
- if (user_probationary_bk_decimal == 0)
- {
- if (bukaNum <= 2) bukaPrice = 0.00M;
- else if (bukaNum <= 4 && bukaNum > 2) bukaPrice = 10.00M;
- else bukaPrice = 50.00M;
- }
- else
- {
- if (bukaNum <= 2) bukaPrice = 10.00M;
- else bukaPrice = 50.00M;
- }
- Ex_Item ex_reissueCard = new Ex_Item()
- {
- SubTypeId = 7,
- SubType = "打卡补卡",
- StartTimeDt = Convert.ToDateTime(item.checkin_time_dt.ToString("yyyy-MM-dd HH:mm:ss")),
- Deduction = bukaPrice,
- Reason = "[打卡记录]抓取到的未打卡数据!",
- Unit = string.Empty
- };
- unprinted_deduction += bukaPrice;
- ex_reissuecard_Items.Add(ex_reissueCard);
- bukaNum++;
- }
- }
- if (ex_reissuecard_Items.Count > 0)
- {
- ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items;
- ex_Items_dk.Ex_ItemInfo = ex_reissuecard_Items.OrderBy(it => it.SubTypeId).ThenBy(it => it.StartTimeDt).ToList();
- 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";
-
- }
- 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)
- {
-
- Attendance attendance = content_Vacation.value.attendance;
-
-
-
- int leaveType = int.Parse("3");
- 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)(Convert.ToDateTime(date_Range.new_end_dt.ToString("yyyy-MM-dd")) -
- Convert.ToDateTime(date_Range.new_begin_dt.ToString("yyyy-MM-dd"))).TotalDays + 1;
-
- for (int i = 0; i < days; i++)
- {
- DateTime thisDt = date_Range.new_begin_dt.AddDays(i);
-
-
- if (i == 0)
- {
- string ccStartTime = thisDt.ToString("HH:mm:ss");
- if (!IsWorkTime(ccStartTime))
- {
- continue;
- }
- }
-
- if (i == days - 1)
- {
- string ccStartTime = date_Range.new_end_dt.ToString("HH:mm:ss");
- if (!IsWorkTime(ccStartTime))
- {
- 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,
-
- Apply_time_dt = Convert.ToDateTime(sp_item.apply_time_dt.ToString("yyyy-MM-dd HH:mm:ss"))
-
- };
- cc_ex_ItemInfos.Add(ex_Item);
- }
- }
- }
- if (cc_ex_ItemInfos.Count > 0)
- {
-
-
-
- List<Ex_Item> ex_jq_Items = new List<Ex_Item>();
- List<Ex_Item> ex_Items1 = new List<Ex_Item>();
- ex_Items1 = (List<Ex_Item>)ex_Items_jq.Ex_ItemInfo;
- if (ex_Items1 != null && ex_Items1.Count > 0)
- {
- ex_jq_Items = ex_Items1;
- }
- 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
- }
- else
- {
- meal_subsidy = work_days * 10.00M;
- }
- #region 应发合计 实发合计 扣款合计(假勤扣款,其他扣款,社保扣款,公积金代扣,个税扣款)
- decimal mealTotal = meal_subsidy - meal_deduction;
- decimal salaryTotal = 0.00M;
- if (dk_work_days >= work_days)
- {
- dk_work_days = work_days;
- salaryTotal = amountPayable + mealTotal + pm_wsInfo.OtherHandle;
- }
- else
- {
- if (itemName.Equals("张海麟"))
- {
- salaryTotal = amountPayable + mealTotal + pm_wsInfo.OtherHandle;
- }
- else
- {
- salaryTotal = (dk_work_days * dailyWage) + mealTotal + pm_wsInfo.OtherHandle;
- }
-
- }
-
- decimal eductionTotal = sickLeaveTotal + personalLeaveTotal + beLate_deduction + early_deduction + absenteeism_deduction + unprinted_deduction + other_deduction +
- pm_wsInfo.WithholdingInsurance + pm_wsInfo.ReservedFunds + pm_wsInfo.OtherDeductions;
- decimal actualReleaseTotal = salaryTotal - eductionTotal;
- #endregion
- #region 处理当月工资数据
- pm_wsInfo.YearMonth = thisYearMonth;
- pm_wsInfo.StartDate = startDt.ToString("yyyy-MM-dd");
- pm_wsInfo.EndDate = endDt.ToString("yyyy-MM-dd");
- pm_wsInfo.WorkDays = work_days;
- pm_wsInfo.RegularDays = dk_work_days;
- pm_wsInfo.SickLeave = sickLeaveTotal;
- pm_wsInfo.SomethingFalse = personalLeaveTotal;
- pm_wsInfo.LateTo = beLate_deduction;
- pm_wsInfo.LeaveEarly = early_deduction;
- pm_wsInfo.Absenteeism = absenteeism_deduction;
- pm_wsInfo.NotPunch = unprinted_deduction;
- pm_wsInfo.OtherDeductions = other_deduction;
- pm_wsInfo.Ex_ItemsRemark = JsonConvert.SerializeObject(ex_Items);
- pm_wsInfo.Mealsupplement = mealTotal;
- 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;
- pm_wsInfo.CreateUserId = userId;
- pm_wsInfo.CreateTime = DateTime.Now;
- pm_wsInfo.DeleteUserId = null;
- pm_wsInfo.DeleteTime = null;
- #endregion
- }
-
- }
- catch (Exception ex)
- {
- _result.Msg = "【" + name + "】【Msg:" + ex.Message + "】";
- return _result;
- }
- _result.Code = 0;
- _result.Data = pm_WageSheetDattaSources;
- return _result;
- }
-
-
-
-
-
- public static bool IsWorkTime(string timeStr)
- {
- string thisDayWorkStartTime = "09:00:00";
- string thisDayWorkEndTime = "18:00:00";
- TimeSpan dspWorkingDayAM = DateTime.Parse(thisDayWorkStartTime).TimeOfDay;
- TimeSpan dspWorkingDayPM = DateTime.Parse(thisDayWorkEndTime).TimeOfDay;
- DateTime dt = Convert.ToDateTime(timeStr);
- TimeSpan dspNow = dt.TimeOfDay;
- if (dspNow >= dspWorkingDayAM && dspNow <= dspWorkingDayPM)
- {
- return true;
- }
- return false;
- }
-
-
-
-
-
- public static decimal ConvertToDecimal(decimal myDecimal)
- {
- var subDecimal = Math.Floor(myDecimal * 100) / 100;
- return subDecimal;
- }
-
-
-
-
-
- public static decimal ConvertToDecimal1(this decimal myDecimal)
- {
- var subDecimal = Math.Floor(myDecimal * 100) / 100;
- return subDecimal;
- }
-
-
-
-
-
-
- public static void MoveItemAtIndexToFront<T>(this List<T> list, int index)
- {
- T item = list[index];
- list.RemoveAt(index);
- list.Insert(0, item);
- }
-
-
-
-
-
- public static async Task<List<VacationLeaveTypeView>> GetVacationLeaveTypes(string template_id)
- {
- List<VacationLeaveTypeView> vacationLeaveTypes = new List<VacationLeaveTypeView>();
- TemplateDetailView templateDetailView = new TemplateDetailView();
- templateDetailView = await _qiYeWeChatApiService.GetTemplateDetailAsync(template_id);
- if (templateDetailView.errcode != 0)
- {
- Serilog.Log.Error("【企业微信】【审批】【获取假勤类型的审批】【Msg】"+ templateDetailView.errmsg);
- return vacationLeaveTypes;
- }
- List<VacationItemInfo> VacationItemInfos = templateDetailView.vacation_list.item;
- foreach (var item in VacationItemInfos)
- {
- ValueItem valueInfo = item.name.Where(it => it.lang == "zh_CN").FirstOrDefault();
- if (valueInfo != null)
- {
- vacationLeaveTypes.Add(
- new VacationLeaveTypeView()
- {
- id = item.id,
- name = valueInfo.text
- });
- }
- }
- return vacationLeaveTypes;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static void CalculateTypeFee1(List<LeaveDetails> leaveDetails, int leaveType, string date_Range_type, DateTime startTime, DateTime endTime,
- decimal amountPayable, int work_days, decimal duration, out decimal mealDeduction, out decimal typeDeduction)
- {
- typeDeduction = 0;
- mealDeduction = 0;
- decimal personalkLeave_dailywage_day = amountPayable / work_days;
-
- decimal halfHour = 7.50M / 0.50M;
- switch (leaveType)
- {
- case 1:
- if (date_Range_type == "halfday")
- {
- if (duration >= 0.5M && duration <= 1M)
- {
- var njItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd") &&
- it.EndDt.ToString("yyyy-MM-dd") == endTime.ToString("yyyy-MM-dd")).ToList();
- if (njItem.Count > 1)
- {
- if (njItem[0].StartDt == startTime)
- {
- mealDeduction = 10;
- }
- }
- else
- {
- mealDeduction = 10;
- }
- }
- else
- {
- var njManyDaysItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd")).ToList();
- if (njManyDaysItem.Count > 1)
- {
- var njManyDaysItem1 = njManyDaysItem.Where(it => it.StartDt != startTime).ToList();
- if (njManyDaysItem1.Count > 0)
- {
- if (njManyDaysItem1[0].Unit.Equals("天"))
- {
- mealDeduction = 10 * Math.Floor(duration);
- }
- else if (njManyDaysItem1[0].Unit.Equals("小时") && njManyDaysItem1[0].New_Duration >= 3)
- {
- mealDeduction = 10 * Math.Floor(duration);
- }
- else
- {
- mealDeduction = 10 * Math.Ceiling(duration);
- }
- }
- }
- else
- {
- mealDeduction = 10 * Math.Ceiling(duration);
- }
- }
- }
- break;
- case 2:
-
- decimal personalkLeave_dailywage_halfhour = personalkLeave_dailywage_day / 7.50M;
-
- if (date_Range_type == "halfday")
- {
- #region 处理当天是否扣除餐补
- string formatDt_begin = startTime.ToString("yyyy-MM-dd");
- List<LeaveDetails> leaveDetails1 = leaveDetails.Where(it => it.IsDeduction && it.EndDt.ToString("yyyy-MM-dd") == formatDt_begin).ToList();
- if (leaveDetails1.Count > 0) mealDeduction = 10.00M * Math.Floor(duration);
- else mealDeduction = 10.00M * Math.Ceiling(duration);
- #endregion
- if (duration % 1 == 0)
- {
- typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day * duration);
- }
- else
- {
- decimal sj_wholeDay = Math.Floor(duration);
- decimal sj_halfDay = duration % 1;
- if (duration % 1 > 0)
- {
- typeDeduction = (personalkLeave_dailywage_day / 2.00M) * (duration / 0.50M);
-
- }
- else
- {
- typeDeduction = (personalkLeave_dailywage_day / 2.00M);
- }
- typeDeduction = ConvertToDecimal(typeDeduction);
- }
- }
- else if (date_Range_type == "hour")
- {
- decimal leave_halfHour = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
- typeDeduction = ConvertToDecimal(personalkLeave_dailywage_halfhour * leave_halfHour);
-
- if (duration >= 3 && duration < 7.5M)
- {
- mealDeduction = 10;
- }
- else if (duration >= 7.5M)
- {
- decimal leave_halfHour1 = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
- decimal leaveDays = duration / 7.5M;
- if (leaveDays % 1 == 0)
- {
- typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day * leaveDays);
- mealDeduction = 10 * leaveDays;
- }
- else
- {
- typeDeduction = personalkLeave_dailywage_day * Convert.ToInt32(leaveDays);
- decimal sy_shijiaunit = leave_halfHour1 - Convert.ToDecimal(15.00M * Convert.ToInt32(leaveDays));
- if (sy_shijiaunit > 0)
- {
- typeDeduction += ConvertToDecimal(personalkLeave_dailywage_halfhour * sy_shijiaunit);
- }
- mealDeduction = 10 * Convert.ToInt32(leaveDays);
-
- int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
- if (lastHours >= 3)
- {
- mealDeduction += 10;
- }
- }
- }
- }
- break;
- case 3:
-
- decimal chengDuMinimumWage_Day = _chengDuMinimumWage / work_days;
- decimal chengDuMinimumWage_halrHour = chengDuMinimumWage_Day / 7.50M;
- decimal sickLeave_dailywage_halfhour_deduction1 = (personalkLeave_dailywage_day / 7.50M) - chengDuMinimumWage_halrHour;
- if (date_Range_type == "halfday")
- {
- mealDeduction = 10.00M * Math.Ceiling(duration);
- decimal pl_dailywage_day = personalkLeave_dailywage_day - chengDuMinimumWage_Day;
- if (duration % 1 == 0)
- {
- typeDeduction = ConvertToDecimal(pl_dailywage_day * duration);
- }
- else
- {
- #region 处理当天是否扣除餐补
- string formatDt_begin = startTime.ToString("yyyy-MM-dd");
- List<LeaveDetails> leaveDetails1 = leaveDetails.Where(it => it.IsDeduction && it.EndDt.ToString("yyyy-MM-dd") == formatDt_begin).ToList();
- if (leaveDetails1.Count > 0) mealDeduction = 10.00M * Math.Floor(duration);
- else mealDeduction = 10.00M * Math.Ceiling(duration);
- #endregion
- if (duration % 1 > 0)
- {
- typeDeduction = (pl_dailywage_day / 2.00M) * (duration / 0.50M); ;
- }
- else
- {
- typeDeduction = (pl_dailywage_day / 2.00M);
- }
- typeDeduction = ConvertToDecimal(typeDeduction);
- }
- }
- else if (date_Range_type == "hour")
- {
- decimal sickLeave_halfHour = duration / 0.5M;
- typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sickLeave_halfHour);
- if (duration >= 3 && duration < 7.5M)
- {
- mealDeduction = 10;
- }
- else if (duration >= 7.5M)
- {
- decimal sickLeave_halfHour1 = duration / 0.5M;
- decimal leaveDays = Convert.ToDecimal(duration / 7.5M);
- typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sickLeave_halfHour1);
- if (leaveDays % 1 == 0)
- {
- mealDeduction = 10 * leaveDays;
- }
- else
- {
- mealDeduction = 10 * Convert.ToInt32(leaveDays);
- typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * Convert.ToInt32(leaveDays));
- decimal sy_bingjiaunit = sickLeave_halfHour1 - Convert.ToDecimal(15.00M * Convert.ToInt32(leaveDays));
- if (sy_bingjiaunit > 0)
- {
- typeDeduction += ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sy_bingjiaunit);
- }
-
- int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
- if (lastHours >= 3)
- {
- mealDeduction += 10;
- }
- }
- }
- }
- break;
- case 4:
- CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 5:
- CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 6:
- CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 7:
- CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 8:
- CalculateTypeFeeSub(leaveDetails, date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 9:
- if (date_Range_type == "halfday")
- {
- if (duration >= 0.5M && duration <= 1M)
- {
- var njItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd") &&
- it.EndDt.ToString("yyyy-MM-dd") == endTime.ToString("yyyy-MM-dd")).ToList();
- if (njItem.Count > 1)
- {
- if (njItem[0].StartDt == startTime)
- {
- mealDeduction = 10;
- }
- }
- else
- {
- mealDeduction = 10;
- }
- }
- else
- {
- var njManyDaysItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd")).ToList();
- if (njManyDaysItem.Count > 1)
- {
- var njManyDaysItem1 = njManyDaysItem.Where(it => it.StartDt != startTime).ToList();
- if (njManyDaysItem1.Count > 0)
- {
- if (njManyDaysItem1[0].Unit.Equals("天"))
- {
- mealDeduction = 10 * Math.Floor(duration);
- }
- else if (njManyDaysItem1[0].Unit.Equals("小时") && njManyDaysItem1[0].New_Duration >= 3)
- {
- mealDeduction = 10 * Math.Floor(duration);
- }
- else
- {
- mealDeduction = 10 * Math.Ceiling(duration);
- }
- }
- }
- else
- {
- mealDeduction = 10 * Math.Ceiling(duration);
- }
- }
- }
- break;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static void CalculateTypeFee2(List<LeaveDetails> leaveDetails,int leaveType, string date_Range_type, DateTime startTime, DateTime endTime,
- decimal amountPayable,int work_days, decimal duration, out decimal mealDeduction, out decimal typeDeduction)
- {
- typeDeduction = 0;
- mealDeduction = 0;
- string am_starttime = "08:59";
- string am_endtime = "13:01";
- decimal personalkLeave_dailywage_day = amountPayable / work_days;
-
- decimal halfHour = 7.50M / 0.50M;
- switch (leaveType)
- {
- case 1:
- if (date_Range_type == "halfday")
- {
- if (duration >= 0.5M && duration <= 1M)
- {
- var njItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd") &&
- it.EndDt.ToString("yyyy-MM-dd") == endTime.ToString("yyyy-MM-dd")).ToList();
- if (njItem.Count > 1)
- {
- if (njItem[0].StartDt == startTime)
- {
- mealDeduction = 10;
- }
- }
- else
- {
- mealDeduction = 10;
- }
- }
- else
- {
- var njManyDaysItem = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd") == startTime.ToString("yyyy-MM-dd")).ToList();
- if (njManyDaysItem.Count > 1)
- {
- var njManyDaysItem1 = njManyDaysItem.Where(it => it.StartDt != startTime).ToList();
- if (njManyDaysItem1.Count > 0)
- {
- if (njManyDaysItem1[0].Unit.Equals("天"))
- {
- mealDeduction = 10 * Math.Floor(duration);
- }
- else if (njManyDaysItem1[0].Unit.Equals("小时") && njManyDaysItem1[0].New_Duration >= 3)
- {
- mealDeduction = 10 * Math.Floor(duration);
- }
- else
- {
- mealDeduction = 10 * Math.Ceiling(duration);
- }
- }
- }
- else
- {
- mealDeduction = 10 * Math.Ceiling(duration);
- }
- }
- }
- break;
- case 2:
-
- decimal personalkLeave_dailywage_halfhour = personalkLeave_dailywage_day / 7.50M;
- if (date_Range_type == "halfday")
- {
- mealDeduction = 10.00M * Math.Floor(duration);
- if (duration % 1 == 0)
- {
- typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day * duration);
- }
- else
- {
- decimal sj_wholeDay = Math.Floor(duration);
- decimal sj_halfDay = duration % 1;
- if (sj_halfDay > 0)
- {
- LeaveDetails sjDetails = leaveDetails.Where(it => it.StartDt == startTime && it.EndDt == endTime).FirstOrDefault();
- decimal sjPrice = 0.00M;
- if (sjDetails != null)
- {
- Slice_info sj_slice_Info = sjDetails.SliceInfo;
- if (sj_slice_Info != null)
- {
- decimal sjLongTime = (sj_slice_Info.duration / 3600.00M);
- typeDeduction = (personalkLeave_dailywage_day / 7.50M) * sjLongTime;
- }
- }
- LeaveDetails sjDetailsMeal = leaveDetails.Where(it => it.EndDt == startTime ).FirstOrDefault();
- if (sjDetailsMeal == null)
- {
- mealDeduction += 10.00M;
- }
- }
- else
- {
- typeDeduction = personalkLeave_dailywage_day* sj_wholeDay;
- }
- typeDeduction = ConvertToDecimal(typeDeduction);
- }
- }
- else if (date_Range_type == "hour")
- {
- decimal leave_halfHour = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
- typeDeduction = ConvertToDecimal(personalkLeave_dailywage_halfhour * leave_halfHour);
-
- if (duration >= 3 && duration < 7.5M)
- {
- mealDeduction = 10;
- }
- else if (duration >= 7.5M)
- {
- decimal leave_halfHour1 = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
-
- decimal leaveDays = duration / 7.5M;
- if (leaveDays % 1 == 0)
- {
- typeDeduction = ConvertToDecimal(personalkLeave_dailywage_day * leaveDays);
- mealDeduction = 10 * leaveDays;
- }
- else
- {
- typeDeduction = personalkLeave_dailywage_day * Convert.ToInt32(leaveDays);
- decimal sy_shijiaunit = leave_halfHour1 - Convert.ToDecimal (15.00M * Convert.ToInt32(leaveDays));
- if (sy_shijiaunit > 0)
- {
- typeDeduction += ConvertToDecimal(personalkLeave_dailywage_halfhour * sy_shijiaunit);
- }
- mealDeduction = 10 * Convert.ToInt32(leaveDays);
-
- int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
- if (lastHours >= 3)
- {
- mealDeduction += 10;
- }
- }
- }
- }
- break;
- case 3:
-
- decimal chengDuMinimumWage_Day = _chengDuMinimumWage / work_days;
- decimal chengDuMinimumWage_halrHour = chengDuMinimumWage_Day / 7.50M;
- decimal sickLeave_dailywage_halfhour_deduction1 = (personalkLeave_dailywage_day / 7.50M) - chengDuMinimumWage_halrHour;
- if (date_Range_type == "halfday")
- {
- mealDeduction = 10.00M * Math.Ceiling(duration);
- decimal pl_dailywage_day = personalkLeave_dailywage_day - chengDuMinimumWage_Day;
- if (duration % 1 == 0)
- {
- typeDeduction = ConvertToDecimal(pl_dailywage_day * duration);
- }
- else
- {
- decimal bj_wholeDay = Math.Floor(duration);
- decimal bj_halfDay = duration % 1;
- decimal bj_wholeDayWage = pl_dailywage_day * bj_wholeDay;
- decimal bj_halfDayWage = 0.00M;
- if (bj_halfDay > 0)
- {
- LeaveDetails bjDetails = leaveDetails.Where(it => it.StartDt == startTime && it.EndDt == endTime).FirstOrDefault();
- decimal bjPrice = 0.00M;
- if (bjDetails != null)
- {
- Slice_info bj_slice_Info = bjDetails.SliceInfo;
- decimal bjLongTime = bj_slice_Info.duration / 3600.00M;
- if (bjLongTime == 3.00M)
- {
- bj_halfDayWage = (pl_dailywage_day / 7.50M) * 3.00M;
- }
- else if (bjLongTime == 4.50M)
- {
- bj_halfDayWage = (pl_dailywage_day / 7.50M) * 4.50M;
- }
- }
- }
- typeDeduction = ConvertToDecimal(bj_wholeDayWage + bj_halfDayWage);
- }
- }
- else if (date_Range_type == "hour")
- {
- decimal sickLeave_halfHour = duration / 0.5M;
- typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sickLeave_halfHour);
- if (duration >= 3 && duration < 7.5M)
- {
- mealDeduction = 10;
- }
- else if (duration >= 7.5M)
- {
- decimal sickLeave_halfHour1 = duration / 0.5M;
- decimal leaveDays = Convert.ToDecimal(duration / 7.5M);
- typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sickLeave_halfHour1);
- if (leaveDays % 1 == 0)
- {
- mealDeduction = 10 * leaveDays;
- }
- else
- {
- mealDeduction = 10 * Convert.ToInt32(leaveDays);
- typeDeduction = ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * Convert.ToInt32(leaveDays));
- decimal sy_bingjiaunit = sickLeave_halfHour1 - Convert.ToDecimal(15.00M * Convert.ToInt32(leaveDays));
- if (sy_bingjiaunit > 0)
- {
- typeDeduction += ConvertToDecimal(sickLeave_dailywage_halfhour_deduction1 * sy_bingjiaunit);
- }
-
- int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
- if (lastHours >= 3)
- {
- mealDeduction += 10;
- }
- }
- }
- }
- break;
- case 4:
- CalculateTypeFeeSub(leaveDetails,date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 5:
- CalculateTypeFeeSub(leaveDetails,date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 6:
- CalculateTypeFeeSub(leaveDetails,date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 7:
- CalculateTypeFeeSub(leaveDetails,date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 8:
- CalculateTypeFeeSub(leaveDetails,date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- case 9:
- CalculateTypeFeeSub(leaveDetails,date_Range_type, startTime, endTime, duration, out mealDeduction);
- break;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
- public static void CalculateTypeFeeSub(List<LeaveDetails> leaveDetails,string date_Range_type, DateTime startTime1, DateTime endTime1,
- decimal duration, out decimal mealDeduction)
- {
- mealDeduction = 0;
- string am_starttime = "09:00";
- string am_endtime = "11:59";
- string startTime = startTime1.ToString("HH:mm:ss");
- string endTime = endTime1.ToString("HH:mm:ss");
- if (date_Range_type == "halfday")
- {
- mealDeduction = duration * 10;
- }
- else if (date_Range_type == "hour")
- {
- List<LeaveDetails> leaveDetails1 = new List<LeaveDetails>();
- leaveDetails1 = leaveDetails.Where(it => it.StartDt.ToString("yyyy-MM-dd").Equals(startTime1.ToString("yyyy-MM-dd")))
- .OrderBy(it => it.StartDt).ToList();
- if (leaveDetails1.Count > 1)
- {
- decimal timelenTatoal = leaveDetails1.Sum(it => it.New_Duration);
- if (timelenTatoal >= 3.00M)
- {
- if (leaveDetails1[0].StartDt == startTime1)
- {
- mealDeduction = 10;
- }
- }
- }
- else
- {
- if (duration >= 3 && duration < 7)
- {
- mealDeduction = 10;
- }
- else if (duration >= 7 && duration <= 7.50M)
- {
- mealDeduction = 10;
- }
- else if (duration >= 7.50M)
- {
- decimal leaveDays = Convert.ToDecimal(duration / 7.50M);
- if (leaveDays % 1 == 0)
- {
- mealDeduction = 10 * leaveDays;
- }
- else
- {
- mealDeduction = 10 * Convert.ToInt32(leaveDays);
-
- int lastHours = (Convert.ToDateTime(endTime) - Convert.ToDateTime("09:00")).Hours;
- if (lastHours >= 3)
- {
- mealDeduction += 10;
-
-
-
-
-
- }
- }
- }
- }
- }
- }
-
-
-
-
-
- public static async Task<List<VacationLeaveTypeView>> GetVacationReissueCardTypes(string template_id)
- {
- List<VacationLeaveTypeView> vacationLeaveTypes = new List<VacationLeaveTypeView>();
- TemplateDetailView templateDetailView = new TemplateDetailView();
- templateDetailView = await _qiYeWeChatApiService.GetTemplateDetailAsync(template_id);
- if (templateDetailView.errcode != 0)
- {
- return vacationLeaveTypes;
- }
- List<VacationItemInfo> VacationItemInfos = templateDetailView.vacation_list.item;
- foreach (var item in VacationItemInfos)
- {
- ValueItem valueInfo = item.name.Where(it => it.lang == "zh_CN").FirstOrDefault();
- if (valueInfo != null)
- {
- vacationLeaveTypes.Add(
- new VacationLeaveTypeView()
- {
- id = item.id,
- name = valueInfo.text
- });
- }
- }
- return vacationLeaveTypes;
- }
-
-
-
-
-
-
-
-
-
-
-
-
- private static int Fallibilitydispose(List<Sp_Item> datas, int type, string? subTypeName)
- {
- int num = 0;
- Sp_Item _Info = datas.Where(it => it.type == type && it.name == subTypeName).FirstOrDefault();
- if (_Info != null) { num = _Info.count; }
- return num;
- }
-
-
-
-
-
- private static int ExceptionStatistics(List<Exception_Info> datas, int type)
- {
- int num = 0;
- Exception_Info _Info = datas.Where(it => it.exception == type).FirstOrDefault();
- if (_Info != null) { num = _Info.count; }
- return num;
- }
-
-
-
-
-
-
- public static async Task<int> GetWorkDays(string yearMonth)
- {
- int workdays = 0;
- string sql = string.Format(@"Select * From Pm_WageIssueWorkingDay
- Where Isdel = 0 And YearMonth = '{0}' ", yearMonth);
- var data = await _usersRep._sqlSugar.SqlQueryable<WageYearMonthView>(sql).FirstAsync();
- if (data != null)
- {
- workdays = data.Workdays;
- }
- return workdays;
- }
- }
- }
|