| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099 |
- package cn.com.lzt.userwage.service.impl;
- import java.math.BigDecimal;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.apache.commons.lang3.StringUtils;
- import org.hibernate.transform.Transformers;
- import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
- import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.util.MyBeanUtils;
- import org.jeecgframework.core.util.oConvertUtils;
- import org.jeecgframework.web.system.dto.TSDepartDto;
- import org.jeecgframework.web.system.pojo.base.TSUserOrgDto;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import com.alibaba.fastjson.JSONObject;
- import cn.com.lzt.arrangedutyoperate.entity.ArrangeDutyOperateEntity;
- import cn.com.lzt.calendar.entity.CalendarEntity;
- import cn.com.lzt.certificatesubsidy.entity.CertificateSubsidyEntity;
- import cn.com.lzt.duties.entity.DutiesEntity;
- import cn.com.lzt.dutyfeestrategy.entity.DutyfeeStrategyEntity;
- import cn.com.lzt.mealssubsidy.entity.MealsSubsidyEntity;
- import cn.com.lzt.megathermalsubsidy.entity.MegathermalSubsidyEntity;
- import cn.com.lzt.othersubsidy.entity.OtherSubsidyEntity;
- import cn.com.lzt.overtimepaystrategy.entity.OvertimepayStrategyEntity;
- import cn.com.lzt.overtimestats.dto.OvertimeDto;
- import cn.com.lzt.personnelbasearchivesmanage.entity.PersonnelBaseArchivesManageEntity;
- import cn.com.lzt.providentfundstrategy.entity.ProvidentFundStrategyEntity;
- import cn.com.lzt.socialsecuritystrategy.entity.SocialSecurityStrategyEntity;
- import cn.com.lzt.trafficsubsidy.entity.TrafficSubsidyEntity;
- import cn.com.lzt.useractiviti.overtime.service.TBusActivitiOvertimeServiceI;
- import cn.com.lzt.useractiviti.sameleveltransfer.entity.TBusActivitiSamelevelTransferEntity;
- import cn.com.lzt.userattendancedetail.dto.AttendanceDetailJsonObj;
- import cn.com.lzt.userattendancedetail.dto.AttendanceTotalJsonObj;
- import cn.com.lzt.userattendancedetail.entity.UserAttendanceDetailEntity;
- import cn.com.lzt.userattendancedetail.service.UserAttendanceDetailServiceI;
- import cn.com.lzt.userattendancetotal.entity.UserAttendanceTotalEntity;
- import cn.com.lzt.userattendancetotal.service.UserAttendanceTotalServiceI;
- import cn.com.lzt.usercertificate.entity.UserCertificateEntity;
- import cn.com.lzt.userwage.dao.UserWageMinidaoDao;
- import cn.com.lzt.userwage.dto.YearMonthDay;
- import cn.com.lzt.userwage.entity.UserWageEntity;
- import cn.com.lzt.userwage.service.UserPayrollServiceI;
- import cn.com.lzt.userwage.service.UserWageServiceI;
- import cn.com.lzt.userwagestrategy.entity.UserWagestrategyEntity;
- import cn.com.lzt.userwagestrategyhistory.entity.UserWagestrategyHistoryEntity;
- import cn.com.lzt.wagestrategy.entity.WagestrategyEntity;
- /**
- * 工资核算
- * @author Administrator
- *
- */
- @Service("userPayrollService")
- @Transactional
- public class UserPayrollServiceImpl extends CommonServiceImpl implements UserPayrollServiceI {
- @Autowired
- private UserWageServiceI userWageServiceI;
-
- @Autowired
- private UserAttendanceTotalServiceI userAttendanceTotalService;
-
- @Autowired
- private UserAttendanceDetailServiceI userAttendanceDetailService;
-
- @Autowired
- private UserWageMinidaoDao userWageMinidaoDao;
- @Autowired
- private TBusActivitiOvertimeServiceI overtimeService;
-
- /**
- * type 0.定时任务 1.手动审核所有 2.手动审核部分
- * @throws Exception
- */
- @Override
- public void userPayroll(List<UserWagestrategyEntity> userWagestrategyEntity,String moth,String type) throws Exception {
- List<UserWageEntity> userWageList = null;
- List<UserWagestrategyHistoryEntity> uwhList = null;
- List<UserWageEntity> userWageList1 = null;
- HashMap<String, HashMap<String, Object>> hm_cache = new HashMap<>();
- userWageList = new ArrayList<UserWageEntity>();
- uwhList = new ArrayList<UserWagestrategyHistoryEntity>();
-
- List<UserWagestrategyHistoryEntity> uwhList1 = null;
- userWagestrategyEntity = filterRepeatUserWagestrategy(userWagestrategyEntity);
- //String moth = ""; getMonthlys();//"2017-09";//"2017-10"; //
- boolean isCacheUsed = true;
- if(!"0".equals(type)){
- if("1".equals(type)){
- StringBuffer hql = new StringBuffer("from UserWageEntity where monthly = :monthly");
- userWageList1 = this.getSession().createQuery(hql.toString()).setParameter("monthly", moth).list();
-
- StringBuffer hqls = new StringBuffer("from UserWagestrategyHistoryEntity where strategyMonth = :monthly");
- uwhList1 = this.getSession().createQuery(hqls.toString()).setParameter("monthly", moth).list();
- }else{
- List<String> userid = new ArrayList<String>();
-
- for (UserWagestrategyEntity userWages : userWagestrategyEntity) {
- userid.add(userWages.getUserid());
- }
-
- /*StringBuffer hql = new StringBuffer("from UserWagestrategyEntity where userid in (:userid)");
- userWagestrategyEntity= this.getSession().createQuery(hql.toString()).setParameterList("userid", userid).list();*/
-
- StringBuffer hql = new StringBuffer("from UserWageEntity where userid in (:userid) and monthly = :monthly");
- userWageList1 = this.getSession().createQuery(hql.toString()).setParameterList("userid", userid).setParameter("monthly", moth).list();
-
- StringBuffer hqls = new StringBuffer("from UserWagestrategyHistoryEntity where userid in (:userid) and strategyMonth = :monthly");
- uwhList1= this.getSession().createQuery(hqls.toString()).setParameterList("userid", userid).setParameter("monthly", moth).list();
- isCacheUsed = false; // 个人核算不用缓存
- }
- }else{
- moth = getMonthlys(); //getMonthlys();//"2017-09";//"2017-10"; //
-
- StringBuffer hql = new StringBuffer("from UserWageEntity where monthly = :monthly");
- userWageList1 = this.getSession().createQuery(hql.toString()).setParameter("monthly", moth).list();
-
- StringBuffer hqls = new StringBuffer("from UserWagestrategyHistoryEntity where strategyMonth = :monthly");
- uwhList1 = this.getSession().createQuery(hqls.toString()).setParameter("monthly", moth).list();
- }
-
- UserWageEntity uw = null;
- UserWagestrategyHistoryEntity uwh = null;
-
- StringBuffer hql = new StringBuffer("from MealsSubsidyEntity where deleteFlag = 0 and status = 0");
- List<MealsSubsidyEntity> meslList = this.getSession().createQuery(hql.toString()).list();
-
- for (UserWagestrategyEntity us : userWagestrategyEntity) {
-
- //PersonnelBaseArchivesManageEntity per = findUniqueByProperty(PersonnelBaseArchivesManageEntity.class,"userid",us.getUserid());
- PersonnelBaseArchivesManageEntity per = null;
- if(isCacheUsed) {
- per = getPersonnelBaseArchivesManageEntityWithCache(hm_cache,us.getUserid());
- }else {
- per = findUniqueByProperty(PersonnelBaseArchivesManageEntity.class,"userid",us.getUserid());
- }
- // if(us.getUserid().equals("000000006120dd360161315003fb0376")) {
- // System.out.println("---");
- // }else {
- // continue;
- // }
- if(type.equals("2") || getPerWageCalcuStatus(per,moth)){
- uw = new UserWageEntity();
- uwh = new UserWagestrategyHistoryEntity();
- uwh.setBelongUnitid(us.getBelongUnitid());
- uwh.setUserid(us.getUserid());
- uwh.setStrategyMonth(moth);
-
- uw.setUserid(us.getUserid());
- uw.setBelongUnitid(us.getBelongUnitid());
- //存入项目(或部门)id
- uw.setPjtId(getBybelongId(hm_cache,us.getUserid()));
-
-
- //查询员工考勤合计表
- //List<UserAttendanceTotalEntity> uatList = userAttendanceTotalService.getByuserid(us.getUserid(), moth);//findListbySql("select * from t_bus_user_attendance_total where user_id = '"+us.getUserid()+"' yearmonth = '"+moth+"'");
- List<UserAttendanceTotalEntity> uatList = null;
- if(isCacheUsed) {
- uatList = getUserAttendanceTotalEntityWithCache(hm_cache,us.getUserid(), moth);
- }else {
- uatList = userAttendanceTotalService.getByuserid(us.getUserid(), moth);//findListbySql("select * from t_bus_user_attendance_total where user_id = '"+us.getUserid()+"' yearmonth = '"+moth+"'");
- }
-
- UserAttendanceTotalEntity uat = null;
- if(uatList==null ||uatList.isEmpty()){
- uat = new UserAttendanceTotalEntity();
- }else{
- uat = uatList.get(0);
- }
- //保存上个月度
- uw.setMonthly(moth);
-
- // debug用的代码
- /*if(us.getUserid().equals("000000006120dd1c01612cf52463023a") || us.getUserid().equals("ff808081616fd75e016182890f5100f2") || us.getUserid().equals("ff8080816184236c016187d295691831")){
- System.out.println(us.getUserid());
- }
- if(uw.getUserid().equals("000000006120dd1c01612cf52463023a") || uw.getUserid().equals("ff808081616fd75e016182890f5100f2") || uw.getUserid().equals("ff8080816184236c016187d295691831")){
- System.out.println(uw.getUserid());
- }
- if(per.getUserid().equals("000000006120dd1c01612cf52463023a") || per.getUserid().equals("ff808081616fd75e016182890f5100f2") || per.getUserid().equals("ff8080816184236c016187d295691831")){
- System.out.println(per.getUserid());
- }*/
-
-
- boolean isCompleteMonthWage = isCompleteMonthWage(hm_cache,us,per, moth);
- if(isCompleteMonthWage && getPerWageCalcuStatus(per,moth)){
- //查询基本工资
- uw = enactmentCalculation(isCacheUsed,hm_cache,us, uw,per);
- //查询所有设定策略信息
- uw = selectStrategy(isCacheUsed,hm_cache,us, uw, per);
- //餐费补助
- uw = mealsCalculation(isCacheUsed,hm_cache,uat, us, uw,meslList);
- //工资扣除项
- uw = deductionCalculation(uat, us, uw, per, true);
- //公积金和社保
- uw = socialSecurityProvidentFund(isCacheUsed,hm_cache,uat, us, uw, per);
- //加班费
- uw = overtimeCalculation(isCacheUsed,hm_cache,uat, us, uw,moth,per);
-
- uw.setStatus(Globals.ARRANGESTATUS_0.toString());
- uw.setTaxMoney(new BigDecimal(0));
- if(us.getDeductPay() != null && us.getDeductPay().doubleValue()> 0){
- uw.setOtherDebit(us.getDeductPay());
- }
- // 代扣款
- if(us.getDaikouFee() != null && us.getDaikouFee().doubleValue()> 0){
- uw.setDaikouDebit(us.getDaikouFee());
- }
-
- if(us.getProjectPerformance() != null && us.getProjectPerformance().doubleValue() > 0) {
- uw.setProjectPerformance(new BigDecimal(us.getProjectPerformance().toString()));
- }
- // calcuPreTaxMonayAndActMoney(uw, us.getDeductPay());
- if(uw.getOtherDebit() == null) {
- uw.setOtherDebit(BigDecimal.ZERO);
- }
- if(uw.getDaikouDebit() == null) {
- uw.setDaikouDebit(BigDecimal.ZERO);
- }
- if(uw.getProjectPerformance() == null) {
- uw.setProjectPerformance(BigDecimal.ZERO);
- }
- if(uw.getBonus() == null) {
- uw.setBonus(BigDecimal.ZERO);
- }
- if(uw.getReissue() == null) {
- uw.setReissue(new BigDecimal(0));
- }
-
- //判断该员工当月是否被调动过
- if("1".equals(uat.getIfmoved())){
- //List<UserAttendanceDetailEntity> uadeList = findListbySql("select * from t_bus_user_attendance_detail where attendance_id = '"+uat.getId()+"' and borrowspid = 1");
- List<UserAttendanceDetailEntity> uadeList = this.getSession().createSQLQuery("select * from t_bus_user_attendance_detail where attendance_id = '"+uat.getId()+"' and borrowstatus = '1'").addEntity(UserAttendanceDetailEntity.class).list();
- if(!uadeList.isEmpty() && uadeList.size() > 0){
- for (UserAttendanceDetailEntity u : uadeList) {
- uw.setReissue(uw.getReissue().add(u.getDayPay()));
- }
- }
- }
-
- // 参考平调的结算工资重新计算工资项,除了补发调整、缴金之外,其它全部为零
- uw = recalcuSamelevelTransWage(true,isCacheUsed,hm_cache,uw,us,uat,moth,per,meslList);
-
- uw.recalculatePreTaxMoney();
- uw.recalculateActualMoney();
- uw.recalculateComCost();
- }else{
- uw = entryOrLeaveCalculation(isCacheUsed,hm_cache,uw,us,uat,moth,per,meslList);
- }
- if(uw.getActualMoney() != null && uw.getActualMoney().intValue() < 0) {
- uw.setActualMoney(BigDecimal.ZERO);
- }
- // 计算企业成本
- // comCost(uat, us, uw, per);
- //记录月度员工工资策略历史记录表
- userWageList.add(uw);
- uwhList.add(historyUW(uwh, us));
- }
- }
- if(!"0".equals(type)){
- if(!uwhList1.isEmpty()){
- for (UserWagestrategyHistoryEntity u : uwhList) {
- boolean temp = true;
- for (UserWagestrategyHistoryEntity userWage1 : uwhList1) {
- if(u.getUserid().equals(userWage1.getUserid())){
- MyBeanUtils.copyBeanNotNull2Bean(u, userWage1);
- saveOrUpdate(userWage1);
- temp = false;
- }
- }
-
- if(temp){
- saveOrUpdate(u);
- }
- }
- }else{
- this.batchSave(uwhList);
- }
-
- if(!userWageList1.isEmpty()){
- for (UserWageEntity uge : userWageList) {
- boolean temp = true;
- for (UserWageEntity uwEntity : userWageList1) {
- if(uge.getUserid().equals(uwEntity.getUserid())){
- // 重新核算后留下已调整的部分
- BigDecimal bufa = uwEntity.getReissue();
- BigDecimal jiangjin = uwEntity.getBonus();
- BigDecimal otherKouchu = uwEntity.getOtherDebit();
- BigDecimal gaowen = uwEntity.getMegathermalSubsidy();
- BigDecimal jiaojinbutie = uwEntity.getPaymentSubsidy();
- String descrip = uwEntity.getRemark();
- String status = uwEntity.getStatus();
- // BigDecimal comsocial = uwEntity.getComSocialSecurityDebit();
- // BigDecimal comProvidentFundDebit = uwEntity.getComProvidentFundDebit();
- MyBeanUtils.copyBeanNotNull2Bean(uge, uwEntity);
- uwEntity.setStatus(status);
- if(bufa.compareTo(BigDecimal.ZERO) > 0) {
- uwEntity.setReissue(bufa);
- }
-
- uwEntity.setBonus(jiangjin);
- uwEntity.setOtherDebit(otherKouchu);
- uwEntity.setRemark(descrip);
- uwEntity.setMegathermalSubsidy(gaowen);
- // uwEntity.setPaymentSubsidy(jiaojinbutie);
- // uwEntity.setComSocialSecurityDebit(comsocial);
- // uwEntity.setComProvidentFundDebit(comProvidentFundDebit);
- // 手动核算的时候需要重新计算实发工资
- uwEntity.recalculatePreTaxMoney();
- uwEntity.recalculateActualMoney();
- uwEntity.recalculateComCost();
- saveOrUpdate(uwEntity);
- temp = false;
- }
- }
-
- if(temp){
- saveOrUpdate(uge);
- }
-
- }
- }else{
- this.batchSave(userWageList);
- }
- }else{
- deleteAllEntitie(userWageList1);
- deleteAllEntitie(uwhList1);
- this.batchSave(userWageList);
- this.batchSave(uwhList);
- }
- hm_cache.clear();
- }
- /**
- * @param isCompletedMonth 是否是整月,整月的话只有补发调整,其它为零
- * @param hm_cache
- * @param uw
- * @param us
- * @param uat
- * @param moth
- * @param per
- * @param meslList
- * @return
- */
- private UserWageEntity recalcuSamelevelTransWage(boolean isCompletedMonth, boolean isCacheUsed, HashMap<String, HashMap<String, Object>> hm_cache, UserWageEntity uw, UserWagestrategyEntity us, UserAttendanceTotalEntity uat, String moth,
- PersonnelBaseArchivesManageEntity per, List<MealsSubsidyEntity> meslList) {
- List<TBusActivitiSamelevelTransferEntity> samelevelTransentities = getTBusActivitiSamelevelTransferEntityWithCache(hm_cache, per.getUserid(), moth);
- if(samelevelTransentities != null && samelevelTransentities.size()>0) {
- if(isCompletedMonth) {
- uw.setBasicWage(BigDecimal.ZERO);
- uw.setDutiesAllowance(BigDecimal.ZERO);
- uw.setCertificateSubsidy(BigDecimal.ZERO);
- uw.setTrafficSubsidy(BigDecimal.ZERO);
- uw.setMegathermalSubsidy(BigDecimal.ZERO);
- uw.setOnlyChildCost(BigDecimal.ZERO);
- uw.setOtherSubsidy(BigDecimal.ZERO);
- uw.setDuty(BigDecimal.ZERO);
- uw.setMealsSubsidyDay(BigDecimal.ZERO);
- uw.setMealsSubsidyNight(BigDecimal.ZERO);
- uw.setBonus(BigDecimal.ZERO);
- uw.setProjectPerformance(BigDecimal.ZERO);
- uw.setMealsSubsidy(BigDecimal.ZERO);
- uw.setOvertimepayTimeout(BigDecimal.ZERO);
-
- uw.setOvertimepayFixed(BigDecimal.ZERO);
- uw.setSpecialOvertime(BigDecimal.ZERO);
- uw.setSickLeaveDebit(BigDecimal.ZERO);
- uw.setThingLeaveDebit(BigDecimal.ZERO);
- uw.setAbsenceDebit(BigDecimal.ZERO);
- uw.setAbsenceDebit(BigDecimal.ZERO);
- uw.setOtherDebit(BigDecimal.ZERO);
- uw.setDaikouDebit(BigDecimal.ZERO);
- uw.setPaymentSubsidy(BigDecimal.ZERO);
- }
-
- uw.setReissue(BigDecimal.ZERO);
-
- BigDecimal reissue = BigDecimal.ZERO;
- for(TBusActivitiSamelevelTransferEntity tranEntity : samelevelTransentities) {
- String monthInEntity = tranEntity.getWageYearmonth();
- String monthLastInEntity = tranEntity.getWageYearmonthLast();
- if(moth.equals(monthInEntity)) {
- reissue = reissue.add(tranEntity.getCheckedWage());
- }
- if(moth.equals(monthLastInEntity)) {
- BigDecimal wageLast= tranEntity.getCheckedWageLast();
- if(wageLast==null) wageLast=BigDecimal.ZERO;
- reissue = reissue.add(wageLast);
- }
- }
- uw.setReissue(reissue);
- }
- return uw;
- }
- /**
- * 去重
- * @param userWagestrategyEntity
- * @return
- */
- private List<UserWagestrategyEntity> filterRepeatUserWagestrategy(
- List<UserWagestrategyEntity> userWagestrategyEntity) {
- HashMap<String, UserWagestrategyEntity> hm_userid = new HashMap<>();
- if(userWagestrategyEntity != null) {
- for(UserWagestrategyEntity entity : userWagestrategyEntity) {
- hm_userid.put(entity.getUserid(), entity);
- }
- }
- return new ArrayList<UserWagestrategyEntity>(hm_userid.values());
- }
- /**
- * @param userid
- * @param moth
- * @return
- */
- private List<UserAttendanceTotalEntity> getUserAttendanceTotalEntityWithCache(HashMap<String, HashMap<String, Object>> hm_cache,String userid, String moth) {
- HashMap<String, Object> hm = hm_cache.get("getUserAttendanceTotalEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getUserAttendanceTotalEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(UserAttendanceTotalEntity.class);
- specialcq.eq("yearmonth", moth);
- specialcq.add();
- List<UserAttendanceTotalEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(UserAttendanceTotalEntity entity : entitiesFromDB) {
- String userInEntity = entity.getUserId();
- if(hm.containsKey(userInEntity)) {
- List<UserAttendanceTotalEntity> entitylist = (List<UserAttendanceTotalEntity>)hm.get(userInEntity);
- entitylist.add(entity);
- }else {
- List<UserAttendanceTotalEntity> newlist = new ArrayList<>();
- newlist.add(entity);
- hm.put(userInEntity, newlist);
- }
- }
- }
- return (List<UserAttendanceTotalEntity>)hm.get(userid);
- }
- /**
- * @param hm_cache
- * @param userid
- * @return
- */
- private PersonnelBaseArchivesManageEntity getPersonnelBaseArchivesManageEntityWithCache(
- HashMap<String, HashMap<String, Object>> hm_cache, String userid) {
- HashMap<String, Object> hm = hm_cache.get("getPersonnelBaseArchivesManageEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getPersonnelBaseArchivesManageEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(PersonnelBaseArchivesManageEntity.class);
- List<PersonnelBaseArchivesManageEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(PersonnelBaseArchivesManageEntity entity : entitiesFromDB) {
- hm.put(entity.getUserid(), entity);
- }
- }
- return (PersonnelBaseArchivesManageEntity)hm.get(userid);
- }
- // private void calcuPreTaxMonayAndActMoney(UserWageEntity uw, BigDecimal deductPay) {
- // uw.setPreTaxMone(userWageServiceI.getMoney(uw));
- // uw.setTaxMoney(new BigDecimal(0));
- //
- // uw.setActualMoney(uw.getPreTaxMone());
- //
- // if(uw.getSocialSecurityDebit()!= null && uw.getSocialSecurityDebit().intValue() > 0){
- // uw.setActualMoney(uw.getActualMoney().subtract(uw.getSocialSecurityDebit()));
- // }
- // if(uw.getProvidentFundDebit()!= null && uw.getProvidentFundDebit().intValue() > 0){
- // uw.setActualMoney(uw.getActualMoney().subtract(uw.getProvidentFundDebit()));
- // }
- //
- // uw.setStatus(Globals.ARRANGESTATUS_0.toString());
- // if(deductPay != null && deductPay.intValue() > 0){
- // uw.setOtherDebit(deductPay);
- // uw.setActualMoney(uw.getActualMoney().subtract(deductPay));
- // }else{
- // // 手动核算的时候需要重新计算实发工资,这里其他扣除项取本对象的值即可
- // if(uw.getOtherDebit() != null && uw.getOtherDebit().intValue() >0) {
- // uw.setActualMoney(uw.getActualMoney().subtract(uw.getOtherDebit()));
- // }else {
- // uw.setOtherDebit(new BigDecimal(0));
- // }
- // }
- //
- // }
-
-
- /**
- * 判断当前人是否应该计算工资
- * @param per
- * @param moth
- * @return
- * @throws ParseException
- */
- private boolean getPerWageCalcuStatus(PersonnelBaseArchivesManageEntity per, String moth) throws ParseException {
- if(per == null){
- return false;
- }
-
- if(Globals.JOBSTATUS_0.equals(per.getPositionStatus())) {
- return false;
- }
-
- // if("0000000061459498016145f3f01407cd".equals(per.getUserid())) {
- // System.out.println("0000000061459498016145f3f01407cd");
- // }
- String moth1 = "";
-
- String [] mothArray = moth.split("-");
- moth1 = mothArray[0] + "-" + (Integer.valueOf(mothArray[1]) > 9 ? mothArray[1] : "0" + Integer.valueOf(mothArray[1])) + "-01 00:00:00";
- Date leaveDate = per.getLeaveDate();
- DateFormat df_leave_limit = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Calendar Cal_leave_limit = Calendar.getInstance();
- Cal_leave_limit.setTime(df_leave_limit.parse(moth1));
- if(leaveDate != null && leaveDate.getTime() <= Cal_leave_limit.getTimeInMillis()) {
- //如果离职时间点早于或等于工资结算月1号,不算入工资表中 zy20180420
- return false;
- }
- // //合同开始时间是否在工资计算之内
- Date contractStime = per.getContractStime();
- // 下个月起始,在这个节点之后入职的,不计入工资表
- Calendar cal_contract_limit = Calendar.getInstance();
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- cal_contract_limit.setTime(df.parse(moth1));
- cal_contract_limit.add(Calendar.MONTH, 1);
- if(contractStime.getTime() >= cal_contract_limit.getTimeInMillis()) {
- return false;
- }
-
- return true;
- }
- /**
- * 通过人查询所属项目
- * @param hm_cache
- * @param userid
- * @return
- */
- private String getBybelongId(HashMap<String, HashMap<String, Object>> hm_cache, String userid){
- String temp = "";
- TSUserOrgDto uo = getTSUserOrgWithCache(hm_cache, userid);
-
- TSDepartDto tsDepart = getTSDepartWithCache(hm_cache, uo.getOrg_id());
- TSDepartDto parentDepartDto = getTSDepartWithCache(hm_cache, tsDepart.getParentdepartid());
- if("1".equals(tsDepart.getOrg_type()) || "3".equals(tsDepart.getOrg_type()) || "4".equals(tsDepart.getOrg_type()) || "5".equals(tsDepart.getOrg_type())){
- temp = tsDepart.getId();
- }else if("2".equals(tsDepart.getOrg_type()) && "1".equals(parentDepartDto.getOrg_type())){
- temp = tsDepart.getId();
- }else{
- temp = selectById(hm_cache,tsDepart.getId());
- }
- return temp;
- }
-
- /**
- * @param hm_cache
- * @param userid
- * @return
- */
- private TSUserOrgDto getTSUserOrgWithCache(HashMap<String, HashMap<String, Object>> hm_cache, String userid) {
- HashMap<String, Object> hm = hm_cache.get("getTSUserOrgWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getTSUserOrgWithCache", hm);
- List<TSUserOrgDto> entitiesFromDB = this.getSession().createSQLQuery("select * from t_s_user_org where ifpluralism = 0 and status=0")
- .addScalar("id")
- .addScalar("user_id")
- .addScalar("org_id")
- .addScalar("ifpluralism")
- .setResultTransformer(Transformers.aliasToBean(TSUserOrgDto.class)).list();
- for(TSUserOrgDto entity : entitiesFromDB) {
- hm.put(entity.getUser_id(), entity);
- }
- }
- return (TSUserOrgDto)hm.get(userid);
- }
-
- /**
- * @param hm_cache
- * @param userid
- * @return
- */
- private TSDepartDto getTSDepartWithCache(HashMap<String, HashMap<String, Object>> hm_cache, String departid) {
- HashMap<String, Object> hm = hm_cache.get("getTSDepartWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getTSDepartWithCache", hm);
-
- List<TSDepartDto> entitiesFromDB = this.getSession().createSQLQuery("select * from t_s_depart where status=0")
- .addScalar("id")
- .addScalar("parentdepartid")
- .addScalar("org_type")
- .addScalar("departname")
- .setResultTransformer(Transformers.aliasToBean(TSDepartDto.class)).list();
-
- for(TSDepartDto entity : entitiesFromDB) {
- hm.put(entity.getId(), entity);
- }
- }
- return (TSDepartDto)hm.get(departid);
- }
- private String selectById(HashMap<String, HashMap<String, Object>> hm_cache, String id){
- String temp = "";
-
- TSDepartDto tsDepart = getTSDepartWithCache(hm_cache, id);
- if("3".equals(tsDepart.getOrg_type()) || "5".equals(tsDepart.getOrg_type())){
- temp = tsDepart.getId();
- }else{
- if(tsDepart.getParentdepartid()!= null){
- selectById(hm_cache,tsDepart.getParentdepartid());
- temp = tsDepart.getParentdepartid();
- }
- }
- return temp;
- }
-
- /**
- * 获得stime日期距离当月第一天的天数
- * @param stime 减数
- * @return
- * @throws ParseException
- */
- private static int dateDiff1(Date stime) throws ParseException{
- Calendar cal=Calendar.getInstance();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- cal.setTime(format.parse(format.format(stime)));
-
- //得到上个月的第一天
- Calendar cal_1=Calendar.getInstance();//获取当前日期
- cal_1.add(Calendar.MONTH, -1);
- cal_1.set(Calendar.DAY_OF_MONTH,1);
- // return DateUtils.dateDiff('d', cal, cal_1);
- return daysBetween(format.parse(format.format(cal_1.getTime())), cal.getTime())-1;
- }
-
- /**
- * 相差的天数
- * @param date1 开始时间
- * @param date2 结束时间
- * @return
- */
- public static int daysBetween(Date date1,Date date2){
- Calendar cal = Calendar.getInstance();
- cal.setTime(date1);
- long time1 = cal.getTimeInMillis();
- cal.setTime(date2);
- long time2 = cal.getTimeInMillis();
- long between_days=(time2-time1)/(1000*3600*24);
- return Integer.parseInt(String.valueOf(between_days))+1;
- }
-
- public static void main(String[] args) throws ParseException {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- System.out.println(dateDiff1(sdf.parse("2017-12-10")));
- }
-
- /**
- * 获取某月的天数
- * @param date
- * @return
- * @throws ParseException
- */
- private static int getDaysOfMonth(String date) throws ParseException {
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(format.parse(date));
- return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
- }
-
- /**
- * 获得stime日期距离当月最后一天的天数
- * @param stime 减数
- * @return
- * @throws ParseException
- */
- private static int dateDiff2(Date stime,Date etime) throws ParseException{
- Calendar cal_1=Calendar.getInstance();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- cal_1.setTime(format.parse(format.format(stime)));
-
- Calendar cale = Calendar.getInstance();
- if(etime != null){
- cale.setTime(format.parse(format.format(etime)));
- }else{
- cale.set(Calendar.DAY_OF_MONTH,0);//设置为1号,当前日期既为本月第一天
- }
- // return DateUtils.dateDiff('d', cale, cal_1);
- return daysBetween(cal_1.getTime(),format.parse(format.format(cale.getTime())));
- }
-
- @SuppressWarnings("unchecked")
- private int dateDiff3(Date stime,Date etime)throws ParseException{
- int temp = 0;
- if(stime == null){
- Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.MONTH, -1);
- calendar.set(Calendar.DAY_OF_MONTH, 1);
- stime = calendar.getTime();
- }
-
- if(etime == null){
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.DAY_OF_MONTH, 1);
- calendar.add(Calendar.DATE, -1);
- etime = calendar.getTime();
- }
- StringBuffer str = new StringBuffer();
- str.append("select * from t_bus_calendar where ymd_date >= '"+stime+"' and ymd_date <= '"+etime+"' and dtype != 2");
- List<CalendarEntity> usList = this.getSession().createSQLQuery(str.toString()).addEntity(CalendarEntity.class).list();
- if(!usList.isEmpty()){
- temp = usList.size();
- }
- return temp;
- }
-
- /**
- * 核算入职或离职当月的工资 在职天数:是除了星期六日外的工作日,不考虑节假日 在12月2日确定
- 得到入职时间的年月和上个月的年月,进行比较,是否是上个月入职
- 如果不相等,说明非上个月入职,工资按照基本工资的80%进行计算
- 如果相等,说明是上个月入职,则(基本工资+所有的补贴)/(21.75*8)*实际考勤时长,并且需单独计算工资
- * @param hm_cache
- * @param uw
- * @param us
- * @param uat
- * @param meslList 所有餐补
- * @return
- * @throws ParseException
- */
- private UserWageEntity entryOrLeaveCalculation(boolean isCacheUsed, HashMap<String, HashMap<String, Object>> hm_cache, UserWageEntity uw,UserWagestrategyEntity us,UserAttendanceTotalEntity uat,String month,PersonnelBaseArchivesManageEntity per,List<MealsSubsidyEntity> meslList) throws ParseException{
- //实际出勤时长
- BigDecimal shichang = new BigDecimal(0);
- if(uat.getActualAttendanceDate() != null){
- shichang = uat.getActualAttendanceDate().divide(new BigDecimal(60),3,BigDecimal.ROUND_HALF_UP);
- }
-
- StringBuffer str = new StringBuffer();
- String st = " and status = 0 and delete_flag = 0";
-
- uw.setBasicWage(new BigDecimal(0));
- uw.setDutiesAllowance(new BigDecimal(0));
-
- //基本工资和职务津贴
- if(StringUtils.isNotEmpty(us.getDutiesid())){
- //WagestrategyEntity wa = this.get(WagestrategyEntity.class, us.getDutiesid());
-
- str.delete(0,str.length());
- str.append("select * from t_bus_wagestrategy where dutiesid = '"+per.getBelongDutiesid()+"'");
- str.insert(str.length(), st);
- List<WagestrategyEntity> perobident = null;
- if(isCacheUsed) {
- perobident = getWagestrategyEntityWithCache(hm_cache,per.getBelongDutiesid());
- }else {
- perobident = this.getSession().createSQLQuery(str.toString()).addEntity(WagestrategyEntity.class).list();
- }
- //this.getSession().createSQLQuery(str.toString()).addEntity(WagestrategyEntity.class).list();
- //WagestrategyEntity wa = this.findUniqueByProperty(WagestrategyEntity.class, "dutiesId", per.getBelongDutiesid());//(WagestrategyEntity.class, us.getDutiesid());
- if(perobident != null && !perobident.isEmpty()){
- //需要区分是管理层还是一线员工
- WagestrategyEntity wa = perobident.get(0);
- //uw.setDutiesid(wa.getId());
- if(wa != null){
- //判断是管理层还是一线员工
- if(Globals.MANAGETYPE_2.toString().equals(per.getManagerType())){
- //一线员工:基本工资 = 基本工资/(21.75*8)*实际出勤时长
- BigDecimal bwage = (wa.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP).divide(new BigDecimal(8),3,BigDecimal.ROUND_HALF_UP)).multiply(shichang);
- if(bwage.compareTo(wa.getBasicWage()) < 0) {
- uw.setBasicWage(bwage);
- }else {
- uw.setBasicWage(wa.getBasicWage());
- }
- }else{
- //管理层:基本工资 = 基本工资/(21.75)*在职天数*80%
- if(per.getLeaveDate() != null){
- if(per.getCorrectionDate() != null){
- //判断转正时间和离职时间是否在同一个月
- if(equals(per.getCorrectionDate(), per.getLeaveDate())){
- //管理层:基本工资/当月天数*80%*试用期自然日天数+ 基本工资/当月天数*转正后自然日天数
- /*uw.setBasicWage(wa.getBasicWage().subtract(wa.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.2)).multiply(new BigDecimal(dateDiff3(null,per.getCorrectionDate())))));
- uw.setBasicWage(uw.getBasicWage().add(wa.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff3(per.getCorrectionDate(),per.getLeaveDate())))));*/
- if(equals(per.getCorrectionDate(),per.getContractStime())){
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(daysBetween(per.getContractStime(),per.getCorrectionDate())-1)));
- //uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.8)).multiply(new BigDecimal(daysBetween(per.getContractStime(),per.getCorrectionDate())-1)));
- uw.setBasicWage(uw.getBasicWage().add(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(daysBetween(per.getCorrectionDate(),per.getLeaveDate())))));
- }else{
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff1(per.getCorrectionDate()))));
- //uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.8)).multiply(new BigDecimal(dateDiff1(per.getCorrectionDate()))));
- uw.setBasicWage(uw.getBasicWage().add(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(daysBetween(per.getCorrectionDate(),per.getLeaveDate())))));
- }
- }else{
- //管理层:基本工资/当月天数*在职自然日天数
- //uw.setBasicWage(wa.getBasicWage().subtract(wa.getBasicWage().divide(new BigDecimal(21.75),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.2)).multiply(new BigDecimal(dateDiff1(per.getCorrectionDate())))));
- //uw.setBasicWage(uw.getBasicWage().add(wa.getBasicWage().divide(new BigDecimal(21.75),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff2(per.getCorrectionDate(),null)))));
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff1(per.getLeaveDate()))));
- }
- }else{
- //管理层:基本工资/当月天数*在职自然日天数*80%
- if(equals(per.getLeaveDate(),per.getContractStime())){
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(daysBetween(per.getContractStime(), per.getLeaveDate()))));
- //uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(daysBetween(per.getContractStime(), per.getLeaveDate()))).multiply(new BigDecimal("0.8")));
- }else{
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff1(per.getLeaveDate())+1)));
- //uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff1(per.getLeaveDate())+1)).multiply(new BigDecimal("0.8")));
- }
- }
- }else{
- //管理层:基本工资 = 基本工资/当月天数*在职自然日天数*80%
- if(per.getCorrectionDate() != null){
- if(equals(per.getCorrectionDate(),per.getContractStime())){
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(daysBetween(per.getContractStime(), per.getCorrectionDate())-1)));
- //uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(daysBetween(per.getContractStime(), per.getCorrectionDate())-1)).multiply(new BigDecimal("0.8")));
- uw.setBasicWage(uw.getBasicWage().add(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff2(per.getCorrectionDate(),null)))));
- }else{
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff2(per.getCorrectionDate(),null))));
- //uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff2(per.getCorrectionDate(),null))).multiply(new BigDecimal("0.8")));
- }
- }else{
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff2(per.getContractStime(),null))));
- //uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff2(per.getContractStime(),null))).multiply(new BigDecimal("0.8")));
- }
- //uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff3(per.getContractStime(),null))).multiply(new BigDecimal(0.8)));
- }
- }
- uw.setDutiesAllowance(wa.getSubsidy());
- }
- }
- }
- /*//证书补贴
- if(StringUtils.isNotEmpty(us.getCertificateSubsidyid())){
- String [] certificteStrings = us.getCertificateSubsidyid().split(",");
- BigDecimal bigDecimal = new BigDecimal(0);
- for (int i = 0; i < certificteStrings.length; i++) {
- str.delete(0,str.length());
- str.append("select * from t_bus_certificate_subsidy where id = '"+certificteStrings[i]+"'");
- str.insert(str.length(), st);
- List<CertificateSubsidyEntity> usList = this.getSession().createSQLQuery(str.toString()).addEntity(CertificateSubsidyEntity.class).list();
- //List<CertificateSubsidyEntity> usList = findListbySql(str.toString());
- if(!usList.isEmpty()){
- uw.setCertificateSubsidy(bigDecimal.add(usList.get(0).getSubsidyMoney()).add(uw.getCertificateSubsidy()));
- }
- }
- }else{
- uw.setCertificateSubsidy(new BigDecimal(0));
- }
- //交通补贴
- if(StringUtils.isNotEmpty(us.getTrafficSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_traffic_subsidy where id ='"+us.getTrafficSubsidyid()+"'");
- str.insert(str.length(), st);
- //List<TrafficSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- List<TrafficSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(TrafficSubsidyEntity.class).list();
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uw.setTrafficSubsidy(trafficSubsidyList.get(0).getSubsidyMoney());
- }
- }else{
- uw.setTrafficSubsidy(new BigDecimal(0));
- }
- //高温补贴
- if(StringUtils.isNotEmpty(us.getMegathermalSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_megathermal_subsidy where id ='"+us.getMegathermalSubsidyid()+"'");
- str.insert(str.length(), st);
- //List<MegathermalSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- List<MegathermalSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(MegathermalSubsidyEntity.class).list();
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uw.setMegathermalSubsidy(trafficSubsidyList.get(0).getSubsidyMoney());
- }
- }else{
- uw.setMegathermalSubsidy(new BigDecimal(0));
- }
- //独生子女费
- if(us.getOnlychildPay() != null){
- uw.setOnlyChildCost(us.getOnlychildPay());
- }else{
- uw.setOnlyChildCost(new BigDecimal(0));
- }
- //其他补贴
- if(StringUtils.isNotEmpty(us.getOtherSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_other_subsidy where id ='"+us.getOtherSubsidyid()+"'");
- str.insert(str.length(), st);
- //List<OtherSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- List<OtherSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(OtherSubsidyEntity.class).list();
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uw.setOtherSubsidy(trafficSubsidyList.get(0).getSubsidyMoney());
- }
- }else{
- uw.setOtherSubsidy(new BigDecimal(0));
- }
- //奖金
- uw.setBonus(new BigDecimal(0));
- uw.setProjectPerformance(new BigDecimal(0)); */
-
- //查询基本策略设定值
- uw = selectStrategy(isCacheUsed,hm_cache,us, uw, per);
-
- //加班费计算
- uw = overtimeCalculation(isCacheUsed,hm_cache,uat, us, uw, month,per);
- //餐补
- uw = mealsCalculation(isCacheUsed,hm_cache,uat, us, uw,meslList);
-
- //缺勤扣
- /*if(uat.getAbsenteeismAmount() != null){
- uw.setThingLeaveDebit((uw.getBasicWage().divide(new BigDecimal(21.75),2,BigDecimal.ROUND_HALF_UP)).multiply(uat.getAbsenteeismAmount()));
- }else{
- uw.setThingLeaveDebit(new BigDecimal(0));
- }*/
-
- /*if(Globals.MANAGETYPE_2.toString().equals(per.getManagerType())){
- //病假扣
- if(uat.getSickLeave() != null && uat.getSickLeave().intValue() != 0){
- //协议员工扣除全部费用
- if(Globals.STAFFTYPE_1.toString().equals(per.getUserType())){
- uw.setSickLeaveDebit((uw.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP).divide(new BigDecimal(8),3,BigDecimal.ROUND_HALF_UP).multiply(uat.getSickLeave())));
- }else{
- //病假时长由分钟转小时
- BigDecimal bigs = uat.getSickLeave().divide(new BigDecimal(60),3,BigDecimal.ROUND_HALF_UP);
- //协议员工扣除全部费用
- if(Globals.STAFFTYPE_1.toString().equals(per.getUserType())){
- uw.setSickLeaveDebit(uw.getBasicWage().divide(new BigDecimal(21.75*8),3,BigDecimal.ROUND_HALF_UP).multiply(bigs));
- }else{
- BigDecimal bigDecimal = new BigDecimal(0);
- int sicleave = bigs.divide(new BigDecimal(8),3,BigDecimal.ROUND_HALF_UP).intValue();
- BigDecimal baseBigDecimal = uw.getBasicWage().divide(new BigDecimal(8*21.75),3,BigDecimal.ROUND_HALF_UP).multiply(bigs);
- if(sicleave < 2){
- bigDecimal = baseBigDecimal.multiply(new BigDecimal(0.4));
- }else if(sicleave >= 2 && sicleave < 4){
- bigDecimal = baseBigDecimal.multiply(new BigDecimal(0.3));
- }else if(sicleave >= 4){
- bigDecimal = baseBigDecimal.multiply(new BigDecimal(0.2));
- }
- //一线员工扣除的金额不能高于最低工资的20%
- uw.setSickLeaveDebit((bigDecimal.intValue() >= Globals.BASE_PAY.multiply(new BigDecimal(0.2)).intValue())?Globals.BASE_PAY.multiply(new BigDecimal(0.2)):bigDecimal);
- }
- }
- }else{
- uw.setSickLeaveDebit(new BigDecimal(0));
- }
-
- //事假扣
- if(uat.getThingLeave() != null && uat.getThingLeave().intValue() != 0){
- uw.setThingLeaveDebit(uw.getBasicWage().divide(new BigDecimal(21.75*8),3,BigDecimal.ROUND_HALF_UP).multiply(uat.getThingLeave().divide(new BigDecimal(60),3,BigDecimal.ROUND_HALF_UP)));
- }else{
- uw.setThingLeaveDebit(new BigDecimal(0));
- }
- }else{
- uw.setSickLeaveDebit(new BigDecimal(0));
- uw.setThingLeaveDebit(new BigDecimal(0));
- }
- //缺勤扣
- if(uat.getAbsenteeismAmount() != null && uat.getAbsenteeismAmount().intValue() != 0){
- uw.setAbsenceDebit((uw.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP)).multiply(uat.getAbsenteeismAmount()));
- }else{
- uw.setAbsenceDebit(new BigDecimal(0));
- }*/
-
- //缺勤病假扣事假扣
- uw = deductionCalculation(uat, us, uw, per, false);
-
- //公积金和社保计算
- //2020-05-14 by dgq 如果月中平调,则需要计算社保公积金
- if(isWorkedInNewProjectAfterSameLevelTrans(hm_cache,us,per.getUserid(),month)) {
- uw = socialSecurityProvidentFund(isCacheUsed,hm_cache,uat, us, uw, per);
- }else {
- uw.setSocialSecurityDebit(BigDecimal.ZERO);
- uw.setComSocialSecurityDebit(BigDecimal.ZERO);
- uw.setProvidentFundDebit(BigDecimal.ZERO);
- uw.setComProvidentFundDebit(BigDecimal.ZERO);
- uw.setPaymentSubsidy(BigDecimal.ZERO);
- }
- if(per.getLeaveDate() != null){
- if(!equals(per.getContractStime(), per.getLeaveDate())){
- Calendar calendar1 = Calendar.getInstance();
- calendar1.setTime(per.getLeaveDate());
- int month1 = calendar1.get(Calendar.DAY_OF_MONTH);
- if(month1 > 15){
- uw = aloneCalculation(isCacheUsed,hm_cache,uw, us, per);
- }
- }
- }else{
- Calendar calendar1 = Calendar.getInstance();
- calendar1.setTime(per.getContractStime());
- int month1 = calendar1.get(Calendar.DAY_OF_MONTH);
- if(month1 < 16){
- uw = aloneCalculation(isCacheUsed,hm_cache,uw, us, per);
- }
- }
-
- /*uw.setTaxMoney(userWageServiceI.getMoney(uw));
-
- uw.setActualMoney(uw.getPreTaxMone());
-
- if(uw.getSocialSecurityDebit()!= null && uw.getSocialSecurityDebit().intValue() > 0){
- uw.setActualMoney(uw.getActualMoney().subtract(uw.getSocialSecurityDebit()));
- }
- if(uw.getProvidentFundDebit()!= null && uw.getProvidentFundDebit().intValue() > 0){
- uw.setActualMoney(uw.getActualMoney().subtract(uw.getProvidentFundDebit()));
- }*/
- //------------------------------------------------
- uw.setStatus(Globals.ARRANGESTATUS_0.toString());
- uw.setTaxMoney(new BigDecimal(0));
- if(us.getDeductPay() != null && us.getDeductPay().intValue() > 0){
- uw.setOtherDebit(new BigDecimal(us.getDeductPay().toString()));
- }
-
- // 代扣款
- if(us.getDaikouFee() != null && us.getDaikouFee().doubleValue()> 0){
- uw.setDaikouDebit(us.getDaikouFee());
- }
-
- if(us.getProjectPerformance() != null && us.getProjectPerformance().intValue() > 0) {
- uw.setProjectPerformance(new BigDecimal(us.getProjectPerformance().toString()));
- }
-
- if(uw.getOtherDebit() == null) {
- uw.setOtherDebit(BigDecimal.ZERO);
- }
- if(uw.getDaikouDebit() == null) {
- uw.setDaikouDebit(BigDecimal.ZERO);
- }
- if(uw.getProjectPerformance() == null) {
- uw.setProjectPerformance(BigDecimal.ZERO);
- }
- if(uw.getBonus() == null) {
- uw.setBonus(BigDecimal.ZERO);
- }
-
- if(uw.getReissue() == null) {
- uw.setReissue(new BigDecimal("0"));
- }
- // 参考平调的结算工资重新计算工资项,除了补发调整、缴金之外,其它全部为零
- uw = recalcuSamelevelTransWage(false, isCacheUsed,hm_cache,uw,us,uat,month,per,meslList);
- uw.recalculatePreTaxMoney();
- uw.recalculateActualMoney();
- uw.recalculateComCost();
- return uw;
- }
-
- /**
- * 公积金修改
- * @param hm_cache
- * @param uw
- * @param us
- * @param per
- * @return
- */
- private UserWageEntity aloneCalculation(boolean isCacheUsed,HashMap<String, HashMap<String, Object>> hm_cache, UserWageEntity uw,UserWagestrategyEntity us,PersonnelBaseArchivesManageEntity per){
- StringBuffer str = new StringBuffer();
- String st = " and status = 0 and delete_flag = 0";
- //社保扣除
- if(StringUtils.isNotEmpty(us.getSocialSecurityStrategyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_social_security_strategy where id = '"+us.getSocialSecurityStrategyid()+"'");
- str.insert(str.length(), st);
- SocialSecurityStrategyEntity social = null;
- if(isCacheUsed) {
- social = getSocialSecurityStrategyEntityWithCache(hm_cache,us.getSocialSecurityStrategyid());
- }else {
- List<SocialSecurityStrategyEntity> socialList = this.getSession().createSQLQuery(str.toString()).addEntity(SocialSecurityStrategyEntity.class).list();
- if(socialList != null && socialList.size()>0) {
- social = socialList.get(0);
- }
- }
-
- if(social != null){
- //设置社保单位
- uw.setSocialSecurityId(social.getId());
- uw.setSocialSecurityUnit(social.getSocialSecurityUnit());
- if(Globals.SOCIAL_SECURITY_STRATEGY_HUZHOU.equals(social.getId())) {
- huzhouSocialSecurityCalcu(uw, social);
- }else {
- normalSocialSecurityCalcu(uw, social);
- }
-
- /*uw.setSocialSecurityDebit(meal.getBasePay().multiply(meal.getPersonalBasicRetireInsu()).multiply(meal.getPersionalBasicMedicalInsu()).multiply(meal.getPersonalUnemploymentInsu()));
- uw.setComSocialSecurityDebit(meal.getBasePay().multiply(meal.getCompanyBasicRetireInsu()).multiply(meal.getCompanyBasicMedicalInsu())
- .multiply(meal.getCompanyUnemploymentInsu()).multiply(meal.getCompanyInjuryInsu()).multiply(meal.getCompanyMaternityInsu()));*/
- }
- }else{
- uw.setSocialSecurityDebit(new BigDecimal("0"));
- }
- //公积金扣除
- if(StringUtils.isNotEmpty(us.getProvidentFundStrategyid())){
- // str.delete(0,str.length());
- // str.append("select * from t_bus_provident_fund_strategy where id = '"+us.getProvidentFundStrategyid()+"'");
- // str.insert(str.length(), st);
- ProvidentFundStrategyEntity perobident = getProvidentFundStrategyEntityWithCache(hm_cache, us.getProvidentFundStrategyid());
- // this.getSession().createSQLQuery(str.toString()).addEntity(ProvidentFundStrategyEntity.class).list();
- //List<ProvidentFundStrategyEntity> perobident = findListbySql(str.toString());
- if(perobident != null){
- /*ProvidentFundStrategyEntity meal = perobident.get(0);
- uw.setProvidentFundDebit(meal.getBasePay().multiply(meal.getPersonalRatio()));
- uw.setComProvidentFundDebit(meal.getBasePay().multiply(meal.getCompanyRatio()));*/
- ProvidentFundStrategyEntity meal = perobident;
- //uw.setProvidentFundDebit(meal.getBasePay().multiply(meal.getPersonalRatio().multiply(new BigDecimal(0.01))));
- uw.setProvidentFundDebit(meal.getBasePay().multiply(meal.getPersonalRatio().multiply(new BigDecimal("0.01"))).setScale(0,BigDecimal.ROUND_HALF_UP));
- //uw.setComProvidentFundDebit(meal.getBasePay().multiply(meal.getCompanyRatio().multiply(new BigDecimal(0.01))));
- uw.setComProvidentFundDebit(meal.getBasePay().multiply(meal.getCompanyRatio().multiply(new BigDecimal("0.01"))).setScale(0,BigDecimal.ROUND_HALF_UP));
- }
- }else{
- uw.setProvidentFundDebit(new BigDecimal("0"));
- }
- //缴金补贴
- BigDecimal jiaojin_subsidy = us.getJiaojinSubsidyid();
- // zy20180428 如果工资策略里没有设定缴金补贴,则按照原始缴扣进行补贴.否则按照工资策略补贴
- if(jiaojin_subsidy == null) {
- uw.setPaymentSubsidy(uw.getSocialSecurityDebit().add(uw.getProvidentFundDebit()));
- }else {
- uw.setPaymentSubsidy(new BigDecimal(us.getJiaojinSubsidyid().toString()));
- }
-
- return uw;
- }
- /**
- * @param uw
- * @param social
- */
- private void huzhouSocialSecurityCalcu(UserWageEntity uw, SocialSecurityStrategyEntity social) {
- BigDecimal perInsu = BigDecimal.ZERO;
- perInsu = perInsu.add(social.getPersonalBasicRetireInsu().multiply(new BigDecimal("0.01")));
- perInsu = perInsu.add(social.getPersionalBasicMedicalInsu().multiply(new BigDecimal("0.01")));
- perInsu = perInsu.add(social.getPersonalUnemploymentInsu().multiply(new BigDecimal("0.01")));
- BigDecimal perResult = BigDecimal.ZERO;
- perResult = social.getBasePay().multiply(perInsu);
- uw.setSocialSecurityDebit(perResult.setScale(1,BigDecimal.ROUND_HALF_UP));
-
- BigDecimal comInsu = BigDecimal.ZERO;
- BigDecimal comResult = BigDecimal.ZERO;
-
- comInsu = comInsu.add(social.getCompanyBasicRetireInsu().multiply(new BigDecimal("0.01")));
- comInsu = comInsu.add(social.getCompanyBasicMedicalInsu().multiply(new BigDecimal("0.01")));
- comInsu = comInsu.add(social.getCompanyUnemploymentInsu().multiply(new BigDecimal("0.01")));
- comInsu = comInsu.add(social.getCompanyInjuryInsu().multiply(new BigDecimal("0.01")));
- comInsu = comInsu.add(social.getCompanyMaternityInsu().multiply(new BigDecimal("0.01")));
-
- comResult = comInsu.multiply(social.getBasePay());
- uw.setComSocialSecurityDebit(comResult.setScale(2,BigDecimal.ROUND_HALF_UP));
- }
- private void normalSocialSecurityCalcu(UserWageEntity uw, SocialSecurityStrategyEntity meal) {
- /**
- * 社保个人金额:
- 中间各项目计算结果:直接进位,保留1位小数;
- 合计:直接进位,保留1位小数;
- */
- uw.setSocialSecurityDebit(new BigDecimal("0"));
- uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersonalBasicRetireInsu().multiply(new BigDecimal("0.01"))).setScale(1,BigDecimal.ROUND_UP)));
- uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersionalBasicMedicalInsu().multiply(new BigDecimal("0.01"))).setScale(1,BigDecimal.ROUND_UP)));
- uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersonalUnemploymentInsu().multiply(new BigDecimal("0.01"))).setScale(1,BigDecimal.ROUND_UP)));
- uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().setScale(1,BigDecimal.ROUND_UP));
- /**
- * 社保单位金额:
- * 中间各项目计算结果:四舍五入,保留4位小数;
- * 合计:四舍五入,保留4位小数;
- */
- uw.setComSocialSecurityDebit(new BigDecimal("0"));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyBasicRetireInsu().multiply(new BigDecimal("0.01"))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyBasicMedicalInsu().multiply(new BigDecimal("0.01"))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyUnemploymentInsu().multiply(new BigDecimal("0.01"))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyInjuryInsu().multiply(new BigDecimal("0.01"))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyMaternityInsu().multiply(new BigDecimal("0.01"))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().setScale(2,BigDecimal.ROUND_HALF_UP));
- }
-
- /**
- * 得到当前年月
- * @return
- */
- private String getMonthlys(){
- Calendar cal = Calendar.getInstance();
- int year = cal.get(Calendar.YEAR);
- int month = cal.get(Calendar.MONTH);
- if(month < 10){
- if(month == 0){
- year = year - 1;
- month = 12;
- }else{
- // month = Integer.valueOf(0+""+month);
- return year + "-" + 0 + "" + month;
- }
- }
- return year+"-"+month;
- }
-
- /** ----------------------------废弃的方法 by zhijia.wang--------------------------
- * 判断上个月是否为入职或离职
- * @param us
- * @return
- * @throws ParseException
- */
- /* private boolean entryOrLeave(UserWagestrategyEntity us,PersonnelBaseArchivesManageEntity per) throws ParseException{
- boolean isOrNot = true;
- if(per.getContractStime() != null){
- Calendar cal_1=Calendar.getInstance();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- Date stime = per.getContractStime();
- cal_1.setTime(format.parse(format.format(stime)));
-
- int year = cal_1.get(Calendar.YEAR);
- int month = cal_1.get(Calendar.MONTH)+1;
-
- Calendar cal_2 = Calendar.getInstance();//获取当前日期
- cal_2.add(Calendar.MONTH, -1);
- cal_2.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
-
- int year1 = cal_2.get(Calendar.YEAR);
- int month1 = cal_2.get(Calendar.MONTH)+1;
- if(year == year1 && month == month1){
- isOrNot = false;
- return isOrNot;
-
- }
- }
-
- //离职同入职原理相同
- if(per.getLeaveDate() != null){
- Calendar cal_1=Calendar.getInstance();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- Date stime = per.getLeaveDate();
- cal_1.setTime(format.parse(format.format(stime)));
-
- int year = cal_1.get(Calendar.YEAR);
- int month = cal_1.get(Calendar.MONTH)+1;
-
- Calendar cal_2 = Calendar.getInstance();//获取当前日期
- cal_2.add(Calendar.MONTH, -1);
- cal_2.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
-
- int year1 = cal_2.get(Calendar.YEAR);
- int month1 = cal_2.get(Calendar.MONTH)+1;
- if(year == year1 && month == month1){
- isOrNot = false;
- return isOrNot;
- }
- }
-
- return isOrNot;
- }*/
-
-
- /**
- * 判断是否当月入职或离职或者如果当月入职或离职,是否干满一个整月
- * @author zhijia.wang
- * @param hm_cache
- * @date 2018-03-09 14:55:20
- * @param us
- * @param moth
- * @return
- * @throws ParseException
- */
- private boolean isCompleteMonthWage(HashMap<String, HashMap<String, Object>> hm_cache, UserWagestrategyEntity us,PersonnelBaseArchivesManageEntity per, String moth) throws ParseException{
- YearMonthDay entryDate = getEntryDate(per.getContractStime());
- YearMonthDay leaveDate = getLeaveDate(per.getLeaveDate());
- // 工资月月初时间
- Calendar cal_1 = Calendar.getInstance();// 获取当前日期
- cal_1.add(Calendar.MONTH, -1);// 设置为上个月(工资月)
- cal_1.set(Calendar.DAY_OF_MONTH,1);// 设置为1号
- int year = cal_1.get(Calendar.YEAR);
- int month = cal_1.get(Calendar.MONTH)+1;
- //int firstday = cal_1.get(Calendar.DATE);
-
- // 工资月月末时间
- Calendar cal_2 = Calendar.getInstance();// 获取当前日期
- cal_2.add(Calendar.MONTH, -1);// 设置为上个月(工资月)
- cal_2.set(Calendar.DATE, cal_2.getActualMaximum(Calendar.DATE));// 设置为最后一天
- int year2 = cal_1.get(Calendar.YEAR);
- int month2 = cal_1.get(Calendar.MONTH)+1;
- int lastday = cal_2.get(Calendar.DATE);
-
- //判断离职
- if(leaveDate != null) {
- int leave_year = leaveDate.getYear();
- int leave_month = leaveDate.getMonth();
- int leave_day = leaveDate.getDay();
- if(year == leave_year && month == leave_month){
- if(leave_day != lastday){//如果不是最后一天离职
- return false;
- }
- }
- }
-
- // 判断入职
- if(entryDate != null){
- int enrty_year = entryDate.getYear();
- int enrty_month = entryDate.getMonth();
- int enrty_day = entryDate.getDay();
- if(year == enrty_year && month == enrty_month){
- if(enrty_day == 1){//如果是1号入职
- // 判断离职
- if(leaveDate != null){
- int leave_year = leaveDate.getYear();
- int leave_month = leaveDate.getMonth();
- int leave_day = leaveDate.getDay();
- if(year == leave_year && month == leave_month){
- if(leave_day != lastday){//如果不是最后一天离职
- return false;
- }
- }
-
- }
- }else{
- return false;
- }
- }
- }
- // 月中调入的,月中调入的,算作是非整月
- if(isWorkedInNewProjectAfterSameLevelTrans(hm_cache,us,per.getUserid(),moth)){
- return false;
- }
-
- return true;
- }
-
- private List<TBusActivitiSamelevelTransferEntity> getTBusActivitiSamelevelTransferEntityWithCache(HashMap<String, HashMap<String, Object>> hm_cache,String userid, String moth) {
- HashMap<String, Object> hm = null;
- if(hm_cache != null) {
- hm = hm_cache.get("getTBusActivitiSamelevelTransferEntityWithCache");
- }
-
- if(hm == null) {
- hm = new HashMap<>();
- if(hm_cache != null) {
- hm_cache.put("getTBusActivitiSamelevelTransferEntityWithCache", hm);
- }
-
- StringBuffer str = new StringBuffer();
- str.append("select * from t_bus_activiti_samelevel_transfer where (wage_yearmonth = '"+moth+"' or wage_yearmonth_last = '"+moth+"') and bpm_status = '3'");
- List<TBusActivitiSamelevelTransferEntity> usList = this.getSession().createSQLQuery(str.toString()).addEntity(TBusActivitiSamelevelTransferEntity.class).list();
-
- for(TBusActivitiSamelevelTransferEntity entity : usList) {
- String userInEntity = entity.getUserid();
- String userAndMonth = userInEntity + entity.getWageYearmonth();
- String userAndLastMonth = userInEntity + entity.getWageYearmonthLast();
- if(hm.containsKey(userAndMonth)) {
- List<TBusActivitiSamelevelTransferEntity> entitylist = (List<TBusActivitiSamelevelTransferEntity>)hm.get(userAndMonth);
- entitylist.add(entity);
- }else {
- List<TBusActivitiSamelevelTransferEntity> newlist = new ArrayList<>();
- newlist.add(entity);
- hm.put(userAndMonth, newlist);
- }
-
- if(hm.containsKey(userAndLastMonth)) {
- List<TBusActivitiSamelevelTransferEntity> entitylist = (List<TBusActivitiSamelevelTransferEntity>)hm.get(userAndLastMonth);
- entitylist.add(entity);
- }else {
- List<TBusActivitiSamelevelTransferEntity> newlist = new ArrayList<>();
- newlist.add(entity);
- hm.put(userAndLastMonth, newlist);
- }
- }
- }
- return (List<TBusActivitiSamelevelTransferEntity>)hm.get(userid+moth);
- }
-
- /**
- *
- * @param hm_cache
- * @param us
- * @param userid
- * @param moth
- * @return
- */
- private boolean isWorkedInNewProjectAfterSameLevelTrans(HashMap<String, HashMap<String, Object>> hm_cache,UserWagestrategyEntity us,String userid, String moth) {
- List<TBusActivitiSamelevelTransferEntity> samelevelTransferEntities
- = getTBusActivitiSamelevelTransferEntityWithCache(hm_cache, userid, moth);
- if(samelevelTransferEntities != null && samelevelTransferEntities.size()>0) {
- // 查询一下调入项目和月份
- for(TBusActivitiSamelevelTransferEntity entity : samelevelTransferEntities) {
- if(us.getBelongUnitid().equals(entity.getInUnitid()) && moth.equals(entity.getWageYearmonth())) {
- return true;
- }
- }
- }
- return false;
- }
-
- // 获取入职日期
- private YearMonthDay getEntryDate(Date contractStime) throws ParseException{
- if(contractStime != null){
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- Calendar cal_1 = Calendar.getInstance();//获取当前日期
- cal_1.setTime(sdf.parse(sdf.format(contractStime)));
- int year = cal_1.get(Calendar.YEAR);
- int month = cal_1.get(Calendar.MONTH)+1;
- int day = cal_1.get(Calendar.DATE);
- return new YearMonthDay(year, month, day);
- }
- return null;
- }
-
- // 获取离职日期
- private YearMonthDay getLeaveDate(Date leaveDate) throws ParseException{
- if(leaveDate != null){
- Calendar cal_1 = Calendar.getInstance();//获取当前日期
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- cal_1.setTime(sdf.parse(sdf.format(leaveDate)));
- int year = cal_1.get(Calendar.YEAR);
- int month = cal_1.get(Calendar.MONTH)+1;
- int day = cal_1.get(Calendar.DATE);
- return new YearMonthDay(year, month, day);
- }
- return null;
- }
-
- /**
- * 判断是否在同一年并且同一个月
- * @param date1
- * @param date2
- * @return
- */
- private static boolean equals(Date date1, Date date2) {
- Calendar calendar1 = Calendar.getInstance();
- calendar1.setTime(date1);
- Calendar calendar2 = Calendar.getInstance();
- calendar2.setTime(date2);
- return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH);
- }
-
- /**
- * 判断是否为上个月转正
- * @param us
- * @return
- * @throws ParseException
- */
- private boolean isCorrection(UserWagestrategyEntity us) throws ParseException{
- boolean isOrNot = true;
- PersonnelBaseArchivesManageEntity per = findUniqueByProperty(PersonnelBaseArchivesManageEntity.class,"userid",us.getUserid());
- if(per.getCorrectionDate() != null){
- Calendar cal_1=Calendar.getInstance();
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- Date stime = per.getCorrectionDate();
- cal_1.setTime(format.parse(format.format(stime)));
-
- int year = cal_1.get(Calendar.YEAR);
- int month = cal_1.get(Calendar.MONTH)+1;
-
- Calendar cal_2 = Calendar.getInstance();//获取当前日期
- cal_2.add(Calendar.MONTH, -1);
- cal_2.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
-
- int year1 = cal_2.get(Calendar.YEAR);
- int month1 = cal_2.get(Calendar.MONTH)+1;
- if(year == year1 && month == month1){
- isOrNot = false;
- return isOrNot;
- }
- }
- return isOrNot;
- }
-
- /**
- * 查询基本工资
- * @param isCacheUsed
- * @param hm_cache
- * @param idString
- * @param uw
- * @return
- * @throws ParseException
- */
- private UserWageEntity enactmentCalculation(boolean isCacheUsed, HashMap<String, HashMap<String, Object>> hm_cache, UserWagestrategyEntity us,UserWageEntity uw,PersonnelBaseArchivesManageEntity per) throws ParseException{
- StringBuffer str = new StringBuffer();
- String st = " and status = 0 and delete_flag = 0";
-
- uw.setBasicWage(new BigDecimal(0));
- uw.setDutiesAllowance(new BigDecimal(0));
-
-
- // debug用的代码
- /*if(us.getUserid().equals("000000006120dd1c01612cf52463023a") || us.getUserid().equals("ff808081616fd75e016182890f5100f2") || us.getUserid().equals("ff8080816184236c016187d295691831")){
- System.out.println(us.getUserid());
- }
- if(uw.getUserid().equals("000000006120dd1c01612cf52463023a") || uw.getUserid().equals("ff808081616fd75e016182890f5100f2") || uw.getUserid().equals("ff8080816184236c016187d295691831")){
- System.out.println(uw.getUserid());
- }
- if(per.getUserid().equals("000000006120dd1c01612cf52463023a") || per.getUserid().equals("ff808081616fd75e016182890f5100f2") || per.getUserid().equals("ff8080816184236c016187d295691831")){
- System.out.println(per.getUserid());
- }*/
-
-
- //基本工资和职务津贴
- // if(StringUtils.isNotEmpty(us.getDutiesid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_wagestrategy where dutiesid = '"+per.getBelongDutiesid()+"'");
- str.insert(str.length(), st);
- List<WagestrategyEntity> perobident = null;
-
- if(isCacheUsed) {
- perobident = getWagestrategyEntityWithCache(hm_cache,per.getBelongDutiesid());
- }else {
- perobident = this.getSession().createSQLQuery(str.toString()).addEntity(WagestrategyEntity.class).list();
- }
- //WagestrategyEntity wa = this.findUniqueByProperty(WagestrategyEntity.class, "dutiesId", per.getBelongDutiesid());//(WagestrategyEntity.class, us.getDutiesid());
- if(perobident != null && !perobident.isEmpty()){
- WagestrategyEntity wa = perobident.get(0);
- if(wa != null){
- uw.setDutiesid(wa.getId());
-
- //判断转正日期是否在上个月,如果在,
- //本月应发基本工资 = 基本工资 - 本月应扣除试用期工资【基本工资/21.75*20%*试用期天数(自然日)】
- //如果不在,就为基本工资
- uw.setBasicWage(wa.getBasicWage());
- /*if(Globals.MANAGETYPE_2.toString().equals(per.getManagerType())){
- uw.setBasicWage(wa.getBasicWage());
- }else{
- //是否上个月转正
- if(isCorrection(us)){
- if(Globals.JOBSTATUS_1.equals(per.getPositionStatus())){
- uw.setBasicWage(wa.getBasicWage().multiply(new BigDecimal(0.8)));
- }else{
- uw.setBasicWage(wa.getBasicWage());
- }
-
-
- }else{
- uw.setBasicWage(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.8)).multiply(new BigDecimal(dateDiff1(per.getCorrectionDate()))));
- uw.setBasicWage(uw.getBasicWage().add(wa.getBasicWage().divide(new BigDecimal(getDaysOfMonth(getMonthlys()+"-01")),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff2(per.getCorrectionDate(),null)))));
- //管理层:基本工资 = 基本工资 - (基本工资/(21.75)*在职天数*20%)
- //uw.setBasicWage(wa.getBasicWage());
-
- //uw.setBasicWage(wa.getBasicWage().subtract(wa.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.2)).multiply(new BigDecimal(dateDiff1(per.getCorrectionDate())))));
- //uw.setBasicWage(uw.getBasicWage().add(wa.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(dateDiff2(per.getCorrectionDate(),null)))));
- }
- }*/
- uw.setDutiesAllowance(wa.getSubsidy());
- }
- }
- // }
- /*//证书补贴
- if(StringUtils.isNotEmpty(us.getCertificateSubsidyid())){
- String [] certificteStrings = us.getCertificateSubsidyid().split(",");
- BigDecimal bigDecimal = new BigDecimal(0);
- for (int i = 0; i < certificteStrings.length; i++) {
- str.delete(0,str.length());
- str.append("select * from t_bus_certificate_subsidy where id = '"+certificteStrings[i]+"'");
- str.insert(str.length(), st);
- List<CertificateSubsidyEntity> usList = this.getSession().createSQLQuery(str.toString()).addEntity(CertificateSubsidyEntity.class).list();
- //List<CertificateSubsidyEntity> usList = findListbySql(str.toString());
- if(!usList.isEmpty()){
- bigDecimal = usList.get(0).getSubsidyMoney().add(bigDecimal);
- }
- }
- uw.setCertificateSubsidy(bigDecimal);
- }else{
- uw.setCertificateSubsidy(new BigDecimal(0));
- }
- //交通补贴
- if(StringUtils.isNotEmpty(us.getTrafficSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_traffic_subsidy where id ='"+us.getTrafficSubsidyid()+"'");
- str.insert(str.length(), st);
- List<TrafficSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(TrafficSubsidyEntity.class).list();
- //List<TrafficSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uw.setTrafficSubsidy(trafficSubsidyList.get(0).getSubsidyMoney());
- }
- }else{
- uw.setTrafficSubsidy(new BigDecimal(0));
- }
- //高温补贴
- if(StringUtils.isNotEmpty(us.getMegathermalSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_megathermal_subsidy where id ='"+us.getMegathermalSubsidyid()+"'");
- str.insert(str.length(), st);
- List<MegathermalSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(MegathermalSubsidyEntity.class).list();
- //List<MegathermalSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uw.setMegathermalSubsidy(trafficSubsidyList.get(0).getSubsidyMoney());
- }
- }else{
- uw.setMegathermalSubsidy(new BigDecimal(0));
- }
- //独生子女费
- if(us.getOnlychildPay() != null && us.getOnlychildPay().intValue() > 0){
- uw.setOnlyChildCost(us.getOnlychildPay());
- }else{
- uw.setOnlyChildCost(new BigDecimal(0));
- }
- //其他补贴
- if(StringUtils.isNotEmpty(us.getOtherSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_other_subsidy where id ='"+us.getOtherSubsidyid()+"'");
- str.insert(str.length(), st);
- List<OtherSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(OtherSubsidyEntity.class).list();
- //List<OtherSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- if(us.getAppendPay() != null && us.getAppendPay().intValue() > 0 ){
- uw.setOtherSubsidy(us.getAppendPay().add(trafficSubsidyList.get(0).getSubsidyMoney()));
- }else{
- uw.setOtherSubsidy(trafficSubsidyList.get(0).getSubsidyMoney());
- }
- }
- }else{
- if(us.getAppendPay() != null && us.getAppendPay().intValue() > 0 ){
- uw.setOtherSubsidy(us.getAppendPay());
- }else{
- uw.setOtherSubsidy(new BigDecimal(0));
- }
- }
- //奖金
- uw.setBonus(new BigDecimal(0));
- uw.setProjectPerformance(new BigDecimal(0));*/
- return uw;
- }
-
- /**
- * @param hm_cache
- * @param belongDutiesid
- * @return
- */
- private List<WagestrategyEntity> getWagestrategyEntityWithCache(HashMap<String, HashMap<String, Object>> hm_cache,
- String belongDutiesid) {
- HashMap<String, Object> hm = hm_cache.get("getWagestrategyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getWagestrategyEntityWithCache", hm);
- StringBuffer str = new StringBuffer();
- str.append("select * from t_bus_wagestrategy where status = 0 and delete_flag = 0");
- List<WagestrategyEntity> entitiesFromDB = this.getSession().createSQLQuery(str.toString()).addEntity(WagestrategyEntity.class).list();
-
- for(WagestrategyEntity entity : entitiesFromDB) {
- String userInEntity = entity.getDutiesId();
- if(hm.containsKey(userInEntity)) {
- List<WagestrategyEntity> entitylist = (List<WagestrategyEntity>)hm.get(userInEntity);
- entitylist.add(entity);
- }else {
- List<WagestrategyEntity> newlist = new ArrayList<>();
- newlist.add(entity);
- hm.put(userInEntity, newlist);
- }
- }
- }
- return (List<WagestrategyEntity>)hm.get(belongDutiesid);
- }
- /**
- * 查询基本策略设定值
- * @param isCacheUsed
- * @param us
- * @param uw
- * @param per
- * @return
- */
- private UserWageEntity selectStrategy(boolean isCacheUsed, HashMap<String, HashMap<String, Object>> hm_cache,UserWagestrategyEntity us,UserWageEntity uw,PersonnelBaseArchivesManageEntity per){
- // StringBuffer str = new StringBuffer();
- // String st = "and status = 0 and delete_flag = 0";
- //
- // String certiSql = "select * from t_bus_certificate_subsidy where id in (select certificateid from t_bus_user_certificate where userid='"+uw.getUserid()+"' and delete_flag = 0) and status = 0 and delete_flag = 0";
- // List<CertificateSubsidyEntity> usList = this.getSession().createSQLQuery(certiSql).addEntity(CertificateSubsidyEntity.class).list();
-
- // //证书补贴
- // if(StringUtils.isNotEmpty(us.getCertificateSubsidyid())){
- // String [] certificteStrings = us.getCertificateSubsidyid().split(",");
- // BigDecimal bigDecimal = new BigDecimal(0);
- // for (int i = 0; i < certificteStrings.length; i++) {
- // str.delete(0,str.length());
- // str.append("select * from t_bus_certificate_subsidy where id = '"+certificteStrings[i]+"'");
- // str.insert(str.length(), st);
- // List<CertificateSubsidyEntity> usList = this.getSession().createSQLQuery(str.toString()).addEntity(CertificateSubsidyEntity.class).list();
- // //List<CertificateSubsidyEntity> usList = findListbySql(str.toString());
- // if(!usList.isEmpty()){
- // bigDecimal = usList.get(0).getSubsidyMoney().add(bigDecimal);
- // }
- // }
- // uw.setCertificateSubsidy(bigDecimal);
- // }else{
- // uw.setCertificateSubsidy(new BigDecimal(0));
- // }
- BigDecimal bigDecimal = getCertificateSubsidyEntityWithCache(hm_cache,uw.getUserid());
- uw.setCertificateSubsidy(BigDecimal.ZERO);
- if(bigDecimal != null){
- uw.setCertificateSubsidy(bigDecimal);
- }
-
- //交通补贴
- if(StringUtils.isNotEmpty(us.getTrafficSubsidyid())){
- // str.delete(0,str.length());
- // str.append("select * from t_bus_traffic_subsidy where id ='"+us.getTrafficSubsidyid()+"'");
- // str.insert(str.length(), st);
- // List<TrafficSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(TrafficSubsidyEntity.class).list();
- TrafficSubsidyEntity trafficSubsidyList = getTrafficSubsidyEntityWithCache(hm_cache,us.getTrafficSubsidyid());
- //List<TrafficSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uw.setTrafficSubsidy(trafficSubsidyList.getSubsidyMoney());
- }
- }else{
- uw.setTrafficSubsidy(new BigDecimal(0));
- }
- //高温补贴
- if(StringUtils.isNotEmpty(us.getMegathermalSubsidyid())){
- // str.delete(0,str.length());
- // str.append("select * from t_bus_megathermal_subsidy where id ='"+us.getMegathermalSubsidyid()+"'");
- // str.insert(str.length(), st);
- // List<MegathermalSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(MegathermalSubsidyEntity.class).list();
-
- MegathermalSubsidyEntity trafficSubsidyList = getMegathermalSubsidyEntityWithCache(hm_cache,us.getMegathermalSubsidyid());
- //List<MegathermalSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uw.setMegathermalSubsidy(trafficSubsidyList.getSubsidyMoney());
- }
- }else{
- uw.setMegathermalSubsidy(new BigDecimal(0));
- }
- //独生子女费
- if(us.getOnlychildPay() != null && us.getOnlychildPay().intValue() > 0){
- uw.setOnlyChildCost(us.getOnlychildPay());
- }else{
- uw.setOnlyChildCost(new BigDecimal(0));
- }
- //其他补贴
- if(StringUtils.isNotEmpty(us.getOtherSubsidyid())){
- // str.delete(0,str.length());
- // str.append("select * from t_bus_other_subsidy where id ='"+us.getOtherSubsidyid()+"'");
- // str.insert(str.length(), st);
- // List<OtherSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(OtherSubsidyEntity.class).list();
- //List<OtherSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- OtherSubsidyEntity trafficSubsidyList = getOtherSubsidyEntityWithCache(hm_cache,us.getOtherSubsidyid());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- if(us.getAppendPay() != null && us.getAppendPay().intValue() > 0 ){
- uw.setOtherSubsidy(us.getAppendPay().add(trafficSubsidyList.getSubsidyMoney()));
- }else{
- uw.setOtherSubsidy(trafficSubsidyList.getSubsidyMoney());
- }
- }
- }else{
- if(us.getAppendPay() != null && us.getAppendPay().intValue() > 0 ){
- uw.setOtherSubsidy(us.getAppendPay());
- }else{
- uw.setOtherSubsidy(new BigDecimal(0));
- }
- }
- //奖金
- // uw.setBonus(new BigDecimal(0));
- // uw.setProjectPerformance(new BigDecimal(0));
-
- return uw;
- }
-
-
- /**
- * @param hm_cache
- * @param otherSubsidyid
- * @return
- */
- private OtherSubsidyEntity getOtherSubsidyEntityWithCache(HashMap<String, HashMap<String, Object>> hm_cache,
- String otherSubsidyid) {
- HashMap<String, Object> hm = hm_cache.get("getOtherSubsidyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getOtherSubsidyEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(OtherSubsidyEntity.class);
- specialcq.eq("deleteFlag", "0");
- specialcq.add();
- specialcq.eq("status", "0");
- specialcq.add();
- List<OtherSubsidyEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(OtherSubsidyEntity entity : entitiesFromDB) {
- hm.put(entity.getId(), entity);
- }
- }
- return (OtherSubsidyEntity)hm.get(otherSubsidyid);
- }
- /**
- * @param hm_cache
- * @param megathermalSubsidyid
- * @return
- */
- private MegathermalSubsidyEntity getMegathermalSubsidyEntityWithCache(
- HashMap<String, HashMap<String, Object>> hm_cache, String megathermalSubsidyid) {
- // TODO Auto-generated method stub
- HashMap<String, Object> hm = hm_cache.get("getMegathermalSubsidyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getMegathermalSubsidyEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(MegathermalSubsidyEntity.class);
- specialcq.eq("deleteFlag", "0");
- specialcq.add();
- specialcq.eq("status", "0");
- specialcq.add();
- List<MegathermalSubsidyEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(MegathermalSubsidyEntity entity : entitiesFromDB) {
- hm.put(entity.getId(), entity);
- }
- }
- return (MegathermalSubsidyEntity)hm.get(megathermalSubsidyid);
- }
- /**
- * @param string
- * @param hm_cache
- * @param trafficSubsidyid
- * @return
- */
- private TrafficSubsidyEntity getTrafficSubsidyEntityWithCache(HashMap<String, HashMap<String, Object>> hm_cache,String trafficSubsidyid) {
- // TODO Auto-generated method stub
- // str.delete(0,str.length());
- // str.append("select * from t_bus_traffic_subsidy where id ='"+us.getTrafficSubsidyid()+"'");
- // str.insert(str.length(), st);
- // List<TrafficSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(TrafficSubsidyEntity.class).list();
- HashMap<String, Object> hm = hm_cache.get("getTrafficSubsidyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getTrafficSubsidyEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(TrafficSubsidyEntity.class);
- specialcq.eq("deleteFlag", "0");
- specialcq.add();
- specialcq.eq("status", "0");
- specialcq.add();
- List<TrafficSubsidyEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(TrafficSubsidyEntity entity : entitiesFromDB) {
- hm.put(entity.getId(), entity);
- }
- }
- return (TrafficSubsidyEntity)hm.get(trafficSubsidyid);
- }
-
- private OvertimeDto getSpecialOvertimeSumEntityWithCache(HashMap<String, HashMap<String, Object>> hm_cache,
- String userid, String yearmonth) {
- HashMap<String, Object> hm = hm_cache.get("getSpecialOvertimeEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getSpecialOvertimeEntityWithCache", hm);
- OvertimeDto dtoIn = new OvertimeDto();
- dtoIn.setYearMonth(yearmonth);
- List<OvertimeDto> overtimeDtos = overtimeService.getOverTimeFees(dtoIn);
-
- if(overtimeDtos != null && overtimeDtos.size()>0) {
- for(OvertimeDto dtoDb : overtimeDtos) {
- String userInEntity = dtoDb.getUserid();
- BigDecimal overtimeFee = BigDecimal.ZERO;
- BigDecimal mealFee = BigDecimal.ZERO;
-
- if(dtoDb != null && dtoDb.getOvertimeFee() != null) {
- overtimeFee = dtoDb.getOvertimeFee();
- }
- if(dtoDb != null && dtoDb.getMealFee() != null) {
- mealFee = dtoDb.getMealFee();
- }
- if(hm.containsKey(userInEntity)) {
- if(hm.get(userInEntity) != null ) {
- OvertimeDto oldDto = (OvertimeDto)hm.get(userInEntity);
- BigDecimal oldDtoovertimeFee = oldDto.getOvertimeFee() == null ? BigDecimal.ZERO : oldDto.getOvertimeFee();
- BigDecimal oldDtomealFee = oldDto.getMealFee() == null ? BigDecimal.ZERO : oldDto.getMealFee();
- oldDto.setOvertimeFee(overtimeFee.add(oldDtoovertimeFee));
- oldDto.setMealFee(mealFee.add(oldDtomealFee));
- hm.put(userInEntity, oldDto);
- }
- }else {
- if(overtimeFee == null) {
- overtimeFee = BigDecimal.ZERO;
- }
- if(mealFee == null) {
- mealFee = BigDecimal.ZERO;
- }
- OvertimeDto newDto = new OvertimeDto();
- newDto.setOvertimeFee(overtimeFee);
- newDto.setMealFee(mealFee);
- hm.put(userInEntity, newDto);
- }
- }
- }
- }
- return (OvertimeDto)hm.get(userid);
- }
- /**
- * @param hm_cache
- * @param userid
- * @return
- */
- private BigDecimal getCertificateSubsidyEntityWithCache(HashMap<String, HashMap<String, Object>> hm_cache,
- String userid) {
- // StringBuffer str = new StringBuffer();
- // String st = "and status = 0 and delete_flag = 0";
- //
- // String certiSql = "select * from t_bus_certificate_subsidy where id in (select certificateid from t_bus_user_certificate where userid='"+uw.getUserid()+"' and delete_flag = 0) and status = 0 and delete_flag = 0";
- // List<CertificateSubsidyEntity> usList = this.getSession().createSQLQuery(certiSql).addEntity(CertificateSubsidyEntity.class).list();
- // BigDecimal bigDecimal = new BigDecimal(0);
-
-
- HashMap<String, Object> hm = hm_cache.get("getCertificateSubsidyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getCertificateSubsidyEntityWithCache", hm);
- StringBuffer str_certificate = new StringBuffer();
- str_certificate.append("select * from t_bus_user_certificate where delete_flag = 0");
- List<UserCertificateEntity> entitiesUserCertificateEntity = this.getSession().createSQLQuery(str_certificate.toString()).addEntity(UserCertificateEntity.class).list();
-
- String str_subsidy = "select * from t_bus_certificate_subsidy where delete_flag = 0 and status=0";
- List<CertificateSubsidyEntity> subList = this.getSession().createSQLQuery(str_subsidy).addEntity(CertificateSubsidyEntity.class).list();
- HashMap<String, CertificateSubsidyEntity> subMap = new HashMap<>();
- for(CertificateSubsidyEntity sub : subList) {
- subMap.put(sub.getId(), sub);
- }
-
- for(UserCertificateEntity certificateEntity : entitiesUserCertificateEntity) {
- String userInEntity = certificateEntity.getUserid();
- String certInEntity = certificateEntity.getCertificateid();
- CertificateSubsidyEntity subEntity = subMap.get(certInEntity);
- BigDecimal subMoney = BigDecimal.ZERO;
-
- if(subEntity != null && subEntity.getSubsidyMoney() != null) {
- subMoney = subEntity.getSubsidyMoney();
- }
- if(hm.containsKey(userInEntity)) {
- BigDecimal old = BigDecimal.ZERO;
- if((BigDecimal)hm.get(userInEntity) != null ) {
- old = (BigDecimal)hm.get(userInEntity);
- }
- hm.put(userInEntity, subMoney.add(old));
- }else {
- if(subMoney == null) {
- subMoney = BigDecimal.ZERO;
- }
- hm.put(userInEntity, subMoney);
- }
- }
- }
- return (BigDecimal)hm.get(userid);
- }
- /**
- * 将从数据库中读取的字符串信息转化成实体类
- * @author hualong.zhao
- * @date 2017-11-29
- * @param jsonobjString
- * @return
- */
- private AttendanceDetailJsonObj getJsonObjFromString(String jsonobjString) {
- AttendanceDetailJsonObj jsonObj = new AttendanceDetailJsonObj();
- if (oConvertUtils.isNotEmpty(jsonobjString)) {
- try {
- jsonObj = (JSONObject.parseObject(jsonobjString)).toJavaObject(AttendanceDetailJsonObj.class);
- } catch (Exception e) {
- }
-
- }
- return jsonObj;
- }
-
- /**
- * 餐费补助
- * @param hm_cache
- * @param us
- * @param uw
- * @return
- */
- private UserWageEntity mealsCalculation(boolean isCacheUsed,HashMap<String, HashMap<String, Object>> hm_cache, UserAttendanceTotalEntity uat,UserWagestrategyEntity us,UserWageEntity uw,List<MealsSubsidyEntity> meslList){
- uw.setMealsSubsidyDay(new BigDecimal(0));
- uw.setMealsSubsidyNight(new BigDecimal(0));
- uw.setMealsSubsidy(new BigDecimal(0));
- if(uat != null){
- List<UserAttendanceDetailEntity> adeList = null;
- if(isCacheUsed) {
- adeList = getUserAttendanceDetailEntityWithCache(hm_cache, uat);
- }else {
- adeList = findByProperty(UserAttendanceDetailEntity.class, "attendanceId", uat.getId());
- }
- //findByProperty(UserAttendanceDetailEntity.class, "attendanceId", uat.getId());
- if(adeList != null && !adeList.isEmpty()){
-
- for (UserAttendanceDetailEntity ade : adeList) {
- AttendanceDetailJsonObj jsonObj = getJsonObjFromString(oConvertUtils.getString(ade.getJsonObj()));
- for (MealsSubsidyEntity mse : meslList) {
- //夜班白班津贴
- if(jsonObj.getDayShiftSubsidy() != null && jsonObj.getDayShiftSubsidy().intValue() > 0){
- if(mse.getId().equals(jsonObj.getDayShiftSubsidyId())){
- uw.setMealsSubsidyDay(uw.getMealsSubsidyDay().add(mse.getSubsidyMoney().multiply(new BigDecimal(jsonObj.getDayShiftSubsidy()))));
- }
- }
- //夜班夜班津贴
- if(jsonObj.getNightShiftSubsidy() != null && jsonObj.getNightShiftSubsidy().intValue() > 0){
- if(mse.getId().equals(jsonObj.getNightShiftSubsidyId())){
- uw.setMealsSubsidyNight(uw.getMealsSubsidyNight().add(mse.getSubsidyMoney().multiply(new BigDecimal(jsonObj.getNightShiftSubsidy()))));
- }
- }
- //日班
- if(jsonObj.getDayShift() != null && jsonObj.getDayShift().intValue() > 0){
- if(mse.getId().equals(jsonObj.getDayShiftId())){
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(mse.getSubsidyMoney().multiply(new BigDecimal(jsonObj.getDayShift()))));
- }
- }
- //常班
- if(jsonObj.getRegularShift() != null && jsonObj.getRegularShift().intValue() > 0){
- if(mse.getId().equals(jsonObj.getRegularShiftId())){
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(mse.getSubsidyMoney().multiply(new BigDecimal(jsonObj.getRegularShift()))));
- }
- }
- //值班
- if(jsonObj.getDutyShift() != null && jsonObj.getDutyShift().intValue() > 0){
- if(mse.getId().equals(jsonObj.getDutyShiftId())){
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(mse.getSubsidyMoney().multiply(new BigDecimal(jsonObj.getDutyShift()))));
- }
- }
- }
- }
- }
-
- /*StringBuffer str = new StringBuffer();
- String st = " and status = 0 and delete_flag = 0";*/
- /*UserAttendanceDetailEntity entity = get(UserAttendanceDetailEntity.class, uat.getId());
- AttendanceDetailJsonObj jsonObj = getJsonObjFromString(oConvertUtils.getString(entity.getJsonObj()));*/
- //AttendanceDetailJsonObj json = userAttendanceDetailService.getJsonObjFromString(uat.getJsonObj());
-
- //餐补白班津贴 state
- //--author:zhaohualong-----start----date: 2017年12月19日--------for:需要修改------
- /*if(json != null &&json.getDayShiftSubsidyMoney() != null && json.getDayShiftSubsidyMoney().intValue() > 0){
- uw.setMealsSubsidyDay(json.getDayShiftSubsidyMoney());
- }else{
- uw.setMealsSubsidyDay(new BigDecimal(0));
- }*/
-
- /*if(uat.getDayShiftSubsidy() != null && uat.getDayShiftSubsidy() != 0){
- str.delete(0,str.length());
- str.append("select * from t_bus_meals_subsidy where shift_subsidy_type = '"+Globals.SHIFT_SUBSIDY_TYPE_BAIBANJINTIEZAO.toString()+"'");
- str.insert(str.length(), st);
- List<MealsSubsidyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(MealsSubsidyEntity.class).list();
- //List<MealsSubsidyEntity> mealList = findListbySql(str.toString());
- MealsSubsidyEntity meal = mealList.get(0);
- uw.setMealsSubsidyDay(new BigDecimal(uat.getDayShiftSubsidy()).multiply(meal.getSubsidyMoney()));
- }else{
- uw.setMealsSubsidyDay(new BigDecimal(0));
- }*/
- //餐补白班津贴 end
-
- //餐补夜班津贴 state
- //--author:zhaohualong-----start----date: 2017年12月19日--------for:需要修改------
-
- /*if(json != null &&json.getNightShiftSubsidyMoney() != null && json.getNightShiftSubsidyMoney().intValue() > 0){
- uw.setMealsSubsidyNight(json.getNightShiftSubsidyMoney());
- }else{
- uw.setMealsSubsidyNight(new BigDecimal(0));
- }*/
-
- /*if(uat.getNightShiftSubsidy() != null && uat.getNightShiftSubsidy() != 0){
- str.delete(0,str.length());
- str.append("select * from t_bus_meals_subsidy where shift_subsidy_type = '"+Globals.SHIFT_SUBSIDY_TYPE_YEBANJINTIEWAN.toString()+"'");
- str.insert(str.length(), st);
- List<MealsSubsidyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(MealsSubsidyEntity.class).list();
- //List<MealsSubsidyEntity> mealList = findListbySql(str.toString());
- MealsSubsidyEntity meal = mealList.get(0);
- uw.setMealsSubsidyNight(new BigDecimal(uat.getNightShiftSubsidy()).multiply(meal.getSubsidyMoney()));
- }else{
- uw.setMealsSubsidyNight(new BigDecimal(0));
- }*/
- //餐补夜班津贴 end
-
- //餐费补助 state
- //日班
- //uw.setMealsSubsidy(new BigDecimal(0));
- //--author:zhaohualong-----start----date: 2017年12月19日--------for:需要修改------
-
- /*if(json != null &&json.getDayShiftMoney() != null && json.getDayShiftMoney().intValue() > 0){
- uw.setMealsSubsidy(json.getDayShiftMoney());
- }*/
- /*if(uat.getDayShift() != null && uat.getDayShift() != 0){
- str.delete(0,str.length());
- str.append("select * from t_bus_meals_subsidy where shift_subsidy_type = '"+Globals.SHIFT_SUBSIDY_TYPE_RIBAN.toString()+"'");
- str.insert(str.length(), st);
- List<MealsSubsidyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(MealsSubsidyEntity.class).list();
- //List<MealsSubsidyEntity> mealList = findListbySql(str.toString());
- MealsSubsidyEntity meal = mealList.get(0);
- uw.setMealsSubsidy(new BigDecimal(uat.getDayShift()).multiply(meal.getSubsidyMoney()));
- }*/
- //常班
- //--author:zhaohualong-----start----date: 2017年12月19日--------for:需要修改------
-
- /*if(json != null &&json.getRegularShiftMoney() != null && json.getRegularShiftMoney().intValue() > 0){
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(json.getRegularShiftMoney()));
- }*/
-
- /*if(uat.getRegularShift() != null && uat.getRegularShift() != 0){
- str.delete(0,str.length());
- str.append("select * from t_bus_meals_subsidy where shift_subsidy_type = '"+Globals.SHIFT_SUBSIDY_TYPE_CHANGBAN.toString()+"'");
- str.insert(str.length(), st);
- List<MealsSubsidyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(MealsSubsidyEntity.class).list();
- //List<MealsSubsidyEntity> mealList = findListbySql(str.toString());
- MealsSubsidyEntity meal = mealList.get(0);
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(new BigDecimal(uat.getRegularShift()).multiply(meal.getSubsidyMoney())));
- }*/
- //额外加班并且选有每月每次加班餐补
- /*if(uat.getExtraOvertime() != null && uat.getExtraOvertime() != 0){
- if(StringUtils.isNotEmpty(us.getNofixedmealsSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_meals_subsidy where id = '"+us.getNofixedmealsSubsidyid()+"'");
- str.insert(str.length(), st);
- List<MealsSubsidyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(MealsSubsidyEntity.class).list();
- //List<MealsSubsidyEntity> mealList = findListbySql(str.toString());
- if(!mealList.isEmpty() && mealList.size() > 0){
- MealsSubsidyEntity meal = mealList.get(0);
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(new BigDecimal(uat.getExtraOvertime()).multiply(meal.getSubsidyMoney())));
- }
- }
- }*/
-
- if("0".equals(us.getStrategyType())){
- uw.setMealsSubsidy(new BigDecimal(0));
- //每月固定餐补
- if(StringUtils.isNotEmpty(us.getFixedmealsSubsidyid())){
- /*str.delete(0,str.length());
- str.append("select * from t_bus_meals_subsidy where id = '"+us.getFixedmealsSubsidyid()+"'");
- str.insert(str.length(), st);
- List<MealsSubsidyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(MealsSubsidyEntity.class).list();
- //List<MealsSubsidyEntity> mealList = findListbySql(str.toString());
- if(!mealList.isEmpty() && mealList.size() > 0){
- MealsSubsidyEntity meal = mealList.get(0);
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(meal.getSubsidyMoney()));
- }*/
-
- for (MealsSubsidyEntity mse : meslList) {
- if(us.getFixedmealsSubsidyid().equals(mse.getId())){
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(mse.getSubsidyMoney()));
- }
- if(uat.getExtraOvertime() != null && uat.getExtraOvertime().intValue() > 0 && StringUtils.isNotEmpty(us.getNofixedmealsSubsidyid())){
- if(us.getNofixedmealsSubsidyid().equals(mse.getId())){
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(mse.getSubsidyMoney()).multiply(new BigDecimal(uat.getExtraOvertime())));
- }
- }
- }
- uw.setMealsSubsidyDay(new BigDecimal(0));
- uw.setMealsSubsidyNight(new BigDecimal(0));
- }
- }else{
- BigDecimal big = new BigDecimal(0);
- for (MealsSubsidyEntity mse : meslList) {
- if(uat.getExtraOvertime() != null && uat.getExtraOvertime().intValue() > 0 && StringUtils.isNotEmpty(us.getNofixedmealsSubsidyid())){
- if(us.getNofixedmealsSubsidyid().equals(mse.getId())){
- big = mse.getSubsidyMoney().multiply(new BigDecimal(uat.getExtraOvertime()));
- //uw.setMealsSubsidy(uw.getMealsSubsidy().add(mse.getSubsidyMoney()).multiply(new BigDecimal(uat.getExtraOvertime())));
- }
- }
- }
- uw.setMealsSubsidy(uw.getMealsSubsidy().add(big));
- }
- }
- //适配加班申请中的餐费部分
- OvertimeDto overtimedto = getSpecialOvertimeSumEntityWithCache(hm_cache, us.getUserid(), uat.getYearmonth());
- if(overtimedto != null) {
- BigDecimal mealFee = overtimedto.getMealFee();
- if(mealFee != null) {
- BigDecimal mealSub = uw.getMealsSubsidy();
- if(mealSub != null) {
- mealSub = mealSub.add(mealFee);
- uw.setMealsSubsidy(mealSub);
- }
- }
- }
- //餐费补助 end
- return uw;
- }
- /**
- * @param hm_cache
- * @param id
- * @return
- */
- private List<UserAttendanceDetailEntity> getUserAttendanceDetailEntityWithCache(
- HashMap<String, HashMap<String, Object>> hm_cache, UserAttendanceTotalEntity uat) {
- // TODO Auto-generated method stub
- //findByProperty(UserAttendanceDetailEntity.class, "attendanceId", uat.getId());
- HashMap<String, Object> hm = hm_cache.get("getUserAttendanceDetailEntityWithCache");
- String month = uat.getYearmonth();
-
- List<UserAttendanceDetailEntity> list = null;
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getUserAttendanceDetailEntityWithCache", hm);
-
- String hql = "from UserAttendanceDetailEntity where ymd_date like '" +month+"%'";
- List<UserAttendanceDetailEntity> entitiesFromDB = findHql(hql);
- for(UserAttendanceDetailEntity entity : entitiesFromDB) {
- String userInEntity = entity.getAttendanceId();
- if(hm.containsKey(userInEntity)) {
- List<UserAttendanceDetailEntity> entitylist = (List<UserAttendanceDetailEntity>)hm.get(userInEntity);
- entitylist.add(entity);
- }else {
- List<UserAttendanceDetailEntity> newlist = new ArrayList<>();
- newlist.add(entity);
- hm.put(userInEntity, newlist);
- }
- }
- }
- return (List<UserAttendanceDetailEntity>)hm.get(uat.getId());
- }
- public AttendanceTotalJsonObj getTotalJsonObjFromString(String jsonobjString) {
- AttendanceTotalJsonObj jsonObj = new AttendanceTotalJsonObj();
- if (oConvertUtils.isNotEmpty(jsonobjString)) {
- try {
- jsonObj = (JSONObject.parseObject(jsonobjString)).toJavaObject(AttendanceTotalJsonObj.class);
- } catch (Exception e) {
- }
-
- }
- return jsonObj;
- }
- /**
- * 工资扣除事项
- * @param uat
- * @param us
- * @param uw
- * @param flag 是否考勤扣:true扣除,false不扣除
- * @return
- */
- private UserWageEntity deductionCalculation(UserAttendanceTotalEntity uat,UserWagestrategyEntity us,UserWageEntity uw,PersonnelBaseArchivesManageEntity per, boolean flag){
- if(uat == null){
- uw.setSickLeaveDebit(new BigDecimal(0));
- uw.setThingLeaveDebit(new BigDecimal(0));
- uw.setAbsenceDebit(new BigDecimal(0));
- }else{
- if(Globals.MANAGETYPE_2.toString().equals(per.getManagerType())){
- //按照合同年限来扣除病假 zy20180417
- calcuSickLeaveDebit(uat, uw, per);
- // if(jsonObj != null && jsonObj.getSickLeavetotalmins() != null && jsonObj.getSickLeavetotalmins().intValue() != 0){
- //
- // //病假时长由分钟转小时
- // BigDecimal bigs = jsonObj.getSickLeavetotalmins().divide(new BigDecimal(60),3,BigDecimal.ROUND_HALF_UP);
- // //协议员工扣除全部费用
- // if(Globals.STAFFTYPE_1.toString().equals(per.getUserType())){
- // uw.setSickLeaveDebit((Globals.BASE_PAY.divide(new BigDecimal(21.75*8),3,BigDecimal.ROUND_HALF_UP).multiply(bigs)));
- // }else{
- // BigDecimal bigDecimal = new BigDecimal(0);
- // int sicleave = bigs.divide(new BigDecimal(8),3,BigDecimal.ROUND_HALF_UP).intValue();
- // BigDecimal baseBigDecimal = uw.getBasicWage().divide(new BigDecimal(8*21.75),3,BigDecimal.ROUND_HALF_UP).multiply(bigs);
- // if(sicleave < 2){
- // bigDecimal = baseBigDecimal.multiply(new BigDecimal(0.4));
- // }else if(sicleave >= 2 && sicleave < 4){
- // bigDecimal = baseBigDecimal.multiply(new BigDecimal(0.3));
- // }else if(sicleave >= 4){
- // bigDecimal = baseBigDecimal.multiply(new BigDecimal(0.2));
- // }
- // //一线员工扣除的金额不能高于最低工资的20%
- // uw.setSickLeaveDebit((bigDecimal.intValue() >= Globals.BASE_PAY.multiply(new BigDecimal(0.2)).intValue())?Globals.BASE_PAY.multiply(new BigDecimal(0.2)):bigDecimal);
- // }
- // }else{
- // uw.setSickLeaveDebit(new BigDecimal(0));
- // }
-
- //事假扣
- if(flag){
- if(uat.getThingLeave() != null && uat.getThingLeave().intValue() != 0){
- if(uat.getTimeoutOvertimeDuration().compareTo(BigDecimal.ZERO) >=0) {
- // 超时加班工时大于等于零=实际工时已经扣除了事假时长,故不再扣除事假扣
- uw.setThingLeaveDebit(new BigDecimal(0));
- }else {
- // 超时工时小于零,说明超时工时不够抵扣事假。那么不扣超时加班费,但是要扣事假扣除和缺勤扣除
- uw.setThingLeaveDebit((uw.getBasicWage().divide(new BigDecimal(21.75*8),3,BigDecimal.ROUND_HALF_UP)).multiply(uat.getThingLeave().divide(new BigDecimal(60),3,BigDecimal.ROUND_HALF_UP)));
- }
- }else{
- uw.setThingLeaveDebit(new BigDecimal(0));
- }
- }else{
- uw.setThingLeaveDebit(new BigDecimal(0));
- }
-
- //缺勤扣
- if(flag){
- if(uat.getAbsenteeismAmount() != null && uat.getAbsenteeismAmount().intValue() != 0){
- if(uat.getTimeoutOvertimeDuration().compareTo(BigDecimal.ZERO) >=0) {
- // 超时加班工时大于等于零=实际工时已经扣除了缺勤时长,故不再扣除缺勤扣
- uw.setAbsenceDebit(new BigDecimal(0));
- }else {
- // 超时工时小于零,说明超时工时不够抵扣缺勤。那么不扣超时加班费,但是要扣事假扣除和缺勤扣除
- uw.setAbsenceDebit((uw.getBasicWage().divide(new BigDecimal(21.75*8),3,BigDecimal.ROUND_HALF_UP)).multiply(uat.getAbsenteeismAmount()).divide(new BigDecimal(60),3,BigDecimal.ROUND_HALF_UP));
- }
- }else{
- uw.setAbsenceDebit(new BigDecimal(0));
- }
- }else{
- uw.setAbsenceDebit(new BigDecimal(0));
- }
- }else{
- uw.setSickLeaveDebit(new BigDecimal(0));
- uw.setThingLeaveDebit(new BigDecimal(0));
- uw.setAbsenceDebit(new BigDecimal(0));
- }
-
-
- }
-
- /*//社保扣除
- if(StringUtils.isNotEmpty(us.getSocialSecurityStrategyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_social_security_strategy where id = '"+us.getSocialSecurityStrategyid()+"'");
- str.insert(str.length(), st);
- List<SocialSecurityStrategyEntity> social = this.getSession().createSQLQuery(str.toString()).addEntity(SocialSecurityStrategyEntity.class).list();
- //List<SocialSecurityStrategyEntity> social = findListbySql(str.toString());
- if(!social.isEmpty() && social.size() > 0){
- SocialSecurityStrategyEntity meal = social.get(0);
- //multiply(meal.getPersonalBasicRetireInsu().add(meal.getPersionalBasicMedicalInsu().add(meal.getPersonalUnemploymentInsu()))).multiply(new BigDecimal(0.01))
- *//**
- * 社保个人金额:
- 中间各项目计算结果:四舍五入,保留1位小数;
- 合计:四舍五入,保留1位小数;
- *//*
- uw.setSocialSecurityDebit(new BigDecimal(0));
- uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersonalBasicRetireInsu().multiply(new BigDecimal(0.01))).setScale(1,BigDecimal.ROUND_HALF_UP)));
- uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersionalBasicMedicalInsu().multiply(new BigDecimal(0.01))).setScale(1,BigDecimal.ROUND_HALF_UP)));
- uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersonalUnemploymentInsu().multiply(new BigDecimal(0.01))).setScale(1,BigDecimal.ROUND_HALF_UP)));
- *//**
- * 社保单位金额:
- * 中间各项目计算结果:四舍五入,保留4位小数;
- * 合计:四舍五入,保留4位小数;
- *//*
- uw.setComSocialSecurityDebit(new BigDecimal(0));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyBasicRetireInsu().multiply(new BigDecimal(0.01))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyBasicMedicalInsu().multiply(new BigDecimal(0.01))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyUnemploymentInsu().multiply(new BigDecimal(0.01))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyInjuryInsu().multiply(new BigDecimal(0.01))).setScale(4,BigDecimal.ROUND_HALF_UP)));
- uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyMaternityInsu().multiply(new BigDecimal(0.01))).setScale(4,BigDecimal.ROUND_HALF_UP)));
-
- uw.setComSocialSecurityDebit(meal.getBasePay().multiply(meal.getCompanyBasicRetireInsu().add(meal.getCompanyBasicMedicalInsu())
- .add(meal.getCompanyUnemploymentInsu()).add(meal.getCompanyInjuryInsu()).add(meal.getCompanyMaternityInsu())).multiply(new BigDecimal(0.01)));
- }else{
- uw.setSocialSecurityDebit(new BigDecimal(0));
- }
- }else{
- uw.setSocialSecurityDebit(new BigDecimal(0));
- }
- //公积金扣除
- if(StringUtils.isNotEmpty(us.getProvidentFundStrategyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_provident_fund_strategy where id = '"+us.getProvidentFundStrategyid()+"'");
- str.insert(str.length(), st);
- List<ProvidentFundStrategyEntity> perobident = this.getSession().createSQLQuery(str.toString()).addEntity(ProvidentFundStrategyEntity.class).list();
- //List<ProvidentFundStrategyEntity> perobident = findListbySql(str.toString());
- if(!perobident.isEmpty() && perobident.size() > 0){
- ProvidentFundStrategyEntity meal = perobident.get(0);
- //uw.setProvidentFundDebit(meal.getBasePay().multiply(meal.getPersonalRatio().multiply(new BigDecimal(0.01))));
- uw.setProvidentFundDebit(meal.getBasePay().multiply(meal.getPersonalRatio().multiply(new BigDecimal(0.01))).setScale(0,BigDecimal.ROUND_HALF_UP));
- //uw.setComProvidentFundDebit(meal.getBasePay().multiply(meal.getCompanyRatio().multiply(new BigDecimal(0.01))));
- uw.setComProvidentFundDebit(meal.getBasePay().multiply(meal.getCompanyRatio().multiply(new BigDecimal(0.01))).setScale(0,BigDecimal.ROUND_HALF_UP));
- }else{
- uw.setProvidentFundDebit(new BigDecimal(0));
- }
- }else{
- uw.setProvidentFundDebit(new BigDecimal(0));
- }
- //缴金补贴
- if(Globals.MANAGETYPE_2.toString().equals(per.getManagerType())){
- uw.setPaymentSubsidy(uw.getSocialSecurityDebit().add(uw.getProvidentFundDebit()));
- }else{
- uw.setPaymentSubsidy(new BigDecimal(0));
- }*/
- return uw;
- }
- /**按照合同年限来扣除病假 zy20180417
- * @param uat
- * @param uw
- * @param per
- */
- private void calcuSickLeaveDebit(UserAttendanceTotalEntity uat, UserWageEntity uw,
- PersonnelBaseArchivesManageEntity per) {
- AttendanceTotalJsonObj jsonObj = getTotalJsonObjFromString (uat.getJsonObj());
- //病假扣
- //按照合同年限来扣除病假 zy20180417
- if(jsonObj != null && jsonObj.getSickLeavetotalmins() != null && jsonObj.getSickLeavetotalmins().intValue() != 0){
- BigDecimal sickDebit = BigDecimal.ZERO;
- BigDecimal multiRate = BigDecimal.ZERO;
- //获取工作年限
- int workYear = getWorkYears(uw,per);
- //获取员工基本工资
- BigDecimal basewage = uw.getBasicWage();
- //病假时长由分钟转小时
- BigDecimal bigs = jsonObj.getSickLeavetotalmins().divide(new BigDecimal(60),3,BigDecimal.ROUND_HALF_UP);
- multiRate = basewage.divide(new BigDecimal(21.75*8),3,BigDecimal.ROUND_HALF_UP).multiply(bigs);
- //协议员工扣除全部费用
- if(Globals.STAFFTYPE_1.toString().equals(per.getUserType())){
- uw.setSickLeaveDebit(multiRate);
- }else{
-
- if(workYear < 2){
- sickDebit = multiRate.multiply(new BigDecimal(0.4));
- }else if(workYear >= 2 && workYear < 4){
- sickDebit = multiRate.multiply(new BigDecimal(0.3));
- }else if(workYear >= 4 && workYear < 10){
- sickDebit = multiRate.multiply(new BigDecimal(0.2));
- }else if(workYear >= 10){
- sickDebit = BigDecimal.ZERO;
- }
-
- //一线员工扣除的金额不能高于最低工资的20%
- BigDecimal limit = basewage.multiply(new BigDecimal(0.2));
- if(sickDebit.compareTo(limit)<=0) {
- uw.setSickLeaveDebit(sickDebit);
- }else {
- uw.setSickLeaveDebit(limit);
- }
- }
- }else{
- uw.setSickLeaveDebit(new BigDecimal(0));
- }
- }
-
- /**
- * 返回工作年限
- * @param uw
- * @param per
- * @return
- */
- private int getWorkYears(UserWageEntity uw, PersonnelBaseArchivesManageEntity per) {
- try {
- Date startDate = per.getContractStime();
- Calendar startCalendar = Calendar.getInstance();
- Calendar endCalendar = Calendar.getInstance();
-
- String monthly = uw.getMonthly();
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-
- Date nowdate = sdf.parse(monthly+"-01");
-
- endCalendar.setTime(nowdate);
-
- endCalendar.add(Calendar.MONTH, 1);
- // 获取工资月份最后一天
- endCalendar.add(Calendar.DAY_OF_MONTH, -1);
- startCalendar.setTime(startDate);
- if (endCalendar.compareTo(startCalendar) < 0) {
- return 0;
- }
- int day = endCalendar.get(Calendar.DAY_OF_MONTH)
- - startCalendar.get(Calendar.DAY_OF_MONTH);
- int month = endCalendar.get(Calendar.MONTH)
- - startCalendar.get(Calendar.MONTH);
- int year = endCalendar.get(Calendar.YEAR)
- - startCalendar.get(Calendar.YEAR);
- if (day < 0) {
- month--;
- }
- if (month < 0) {
- month += 12;
- year--;
- }
- if(year > 0) {
- return year;
- }
- } catch (Exception e) {
- }
- return 0;
- }
-
- // private UserWageEntity comCost(UserAttendanceTotalEntity uat
- // ,UserWagestrategyEntity us,UserWageEntity uw,PersonnelBaseArchivesManageEntity per){
- // BigDecimal result = BigDecimal.ZERO;
- // if(uw.getPreTaxMone() != null) {
- // result = result.add(uw.getPreTaxMone());
- // }
- // if(uw.getComSocialSecurityDebit() != null) {
- // result = result.add(uw.getComSocialSecurityDebit());
- // }
- // if(uw.getComProvidentFundDebit() != null) {
- // result = result.add(uw.getComProvidentFundDebit());
- // }
- // return uw;
- // }
-
- /**
- * 查询社保和公积金
- * @param hm_cache
- * @param uat
- * @param us
- * @param uw
- * @param per
- * @return
- */
- private UserWageEntity socialSecurityProvidentFund(boolean isCacheUsed, HashMap<String, HashMap<String, Object>> hm_cache, UserAttendanceTotalEntity uat,UserWagestrategyEntity us,UserWageEntity uw,PersonnelBaseArchivesManageEntity per){
- StringBuffer str = new StringBuffer();
- String st = " and status = 0 and delete_flag = 0";
- //社保扣除
- if(StringUtils.isNotEmpty(us.getSocialSecurityStrategyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_social_security_strategy where id = '"+us.getSocialSecurityStrategyid()+"'");
- str.insert(str.length(), st);
- // List<SocialSecurityStrategyEntity> social = this.getSession().createSQLQuery(str.toString()).addEntity(SocialSecurityStrategyEntity.class).list();
- //List<SocialSecurityStrategyEntity> social = findListbySql(str.toString());
- SocialSecurityStrategyEntity social = null;
- if(isCacheUsed) {
- social = getSocialSecurityStrategyEntityWithCache(hm_cache,us.getSocialSecurityStrategyid());
- }else {
- List<SocialSecurityStrategyEntity> socialList = this.getSession().createSQLQuery(str.toString()).addEntity(SocialSecurityStrategyEntity.class).list();
- if(socialList != null && socialList.size()>0) {
- social = socialList.get(0);
- }
- }
-
- if(social != null){
- SocialSecurityStrategyEntity meal = social;
- uw.setSocialSecurityId(meal.getId());
- uw.setSocialSecurityUnit(meal.getSocialSecurityUnit());
- //multiply(meal.getPersonalBasicRetireInsu().add(meal.getPersionalBasicMedicalInsu().add(meal.getPersonalUnemploymentInsu()))).multiply(new BigDecimal(0.01))
-
- if(Globals.SOCIAL_SECURITY_STRATEGY_HUZHOU.equals(social.getId())) {
- huzhouSocialSecurityCalcu(uw, social);
- }else {
- normalSocialSecurityCalcu(uw, social);
- }
-
- // /**
- // * 社保个人金额:
- // 中间各项目计算结果:直接进位,保留1位小数;
- // 合计:直接进位,保留1位小数;
- // */
- // uw.setSocialSecurityDebit(new BigDecimal(0));
- // uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersonalBasicRetireInsu().multiply(new BigDecimal(0.01))).setScale(1,BigDecimal.ROUND_UP)));
- // uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersionalBasicMedicalInsu().multiply(new BigDecimal(0.01))).setScale(1,BigDecimal.ROUND_UP)));
- // uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getPersonalUnemploymentInsu().multiply(new BigDecimal(0.01))).setScale(1,BigDecimal.ROUND_UP)));
- // //合计值保留一位
- // uw.setSocialSecurityDebit(uw.getSocialSecurityDebit().setScale(1,BigDecimal.ROUND_UP));
- // /**
- // * 社保单位金额:
- // * 中间各项目计算结果:四舍五入,保留3位小数;
- // * 合计:四舍五入,保留2位小数;
- // */
- // uw.setComSocialSecurityDebit(new BigDecimal(0));
- // uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyBasicRetireInsu().multiply(new BigDecimal(0.01))).setScale(3,BigDecimal.ROUND_HALF_UP)));
- // uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyBasicMedicalInsu().multiply(new BigDecimal(0.01))).setScale(3,BigDecimal.ROUND_HALF_UP)));
- // uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyUnemploymentInsu().multiply(new BigDecimal(0.01))).setScale(3,BigDecimal.ROUND_HALF_UP)));
- // uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyInjuryInsu().multiply(new BigDecimal(0.01))).setScale(3,BigDecimal.ROUND_HALF_UP)));
- // uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().add(meal.getBasePay().multiply(meal.getCompanyMaternityInsu().multiply(new BigDecimal(0.01))).setScale(3,BigDecimal.ROUND_HALF_UP)));
- // uw.setComSocialSecurityDebit(uw.getComSocialSecurityDebit().setScale(2,BigDecimal.ROUND_HALF_UP));
- /*uw.setComSocialSecurityDebit(meal.getBasePay().multiply(meal.getCompanyBasicRetireInsu().add(meal.getCompanyBasicMedicalInsu())
- .add(meal.getCompanyUnemploymentInsu()).add(meal.getCompanyInjuryInsu()).add(meal.getCompanyMaternityInsu())).multiply(new BigDecimal(0.01)));*/
- }else{
- uw.setSocialSecurityDebit(new BigDecimal(0));
- uw.setComSocialSecurityDebit(new BigDecimal(0));
- }
- }else{
- uw.setSocialSecurityDebit(new BigDecimal(0));
- uw.setComSocialSecurityDebit(new BigDecimal(0));
- }
- //公积金扣除
- if(StringUtils.isNotEmpty(us.getProvidentFundStrategyid())){
- ProvidentFundStrategyEntity perobident = null;
- if(isCacheUsed) {
- perobident = getProvidentFundStrategyEntityWithCache(hm_cache, us.getProvidentFundStrategyid());
- }else {
- str.delete(0,str.length());
- str.append("select * from t_bus_provident_fund_strategy where id = '"+us.getProvidentFundStrategyid()+"'");
- str.insert(str.length(), st);
- List<ProvidentFundStrategyEntity> perobidentList = this.getSession().createSQLQuery(str.toString()).addEntity(ProvidentFundStrategyEntity.class).list();
- if(perobidentList != null && perobidentList.size()>0) {
- perobident = perobidentList.get(0);
- }
- }
-
- if(perobident != null){
- ProvidentFundStrategyEntity meal = perobident;
- //uw.setProvidentFundDebit(meal.getBasePay().multiply(meal.getPersonalRatio().multiply(new BigDecimal(0.01))));
- uw.setProvidentFundDebit(meal.getBasePay().multiply(meal.getPersonalRatio().multiply(new BigDecimal(0.01))).setScale(0,BigDecimal.ROUND_HALF_UP));
- //uw.setComProvidentFundDebit(meal.getBasePay().multiply(meal.getCompanyRatio().multiply(new BigDecimal(0.01))));
- uw.setComProvidentFundDebit(meal.getBasePay().multiply(meal.getCompanyRatio().multiply(new BigDecimal(0.01))).setScale(0,BigDecimal.ROUND_HALF_UP));
- }else{
- uw.setProvidentFundDebit(new BigDecimal(0));
- uw.setComProvidentFundDebit(new BigDecimal(0));
- }
- }else{
- uw.setProvidentFundDebit(new BigDecimal(0));
- uw.setComProvidentFundDebit(new BigDecimal(0));
- }
- //缴金补贴
- BigDecimal jiaojin_subsidy = us.getJiaojinSubsidyid();
- // zy20180428 如果工资策略里没有设定缴金补贴,则按照原始缴扣进行补贴.否则按照工资策略补贴
- if(jiaojin_subsidy == null) {
- uw.setPaymentSubsidy(uw.getSocialSecurityDebit().add(uw.getProvidentFundDebit()));
- }else {
- uw.setPaymentSubsidy(new BigDecimal(us.getJiaojinSubsidyid().toString()));
- }
-
- return uw;
- }
-
-
- /**
- * @param hm_cache
- * @param providentFundStrategyid
- * @return
- */
- private ProvidentFundStrategyEntity getProvidentFundStrategyEntityWithCache(
- HashMap<String, HashMap<String, Object>> hm_cache, String providentFundStrategyid) {
- HashMap<String, Object> hm = hm_cache.get("getProvidentFundStrategyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getProvidentFundStrategyEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(ProvidentFundStrategyEntity.class);
- specialcq.eq("deleteFlag", "0");
- specialcq.add();
- specialcq.eq("status", "0");
- specialcq.add();
- List<ProvidentFundStrategyEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(ProvidentFundStrategyEntity entity : entitiesFromDB) {
- hm.put(entity.getId(), entity);
- }
- }
- return (ProvidentFundStrategyEntity)hm.get(providentFundStrategyid);
- }
- /**
- * @param hm_cache
- * @param socialSecurityStrategyid
- * @return
- */
- private SocialSecurityStrategyEntity getSocialSecurityStrategyEntityWithCache(
- HashMap<String, HashMap<String, Object>> hm_cache, String socialSecurityStrategyid) {
- HashMap<String, Object> hm = hm_cache.get("getSocialSecurityStrategyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getSocialSecurityStrategyEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(SocialSecurityStrategyEntity.class);
- specialcq.eq("deleteFlag", "0");
- specialcq.add();
- specialcq.eq("status", "0");
- specialcq.add();
- List<SocialSecurityStrategyEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(SocialSecurityStrategyEntity entity : entitiesFromDB) {
- hm.put(entity.getId(), entity);
- }
- }
- return (SocialSecurityStrategyEntity)hm.get(socialSecurityStrategyid);
- }
- /**
- * 加班统计
- * @param hm_cache
- * @param uat
- * @param us
- * @param uw
- * @return
- */
- private UserWageEntity overtimeCalculation(boolean isCacheUsed, HashMap<String, HashMap<String, Object>> hm_cache, UserAttendanceTotalEntity uat,UserWagestrategyEntity us,UserWageEntity uw,String month,PersonnelBaseArchivesManageEntity per){
- StringBuffer str = new StringBuffer();
- String st = " and status = 0 and delete_flag = 0";
- if(uat == null){
- uw.setOvertimepayTimeout(new BigDecimal(0.00));
- uw.setOvertimepayFixed(new BigDecimal(0));
- uw.setDuty(new BigDecimal(0));
- uw.setSpecialOvertime(new BigDecimal(0));
- }else{
- // if("ff808081645a0e3d0164d097628a07f3".equals(uat.getUserId())) {
- // System.out.println("wu");
- // }
- //超时加班费
- if(uat.getTimeoutOvertimeDuration() != null && uat.getTimeoutOvertimeDuration().intValue() > 0){
- ArrangeDutyOperateEntity arrange = getArrangeDutyOperateEntityWithCache(hm_cache, month, us.getUserid());
- if(arrange == null || arrange.getRunway().contains("jijiabanfei")){
- // 轮转方式为空,默认给加班费
- OvertimepayStrategyEntity overtimepaystrate = null;
- if(isCacheUsed) {
- overtimepaystrate = getOvertimepayStrategyEntityWithCache(hm_cache, us.getOvertimepayStrategyid());
- }else {
- str.delete(0,str.length());
- str.append("select * from t_bus_overtimepay_strategy where id = '"+us.getOvertimepayStrategyid()+"'");
- str.insert(str.length(), st);
- List<OvertimepayStrategyEntity> overtimepaystrateList=this.getSession().createSQLQuery(str.toString()).addEntity(OvertimepayStrategyEntity.class).list();
- if(overtimepaystrateList != null && overtimepaystrateList.size()>0) {
- overtimepaystrate = overtimepaystrateList.get(0);
- }
- }
-
- if(overtimepaystrate!=null){
- uw.setOvertimepayTimeout((uw.getBasicWage().divide(new BigDecimal(21.75),2,BigDecimal.ROUND_HALF_UP).divide(new BigDecimal(8),2,BigDecimal.ROUND_HALF_UP)).multiply(overtimepaystrate.getMultiple()).multiply(uat.getTimeoutOvertimeDuration().divide(new BigDecimal(60),2,BigDecimal.ROUND_HALF_UP)));
- } else {
- uw.setOvertimepayTimeout(new BigDecimal(0.00));
- }
- }else{
- uw.setOvertimepayTimeout(new BigDecimal(0.00));
- }
- }else{
- uw.setOvertimepayTimeout(new BigDecimal(0.00));
- }
- //国家法定加班费
- //两部分:一部分是国定超时加班,另一部分是国定值班,国定值班费在值班费的代码里计算 zy20180416
- if(uat.getNationalOvertimeDuration() != null && uat.getNationalOvertimeDuration().intValue() > 0){
- List<WagestrategyEntity> perobident = null;
- str.delete(0,str.length());
- str.append("select * from t_bus_wagestrategy where dutiesid = '"+per.getBelongDutiesid()+"'");
- str.insert(str.length(), st);
- if(isCacheUsed) {
- perobident = getWagestrategyEntityWithCache(hm_cache,per.getBelongDutiesid());
- }else {
- perobident = this.getSession().createSQLQuery(str.toString()).addEntity(WagestrategyEntity.class).list();
- }
- //this.getSession().createSQLQuery(str.toString()).addEntity(WagestrategyEntity.class).list();
- //WagestrategyEntity wa = this.findUniqueByProperty(WagestrategyEntity.class, "dutiesId", per.getBelongDutiesid());//(WagestrategyEntity.class, us.getDutiesid());
- if(perobident != null && !perobident.isEmpty()){
- //需要区分是管理层还是一线员工
- WagestrategyEntity wa = perobident.get(0);
- //uw.setDutiesid(wa.getId());
- if(wa != null){
- if(per != null && "2".equals(per.getManagerType())){
- uw.setOvertimepayFixed((wa.getBasicWage().divide(new BigDecimal(21.75),3,BigDecimal.ROUND_HALF_UP).divide(new BigDecimal(8),3,BigDecimal.ROUND_HALF_UP)).multiply(new BigDecimal(3)).multiply(uat.getNationalOvertimeDuration().divide(new BigDecimal(60),3,BigDecimal.ROUND_HALF_UP)));
- } else {
- uw.setOvertimepayFixed(new BigDecimal(0));
- }
- }
- }
-
- }else{
- uw.setOvertimepayFixed(new BigDecimal(0));
- }
- //值班费 duty_duration
- if(uat.getDutyDuration() != null && StringUtils.isNotEmpty(us.getDutyStrategyid())){
- // str.delete(0,str.length());
- // str.append("select * from t_bus_dutyfee_strategy where id = '"+us.getDutyStrategyid()+"'");
- // str.insert(str.length(), st);
- // List<DutyfeeStrategyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(DutyfeeStrategyEntity.class).list();
- DutyfeeStrategyEntity dutyfee = null;
-
- if(isCacheUsed) {
- dutyfee = getDutyfeeStrategyEntityWithCache(hm_cache, us.getDutyStrategyid());
- }else {
- str.delete(0,str.length());
- str.append("select * from t_bus_dutyfee_strategy where id = '"+us.getDutyStrategyid()+"'");
- str.insert(str.length(), st);
- List<DutyfeeStrategyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(DutyfeeStrategyEntity.class).list();
- if(mealList != null &&mealList.size()>0) {
- dutyfee = mealList.get(0);
- }
- }
-
- //List<DutyfeeStrategyEntity> mealList = findListbySql(str.toString());
- if(dutyfee!=null){
- DutyfeeStrategyEntity meal = dutyfee;
- uw.setDuty(uat.getDutyDuration().multiply(meal.getMoney()));
- //把国定值班费算到国定加班zyzy20180416
- BigDecimal nationaltimeoutPay = uw.getOvertimepayFixed(); //已有的国定超时加班费
- BigDecimal nationaldutyPay = meal.getMoney().multiply(new BigDecimal(3)).multiply(uat.getNationalDutyDuration()); //3倍普通值班费*国定值班天数
- uw.setOvertimepayFixed(nationaltimeoutPay.add(nationaldutyPay)); //两部分都赋值到国定加班费里
- } else {
- uw.setDuty(new BigDecimal(0));
- }
- }else{
- uw.setDuty(new BigDecimal(0));
- }
- //特殊加班费 special_overtime
- // if(uat.getSpecialOvertime() != null && StringUtils.isNotEmpty(us.getOvertimepayStrategyid())){
- //// str.delete(0,str.length());
- //// str.append("select * from t_bus_overtimepay_strategy where id = '"+us.getOvertimepayStrategyid()+"'");
- //// str.insert(str.length(), st);
- //// List<OvertimepayStrategyEntity> perobident = this.getSession().createSQLQuery(str.toString()).addEntity(OvertimepayStrategyEntity.class).list();
- //
- // OvertimepayStrategyEntity overtimepaystrate = getOvertimepayStrategyEntityWithCache(hm_cache, us.getOvertimepayStrategyid());
- // //List<OvertimepayStrategyEntity> perobident = findListbySql(str.toString());
- // if(overtimepaystrate != null){
- // uw.setSpecialOvertime((Globals.BASE_PAY.divide(new BigDecimal(21.75),2,BigDecimal.ROUND_HALF_UP).divide(new BigDecimal(8),2,BigDecimal.ROUND_HALF_UP)).multiply(overtimepaystrate.getMultiple()).multiply(uat.getSpecialOvertime().divide(new BigDecimal(60),2,BigDecimal.ROUND_HALF_UP)));
- // } else {
- // uw.setSpecialOvertime(new BigDecimal(0));
- // }
- // }else{
- // uw.setSpecialOvertime(new BigDecimal(0));
- // }
- // 适配新的加班申请 2019-12-05
- OvertimeDto overtimedto = getSpecialOvertimeSumEntityWithCache(hm_cache, per.getUserid(), month);
- if(overtimedto != null) {
- uw.setSpecialOvertime(overtimedto.getOvertimeFee() == null ? BigDecimal.ZERO : overtimedto.getOvertimeFee());
- }else {
- uw.setSpecialOvertime(new BigDecimal(0));
- }
- }
- return uw;
- }
- /**
- * @param hm_cache
- * @param month
- * @param userid
- * @return
- */
- private ArrangeDutyOperateEntity getArrangeDutyOperateEntityWithCache(
- HashMap<String, HashMap<String, Object>> hm_cache, String month, String userid) {
- //this.getSession().createSQLQuery("select * from t_bus_arrangeduty_operate where userid like '%"+us.getUserid()+"%' and yearmonth = '"+month+"'").addEntity(ArrangeDutyOperateEntity.class).list();
-
- HashMap<String, Object> hm = hm_cache.get("getArrangeDutyOperateEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getArrangeDutyOperateEntityWithCache", hm);
- List<ArrangeDutyOperateEntity> entitiesFromDB = this.getSession().createSQLQuery("select * from t_bus_arrangeduty_operate where yearmonth = '"+month+"'").addEntity(ArrangeDutyOperateEntity.class).list();
- hm.put("ALL", entitiesFromDB);
- }
-
- List<ArrangeDutyOperateEntity> entitiesFromDB = (List<ArrangeDutyOperateEntity>)hm.get("ALL");
- if(entitiesFromDB != null && entitiesFromDB.size()>0) {
- for(ArrangeDutyOperateEntity entity : entitiesFromDB) {
- if(entity != null) {
- String userids = entity.getUserid();
- if(userids.indexOf(userid) > -1) {
- return entity;
- }
- }
- }
- }
- return null;
- }
- /**
- * @param hm_cache
- * @param dutyStrategyid
- * @return
- */
- private DutyfeeStrategyEntity getDutyfeeStrategyEntityWithCache(HashMap<String, HashMap<String, Object>> hm_cache,
- String dutyStrategyid) {
- HashMap<String, Object> hm = hm_cache.get("getDutyfeeStrategyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getDutyfeeStrategyEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(DutyfeeStrategyEntity.class);
- specialcq.eq("deleteFlag", "0");
- specialcq.add();
- specialcq.eq("status", "0");
- specialcq.add();
- List<DutyfeeStrategyEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(DutyfeeStrategyEntity entity : entitiesFromDB) {
- hm.put(entity.getId(), entity);
- }
- }
- return (DutyfeeStrategyEntity)hm.get(dutyStrategyid);
- }
- /**
- * @param hm_cache
- * @param overtimepayStrategyid
- * @return
- */
- private OvertimepayStrategyEntity getOvertimepayStrategyEntityWithCache(
- HashMap<String, HashMap<String, Object>> hm_cache, String overtimepayStrategyid) {
- // TODO Auto-generated method stub
- HashMap<String, Object> hm = hm_cache.get("getOvertimepayStrategyEntityWithCache");
- if(hm == null) {
- hm = new HashMap<>();
- hm_cache.put("getOvertimepayStrategyEntityWithCache", hm);
- CriteriaQuery specialcq = new CriteriaQuery(OvertimepayStrategyEntity.class);
- specialcq.eq("deleteFlag", "0");
- specialcq.add();
- specialcq.eq("status", "0");
- specialcq.add();
- List<OvertimepayStrategyEntity> entitiesFromDB = getListByCriteriaQuery(specialcq, false);
- for(OvertimepayStrategyEntity entity : entitiesFromDB) {
- hm.put(entity.getId(), entity);
- }
- }
- return (OvertimepayStrategyEntity)hm.get(overtimepayStrategyid);
- }
- /**
- * 查询保存员工工资策略设定历史表
- * @param uwh
- * @param us
- * @return
- */
- private UserWagestrategyHistoryEntity historyUW(UserWagestrategyHistoryEntity uwh,UserWagestrategyEntity us){
- StringBuffer str = new StringBuffer();
- String st = " and status = 0 and delete_flag = 0";
- //职务
- if(StringUtils.isNotEmpty(us.getDutiesid())){
- DutiesEntity dut = get(DutiesEntity.class, us.getDutiesid());
- uwh.setDutiesName(dut.getDutiesName());
- }
- //证书补贴
- if(StringUtils.isNotEmpty(us.getCertificateSubsidyid())){
- String [] certificteStrings = us.getCertificateSubsidyid().split(",");
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < certificteStrings.length; i++) {
- str.delete(0,str.length());
- str.append("select * from t_bus_certificate_subsidy where id = '"+certificteStrings[i]+"'");
- str.insert(str.length(), st);
- List<CertificateSubsidyEntity> usList = this.getSession().createSQLQuery(str.toString()).addEntity(CertificateSubsidyEntity.class).list();
- //List<CertificateSubsidyEntity> usList = findListbySql(str.toString());
- if(!usList.isEmpty()){
- CertificateSubsidyEntity cer = usList.get(0);
- if(i == 0){
- buffer.append(cer.getCertificateName()+"-"+cer.getSubsidyMoney()+"元");
- }else{
- buffer.append(","+cer.getCertificateName()+"-"+cer.getSubsidyMoney()+"元");
- }
- }
- }
- uwh.setCertificateSubsidyDesc(buffer.toString());
- }
- //交通补贴
- if(StringUtils.isNotEmpty(us.getTrafficSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_traffic_subsidy where id ='"+us.getTrafficSubsidyid()+"'");
- str.insert(str.length(), st);
- List<TrafficSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(TrafficSubsidyEntity.class).list();
- //List<TrafficSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uwh.setTrafficSubsidyDesc(trafficSubsidyList.get(0).getSubsidyName()+"-"+trafficSubsidyList.get(0).getSubsidyMoney()+"元");
- }
- }
- //高温补贴
- if(StringUtils.isNotEmpty(us.getMegathermalSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_megathermal_subsidy where id ='"+us.getMegathermalSubsidyid()+"'");
- str.insert(str.length(), st);
- List<MegathermalSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(MegathermalSubsidyEntity.class).list();
- //List<MegathermalSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uwh.setMegathermalSubsidyDesc(trafficSubsidyList.get(0).getSubsidyName()+"-"+trafficSubsidyList.get(0).getSubsidyMoney()+"元");
- }
- }
- //独生子女费
- if(us.getOnlychildPay() != null){
- uwh.setOnlychildPay(us.getOnlychildPay());
- }
- //其他补贴
- if(StringUtils.isNotEmpty(us.getOtherSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_other_subsidy where id ='"+us.getOtherSubsidyid()+"'");
- str.insert(str.length(), st);
- List<OtherSubsidyEntity> trafficSubsidyList = this.getSession().createSQLQuery(str.toString()).addEntity(OtherSubsidyEntity.class).list();
- //List<OtherSubsidyEntity> trafficSubsidyList = this.findListbySql(str.toString());
- if(oConvertUtils.isNotEmpty(trafficSubsidyList)){
- uwh.setOtherSubsidyDesc(trafficSubsidyList.get(0).getSubsidyName()+"-"+trafficSubsidyList.get(0).getSubsidyMoney()+"元");
- }
- }
- //餐补方式 0.每月固定 1.每月班次
- uwh.setStrategyType(us.getStrategyType());
-
- //额外加班
- if(StringUtils.isNotEmpty(us.getNofixedmealsSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_meals_subsidy where id = '"+us.getNofixedmealsSubsidyid()+"'");
- str.insert(str.length(), st);
- List<MealsSubsidyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(MealsSubsidyEntity.class).list();
- //List<MealsSubsidyEntity> mealList = findListbySql(str.toString());
- if(!mealList.isEmpty() && mealList.size() > 0){
- MealsSubsidyEntity meal = mealList.get(0);
- uwh.setNofixedmealsSubsidyDesc(meal.getSubsidyName()+"-"+meal.getSubsidyMoney()+"元");
- }
- }
- //每月固定餐补
- if(StringUtils.isNotEmpty(us.getFixedmealsSubsidyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_meals_subsidy where id = '"+us.getFixedmealsSubsidyid()+"'");
- str.insert(str.length(), st);
- List<MealsSubsidyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(MealsSubsidyEntity.class).list();
- //List<MealsSubsidyEntity> mealList = findListbySql(str.toString());
- if(!mealList.isEmpty() && mealList.size() > 0){
- MealsSubsidyEntity meal = mealList.get(0);
- uwh.setFixedmealsSubsidyDesc(meal.getSubsidyName()+"-"+meal.getSubsidyMoney()+"元");
- }
- }
- //加班
- if(StringUtils.isNotEmpty(us.getOvertimepayStrategyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_overtimepay_strategy where id = '"+us.getOvertimepayStrategyid()+"'");
- str.insert(str.length(), st);
- List<OvertimepayStrategyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(OvertimepayStrategyEntity.class).list();
- //List<OvertimepayStrategyEntity> mealList = findListbySql(str.toString());
- if(!mealList.isEmpty() && mealList.size() > 0){
- OvertimepayStrategyEntity meal = mealList.get(0);
- uwh.setOvertimepayStrategyDesc(meal.getStrategyName()+"-"+meal.getMultiple()+"倍");
- }
- }
- //值班
- if(StringUtils.isNotEmpty(us.getDutyStrategyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_dutyfee_strategy where id = '"+us.getDutyStrategyid()+"'");
- str.insert(str.length(), st);
- List<DutyfeeStrategyEntity> mealList = this.getSession().createSQLQuery(str.toString()).addEntity(DutyfeeStrategyEntity.class).list();
- //List<DutyfeeStrategyEntity> mealList = findListbySql(str.toString());
- if(!mealList.isEmpty() && mealList.size() > 0){
- DutyfeeStrategyEntity meal = mealList.get(0);
- uwh.setDutyStrategyDesc(meal.getStrategyName()+"-"+meal.getMoney()+"元");
- }
- }
- //社保
- if(StringUtils.isNotEmpty(us.getSocialSecurityStrategyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_social_security_strategy where id = '"+us.getSocialSecurityStrategyid()+"'");
- str.insert(str.length(), st);
- List<SocialSecurityStrategyEntity> social = this.getSession().createSQLQuery(str.toString()).addEntity(SocialSecurityStrategyEntity.class).list();
- //List<SocialSecurityStrategyEntity> social = findListbySql(str.toString());
- if(!social.isEmpty() && social.size() > 0){
- SocialSecurityStrategyEntity meal = social.get(0);
- uwh.setSocialSecurityStrategyDesc(meal.getSocialSecurityUnit());
-
- //保存社保各个参数
- if(meal.getCompanyInjuryInsu() != null){
- uwh.setCompanyInjuryInsu(meal.getCompanyInjuryInsu());
- }
- if(meal.getCompanyMaternityInsu() != null){
- uwh.setCompanyMaternityInsu(meal.getCompanyMaternityInsu());
- }
- if(meal.getPersionalBasicMedicalInsu() != null){
- uwh.setPersionalBasicMedicalInsu(meal.getPersionalBasicMedicalInsu());
- }
- if(meal.getCompanyBasicRetireInsu() != null){
- uwh.setCompanyBasicRetireInsu(meal.getCompanyBasicRetireInsu());
- }
- if(meal.getBasePay()!= null){
- uwh.setSocialSecurityBasePay(meal.getBasePay());
- }
- if(meal.getPersonalUnemploymentInsu() != null){
- uwh.setPersonalUnemploymentInsu(meal.getPersonalUnemploymentInsu());
- }
- if(meal.getCompanyBasicMedicalInsu() != null){
- uwh.setCompanyBasicMedicalInsu(meal.getCompanyBasicMedicalInsu());
- }
- if(meal.getCompanyUnemploymentInsu() != null){
- uwh.setCompanyUnemploymentInsu(meal.getCompanyUnemploymentInsu());
- }
- if(meal.getPersonalBasicRetireInsu() != null){
- uwh.setPersonalBasicRetireInsu(meal.getPersonalBasicRetireInsu());
- }
- }
- }
- //公积金
- if(StringUtils.isNotEmpty(us.getProvidentFundStrategyid())){
- str.delete(0,str.length());
- str.append("select * from t_bus_provident_fund_strategy where id = '"+us.getProvidentFundStrategyid()+"'");
- str.insert(str.length(), st);
- List<ProvidentFundStrategyEntity> perobident = this.getSession().createSQLQuery(str.toString()).addEntity(ProvidentFundStrategyEntity.class).list();
- //List<ProvidentFundStrategyEntity> perobident = findListbySql(str.toString());
- if(!perobident.isEmpty() && perobident.size() > 0){
- ProvidentFundStrategyEntity meal = perobident.get(0);
- uwh.setProvidentFundStrategyDesc(meal.getProvidentFundName());
- //保存公积金各个参数
- if(meal.getPersonalRatio() != null){
- uwh.setPersonalRatio(meal.getPersonalRatio());
- }
- if(meal.getBasePay() != null){
- uwh.setProvidentFundBasePay(meal.getBasePay());
- }
- if(meal.getCompanyRatio() != null){
- uwh.setCompanyRatio(meal.getCompanyRatio());
- }
- }
- }
-
- //追加调整
- if(us.getAppendPay() != null){
- uwh.setAppendPay(us.getAppendPay());
- }
- //扣除调整
- if(us.getDeductPay()!= null){
- uwh.setDeductPay(us.getDeductPay());
- }
- //扣除调整
- if(us.getDaikouFee()!= null){
- uwh.setDaikouFee(us.getDaikouFee());
- }
-
- return uwh;
- }
- @Override
- public Map<String, String> isDuties(String userid) {
- return userWageMinidaoDao.isDuties(userid);
- }
- @Override
- public void userPayrollOverride() throws Exception {
- StringBuffer hql = new StringBuffer("from UserWagestrategyEntity");
- List<UserWagestrategyEntity> userWagestrategyEntity = this.getSession().createQuery(hql.toString()).list();
- userPayroll(userWagestrategyEntity,null,"0");
- }
- }
|