|
@@ -325,7 +325,7 @@ public class UserFvTimeController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping("syncAttendanceForMingYi")
|
|
|
- public HttpRespMsg getAttendanceForMingYi( String startDate,String endDate,String userId, HttpServletRequest request) throws Exception {
|
|
|
+ public HttpRespMsg getAttendanceForMingYi(Integer isBatch,String startDate,String endDate,String userId, HttpServletRequest request) throws Exception {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
JSONObject reqParam = new JSONObject();
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
@@ -335,7 +335,7 @@ public class UserFvTimeController {
|
|
|
DateTimeFormatter time=DateTimeFormatter.ofPattern("HH:mm");
|
|
|
reqParam.put("startDate",startDate);
|
|
|
reqParam.put("endDate",endDate);
|
|
|
- reqParam.put("userId",userId);
|
|
|
+ userList.stream().filter(u->u.getId().equals(userId)).findFirst().ifPresent(u->reqParam.put("userId",u.getJobNumber()));
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
String url="http://localhost:10020/attendance/getAttendanceList";
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
@@ -382,6 +382,10 @@ public class UserFvTimeController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (userFvTimeList.size() == 0 && userFvTimeUpdateList.size() == 0) {
|
|
|
+ httpRespMsg.setError("暂无考勤记录");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
if(!userFvTimeService.saveBatch(userFvTimeList)){
|
|
|
httpRespMsg.setError("验证失败");
|
|
|
return httpRespMsg;
|
|
@@ -404,27 +408,45 @@ public class UserFvTimeController {
|
|
|
}
|
|
|
}
|
|
|
int workDayCount = workDaysListInRange.size();
|
|
|
- HashMap map = new HashMap();
|
|
|
- map.put("workHours", df.format(sum));
|
|
|
- map.put("workDayCount", workDayCount);
|
|
|
- if (workDayCount == 0) {
|
|
|
- map.put("avgWorkDayHours", 0);
|
|
|
+ if (isBatch == 1) {
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("workHours", df.format(sum));
|
|
|
+ map.put("workDayCount", workDayCount);
|
|
|
+ if (workDayCount == 0) {
|
|
|
+ map.put("avgWorkDayHours", 0);
|
|
|
+ } else {
|
|
|
+ map.put("avgWorkDayHours", df.format(sum / workDayCount));
|
|
|
+ }
|
|
|
+ httpRespMsg.setData(map);
|
|
|
} else {
|
|
|
- map.put("avgWorkDayHours", df.format(sum / workDayCount));
|
|
|
+ //单人单日的获取
|
|
|
+ List<UserFvTime> curUserTimeList = userFvTimeService.list(new QueryWrapper<UserFvTime>()
|
|
|
+ .eq("user_id", userId).eq("work_date", startDate));
|
|
|
+ System.out.println("userFvTimeList:"+curUserTimeList.size());
|
|
|
+ if (userFvTimeList.size() > 0) {
|
|
|
+ UserFvTime item = userFvTimeList.get(0);
|
|
|
+ httpRespMsg.setData(item);
|
|
|
+ } else {
|
|
|
+ httpRespMsg.setError("暂无考勤记录");
|
|
|
+ }
|
|
|
}
|
|
|
- httpRespMsg.setData(map);
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/getMinYiWorkHour")
|
|
|
- public HttpRespMsg getMinYiWorkHour(HttpServletRequest request, String startDate,String endDate){
|
|
|
+ public HttpRespMsg getMinYiWorkHour(HttpServletRequest request, String startDate,String endDate, String userId){
|
|
|
HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
DecimalFormat df = new DecimalFormat("#0.0");
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
//根据配置决定是否过滤掉周末
|
|
|
List<LocalDate> workDaysListInRange = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, timeType.getIncludeWeekends());
|
|
|
- List<UserFvTime> userFvTimeList = userFvTimeService.list(new QueryWrapper<UserFvTime>().in("work_date", workDaysListInRange).eq("company_id", user.getCompanyId()).eq("user_id", user.getId()));
|
|
|
+ List<UserFvTime> userFvTimeList = null;
|
|
|
+ if (workDaysListInRange.size() > 0) {
|
|
|
+ userFvTimeList = userFvTimeService.list(new QueryWrapper<UserFvTime>().in("work_date", workDaysListInRange).eq("company_id", user.getCompanyId()).eq("user_id", userId));
|
|
|
+ } else {
|
|
|
+ userFvTimeList = new ArrayList<>();
|
|
|
+ }
|
|
|
|
|
|
double sum = 0;
|
|
|
for (LocalDate workDay : workDaysListInRange) {
|