package com.ruoyi.web.controller.wgz.controller;


import com.ruoyi.bgt.domain.BgtProjectRecruit;
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
import com.ruoyi.bgt.domain.dto.BgtProjectRecruitQueryDTO;
import com.ruoyi.bgt.domain.vo.BgtProjectRecruitVO;
import com.ruoyi.bgt.service.IBgtProjectRecruitApplyService;
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
import com.ruoyi.common.bo.AnnexQueryBo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.domain.Annex;
import com.ruoyi.common.service.IAnnexService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysDictTypeService;
import com.ruoyi.wgz.bo.res.*;
import com.ruoyi.wgz.bo.rests.WgzAppGetTestPaperThree;
import com.ruoyi.wgz.bo.rests.WgzAppGetTestPaperTwo;
import com.ruoyi.wgz.bo.rests.WgzAutonymAnnex;
import com.ruoyi.wgz.bo.req.*;
import com.ruoyi.wgz.domain.WgzDailyClock;
import com.ruoyi.wgz.domain.WgzPayCalculation;
import com.ruoyi.wgz.domain.WgzQuestionsConfiguration;
import com.ruoyi.wgz.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * APP务工者Controller
 *
 * @author ruoyi
 * @date 2025-02-14
 */
@Api(value = "APP务工者接口", tags = {"务工者-APP接口"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController

@RequestMapping("/wgz/app")
public class WgzAppController {

	private final IWgzUserService iWgzUserService;

	@Autowired
	private ISysDictTypeService dictTypeService;

	@Autowired
	private IAnnexService iAnnexService;

	@Autowired
	private IWgzQuestionBankService iWgzQuestionBankService;

	@Autowired
	private IWgzQuestionsConfigurationService iWgzQuestionsConfigurationService;

	@Autowired
	private IWgzQuestionSaveService iWgzQuestionSaveService;

	@Autowired
	private IBgtProjectRecruitService iBgtProjectRecruitService;

	@Autowired
	private IWgzDailyClockService iWgzDailyClockService;

	@Autowired
	private  IWgzLeaveService iWgzLeaveService;

	@Autowired
	private IBgtProjectRecruitApplyService iBgtProjectRecruitApplyService;

	@Autowired
	private IWgzAttendanceService iWgzAttendanceService;

	@Autowired
	private IWgzReissueacardService iWgzReissueacardService;

	@Autowired
	private IWgzPayCalculationService iWgzPayCalculationService;


	/**
	 * 【注册】务工者注册
	 */
	@ApiOperation("APP务工者-注册")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:register')")
	@PostMapping("/wgzRegister")
	public AjaxResult<Boolean> userRegister(@Validated @RequestBody WgzAppRegisterReq bo) {
		return AjaxResult.success(iWgzUserService.userRegister(bo));
	}

	/**
	 * 【首页】【首页界面】招工列表
	 */
	@ApiOperation("首页-招工列表")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userJobListing')")
	@GetMapping("/WgzUserJobListing")
	public AjaxResult<WgzAppJobListingRes> userJobListing(@Validated WgzAppJobListingReq req) {
		//1、请求转换
		BgtProjectRecruitQueryDTO dto = new BgtProjectRecruitQueryDTO();
		BeanUtils.copyProperties(req,dto);
		//2、查询招工列表信息
		TableDataInfo<BgtProjectRecruitVO> info = iBgtProjectRecruitService.appQueryPageList(dto);
		//3、将招工信息转换
		WgzAppJobListingRes wgzAppJobListingRes = new WgzAppJobListingRes();
		BeanUtils.copyProperties(info,wgzAppJobListingRes);
		return AjaxResult.success(wgzAppJobListingRes);
	}

	/**
	 * 【我的】【个人基本信息】修改用户头像
	 */
	@ApiOperation("我的-修改用户头像")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userModifyingUserProfilePicture')")
	@PutMapping("/wgzUserModifyingUserProfilePicture")
	public AjaxResult<Boolean> userModifyingUserProfilePicture(@Validated @RequestBody WgzAppModifyingUserProfilePictureReq req) {
		return AjaxResult.success(iWgzUserService.userModifyingUserProfilePicture(req));
	}

	/**
	 * 【我的】【个人基本信息】查询基础用户信息（还未带附件信息）
	 */
	@ApiOperation("我的-个人基本信息（还未带附件信息）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userPersonalBasicInformation')")
	@GetMapping("/wgzUserPersonalBasicInformation")
	public AjaxResult<WgzAppPersonalBasicInformationRes> userPersonalBasicInformation(@Validated WgzAppPersonalBasicInformationReq req) {
		return AjaxResult.success(iWgzUserService.userPersonalBasicInformation(req));
	}

	/**
	 * 【我的】【实名认证】实名认证
	 */
	@ApiOperation("我的-实名认证")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userRealNameAuthentication')")
	@PutMapping("/wgzUserRealNameAuthentication")
	public AjaxResult<Boolean> userRealNameAuthentication(@Validated @RequestBody WgzAppRealNameAuthenticationReq req) {
		return AjaxResult.success(iWgzUserService.userRealNameAuthentication(req));
	}

	/**
	 * 【我的】【岗前培训】获取安全教育考试试卷（随机获取）
	 */
	@ApiOperation("我的-岗前培训·获取随机试卷")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userGetTestPaper')")
	@GetMapping("/WgzUserGetTestPaper")
	public AjaxResult<WgzAppGetTestPaperRes> userGetTestPaper() {
		//1、获取配置信息
		WgzQuestionsConfiguration configuration = iWgzQuestionsConfigurationService.appQueryLimitOne();
		if (configuration == null) {
			throw new RuntimeException("未查询到配置信息");
		}
		//2、随机获取数据，返回id和score
		Integer s = configuration.getSingleChoice();
		Integer m = configuration.getMultipleChoice();
		Integer e = configuration.getEstimate();
		List<WgzAppGetTestPaperThree> sEntity = iWgzQuestionBankService.appQueryList(1, s);
		List<WgzAppGetTestPaperThree> mEntity = iWgzQuestionBankService.appQueryList(2, m);
		List<WgzAppGetTestPaperThree> eEntity = iWgzQuestionBankService.appQueryList(3, e);
		//3、组装数据
		WgzAppGetTestPaperRes res = new WgzAppGetTestPaperRes();
		res.setSingleList(createQuestionSection("一、单选题", sEntity, configuration.getSingleScore(), s));
		res.setMultipleList(createQuestionSection("二、多选题", mEntity, configuration.getMultipleScore(), m));
		res.setEstimateList(createQuestionSection("三、判断题", eEntity, configuration.getEstimateScore(), e));
		//4、设置最大考试时间
		res.setMaximum(configuration.getAnswerTime());
		return AjaxResult.success(res);
	}

	/**
	 * 【我的】【岗前培训】提交用户的试卷（只保存最高分的试卷信息）
	 */
	@ApiOperation("我的-岗前培训·提交试卷")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userSubmitATestPaper')")
	@PostMapping("/WgzUserSubmitATestPaper")
	public AjaxResult<WgzAppSubmitATestPaperRes> userSubmitATestPaper(@Validated @RequestBody WgzAppSubmitATestPaperReq req) {
		return AjaxResult.success(iWgzQuestionSaveService.userSubmitATestPaper(req));
	}

	/**
	 * 【我的】【请假】 历史请假列表
	 */
	@ApiOperation("我的-请假·历史请假列表")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userLeaveHistoryList')")
	@GetMapping("/WgzAppUserLeaveHistoryListPage")//PageReq
	public TableDataInfo<WgzAppLeaveHistoryListPageRes> userLeaveHistoryListPage(@Validated WgzAppLeaveHistoryListPageReq req) {
		return iWgzLeaveService.userLeaveHistoryListPage(req);
	}

	/**
	 * 【我的】【请假】 提交请假（上下班的时间需要等待zt创建好mysql字段）
	 */
	@ApiOperation("我的-请假·提交请假（上下班的时间需要等待zt创建好mysql字段）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userSubmitLeave')")
	@PostMapping("/WgzAppSubmitLeave")
	public AjaxResult<Boolean> userSubmitLeave(@Validated @RequestBody WgzAppSubmitLeaveReq req) {
		return AjaxResult.success(iWgzLeaveService.userSubmitLeave(req));
	}

	/**
	 * 【我的】【请假】 取消请假
	 */
	@ApiOperation("我的-请假·取消请假")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userCancelLeave')")
	@PutMapping("/WgzAppUserCancelLeave")
	public AjaxResult<Boolean> userCancelLeave(@Validated @RequestBody WgzAppCancelLeaveReq req) {
		return AjaxResult.success(iWgzLeaveService.userCancelLeave(req));
	}

	/**
	 * 【日报】日报日历
	 */
	@ApiOperation("日报-日报日历")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userDailyCalendar')")
	@GetMapping("/WgzUserDailyCalendar")
	public AjaxResult<WgzUserDailyCalendarRes> userDailyCalendar(@Validated WgzAppDailyCalendarReq req) {
		WgzUserDailyCalendarRes wfzUserDailyCalendarRes = iWgzDailyClockService.userDailyCalendar(req);
		return AjaxResult.success(wfzUserDailyCalendarRes);
	}

	/**
	 * 【日报】日报日历·日报记录
	 */
	@ApiOperation("日报-日报日历·日报记录")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userDailyRecord')")
	@GetMapping("/WgzUserDailyRecord")
	public TableDataInfo<WgzAppUserDailyRecordRes> userDailyRecord(@Validated WgzAppDailyRecordReq req) {
		return iWgzDailyClockService.userDailyRecord(req);
	}

	/**
	 * 【日报】日报日历·查看日报
	 */
	@ApiOperation("日报-日报日历·查看日报")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userCheckDailyNewspaper')")
	@GetMapping("/WgzUserCheckDailyNewspaper/{id}")
	public AjaxResult<WgzDailyClock> userCheckDailyNewspaper(@NotNull(message = "主键不能为空") @PathVariable("id") Long id) {
		return AjaxResult.success(iWgzDailyClockService.userCheckDailyNewspaper(id));
	}

	/**
	 * 【考勤打卡】【打卡】 提交上下班打卡·查看当前用户的打卡状态（0上班 1下班 2请假）
	 */
	@ApiOperation("【考勤打卡】【打卡】 提交上下班打卡·用户今日打卡状态（0上班 1下班 2请假）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userClockingCondition')")
	@GetMapping("/WgzAppUserClockingCondition")
	public AjaxResult<WgzAppUserClockingConditionRes> userClockingCondition() {
		return AjaxResult.success(iWgzAttendanceService.userClockingCondition());
	}

	/**
	 * 【考勤打卡】【打卡】 提交上下班打卡
	 */
	@ApiOperation("【考勤打卡】【打卡】 提交上下班打卡）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userSubmitTheClock')")
	@PostMapping("/WgzAppUserSubmitTheClock")
	public AjaxResult<Boolean> userSubmitTheClock(@Validated @RequestBody WgzAppSubmitTheClockReq req) {
		return AjaxResult.success(iWgzAttendanceService.userSubmitTheClock(req));
	}

	/**
	 * 【考勤打卡】【打卡日历】 打卡日历记录
	 */
	@ApiOperation("【考勤打卡】【打卡日历】 打卡日历记录）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userPunchTheCalendarRecord')")
	@GetMapping("/WgzAppUserPunchTheCalendarRecord")
	public AjaxResult<WgzAppPunchTheCalendarRecordRes> userPunchTheCalendarRecord() {
		return AjaxResult.success(iWgzAttendanceService.userPunchTheCalendarRecord());
	}

	/**
	 * 【考勤打卡】【打卡日历】 补卡申请列表
	 */
	@ApiOperation("【考勤打卡】【打卡日历】 补卡申请列表")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userCardReplacementApplicationList')")
	@GetMapping("/WgzAppUserCardReplacementApplicationList")
	public AjaxResult<WgzAppCardReplacementApplicationRes> userCardReplacementApplication() {
		return AjaxResult.success(iWgzAttendanceService.userCardReplacementApplication());
	}

	/**
	 * 【考勤打卡】【打卡日历】 补卡申请
	 */
	@ApiOperation("【考勤打卡】【打卡日历】 补卡申请）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userCardReplacementApplication')")
	@PostMapping("/WgzAppUserCardReplacementApplication")
	public AjaxResult<Boolean> userCardReplacementApplication(@Validated @RequestBody WgzAppCardReplacementApplicationReq req) {
		return AjaxResult.success(iWgzReissueacardService.userCardReplacementApplication(req));
	}

	/**
	 * 【考勤打卡】【打卡日历】 补卡记录
	 */
	@ApiOperation("【考勤打卡】【打卡日历】 补卡记录）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userReplacementCardRecord')")
	@GetMapping("/WgzAppUserReplacementCardRecord")
	public TableDataInfo<WgzReplacementCardRecordRes> userReplacementCardRecord(@Validated WgzAppReplacementCardRecordReq req) {
		return iWgzReissueacardService.userReplacementCardRecord(req);
	}

	/**
	 * 【首页】【项目详情】 项目详情
	 */
	@ApiOperation("【首页】【项目详情】 项目详情）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userProjectDetails')")
	@GetMapping("/WgzAppUserProjectDetails/{id}")
	public AjaxResult<WgzAppProjectDetailsRes> userProjectDetails(@NotNull(message = "主键不能为空") @PathVariable("id") Long id) {
		return AjaxResult.success(iBgtProjectRecruitService.userProjectDetails(id));
	}

	/**
	 * 【首页】【项目详情】 项目详情·申请报名（还未校验工种是否匹配工地岗位）
	 */
	@ApiOperation("【首页】【项目详情】 项目详情·申请报名）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userApplyForRegistration')")
	@GetMapping("/WgzAppUserApplyForRegistration/{id}")
	public AjaxResult<Boolean> userApplyForRegistration(@NotNull(message = "主键不能为空") @PathVariable("id") Long id) {
		return AjaxResult.success(iBgtProjectRecruitApplyService.userApplyForRegistration(id));
	}

	/**
	 * 【首页】【已报名项目】 已报名项目
	 */
	@ApiOperation("【首页】【已报名项目】 已报名项目）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userRegisteredProject')")
	@GetMapping("/WgzAppUserRegisteredProject")
	public TableDataInfo<WgzAppRegisteredProjectRes> userRegisteredProject(@Validated WgzAppRegisteredProjectReq req) {
		return iBgtProjectRecruitService.userRegisteredProject(req);
	}

	/**
	 * 【首页】【已报名项目】 已报名项目·取消报名
	 */
	@ApiOperation("【首页】【已报名项目】 已报名项目·取消报名）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userCancelRegistration')")
	@DeleteMapping("/WgzAppUserCancelRegistration/{recruitId}")
	public AjaxResult<Boolean> userCancelRegistration(@NotEmpty(message = "招工主键不能为空") @PathVariable Long recruitId) {
		return AjaxResult.success(iBgtProjectRecruitApplyService.userCancelRegistration(recruitId));
	}

	/**
	 * 【首页】【已报名项目】 已报名项目·项目详情
	 */
	@ApiOperation("【首页】【已报名项目】 已报名项目·项目详情")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userCancelRegistrationProjectDetails')")
	@GetMapping("/WgzAppUserCancelRegistrationProjectDetails/{recruitId}")
	public AjaxResult<WgzAppCancelRegistrationProjectDetailsRes> userCancelRegistrationProjectDetails(@NotEmpty(message = "招工主键不能为空") @PathVariable Long recruitId) {
		return AjaxResult.success(iBgtProjectRecruitService.userCancelRegistrationProjectDetails(recruitId));
	}

	/**
	 * 【首页】【项目进行中】 项目进行中（分页，但是理论上这里始终只会有一条数据）
	 * 【首页】【已完成项目】 已完成项目
	 */
	@ApiOperation("【首页】【项目进行中|已完成项目】 项目进行中")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userUnderway')")
	@GetMapping("/WgzAppUserUnderway")
	public TableDataInfo<WgzAppUnderwayRes> userUnderway(@Validated WgzAppUnderwayReq req) {
		return iBgtProjectRecruitApplyService.userUnderway(req);
	}

	/**
	 * 【首页】【项目进行中】 项目进行中·详情
	 * 【首页】【已完成项目】 已完成项目·详情
	 */
	@ApiOperation("【首页】【项目进行中|已完成项目】 详情")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userProjectInProgressDetails')")
	@GetMapping("/WgzAppUserProjectInProgressDetails/{id}")
	public AjaxResult<WgzApplyForPayrollSettlementAddRes> userProjectInProgressDetails(@NotNull(message = "主键不能为空") @PathVariable("id") Long id) {
		WgzApplyForPayrollSettlementAddRes res = new WgzApplyForPayrollSettlementAddRes();
		Long appUserId = SecurityUtils.getAppUserId();
		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(appUserId);
		BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getId());
		//1、先获取项目详情基本信息
		WgzAppProjectDetailsRes wgzAppProjectDetailsRes = iBgtProjectRecruitService.userProjectDetails(id);
		BeanUtils.copyProperties(wgzAppProjectDetailsRes, res);
		//2、获取当前人员的打卡天数*单天金额=实际总工资金额
		BigDecimal recruitAmount = appById.getRecruitAmount();
		//查询实际考勤时间（只要有打卡就算出勤一条，异常也视为正常出勤,也就是说只要有上班or下班至少有一个有数据，那就证明出勤ok）
		Integer i = iWgzAttendanceService.attendanceDetail(appUserId, appById.getId(), null);
		if (i==0){
			res.setNum(0);
			res.setTotalAmount(BigDecimal.valueOf(0));
		}else{
			BigDecimal totalAmount = recruitAmount.multiply(BigDecimal.valueOf(i));
			res.setNum(i);
			res.setTotalAmount(totalAmount);
		}
		res.setEntryTime(by.getEntryTime()).
			setLeaveTime(by.getLeaveTime()).
			setAmount(recruitAmount);
		//3、查询当前进行中的项目是否有工资结算
		WgzPayCalculation gz = iWgzPayCalculationService.findByUserIdRecruitIdNewestData(appUserId, appById.getId());
		if (gz != null){
			//金额*天数=实际工资
			res.setAppliedAmount(gz.getRecruitAmount().multiply(BigDecimal.valueOf(gz.getNum())));
			res.setNameOfApplicant(gz.getUserName());
		}
		if(i!=0){
			//总的金额/结算的金额=百分比
			BigDecimal divide = res.getTotalAmount().divide(res.getAmount(), 2, BigDecimal.ROUND_HALF_UP);
			res.setPercentage(divide.doubleValue());
		}
		return AjaxResult.success(res);
	}

	/**
	 * 【首页】【项目进行中】 项目进行中·申请工资结算（新增）
	 * 【首页】【已完成项目】 已完成项目·申请工资结算（新增）
	 */
	@ApiOperation("【首页】【项目进行中|已完成项目】 申请工资结算（新增）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userApplyForPayrollSettlementAdd')")
	@PostMapping("/WgzAppUserApplyForPayrollSettlementAdd")
	public AjaxResult<Boolean> userApplyForPayrollSettlementAdd(@Validated @RequestBody WgzApplyForPayrollSettlementAddReq req) {
		return AjaxResult.success(iWgzPayCalculationService.userApplyForPayrollSettlementAdd(req));
	}

	/**
	 * 【首页】【项目进行中】 项目进行中·申请工资结算（列表）
	 */
	@ApiOperation("【首页】【项目进行中】 项目进行中·申请工资结算（列表）")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userApplyForPayrollSettlementList')")
	@GetMapping("/WgzAppUserApplyForPayrollSettlementList")
	public TableDataInfo<WgzAppApplyForPayrollSettlementListRes> userApplyForPayrollSettlementList(@Validated WgzAppApplyForPayrollSettlementListReq req) {
		return iWgzPayCalculationService.userApplyForPayrollSettlementList(req);
	}






	/**
	 * 通用接口
	 * =================================================================================================================
	 * =================================================================================================================
	 * =================================================================================================================
	 */

	/**
	 * 【我的】【实名认证】实名认证之务工者附件结构获取
	 		0-资格证书
	 * 【我的】【签协议】协议列表
	 		1-劳动合同
	 */
	@ApiOperation("通用·附件获取(仅限和务工者直接关联的)")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userAttachmentAcquisition')")
	@GetMapping("/wgzUserAttachmentAcquisition")
	public AjaxResult<WgzAppAttachmentAcquisitionRes> userAttachmentAcquisition(@Validated WgzAppAttachmentAcquisitionReq req) {
		//返回对象
		WgzAppAttachmentAcquisitionRes wgzAppAttachmentAcquisitionRes = new WgzAppAttachmentAcquisitionRes();
		List<WgzAutonymAnnex> resData = new ArrayList<>();
		//附件类型
		String userType = "wgz_attachment";
		//具体附件值
		String[] specifiedAttachment = req.getSpecifiedAttachment();
		//String[] SpecifiedAttachment = {"0"};

		//1、获取指定实名认证的附件结构返回
		List<SysDictData> data = dictTypeService.selectDictDataByType(userType);
		data.forEach(item -> {
			for (String val : specifiedAttachment) {
				String dictValue = item.getDictValue();
				if (dictValue.equals(val)) {
					//2、每个结构下有那些附件（附件可能有多个或一个）；查询附件表
					AnnexQueryBo annexQueryBo = new AnnexQueryBo();
					annexQueryBo.setUserId(req.getUserId());
					annexQueryBo.setUserType(userType);
					annexQueryBo.setAnnexType(val);
					List<Annex> annexes = iAnnexService.queryList(annexQueryBo);
					//3、具体附件结构
					WgzAutonymAnnex wgzAutonymAnnex = new WgzAutonymAnnex().
						setUserType(userType).
						setDictLabel(item.getDictLabel()).
						setDictValue(dictValue).setAnnex(annexes);
					resData.add(wgzAutonymAnnex);
				}
			}
		});
		return AjaxResult.success(wgzAppAttachmentAcquisitionRes.setWgzAutonymAnnex(resData));
	}

	/**
	 * 【我的】【请假】 获取上下班时间
	 * 【考勤打卡】【打卡】 获取上下班时间
	 */
	@ApiOperation("通用·获取上下班时间")
	@PreAuthorize("@ss.hasPermi('wgzApp:user:userGetCommutingTime')")
	@GetMapping("/WgzAppUserGetCommutingTime")//PageReq
	public AjaxResult<Map<String, LocalTime>> userGetCommutingTime() {
		//1、获取当前人、当前工的上下班时间范围
		Long appUserId = SecurityUtils.getAppUserId();
		//2、根据唯一标识获取到当前用户的招工
		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(appUserId);
		//3、根据招工id获取到具体招工信息
		BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getId());
		Map<String, LocalTime> mp = new HashMap<>();
		mp.put("beginWorkTime", appById.getBeginWorkTime());
		mp.put("endWorkTime", appById.getEndWorkTime());
		return AjaxResult.success(mp);
	}



	/**
	 * 控制层业务
	 * =================================================================================================================
	 * =================================================================================================================
	 * =================================================================================================================
	 */

	/**
	 * 创建题目板块
	 * @param topicPrefix 板块标题前缀
	 * @param questions 题目列表
	 * @param score 每题分数
	 * @param questionCount 题目数量
	 * @return 题目板块实体
	 */
	private WgzAppGetTestPaperTwo createQuestionSection(String topicPrefix, List<WgzAppGetTestPaperThree> questions, Float score, int questionCount) {
		WgzAppGetTestPaperTwo section = new WgzAppGetTestPaperTwo();
		section.setTopic(String.format("%s，共%d道题，每小题%.2f分，共计%.2f分", topicPrefix, questionCount, score, questionCount * score));
		questions.forEach(item -> item.setScore(score));
		section.setList(questions);
		return section;
	}

	/**
	 * 【我的】【实名认证】实名认证·删除附件
	 */
//	@ApiOperation("APP务工者-实名认证·删除附件")
//	@PreAuthorize("@ss.hasPermi('wgzApp:user:userDeleteAttachment')")
//	@DeleteMapping("/WgzUserDeleteAttachment/{attachmentId}")
//	public AjaxResult<Boolean> userDeleteAttachment(@NotEmpty(message = "主键不能为空") @PathVariable Long attachmentId) {
//		return AjaxResult.success(iAnnexService.deleteByIds(attachmentId));
//	}


	/**
	 * 【首页】【项目进行中】 项目进行中·申请工资结算（查询）
	 */
//	@ApiOperation("【首页】【项目进行中】 项目进行中·申请工资结算（查询）")
//	@PreAuthorize("@ss.hasPermi('wgzApp:user:userApplyForPayrollSettlementFind')")
//	@GetMapping("/WgzAppUserApplyForPayrollSettlementFind")
//	public AjaxResult<WgzApplyForPayrollSettlementFindRes> userApplyForPayrollSettlementFind(@Validated WgzApplyForPayrollSettlementFindReq req) {
//		Long appUserId = SecurityUtils.getAppUserId();
//		BgtProjectRecruitApply by = iBgtProjectRecruitApplyService.selectByUserIdProjectRecruitApplyId(appUserId);
//		BgtProjectRecruit appById = iBgtProjectRecruitService.getAppById(by.getId());
//		//1、查询入场时间、退场时间、单天金额
//		BigDecimal recruitAmount = appById.getRecruitAmount();
//		//2、查询实际考勤时间（只要有打卡就算出勤一条，异常也视为正常出勤,也就是说只要有上班or下班至少有一个有数据，那就证明出勤ok）
//		Integer i = iWgzAttendanceService.attendanceDetail(appUserId, appById.getId(), req.getNum());
//		if (i == 0){
//			throw new RuntimeException("您还未打卡");
//		}
//		//3、单天金额*实际考勤总天数=实际工资
//		BigDecimal totalAmount = recruitAmount.multiply(BigDecimal.valueOf(i));
//		WgzApplyForPayrollSettlementFindRes res = new WgzApplyForPayrollSettlementFindRes().
//			setEntryTime(by.getEntryTime()).
//			setLeaveTime(by.getLeaveTime()).
//			setAmount(recruitAmount).
//			setNum(i).
//			setTotalAmount(totalAmount);
//		return AjaxResult.success(res);
//	}

}
