package com.engine.bjcj220907.service.impl; import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.fastjson.JSONObject; import com.engine.bjcj220907.entity.Attend4MonthBonus; import com.engine.bjcj220907.service.GetKQ4OverseasAllowanceCountService; import com.engine.core.impl.Service; import com.engine.kq.cmd.report.GetKQReportCmd; import com.weaver.general.BaseBean; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author Harryxzy * @date 2022/09/27 15:56 * @description 拉取考勤中数据供境外津贴使用 */ public class GetKQ4OverseasAllowanceCountServiceImpl extends Service implements GetKQ4OverseasAllowanceCountService { BaseBean baseBean = new BaseBean(); /*** * @description 获取境外常驻用户考勤中请假天数以及公务回国天数 * @return Map * @author Harryxzy * @date 2022/9/27 15:58 */ @Override public Map getKQDatas(Attend4MonthBonus attend4MonthBonus) { baseBean.writeLog("开始获取考勤数据,参数{}", attend4MonthBonus); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM"); List columnsList = new ArrayList<>(); List> dataList = new ArrayList<>(); try { Map paramsMap = new HashMap(); paramsMap.put("typeselect", "6"); paramsMap.put("pageIndex", 1); paramsMap.put("pageSize", 10000); paramsMap.put("fromDate", sdf.format(attend4MonthBonus.getBeginDate())); paramsMap.put("toDate", sdf.format(attend4MonthBonus.getEndDate())); paramsMap.put("viewScope", "0"); paramsMap.put("isNoAccount", "1"); paramsMap.put("attendanceSerial", "0"); paramsMap.put("status", "9"); Map temp = new HashMap(); temp.put("data", JSONObject.toJSONString(paramsMap)); temp.put("reportType", "month"); baseBean.writeLog("开始执行GetKQReportCmd"); Map execute = commandExecutor.execute(new GetKQReportCmd(temp,user)); baseBean.writeLog("GetKQReportCmd执行成功"); // 获取列数据 columnsList = (List) execute.get("columns"); List c = new ArrayList(); String[] gwhgDataIndex={""}; columnsList.stream().forEach(column->{ if(column.get("title").equals("旷工")){ c.add(column.get("dataIndex")); } if(column.get("title").equals("出差及请假")){ List children =(List) column.get("children"); children.stream().forEach(i->{ if((!i.get("title").equals("境内年假")) && (!i.get("title").equals("境外年假")) && (!i.get("title").equals("工伤"))){ c.add(i.get("dataIndex")); } if(i.get("title").equals("公务回国") ){ gwhgDataIndex[0] =(String) column.get("dataIndex"); } }); } }); baseBean.writeLog("计算缺勤列:"+c); dataList = (List>) execute.get("datas"); // 获取每个人的缺勤天数、及公务回国天数 Map qqDays = new HashMap<>(); String[] gwhgS= {""}; dataList.stream().forEach(i->{ double[] qq={0.0}; c.stream().forEach(j->{ // 累加各种请假天数 qq[0]+=Double.parseDouble(i.get(j)); }); String qqStr = i.get("resourceId") +"-qq"; qqDays.put(qqStr,qq[0]); String gwhgStr = i.get("resourceId") + "-gwhg"; if(!gwhgDataIndex[0].equals("")){ gwhgS[0] = i.get(gwhgDataIndex[0]); }else { gwhgS[0] ="0"; } qqDays.put(gwhgStr,Double.valueOf(gwhgS[0])); }); baseBean.writeLog("获取的考勤缺勤及公务回国天数,{}", JSONUtils.toJSONString(qqDays)); return qqDays; } catch (Exception e) { baseBean.writeLog("获取考勤数据失败{}", e); } return null; } }