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

107 lines
5.1 KiB
Java
Raw Normal View History

2022-09-27 21:19:37 +08:00
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;
2022-10-23 22:27:09 +08:00
import java.util.*;
2022-09-27 21:19:37 +08:00
/**
* @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
2022-10-23 22:27:09 +08:00
public Map<String, Object> getKQDatas(Attend4MonthBonus attend4MonthBonus,List<String> users) {
2022-09-27 21:19:37 +08:00
baseBean.writeLog("开始获取考勤数据,参数{}", attend4MonthBonus);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
2022-10-23 22:27:09 +08:00
// SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
2022-09-27 21:19:37 +08:00
List<Map> columnsList = new ArrayList<>();
2022-10-23 22:27:09 +08:00
List<Map<String, Object>> dataList = new ArrayList<>();
2022-09-27 21:19:37 +08:00
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");
2022-09-28 15:58:46 +08:00
baseBean.writeLog("开始执行GetKQReportCmd");
2022-09-27 21:19:37 +08:00
Map execute = commandExecutor.execute(new GetKQReportCmd(temp,user));
2022-09-28 15:58:46 +08:00
baseBean.writeLog("GetKQReportCmd执行成功");
2022-09-27 21:19:37 +08:00
// 获取列数据
columnsList = (List<Map>) execute.get("columns");
2022-09-28 15:58:46 +08:00
String[] gwhgDataIndex={""};
2022-09-27 21:19:37 +08:00
columnsList.stream().forEach(column->{
if(column.get("title").equals("出差及请假")){
List<Map> children =(List<Map>) column.get("children");
children.stream().forEach(i->{
2022-09-28 15:58:46 +08:00
if(i.get("title").equals("公务回国") ){
gwhgDataIndex[0] =(String) column.get("dataIndex");
}
2022-09-27 21:19:37 +08:00
});
}
});
2022-10-23 22:27:09 +08:00
dataList = (List<Map<String, Object>>) execute.get("datas");
// 获取每个人的缺勤日期、及公务回国天数
Map<String, Object> qqDays = new HashMap<>();
2022-09-28 15:58:46 +08:00
String[] gwhgS= {""};
2022-10-23 22:27:09 +08:00
Calendar countBeginCal = Calendar.getInstance();
countBeginCal.setTime(attend4MonthBonus.getBeginDate());
Calendar countEndCal = Calendar.getInstance();
countEndCal.setTime(attend4MonthBonus.getEndDate());
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);
2022-09-28 15:58:46 +08:00
dataList.stream().forEach(i->{
2022-10-23 22:27:09 +08:00
if(users.contains(i.get("resourceId"))){
List<Date> qqDate = new ArrayList<>();
attDateList.stream().forEach(a -> {
Map attCalMap =(Map) i.get(sdf.format(a));
String attCal = (String)attCalMap.get("text");
2022-10-24 18:01:00 +08:00
if( (attCal.contains("旷工")) || ( (!attCal.equals("")) && (!attCal.contains("休息")) && (!attCal.equals("")) && (!attCal.contains("境内年假")) && (!attCal.contains("境外年假")) && (!attCal.contains("工伤")) && (!attCal.contains("奖励假")) ) ){
2022-10-23 22:27:09 +08:00
// 存在缺勤
qqDate.add(a);
}
});
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";
}
qqDays.put(gwhgStr,Double.valueOf(gwhgS[0]));
2022-09-28 15:58:46 +08:00
}
});
2022-09-27 21:19:37 +08:00
return qqDays;
} catch (Exception e) {
baseBean.writeLog("获取考勤数据失败{}", e);
}
return null;
}
}