|
|
|
|
@ -1,22 +1,24 @@
|
|
|
|
|
package com.ruoyi.wgz.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
|
|
import com.ruoyi.bgt.domain.BgtMessage;
|
|
|
|
|
import com.ruoyi.bgt.domain.BgtProjectRecruit;
|
|
|
|
|
import com.ruoyi.bgt.domain.BgtProjectRecruitApply;
|
|
|
|
|
import com.ruoyi.bgt.domain.dto.BgtPayCalculationDetailBaseVO;
|
|
|
|
|
import com.ruoyi.bgt.domain.dto.BgtPayCalculationDetailListVO;
|
|
|
|
|
import com.ruoyi.bgt.domain.dto.BgtApplyForWgzPayAddDTO;
|
|
|
|
|
import com.ruoyi.bgt.domain.dto.BgtPayCalculationListDTO;
|
|
|
|
|
import com.ruoyi.bgt.domain.dto.BgtPayCalculationRecordDTO;
|
|
|
|
|
import com.ruoyi.bgt.domain.dto.BgtPayCalculationUpdateDTO;
|
|
|
|
|
import com.ruoyi.bgt.service.IBgtMessageService;
|
|
|
|
|
import com.ruoyi.bgt.domain.vo.BgtApplyForWgzPayAddInfoVO;
|
|
|
|
|
import com.ruoyi.bgt.domain.vo.BgtPayCalculationDetailBaseVO;
|
|
|
|
|
import com.ruoyi.bgt.domain.vo.BgtPayCalculationDetailListVO;
|
|
|
|
|
import com.ruoyi.bgt.service.IBgtProjectRecruitApplyService;
|
|
|
|
|
import com.ruoyi.bgt.service.IBgtProjectRecruitService;
|
|
|
|
|
import com.ruoyi.common.constants.WgzAndBgtMessageConstant;
|
|
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
|
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
@ -32,15 +34,16 @@ import com.ruoyi.wgz.bo.res.WgzAppApplyForPayrollSettlementListRes;
|
|
|
|
|
import com.ruoyi.wgz.domain.*;
|
|
|
|
|
import com.ruoyi.wgz.mapper.WgzPayCalculationMapper;
|
|
|
|
|
import com.ruoyi.wgz.service.*;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.ruoyi.common.constants.BgtMessageConstant.*;
|
|
|
|
|
import static com.ruoyi.common.constants.WgzAndBgtMessageConstant.*;
|
|
|
|
|
@ -75,12 +78,6 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
|
|
|
|
|
@Autowired
|
|
|
|
|
private IWgzMessageService wgzMessageService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IWgzMessageService iWgzMessageService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IBgtMessageService iBgtMessageService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IWgzAttendanceService iWgzAttendanceService;
|
|
|
|
|
|
|
|
|
|
@ -341,16 +338,28 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean appUpdate(BgtPayCalculationUpdateDTO dto) {
|
|
|
|
|
WgzPayCalculation payCalculation = getById(dto.getId());
|
|
|
|
|
BeanUtil.copyProperties(dto, payCalculation);
|
|
|
|
|
boolean isPass = AuditStatus.PASS.getCode().equals(dto.getAuditorType());
|
|
|
|
|
payCalculation.setAuditorTime(LocalDateTime.now());
|
|
|
|
|
if(!isPass){
|
|
|
|
|
List<WgzPayCalculationMiddle> list = iWgzPayCalculationMiddleService.list(Wrappers.<WgzPayCalculationMiddle>lambdaQuery()
|
|
|
|
|
.eq(WgzPayCalculationMiddle::getCalculationId, dto.getId()));
|
|
|
|
|
if(CollectionUtils.isNotEmpty(list)){
|
|
|
|
|
List<Long> collect = list.stream().map(WgzPayCalculationMiddle::getAttendanceId).collect(Collectors.toList());
|
|
|
|
|
attendanceService.lambdaUpdate().in(WgzAttendance::getId,collect)
|
|
|
|
|
.set(WgzAttendance::getSettlement, 0).update();
|
|
|
|
|
iWgzPayCalculationMiddleService.removeByIds(list.stream().map(WgzPayCalculationMiddle::getId).collect(Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//发消息
|
|
|
|
|
HashMap<String, String> mp = new HashMap<>();
|
|
|
|
|
mp.put("projectName",iBgtProjectRecruitService.getById(payCalculation.getRecruitId()).getRecruitName());
|
|
|
|
|
mp.put("auditor",SecurityUtils.getUsername());
|
|
|
|
|
Map<String, String> map = bgtMessage(mp, BGT_TYPE_PAY, AuditStatus.PASS.getCode().equals(dto.getAuditorType()));
|
|
|
|
|
Map<String, String> map = bgtMessage(mp, BGT_TYPE_PAY, isPass);
|
|
|
|
|
WgzMessage wgzMessage = new WgzMessage()
|
|
|
|
|
.setSenderType(USERTYPE_BGT)
|
|
|
|
|
.setSenderId(SecurityUtils.getAppUserId())
|
|
|
|
|
@ -380,6 +389,7 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
|
|
|
|
|
vo.setScore(wgzUser.getScore());
|
|
|
|
|
vo.setUsername(wgzUser.getUsername());
|
|
|
|
|
vo.setAvatarName(wgzUser.getAvatarName());
|
|
|
|
|
vo.setIdentityCard(wgzUser.getIdentityCard());
|
|
|
|
|
|
|
|
|
|
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(recruitId);
|
|
|
|
|
vo.setRecruitName(recruit.getRecruitName());
|
|
|
|
|
@ -387,6 +397,10 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
|
|
|
|
|
FbsProjectTask task = taskService.getById(recruit.getTaskId());
|
|
|
|
|
vo.setTaskName(task.getTaskName());
|
|
|
|
|
|
|
|
|
|
vo.setUserId(userId);
|
|
|
|
|
vo.setRecruitId(recruitId);
|
|
|
|
|
vo.setTaskId(recruit.getTaskId());
|
|
|
|
|
|
|
|
|
|
BgtProjectRecruitApply apply = iBgtProjectRecruitApplyService.getOne(Wrappers.<BgtProjectRecruitApply>lambdaQuery()
|
|
|
|
|
.eq(BgtProjectRecruitApply::getRecruitId, recruitId).eq(BgtProjectRecruitApply::getUserId, userId)
|
|
|
|
|
.last("limit 1"));
|
|
|
|
|
@ -410,10 +424,99 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<BgtPayCalculationDetailListVO> record(Long userId, Long recruitId) {
|
|
|
|
|
List<WgzPayCalculation> wgzPayCalculations = baseMapper.selectList(Wrappers.<WgzPayCalculation>lambdaQuery()
|
|
|
|
|
public TableDataInfo<BgtPayCalculationDetailListVO> record(BgtPayCalculationRecordDTO dto) {
|
|
|
|
|
LambdaQueryWrapper<WgzPayCalculation> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
wrapper.eq(WgzPayCalculation::getUserId, dto.getUserId())
|
|
|
|
|
.eq(WgzPayCalculation::getRecruitId, dto.getRecruitId())
|
|
|
|
|
.eq(WgzPayCalculation::getAuditorUserId, SecurityUtils.getAppUserId())
|
|
|
|
|
.in(WgzPayCalculation::getAuditorType,AuditStatus.getAudit())
|
|
|
|
|
.orderByDesc(WgzPayCalculation::getCreateTime);
|
|
|
|
|
Page<WgzPayCalculation> result = page(PageUtils.buildPage(), wrapper);
|
|
|
|
|
Page<BgtPayCalculationDetailListVO> res = new Page<>();
|
|
|
|
|
res.setRecords(BeanUtil.copyToList(result.getRecords(), BgtPayCalculationDetailListVO.class));
|
|
|
|
|
res.setTotal(result.getTotal());
|
|
|
|
|
return PageUtils.buildDataInfo(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public Boolean bgtAdd(BgtApplyForWgzPayAddDTO dto) {
|
|
|
|
|
|
|
|
|
|
//添加申请
|
|
|
|
|
WgzPayCalculation payCalculation = BeanUtil.copyProperties(dto, WgzPayCalculation.class);
|
|
|
|
|
payCalculation.setAuditorType(AuditStatus.PASS.getCode());
|
|
|
|
|
payCalculation.setAuditorTime(LocalDateTime.now());
|
|
|
|
|
payCalculation.setAuditorUserId(SecurityUtils.getAppUserId());
|
|
|
|
|
payCalculation.setAuditorUserName(SecurityUtils.getUsername());
|
|
|
|
|
payCalculation.setOperatorType(Constants.BGT);
|
|
|
|
|
boolean save = save(payCalculation);
|
|
|
|
|
|
|
|
|
|
//修改标记,添加中间表
|
|
|
|
|
List<WgzPayCalculationMiddle> middleList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
List<WgzAttendance> list = iWgzAttendanceService.list(Wrappers.<WgzAttendance>lambdaQuery()
|
|
|
|
|
.eq(WgzAttendance::getRecruitId, dto.getRecruitId())
|
|
|
|
|
.eq(WgzAttendance::getSettlement, 0));
|
|
|
|
|
for(WgzAttendance data : list) {
|
|
|
|
|
data.setSettlement(1);
|
|
|
|
|
WgzPayCalculationMiddle wgzPayCalculationMiddle = new WgzPayCalculationMiddle();
|
|
|
|
|
wgzPayCalculationMiddle.setCalculationId(payCalculation.getId());
|
|
|
|
|
wgzPayCalculationMiddle.setAttendanceId(data.getId());
|
|
|
|
|
middleList.add(wgzPayCalculationMiddle);
|
|
|
|
|
}
|
|
|
|
|
iWgzAttendanceService.updateBatchById(list);
|
|
|
|
|
iWgzPayCalculationMiddleService.saveBatch(middleList);
|
|
|
|
|
|
|
|
|
|
//修改其余未审批申请的状态
|
|
|
|
|
List<WgzPayCalculation> payList = list(Wrappers.<WgzPayCalculation>lambdaQuery().eq(WgzPayCalculation::getAuditorType, AuditStatus.UNREAD.getCode())
|
|
|
|
|
.eq(WgzPayCalculation::getUserId, dto.getUserId()));
|
|
|
|
|
if(CollectionUtil.isNotEmpty(payList)) {
|
|
|
|
|
payList.forEach(pay -> {
|
|
|
|
|
pay.setAuditorType(AuditStatus.REFUSE.getCode());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
updateBatchById(payList);
|
|
|
|
|
return save;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BgtApplyForWgzPayAddInfoVO payInfo(Long userId, Long recruitId) {
|
|
|
|
|
BgtApplyForWgzPayAddInfoVO vo = new BgtApplyForWgzPayAddInfoVO();
|
|
|
|
|
|
|
|
|
|
//招工信息
|
|
|
|
|
BgtProjectRecruit recruit = iBgtProjectRecruitService.getById(recruitId);
|
|
|
|
|
vo.setRecruitId(recruitId);
|
|
|
|
|
vo.setRecruitAmount(recruit.getRecruitAmount());
|
|
|
|
|
vo.setRecruitName(recruit.getRecruitName());
|
|
|
|
|
|
|
|
|
|
//任务信息
|
|
|
|
|
FbsProjectTask task = taskService.getById(recruit.getTaskId());
|
|
|
|
|
vo.setTaskId(task.getId());
|
|
|
|
|
vo.setTaskName(task.getTaskName());
|
|
|
|
|
vo.setTaskAddress(task.getTaskAddress());
|
|
|
|
|
|
|
|
|
|
//申请信息
|
|
|
|
|
BgtProjectRecruitApply recruitApply = iBgtProjectRecruitApplyService.getOneByUserIdAndRecruitId(userId, recruitId);
|
|
|
|
|
vo.setEntryTime(recruitApply.getEntryTime());
|
|
|
|
|
vo.setLeaveTime(recruitApply.getLeaveTime());
|
|
|
|
|
vo.setWorkingState(recruitApply.getStatus());
|
|
|
|
|
|
|
|
|
|
//出勤天数
|
|
|
|
|
//总天数
|
|
|
|
|
Integer i = attendanceService.attendanceDetail(userId, recruitId, null);
|
|
|
|
|
//已结算天数
|
|
|
|
|
List<WgzPayCalculation> list = list(Wrappers.<WgzPayCalculation>lambdaQuery()
|
|
|
|
|
.eq(WgzPayCalculation::getUserId, userId)
|
|
|
|
|
.eq(WgzPayCalculation::getRecruitId, recruitId));
|
|
|
|
|
return BeanUtil.copyToList(wgzPayCalculations, BgtPayCalculationDetailListVO.class);
|
|
|
|
|
.eq(WgzPayCalculation::getRecruitId, recruitId)
|
|
|
|
|
.eq(WgzPayCalculation::getAuditorType, AuditStatus.PASS.getCode()));
|
|
|
|
|
if(CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
int sum = list.stream().mapToInt(WgzPayCalculation::getNum).sum();
|
|
|
|
|
i = i - sum;
|
|
|
|
|
}
|
|
|
|
|
vo.setNum(i);
|
|
|
|
|
|
|
|
|
|
//个人信息
|
|
|
|
|
return vo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|