weaver-bjcj/src/com/engine/bjcj220907/service/impl/GetKQ4OverseasAllowanceCoun...

122 lines
5.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.engine.bjcj220907.service.impl;
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.*;
/**
* @author Harryxzy
* @date 2022/09/27 15:56
* @description 拉取考勤中数据供境外津贴使用
*/
public class GetKQ4OverseasAllowanceCountServiceImpl extends Service implements GetKQ4OverseasAllowanceCountService {
BaseBean baseBean = new BaseBean();
/***
* @description 获取境外常驻用户考勤中请假天数以及公务回国天数
* @return Map<String,Double>
* @author Harryxzy
* @date 2022/9/27 15:58
*/
@Override
public Map<String, Object> getKQDatas(Attend4MonthBonus attend4MonthBonus,List<String> users) {
baseBean.writeLog("开始获取考勤数据,参数{}", attend4MonthBonus);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
List<Map> columnsList = new ArrayList<>();
List<Map<String, Object>> dataList = new ArrayList<>();
try {
Map<String, Object> paramsMap = new HashMap<String, Object>();
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<String, Object> temp = new HashMap<String, Object>();
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<Map>) execute.get("columns");
String[] gwhgDataIndex={""};
columnsList.stream().forEach(column->{
if(column.get("title").equals("出差及请假")){
List<Map> children =(List<Map>) column.get("children");
children.stream().forEach(i->{
if(i.get("title").equals("公务回国") ){
gwhgDataIndex[0] =(String) i.get("dataIndex");
}
});
}
});
baseBean.writeLog("公务回国dataIndex"+gwhgDataIndex[0]);
dataList = (List<Map<String, Object>>) execute.get("datas");
// 获取每个人的缺勤日期、及公务回国天数
Map<String, Object> qqDays = new HashMap<>();
String[] gwhgS= {""};
Calendar countBeginCal = Calendar.getInstance();
countBeginCal.setTime(attend4MonthBonus.getBeginDate());
Calendar countEndCal = Calendar.getInstance();
countEndCal.setTime(attend4MonthBonus.getEndDate());
countEndCal.set(Calendar.HOUR_OF_DAY, 0);
countEndCal.set(Calendar.MINUTE, 0);
countEndCal.set(Calendar.SECOND, 0);
countEndCal.set(Calendar.MILLISECOND, 0);
List<Date> attDateList = new ArrayList<>();
while (countEndCal.after(countBeginCal) || countEndCal.getTime().equals(countBeginCal.getTime())){
attDateList.add(countEndCal.getTime());
countEndCal.add(Calendar.DATE,-1);
}
baseBean.writeLog("获取缺勤日期为:"+attDateList);
dataList.stream().forEach(i->{
if(users.contains(i.get("resourceId"))){
List<Date> qqDate = new ArrayList<>();
attDateList.stream().forEach(a -> {
Object o = i.get(sdf.format(a));
// baseBean.writeLog("i.get(sdf.format(a)) o:"+o);
String attCal = "";
try{
Map attCalMap =(Map) o;
attCal = (String)attCalMap.get("text");
}catch (Exception e){
baseBean.writeLog("考勤数据:"+o+"转换为Map失败");
attCal="休息";
}
if( (attCal.contains("旷工")) || ( (!attCal.equals("")) && (!attCal.contains("休息")) && (!attCal.equals("")) && (!attCal.contains("境内年假")) && (!attCal.contains("境外年假")) && (!attCal.contains("公务回国")) && (!attCal.contains("工伤")) && (!attCal.contains("奖励假")) ) ){
// 存在缺勤
qqDate.add(a);
baseBean.writeLog(attCal+"缺勤");
}
});
String qqStr = i.get("resourceId") +"-qq";
qqDays.put(qqStr,qqDate);
String gwhgStr = i.get("resourceId") + "-gwhg";
if(!gwhgDataIndex[0].equals("")){
gwhgS[0] = (String) i.get(gwhgDataIndex[0]);
}else {
gwhgS[0] ="0";
}
baseBean.writeLog("公务回国PUT"+gwhgStr+","+Double.valueOf(gwhgS[0]));
qqDays.put(gwhgStr,Double.valueOf(gwhgS[0]));
}
});
return qqDays;
} catch (Exception e) {
baseBean.writeLog("获取考勤数据失败{}", e);
}
return null;
}
}