3.17优化
This commit is contained in:
		@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
import org.springframework.format.annotation.DateTimeFormat;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
 | 
			
		||||
@ -21,5 +22,6 @@ public class WgzAppDailyRecordReq extends PageReq {
 | 
			
		||||
	private String types;
 | 
			
		||||
 | 
			
		||||
	@ApiModelProperty(value = "日期(格式:年-月-日)")
 | 
			
		||||
	@DateTimeFormat(pattern = "yyyy-MM-dd")
 | 
			
		||||
	private LocalDate rq;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,20 @@
 | 
			
		||||
package com.ruoyi.wgz.bo.req;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotBlank;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@ApiModel("务工者APP-打卡日历请求对象")
 | 
			
		||||
public class WgzAppUserPunchTheCalendarRecordReq implements Serializable {
 | 
			
		||||
	@ApiModelProperty("年月日期:2025-02")
 | 
			
		||||
	@NotBlank(message = "年月不能为空")
 | 
			
		||||
	private String yearMonth;
 | 
			
		||||
}
 | 
			
		||||
@ -10,6 +10,7 @@ import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import com.ruoyi.wgz.bo.WgzAttendanceQueryBo;
 | 
			
		||||
import com.ruoyi.wgz.bo.req.WgzAppSubmitTheClockReq;
 | 
			
		||||
import com.ruoyi.wgz.bo.req.WgzAppUserPunchTheCalendarRecordReq;
 | 
			
		||||
import com.ruoyi.wgz.bo.res.WgzAppCardReplacementApplicationRes;
 | 
			
		||||
import com.ruoyi.wgz.bo.res.WgzAppPunchTheCalendarRecordRes;
 | 
			
		||||
import com.ruoyi.wgz.bo.res.WgzAppUserClockingConditionRes;
 | 
			
		||||
@ -86,7 +87,7 @@ public interface IWgzAttendanceService extends IServicePlus<WgzAttendance> {
 | 
			
		||||
	/**
 | 
			
		||||
	 * 打卡日历记录
 | 
			
		||||
	 */
 | 
			
		||||
	WgzAppPunchTheCalendarRecordRes userPunchTheCalendarRecord();
 | 
			
		||||
	WgzAppPunchTheCalendarRecordRes userPunchTheCalendarRecord(@Validated WgzAppUserPunchTheCalendarRecordReq req);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据id查询具体的打卡详情
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,7 @@ import com.ruoyi.fbs.domain.FbsProjectTask;
 | 
			
		||||
import com.ruoyi.fbs.service.IFbsProjectTaskService;
 | 
			
		||||
import com.ruoyi.wgz.bo.WgzAttendanceQueryBo;
 | 
			
		||||
import com.ruoyi.wgz.bo.req.WgzAppSubmitTheClockReq;
 | 
			
		||||
import com.ruoyi.wgz.bo.req.WgzAppUserPunchTheCalendarRecordReq;
 | 
			
		||||
import com.ruoyi.wgz.bo.res.WgzAppCardReplacementApplicationRes;
 | 
			
		||||
import com.ruoyi.wgz.bo.res.WgzAppPunchTheCalendarRecordRes;
 | 
			
		||||
import com.ruoyi.wgz.bo.res.WgzAppUserClockingConditionRes;
 | 
			
		||||
@ -40,12 +41,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.context.annotation.Lazy;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
 | 
			
		||||
import java.text.DecimalFormat;
 | 
			
		||||
import java.time.Duration;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.LocalTime;
 | 
			
		||||
import java.time.*;
 | 
			
		||||
import java.time.format.DateTimeFormatter;
 | 
			
		||||
import java.time.temporal.TemporalAdjusters;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
@ -295,11 +294,13 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public WgzAppPunchTheCalendarRecordRes userPunchTheCalendarRecord() {
 | 
			
		||||
	public WgzAppPunchTheCalendarRecordRes userPunchTheCalendarRecord(WgzAppUserPunchTheCalendarRecordReq req) {
 | 
			
		||||
		Long appUserId = SecurityUtils.getAppUserId();
 | 
			
		||||
		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(appUserId);
 | 
			
		||||
		//1、获取当月的所有日期
 | 
			
		||||
		LocalDate currentDate = LocalDate.now();
 | 
			
		||||
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
 | 
			
		||||
		YearMonth yearMonth = YearMonth.parse(req.getYearMonth(), formatter);
 | 
			
		||||
		LocalDate currentDate = yearMonth.atDay(1);
 | 
			
		||||
		LocalDate firstDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth());
 | 
			
		||||
		LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth());
 | 
			
		||||
		List<LocalDate> dates = new ArrayList<>();
 | 
			
		||||
@ -308,35 +309,35 @@ public class WgzAttendanceServiceImpl extends ServicePlusImpl<WgzAttendanceMappe
 | 
			
		||||
			dates.add(tempDate);
 | 
			
		||||
			tempDate = tempDate.plusDays(1);
 | 
			
		||||
		}
 | 
			
		||||
		String format = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
 | 
			
		||||
		//2、获取当前人、当前工地、当前月的所有考勤记录
 | 
			
		||||
		LambdaQueryWrapper<WgzAttendance> apply = new LambdaQueryWrapper<WgzAttendance>().
 | 
			
		||||
			eq(WgzAttendance::getUserId, appUserId).
 | 
			
		||||
			eq(WgzAttendance::getRecruitId, by.getRecruitId()).
 | 
			
		||||
			apply("DATE_FORMAT(date, '%Y-%m') = {0}", format);
 | 
			
		||||
			apply("DATE_FORMAT(date, '%Y-%m') = {0}", req.getYearMonth());
 | 
			
		||||
		List<WgzAttendance> wgzAttendances = baseMapper.selectList(apply);
 | 
			
		||||
		//3、组装返回数据
 | 
			
		||||
		Map<LocalDate, WgzAppPunchTheCalendarRecordTwo> mp = new HashMap<>();
 | 
			
		||||
		Map<LocalDate, WgzAppPunchTheCalendarRecordTwo> mp = new LinkedHashMap <>();
 | 
			
		||||
		for (LocalDate date : dates) {
 | 
			
		||||
			for (WgzAttendance wa : wgzAttendances) {
 | 
			
		||||
				WgzAppPunchTheCalendarRecordTwo two = new WgzAppPunchTheCalendarRecordTwo().setId(wa.getId());
 | 
			
		||||
				LocalDate clockDate = wa.getDate();
 | 
			
		||||
				if (clockDate.equals(date)) {
 | 
			
		||||
					//上班
 | 
			
		||||
					if (wa.getClockInTime() != null || wa.getMissedIn()== 1) {
 | 
			
		||||
					if (wa.getClockInTime() != null || wa.getMissedIn() == 1 || wa.getLeaveMarkId() != 0) {
 | 
			
		||||
						two.setNum(1);
 | 
			
		||||
						two.setSb(sbOrXb(wa, 1));
 | 
			
		||||
					}
 | 
			
		||||
					//下班
 | 
			
		||||
					if (wa.getClockOutTime() != null || wa.getMissedOut()== 1) {
 | 
			
		||||
					if (wa.getClockOutTime() != null || wa.getMissedOut()== 1 || wa.getLeaveMarkId() != 0) {
 | 
			
		||||
						two.setNum(2);
 | 
			
		||||
						if (wa.getClockInTime() != null && wa.getClockOutTime() != null ) {
 | 
			
		||||
							two.setManHour(calculateWorkingHours(wa.getClockInTime(), wa.getClockOutTime()));
 | 
			
		||||
						}
 | 
			
		||||
						two.setXb(sbOrXb(wa, 2));
 | 
			
		||||
					}
 | 
			
		||||
					mp.put(date, two);
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
				mp.put(date, two);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return new WgzAppPunchTheCalendarRecordRes().setMp(mp);
 | 
			
		||||
 | 
			
		||||
@ -170,7 +170,6 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
 | 
			
		||||
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
 | 
			
		||||
		YearMonth yearMonth = YearMonth.parse(req.getYearMonth(), formatter);
 | 
			
		||||
		LocalDate currentDate = yearMonth.atDay(1);
 | 
			
		||||
 | 
			
		||||
		LocalDate firstDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth());
 | 
			
		||||
		LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth());
 | 
			
		||||
		List<LocalDate> dates = new ArrayList<>();
 | 
			
		||||
@ -186,24 +185,24 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
 | 
			
		||||
		//3、查看当前人、当前项目、当前月是否有请假
 | 
			
		||||
        Map<LocalDate, LocalDate> ll = iWgzLeaveService.selectByUserCancelLeave(req.getYearMonth());
 | 
			
		||||
        //4、将获取的年月与数据库中的日期进行比对,然后填充数据
 | 
			
		||||
		Map<String, WgzAppAttachmentAcquisitionTwo> fh = new HashMap<>();
 | 
			
		||||
		Map<String, WgzAppAttachmentAcquisitionTwo> fh = new LinkedHashMap<>();
 | 
			
		||||
		dates.forEach(date -> {
 | 
			
		||||
			wgzDailyClocks.forEach(wgzDailyClock -> {
 | 
			
		||||
			for (WgzDailyClock wgzDailyClock : wgzDailyClocks) {
 | 
			
		||||
				LocalDate clockDate = wgzDailyClock.getDilyTime().toLocalDate();
 | 
			
		||||
				//两个时间一致就填充数据;如若有请假的日期需要将状态改为请假
 | 
			
		||||
				if (clockDate.equals(date)) {
 | 
			
		||||
					WgzAppAttachmentAcquisitionTwo wgzAppAttachmentAcquisitionTwo = new WgzAppAttachmentAcquisitionTwo().
 | 
			
		||||
						setStatus("0").//正常上传日志
 | 
			
		||||
						setId(wgzDailyClock.getId()).
 | 
			
		||||
							setId(wgzDailyClock.getId()).
 | 
			
		||||
						setDilyTime(wgzDailyClock.getDilyTime()).
 | 
			
		||||
						setPnchOsition(wgzDailyClock.getPnchOsition());
 | 
			
		||||
					if (ll.get(date) !=null && ll.get(date).equals(clockDate)) {
 | 
			
		||||
						wgzAppAttachmentAcquisitionTwo.setStatus("2"); //全天请假
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					fh.put(date.toString(),wgzAppAttachmentAcquisitionTwo);
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		//4、获取当前务工者的招工信息的主题及招工创建人的基本信息
 | 
			
		||||
		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(SecurityUtils.getAppUserId());
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user