Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e811d20348
@ -20,7 +20,7 @@ public class BannerApplicationRunner implements ApplicationRunner {
|
||||
public void run(ApplicationArguments args) {
|
||||
ThreadUtil.execute(() -> {
|
||||
ThreadUtil.sleep(1, TimeUnit.SECONDS); // 延迟 1 秒,保证输出到结尾
|
||||
log.info("\n-------------程序猿---------------------------------------------\n\t" +
|
||||
log.info("\n--------------------程序猿-------------------\n\t" +
|
||||
"写字楼里写字间,写字间里程序员; \n\t" +
|
||||
"程序员来写程序,代码换得几杯钱。\n\t" +
|
||||
"酒醒只在屏前坐,酒醉依旧在线眠; \n\t" +
|
||||
@ -29,7 +29,9 @@ public class BannerApplicationRunner implements ApplicationRunner {
|
||||
"宝马奔驰富者趣,地铁公交码农缘。\n\t" +
|
||||
"他人笑我太疯癫,我笑他人代码烂;\n\t" +
|
||||
"不见满街网红妹,哪个曾怜程序员?\n\t" +
|
||||
"-------------------------代码如诗心似弦, 昼夜不倦解难关。 屏前独坐灯如昼, 梦想成真在眼前。--------------OK");
|
||||
"代码如诗心似弦,昼夜不倦解难关。\n\t" +
|
||||
"屏前独坐灯如昼,梦想成真在眼前。\n\t" +
|
||||
"--------------------OK-------------------");
|
||||
|
||||
// log.info("\n----------------------------------------------------------\n\t" +
|
||||
// "项目启动成功!\n\t" +
|
||||
|
@ -16,4 +16,6 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode IMG_NOT_EXISTS = new ErrorCode(1_009_003_000, "公告内容不存在");
|
||||
// ========== 公司新闻 1-011-003-000 ==========
|
||||
ErrorCode NEWS_NOT_EXISTS = new ErrorCode(1_011_003_000, "公司新闻不存在");
|
||||
// ========== 车辆管理 1_011_004_000 ==========
|
||||
ErrorCode CLGL_NOT_EXISTS = new ErrorCode(1_011_004_000, "车辆管理不存在");
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.clgl;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
import cn.iocoder.yudao.module.home.controller.admin.clgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.clgl.ClglDO;
|
||||
import cn.iocoder.yudao.module.home.service.clgl.ClglService;
|
||||
|
||||
@Tag(name = "管理后台 - 车辆管理")
|
||||
@RestController
|
||||
@RequestMapping("/home/clgl")
|
||||
@Validated
|
||||
public class ClglController {
|
||||
|
||||
@Resource
|
||||
private ClglService clglService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建车辆管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:clgl:create')")
|
||||
public CommonResult<Long> createClgl(@Valid @RequestBody ClglSaveReqVO createReqVO) {
|
||||
return success(clglService.createClgl(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新车辆管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:clgl:update')")
|
||||
public CommonResult<Boolean> updateClgl(@Valid @RequestBody ClglSaveReqVO updateReqVO) {
|
||||
clglService.updateClgl(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除车辆管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('home:clgl:delete')")
|
||||
public CommonResult<Boolean> deleteClgl(@RequestParam("id") Long id) {
|
||||
clglService.deleteClgl(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得车辆管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('home:clgl:query')")
|
||||
public CommonResult<ClglRespVO> getClgl(@RequestParam("id") Long id) {
|
||||
ClglDO clgl = clglService.getClgl(id);
|
||||
return success(BeanUtils.toBean(clgl, ClglRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得车辆管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('home:clgl:query')")
|
||||
public CommonResult<PageResult<ClglRespVO>> getClglPage(@Valid ClglPageReqVO pageReqVO) {
|
||||
PageResult<ClglDO> pageResult = clglService.getClglPage(getLoginUserId(),pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ClglRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出车辆管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('home:clgl:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportClglExcel(@Valid ClglPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ClglDO> list = clglService.getClglPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "车辆管理.xls", "数据", ClglRespVO.class,
|
||||
BeanUtils.toBean(list, ClglRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.clgl.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 车辆管理分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ClglPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "流程状态", example = "1")
|
||||
private Integer flowStatus;
|
||||
|
||||
@Schema(description = "id", example = "26309")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "申请人")
|
||||
private Integer carUser;
|
||||
|
||||
@Schema(description = "部门")
|
||||
private Integer dept;
|
||||
|
||||
@Schema(description = "用车类型", example = "1")
|
||||
private Integer carType;
|
||||
|
||||
@Schema(description = "驾驶员")
|
||||
private Integer carDriver;
|
||||
|
||||
@Schema(description = "用车开始时间")
|
||||
private LocalDateTime carStart;
|
||||
|
||||
@Schema(description = "用车结束时间")
|
||||
private LocalDateTime carEnd;
|
||||
|
||||
@Schema(description = "目的地")
|
||||
private String carAddress;
|
||||
|
||||
@Schema(description = "车辆开始里程")
|
||||
private String carStartMileage;
|
||||
|
||||
@Schema(description = "车辆结束里程")
|
||||
private String carEndMileage;
|
||||
|
||||
@Schema(description = "用车状态", example = "2")
|
||||
private Integer carStatus;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.clgl.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 车辆管理 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ClglRespVO {
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "20058")
|
||||
@ExcelProperty("流程实例的编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "流程状态", example = "1")
|
||||
private Integer flowStatus;
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26309")
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "申请人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("申请人")
|
||||
private Integer carUser;
|
||||
|
||||
@Schema(description = "部门", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("部门")
|
||||
private Integer dept;
|
||||
|
||||
@Schema(description = "用车类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "用车类型", converter = DictConvert.class)
|
||||
@DictFormat("clgl_car_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer carType;
|
||||
|
||||
@Schema(description = "驾驶员", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("驾驶员")
|
||||
private Integer carDriver;
|
||||
|
||||
@Schema(description = "用车开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("用车开始时间")
|
||||
private LocalDateTime carStart;
|
||||
|
||||
@Schema(description = "用车结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("用车结束时间")
|
||||
private LocalDateTime carEnd;
|
||||
|
||||
@Schema(description = "目的地", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("目的地")
|
||||
private String carAddress;
|
||||
|
||||
@Schema(description = "车辆信息")
|
||||
@ExcelProperty("车辆信息")
|
||||
private String carInfo;
|
||||
|
||||
@Schema(description = "车辆开始里程")
|
||||
@ExcelProperty("车辆开始里程")
|
||||
private String carStartMileage;
|
||||
|
||||
@Schema(description = "车辆结束里程")
|
||||
@ExcelProperty("车辆结束里程")
|
||||
private String carEndMileage;
|
||||
|
||||
@Schema(description = "用车状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty(value = "用车状态", converter = DictConvert.class)
|
||||
@DictFormat("clgl_car_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer carStatus;
|
||||
|
||||
@Schema(description = "用车原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不喜欢")
|
||||
@ExcelProperty("用车原因")
|
||||
private String carReason;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
@ExcelProperty("备注")
|
||||
private String carRemark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.clgl.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 车辆管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class ClglSaveReqVO {
|
||||
|
||||
@Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}")
|
||||
private Map<String, List<Long>> startUserSelectAssignees;
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26309")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "申请人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "申请人不能为空")
|
||||
private Integer carUser;
|
||||
|
||||
@Schema(description = "部门", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "部门不能为空")
|
||||
private Integer dept;
|
||||
|
||||
@Schema(description = "用车类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "用车类型不能为空")
|
||||
private Integer carType;
|
||||
|
||||
@Schema(description = "驾驶员", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "驾驶员不能为空")
|
||||
private Integer carDriver;
|
||||
|
||||
@Schema(description = "用车开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "用车开始时间不能为空")
|
||||
private LocalDateTime carStart;
|
||||
|
||||
@Schema(description = "用车结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "用车结束时间不能为空")
|
||||
private LocalDateTime carEnd;
|
||||
|
||||
@Schema(description = "目的地", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "目的地不能为空")
|
||||
private String carAddress;
|
||||
|
||||
@Schema(description = "车辆信息")
|
||||
private String carInfo;
|
||||
|
||||
@Schema(description = "车辆开始里程")
|
||||
private String carStartMileage;
|
||||
|
||||
@Schema(description = "车辆结束里程")
|
||||
private String carEndMileage;
|
||||
|
||||
@Schema(description = "用车状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "用车状态不能为空")
|
||||
private Integer carStatus;
|
||||
|
||||
@Schema(description = "用车原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不喜欢")
|
||||
@NotEmpty(message = "用车原因不能为空")
|
||||
private String carReason;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String carRemark;
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package cn.iocoder.yudao.module.home.dal.dataobject.clgl;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
import com.sun.xml.bind.v2.TODO;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 车辆管理 DO
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@TableName("oa_clgl")
|
||||
@KeySequence("oa_clgl_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ClglDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 对应的流程编号
|
||||
*
|
||||
* 关联 ProcessInstance 的 id 属性
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 申请人的用户编号
|
||||
*
|
||||
* 关联 AdminUserDO 的 id 属性
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 审批结果
|
||||
*
|
||||
* 枚举 {@link BpmTaskStatusEnum}
|
||||
* 考虑到简单,所以直接复用了 BpmProcessInstanceStatusEnum 枚举,也可以自己定义一个枚举哈
|
||||
*/
|
||||
private Integer flowStatus;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 申请人
|
||||
*/
|
||||
private Integer carUser;
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
private Integer dept;
|
||||
/**
|
||||
* 用车类型
|
||||
*
|
||||
* 枚举 {@link TODO clgl_car_type 对应的类}
|
||||
*/
|
||||
private Integer carType;
|
||||
/**
|
||||
* 驾驶员
|
||||
*/
|
||||
private Integer carDriver;
|
||||
/**
|
||||
* 用车开始时间
|
||||
*/
|
||||
private LocalDateTime carStart;
|
||||
/**
|
||||
* 用车结束时间
|
||||
*/
|
||||
private LocalDateTime carEnd;
|
||||
/**
|
||||
* 目的地
|
||||
*/
|
||||
private String carAddress;
|
||||
/**
|
||||
* 车辆信息
|
||||
*/
|
||||
private String carInfo;
|
||||
/**
|
||||
* 车辆开始里程
|
||||
*/
|
||||
private String carStartMileage;
|
||||
/**
|
||||
* 车辆结束里程
|
||||
*/
|
||||
private String carEndMileage;
|
||||
/**
|
||||
* 用车状态
|
||||
*
|
||||
* 枚举 {@link TODO clgl_car_status 对应的类}
|
||||
*/
|
||||
private Integer carStatus;
|
||||
/**
|
||||
* 用车原因
|
||||
*/
|
||||
private String carReason;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String carRemark;
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.home.dal.mysql.clgl;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.clgl.ClglDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.clgl.vo.*;
|
||||
|
||||
/**
|
||||
* 车辆管理 Mapper
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Mapper
|
||||
public interface ClglMapper extends BaseMapperX<ClglDO> {
|
||||
|
||||
default PageResult<ClglDO> selectPage(Long userId,ClglPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ClglDO>()
|
||||
.eqIfPresent(ClglDO::getId, reqVO.getId())
|
||||
.eqIfPresent(ClglDO::getCarUser, reqVO.getCarUser())
|
||||
.eqIfPresent(ClglDO::getDept, reqVO.getDept())
|
||||
.eqIfPresent(ClglDO::getCarType, reqVO.getCarType())
|
||||
.eqIfPresent(ClglDO::getCarDriver, reqVO.getCarDriver())
|
||||
.eqIfPresent(ClglDO::getCarStart, reqVO.getCarStart())
|
||||
.eqIfPresent(ClglDO::getCarEnd, reqVO.getCarEnd())
|
||||
.eqIfPresent(ClglDO::getCarAddress, reqVO.getCarAddress())
|
||||
.eqIfPresent(ClglDO::getCarStartMileage, reqVO.getCarStartMileage())
|
||||
.eqIfPresent(ClglDO::getCarEndMileage, reqVO.getCarEndMileage())
|
||||
.eqIfPresent(ClglDO::getCarStatus, reqVO.getCarStatus())
|
||||
.eqIfPresent(ClglDO::getUserId, userId)
|
||||
.eqIfPresent(ClglDO::getFlowStatus, reqVO.getFlowStatus())
|
||||
.betweenIfPresent(ClglDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ClglDO::getId));
|
||||
}
|
||||
default PageResult<ClglDO> selectPage(ClglPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ClglDO>()
|
||||
.eqIfPresent(ClglDO::getId, reqVO.getId())
|
||||
.eqIfPresent(ClglDO::getCarUser, reqVO.getCarUser())
|
||||
.eqIfPresent(ClglDO::getDept, reqVO.getDept())
|
||||
.eqIfPresent(ClglDO::getCarType, reqVO.getCarType())
|
||||
.eqIfPresent(ClglDO::getCarDriver, reqVO.getCarDriver())
|
||||
.eqIfPresent(ClglDO::getCarStart, reqVO.getCarStart())
|
||||
.eqIfPresent(ClglDO::getCarEnd, reqVO.getCarEnd())
|
||||
.eqIfPresent(ClglDO::getCarAddress, reqVO.getCarAddress())
|
||||
.eqIfPresent(ClglDO::getCarStartMileage, reqVO.getCarStartMileage())
|
||||
.eqIfPresent(ClglDO::getCarEndMileage, reqVO.getCarEndMileage())
|
||||
.eqIfPresent(ClglDO::getCarStatus, reqVO.getCarStatus())
|
||||
.eqIfPresent(ClglDO::getFlowStatus, reqVO.getFlowStatus())
|
||||
.betweenIfPresent(ClglDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ClglDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.home.service.clgl;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.clgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.clgl.ClglDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 车辆管理 Service 接口
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
public interface ClglService {
|
||||
|
||||
/**
|
||||
* 创建车辆管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createClgl(Long userId, @Valid ClglSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新车辆管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateClgl(@Valid ClglSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除车辆管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteClgl(Long id);
|
||||
|
||||
/**
|
||||
* 获得车辆管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 车辆管理
|
||||
*/
|
||||
ClglDO getClgl(Long id);
|
||||
|
||||
/**
|
||||
* 获得车辆管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 车辆管理分页
|
||||
*/
|
||||
PageResult<ClglDO> getClglPage(ClglPageReqVO pageReqVO);
|
||||
PageResult<ClglDO> getClglPage(Long userid, ClglPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 更新请假申请的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param status 结果
|
||||
*/
|
||||
void updateClglStatus(Long id, Integer status);
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package cn.iocoder.yudao.module.home.service.clgl;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
||||
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.clgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.clgl.ClglDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.home.dal.mysql.clgl.ClglMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.KNOWLEDGE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 车辆管理 Service 实现类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ClglServiceImpl implements ClglService {
|
||||
public static final String PROCESS_KEY = "test-001";
|
||||
|
||||
@Resource
|
||||
private ClglMapper clglMapper;
|
||||
@Resource
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
|
||||
@Override
|
||||
public Long createClgl(Long userId,ClglSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ClglDO clgl = BeanUtils.toBean(createReqVO, ClglDO.class)
|
||||
.setUserId(userId).setFlowStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
clglMapper.insert(clgl);
|
||||
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
String processInstanceId = processInstanceApi.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(clgl.getId()))
|
||||
.setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees()));
|
||||
// 将工作流的编号,更新到 OA 请假单中
|
||||
clglMapper.updateById(new ClglDO().setId(clgl.getId()).setProcessInstanceId(processInstanceId));
|
||||
// 返回
|
||||
return clgl.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClgl(ClglSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateClglExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ClglDO updateObj = BeanUtils.toBean(updateReqVO, ClglDO.class);
|
||||
clglMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteClgl(Long id) {
|
||||
// 校验存在
|
||||
validateClglExists(id);
|
||||
// 删除
|
||||
clglMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateClglExists(Long id) {
|
||||
if (clglMapper.selectById(id) == null) {
|
||||
throw exception(CLGL_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClglDO getClgl(Long id) {
|
||||
return clglMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ClglDO> getClglPage(ClglPageReqVO pageReqVO) {
|
||||
return clglMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ClglDO> getClglPage(Long userId, ClglPageReqVO pageReqVO) {
|
||||
return clglMapper.selectPage(userId, pageReqVO);
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (clglMapper.selectById(id) == null) {
|
||||
throw exception(KNOWLEDGE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateClglStatus(Long id, Integer status) {
|
||||
validateLeaveExists(id);
|
||||
clglMapper.updateById(new ClglDO().setId(id).setFlowStatus(status));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.home.service.clgl.listener;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent;
|
||||
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener;
|
||||
import cn.iocoder.yudao.module.home.service.clgl.ClglService;
|
||||
import cn.iocoder.yudao.module.home.service.clgl.ClglServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 车辆管理流程的结果的监听器实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmClglStatusListener extends BpmProcessInstanceStatusEventListener {
|
||||
|
||||
@Resource
|
||||
private ClglService clglService;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
return ClglServiceImpl.PROCESS_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||
clglService.updateClglStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?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="cn.iocoder.yudao.module.home.dal.mysql.clgl.ClglMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,175 @@
|
||||
package cn.iocoder.yudao.module.home.service.clgl;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.home.controller.admin.clgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.clgl.ClglDO;
|
||||
import cn.iocoder.yudao.module.home.dal.mysql.clgl.ClglMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link ClglServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Import(ClglServiceImpl.class)
|
||||
public class ClglServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ClglServiceImpl clglService;
|
||||
|
||||
@Resource
|
||||
private ClglMapper clglMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateClgl_success() {
|
||||
// 准备参数
|
||||
ClglSaveReqVO createReqVO = randomPojo(ClglSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long clglId = clglService.createClgl(getLoginUserId(), createReqVO);
|
||||
// 断言
|
||||
assertNotNull(clglId);
|
||||
// 校验记录的属性是否正确
|
||||
ClglDO clgl = clglMapper.selectById(clglId);
|
||||
assertPojoEquals(createReqVO, clgl, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateClgl_success() {
|
||||
// mock 数据
|
||||
ClglDO dbClgl = randomPojo(ClglDO.class);
|
||||
clglMapper.insert(dbClgl);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ClglSaveReqVO updateReqVO = randomPojo(ClglSaveReqVO.class, o -> {
|
||||
o.setId(dbClgl.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
clglService.updateClgl(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
ClglDO clgl = clglMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, clgl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateClgl_notExists() {
|
||||
// 准备参数
|
||||
ClglSaveReqVO updateReqVO = randomPojo(ClglSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> clglService.updateClgl(updateReqVO), CLGL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteClgl_success() {
|
||||
// mock 数据
|
||||
ClglDO dbClgl = randomPojo(ClglDO.class);
|
||||
clglMapper.insert(dbClgl);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbClgl.getId();
|
||||
|
||||
// 调用
|
||||
clglService.deleteClgl(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(clglMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteClgl_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> clglService.deleteClgl(id), CLGL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetClglPage() {
|
||||
// mock 数据
|
||||
ClglDO dbClgl = randomPojo(ClglDO.class, o -> { // 等会查询到
|
||||
o.setId(null);
|
||||
o.setCarUser(null);
|
||||
o.setDept(null);
|
||||
o.setCarType(null);
|
||||
o.setCarDriver(null);
|
||||
o.setCarStart(null);
|
||||
o.setCarEnd(null);
|
||||
o.setCarAddress(null);
|
||||
o.setCarStartMileage(null);
|
||||
o.setCarEndMileage(null);
|
||||
o.setCarStatus(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
clglMapper.insert(dbClgl);
|
||||
// 测试 id 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setId(null)));
|
||||
// 测试 carUser 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarUser(null)));
|
||||
// 测试 dept 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setDept(null)));
|
||||
// 测试 carType 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarType(null)));
|
||||
// 测试 carDriver 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarDriver(null)));
|
||||
// 测试 carStart 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarStart(null)));
|
||||
// 测试 carEnd 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarEnd(null)));
|
||||
// 测试 carAddress 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarAddress(null)));
|
||||
// 测试 carStartMileage 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarStartMileage(null)));
|
||||
// 测试 carEndMileage 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarEndMileage(null)));
|
||||
// 测试 carStatus 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCarStatus(null)));
|
||||
// 测试 createTime 不匹配
|
||||
clglMapper.insert(cloneIgnoreId(dbClgl, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ClglPageReqVO reqVO = new ClglPageReqVO();
|
||||
reqVO.setId(null);
|
||||
reqVO.setCarUser(null);
|
||||
reqVO.setDept(null);
|
||||
reqVO.setCarType(null);
|
||||
reqVO.setCarDriver(null);
|
||||
reqVO.setCarStart(null);
|
||||
reqVO.setCarEnd(null);
|
||||
reqVO.setCarAddress(null);
|
||||
reqVO.setCarStartMileage(null);
|
||||
reqVO.setCarEndMileage(null);
|
||||
reqVO.setCarStatus(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<ClglDO> pageResult = clglService.getClglPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbClgl, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
DELETE FROM "des_datainfo";
|
||||
DELETE FROM "des_homePJ";
|
||||
DELETE FROM "des_homeimg";
|
||||
|
||||
DELETE FROM "oa_clgl";
|
||||
|
@ -62,3 +62,26 @@ CREATE TABLE IF NOT EXISTS "des_homeimg" (
|
||||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("img_id")
|
||||
) COMMENT '公告管理';
|
||||
CREATE TABLE IF NOT EXISTS "oa_clgl" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"car_user" int NOT NULL,
|
||||
"dept" int NOT NULL,
|
||||
"car_type" int NOT NULL,
|
||||
"car_driver" int NOT NULL,
|
||||
"car_start" varchar NOT NULL,
|
||||
"car_end" varchar NOT NULL,
|
||||
"car_address" varchar NOT NULL,
|
||||
"car_info" varchar,
|
||||
"car_start_mileage" varchar,
|
||||
"car_end_mileage" varchar,
|
||||
"car_status" int NOT NULL,
|
||||
"car_reason" varchar NOT NULL,
|
||||
"car_remark" varchar,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '车辆管理表';
|
||||
|
Loading…
Reference in New Issue
Block a user