3.13优化版本
This commit is contained in:
		@ -0,0 +1,49 @@
 | 
			
		||||
package com.ruoyi.wgz.bo;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.LocalTime;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.core.domain.BaseEntity;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 工资结算中间分页查询对象 wgz_pay_calculation_middle
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-03-13
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ApiModel("工资结算中间分页查询对象")
 | 
			
		||||
public class WgzPayCalculationMiddleQueryBo extends BaseEntity {
 | 
			
		||||
 | 
			
		||||
	/** 分页大小 */
 | 
			
		||||
	@ApiModelProperty("分页大小")
 | 
			
		||||
	private Integer pageSize;
 | 
			
		||||
	/** 当前页数 */
 | 
			
		||||
	@ApiModelProperty("当前页数")
 | 
			
		||||
	private Integer pageNum;
 | 
			
		||||
	/** 排序列 */
 | 
			
		||||
	@ApiModelProperty("排序列")
 | 
			
		||||
	private String orderByColumn;
 | 
			
		||||
	/** 排序的方向desc或者asc */
 | 
			
		||||
	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
 | 
			
		||||
	private String isAsc;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/** 结算ID */
 | 
			
		||||
	@ApiModelProperty("结算ID")
 | 
			
		||||
	private Long calculationId;
 | 
			
		||||
	/** 考勤ID */
 | 
			
		||||
	@ApiModelProperty("考勤ID")
 | 
			
		||||
	private Long attendanceId;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,49 @@
 | 
			
		||||
package com.ruoyi.wgz.domain;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.common.annotation.Excel;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.*;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.LocalTime;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 工资结算中间对象 wgz_pay_calculation_middle
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-03-13
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@TableName("wgz_pay_calculation_middle")
 | 
			
		||||
@ApiModel("工资结算中间视图对象")
 | 
			
		||||
public class WgzPayCalculationMiddle implements Serializable {
 | 
			
		||||
 | 
			
		||||
    private static final long serialVersionUID=1L;
 | 
			
		||||
 | 
			
		||||
    /** 自增ID */
 | 
			
		||||
    @ApiModelProperty("自增ID")
 | 
			
		||||
    @TableId(value = "id")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    /** 结算ID */
 | 
			
		||||
    @Excel(name = "结算ID")
 | 
			
		||||
    @ApiModelProperty("结算ID")
 | 
			
		||||
    private Long calculationId;
 | 
			
		||||
 | 
			
		||||
    /** 考勤ID */
 | 
			
		||||
    @Excel(name = "考勤ID")
 | 
			
		||||
    @ApiModelProperty("考勤ID")
 | 
			
		||||
    private Long attendanceId;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,18 @@
 | 
			
		||||
package com.ruoyi.wgz.mapper;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.wgz.domain.WgzPayCalculationMiddle;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache;
 | 
			
		||||
import org.apache.ibatis.annotations.CacheNamespace;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 工资结算中间Mapper接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-03-13
 | 
			
		||||
 */
 | 
			
		||||
// 如使需切换数据源 请勿使用缓存 会造成数据不一致现象
 | 
			
		||||
@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class)
 | 
			
		||||
public interface WgzPayCalculationMiddleMapper extends BaseMapperPlus<WgzPayCalculationMiddle> {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,55 @@
 | 
			
		||||
package com.ruoyi.wgz.service;
 | 
			
		||||
 | 
			
		||||
import com.ruoyi.wgz.domain.WgzPayCalculationMiddle;
 | 
			
		||||
import com.ruoyi.wgz.bo.WgzPayCalculationMiddleQueryBo;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 工资结算中间Service接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-03-13
 | 
			
		||||
 */
 | 
			
