优化,修改人员管理模块相关代码逻辑
This commit is contained in:
@ -13,7 +13,6 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.project.domain.req.workerdailyreport.WorkerDailyReportQueryReq;
|
||||
import org.dromara.project.domain.resp.workerdailyreport.WorkerDailyReportReissueResp;
|
||||
import org.dromara.project.domain.vo.BusWorkerDailyReportVo;
|
||||
import org.dromara.project.service.IBusWorkerDailyReportService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -44,15 +43,6 @@ public class BusWorkerDailyReportController extends BaseController {
|
||||
return busWorkerDailyReportService.queryPageList(req, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询施工人员补交日报列表
|
||||
*/
|
||||
@SaCheckPermission("project:workerDailyReport:list")
|
||||
@GetMapping("/list/reissue")
|
||||
public TableDataInfo<WorkerDailyReportReissueResp> listReissue(WorkerDailyReportQueryReq req, PageQuery pageQuery) {
|
||||
return busWorkerDailyReportService.queryReissuePageList(req, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出施工人员日报列表
|
||||
*/
|
||||
@ -76,18 +66,6 @@ public class BusWorkerDailyReportController extends BaseController {
|
||||
return R.ok(busWorkerDailyReportService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取施工人员补交日报详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("project:workerDailyReport:query")
|
||||
@GetMapping("/reissue/{id}")
|
||||
public R<WorkerDailyReportReissueResp> getReissueInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(busWorkerDailyReportService.queryReissueById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除施工人员日报
|
||||
*
|
||||
|
@ -55,6 +55,11 @@ public class BusConstructionUser extends BaseEntity {
|
||||
*/
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 班组名称
|
||||
*/
|
||||
private String teamName;
|
||||
|
||||
/**
|
||||
* 状态(0在职 1离职)
|
||||
*/
|
||||
|
@ -1,79 +0,0 @@
|
||||
package org.dromara.project.domain.bo;
|
||||
|
||||
import org.dromara.project.domain.BusWorkerDailyReport;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* 施工人员日报业务对象 bus_worker_daily_report
|
||||
*
|
||||
* @author lcj
|
||||
* @date 2025-04-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = BusWorkerDailyReport.class, reverseConvertGenerate = false)
|
||||
public class BusWorkerDailyReportBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotNull(message = "项目id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 班组id
|
||||
*/
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 申请人id
|
||||
*/
|
||||
@NotNull(message = "申请人id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 申请人名字
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 今日完成工作
|
||||
*/
|
||||
private String todayCompletedWork;
|
||||
|
||||
/**
|
||||
* 未完成工作
|
||||
*/
|
||||
private String unfinishedWork;
|
||||
|
||||
/**
|
||||
* 明日工作
|
||||
*/
|
||||
private String tomorrowWork;
|
||||
|
||||
/**
|
||||
* 需协调与帮助
|
||||
*/
|
||||
private String coordinationHelp;
|
||||
|
||||
/**
|
||||
* 附件
|
||||
*/
|
||||
private String file;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package org.dromara.project.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/4/10 11:16
|
||||
*/
|
||||
@Getter
|
||||
public enum WageMeasureUnitEnum {
|
||||
|
||||
TIME("计时:元/每天", "1"),
|
||||
PIECE("计件:元/每个", "2");
|
||||
|
||||
private final String text;
|
||||
|
||||
private final String value;
|
||||
|
||||
WageMeasureUnitEnum(String text, String value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package org.dromara.project.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/4/9 17:23
|
||||
*/
|
||||
@Getter
|
||||
public enum WorkerDailyReportReissueEnum {
|
||||
|
||||
UNREISSUE("不是补卡", 1),
|
||||
REISSUE("是补卡", 2);
|
||||
|
||||
private final String text;
|
||||
|
||||
private final int value;
|
||||
|
||||
WorkerDailyReportReissueEnum(String text, int value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
@ -2,9 +2,11 @@ package org.dromara.project.domain.req.attendance;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
@ -16,10 +18,31 @@ public class AttendanceQueryTwoWeekReq implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3193787736889938829L;
|
||||
|
||||
/**
|
||||
* 人员姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotNull(message = "项目id不能为空")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 班组id
|
||||
*/
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 工种
|
||||
*/
|
||||
private String typeOfWork;
|
||||
|
||||
/**
|
||||
* 打卡日期
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date clockDate;
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,6 @@ public class ConstructionUserAttendanceQueryReq implements Serializable {
|
||||
/**
|
||||
* 打卡月份
|
||||
*/
|
||||
private String clockMonth;
|
||||
private String clockDate;
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ public class ConstructionUserQueryReq implements Serializable {
|
||||
*/
|
||||
private Long notTeamId;
|
||||
|
||||
/**
|
||||
* 班组名称
|
||||
*/
|
||||
private String teamName;
|
||||
|
||||
/**
|
||||
* 状态(0在职 1离职)
|
||||
*/
|
||||
|
@ -48,4 +48,9 @@ public class WorkerDailyReportQueryReq implements Serializable {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date reportDate;
|
||||
|
||||
/**
|
||||
* 是否为补卡(1不是 2是)
|
||||
*/
|
||||
private Long isResubmit;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.dromara.project.domain.req.workwage;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -18,11 +19,13 @@ public class WorkWageCreateReq implements Serializable {
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotNull(message = "项目id不能为空")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 工种
|
||||
*/
|
||||
@NotNull(message = "工种不能为空")
|
||||
private String workType;
|
||||
|
||||
/**
|
||||
@ -33,18 +36,15 @@ public class WorkWageCreateReq implements Serializable {
|
||||
/**
|
||||
* 工资计算方式(1计时 2计件)
|
||||
*/
|
||||
@NotNull(message = "工资计算方式不能为空")
|
||||
private String wageCalculationType;
|
||||
|
||||
/**
|
||||
* 工资标准
|
||||
*/
|
||||
@NotNull(message = "工资标准不能为空")
|
||||
private Long wage;
|
||||
|
||||
/**
|
||||
* 工资计量单位
|
||||
*/
|
||||
private String wageMeasureUnit;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -25,31 +25,16 @@ public class WorkWageUpdateReq implements Serializable {
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 工种
|
||||
*/
|
||||
private String workType;
|
||||
|
||||
/**
|
||||
* 是否是特种兵(1是 2否)
|
||||
*/
|
||||
private String isSpecialType;
|
||||
|
||||
/**
|
||||
* 工资计算方式(1计时 2计件)
|
||||
*/
|
||||
private String wageCalculationType;
|
||||
|
||||
/**
|
||||
* 工资标准
|
||||
*/
|
||||
private Long wage;
|
||||
|
||||
/**
|
||||
* 工资计量单位
|
||||
*/
|
||||
private String wageMeasureUnit;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -75,9 +75,10 @@ public class BusConstructionUserVo implements Serializable {
|
||||
private Long teamId;
|
||||
|
||||
/**
|
||||
* 班组
|
||||
* 班组名称
|
||||
*/
|
||||
private BusProjectTeamVo teamVo;
|
||||
@ExcelProperty(value = "班组名称")
|
||||
private String teamName;
|
||||
|
||||
/**
|
||||
* 状态(0在职 1离职)
|
||||
|
@ -52,6 +52,11 @@ public class BusProjectTeamVo implements Serializable {
|
||||
@ExcelDictFormat(readConverterExp = "0=范围内打卡,1=任何地点打卡")
|
||||
private String isClockIn;
|
||||
|
||||
/**
|
||||
* 班组人数
|
||||
*/
|
||||
private Long peopleNumber;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -77,6 +77,11 @@ public class BusWorkerDailyReportVo implements Serializable {
|
||||
@ExcelProperty(value = "需协调与帮助")
|
||||
private String coordinationHelp;
|
||||
|
||||
/**
|
||||
* 是否为补卡(1不是 2是)
|
||||
*/
|
||||
private Long isResubmit;
|
||||
|
||||
/**
|
||||
* 补交理由
|
||||
*/
|
||||
@ -95,6 +100,11 @@ public class BusWorkerDailyReportVo implements Serializable {
|
||||
/**
|
||||
* 附件
|
||||
*/
|
||||
private List<String> fileList;
|
||||
|
||||
/**
|
||||
* 附件id
|
||||
*/
|
||||
private String file;
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,14 @@ public interface IBusConstructionBlacklistService extends IService<BusConstructi
|
||||
*/
|
||||
List<BusConstructionBlacklistVo> queryList(ConstructionBlacklistQueryReq req);
|
||||
|
||||
/**
|
||||
* 根据项目id查询黑名单用户id列表
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return 黑名单用户id列表
|
||||
*/
|
||||
List<Long> queryIdListByProjectId(Long projectId);
|
||||
|
||||
/**
|
||||
* 新增黑名单
|
||||
*
|
||||
|
@ -7,7 +7,6 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.project.domain.BusWorkerDailyReport;
|
||||
import org.dromara.project.domain.req.workerdailyreport.WorkerDailyReportQueryReq;
|
||||
import org.dromara.project.domain.resp.workerdailyreport.WorkerDailyReportReissueResp;
|
||||
import org.dromara.project.domain.vo.BusWorkerDailyReportVo;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -29,14 +28,6 @@ public interface IBusWorkerDailyReportService extends IService<BusWorkerDailyRep
|
||||
*/
|
||||
BusWorkerDailyReportVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询施工人员日报补报
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 施工人员日报补报
|
||||
*/
|
||||
WorkerDailyReportReissueResp queryReissueById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询施工人员日报列表
|
||||
*
|
||||
@ -46,15 +37,6 @@ public interface IBusWorkerDailyReportService extends IService<BusWorkerDailyRep
|
||||
*/
|
||||
TableDataInfo<BusWorkerDailyReportVo> queryPageList(WorkerDailyReportQueryReq req, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 分页查询施工人员日报补报列表
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 施工人员日报补报分页列表
|
||||
*/
|
||||
TableDataInfo<WorkerDailyReportReissueResp> queryReissuePageList(WorkerDailyReportQueryReq req, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的施工人员日报列表
|
||||
*
|
||||
@ -80,14 +62,6 @@ public interface IBusWorkerDailyReportService extends IService<BusWorkerDailyRep
|
||||
*/
|
||||
BusWorkerDailyReportVo getVo(BusWorkerDailyReport workerDailyReport);
|
||||
|
||||
/**
|
||||
* 获取施工人员日报补报视图对象
|
||||
*
|
||||
* @param workerDailyReport 施工人员日报对象
|
||||
* @return 施工人员日报补报视图对象
|
||||
*/
|
||||
WorkerDailyReportReissueResp getReissueVo(BusWorkerDailyReport workerDailyReport);
|
||||
|
||||
/**
|
||||
* 获取施工人员日报列表查询条件封装
|
||||
*
|
||||
@ -104,12 +78,4 @@ public interface IBusWorkerDailyReportService extends IService<BusWorkerDailyRep
|
||||
*/
|
||||
Page<BusWorkerDailyReportVo> getVoPage(Page<BusWorkerDailyReport> workerDailyReportPage);
|
||||
|
||||
/**
|
||||
* 获取施工人员日报补报分页对象视图
|
||||
*
|
||||
* @param workerDailyReportPage 施工人员日报列表分页对象
|
||||
* @return 施工人员日报列表分页对象视图
|
||||
*/
|
||||
Page<WorkerDailyReportReissueResp> getReissueVoPage(Page<BusWorkerDailyReport> workerDailyReportPage);
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.dromara.project.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -14,7 +15,7 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.project.domain.BusAttendance;
|
||||
import org.dromara.project.domain.BusLeave;
|
||||
import org.dromara.project.domain.BusConstructionUser;
|
||||
import org.dromara.project.domain.BusProjectTeamMember;
|
||||
import org.dromara.project.domain.enums.AttendanceClockStatusEnum;
|
||||
import org.dromara.project.domain.enums.AttendanceCommuterEnum;
|
||||
@ -54,10 +55,10 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
private IBusProjectTeamMemberService projectTeamMemberService;
|
||||
|
||||
@Resource
|
||||
private IBusLeaveService leaveService;
|
||||
private IBusConstructionUserService constructionUserService;
|
||||
|
||||
@Resource
|
||||
private IBusConstructionUserService constructionUserService;
|
||||
private IBusConstructionBlacklistService constructionBlacklistService;
|
||||
|
||||
/**
|
||||
* 查询考勤
|
||||
@ -99,42 +100,46 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
if (projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("项目信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 获取两周前的日期
|
||||
LocalDate twoWeeksAgoLocal = LocalDate.now().minusWeeks(2);
|
||||
// 2. 转成Date(时分秒会被置为 00:00:00)
|
||||
Date twoWeeksDate = Date.from(twoWeeksAgoLocal.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
// 获取两周内的考勤记录
|
||||
// 1. 处理日期区间
|
||||
Date clockDate = req.getClockDate();
|
||||
LocalDate startLocal;
|
||||
LocalDate endLocal;
|
||||
if (clockDate != null) {
|
||||
// 检查 clockDate 不能大于当前日期
|
||||
if (DateUtil.compare(clockDate, new Date()) > 0) {
|
||||
throw new ServiceException("日期不能大于当前日期", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 以传入的 clockDate 为结束日期
|
||||
endLocal = clockDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
} else {
|
||||
// 如果未传入,则以当前日期为结束日期
|
||||
endLocal = LocalDate.now();
|
||||
}
|
||||
// 计算开始日期为结束日期减两周
|
||||
startLocal = endLocal.minusWeeks(2);
|
||||
// 如果数据库中的 clockDate 只存储日期(时分秒置为 00:00:00),直接转换即可
|
||||
Date startDate = Date.from(startLocal.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
Date endDate = Date.from(endLocal.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
// 构造查询条件 clockDate 在 [startDate, endDate] 区间内
|
||||
LambdaQueryWrapper<BusAttendance> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(BusAttendance::getProjectId, projectId)
|
||||
.ge(BusAttendance::getClockDate, twoWeeksDate)
|
||||
.eq(StringUtils.isNotEmpty(req.getUserName()), BusAttendance::getUserName, req.getUserName())
|
||||
.between(BusAttendance::getClockDate, startDate, endDate)
|
||||
.orderByDesc(BusAttendance::getClockDate);
|
||||
// 构建查询用户相关信息查询条件
|
||||
List<Long> userIdList = constructionUserService.lambdaQuery()
|
||||
.eq(BusConstructionUser::getProjectId, projectId)
|
||||
.eq(req.getTeamId() != null, BusConstructionUser::getTeamId, req.getTeamId())
|
||||
.eq(req.getTypeOfWork() != null, BusConstructionUser::getTypeOfWork, req.getTypeOfWork())
|
||||
.notIn(BusConstructionUser::getId, constructionBlacklistService.queryIdListByProjectId(projectId))
|
||||
.list().stream().map(BusConstructionUser::getId).toList();
|
||||
lqw.in(CollUtil.isNotEmpty(userIdList), BusAttendance::getUserId, userIdList);
|
||||
Map<Date, List<BusAttendance>> dateListMap = this.list(lqw)
|
||||
.stream().collect(Collectors.groupingBy(BusAttendance::getClockDate));
|
||||
// 查询两周内的请假记录
|
||||
List<BusLeave> leaveList = leaveService.lambdaQuery()
|
||||
.eq(BusLeave::getProjectId, projectId)
|
||||
.ge(BusLeave::getEndTime, twoWeeksDate) // 请假结束时间在两周前之后的
|
||||
.le(BusLeave::getStartTime, new Date()) // 请假开始时间在当前时间之前的
|
||||
.list();
|
||||
// 构造一个 Map:Key -> LocalDate(请假生效的日期),Value -> 当天请假的用户ID集合(Set 用于去重)
|
||||
Map<LocalDate, Set<Long>> leaveMap = new HashMap<>();
|
||||
LocalDate todayLocal = LocalDate.now();
|
||||
for (BusLeave leave : leaveList) {
|
||||
// 将请假记录的开始和结束时间转换为 LocalDate
|
||||
LocalDate leaveStart = leave.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
LocalDate leaveEnd = leave.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
// 计算在两周范围内的有效区间
|
||||
LocalDate effectiveStart = leaveStart.isBefore(twoWeeksAgoLocal) ? twoWeeksAgoLocal : leaveStart;
|
||||
LocalDate effectiveEnd = leaveEnd.isAfter(todayLocal) ? todayLocal : leaveEnd;
|
||||
// 对有效区间内的每一天加入该请假用户
|
||||
for (LocalDate date = effectiveStart; !date.isAfter(effectiveEnd); date = date.plusDays(1)) {
|
||||
leaveMap.computeIfAbsent(date, k -> new HashSet<>()).add(leave.getUserId());
|
||||
}
|
||||
}
|
||||
// 遍历每个日期,计算考勤状态
|
||||
List<AttendanceClockDateForTwoWeekResp> respList = new ArrayList<>();
|
||||
// 遍历从两周前到今天的所有日期
|
||||
for (LocalDate localDate = twoWeeksAgoLocal; !localDate.isAfter(todayLocal); localDate = localDate.plusDays(1)) {
|
||||
for (LocalDate localDate = startLocal; !localDate.isAfter(endLocal); localDate = localDate.plusDays(1)) {
|
||||
AttendanceClockDateForTwoWeekResp resp = new AttendanceClockDateForTwoWeekResp();
|
||||
// 转换为 Date 类型(时分秒为 00:00:00)
|
||||
Date currentDate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
@ -152,16 +157,21 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
for (List<BusAttendance> userAttendanceList : userAttendanceMap.values()) {
|
||||
String clockInStatus = null;
|
||||
String clockOutStatus = null;
|
||||
String clockAllDayStatus = null;
|
||||
// 遍历同一用户的考勤记录,分别获取上下班状态
|
||||
for (BusAttendance a : userAttendanceList) {
|
||||
if (AttendanceCommuterEnum.CLOCKIN.getValue().equals(a.getCommuter())) {
|
||||
clockInStatus = a.getClockStatus();
|
||||
} else if (AttendanceCommuterEnum.CLOCKOUT.getValue().equals(a.getCommuter())) {
|
||||
clockOutStatus = a.getClockStatus();
|
||||
} else if (AttendanceCommuterEnum.ALLDAY.getValue().equals(a.getCommuter())) {
|
||||
clockAllDayStatus = a.getClockStatus();
|
||||
}
|
||||
}
|
||||
// 统计考勤状态
|
||||
if ((AttendanceClockStatusEnum.NORMAL.getValue().equals(clockInStatus)
|
||||
if (AttendanceClockStatusEnum.LEAVE.getValue().equals(clockAllDayStatus)) {
|
||||
leave++;
|
||||
} else if ((AttendanceClockStatusEnum.NORMAL.getValue().equals(clockInStatus)
|
||||
|| AttendanceClockStatusEnum.REISSUE.getValue().equals(clockInStatus))
|
||||
&& (AttendanceClockStatusEnum.NORMAL.getValue().equals(clockOutStatus)
|
||||
|| AttendanceClockStatusEnum.REISSUE.getValue().equals(clockOutStatus))) {
|
||||
@ -169,15 +179,12 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
} else if (AttendanceClockStatusEnum.UNCLOCK.getValue().equals(clockInStatus)
|
||||
&& AttendanceClockStatusEnum.UNCLOCK.getValue().equals(clockOutStatus)) {
|
||||
absenteeism++;
|
||||
} else {
|
||||
} else if (AttendanceClockStatusEnum.UNCLOCK.getValue().equals(clockInStatus)
|
||||
|| AttendanceClockStatusEnum.UNCLOCK.getValue().equals(clockOutStatus)) {
|
||||
halfAttendance++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<Long> leaveUserSet = leaveMap.get(localDate);
|
||||
if (leaveUserSet != null) {
|
||||
leave = leaveUserSet.size();
|
||||
}
|
||||
resp.setAttendance(attendance);
|
||||
resp.setHalfAttendance(halfAttendance);
|
||||
resp.setAbsenteeism(absenteeism);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.dromara.project.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -30,7 +29,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -90,6 +88,20 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据项目id查询黑名单用户id列表
|
||||
*
|
||||
* @param projectId 项目id
|
||||
* @return 黑名单用户id列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> queryIdListByProjectId(Long projectId) {
|
||||
LambdaQueryWrapper<BusConstructionBlacklist> lqw = Wrappers.lambdaQuery(BusConstructionBlacklist.class)
|
||||
.select(BusConstructionBlacklist::getUserId)
|
||||
.eq(projectId != null, BusConstructionBlacklist::getProjectId, projectId);
|
||||
return this.listObjs(lqw, obj -> (Long) obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增黑名单
|
||||
*
|
||||
@ -120,28 +132,6 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
if (!result) {
|
||||
throw new ServiceException("新增黑名单失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 如果加入黑名单用户已在班组,则移除
|
||||
Long teamId = constructionUser.getTeamId();
|
||||
if (teamId != null) {
|
||||
// 修改用户team_id字段
|
||||
LambdaUpdateWrapper<BusConstructionUser> constructionUserLqw = Wrappers.lambdaUpdate(BusConstructionUser.class)
|
||||
.eq(BusConstructionUser::getId, userId)
|
||||
.set(BusConstructionUser::getTeamId, null)
|
||||
.set(BusConstructionUser::getLeaveDate, new Date());
|
||||
boolean update = constructionUserService.update(constructionUserLqw);
|
||||
if (!update) {
|
||||
throw new ServiceException("用户退场失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
// 移除用户与班组关联
|
||||
LambdaQueryWrapper<BusProjectTeamMember> projectTeamMemberLqw = Wrappers.lambdaQuery(BusProjectTeamMember.class)
|
||||
.eq(BusProjectTeamMember::getProjectId, req.getProjectId())
|
||||
.eq(BusProjectTeamMember::getTeamId, teamId)
|
||||
.eq(BusProjectTeamMember::getMemberId, userId);
|
||||
boolean remove = projectTeamMemberService.remove(projectTeamMemberLqw);
|
||||
if (!remove) {
|
||||
throw new ServiceException("用户退场失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
return constructionBlacklist.getId();
|
||||
}
|
||||
|
||||
@ -158,13 +148,16 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
if (projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 判断是否已经存在该用户
|
||||
LambdaQueryWrapper<BusConstructionBlacklist> lqw = Wrappers.lambdaQuery(BusConstructionBlacklist.class)
|
||||
.eq(BusConstructionBlacklist::getProjectId, projectId)
|
||||
.eq(BusConstructionBlacklist::getUserId, userId);
|
||||
if (this.count(lqw) > 0) {
|
||||
throw new ServiceException("该用户已经存在", HttpStatus.BAD_REQUEST);
|
||||
// 判断用户是否退场
|
||||
Long count = projectTeamMemberService.lambdaQuery()
|
||||
.eq(BusProjectTeamMember::getProjectId, projectId)
|
||||
.eq(BusProjectTeamMember::getMemberId, userId)
|
||||
.count();
|
||||
if (count > 0) {
|
||||
throw new ServiceException("请将施工人员退场后,再加入黑名单", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 判断是否已经存在该用户
|
||||
this.validUserInBlacklist(userId, projectId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,6 +207,7 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
LambdaQueryWrapper<BusConstructionBlacklist> lqw = new LambdaQueryWrapper<>();
|
||||
Long id = req.getId();
|
||||
Long userId = req.getUserId();
|
||||
Long projectId = req.getProjectId();
|
||||
String userName = req.getUserName();
|
||||
String sfzNumber = req.getSfzNumber();
|
||||
// 模糊查询
|
||||
@ -222,6 +216,7 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
|
||||
// 精确查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(id), BusConstructionBlacklist::getId, id);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(userId), BusConstructionBlacklist::getUserId, userId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(projectId), BusConstructionBlacklist::getProjectId, projectId);
|
||||
return lqw;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import org.dromara.project.domain.resp.constructionuser.ConstructionUserAttendan
|
||||
import org.dromara.project.domain.resp.constructionuser.ConstructionUserAttendanceTotalResp;
|
||||
import org.dromara.project.domain.vo.BusConstructionUserVo;
|
||||
import org.dromara.project.domain.vo.BusContractorVo;
|
||||
import org.dromara.project.domain.vo.BusProjectTeamVo;
|
||||
import org.dromara.project.mapper.BusConstructionUserMapper;
|
||||
import org.dromara.project.service.*;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
@ -65,9 +64,6 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
@Resource
|
||||
private IBusProjectTeamMemberService projectTeamMemberService;
|
||||
|
||||
@Resource
|
||||
private IBusProjectTeamService projectTeamService;
|
||||
|
||||
@Resource
|
||||
private ISysOssService ossService;
|
||||
|
||||
@ -244,8 +240,6 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
BeanUtils.copyProperties(constructionUserVo, constructionUserExportVo);
|
||||
// 关联分包公司信息
|
||||
constructionUserExportVo.setContractorName(constructionUserVo.getContractorVo().getName());
|
||||
// 关联班组信息
|
||||
constructionUserExportVo.setTeamName(constructionUserVo.getTeamVo().getTeamName());
|
||||
// 关联项目信息
|
||||
Long projectId = constructionUserVo.getProjectId();
|
||||
String projectName = null;
|
||||
@ -594,11 +588,6 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
if (StringUtils.isNotBlank(facePic)) {
|
||||
constructionUserVo.setFacePicUrl(ossService.getById(Long.parseLong(facePic)).getUrl());
|
||||
}
|
||||
// 关联查询班组信息
|
||||
Long teamId = constructionUser.getTeamId();
|
||||
if (teamId != null) {
|
||||
constructionUserVo.setTeamVo(projectTeamService.queryById(teamId));
|
||||
}
|
||||
// 关联查询薪水标准
|
||||
Long projectId = constructionUser.getProjectId();
|
||||
String typeOfWork = constructionUser.getTypeOfWork();
|
||||
@ -635,6 +624,7 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
Long contractorId = req.getContractorId();
|
||||
Long teamId = req.getTeamId();
|
||||
Long notTeamId = req.getNotTeamId();
|
||||
String teamName = req.getTeamName();
|
||||
String status = req.getStatus();
|
||||
String isPinch = req.getIsPinch();
|
||||
String phone = req.getPhone();
|
||||
@ -660,6 +650,7 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
lqw.like(StringUtils.isNotBlank(yhkNumber), BusConstructionUser::getYhkNumber, yhkNumber);
|
||||
lqw.like(StringUtils.isNotBlank(yhkOpeningBank), BusConstructionUser::getYhkOpeningBank, yhkOpeningBank);
|
||||
lqw.like(StringUtils.isNotBlank(yhkCardholder), BusConstructionUser::getYhkCardholder, yhkCardholder);
|
||||
lqw.like(StringUtils.isNotBlank(teamName), BusConstructionUser::getTeamName, teamName);
|
||||
// 精确查询
|
||||
lqw.eq(StringUtils.isNotBlank(status), BusConstructionUser::getStatus, status);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(id), BusConstructionUser::getId, id);
|
||||
@ -679,15 +670,12 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
.or().isNull(BusConstructionUser::getTeamId));
|
||||
}
|
||||
// 查询当前项目下的黑名单人员
|
||||
LambdaQueryWrapper<BusConstructionBlacklist> blacklistLqw = Wrappers.lambdaQuery(BusConstructionBlacklist.class)
|
||||
.select(BusConstructionBlacklist::getUserId);
|
||||
if (projectId != null) {
|
||||
blacklistLqw.eq(BusConstructionBlacklist::getProjectId, projectId);
|
||||
}
|
||||
List<Long> blackUserIdList = constructionBlacklistService.listObjs(blacklistLqw, obj -> (Long) obj);
|
||||
// 查询结果移除黑名单人员
|
||||
if (CollUtil.isNotEmpty(blackUserIdList)) {
|
||||
lqw.notIn(BusConstructionUser::getId, blackUserIdList);
|
||||
List<Long> blackUserIdList = constructionBlacklistService.queryIdListByProjectId(projectId);
|
||||
// 查询结果移除黑名单人员
|
||||
if (CollUtil.isNotEmpty(blackUserIdList)) {
|
||||
lqw.notIn(BusConstructionUser::getId, blackUserIdList);
|
||||
}
|
||||
}
|
||||
return lqw;
|
||||
}
|
||||
@ -713,11 +701,6 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
.collect(Collectors.toSet());
|
||||
Map<Long, List<BusContractor>> contractorIdContractorMap = contractorService.listByIds(contractorIdSet).stream()
|
||||
.collect(Collectors.groupingBy(BusContractor::getId));
|
||||
// 关联查询班组信息
|
||||
Set<Long> teamIdSet = constructionUserList.stream().map(BusConstructionUser::getTeamId)
|
||||
.collect(Collectors.toSet());
|
||||
Map<Long, List<BusProjectTeam>> teamIdTeamMap = projectTeamService.listByIds(teamIdSet).stream()
|
||||
.collect(Collectors.groupingBy(BusProjectTeam::getId));
|
||||
// 关联查询工资标准
|
||||
LambdaQueryWrapper<BusWorkWage> workWageLqw = Wrappers.lambdaQuery(BusWorkWage.class)
|
||||
.in(BusWorkWage::getProjectId, constructionUserList.stream().map(BusConstructionUser::getProjectId).toList())
|
||||
@ -740,13 +723,6 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
contractor = contractorService.getVo(contractorIdContractorMap.get(contractorId).get(0));
|
||||
}
|
||||
constructionUserVo.setContractorVo(contractor);
|
||||
// 关联班组信息
|
||||
Long teamId = constructionUser.getTeamId();
|
||||
BusProjectTeamVo team = null;
|
||||
if (teamIdTeamMap.containsKey(teamId)) {
|
||||
team = projectTeamService.getVo(teamIdTeamMap.get(teamId).get(0));
|
||||
}
|
||||
constructionUserVo.setTeamVo(team);
|
||||
// 关联工资标准
|
||||
// 构造相应的 key
|
||||
String key = constructionUser.getTypeOfWork() + "_" + constructionUser.getWageMeasureUnit();
|
||||
@ -786,17 +762,22 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
Long projectId = req.getProjectId();
|
||||
Long teamId = req.getTeamId();
|
||||
String typeOfWork = req.getTypeOfWork();
|
||||
String clockMonth = req.getClockMonth();
|
||||
String clockDate = req.getClockDate();
|
||||
// 联表查询
|
||||
LambdaQueryWrapper<BusAttendance> attendanceLqw = Wrappers.lambdaQuery(BusAttendance.class)
|
||||
.eq(BusAttendance::getProjectId, projectId);
|
||||
if (ObjectUtils.isNotEmpty(clockMonth)) {
|
||||
if (ObjectUtils.isNotEmpty(clockDate)) {
|
||||
String clockMonth = clockDate.substring(0, 7);
|
||||
// 校验月份格式
|
||||
if (!DateConstant.YEAR_MONTH_PATTERN.matcher(clockMonth).matches()) {
|
||||
throw new ServiceException("月份格式不正确", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 解析月份
|
||||
YearMonth yearMonth = YearMonth.parse(clockMonth);
|
||||
// 判断是否大于当前月份
|
||||
if (yearMonth.isAfter(YearMonth.now())) {
|
||||
throw new ServiceException("不能查看大于当前月份的记录", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 计算当月第一天 / 最后一天
|
||||
Date start = DateUtils.toDate(yearMonth.atDay(1));
|
||||
Date end = DateUtils.toDate(yearMonth.atEndOfMonth());
|
||||
@ -814,9 +795,7 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
lqw.eq(ObjectUtils.isNotEmpty(teamId), BusConstructionUser::getTeamId, teamId);
|
||||
lqw.eq(StringUtils.isNotBlank(typeOfWork), BusConstructionUser::getTypeOfWork, typeOfWork);
|
||||
// 查询当前项目下的黑名单人员
|
||||
List<Long> blackUserIdList = constructionBlacklistService.lambdaQuery()
|
||||
.eq(BusConstructionBlacklist::getProjectId, projectId).list()
|
||||
.stream().map(BusConstructionBlacklist::getUserId).toList();
|
||||
List<Long> blackUserIdList = constructionBlacklistService.queryIdListByProjectId(projectId);
|
||||
// 查询结果移除黑名单人员
|
||||
if (CollUtil.isNotEmpty(blackUserIdList)) {
|
||||
lqw.notIn(BusConstructionUser::getId, blackUserIdList);
|
||||
@ -837,18 +816,11 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
attendanceLqw.in(BusAttendance::getUserId, userIdList);
|
||||
Map<Long, List<BusAttendance>> userIdBusAttendanceListMap = attendanceService.list(attendanceLqw)
|
||||
.stream().collect(Collectors.groupingBy(BusAttendance::getUserId));
|
||||
// 关联查询班组列表
|
||||
List<Long> teamIdList = constructionUserList.stream().map(BusConstructionUser::getTeamId).toList();
|
||||
Map<Long, List<BusProjectTeam>> teamIdProjectTeamListMap = projectTeamService.lambdaQuery()
|
||||
.in(BusProjectTeam::getId, teamIdList).list()
|
||||
.stream().collect(Collectors.groupingBy(BusProjectTeam::getId));
|
||||
// 填充信息
|
||||
List<ConstructionUserAttendanceTotalResp> userAttendanceTotalList = constructionUserList.stream().map(constructionUser -> {
|
||||
ConstructionUserAttendanceTotalResp constructionUserAttendanceTotalResp = new ConstructionUserAttendanceTotalResp();
|
||||
Long id = constructionUser.getId();
|
||||
constructionUserAttendanceTotalResp.setId(id);
|
||||
constructionUserAttendanceTotalResp.setUserName(constructionUser.getUserName());
|
||||
constructionUserAttendanceTotalResp.setTypeOfWork(constructionUser.getTypeOfWork());
|
||||
BeanUtils.copyProperties(constructionUser, constructionUserAttendanceTotalResp);
|
||||
// 关联施工人员考勤信息
|
||||
int attendanceDays = 0;
|
||||
int lateDays = 0;
|
||||
@ -902,14 +874,6 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU
|
||||
constructionUserAttendanceTotalResp.setLeaveEarlyDays(leaveEarlyDays);
|
||||
constructionUserAttendanceTotalResp.setUnClockDays(unClockDays);
|
||||
constructionUserAttendanceTotalResp.setLeaveDays(leaveDays);
|
||||
// 关联班组信息
|
||||
Long userTeamId = constructionUser.getTeamId();
|
||||
String teamName = null;
|
||||
if (teamIdProjectTeamListMap.containsKey(userTeamId)) {
|
||||
teamName = teamIdProjectTeamListMap.get(userTeamId).get(0).getTeamName();
|
||||
}
|
||||
constructionUserAttendanceTotalResp.setTeamId(userTeamId);
|
||||
constructionUserAttendanceTotalResp.setTeamName(teamName);
|
||||
return constructionUserAttendanceTotalResp;
|
||||
}).toList();
|
||||
constructionUserAttendanceTotalPage.setRecords(userAttendanceTotalList);
|
||||
|
@ -17,6 +17,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.project.domain.BusConstructionUser;
|
||||
import org.dromara.project.domain.BusConstructionUserExit;
|
||||
import org.dromara.project.domain.BusProjectTeam;
|
||||
import org.dromara.project.domain.BusProjectTeamMember;
|
||||
import org.dromara.project.domain.enums.ProjectTeamMemberPostEnum;
|
||||
import org.dromara.project.domain.req.projectteammember.ProjectTeamMemberCreateReq;
|
||||
@ -117,6 +118,12 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
BeanUtils.copyProperties(req, projectTeamMember);
|
||||
// 数据校验
|
||||
validEntityBeforeSave(projectTeamMember, true);
|
||||
// 判断班组信息是否存在
|
||||
Long teamId = req.getTeamId();
|
||||
BusProjectTeam projectTeam = projectTeamService.getById(teamId);
|
||||
if (projectTeam == null) {
|
||||
throw new ServiceException("对应班组不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 判断用户是否已经被拉黑
|
||||
constructionBlacklistService.validUserInBlacklist(projectTeamMember.getMemberId(), projectTeamMember.getProjectId());
|
||||
// 判断对应的用户与项目关联是否存在
|
||||
@ -135,6 +142,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
LambdaUpdateWrapper<BusConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(BusConstructionUser.class)
|
||||
.eq(BusConstructionUser::getId, projectTeamMember.getMemberId())
|
||||
.set(BusConstructionUser::getTeamId, projectTeamMember.getTeamId())
|
||||
.set(BusConstructionUser::getTeamName, projectTeam.getTeamName())
|
||||
.set(BusConstructionUser::getEntryDate, new Date())
|
||||
.set(BusConstructionUser::getLeaveDate, null);
|
||||
constructionUserService.update(constructionUserLuw);
|
||||
@ -155,16 +163,25 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
BeanUtils.copyProperties(req, projectTeamMember);
|
||||
// 数据校验
|
||||
validEntityBeforeSave(projectTeamMember, false);
|
||||
// 判断班组信息是否存在
|
||||
Long teamId = req.getTeamId();
|
||||
BusProjectTeam projectTeam = projectTeamService.getById(teamId);
|
||||
if (projectTeam == null) {
|
||||
throw new ServiceException("对应班组不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 判断是否存在
|
||||
BusProjectTeamMember oldProjectTeamMember = this.getById(projectTeamMember.getId());
|
||||
if (oldProjectTeamMember == null) {
|
||||
throw new ServiceException("修改项目班组下的成员,数据不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 同步修改用户表的team_id字段
|
||||
LambdaUpdateWrapper<BusConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(BusConstructionUser.class)
|
||||
.eq(BusConstructionUser::getId, projectTeamMember.getMemberId())
|
||||
.set(BusConstructionUser::getTeamId, projectTeamMember.getTeamId());
|
||||
constructionUserService.update(constructionUserLuw);
|
||||
// 如果修改了班组信息,同步修改用户表的字段
|
||||
if (!oldProjectTeamMember.getTeamId().equals(teamId)) {
|
||||
LambdaUpdateWrapper<BusConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(BusConstructionUser.class)
|
||||
.eq(BusConstructionUser::getId, projectTeamMember.getMemberId())
|
||||
.set(BusConstructionUser::getTeamId, projectTeamMember.getTeamId())
|
||||
.set(BusConstructionUser::getTeamName, projectTeam.getTeamName());
|
||||
constructionUserService.update(constructionUserLuw);
|
||||
}
|
||||
// 操作数据库
|
||||
return this.updateById(projectTeamMember);
|
||||
}
|
||||
@ -176,7 +193,6 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
// TODO 做一些数据校验,如唯一约束
|
||||
Long projectId = entity.getProjectId();
|
||||
Long memberId = entity.getMemberId();
|
||||
Long teamId = entity.getTeamId();
|
||||
String postId = entity.getPostId();
|
||||
ProjectTeamMemberPostEnum postEnum = ProjectTeamMemberPostEnum.getEnumByValue(postId);
|
||||
if (create) {
|
||||
@ -186,9 +202,6 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
if (memberId == null) {
|
||||
throw new ServiceException("人员 id 不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (teamId == null) {
|
||||
throw new ServiceException("班组 id 不能为空", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (postEnum == null) {
|
||||
throw new ServiceException("请选择正确的岗位", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@ -199,9 +212,6 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
|
||||
if (constructionUserService.getById(memberId) == null) {
|
||||
throw new ServiceException("对应人员不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
if (projectTeamService.getById(teamId) == null) {
|
||||
throw new ServiceException("对应班组不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package org.dromara.project.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -252,6 +253,11 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
return projectTeamVo;
|
||||
}
|
||||
BeanUtils.copyProperties(projectTeam, projectTeamVo);
|
||||
// 获取班组人数
|
||||
Long peopleNumber = projectTeamMemberService.lambdaQuery()
|
||||
.eq(BusProjectTeamMember::getTeamId, projectTeam.getId())
|
||||
.count();
|
||||
projectTeamVo.setPeopleNumber(peopleNumber);
|
||||
return projectTeamVo;
|
||||
}
|
||||
|
||||
@ -299,7 +305,27 @@ public class BusProjectTeamServiceImpl extends ServiceImpl<BusProjectTeamMapper,
|
||||
if (CollUtil.isEmpty(projectTeamList)) {
|
||||
return projectTeamVoPage;
|
||||
}
|
||||
List<BusProjectTeamVo> projectTeamVoList = projectTeamList.stream().map(this::getVo).toList();
|
||||
// 1. 获取各班组人数
|
||||
List<Long> teamIdList = projectTeamList.stream().map(BusProjectTeam::getId).toList();
|
||||
List<Map<String, Object>> mapList = projectTeamMemberService.listMaps(
|
||||
new QueryWrapper<BusProjectTeamMember>()
|
||||
.select("team_id", "COUNT(*) as count")
|
||||
.in("team_id", teamIdList)
|
||||
.groupBy("team_id")
|
||||
);
|
||||
// 2. 将查询结果转换成 Map<Long, Long>
|
||||
Map<Long, Long> teamCountMap = mapList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
m -> ((Number) m.get("team_id")).longValue(),
|
||||
m -> ((Number) m.get("count")).longValue()
|
||||
));
|
||||
// 对象列表 => 封装对象列表
|
||||
List<BusProjectTeamVo> projectTeamVoList = projectTeamList.stream().map(projectTeam -> {
|
||||
BusProjectTeamVo projectTeamVo = new BusProjectTeamVo();
|
||||
BeanUtils.copyProperties(projectTeam, projectTeamVo);
|
||||
projectTeamVo.setPeopleNumber(teamCountMap.getOrDefault(projectTeam.getId(), 0L));
|
||||
return projectTeamVo;
|
||||
}).toList();
|
||||
projectTeamVoPage.setRecords(projectTeamVoList);
|
||||
return projectTeamVoPage;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.project.domain.BusWorkWage;
|
||||
import org.dromara.project.domain.enums.WageMeasureUnitEnum;
|
||||
import org.dromara.project.domain.req.workwage.WorkWageCreateReq;
|
||||
import org.dromara.project.domain.req.workwage.WorkWageQueryReq;
|
||||
import org.dromara.project.domain.req.workwage.WorkWageUpdateReq;
|
||||
@ -93,6 +94,27 @@ public class BusWorkWageServiceImpl extends ServiceImpl<BusWorkWageMapper, BusWo
|
||||
BeanUtils.copyProperties(req, workWage);
|
||||
// 数据校验
|
||||
validEntityBeforeSave(workWage, true);
|
||||
// 判断是否存在
|
||||
Long count = this.lambdaQuery()
|
||||
.eq(BusWorkWage::getProjectId, workWage.getProjectId())
|
||||
.eq(BusWorkWage::getWorkType, workWage.getWorkType())
|
||||
.eq(BusWorkWage::getWageCalculationType, workWage.getWageCalculationType())
|
||||
.count();
|
||||
if (count > 0) {
|
||||
throw new ServiceException("该项目已存在该工种薪水信息", HttpStatus.CONFLICT);
|
||||
}
|
||||
// 填充默认值
|
||||
String wageCalculationType = req.getWageCalculationType();
|
||||
switch (wageCalculationType) {
|
||||
case "1":
|
||||
workWage.setWageMeasureUnit(WageMeasureUnitEnum.TIME.getValue());
|
||||
break;
|
||||
case "2":
|
||||
workWage.setWageMeasureUnit(WageMeasureUnitEnum.PIECE.getValue());
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("工资计算方式错误", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// 操作数据库
|
||||
boolean save = this.save(workWage);
|
||||
if (!save) {
|
||||
|
@ -14,15 +14,15 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.project.domain.BusDailyPieceItem;
|
||||
import org.dromara.project.domain.BusProjectTeam;
|
||||
import org.dromara.project.domain.BusWorkerDailyReport;
|
||||
import org.dromara.project.domain.enums.WorkerDailyReportReissueEnum;
|
||||
import org.dromara.project.domain.req.workerdailyreport.WorkerDailyReportQueryReq;
|
||||
import org.dromara.project.domain.resp.workerdailyreport.WorkerDailyReportReissueResp;
|
||||
import org.dromara.project.domain.vo.BusDailyPieceItemVo;
|
||||
import org.dromara.project.domain.vo.BusWorkerDailyReportVo;
|
||||
import org.dromara.project.mapper.BusWorkerDailyReportMapper;
|
||||
import org.dromara.project.service.IBusDailyPieceItemService;
|
||||
import org.dromara.project.service.IBusProjectTeamService;
|
||||
import org.dromara.project.service.IBusWorkerDailyReportService;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -45,6 +45,9 @@ public class BusWorkerDailyReportServiceImpl extends ServiceImpl<BusWorkerDailyR
|
||||
@Resource
|
||||
private IBusProjectTeamService projectTeamService;
|
||||
|
||||
@Resource
|
||||
private ISysOssService ossService;
|
||||
|
||||
/**
|
||||
* 查询施工人员日报
|
||||
*
|
||||
@ -60,22 +63,6 @@ public class BusWorkerDailyReportServiceImpl extends ServiceImpl<BusWorkerDailyR
|
||||
return this.getVo(workerDailyReport);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询施工人员日报补报
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 施工人员日报补报
|
||||
*/
|
||||
@Override
|
||||
public WorkerDailyReportReissueResp queryReissueById(Long id) {
|
||||
BusWorkerDailyReport workerDailyReport = this.getById(id);
|
||||
if (workerDailyReport == null) {
|
||||
throw new ServiceException("施工人员日报信息不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return this.getReissueVo(workerDailyReport);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询施工人员日报列表
|
||||
*
|
||||
@ -86,26 +73,10 @@ public class BusWorkerDailyReportServiceImpl extends ServiceImpl<BusWorkerDailyR
|
||||
@Override
|
||||
public TableDataInfo<BusWorkerDailyReportVo> queryPageList(WorkerDailyReportQueryReq req, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<BusWorkerDailyReport> lqw = this.buildQueryWrapper(req);
|
||||
lqw.eq(BusWorkerDailyReport::getIsResubmit, WorkerDailyReportReissueEnum.UNREISSUE.getValue());
|
||||
Page<BusWorkerDailyReport> result = this.page(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(this.getVoPage(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询施工人员日报补报列表
|
||||
*
|
||||
* @param req 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 施工人员日报补报分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<WorkerDailyReportReissueResp> queryReissuePageList(WorkerDailyReportQueryReq req, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<BusWorkerDailyReport> lqw = this.buildQueryWrapper(req);
|
||||
lqw.eq(BusWorkerDailyReport::getIsResubmit, WorkerDailyReportReissueEnum.REISSUE.getValue());
|
||||
Page<BusWorkerDailyReport> result = this.page(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(this.getReissueVoPage(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的施工人员日报列表
|
||||
*
|
||||
@ -128,7 +99,7 @@ public class BusWorkerDailyReportServiceImpl extends ServiceImpl<BusWorkerDailyR
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
// TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
@ -153,30 +124,16 @@ public class BusWorkerDailyReportServiceImpl extends ServiceImpl<BusWorkerDailyR
|
||||
workerDailyReportVo.setDailyPieceItemVoList(dailyPieceItemService.getListVo(dailyPieceItemList));
|
||||
// 获取班组详情信息
|
||||
workerDailyReportVo.setTeamName(projectTeamService.getById(workerDailyReport.getTeamId()).getTeamName());
|
||||
return workerDailyReportVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取施工人员日报补报视图对象
|
||||
*
|
||||
* @param workerDailyReport 施工人员日报对象
|
||||
* @return 施工人员日报补报视图对象
|
||||
*/
|
||||
@Override
|
||||
public WorkerDailyReportReissueResp getReissueVo(BusWorkerDailyReport workerDailyReport) {
|
||||
// 对象转封装类
|
||||
WorkerDailyReportReissueResp workerDailyReportReissueResp = new WorkerDailyReportReissueResp();
|
||||
if (workerDailyReport == null) {
|
||||
return workerDailyReportReissueResp;
|
||||
// 获取图片信息
|
||||
String file = workerDailyReport.getFile();
|
||||
if (StringUtils.isNotEmpty(file)) {
|
||||
List<Long> picList = Arrays.stream(file.split(","))
|
||||
.map(Long::parseLong)
|
||||
.toList();
|
||||
List<SysOssVo> pictureList = ossService.listByIds(picList);
|
||||
workerDailyReportVo.setFileList(pictureList.stream().map(SysOssVo::getUrl).toList());
|
||||
}
|
||||
BeanUtils.copyProperties(workerDailyReport, workerDailyReportReissueResp);
|
||||
// 获取日报计件详情信息
|
||||
List<BusDailyPieceItem> dailyPieceItemList = dailyPieceItemService.lambdaQuery()
|
||||
.eq(BusDailyPieceItem::getReportId, workerDailyReport.getId()).list();
|
||||
workerDailyReportReissueResp.setDailyPieceItemVoList(dailyPieceItemService.getListVo(dailyPieceItemList));
|
||||
// 获取班组详情信息
|
||||
workerDailyReportReissueResp.setTeamName(projectTeamService.getById(workerDailyReport.getTeamId()).getTeamName());
|
||||
return workerDailyReportReissueResp;
|
||||
return workerDailyReportVo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,6 +154,7 @@ public class BusWorkerDailyReportServiceImpl extends ServiceImpl<BusWorkerDailyR
|
||||
Long userId = req.getUserId();
|
||||
String userName = req.getUserName();
|
||||
Date reportDate = req.getReportDate();
|
||||
Long isResubmit = req.getIsResubmit();
|
||||
// 模糊查询
|
||||
lqw.like(StringUtils.isNotBlank(userName), BusWorkerDailyReport::getUserName, userName);
|
||||
// 精确查询
|
||||
@ -205,6 +163,7 @@ public class BusWorkerDailyReportServiceImpl extends ServiceImpl<BusWorkerDailyR
|
||||
lqw.eq(ObjectUtils.isNotEmpty(teamId), BusWorkerDailyReport::getTeamId, teamId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(userId), BusWorkerDailyReport::getUserId, userId);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(reportDate), BusWorkerDailyReport::getReportDate, reportDate);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(isResubmit), BusWorkerDailyReport::getIsResubmit, isResubmit);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@ -260,56 +219,4 @@ public class BusWorkerDailyReportServiceImpl extends ServiceImpl<BusWorkerDailyR
|
||||
return workerDailyReportVoPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取施工人员日报补报分页对象视图
|
||||
*
|
||||
* @param workerDailyReportPage 施工人员日报列表分页对象
|
||||
* @return 施工人员日报列表分页对象视图
|
||||
*/
|
||||
@Override
|
||||
public Page<WorkerDailyReportReissueResp> getReissueVoPage(Page<BusWorkerDailyReport> workerDailyReportPage) {
|
||||
// 对象列表 => 封装对象列表
|
||||
List<BusWorkerDailyReport> workerDailyReportList = workerDailyReportPage.getRecords();
|
||||
Page<WorkerDailyReportReissueResp> respPage = new Page<>(
|
||||
workerDailyReportPage.getCurrent(),
|
||||
workerDailyReportPage.getSize(),
|
||||
workerDailyReportPage.getTotal());
|
||||
if (CollUtil.isEmpty(workerDailyReportList)) {
|
||||
return respPage;
|
||||
}
|
||||
// 获取日报计件详情信息
|
||||
List<Long> idList = workerDailyReportList.stream().map(BusWorkerDailyReport::getId).toList();
|
||||
Map<Long, List<BusDailyPieceItem>> reportIdDailyPieceItemMap = dailyPieceItemService.lambdaQuery()
|
||||
.in(BusDailyPieceItem::getReportId, idList).list()
|
||||
.stream().collect(Collectors.groupingBy(BusDailyPieceItem::getReportId));
|
||||
// 获取班组详情信息
|
||||
List<Long> teamIdList = workerDailyReportList.stream().map(BusWorkerDailyReport::getTeamId).toList();
|
||||
Map<Long, List<BusProjectTeam>> teamIdProjectTeamMap = projectTeamService.lambdaQuery()
|
||||
.in(BusProjectTeam::getId, teamIdList).list()
|
||||
.stream().collect(Collectors.groupingBy(BusProjectTeam::getId));
|
||||
// 封装对象
|
||||
List<WorkerDailyReportReissueResp> workerDailyReportVoList = workerDailyReportList.stream().map(workerDailyReport -> {
|
||||
WorkerDailyReportReissueResp workerDailyReportVo = new WorkerDailyReportReissueResp();
|
||||
BeanUtils.copyProperties(workerDailyReport, workerDailyReportVo);
|
||||
Long id = workerDailyReport.getId();
|
||||
// 获取日报计件详情信息
|
||||
List<BusDailyPieceItemVo> dailyPieceItemVoList = new ArrayList<>();
|
||||
if (reportIdDailyPieceItemMap.containsKey(id)) {
|
||||
List<BusDailyPieceItem> dailyPieceItemList = reportIdDailyPieceItemMap.get(id);
|
||||
dailyPieceItemVoList = dailyPieceItemService.getListVo(dailyPieceItemList);
|
||||
}
|
||||
workerDailyReportVo.setDailyPieceItemVoList(dailyPieceItemVoList);
|
||||
// 获取班组详情信息
|
||||
String teamName = null;
|
||||
if (teamIdProjectTeamMap.containsKey(workerDailyReport.getTeamId())) {
|
||||
BusProjectTeam projectTeam = teamIdProjectTeamMap.get(workerDailyReport.getTeamId()).get(0);
|
||||
teamName = projectTeam.getTeamName();
|
||||
}
|
||||
workerDailyReportVo.setTeamName(teamName);
|
||||
return workerDailyReportVo;
|
||||
}).toList();
|
||||
respPage.setRecords(workerDailyReportVoList);
|
||||
return respPage;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user