|
@@ -30,6 +30,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
@@ -105,6 +106,10 @@ public class ReportController {
|
|
|
private LeaveSheetService leaveSheetService;
|
|
|
@Resource
|
|
|
private EstimateTimeSettingMapper estimateTimeSettingMapper;
|
|
|
+ @Resource
|
|
|
+ private UserFvTimeMapper userFvTimeMapper;
|
|
|
+ @Resource
|
|
|
+ private UserCustomMapper userCustomMapper;
|
|
|
|
|
|
//获取任务相关的日报列表
|
|
|
@RequestMapping("/getTaskReportList")
|
|
@@ -1723,6 +1728,78 @@ public class ReportController {
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/checkBeiSengCardTime")
|
|
|
+ public HttpRespMsg checkBeiSengCardTime(String userId, String dateWorkingTime) throws Exception {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ JSONArray array = JSONArray.parseArray(dateWorkingTime);
|
|
|
+ List<UserCustom> userCustomList = userCustomMapper.selectList(new LambdaQueryWrapper<UserCustom>().eq(UserCustom::getCompanyId, user.getCompanyId()));
|
|
|
+ List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, user.getCompanyId()));
|
|
|
+ DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ List<LocalDate> dateList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
+ JSONObject jsonObject = array.getJSONObject(i);
|
|
|
+ LocalDate date = LocalDate.parse(jsonObject.getString("date"), df);
|
|
|
+ dateList.add(date);
|
|
|
+ }
|
|
|
+ Optional<LocalDate> max = dateList.stream().max(LocalDate::compareTo);
|
|
|
+ Optional<LocalDate> min = dateList.stream().min(LocalDate::compareTo);
|
|
|
+ //获取景昱的考勤和加班时长,进行比对,如果有不一致的,返回错误
|
|
|
+ //错误信息格式:有加班工资的情况下,返回 异常:2024-04-18日填报工时(6h)不等于考勤总时长(8h);无加班工资情况下,返回 异常:2024-04-18日填报工时(8h)少于考勤工时(10h)
|
|
|
+ List<UserFvTime> userFvTimeList = userFvTimeMapper.selectList(new LambdaQueryWrapper<UserFvTime>().between(UserFvTime::getWorkDate, df.format(min.get()), df.format(max.get())));
|
|
|
+ StringBuilder warningMsg = new StringBuilder();
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
+ JSONObject jsonObject = array.getJSONObject(i);
|
|
|
+ LocalDate date = LocalDate.parse(jsonObject.getString("date"), df);
|
|
|
+ double workingTime = jsonObject.getDouble("workingTime");
|
|
|
+ Optional<UserFvTime> first = userFvTimeList.stream().filter(u -> u.getWorkDate().isEqual(date) && u.getUserId().equals(userId)).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ if(first.get().getWorkHours()!=null){
|
|
|
+ Optional<User> optional = userList.stream().filter(u -> u.getId().equals(userId)).findFirst();
|
|
|
+ User targetUser = optional.get();
|
|
|
+ List<String> customList = userCustomList.stream().map(UserCustom::getName).collect(Collectors.toList());
|
|
|
+ if(customList.size()>0&&customList.contains("是否有加班费")){
|
|
|
+ int index = customList.indexOf("是否有加班费");
|
|
|
+ targetUser.getPlate1();
|
|
|
+ String getter="getPlate"+(index+1);
|
|
|
+ Class<User> aClass = User.class;
|
|
|
+ Method method = aClass.getMethod(getter);
|
|
|
+ String invoke = (String) method.invoke(targetUser);
|
|
|
+ if(StringUtils.isEmpty(invoke)){
|
|
|
+ msg.setError("人员未设置薪资类型,请联系管理人员");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if(invoke.equals("有加班费")){
|
|
|
+ if(!(Double.valueOf(String.valueOf(workingTime)).equals(Double.valueOf(first.get().getWorkHours())))){
|
|
|
+ if(warningMsg.length()>0){
|
|
|
+ warningMsg.append(",");
|
|
|
+ }
|
|
|
+ warningMsg.append(df.format(date)+"日填报工时("+workingTime+"h)不等于考勤总时长("+first.get().getWorkHours()+"h)");
|
|
|
+ }
|
|
|
+ }else if(invoke.equals("无加班费")){
|
|
|
+ if((Double.valueOf(String.valueOf(workingTime))<first.get().getWorkHours())){
|
|
|
+ if(warningMsg.length()>0){
|
|
|
+ warningMsg.append(",");
|
|
|
+ }
|
|
|
+ warningMsg.append(df.format(date)+"日填报工时("+workingTime+"h)少于考勤工时("+first.get().getWorkHours()+"h)");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ warningMsg.append("未查询到考勤信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String warningMsgStr = warningMsg.toString();
|
|
|
+ if (!StringUtils.isEmpty(warningMsgStr)) {
|
|
|
+ if(warningMsgStr.length()>100){
|
|
|
+ warningMsgStr = warningMsgStr.substring(0, 100)+"...";
|
|
|
+ }
|
|
|
+ msg.setError(warningMsgStr);
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
private void fillReportHours(Report report, BigDecimal hourCost, Double workingTime, Integer timeType, String startTime, String endTime, SimpleDateFormat sdf, TimeType comTimeType, List<TimeAutoExclude> excludeTimeList) {
|
|
|
if (report.getMultiWorktime() == 0) {
|
|
|
//普通工时成本计算
|