施工人员黑名单模块、施工人员考勤模块
This commit is contained in:
		| @ -0,0 +1,108 @@ | ||||
| package org.dromara.project.controller; | ||||
|  | ||||
| import cn.dev33.satoken.annotation.SaCheckPermission; | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import jakarta.validation.constraints.NotEmpty; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import org.dromara.common.core.domain.R; | ||||
| import org.dromara.common.core.validate.AddGroup; | ||||
| import org.dromara.common.core.validate.EditGroup; | ||||
| import org.dromara.common.excel.utils.ExcelUtil; | ||||
| import org.dromara.common.idempotent.annotation.RepeatSubmit; | ||||
| import org.dromara.common.log.annotation.Log; | ||||
| import org.dromara.common.log.enums.BusinessType; | ||||
| 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.attendance.AttendanceCreateReq; | ||||
| import org.dromara.project.domain.req.attendance.AttendanceQueryReq; | ||||
| import org.dromara.project.domain.req.attendance.AttendanceUpdateReq; | ||||
| import org.dromara.project.domain.vo.BusAttendanceVo; | ||||
| import org.dromara.project.service.IBusAttendanceService; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 考勤 | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-26 | ||||
|  */ | ||||
| @Validated | ||||
| @RequiredArgsConstructor | ||||
| @RestController | ||||
| @RequestMapping("/project/attendance") | ||||
| public class BusAttendanceController extends BaseController { | ||||
|  | ||||
|     private final IBusAttendanceService busAttendanceService; | ||||
|  | ||||
|     /** | ||||
|      * 查询考勤列表 | ||||
|      */ | ||||
|     @SaCheckPermission("project:attendance:list") | ||||
|     @GetMapping("/list") | ||||
|     public TableDataInfo<BusAttendanceVo> list(AttendanceQueryReq req, PageQuery pageQuery) { | ||||
|         return busAttendanceService.queryPageList(req, pageQuery); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 导出考勤列表 | ||||
|      */ | ||||
|     @SaCheckPermission("project:attendance:export") | ||||
|     @Log(title = "考勤", businessType = BusinessType.EXPORT) | ||||
|     @PostMapping("/export") | ||||
|     public void export(AttendanceQueryReq req, HttpServletResponse response) { | ||||
|         List<BusAttendanceVo> list = busAttendanceService.queryList(req); | ||||
|         ExcelUtil.exportExcel(list, "考勤", BusAttendanceVo.class, response); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取考勤详细信息 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      */ | ||||
|     @SaCheckPermission("project:attendance:query") | ||||
|     @GetMapping("/{id}") | ||||
|     public R<BusAttendanceVo> getInfo(@NotNull(message = "主键不能为空") | ||||
|                                       @PathVariable Long id) { | ||||
|         return R.ok(busAttendanceService.queryById(id)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增考勤 | ||||
|      */ | ||||
|     @SaCheckPermission("project:attendance:add") | ||||
|     @Log(title = "考勤", businessType = BusinessType.INSERT) | ||||
|     @RepeatSubmit() | ||||
|     @PostMapping() | ||||
|     public R<Long> add(@Validated(AddGroup.class) @RequestBody AttendanceCreateReq req) { | ||||
|         return R.ok(busAttendanceService.insertByBo(req)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 修改考勤 | ||||
|      */ | ||||
|     @SaCheckPermission("project:attendance:edit") | ||||
|     @Log(title = "考勤", businessType = BusinessType.UPDATE) | ||||
|     @RepeatSubmit() | ||||
|     @PutMapping() | ||||
|     public R<Void> edit(@Validated(EditGroup.class) @RequestBody AttendanceUpdateReq req) { | ||||
|         return toAjax(busAttendanceService.updateByBo(req)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 删除考勤 | ||||
|      * | ||||
|      * @param ids 主键串 | ||||
|      */ | ||||
|     @SaCheckPermission("project:attendance:remove") | ||||
|     @Log(title = "考勤", businessType = BusinessType.DELETE) | ||||
|     @DeleteMapping("/{ids}") | ||||
|     public R<Void> remove(@NotEmpty(message = "主键不能为空") | ||||
|                           @PathVariable Long[] ids) { | ||||
|         return toAjax(busAttendanceService.deleteWithValidByIds(List.of(ids), true)); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,95 @@ | ||||
| package org.dromara.project.controller; | ||||
|  | ||||
| import cn.dev33.satoken.annotation.SaCheckPermission; | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import jakarta.validation.constraints.NotEmpty; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import org.dromara.common.core.domain.R; | ||||
| import org.dromara.common.core.validate.AddGroup; | ||||
| import org.dromara.common.excel.utils.ExcelUtil; | ||||
| import org.dromara.common.idempotent.annotation.RepeatSubmit; | ||||
| import org.dromara.common.log.annotation.Log; | ||||
| import org.dromara.common.log.enums.BusinessType; | ||||
| 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.constructionblacklist.ConstructionBlacklistCreateReq; | ||||
| import org.dromara.project.domain.req.constructionblacklist.ConstructionBlacklistQueryReq; | ||||
| import org.dromara.project.domain.vo.BusConstructionBlacklistVo; | ||||
| import org.dromara.project.service.IBusConstructionBlacklistService; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 黑名单 | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-27 | ||||
|  */ | ||||
| @Validated | ||||
| @RequiredArgsConstructor | ||||
| @RestController | ||||
| @RequestMapping("/project/constructionBlacklist") | ||||
| public class BusConstructionBlacklistController extends BaseController { | ||||
|  | ||||
|     private final IBusConstructionBlacklistService busConstructionBlacklistService; | ||||
|  | ||||
|     /** | ||||
|      * 查询黑名单列表 | ||||
|      */ | ||||
|     @SaCheckPermission("project:constructionBlacklist:list") | ||||
|     @GetMapping("/list") | ||||
|     public TableDataInfo<BusConstructionBlacklistVo> list(ConstructionBlacklistQueryReq req, PageQuery pageQuery) { | ||||
|         return busConstructionBlacklistService.queryPageList(req, pageQuery); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 导出黑名单列表 | ||||
|      */ | ||||
|     @SaCheckPermission("project:constructionBlacklist:export") | ||||
|     @Log(title = "黑名单", businessType = BusinessType.EXPORT) | ||||
|     @PostMapping("/export") | ||||
|     public void export(ConstructionBlacklistQueryReq req, HttpServletResponse response) { | ||||
|         List<BusConstructionBlacklistVo> list = busConstructionBlacklistService.queryList(req); | ||||
|         ExcelUtil.exportExcel(list, "黑名单", BusConstructionBlacklistVo.class, response); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取黑名单详细信息 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      */ | ||||
|     @SaCheckPermission("project:constructionBlacklist:query") | ||||
|     @GetMapping("/{id}") | ||||
|     public R<BusConstructionBlacklistVo> getInfo(@NotNull(message = "主键不能为空") | ||||
|                                                  @PathVariable Long id) { | ||||
|         return R.ok(busConstructionBlacklistService.queryById(id)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增黑名单 | ||||
|      */ | ||||
|     @SaCheckPermission("project:constructionBlacklist:add") | ||||
|     @Log(title = "黑名单", businessType = BusinessType.INSERT) | ||||
|     @RepeatSubmit() | ||||
|     @PostMapping() | ||||
|     public R<Long> add(@Validated(AddGroup.class) @RequestBody ConstructionBlacklistCreateReq req) { | ||||
|         return R.ok(busConstructionBlacklistService.insertByBo(req)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 删除黑名单 | ||||
|      * | ||||
|      * @param ids 主键串 | ||||
|      */ | ||||
|     @SaCheckPermission("project:constructionBlacklist:remove") | ||||
|     @Log(title = "黑名单", businessType = BusinessType.DELETE) | ||||
|     @DeleteMapping("/{ids}") | ||||
|     public R<Void> remove(@NotEmpty(message = "主键不能为空") | ||||
|                           @PathVariable Long[] ids) { | ||||
|         return toAjax(busConstructionBlacklistService.deleteWithValidByIds(List.of(ids), true)); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,94 @@ | ||||
| package org.dromara.project.domain; | ||||
|  | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableLogic; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import org.dromara.common.mybatis.core.domain.BaseEntity; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.util.Date; | ||||
|  | ||||
| /** | ||||
|  * 考勤对象 bus_attendance | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-26 | ||||
|  */ | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @TableName("bus_attendance") | ||||
| public class BusAttendance extends BaseEntity { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 主键id | ||||
|      */ | ||||
|     @TableId(value = "id") | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 人员id | ||||
|      */ | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 人员姓名 | ||||
|      */ | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|      * 人脸照 | ||||
|      */ | ||||
|     private String facePic; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 打卡时间 | ||||
|      */ | ||||
|     private String clockTime; | ||||
|  | ||||
|     /** | ||||
|      * 1正常,2迟到,3早退,4缺勤,5补卡 | ||||
|      */ | ||||
|     private String clockStatus; | ||||
|  | ||||
|     /** | ||||
|      * 代打人员id | ||||
|      */ | ||||
|     private String pinchUserId; | ||||
|  | ||||
|     /** | ||||
|      * 多次打卡时间记录 | ||||
|      */ | ||||
|     private String clockRecord; | ||||
|  | ||||
|     /** | ||||
|      * 上下班(1上班,2下班) | ||||
|      */ | ||||
|     private String commuter; | ||||
|  | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     private String remark; | ||||
|  | ||||
|     /** | ||||
|      * 删除时间 | ||||
|      */ | ||||
|     private Date deletedAt; | ||||
|  | ||||
|     /** | ||||
|      * 是否删除(0正常 1删除) | ||||
|      */ | ||||
|     @TableLogic | ||||
|     private Long isDelete; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,69 @@ | ||||
| package org.dromara.project.domain; | ||||
|  | ||||
| import com.baomidou.mybatisplus.annotation.FieldFill; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
| import java.util.Date; | ||||
|  | ||||
| /** | ||||
|  * 黑名单对象 bus_construction_blacklist | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-27 | ||||
|  */ | ||||
| @Data | ||||
| @TableName("bus_construction_blacklist") | ||||
| public class BusConstructionBlacklist implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 主键id | ||||
|      */ | ||||
|     @TableId(value = "id") | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 用户id | ||||
|      */ | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 名字 | ||||
|      */ | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|      * 身份证号码 | ||||
|      */ | ||||
|     private String sfzNumber; | ||||
|  | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     private String remark; | ||||
|  | ||||
|     /** | ||||
|      * 创建者 | ||||
|      */ | ||||
|     @TableField(fill = FieldFill.INSERT) | ||||
|     private Long createBy; | ||||
|  | ||||
|     /** | ||||
|      * 创建时间 | ||||
|      */ | ||||
|     @TableField(fill = FieldFill.INSERT) | ||||
|     private Date createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,45 @@ | ||||
| package org.dromara.project.domain.bo; | ||||
|  | ||||
| import org.dromara.project.domain.BusConstructionBlacklist; | ||||
| 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.*; | ||||
|  | ||||
| /** | ||||
|  * 黑名单业务对象 bus_construction_blacklist | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-27 | ||||
|  */ | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @AutoMapper(target = BusConstructionBlacklist.class, reverseConvertGenerate = false) | ||||
| public class BusConstructionBlacklistBo extends BaseEntity { | ||||
|  | ||||
|     /** | ||||
|      * 用户id | ||||
|      */ | ||||
|     @NotNull(message = "用户id不能为空", groups = { AddGroup.class }) | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 名字 | ||||
|      */ | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|      * 身份证号码 | ||||
|      */ | ||||
|     private String sfzNumber; | ||||
|  | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     private String remark; | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,57 @@ | ||||
| package org.dromara.project.domain.req.attendance; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * @author lcj | ||||
|  * @date 2025/3/26 9:46 | ||||
|  */ | ||||
| @Data | ||||
| public class AttendanceCreateReq implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1906706006468828948L; | ||||
|  | ||||
|     /** | ||||
|      * 人员id | ||||
|      */ | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 人脸照 | ||||
|      */ | ||||
|     private String facePic; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 1正常,2迟到,3早退,4缺勤,5补卡 | ||||
|      */ | ||||
|     private String clockStatus; | ||||
|  | ||||
|     /** | ||||
|      * 代打人员id | ||||
|      */ | ||||
|     private String pinchUserId; | ||||
|  | ||||
|     /** | ||||
|      * 多次打卡时间记录 | ||||
|      */ | ||||
|     private String clockRecord; | ||||
|  | ||||
|     /** | ||||
|      * 上下班(1上班,2下班) | ||||
|      */ | ||||
|     private String commuter; | ||||
|  | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     private String remark; | ||||
| } | ||||
| @ -0,0 +1,58 @@ | ||||
| package org.dromara.project.domain.req.attendance; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * @author lcj | ||||
|  * @date 2025/3/26 9:47 | ||||
|  */ | ||||
| @Data | ||||
| public class AttendanceQueryReq implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = -7188085233824968862L; | ||||
|  | ||||
|     /** | ||||
|      * 主键id | ||||
|      */ | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 人员id | ||||
|      */ | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 人员姓名 | ||||
|      */ | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 1正常,2迟到,3早退,4缺勤,5补卡 | ||||
|      */ | ||||
|     private String clockStatus; | ||||
|  | ||||
|     /** | ||||
|      * 代打人员id | ||||
|      */ | ||||
|     private String pinchUserId; | ||||
|  | ||||
|     /** | ||||
|      * 上下班(1上班,2下班) | ||||
|      */ | ||||
|     private String commuter; | ||||
|  | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     private String remark; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,72 @@ | ||||
| package org.dromara.project.domain.req.attendance; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * @author lcj | ||||
|  * @date 2025/3/26 9:47 | ||||
|  */ | ||||
| @Data | ||||
| public class AttendanceUpdateReq implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 3159243618168476248L; | ||||
|  | ||||
|     /** | ||||
|      * 主键id | ||||
|      */ | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 人员id | ||||
|      */ | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 人员姓名 | ||||
|      */ | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|      * 人脸照 | ||||
|      */ | ||||
|     private String facePic; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 打卡时间 | ||||
|      */ | ||||
|     private String clockTime; | ||||
|  | ||||
|     /** | ||||
|      * 1正常,2迟到,3早退,4缺勤,5补卡 | ||||
|      */ | ||||
|     private String clockStatus; | ||||
|  | ||||
|     /** | ||||
|      * 代打人员id | ||||
|      */ | ||||
|     private String pinchUserId; | ||||
|  | ||||
|     /** | ||||
|      * 多次打卡时间记录 | ||||
|      */ | ||||
|     private String clockRecord; | ||||
|  | ||||
|     /** | ||||
|      * 上下班(1上班,2下班) | ||||
|      */ | ||||
|     private String commuter; | ||||
|  | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     private String remark; | ||||
| } | ||||
| @ -0,0 +1,28 @@ | ||||
| package org.dromara.project.domain.req.constructionblacklist; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * @author lcj | ||||
|  * @date 2025/3/27 9:30 | ||||
|  */ | ||||
| @Data | ||||
| public class ConstructionBlacklistCreateReq implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = -1095123147028743165L; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 用户id | ||||
|      */ | ||||
|     private Long userId; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,43 @@ | ||||
| package org.dromara.project.domain.req.constructionblacklist; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * @author lcj | ||||
|  * @date 2025/3/27 9:30 | ||||
|  */ | ||||
| @Data | ||||
| public class ConstructionBlacklistQueryReq implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 5638694783769399209L; | ||||
|  | ||||
|     /** | ||||
|      * 主键id | ||||
|      */ | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 用户id | ||||
|      */ | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 名字 | ||||
|      */ | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|      * 身份证号码 | ||||
|      */ | ||||
|     private String sfzNumber; | ||||
|  | ||||
| } | ||||
| @ -20,6 +20,11 @@ public class WorkWageUpdateReq implements Serializable { | ||||
|      */ | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 工种 | ||||
|      */ | ||||
|  | ||||
| @ -0,0 +1,98 @@ | ||||
| package org.dromara.project.domain.vo; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import io.github.linpeilie.annotations.AutoMapper; | ||||
| import lombok.Data; | ||||
| import org.dromara.common.excel.annotation.ExcelDictFormat; | ||||
| import org.dromara.common.excel.convert.ExcelDictConvert; | ||||
| import org.dromara.project.domain.BusAttendance; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * 考勤视图对象 bus_attendance | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-26 | ||||
|  */ | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| @AutoMapper(target = BusAttendance.class) | ||||
| public class BusAttendanceVo implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 主键id | ||||
|      */ | ||||
|     @ExcelProperty(value = "主键id") | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 人员id | ||||
|      */ | ||||
|     @ExcelProperty(value = "人员id") | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 人员姓名 | ||||
|      */ | ||||
|     @ExcelProperty(value = "人员姓名") | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|      * 人脸照 | ||||
|      */ | ||||
|     @ExcelProperty(value = "人脸照") | ||||
|     private String facePic; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     @ExcelProperty(value = "项目id") | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 打卡时间 | ||||
|      */ | ||||
|     @ExcelProperty(value = "打卡时间") | ||||
|     private String clockTime; | ||||
|  | ||||
|     /** | ||||
|      * 1正常,2迟到,3早退,4缺勤,5补卡 | ||||
|      */ | ||||
|     @ExcelProperty(value = "1正常,2迟到,3早退,4缺勤,5补卡", converter = ExcelDictConvert.class) | ||||
|     @ExcelDictFormat(dictType = "clock_status_type") | ||||
|     private String clockStatus; | ||||
|  | ||||
|     /** | ||||
|      * 代打人员id | ||||
|      */ | ||||
|     @ExcelProperty(value = "代打人员id") | ||||
|     private String pinchUserId; | ||||
|  | ||||
|     /** | ||||
|      * 多次打卡时间记录 | ||||
|      */ | ||||
|     @ExcelProperty(value = "多次打卡时间记录") | ||||
|     private String clockRecord; | ||||
|  | ||||
|     /** | ||||
|      * 上下班(1上班,2下班) | ||||
|      */ | ||||
|     @ExcelProperty(value = "上下班", converter = ExcelDictConvert.class) | ||||
|     @ExcelDictFormat(dictType = "commuter_type") | ||||
|     private String commuter; | ||||
|  | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     @ExcelProperty(value = "备注") | ||||
|     private String remark; | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,76 @@ | ||||
| package org.dromara.project.domain.vo; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import io.github.linpeilie.annotations.AutoMapper; | ||||
| import lombok.Data; | ||||
| import org.dromara.project.domain.BusConstructionBlacklist; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
| import java.util.Date; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * 黑名单视图对象 bus_construction_blacklist | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-27 | ||||
|  */ | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| @AutoMapper(target = BusConstructionBlacklist.class) | ||||
| public class BusConstructionBlacklistVo implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 主键id | ||||
|      */ | ||||
|     @ExcelProperty(value = "主键id") | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 项目id | ||||
|      */ | ||||
|     @ExcelProperty(value = "项目id") | ||||
|     private Long projectId; | ||||
|  | ||||
|     /** | ||||
|      * 用户id | ||||
|      */ | ||||
|     @ExcelProperty(value = "用户id") | ||||
|     private Long userId; | ||||
|  | ||||
|     /** | ||||
|      * 名字 | ||||
|      */ | ||||
|     @ExcelProperty(value = "名字") | ||||
|     private String userName; | ||||
|  | ||||
|     /** | ||||
|      * 身份证号码 | ||||
|      */ | ||||
|     @ExcelProperty(value = "身份证号码") | ||||
|     private String sfzNumber; | ||||
|  | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     @ExcelProperty(value = "备注") | ||||
|     private String remark; | ||||
|  | ||||
|     /** | ||||
|      * 创建者 | ||||
|      */ | ||||
|     @ExcelProperty(value = "创建者") | ||||
|     private Long createBy; | ||||
|  | ||||
|     /** | ||||
|      * 创建时间 | ||||
|      */ | ||||
|     @ExcelProperty(value = "创建时间") | ||||
|     private Date createTime; | ||||
|  | ||||
| } | ||||
| @ -134,8 +134,7 @@ public class BusProjectVo implements Serializable { | ||||
|     /** | ||||
|      * 打卡范围(09:00,18:00) | ||||
|      */ | ||||
|     @ExcelProperty(value = "打卡范围", converter = ExcelDictConvert.class) | ||||
|     @ExcelDictFormat(readConverterExp = "0=9:00,18:00") | ||||
|     @ExcelProperty(value = "打卡范围") | ||||
|     private String punchRange; | ||||
|  | ||||
|     /** | ||||
|  | ||||
| @ -0,0 +1,15 @@ | ||||
| package org.dromara.project.mapper; | ||||
|  | ||||
| import org.dromara.project.domain.BusAttendance; | ||||
| import org.dromara.project.domain.vo.BusAttendanceVo; | ||||
| import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; | ||||
|  | ||||
| /** | ||||
|  * 考勤Mapper接口 | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-26 | ||||
|  */ | ||||
| public interface BusAttendanceMapper extends BaseMapperPlus<BusAttendance, BusAttendanceVo> { | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| package org.dromara.project.mapper; | ||||
|  | ||||
| import org.dromara.project.domain.BusConstructionBlacklist; | ||||
| import org.dromara.project.domain.vo.BusConstructionBlacklistVo; | ||||
| import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; | ||||
|  | ||||
| /** | ||||
|  * 黑名单Mapper接口 | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-27 | ||||
|  */ | ||||
| public interface BusConstructionBlacklistMapper extends BaseMapperPlus<BusConstructionBlacklist, BusConstructionBlacklistVo> { | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,72 @@ | ||||
| package org.dromara.project.service; | ||||
|  | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import org.dromara.common.mybatis.core.page.PageQuery; | ||||
| import org.dromara.common.mybatis.core.page.TableDataInfo; | ||||
| import org.dromara.project.domain.BusConstructionBlacklist; | ||||
| import org.dromara.project.domain.req.constructionblacklist.ConstructionBlacklistCreateReq; | ||||
| import org.dromara.project.domain.req.constructionblacklist.ConstructionBlacklistQueryReq; | ||||
| import org.dromara.project.domain.vo.BusConstructionBlacklistVo; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 黑名单Service接口 | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-27 | ||||
|  */ | ||||
| public interface IBusConstructionBlacklistService extends IService<BusConstructionBlacklist> { | ||||
|  | ||||
|     /** | ||||
|      * 查询黑名单 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      * @return 黑名单 | ||||
|      */ | ||||
|     BusConstructionBlacklistVo queryById(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 分页查询黑名单列表 | ||||
|      * | ||||
|      * @param req       查询条件 | ||||
|      * @param pageQuery 分页参数 | ||||
|      * @return 黑名单分页列表 | ||||
|      */ | ||||
|     TableDataInfo<BusConstructionBlacklistVo> queryPageList(ConstructionBlacklistQueryReq req, PageQuery pageQuery); | ||||
|  | ||||
|     /** | ||||
|      * 查询符合条件的黑名单列表 | ||||
|      * | ||||
|      * @param req 查询条件 | ||||
|      * @return 黑名单列表 | ||||
|      */ | ||||
|     List<BusConstructionBlacklistVo> queryList(ConstructionBlacklistQueryReq req); | ||||
|  | ||||
|     /** | ||||
|      * 新增黑名单 | ||||
|      * | ||||
|      * @param req 黑名单 | ||||
|      * @return 是否新增成功 | ||||
|      */ | ||||
|     Long insertByBo(ConstructionBlacklistCreateReq req); | ||||
|  | ||||
|     /** | ||||
|      * 校验并批量删除黑名单信息 | ||||
|      * | ||||
|      * @param ids     待删除的主键集合 | ||||
|      * @param isValid 是否进行有效性校验 | ||||
|      * @return 是否删除成功 | ||||
|      */ | ||||
|     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); | ||||
|  | ||||
|     /** | ||||
|      * 获取黑名单查询条件封装 | ||||
|      * | ||||
|      * @param req 查询条件 | ||||
|      * @return 查询条件封装 | ||||
|      */ | ||||
|     LambdaQueryWrapper<BusConstructionBlacklist> buildQueryWrapper(ConstructionBlacklistQueryReq req); | ||||
| } | ||||
| @ -78,7 +78,7 @@ public interface IBusProjectService extends IService<BusProject> { | ||||
|      * @param project 项目对象 | ||||
|      * @return 项目视图对象 | ||||
|      */ | ||||
|     BusProjectVo getProjectVo(BusProject project); | ||||
|     BusProjectVo getVo(BusProject project); | ||||
|  | ||||
|     /** | ||||
|      * 获取项目查询条件封装 | ||||
|  | ||||
| @ -53,7 +53,7 @@ public interface IBusUserProjectRelevancyService extends IService<BusUserProject | ||||
|      * 新增系统用户与项目关联 | ||||
|      * | ||||
|      * @param req 系统用户与项目关联 | ||||
|      * @return 新增关联信息ID | ||||
|      * @return 新增关联id | ||||
|      */ | ||||
|     Long insertByBo(UserProjectRelevancyCreateReq req); | ||||
|  | ||||
|  | ||||
| @ -0,0 +1,217 @@ | ||||
| package org.dromara.project.service.impl; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import org.dromara.common.core.constant.HttpStatus; | ||||
| import org.dromara.common.core.exception.ServiceException; | ||||
| import org.dromara.common.core.utils.ObjectUtils; | ||||
| 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.req.attendance.AttendanceCreateReq; | ||||
| import org.dromara.project.domain.req.attendance.AttendanceQueryReq; | ||||
| import org.dromara.project.domain.req.attendance.AttendanceUpdateReq; | ||||
| import org.dromara.project.domain.vo.BusAttendanceVo; | ||||
| import org.dromara.project.mapper.BusAttendanceMapper; | ||||
| import org.dromara.project.service.IBusAttendanceService; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 考勤Service业务层处理 | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-26 | ||||
|  */ | ||||
| @Service | ||||
| public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, BusAttendance> | ||||
|     implements IBusAttendanceService { | ||||
|  | ||||
|     /** | ||||
|      * 查询考勤 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      * @return 考勤 | ||||
|      */ | ||||
|     @Override | ||||
|     public BusAttendanceVo queryById(Long id) { | ||||
|         BusAttendance attendance = this.getById(id); | ||||
|         if (attendance == null) { | ||||
|             throw new ServiceException("考勤信息不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         return this.getVo(attendance); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 分页查询考勤列表 | ||||
|      * | ||||
|      * @param req       查询条件 | ||||
|      * @param pageQuery 分页参数 | ||||
|      * @return 考勤分页列表 | ||||
|      */ | ||||
|     @Override | ||||
|     public TableDataInfo<BusAttendanceVo> queryPageList(AttendanceQueryReq req, PageQuery pageQuery) { | ||||
|         Page<BusAttendance> result = this.page(pageQuery.build(), buildQueryWrapper(req)); | ||||
|         return TableDataInfo.build(this.getVoPage(result)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 查询符合条件的考勤列表 | ||||
|      * | ||||
|      * @param req 查询条件 | ||||
|      * @return 考勤列表 | ||||
|      */ | ||||
|     @Override | ||||
|     public List<BusAttendanceVo> queryList(AttendanceQueryReq req) { | ||||
|         LambdaQueryWrapper<BusAttendance> lqw = buildQueryWrapper(req); | ||||
|         return this.list(lqw).stream().map(this::getVo).toList(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增考勤 | ||||
|      * | ||||
|      * @param req 考勤 | ||||
|      * @return 新增考勤id | ||||
|      */ | ||||
|     @Override | ||||
|     public Long insertByBo(AttendanceCreateReq req) { | ||||
|         // 将实体类和 DTO 进行转换 | ||||
|         BusAttendance attendance = new BusAttendance(); | ||||
|         BeanUtils.copyProperties(req, attendance); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(attendance, true); | ||||
|         // 操作数据库 | ||||
|         boolean save = this.save(attendance); | ||||
|         if (!save) { | ||||
|             throw new ServiceException("新增考勤失败,数据库异常", HttpStatus.ERROR); | ||||
|         } | ||||
|         return attendance.getId(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 修改考勤 | ||||
|      * | ||||
|      * @param req 考勤 | ||||
|      * @return 是否修改成功 | ||||
|      */ | ||||
|     @Override | ||||
|     public Boolean updateByBo(AttendanceUpdateReq req) { | ||||
|         // 将实体类和 DTO 进行转换 | ||||
|         BusAttendance attendance = new BusAttendance(); | ||||
|         BeanUtils.copyProperties(req, attendance); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(attendance, false); | ||||
|         // 判断是否存在 | ||||
|         BusAttendance oldBusAttendance = this.getById(attendance.getId()); | ||||
|         if (oldBusAttendance == null) { | ||||
|             throw new ServiceException("修改考勤失败,数据不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         // 操作数据库 | ||||
|         return this.updateById(attendance); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 保存前的数据校验 | ||||
|      */ | ||||
|     private void validEntityBeforeSave(BusAttendance entity, Boolean create) { | ||||
|         // TODO 做一些数据校验,如唯一约束 | ||||
|         if (create) { | ||||
|  | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 校验并批量删除考勤信息 | ||||
|      * | ||||
|      * @param ids     待删除的主键集合 | ||||
|      * @param isValid 是否进行有效性校验 | ||||
|      * @return 是否删除成功 | ||||
|      */ | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { | ||||
|         if (isValid) { | ||||
|             // TODO 做一些业务上的校验,判断是否需要校验 | ||||
|         } | ||||
|         return this.removeBatchByIds(ids); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取考勤视图对象 | ||||
|      * | ||||
|      * @param attendance 考勤对象 | ||||
|      * @return 考勤视图对象 | ||||
|      */ | ||||
|     @Override | ||||
|     public BusAttendanceVo getVo(BusAttendance attendance) { | ||||
|         // 对象转封装类 | ||||
|         BusAttendanceVo attendanceVo = new BusAttendanceVo(); | ||||
|         if (attendance == null) { | ||||
|             return attendanceVo; | ||||
|         } | ||||
|         BeanUtils.copyProperties(attendance, attendanceVo); | ||||
|         return attendanceVo; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取考勤查询条件封装 | ||||
|      * | ||||
|      * @param req 查询条件 | ||||
|      * @return 查询条件封装 | ||||
|      */ | ||||
|     @Override | ||||
|     public LambdaQueryWrapper<BusAttendance> buildQueryWrapper(AttendanceQueryReq req) { | ||||
|         LambdaQueryWrapper<BusAttendance> lqw = new LambdaQueryWrapper<>(); | ||||
|         if (req == null) { | ||||
|             return lqw; | ||||
|         } | ||||
|         Long id = req.getId(); | ||||
|         Long userId = req.getUserId(); | ||||
|         String userName = req.getUserName(); | ||||
|         Long projectId = req.getProjectId(); | ||||
|         String clockStatus = req.getClockStatus(); | ||||
|         String pinchUserId = req.getPinchUserId(); | ||||
|         String commuter = req.getCommuter(); | ||||
|         String remark = req.getRemark(); | ||||
|         // 模糊查询 | ||||
|         lqw.like(StringUtils.isNotBlank(userName), BusAttendance::getUserName, userName); | ||||
|         lqw.like(StringUtils.isNotBlank(remark), BusAttendance::getRemark, remark); | ||||
|         // 精确查询 | ||||
|         lqw.eq(ObjectUtils.isNotEmpty(id), BusAttendance::getId, id); | ||||
|         lqw.eq(ObjectUtils.isNotEmpty(userId), BusAttendance::getUserId, userId); | ||||
|         lqw.eq(ObjectUtils.isNotEmpty(projectId), BusAttendance::getProjectId, projectId); | ||||
|         lqw.eq(StringUtils.isNotBlank(clockStatus), BusAttendance::getClockStatus, clockStatus); | ||||
|         lqw.eq(StringUtils.isNotBlank(pinchUserId), BusAttendance::getPinchUserId, pinchUserId); | ||||
|         lqw.eq(StringUtils.isNotBlank(commuter), BusAttendance::getCommuter, commuter); | ||||
|         return lqw; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取考勤分页对象视图 | ||||
|      * | ||||
|      * @param attendancePage 考勤分页对象 | ||||
|      * @return 考勤分页对象视图 | ||||
|      */ | ||||
|     @Override | ||||
|     public Page<BusAttendanceVo> getVoPage(Page<BusAttendance> attendancePage) { | ||||
|         List<BusAttendance> attendanceList = attendancePage.getRecords(); | ||||
|         Page<BusAttendanceVo> attendanceVoPage = new Page<>( | ||||
|             attendancePage.getCurrent(), | ||||
|             attendancePage.getSize(), | ||||
|             attendancePage.getTotal() | ||||
|         ); | ||||
|         if (CollUtil.isEmpty(attendanceList)) { | ||||
|             return attendanceVoPage; | ||||
|         } | ||||
|         List<BusAttendanceVo> attendanceVoList = attendanceList.stream().map(this::getVo).toList(); | ||||
|         attendanceVoPage.setRecords(attendanceVoList); | ||||
|         return attendanceVoPage; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,179 @@ | ||||
| package org.dromara.project.service.impl; | ||||
|  | ||||
| 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.service.impl.ServiceImpl; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.dromara.common.core.constant.HttpStatus; | ||||
| import org.dromara.common.core.exception.ServiceException; | ||||
| import org.dromara.common.core.utils.ObjectUtils; | ||||
| 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.common.satoken.utils.LoginHelper; | ||||
| import org.dromara.project.domain.BusConstructionBlacklist; | ||||
| import org.dromara.project.domain.BusConstructionUser; | ||||
| import org.dromara.project.domain.req.constructionblacklist.ConstructionBlacklistCreateReq; | ||||
| import org.dromara.project.domain.req.constructionblacklist.ConstructionBlacklistQueryReq; | ||||
| import org.dromara.project.domain.vo.BusConstructionBlacklistVo; | ||||
| import org.dromara.project.mapper.BusConstructionBlacklistMapper; | ||||
| import org.dromara.project.service.IBusConstructionBlacklistService; | ||||
| import org.dromara.project.service.IBusConstructionUserService; | ||||
| import org.dromara.project.service.IBusProjectService; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 黑名单Service业务层处理 | ||||
|  * | ||||
|  * @author lcj | ||||
|  * @date 2025-03-27 | ||||
|  */ | ||||
| @Service | ||||
| public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstructionBlacklistMapper, BusConstructionBlacklist> | ||||
|     implements IBusConstructionBlacklistService { | ||||
|  | ||||
|     @Resource | ||||
|     private IBusProjectService projectService; | ||||
|  | ||||
|     @Resource | ||||
|     private IBusConstructionUserService constructionUserService; | ||||
|  | ||||
|     /** | ||||
|      * 查询黑名单 | ||||
|      * | ||||
|      * @param id 主键 | ||||
|      * @return 黑名单 | ||||
|      */ | ||||
|     @Override | ||||
|     public BusConstructionBlacklistVo queryById(Long id) { | ||||
|         return baseMapper.selectVoById(id); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 分页查询黑名单列表 | ||||
|      * | ||||
|      * @param req       查询条件 | ||||
|      * @param pageQuery 分页参数 | ||||
|      * @return 黑名单分页列表 | ||||
|      */ | ||||
|     @Override | ||||
|     public TableDataInfo<BusConstructionBlacklistVo> queryPageList(ConstructionBlacklistQueryReq req, PageQuery pageQuery) { | ||||
|         LambdaQueryWrapper<BusConstructionBlacklist> lqw = buildQueryWrapper(req); | ||||
|         Page<BusConstructionBlacklistVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); | ||||
|         return TableDataInfo.build(result); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 查询符合条件的黑名单列表 | ||||
|      * | ||||
|      * @param req 查询条件 | ||||
|      * @return 黑名单列表 | ||||
|      */ | ||||
|     @Override | ||||
|     public List<BusConstructionBlacklistVo> queryList(ConstructionBlacklistQueryReq req) { | ||||
|         LambdaQueryWrapper<BusConstructionBlacklist> lqw = buildQueryWrapper(req); | ||||
|         return baseMapper.selectVoList(lqw); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增黑名单 | ||||
|      * | ||||
|      * @param req 黑名单 | ||||
|      * @return 是否新增成功 | ||||
|      */ | ||||
|     @Override | ||||
|     public Long insertByBo(ConstructionBlacklistCreateReq req) { | ||||
|         // 将实体类和 DTO 进行转换 | ||||
|         BusConstructionBlacklist constructionBlacklist = new BusConstructionBlacklist(); | ||||
|         BeanUtils.copyProperties(req, constructionBlacklist); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(constructionBlacklist); | ||||
|         // 填充默认值 | ||||
|         Long userId = req.getUserId(); | ||||
|         if (userId == null) { | ||||
|             throw new ServiceException("用户 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         } | ||||
|         BusConstructionUser constructionUser = constructionUserService.getById(userId); | ||||
|         if (constructionUser == null) { | ||||
|             throw new ServiceException("对应用户不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         constructionBlacklist.setUserName(constructionUser.getUserName()); | ||||
|         constructionBlacklist.setSfzNumber(constructionUser.getSfzNumber()); | ||||
|         // 操作数据库 | ||||
|         boolean result = this.save(constructionBlacklist); | ||||
|         if (!result) { | ||||
|             throw new ServiceException("新增黑名单失败,数据库异常", HttpStatus.ERROR); | ||||
|         } | ||||
|         return constructionBlacklist.getId(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 保存前的数据校验 | ||||
|      */ | ||||
|     private void validEntityBeforeSave(BusConstructionBlacklist entity) { | ||||
|         // TODO 做一些数据校验,如唯一约束 | ||||
|         Long projectId = entity.getProjectId(); | ||||
|         Long userId = entity.getUserId(); | ||||
|         if (projectId == null) { | ||||
|             throw new ServiceException("项目 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         } | ||||
|         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); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 校验并批量删除黑名单信息 | ||||
|      * | ||||
|      * @param ids     待删除的主键集合 | ||||
|      * @param isValid 是否进行有效性校验 | ||||
|      * @return 是否删除成功 | ||||
|      */ | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { | ||||
|         Long userId = LoginHelper.getUserId(); | ||||
|         List<BusConstructionBlacklist> constructionBlacklistList = this.listByIds(ids); | ||||
|         if (isValid) { | ||||
|             // TODO 做一些业务上的校验,判断是否需要校验 | ||||
|             List<Long> projectId = constructionBlacklistList.stream().map(BusConstructionBlacklist::getProjectId).toList(); | ||||
|             projectService.validAuth(projectId, userId); | ||||
|         } | ||||
|         return this.removeBatchByIds(ids); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获取黑名单查询条件封装 | ||||
|      * | ||||
|      * @param req 查询条件 | ||||
|      * @return 查询条件封装 | ||||
|      */ | ||||
|     @Override | ||||
|     public LambdaQueryWrapper<BusConstructionBlacklist> buildQueryWrapper(ConstructionBlacklistQueryReq req) { | ||||
|         LambdaQueryWrapper<BusConstructionBlacklist> lqw = new LambdaQueryWrapper<>(); | ||||
|         Long id = req.getId(); | ||||
|         Long userId = req.getUserId(); | ||||
|         String userName = req.getUserName(); | ||||
|         String sfzNumber = req.getSfzNumber(); | ||||
|         // 模糊查询 | ||||
|         lqw.like(StringUtils.isNotBlank(userName), BusConstructionBlacklist::getUserName, userName); | ||||
|         lqw.like(StringUtils.isNotBlank(sfzNumber), BusConstructionBlacklist::getSfzNumber, sfzNumber); | ||||
|         // 精确查询 | ||||
|         lqw.eq(ObjectUtils.isNotEmpty(id), BusConstructionBlacklist::getId, id); | ||||
|         lqw.eq(ObjectUtils.isNotEmpty(userId), BusConstructionBlacklist::getUserId, userId); | ||||
|         return lqw; | ||||
|     } | ||||
| } | ||||
| @ -117,7 +117,7 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU | ||||
|         BusConstructionUser constructionUser = new BusConstructionUser(); | ||||
|         BeanUtils.copyProperties(req, constructionUser); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(constructionUser); | ||||
|         validEntityBeforeSave(constructionUser, true); | ||||
|         // 操作数据库 | ||||
|         boolean save = this.save(constructionUser); | ||||
|         if (!save) { | ||||
| @ -138,7 +138,7 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU | ||||
|         BusConstructionUser constructionUser = new BusConstructionUser(); | ||||
|         BeanUtils.copyProperties(req, constructionUser); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(constructionUser); | ||||
|         validEntityBeforeSave(constructionUser, false); | ||||
|         // 判断是否存在 | ||||
|         BusConstructionUser oldConstructionUser = this.getById(constructionUser.getId()); | ||||
|         if (oldConstructionUser == null) { | ||||
| @ -151,21 +151,23 @@ public class BusConstructionUserServiceImpl extends ServiceImpl<BusConstructionU | ||||
|     /** | ||||
|      * 保存前的数据校验 | ||||
|      */ | ||||
|     private void validEntityBeforeSave(BusConstructionUser entity) { | ||||
|     private void validEntityBeforeSave(BusConstructionUser entity, Boolean create) { | ||||
|         // TODO 做一些数据校验,如唯一约束 | ||||
|         // 校验项目id和对应项目是否存在 | ||||
|         Long projectId = entity.getProjectId(); | ||||
|         if (projectId == null) { | ||||
|             throw new ServiceException("项目 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         // 校验分包公司id和对应项目是否存在 | ||||
|         Long contractorId = entity.getContractorId(); | ||||
|         if (create) { | ||||
|             if (projectId == null) { | ||||
|                 throw new ServiceException("项目 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|             } | ||||
|             if (contractorId == null) { | ||||
|                 throw new ServiceException("分包公司 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|             } | ||||
|         } | ||||
|         if (projectService.getById(projectId) == null) { | ||||
|             throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         // 校验分包公司id和对应项目是否存在 | ||||
|         Long contractorId = entity.getContractorId(); | ||||
|         if (contractorId == null) { | ||||
|             throw new ServiceException("分包公司 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         } | ||||
|         if (contractorService.getById(contractorId) == null) { | ||||
|             throw new ServiceException("对应分包公司不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|  | ||||
| @ -24,6 +24,7 @@ import org.dromara.project.domain.vo.BusContractorVo; | ||||
| import org.dromara.project.mapper.BusContractorMapper; | ||||
| import org.dromara.project.service.IBusConstructionUserService; | ||||
| import org.dromara.project.service.IBusContractorService; | ||||
| import org.dromara.project.service.IBusProjectService; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| @ -46,6 +47,9 @@ public class BusContractorServiceImpl extends ServiceImpl<BusContractorMapper, B | ||||
|     @Resource | ||||
|     private IBusConstructionUserService constructionUserService; | ||||
|  | ||||
|     @Resource | ||||
|     private IBusProjectService projectService; | ||||
|  | ||||
|     /** | ||||
|      * 查询分包单位 | ||||
|      * | ||||
| @ -170,12 +174,9 @@ public class BusContractorServiceImpl extends ServiceImpl<BusContractorMapper, B | ||||
|         List<BusContractor> contractorList = this.listByIds(ids); | ||||
|         // 做一些业务上的校验,判断是否需要校验 | ||||
|         if (isValid) { | ||||
|             // 仅创建用户可以删除 | ||||
|             contractorList.forEach(contractor -> { | ||||
|                 if (!contractor.getCreateBy().equals(userId)) { | ||||
|                     throw new ServiceException("您无权删除该分包单位", HttpStatus.FORBIDDEN); | ||||
|                 } | ||||
|             }); | ||||
|             // 仅当前项目下的用户可以删除 | ||||
|             List<Long> projectIdList = contractorList.stream().map(BusContractor::getProjectId).toList(); | ||||
|             projectService.validAuth(projectIdList, userId); | ||||
|             // 判断当前分包公司下是否还包含施工人员 | ||||
|             QueryWrapper<BusConstructionUser> queryWrapper = new QueryWrapper<>(); | ||||
|             queryWrapper.in("contractor_id", ids); | ||||
|  | ||||
| @ -43,9 +43,6 @@ import java.util.stream.Collectors; | ||||
| public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProject> | ||||
|     implements IBusProjectService { | ||||
|  | ||||
|     @Resource | ||||
|     private BusProjectMapper baseMapper; | ||||
|  | ||||
|     @Lazy | ||||
|     @Resource | ||||
|     private IBusUserProjectRelevancyService userProjectRelevancyService; | ||||
| @ -58,7 +55,11 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj | ||||
|      */ | ||||
|     @Override | ||||
|     public BusProjectVo queryById(Long id) { | ||||
|         return baseMapper.selectVoById(id); | ||||
|         BusProject project = this.getById(id); | ||||
|         if (project == null) { | ||||
|             throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         return this.getVo(project); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @ -84,7 +85,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj | ||||
|     @Override | ||||
|     public List<BusProjectVo> queryList(ProjectQueryReq req) { | ||||
|         LambdaQueryWrapper<BusProject> lqw = this.buildQueryWrapper(req); | ||||
|         return baseMapper.selectVoList(lqw); | ||||
|         return this.list(lqw).stream().map(this::getVo).toList(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @ -200,7 +201,6 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj | ||||
|         } | ||||
|         // 删除用户与项目关联表 | ||||
|         QueryWrapper<BusUserProjectRelevancy> queryWrapper = new QueryWrapper<>(); | ||||
|         queryWrapper.eq("user_id", userId); | ||||
|         queryWrapper.in("project_id", ids); | ||||
|         boolean removeRelevancyList = userProjectRelevancyService.remove(queryWrapper); | ||||
|         if (!removeRelevancyList) { | ||||
| @ -216,7 +216,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj | ||||
|      * @return 项目视图对象 | ||||
|      */ | ||||
|     @Override | ||||
|     public BusProjectVo getProjectVo(BusProject project) { | ||||
|     public BusProjectVo getVo(BusProject project) { | ||||
|         if (project == null) { | ||||
|             return null; | ||||
|         } | ||||
| @ -287,7 +287,7 @@ public class BusProjectServiceImpl extends ServiceImpl<BusProjectMapper, BusProj | ||||
|             return projectVoPage; | ||||
|         } | ||||
|         // 对象列表 => 封装对象列表 | ||||
|         List<BusProjectVo> projectVoList = projectList.stream().map(this::getProjectVo).toList(); | ||||
|         List<BusProjectVo> projectVoList = projectList.stream().map(this::getVo).toList(); | ||||
|         projectVoPage.setRecords(projectVoList); | ||||
|         return projectVoPage; | ||||
|     } | ||||
|  | ||||
| @ -4,7 +4,6 @@ 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.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; | ||||
| import jakarta.annotation.Resource; | ||||
| @ -111,7 +110,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM | ||||
|         BusProjectTeamMember projectTeamMember = new BusProjectTeamMember(); | ||||
|         BeanUtils.copyProperties(req, projectTeamMember); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(projectTeamMember); | ||||
|         validEntityBeforeSave(projectTeamMember, true); | ||||
|         // 判断对应的用户与项目关联是否存在 | ||||
|         BusProjectTeamMember teamMember = this.getOne(new LambdaQueryWrapper<BusProjectTeamMember>() | ||||
|             .eq(BusProjectTeamMember::getMemberId, projectTeamMember.getMemberId())); | ||||
| @ -144,7 +143,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM | ||||
|         BusProjectTeamMember projectTeamMember = new BusProjectTeamMember(); | ||||
|         BeanUtils.copyProperties(req, projectTeamMember); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(projectTeamMember); | ||||
|         validEntityBeforeSave(projectTeamMember, false); | ||||
|         // 判断是否存在 | ||||
|         BusProjectTeamMember oldProjectTeamMember = this.getById(projectTeamMember.getId()); | ||||
|         if (oldProjectTeamMember == null) { | ||||
| @ -162,45 +161,36 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM | ||||
|     /** | ||||
|      * 保存前的数据校验 | ||||
|      */ | ||||
|     private void validEntityBeforeSave(BusProjectTeamMember entity) { | ||||
|     private void validEntityBeforeSave(BusProjectTeamMember entity, Boolean create) { | ||||
|         // TODO 做一些数据校验,如唯一约束 | ||||
|         // 判断对应项目是否存在 | ||||
|         Long projectId = entity.getProjectId(); | ||||
|         if (projectId == null) { | ||||
|             throw new ServiceException("项目 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         Long memberId = entity.getMemberId(); | ||||
|         Long teamId = entity.getTeamId(); | ||||
|         String postId = entity.getPostId(); | ||||
|         ProjectTeamMemberPostEnum postEnum = ProjectTeamMemberPostEnum.getEnumByValue(postId); | ||||
|         if (create) { | ||||
|             if (projectId == null) { | ||||
|                 throw new ServiceException("项目 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|             } | ||||
|             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); | ||||
|             } | ||||
|         } | ||||
|         if (projectService.getById(projectId) == null) { | ||||
|             throw new ServiceException("对应项目不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         // 判断对应成员是否存在 | ||||
|         Long memberId = entity.getMemberId(); | ||||
|         if (memberId == null) { | ||||
|             throw new ServiceException("人员 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         } | ||||
|         if (constructionUserService.getById(memberId) == null) { | ||||
|             throw new ServiceException("对应人员不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         // 判断对应班组是否存在 | ||||
|         Long teamId = entity.getTeamId(); | ||||
|         if (teamId == null) { | ||||
|             throw new ServiceException("班组 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         } | ||||
|         if (projectTeamService.getById(teamId) == null) { | ||||
|             throw new ServiceException("对应班组不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         // 判断对应班组班组长是否存在 | ||||
|         String postId = entity.getPostId(); | ||||
|         ProjectTeamMemberPostEnum postEnum = ProjectTeamMemberPostEnum.getEnumByValue(postId); | ||||
|         if (postEnum == null) { | ||||
|             throw new ServiceException("请选择正确的岗位", HttpStatus.BAD_REQUEST); | ||||
|         } | ||||
|         LambdaQueryWrapper<BusProjectTeamMember> lqw = Wrappers.lambdaQuery(BusProjectTeamMember.class) | ||||
|             .eq(BusProjectTeamMember::getProjectId, projectId) | ||||
|             .eq(BusProjectTeamMember::getTeamId, teamId) | ||||
|             .eq(BusProjectTeamMember::getPostId, ProjectTeamMemberPostEnum.FOREMAN.getValue()); | ||||
|         if (this.count(lqw) > 0) { | ||||
|             throw new ServiceException("当前班组已存在班组长", HttpStatus.CONFLICT); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|  | ||||
| @ -44,9 +44,6 @@ import java.util.Objects; | ||||
| public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProjectRelevancyMapper, BusUserProjectRelevancy> | ||||
|     implements IBusUserProjectRelevancyService { | ||||
|  | ||||
|     @Resource | ||||
|     private BusUserProjectRelevancyMapper baseMapper; | ||||
|  | ||||
|     @Resource | ||||
|     private IBusProjectService projectService; | ||||
|  | ||||
| @ -63,6 +60,9 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje | ||||
|     public BusUserProjectRelevancyVo queryById(Long id) { | ||||
|         // 查询数据 | ||||
|         BusUserProjectRelevancy userProjectRelevancy = this.getById(id); | ||||
|         if (userProjectRelevancy == null) { | ||||
|             throw new ServiceException("对应用户与项目关联不存在", HttpStatus.NOT_FOUND); | ||||
|         } | ||||
|         // 封装并返回 | ||||
|         return this.getVo(userProjectRelevancy); | ||||
|     } | ||||
| @ -89,15 +89,15 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje | ||||
|      */ | ||||
|     @Override | ||||
|     public List<BusUserProjectRelevancyVo> queryList(UserProjectRelevancyQueryReq req) { | ||||
|         LambdaQueryWrapper<BusUserProjectRelevancy> queryWrapper = this.buildQueryWrapper(req); | ||||
|         return baseMapper.selectVoList(queryWrapper); | ||||
|         LambdaQueryWrapper<BusUserProjectRelevancy> lqw = this.buildQueryWrapper(req); | ||||
|         return this.list(lqw).stream().map(this::getVo).toList(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 新增系统用户与项目关联 | ||||
|      * | ||||
|      * @param req 系统用户与项目关联 | ||||
|      * @return 是否新增成功 | ||||
|      * @return 新增关联id | ||||
|      */ | ||||
|     @Override | ||||
|     public Long insertByBo(UserProjectRelevancyCreateReq req) { | ||||
| @ -105,7 +105,7 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje | ||||
|         BusUserProjectRelevancy userProjectRelevancy = new BusUserProjectRelevancy(); | ||||
|         BeanUtils.copyProperties(req, userProjectRelevancy); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(userProjectRelevancy); | ||||
|         validEntityBeforeSave(userProjectRelevancy, true); | ||||
|         // 判断对应的用户与项目关联是否存在 | ||||
|         if (this.getOne(new LambdaQueryWrapper<BusUserProjectRelevancy>() | ||||
|             .eq(BusUserProjectRelevancy::getUserId, userProjectRelevancy.getUserId()) | ||||
| @ -133,7 +133,7 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje | ||||
|         BusUserProjectRelevancy userProjectRelevancy = new BusUserProjectRelevancy(); | ||||
|         BeanUtils.copyProperties(req, userProjectRelevancy); | ||||
|         // 数据校验 | ||||
|         validEntityBeforeSave(userProjectRelevancy); | ||||
|         validEntityBeforeSave(userProjectRelevancy, false); | ||||
|         // 判断是否存在 | ||||
|         BusUserProjectRelevancy oldUserProjectRelevancy = this.getById(userProjectRelevancy.getId()); | ||||
|         if (oldUserProjectRelevancy == null) { | ||||
| @ -146,15 +146,17 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje | ||||
|     /** | ||||
|      * 保存前的数据校验 | ||||
|      */ | ||||
|     private void validEntityBeforeSave(BusUserProjectRelevancy entity) { | ||||
|     private void validEntityBeforeSave(BusUserProjectRelevancy entity, Boolean create) { | ||||
|         // TODO 做一些数据校验,如唯一约束 | ||||
|         Long projectId = entity.getProjectId(); | ||||
|         Long userId = entity.getUserId(); | ||||
|         if (projectId == null) { | ||||
|             throw new ServiceException("项目 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         } | ||||
|         if (userId == null) { | ||||
|             throw new ServiceException("用户 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|         if (create) { | ||||
|             if (projectId == null) { | ||||
|                 throw new ServiceException("项目 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|             } | ||||
|             if (userId == null) { | ||||
|                 throw new ServiceException("用户 id 不能为空", HttpStatus.BAD_REQUEST); | ||||
|             } | ||||
|         } | ||||
|         // 判断对应项目是否存在 | ||||
|         if (projectService.getById(projectId) == null) { | ||||
| @ -174,6 +176,7 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje | ||||
|      * @return 是否删除成功 | ||||
|      */ | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { | ||||
|         // 获取当前登录用户 | ||||
|         Long userId = LoginHelper.getUserId(); | ||||
| @ -190,7 +193,7 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje | ||||
|         if (busUserProjectRelevancyList.size() != ids.size()) { | ||||
|             throw new ServiceException("删除系统用户与项目关联失败,数据缺失", HttpStatus.BAD_REQUEST); | ||||
|         } | ||||
|         return baseMapper.deleteByIds(ids) > 0; | ||||
|         return this.removeBatchByIds(ids); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|  | ||||
| @ -0,0 +1,7 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <!DOCTYPE mapper | ||||
| PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="org.dromara.project.mapper.BusAttendanceMapper"> | ||||
|  | ||||
| </mapper> | ||||
| @ -0,0 +1,7 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <!DOCTYPE mapper | ||||
| PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="org.dromara.project.mapper.BusConstructionBlacklistMapper"> | ||||
|  | ||||
| </mapper> | ||||
		Reference in New Issue
	
	Block a user