|
@@ -6,29 +6,27 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.controller.AuditWorkflowSettingController;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.vo.SysRichFunction;
|
|
|
+import com.management.platform.entity.vo.UserRestTimeVO;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.*;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.management.platform.util.ExcelUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import com.management.platform.util.WorkDayCalculateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.xml.transform.Source;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneOffset;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -831,4 +829,66 @@ public class LeaveSheetServiceImpl extends ServiceImpl<LeaveSheetMapper, LeaveSh
|
|
|
httpRespMsg.data = leaveDays;
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getCompanyUserTime(String userName,HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ User user= userMapper.selectById(request.getHeader("token"));
|
|
|
+ if(null == user){
|
|
|
+ httpRespMsg.setError("用户不存在");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<UserRestTimeVO> resList = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取该公司全天工作时长
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
+ if(null == timeType){
|
|
|
+ httpRespMsg.setError("公司时间信息未完善,请填写");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ float allDayHours = timeType.getAllday();
|
|
|
+ if(allDayHours <=0){
|
|
|
+ httpRespMsg.setError("公司全天时长有误,请完善对应信息");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取加班时长 creatorId overTimeHours
|
|
|
+ List<UserRestTimeVO> overTimeHourList = reportMapper.getCompanyUserOverTimeHours(user.getCompanyId(),userName);
|
|
|
+
|
|
|
+ //获取已经休息的时长
|
|
|
+ List<UserRestTimeVO> restTimeHourList = leaveSheetMapper.getCompanyUserRestTimeHours(user.getCompanyId(),userName);
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(overTimeHourList)){
|
|
|
+ Map<String, UserRestTimeVO> overTimeHourMap = overTimeHourList.stream().collect(Collectors.toMap(UserRestTimeVO::getUserId, t -> t));
|
|
|
+ Map<String, UserRestTimeVO> restTimeHourMap = new HashMap<>();
|
|
|
+ if(!CollectionUtils.isEmpty(restTimeHourMap)){
|
|
|
+ restTimeHourMap = restTimeHourList.stream().collect(Collectors.toMap(UserRestTimeVO::getUserId, t -> t));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map.Entry<String, UserRestTimeVO> entry : overTimeHourMap.entrySet()) {
|
|
|
+ String userId = entry.getKey();
|
|
|
+ UserRestTimeVO tmpUserTimeVO = entry.getValue();
|
|
|
+ UserRestTimeVO restTimeUserVO = restTimeHourMap.get(userId);
|
|
|
+ if(null != restTimeUserVO){
|
|
|
+ BigDecimal leftTimeHour = tmpUserTimeVO.getOverTimeHour().subtract(restTimeUserVO.getRestTimeHour());
|
|
|
+ if(0 > leftTimeHour.compareTo(new BigDecimal(0))){
|
|
|
+ tmpUserTimeVO.setRestTimeHourStr("0.0");
|
|
|
+ tmpUserTimeVO.setRestTimeDayStr("0.0");
|
|
|
+ }else{
|
|
|
+ tmpUserTimeVO.setRestTimeHourStr(leftTimeHour.setScale(1,BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ tmpUserTimeVO.setRestTimeDayStr(leftTimeHour.divide(new BigDecimal(allDayHours), 1, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //restTimeHour就是调休时长
|
|
|
+ tmpUserTimeVO.setRestTimeHourStr(tmpUserTimeVO.getOverTimeHour().setScale(1,BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ tmpUserTimeVO.setRestTimeDayStr(tmpUserTimeVO.getOverTimeHour().divide(new BigDecimal(allDayHours), 1, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ }
|
|
|
+ resList.add(tmpUserTimeVO);
|
|
|
+ }
|
|
|
+ httpRespMsg.setData(resList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|