|
@@ -12,9 +12,11 @@ import com.management.platform.entity.vo.SysRichFunction;
|
|
|
import com.management.platform.entity.vo.WorktimeItem;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.*;
|
|
|
-import com.management.platform.util.HttpRespMsg;
|
|
|
-import com.management.platform.util.MessageUtils;
|
|
|
-import com.management.platform.util.WorkDayCalculateUtils;
|
|
|
+import com.management.platform.util.*;
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
+import okhttp3.Request;
|
|
|
+import okhttp3.WebSocket;
|
|
|
+import org.apache.ibatis.annotations.Param;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.util.StringUtils;
|
|
@@ -24,14 +26,17 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
@@ -86,6 +91,10 @@ public class ReportController {
|
|
|
private UserCorpwxTimeMapper userCorpwxTimeMapper;
|
|
|
@Resource
|
|
|
private UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ private UserFvTimeService userFvTimeService;
|
|
|
+ @Resource
|
|
|
+ private LeaveSheetService leaveSheetService;
|
|
|
|
|
|
//获取任务相关的日报列表
|
|
|
@RequestMapping("/getTaskReportList")
|
|
@@ -1703,5 +1712,253 @@ public class ReportController {
|
|
|
return reportService.correctWorkingTime(userIds,startDate,endDate);
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/fvTongBu")
|
|
|
+ public void fvTongBu(){
|
|
|
+ List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_fanwei", 1));
|
|
|
+ List<Integer> compIds = timeTypeList.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
|
|
|
+ if(compIds.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Integer compId : compIds) {
|
|
|
+ DockWithMLD dockWithMLD=new DockWithMLD();
|
|
|
+ JSONObject jsonObject=new JSONObject();
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter dtf1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
+ //需要修改************************************************ 日期
|
|
|
+ LocalDateTime yesterday = LocalDateTime.now().minusDays(2);
|
|
|
+ String startDate = dtf.format(yesterday);
|
|
|
+ String endDate = dtf.format(yesterday.plusDays(30));
|
|
|
+ List<UserFvTime> oldUserFvTimeList = userFvTimeService.list(new QueryWrapper<UserFvTime>().eq("company_id", compId));
|
|
|
+ List<LeaveSheet> oldLeaveSheetList = leaveSheetService.list(new QueryWrapper<LeaveSheet>().eq("company_id", compId));
|
|
|
+ List<BusinessTrip> oldBusinessTripList = businessTripService.list(new QueryWrapper<BusinessTrip>().eq("company_id", compId));
|
|
|
+ /*jsonObject.put("startDate",startDate);
|
|
|
+ jsonObject.put("endDate",endDate);*/
|
|
|
+ jsonObject.put("workDate",startDate);
|
|
|
+ jsonObject.put("gmtFinished",startDate);
|
|
|
+ String jsonString = jsonObject.toJSONString();
|
|
|
+ List<UserFvTime> userFvTimeList=new ArrayList<>();
|
|
|
+ List<LeaveSheet> leaveSheetList=new ArrayList<>();
|
|
|
+ List<BusinessTrip> businessTripList=new ArrayList<>();
|
|
|
+ TimeType allDay = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", compId));
|
|
|
+ List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", compId));
|
|
|
+ //获取休息设置
|
|
|
+ TimeAutoExclude timeAutoExclude = timeAutoExcludeMapper.selectOne(new QueryWrapper<TimeAutoExclude>().eq("company_id", compId));
|
|
|
+ //Todo: 获取考勤打卡数据
|
|
|
+ HttpRespMsg workDataMsg = dockWithMLD.getResult("http://10.1.10.51:20175/api/cube/restful/interface/getModeDataPageList/getWorkData", jsonString);
|
|
|
+ List<Map<String,Object>> workDataList= (List<Map<String, Object>>) workDataMsg.data;
|
|
|
+ //Todo: 获取外出打卡数据
|
|
|
+ HttpRespMsg outWorkDataMsg = dockWithMLD.getResult("http://10.1.10.51:20175/api/cube/restful/interface/getModeDataPageList/getOutRecord", jsonString);
|
|
|
+ List<Map<String,Object>> outWorkDataList= (List<Map<String, Object>>) outWorkDataMsg.data;
|
|
|
+ //Todo: 获取考勤补卡数据
|
|
|
+ HttpRespMsg replaceWorkDataMsg = dockWithMLD.getResult("http://10.1.10.51:20175/api/cube/restful/interface/getModeDataPageList/getReplaceRecord", jsonString);
|
|
|
+ List<Map<String,Object>> replaceWorkDataList= (List<Map<String, Object>>) replaceWorkDataMsg.data;
|
|
|
+ List<String> userIds = workDataList.stream().map(map -> String.valueOf(map.get("userId"))).distinct().collect(Collectors.toList());
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("job_number", userIds));
|
|
|
+ List<LocalDateTime> dateTimeList = getDays(yesterday, yesterday.plusDays(2));
|
|
|
+ for (User user : userList) {
|
|
|
+ for (LocalDateTime localDateTime : dateTimeList) {
|
|
|
+ LocalDate workDate=localDateTime.toLocalDate();
|
|
|
+ //当天的考勤记录
|
|
|
+ List<Map<String, Object>> list = workDataList.stream().filter(wl -> wl.get("userId").equals(user.getJobNumber())&&wl.get("workDate").equals(workDate.format(dtf))).collect(Collectors.toList());
|
|
|
+ UserFvTime userFvTime=new UserFvTime();
|
|
|
+ userFvTime.setWorkDate(workDate);
|
|
|
+ LocalTime startTime=null;
|
|
|
+ LocalTime endTime=null;
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ if(String.valueOf(map.get("signtype")).equals("签到")&&!map.get("signtime").equals("")){
|
|
|
+ startTime=LocalTime.parse(String.valueOf(map.get("signtime")), dtf2);
|
|
|
+ }
|
|
|
+ if(String.valueOf(map.get("signtype")).equals("签退")&&!map.get("signtime").equals("")){
|
|
|
+ endTime=LocalTime.parse(String.valueOf(map.get("signtime")), dtf2);
|
|
|
+ }
|
|
|
+ //处理外出记录 有外出记录默认以默认规则作为考勤数据来源
|
|
|
+ Optional<Map<String, Object>> outFirst = outWorkDataList.stream().filter(ol -> ol.get("ycbgkssj").equals(map.get("workDate")) && ol.get("rybh").equals(map.get("userId"))).findFirst();
|
|
|
+ if(outFirst.isPresent()){
|
|
|
+ if(startTime==null||LocalTime.parse(String.valueOf(outFirst.get().get("kssj")), dtf2).isBefore(startTime)){
|
|
|
+ startTime=LocalTime.parse(String.valueOf(outFirst.get().get("kssj")), dtf2);
|
|
|
+ }
|
|
|
+ if(endTime==null||LocalTime.parse(String.valueOf(outFirst.get().get("jssj")), dtf2).isBefore(endTime)){
|
|
|
+ endTime=LocalTime.parse(String.valueOf(outFirst.get().get("jssj")), dtf2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理补卡记录 有补卡记录以补卡记录作为考勤数据来源
|
|
|
+ Optional<Map<String, Object>> replaceFirst = replaceWorkDataList.stream().filter(rl -> rl.get("kqrq").equals(map.get("workDate")) && rl.get("rybh").equals(map.get("userId"))).findFirst();
|
|
|
+ if(replaceFirst.isPresent()){
|
|
|
+ if(startTime==null||replaceFirst.get().get("bklx").equals("上班")){
|
|
|
+ startTime=LocalTime.parse(String.valueOf(replaceFirst.get().get("bksj")), dtf2);
|
|
|
+ }
|
|
|
+ if(endTime==null||replaceFirst.get().get("bklx").equals("下班")){
|
|
|
+ endTime=LocalTime.parse(String.valueOf(replaceFirst.get().get("bksj")), dtf2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(compIds.contains(user.getCompanyId())){
|
|
|
+ if(startTime==null||endTime==null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Duration between = Duration.between(startTime, endTime);
|
|
|
+ userFvTime.setStartTime(startTime.format(dtf2));
|
|
|
+ userFvTime.setEndTime(endTime.format(dtf2));
|
|
|
+ userFvTime.setCompanyId(user.getCompanyId());
|
|
|
+ userFvTime.setUserId(user.getId());
|
|
|
+ long workHours = between.toHours();
|
|
|
+ long restHours;
|
|
|
+ if(startTime.isBefore(LocalTime.parse(timeAutoExclude.getStartTime(),dtf2))
|
|
|
+ &&endTime.isAfter(LocalTime.parse(timeAutoExclude.getEndTime(),dtf2))){
|
|
|
+ Duration bt = Duration.between(LocalTime.parse(timeAutoExclude.getStartTime(),dtf2), LocalTime.parse(timeAutoExclude.getEndTime(),dtf2));
|
|
|
+ restHours=bt.toHours();
|
|
|
+ }else {
|
|
|
+ restHours=0;
|
|
|
+ }
|
|
|
+ userFvTime.setWorkHours(BigDecimal.valueOf(workHours).subtract(BigDecimal.valueOf(restHours)).floatValue());
|
|
|
+ Optional<UserFvTime> first = oldUserFvTimeList.stream().filter(ol -> ol.getWorkDate().isEqual(userFvTime.getWorkDate()) && ol.getUserId().equals(userFvTime.getUserId())).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ userFvTime.setId(first.get().getId());
|
|
|
+ }
|
|
|
+ if(endTime.isBefore(startTime)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ userFvTimeList.add(userFvTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(userFvTimeList.size()>0){
|
|
|
+ userFvTimeService.saveOrUpdateBatch(userFvTimeList);
|
|
|
+ }
|
|
|
+ System.out.println(userFvTimeList);
|
|
|
+ //Todo: 获取请假数据
|
|
|
+ HttpRespMsg leaveRecordMsg = dockWithMLD.getResult("http://10.1.10.51:20175/api/cube/restful/interface/getModeDataPageList/getLeaveRecord", jsonString);
|
|
|
+ List<Map<String,Object>> leaveRecordList= (List<Map<String, Object>>) leaveRecordMsg.data;
|
|
|
+ for (Map<String, Object> map : leaveRecordList) {
|
|
|
+ Optional<User> optional=allUserList.stream().filter(al->al.getJobNumber()!=null&&al.getJobNumber().equals(map.get("rybh"))).findFirst();
|
|
|
+ if(!optional.isPresent()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ User user=optional.get();
|
|
|
+ /*System.out.println("泛微同步人员请假数据----"+user.getName());*/
|
|
|
+ if(compIds.contains(user.getCompanyId())){
|
|
|
+ LeaveSheet leaveSheet=new LeaveSheet();
|
|
|
+ leaveSheet.setCompanyId(user.getCompanyId());
|
|
|
+ leaveSheet.setStatus(0);
|
|
|
+ leaveSheet.setOwnerId(user.getId());
|
|
|
+ leaveSheet.setOwnerName(user.getName());
|
|
|
+ leaveSheet.setStartDate(LocalDate.parse(String.valueOf(map.get("startDate")),dtf1));
|
|
|
+ leaveSheet.setEndDate(LocalDate.parse(String.valueOf(map.get("endDate")),dtf1));
|
|
|
+ Integer timeType=null;
|
|
|
+ switch (String.valueOf(map.get("timeType"))){
|
|
|
+ case "小时":timeType=1;
|
|
|
+ break;
|
|
|
+ case "天":timeType=0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ leaveSheet.setTimeType(timeType);
|
|
|
+ leaveSheet.setTimeDays(Float.parseFloat(((String) map.get("timeDays")).equals("")?"0.00":((String) map.get("timeDays"))));
|
|
|
+ if (timeType == 0){
|
|
|
+ leaveSheet.setTimeHours(leaveSheet.getTimeDays()*allDay.getAllday());
|
|
|
+ }else {
|
|
|
+ leaveSheet.setTimeHours(Float.parseFloat(((String) map.get("timeHours")).equals("")?"0.00":((String) map.get("timeHours"))));
|
|
|
+ }
|
|
|
+ Integer leaveType;
|
|
|
+ switch (String.valueOf(map.get("leaveType"))){
|
|
|
+ case "事假":leaveType=0;
|
|
|
+ break;
|
|
|
+ case "病假":leaveType=1;
|
|
|
+ break;
|
|
|
+ case "年假":leaveType=2;
|
|
|
+ break;
|
|
|
+ case "产假":leaveType=3;
|
|
|
+ break;
|
|
|
+ case "婚假":leaveType=4;
|
|
|
+ break;
|
|
|
+ case "丧假":leaveType=5;
|
|
|
+ break;
|
|
|
+ case "调休":leaveType=6;
|
|
|
+ break;
|
|
|
+ case "陪产假":leaveType=7;
|
|
|
+ break;
|
|
|
+ default:leaveType=8;
|
|
|
+ }
|
|
|
+ leaveSheet.setLeaveType(leaveType);
|
|
|
+ leaveSheet.setProcinstId(String.valueOf(map.get("id")));
|
|
|
+ leaveSheet.setGmtFinished(String.valueOf(map.get("gmtFinished")));
|
|
|
+ Optional<LeaveSheet> first = oldLeaveSheetList.stream().filter(ol -> ol.getStartDate().isEqual(leaveSheet.getStartDate())&&ol.getEndDate().isEqual(leaveSheet.getEndDate())&& ol.getOwnerId().equals(leaveSheet.getOwnerId())&&(ol.getProcinstId()!=null&& ol.getProcinstId().equals(leaveSheet.getProcinstId()))).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ leaveSheet.setId(first.get().getId());
|
|
|
+ }
|
|
|
+ leaveSheetList.add(leaveSheet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(leaveSheetList.size()>0){
|
|
|
+ leaveSheetService.saveOrUpdateBatch(leaveSheetList);
|
|
|
+ }
|
|
|
+ System.out.println(leaveRecordList);
|
|
|
+ //Todo: 获取出差数据
|
|
|
+ HttpRespMsg travelRecordMsg = dockWithMLD.getResult("http://10.1.10.51:20175/api/cube/restful/interface/getModeDataPageList/getTravelRecord", jsonString);
|
|
|
+ List<Map<String,Object>> travelRecordList= (List<Map<String, Object>>) travelRecordMsg.data;
|
|
|
+ for (Map<String, Object> map : travelRecordList) {
|
|
|
+ Optional<User> optional=allUserList.stream().filter(al->al.getJobNumber()!=null&&al.getJobNumber().equals(map.get("rybh"))).findFirst();
|
|
|
+ if(!optional.isPresent()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ User user=optional.get();
|
|
|
+ if(compIds.contains(user.getCompanyId())){
|
|
|
+ BusinessTrip businessTrip=new BusinessTrip();
|
|
|
+ businessTrip.setCompanyId(user.getCompanyId());
|
|
|
+ businessTrip.setOwnerId(user.getId());
|
|
|
+ businessTrip.setOwnerName(user.getName());
|
|
|
+ businessTrip.setStartDate(LocalDate.parse(String.valueOf(map.get("startDate")),dtf1));
|
|
|
+ businessTrip.setEndDate(LocalDate.parse(String.valueOf(map.get("endDate")),dtf1));
|
|
|
+ Integer way=null;
|
|
|
+ switch (String.valueOf(map.get("way"))){
|
|
|
+ case "飞机":way=0;
|
|
|
+ break;
|
|
|
+ case "高铁/火车":way=1;
|
|
|
+ break;
|
|
|
+ case "汽车":way=2;
|
|
|
+ break;
|
|
|
+ case "轮船":way=3;
|
|
|
+ break;
|
|
|
+ case "其他":way=4;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ businessTrip.setWay(way);
|
|
|
+ businessTrip.setCityFrom((String) map.get("cityFrom"));
|
|
|
+ businessTrip.setCityTo((String) map.get("cityTo"));
|
|
|
+ Integer goBack=null;
|
|
|
+ switch (String.valueOf(map.get("goBack"))){
|
|
|
+ case "单程":goBack=0;
|
|
|
+ break;
|
|
|
+ case "往返":goBack=1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ businessTrip.setGoBack(goBack);
|
|
|
+ Double dayCount =Double.valueOf(String.valueOf(map.get("dayCount")));
|
|
|
+ businessTrip.setDayCount(dayCount.intValue());
|
|
|
+ businessTrip.setProcinstId((String) map.get("id"));
|
|
|
+ businessTrip.setGmtFinished((String)map.get("gmtFinished"));
|
|
|
+ Optional<BusinessTrip> first = oldBusinessTripList.stream().filter(ol -> ol.getStartDate().isEqual(businessTrip.getStartDate())&&ol.getEndDate().isEqual(businessTrip.getEndDate())&& ol.getOwnerId().equals(businessTrip.getOwnerId())&&(ol.getProcinstId()!=null&&ol.getProcinstId().equals(businessTrip.getProcinstId()))).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ businessTrip.setId(first.get().getId());
|
|
|
+ }
|
|
|
+ businessTripList.add(businessTrip);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(businessTripList.size()>0){
|
|
|
+ businessTripService.saveOrUpdateBatch(businessTripList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<LocalDateTime> getDays(LocalDateTime start, LocalDateTime end) {
|
|
|
+ List<LocalDateTime> result = new ArrayList();
|
|
|
+ while (start.isBefore(end)) {
|
|
|
+ result.add(start);
|
|
|
+ start=start.plusDays(1);
|
|
|
+ }
|
|
|
+ result.add(start);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|