		||||
public interface IWgzPayCalculationMiddleService extends IServicePlus<WgzPayCalculationMiddle> {
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询单个
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    WgzPayCalculationMiddle queryById(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询列表
 | 
			
		||||
     */
 | 
			
		||||
    TableDataInfo<WgzPayCalculationMiddle> queryPageList(WgzPayCalculationMiddleQueryBo bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询列表
 | 
			
		||||
     */
 | 
			
		||||
    List<WgzPayCalculationMiddle> queryList(WgzPayCalculationMiddleQueryBo bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据新增业务对象插入工资结算中间
 | 
			
		||||
     * @param bo 工资结算中间新增业务对象
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean insert(WgzPayCalculationMiddle bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据编辑业务对象修改工资结算中间
 | 
			
		||||
     * @param bo 工资结算中间编辑业务对象
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean update(WgzPayCalculationMiddle bo);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验并删除数据
 | 
			
		||||
     * @param ids 主键集合
 | 
			
		||||
     * @param isValid 是否校验,true-删除前校验,false-不校验
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 | 
			
		||||
}
 | 
			
		||||
@ -47,6 +47,8 @@ import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.YearMonth;
 | 
			
		||||
import java.time.format.DateTimeFormatter;
 | 
			
		||||
import java.time.temporal.TemporalAdjusters;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
@ -165,7 +167,10 @@ public class WgzDailyClockServiceImpl extends ServicePlusImpl<WgzDailyClockMappe
 | 
			
		||||
	@Override
 | 
			
		||||
	public WgzUserDailyCalendarRes userDailyCalendar(WgzAppDailyCalendarReq req) {
 | 
			
		||||
		//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<>();
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,85 @@
 | 
			
		||||
package com.ruoyi.wgz.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.bean.BeanUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.ruoyi.common.utils.PageUtils;
 | 
			
		||||
import com.ruoyi.common.core.page.PagePlus;
 | 
			
		||||
import com.ruoyi.common.core.page.TableDataInfo;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
			
		||||
import com.ruoyi.wgz.bo.WgzPayCalculationMiddleQueryBo;
 | 
			
		||||
import com.ruoyi.wgz.domain.WgzPayCalculationMiddle;
 | 
			
		||||
import com.ruoyi.wgz.mapper.WgzPayCalculationMiddleMapper;
 | 
			
		||||
import com.ruoyi.wgz.service.IWgzPayCalculationMiddleService;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 工资结算中间Service业务层处理
 | 
			
		||||
 *
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 * @date 2025-03-13
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class WgzPayCalculationMiddleServiceImpl extends ServicePlusImpl<WgzPayCalculationMiddleMapper, WgzPayCalculationMiddle> implements IWgzPayCalculationMiddleService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public WgzPayCalculationMiddle queryById(Long id){
 | 
			
		||||
        return getById(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public TableDataInfo<WgzPayCalculationMiddle> queryPageList(WgzPayCalculationMiddleQueryBo bo) {
 | 
			
		||||
        Page<WgzPayCalculationMiddle> result = page(PageUtils.buildPage(), buildQueryWrapper(bo));
 | 
			
		||||
        return PageUtils.buildDataInfo(result);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<WgzPayCalculationMiddle> queryList(WgzPayCalculationMiddleQueryBo bo) {
 | 
			
		||||
        return list(buildQueryWrapper(bo));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private LambdaQueryWrapper<WgzPayCalculationMiddle> buildQueryWrapper(WgzPayCalculationMiddleQueryBo bo) {
 | 
			
		||||
        Map<String, Object> params = bo.getParams();
 | 
			
		||||
        LambdaQueryWrapper<WgzPayCalculationMiddle> lqw = Wrappers.lambdaQuery();
 | 
			
		||||
        lqw.eq(bo.getCalculationId() != null, WgzPayCalculationMiddle::getCalculationId, bo.getCalculationId());
 | 
			
		||||
        lqw.eq(bo.getAttendanceId() != null, WgzPayCalculationMiddle::getAttendanceId, bo.getAttendanceId());
 | 
			
		||||
        return lqw;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean insert(WgzPayCalculationMiddle bo) {
 | 
			
		||||
        WgzPayCalculationMiddle add = BeanUtil.toBean(bo, WgzPayCalculationMiddle.class);
 | 
			
		||||
        validEntityBeforeSave(add);
 | 
			
		||||
        return save(add);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean update(WgzPayCalculationMiddle bo) {
 | 
			
		||||
        WgzPayCalculationMiddle update = BeanUtil.toBean(bo, WgzPayCalculationMiddle.class);
 | 
			
		||||
        validEntityBeforeSave(update);
 | 
			
		||||
        return updateById(update);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 保存前的数据校验
 | 
			
		||||
     *
 | 
			
		||||
     * @param entity 实体类数据
 | 
			
		||||
     */
 | 
			
		||||
    private void validEntityBeforeSave(WgzPayCalculationMiddle entity){
 | 
			
		||||
        //TODO 做一些数据校验,如唯一约束
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
 | 
			
		||||
        if(isValid){
 | 
			
		||||
            //TODO 做一些业务上的校验,判断是否需要校验
 | 
			
		||||
        }
 | 
			
		||||
        return removeByIds(ids);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -84,6 +84,9 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
 | 
			
		||||
	@Autowired
 | 
			
		||||
	private IWgzAttendanceService iWgzAttendanceService;
 | 
			
		||||
 | 
			
		||||
	@Autowired
 | 
			
		||||
	private IWgzPayCalculationMiddleService iWgzPayCalculationMiddleService;
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
    public WgzPayCalculation queryById(Long id){
 | 
			
		||||
        return getById(id);
 | 
			
		||||
@ -188,25 +191,42 @@ public class WgzPayCalculationServiceImpl extends ServicePlusImpl<WgzPayCalculat
 | 
			
		||||
		//3、把需要结算的数据标记为已结算
 | 
			
		||||
		List<WgzAttendance> objects = new ArrayList<>();
 | 
			
		||||
		for (WgzAttendance data : attList) {
 | 
			
		||||
//			WgzPayCalculationMiddle middle = new WgzPayCalculationMiddle()
 | 
			
		||||
//				.setCalculationId(data.getId())
 | 
			
		||||
//				.setAttendanceId(data.getId());
 | 
			
		||||
			objects.add(new WgzAttendance()
 | 
			
		||||
				.setId(data.getId())
 | 
			
		||||
				.setSettlement(1)
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
		//4、将结算的数据
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		//4、组装数据
 | 
			
		||||
		//4、修改标识符,新增结算数据
 | 
			
		||||
		boolean b = iWgzAttendanceService.updateBatchById(objects);
 | 
			
		||||
		if (!b) {
 | 
			
		||||
			throw new RuntimeException("标识符修改失败!");
 | 
			
		||||
		}
 | 
			
		||||
		WgzPayCalculation wgzPayCalculation = new WgzPayCalculation();
 | 
			
		||||
		BeanUtils.copyProperties(req,wgzPayCalculation);
 | 
			
		||||
		wgzPayCalculation.
 | 
			
		||||
			setUserId(user.getUserId()).
 | 
			
		||||
			setUserName(user.getUserName()).
 | 
			
		||||
			setAuditorUserId(recruit.getUserId());
 | 
			
		||||
		//5、获取附件信息并插入
 | 
			
		||||
		iWgzPayCalculationFilesService.saveBatch(req.getPayCalculation());
 | 
			
		||||
		//6、插入工资结算信息
 | 
			
		||||
		return save(wgzPayCalculation);
 | 
			
		||||
		boolean save = save(wgzPayCalculation);
 | 
			
		||||
		if (!save) {
 | 
			
		||||
			throw new RuntimeException("新增结算失败!");
 | 
			
		||||
		}
 | 
			
		||||
		//5、将修改标识符的数据存放到中间表
 | 
			
		||||
		List<WgzPayCalculationMiddle> listMiddle = new ArrayList<>();
 | 
			
		||||
		for (WgzAttendance data : attList) {
 | 
			
		||||
			WgzPayCalculationMiddle middle = new WgzPayCalculationMiddle()
 | 
			
		||||
				.setCalculationId(wgzPayCalculation.getId())
 | 
			
		||||
				.setAttendanceId(data.getId());
 | 
			
		||||
			listMiddle.add(middle);
 | 
			
		||||
		}
 | 
			
		||||
		iWgzPayCalculationMiddleService.saveBatch(listMiddle);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
//	@Override
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user