调整 基础数据、运力、车船务

This commit is contained in:
2026-09-14 01:49:02 +08:00
parent 2262c39f60
commit 940f0b9b9f
34 changed files with 2682 additions and 26 deletions
@@ -0,0 +1,65 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.pojo.entity;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.io.Serial;
/**
* 计量单位实体类
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("blade_measurement_unit")
@Schema(description = "计量单位")
public class MeasurementUnit extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 计量单位
*/
@Schema(description = "计量单位")
private String unitName;
/**
* 计量维度
*/
@Schema(description = "计量维度")
private String dimension;
/**
* 备注
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
@Schema(description = "备注")
private String remark;
}
@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.pojo.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.system.pojo.entity.MeasurementUnit;
import java.io.Serial;
/**
* 计量单位视图实体类
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "计量单位")
public class MeasurementUnitVO extends MeasurementUnit {
@Serial
private static final long serialVersionUID = 1L;
@TableField(exist = false)
@Schema(description = "创建人姓名")
private String createUserName;
@TableField(exist = false)
@Schema(description = "更新人姓名")
private String updateUserName;
}
@@ -0,0 +1,68 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author
* is not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.transport.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serial;
/**
* 车辆调度申请实体类。
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("blade_transport_vehicle_dispatch")
@Schema(description = "车辆调度申请")
public class VehicleDispatch extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "申请单号")
private String applicationNo;
@Schema(description = "车牌号")
private String plateNo;
@Schema(description = "所属组织")
private String organizationName;
@Schema(description = "使用部门")
private String useDepartment;
@Schema(description = "审批状态:draft/reviewing/rejected/approved")
private String approvalStatus;
@Schema(description = "当前节点")
private String currentNode;
@Schema(description = "当前处理人")
private String currentProcessor;
@Schema(description = "备注")
private String remark;
@Schema(description = "附件JSON")
private String attachments;
}
@@ -0,0 +1,58 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author
* is not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.transport.pojo.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.transport.pojo.entity.VehicleDispatch;
import java.io.Serial;
/**
* 车辆调度申请视图对象。
*
* @author Chill
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "车辆调度申请")
public class VehicleDispatchVO extends VehicleDispatch {
@Serial
private static final long serialVersionUID = 1L;
@TableField(exist = false)
@Schema(description = "审批状态名称")
private String approvalStatusName;
@TableField(exist = false)
@Schema(description = "创建人姓名")
private String createUserName;
@TableField(exist = false)
@Schema(description = "更新人姓名")
private String updateUserName;
}
@@ -0,0 +1,137 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.pojo.entity.MeasurementUnit;
import org.springblade.system.pojo.vo.MeasurementUnitVO;
import org.springblade.system.service.IMeasurementUnitService;
import org.springblade.system.wrapper.MeasurementUnitWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 计量单位控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@PreAuth(menu = "measurement_unit")
@RequestMapping("/measurement-unit")
@Tag(name = "计量单位", description = "计量单位")
public class MeasurementUnitController extends BladeController {
private final IMeasurementUnitService measurementUnitService;
/**
* 详情
*
* @param measurementUnit 查询条件
* @return 计量单位详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入measurementUnit")
public R<MeasurementUnitVO> detail(MeasurementUnit measurementUnit) {
MeasurementUnit detail = measurementUnitService.getOne(Condition.getQueryWrapper(measurementUnit));
if (detail == null) {
return R.fail("数据不存在");
}
return R.data(MeasurementUnitWrapper.build().entityVO(detail));
}
/**
* 分页
*
* @param measurementUnit 查询条件
* @param query 分页参数
* @return 计量单位分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入measurementUnit")
public R<IPage<MeasurementUnitVO>> list(MeasurementUnitVO measurementUnit, Query query) {
IPage<MeasurementUnitVO> pages = measurementUnitService.selectMeasurementUnitPage(
Condition.getPage(query), measurementUnit
);
return R.data(pages);
}
/**
* 新增或修改
*
* @param measurementUnit 计量单位
* @return 操作结果
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入measurementUnit")
public R submit(@Valid @RequestBody MeasurementUnit measurementUnit) {
return R.status(measurementUnitService.submit(measurementUnit));
}
/**
* 删除
*
* @param ids 主键集合
* @return 操作结果
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(measurementUnitService.deleteLogic(Func.toLongList(ids)));
}
/**
* 启用或停用
*
* @param id 主键
* @param status 状态
* @return 操作结果
*/
@PostMapping("/status")
@ApiOperationSupport(order = 5)
@Operation(summary = "启用或停用", description = "传入id和status")
public R status(@Parameter(description = "主键", required = true) @RequestParam Long id,
@Parameter(description = "状态", required = true) @RequestParam Integer status) {
return R.status(measurementUnitService.changeStatus(id, status));
}
}
@@ -0,0 +1,47 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.system.pojo.entity.MeasurementUnit;
import org.springblade.system.pojo.vo.MeasurementUnitVO;
import java.util.List;
/**
* 计量单位 Mapper 接口
*
* @author Chill
*/
public interface MeasurementUnitMapper extends BaseMapper<MeasurementUnit> {
/**
* 自定义分页
*
* @param page 分页参数
* @param measurementUnit 查询参数
* @return 计量单位分页
*/
List<MeasurementUnitVO> selectMeasurementUnitPage(IPage<MeasurementUnitVO> page,
@Param("measurementUnit") MeasurementUnitVO measurementUnit);
}
@@ -0,0 +1,55 @@
<?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.springblade.system.mapper.MeasurementUnitMapper">
<resultMap id="measurementUnitResultMap" type="org.springblade.system.pojo.vo.MeasurementUnitVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_user_name" property="createUserName"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_user_name" property="updateUserName"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="unit_name" property="unitName"/>
<result column="dimension" property="dimension"/>
<result column="remark" property="remark"/>
</resultMap>
<select id="selectMeasurementUnitPage" resultMap="measurementUnitResultMap">
SELECT
mmu.id,
mmu.create_user,
cu.real_name AS create_user_name,
mmu.create_dept,
mmu.create_time,
mmu.update_user,
uu.real_name AS update_user_name,
mmu.update_time,
mmu.status,
mmu.is_deleted,
mmu.unit_name,
mmu.dimension,
mmu.remark
FROM
blade_measurement_unit mmu
LEFT JOIN blade_user cu ON cu.id = mmu.create_user
LEFT JOIN blade_user uu ON uu.id = mmu.update_user
WHERE
mmu.is_deleted = 0
<if test="measurementUnit.unitName != null and measurementUnit.unitName != ''">
<bind name="unitNameLike" value="'%' + measurementUnit.unitName + '%'"/>
AND mmu.unit_name LIKE #{unitNameLike}
</if>
<if test="measurementUnit.dimension != null and measurementUnit.dimension != ''">
AND mmu.dimension = #{measurementUnit.dimension}
</if>
<if test="measurementUnit.status != null">
AND mmu.status = #{measurementUnit.status}
</if>
ORDER BY mmu.create_time DESC
</select>
</mapper>
@@ -0,0 +1,61 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.pojo.entity.MeasurementUnit;
import org.springblade.system.pojo.vo.MeasurementUnitVO;
/**
* 计量单位服务类
*
* @author Chill
*/
public interface IMeasurementUnitService extends BaseService<MeasurementUnit> {
/**
* 自定义分页
*
* @param page 分页参数
* @param measurementUnit 查询参数
* @return 计量单位分页
*/
IPage<MeasurementUnitVO> selectMeasurementUnitPage(IPage<MeasurementUnitVO> page,
MeasurementUnitVO measurementUnit);
/**
* 新增或修改计量单位
*
* @param measurementUnit 计量单位
* @return 是否成功
*/
boolean submit(MeasurementUnit measurementUnit);
/**
* 启用或停用计量单位
*
* @param id 主键
* @param status 状态
* @return 是否成功
*/
boolean changeStatus(Long id, Integer status);
}
@@ -0,0 +1,142 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.mapper.MeasurementUnitMapper;
import org.springblade.system.pojo.entity.MeasurementUnit;
import org.springblade.system.pojo.vo.MeasurementUnitVO;
import org.springblade.system.service.IMeasurementUnitService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
import java.util.Set;
/**
* 计量单位服务实现类
*
* @author Chill
*/
@Service
public class MeasurementUnitServiceImpl extends BaseServiceImpl<MeasurementUnitMapper, MeasurementUnit>
implements IMeasurementUnitService {
private static final int STATUS_ENABLED = 1;
private static final int STATUS_DISABLED = 2;
private static final int UNIT_NAME_MAX_LENGTH = 50;
private static final int DIMENSION_MAX_LENGTH = 20;
private static final int REMARK_MAX_LENGTH = 200;
private static final Set<String> DIMENSIONS = Set.of("重量", "体积", "数量");
@Override
public IPage<MeasurementUnitVO> selectMeasurementUnitPage(IPage<MeasurementUnitVO> page,
MeasurementUnitVO measurementUnit) {
return page.setRecords(baseMapper.selectMeasurementUnitPage(page, measurementUnit));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(MeasurementUnit measurementUnit) {
prepare(measurementUnit);
validate(measurementUnit);
return saveOrUpdate(measurementUnit);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean changeStatus(Long id, Integer status) {
if (Func.isEmpty(id)) {
throw new ServiceException("主键不能为空");
}
MeasurementUnit measurementUnit = getById(id);
if (Func.isEmpty(measurementUnit)) {
throw new ServiceException("计量单位不存在");
}
if (!Objects.equals(status, STATUS_ENABLED) && !Objects.equals(status, STATUS_DISABLED)) {
throw new ServiceException("启停状态不正确");
}
MeasurementUnit update = new MeasurementUnit();
update.setId(id);
update.setStatus(status);
return updateById(update);
}
private void prepare(MeasurementUnit measurementUnit) {
measurementUnit.setUnitName(trimToEmpty(measurementUnit.getUnitName()));
measurementUnit.setDimension(trimToEmpty(measurementUnit.getDimension()));
measurementUnit.setRemark(trimToNull(measurementUnit.getRemark()));
if (Func.isEmpty(measurementUnit.getStatus())) {
measurementUnit.setStatus(STATUS_ENABLED);
}
}
private void validate(MeasurementUnit measurementUnit) {
if (Func.isEmpty(measurementUnit.getUnitName())) {
throw new ServiceException("计量单位不能为空");
}
if (measurementUnit.getUnitName().length() > UNIT_NAME_MAX_LENGTH) {
throw new ServiceException("计量单位不能超过50字");
}
if (Func.isEmpty(measurementUnit.getDimension())) {
throw new ServiceException("计量维度不能为空");
}
if (measurementUnit.getDimension().length() > DIMENSION_MAX_LENGTH
|| !DIMENSIONS.contains(measurementUnit.getDimension())) {
throw new ServiceException("计量维度不正确");
}
if (Func.isNotEmpty(measurementUnit.getRemark())
&& measurementUnit.getRemark().length() > REMARK_MAX_LENGTH) {
throw new ServiceException("备注不能超过200个字");
}
if (!Objects.equals(measurementUnit.getStatus(), STATUS_ENABLED)
&& !Objects.equals(measurementUnit.getStatus(), STATUS_DISABLED)) {
throw new ServiceException("启停状态不正确");
}
validateUniqueUnitName(measurementUnit);
}
private void validateUniqueUnitName(MeasurementUnit measurementUnit) {
LambdaQueryWrapper<MeasurementUnit> queryWrapper = Wrappers.<MeasurementUnit>lambdaQuery()
.eq(MeasurementUnit::getUnitName, measurementUnit.getUnitName())
.eq(MeasurementUnit::getIsDeleted, 0);
if (Func.isNotEmpty(measurementUnit.getId())) {
queryWrapper.ne(MeasurementUnit::getId, measurementUnit.getId());
}
if (count(queryWrapper) > 0L) {
throw new ServiceException("该计量单位已存在");
}
}
private String trimToEmpty(String value) {
return value == null ? "" : value.trim();
}
private String trimToNull(String value) {
String trimValue = trimToEmpty(value);
return trimValue.isEmpty() ? null : trimValue;
}
}
@@ -0,0 +1,51 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.cache.UserCache;
import org.springblade.system.pojo.entity.MeasurementUnit;
import org.springblade.system.pojo.vo.MeasurementUnitVO;
import java.util.Objects;
/**
* 计量单位包装类
*
* @author Chill
*/
public class MeasurementUnitWrapper extends BaseEntityWrapper<MeasurementUnit, MeasurementUnitVO> {
public static MeasurementUnitWrapper build() {
return new MeasurementUnitWrapper();
}
@Override
public MeasurementUnitVO entityVO(MeasurementUnit measurementUnit) {
MeasurementUnitVO measurementUnitVO = Objects.requireNonNull(
BeanUtil.copyProperties(measurementUnit, MeasurementUnitVO.class)
);
measurementUnitVO.setCreateUserName(UserCache.getUserRealName(measurementUnit.getCreateUser()));
measurementUnitVO.setUpdateUserName(UserCache.getUserRealName(measurementUnit.getUpdateUser()));
return measurementUnitVO;
}
}
@@ -0,0 +1,105 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.transport.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.transport.excel.VehicleDispatchExcel;
import org.springblade.transport.pojo.entity.VehicleDispatch;
import org.springblade.transport.pojo.vo.VehicleDispatchVO;
import org.springblade.transport.service.IVehicleDispatchService;
import org.springblade.transport.wrapper.VehicleDispatchWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** 车辆调度申请控制器。 */
@RestController
@AllArgsConstructor
@PreAuth(menu = "vehicle_dispatch")
@RequestMapping("/vehicle-dispatch")
@Tag(name = "车辆调度", description = "车辆调度申请")
public class VehicleDispatchController extends BladeController {
private final IVehicleDispatchService vehicleDispatchService;
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情")
public R<VehicleDispatchVO> detail(@Parameter(description = "主键", required = true) @RequestParam Long id) {
VehicleDispatch entity = vehicleDispatchService.getById(id);
if (entity == null) return R.fail("记录不存在");
return R.data(VehicleDispatchWrapper.build().entityVO(entity));
}
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页")
public R<IPage<VehicleDispatchVO>> list(VehicleDispatchVO dispatch, Query query) {
return R.data(vehicleDispatchService.selectVehicleDispatchPage(Condition.getPage(query), dispatch));
}
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改")
public R submit(@RequestBody VehicleDispatch dispatch) {
return R.status(vehicleDispatchService.submit(dispatch));
}
@PostMapping("/submit-approval")
@ApiOperationSupport(order = 4)
@Operation(summary = "提交审批")
public R submitApproval(@RequestParam Long id) {
return R.status(vehicleDispatchService.submitApproval(id));
}
@PostMapping("/approve")
@ApiOperationSupport(order = 5)
@Operation(summary = "审批通过")
public R approve(@RequestParam Long id) {
return R.status(vehicleDispatchService.approve(id));
}
@PostMapping("/remove")
@ApiOperationSupport(order = 6)
@Operation(summary = "逻辑删除")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(vehicleDispatchService.deleteLogic(Func.toLongList(ids)));
}
@GetMapping("/export-vehicle-dispatch")
@ApiOperationSupport(order = 7)
@Operation(summary = "导出车辆调度")
public void export(VehicleDispatchVO dispatch, HttpServletResponse response) {
List<VehicleDispatchExcel> list = vehicleDispatchService.exportList(dispatch).stream().map(VehicleDispatchExcel::from).toList();
ExcelUtil.export(response, "车辆调度" + DateUtil.time(), "车辆调度", list, VehicleDispatchExcel.class);
}
}
@@ -0,0 +1,52 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.transport.excel;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import org.springblade.transport.pojo.vo.VehicleDispatchVO;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/** 车辆调度导出模型。 */
@Data
@ColumnWidth(20)
public class VehicleDispatchExcel implements Serializable {
@Serial private static final long serialVersionUID = 1L;
@ExcelProperty("申请单号") private String applicationNo;
@ExcelProperty("车牌号") private String plateNo;
@ExcelProperty("所属组织") private String organizationName;
@ExcelProperty("使用部门") private String useDepartment;
@ExcelProperty("审批状态") private String approvalStatusName;
@ExcelProperty("当前节点") private String currentNode;
@ExcelProperty("当前处理人") private String currentProcessor;
@ExcelProperty("创建人") private String createUserName;
@ExcelProperty("创建时间") private Date createTime;
public static VehicleDispatchExcel from(VehicleDispatchVO source) {
VehicleDispatchExcel target = new VehicleDispatchExcel();
target.applicationNo = source.getApplicationNo();
target.plateNo = source.getPlateNo();
target.organizationName = source.getOrganizationName();
target.useDepartment = source.getUseDepartment();
target.approvalStatusName = source.getApprovalStatusName();
target.currentNode = source.getCurrentNode();
target.currentProcessor = source.getCurrentProcessor();
target.createUserName = source.getCreateUserName();
target.createTime = source.getCreateTime();
return target;
}
}
@@ -77,10 +77,10 @@
<if test="accidentRecord.accidentAssessmentDateEnd != null"> <if test="accidentRecord.accidentAssessmentDateEnd != null">
AND accident_date &lt;= #{accidentRecord.accidentAssessmentDateEnd} AND accident_date &lt;= #{accidentRecord.accidentAssessmentDateEnd}
</if> </if>
<if test="accidentRecord.createTimeStart != null and accidentRecord.createTimeStart != ''"> <if test="accidentRecord.createTimeStart != null">
AND create_time &gt;= #{accidentRecord.createTimeStart} AND create_time &gt;= #{accidentRecord.createTimeStart}
</if> </if>
<if test="accidentRecord.createTimeEnd != null and accidentRecord.createTimeEnd != ''"> <if test="accidentRecord.createTimeEnd != null">
AND create_time &lt;= #{accidentRecord.createTimeEnd} AND create_time &lt;= #{accidentRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -69,10 +69,10 @@
<if test="annualInspectionRecord.inspectionAssessmentDateEnd != null"> <if test="annualInspectionRecord.inspectionAssessmentDateEnd != null">
AND inspection_assessment_date &lt;= #{annualInspectionRecord.inspectionAssessmentDateEnd} AND inspection_assessment_date &lt;= #{annualInspectionRecord.inspectionAssessmentDateEnd}
</if> </if>
<if test="annualInspectionRecord.createTimeStart != null and annualInspectionRecord.createTimeStart != ''"> <if test="annualInspectionRecord.createTimeStart != null">
AND create_time &gt;= #{annualInspectionRecord.createTimeStart} AND create_time &gt;= #{annualInspectionRecord.createTimeStart}
</if> </if>
<if test="annualInspectionRecord.createTimeEnd != null and annualInspectionRecord.createTimeEnd != ''"> <if test="annualInspectionRecord.createTimeEnd != null">
AND create_time &lt;= #{annualInspectionRecord.createTimeEnd} AND create_time &lt;= #{annualInspectionRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -45,10 +45,10 @@
<if test="quantification.status != null"> <if test="quantification.status != null">
AND csq.status = #{quantification.status} AND csq.status = #{quantification.status}
</if> </if>
<if test="quantification.createTimeStart != null and quantification.createTimeStart != ''"> <if test="quantification.createTimeStart != null">
AND csq.create_time &gt;= #{quantification.createTimeStart} AND csq.create_time &gt;= #{quantification.createTimeStart}
</if> </if>
<if test="quantification.createTimeEnd != null and quantification.createTimeEnd != ''"> <if test="quantification.createTimeEnd != null">
AND csq.create_time &lt;= #{quantification.createTimeEnd} AND csq.create_time &lt;= #{quantification.createTimeEnd}
</if> </if>
ORDER BY csq.create_time DESC ORDER BY csq.create_time DESC
@@ -135,10 +135,10 @@
<bind name="deptNameLike" value="'%' + customer.deptName + '%'"/> <bind name="deptNameLike" value="'%' + customer.deptName + '%'"/>
AND dept_name LIKE #{deptNameLike} AND dept_name LIKE #{deptNameLike}
</if> </if>
<if test="customer.createTimeStart != null and customer.createTimeStart != ''"> <if test="customer.createTimeStart != null">
AND create_time &gt;= #{customer.createTimeStart} AND create_time &gt;= #{customer.createTimeStart}
</if> </if>
<if test="customer.createTimeEnd != null and customer.createTimeEnd != ''"> <if test="customer.createTimeEnd != null">
AND create_time &lt;= #{customer.createTimeEnd} AND create_time &lt;= #{customer.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -68,10 +68,10 @@
<if test="insuranceRecord.insuranceType != null and insuranceRecord.insuranceType != ''"> <if test="insuranceRecord.insuranceType != null and insuranceRecord.insuranceType != ''">
AND insurance_type = #{insuranceRecord.insuranceType} AND insurance_type = #{insuranceRecord.insuranceType}
</if> </if>
<if test="insuranceRecord.createTimeStart != null and insuranceRecord.createTimeStart != ''"> <if test="insuranceRecord.createTimeStart != null">
AND create_time &gt;= #{insuranceRecord.createTimeStart} AND create_time &gt;= #{insuranceRecord.createTimeStart}
</if> </if>
<if test="insuranceRecord.createTimeEnd != null and insuranceRecord.createTimeEnd != ''"> <if test="insuranceRecord.createTimeEnd != null">
AND create_time &lt;= #{insuranceRecord.createTimeEnd} AND create_time &lt;= #{insuranceRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -69,10 +69,10 @@
<bind name="vehicleNoLike" value="'%' + maintenancePlan.vehicleNo + '%'"/> <bind name="vehicleNoLike" value="'%' + maintenancePlan.vehicleNo + '%'"/>
AND vehicle_no LIKE #{vehicleNoLike} AND vehicle_no LIKE #{vehicleNoLike}
</if> </if>
<if test="maintenancePlan.createTimeStart != null and maintenancePlan.createTimeStart != ''"> <if test="maintenancePlan.createTimeStart != null">
AND create_time &gt;= #{maintenancePlan.createTimeStart} AND create_time &gt;= #{maintenancePlan.createTimeStart}
</if> </if>
<if test="maintenancePlan.createTimeEnd != null and maintenancePlan.createTimeEnd != ''"> <if test="maintenancePlan.createTimeEnd != null">
AND create_time &lt;= #{maintenancePlan.createTimeEnd} AND create_time &lt;= #{maintenancePlan.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -69,10 +69,10 @@
<bind name="vehicleNoLike" value="'%' + maintenanceRecord.vehicleNo + '%'"/> <bind name="vehicleNoLike" value="'%' + maintenanceRecord.vehicleNo + '%'"/>
AND vehicle_no LIKE #{vehicleNoLike} AND vehicle_no LIKE #{vehicleNoLike}
</if> </if>
<if test="maintenanceRecord.createTimeStart != null and maintenanceRecord.createTimeStart != ''"> <if test="maintenanceRecord.createTimeStart != null">
AND create_time &gt;= #{maintenanceRecord.createTimeStart} AND create_time &gt;= #{maintenanceRecord.createTimeStart}
</if> </if>
<if test="maintenanceRecord.createTimeEnd != null and maintenanceRecord.createTimeEnd != ''"> <if test="maintenanceRecord.createTimeEnd != null">
AND create_time &lt;= #{maintenanceRecord.createTimeEnd} AND create_time &lt;= #{maintenanceRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -63,10 +63,10 @@
<if test="mileageRecord.totalMileageEnd != null"> <if test="mileageRecord.totalMileageEnd != null">
AND total_mileage &lt;= #{mileageRecord.totalMileageEnd} AND total_mileage &lt;= #{mileageRecord.totalMileageEnd}
</if> </if>
<if test="mileageRecord.createTimeStart != null and mileageRecord.createTimeStart != ''"> <if test="mileageRecord.createTimeStart != null">
AND create_time &gt;= #{mileageRecord.createTimeStart} AND create_time &gt;= #{mileageRecord.createTimeStart}
</if> </if>
<if test="mileageRecord.createTimeEnd != null and mileageRecord.createTimeEnd != ''"> <if test="mileageRecord.createTimeEnd != null">
AND create_time &lt;= #{mileageRecord.createTimeEnd} AND create_time &lt;= #{mileageRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -84,10 +84,10 @@
<if test="oilElectricRecord.transactionAmountEnd != null"> <if test="oilElectricRecord.transactionAmountEnd != null">
AND transaction_amount &lt;= #{oilElectricRecord.transactionAmountEnd} AND transaction_amount &lt;= #{oilElectricRecord.transactionAmountEnd}
</if> </if>
<if test="oilElectricRecord.createTimeStart != null and oilElectricRecord.createTimeStart != ''"> <if test="oilElectricRecord.createTimeStart != null">
AND create_time &gt;= #{oilElectricRecord.createTimeStart} AND create_time &gt;= #{oilElectricRecord.createTimeStart}
</if> </if>
<if test="oilElectricRecord.createTimeEnd != null and oilElectricRecord.createTimeEnd != ''"> <if test="oilElectricRecord.createTimeEnd != null">
AND create_time &lt;= #{oilElectricRecord.createTimeEnd} AND create_time &lt;= #{oilElectricRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -64,10 +64,10 @@
<if test="otherExpenseRecord.expenseDateEnd != null"> <if test="otherExpenseRecord.expenseDateEnd != null">
AND expense_date &lt;= #{otherExpenseRecord.expenseDateEnd} AND expense_date &lt;= #{otherExpenseRecord.expenseDateEnd}
</if> </if>
<if test="otherExpenseRecord.createTimeStart != null and otherExpenseRecord.createTimeStart != ''"> <if test="otherExpenseRecord.createTimeStart != null">
AND create_time &gt;= #{otherExpenseRecord.createTimeStart} AND create_time &gt;= #{otherExpenseRecord.createTimeStart}
</if> </if>
<if test="otherExpenseRecord.createTimeEnd != null and otherExpenseRecord.createTimeEnd != ''"> <if test="otherExpenseRecord.createTimeEnd != null">
AND create_time &lt;= #{otherExpenseRecord.createTimeEnd} AND create_time &lt;= #{otherExpenseRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -54,10 +54,10 @@
<bind name="vehicleNoLike" value="'%' + tireReplacementRecord.vehicleNo + '%'"/> <bind name="vehicleNoLike" value="'%' + tireReplacementRecord.vehicleNo + '%'"/>
AND vehicle_no LIKE #{vehicleNoLike} AND vehicle_no LIKE #{vehicleNoLike}
</if> </if>
<if test="tireReplacementRecord.createTimeStart != null and tireReplacementRecord.createTimeStart != ''"> <if test="tireReplacementRecord.createTimeStart != null">
AND create_time &gt;= #{tireReplacementRecord.createTimeStart} AND create_time &gt;= #{tireReplacementRecord.createTimeStart}
</if> </if>
<if test="tireReplacementRecord.createTimeEnd != null and tireReplacementRecord.createTimeEnd != ''"> <if test="tireReplacementRecord.createTimeEnd != null">
AND create_time &lt;= #{tireReplacementRecord.createTimeEnd} AND create_time &lt;= #{tireReplacementRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -55,10 +55,10 @@
<bind name="changeContentLike" value="'%' + transportChangeRecord.changeContent + '%'"/> <bind name="changeContentLike" value="'%' + transportChangeRecord.changeContent + '%'"/>
AND change_content LIKE #{changeContentLike} AND change_content LIKE #{changeContentLike}
</if> </if>
<if test="transportChangeRecord.createTimeStart != null and transportChangeRecord.createTimeStart != ''"> <if test="transportChangeRecord.createTimeStart != null">
AND create_time &gt;= #{transportChangeRecord.createTimeStart} AND create_time &gt;= #{transportChangeRecord.createTimeStart}
</if> </if>
<if test="transportChangeRecord.createTimeEnd != null and transportChangeRecord.createTimeEnd != ''"> <if test="transportChangeRecord.createTimeEnd != null">
AND create_time &lt;= #{transportChangeRecord.createTimeEnd} AND create_time &lt;= #{transportChangeRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -0,0 +1,31 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments from this software for such purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.transport.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.transport.pojo.entity.VehicleDispatch;
import org.springblade.transport.pojo.vo.VehicleDispatchVO;
import java.util.List;
/** 车辆调度申请 Mapper。 */
public interface VehicleDispatchMapper extends BaseMapper<VehicleDispatch> {
List<VehicleDispatchVO> selectVehicleDispatchPage(IPage<VehicleDispatchVO> page, @Param("dispatch") VehicleDispatchVO dispatch);
}
@@ -0,0 +1,46 @@
<?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.springblade.transport.mapper.VehicleDispatchMapper">
<resultMap id="vehicleDispatchResultMap" type="org.springblade.transport.pojo.vo.VehicleDispatchVO">
<id column="id" property="id"/>
<result column="tenant_id" property="tenantId"/>
<result column="application_no" property="applicationNo"/>
<result column="plate_no" property="plateNo"/>
<result column="organization_name" property="organizationName"/>
<result column="use_department" property="useDepartment"/>
<result column="approval_status" property="approvalStatus"/>
<result column="current_node" property="currentNode"/>
<result column="current_processor" property="currentProcessor"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="remark" property="remark"/>
<result column="attachments" property="attachments"/>
</resultMap>
<select id="selectVehicleDispatchPage" resultMap="vehicleDispatchResultMap">
SELECT id, tenant_id, application_no, plate_no, organization_name, use_department,
approval_status, current_node, current_processor, remark, attachments, create_user,
create_time, update_user, update_time, status, is_deleted
FROM blade_transport_vehicle_dispatch
WHERE is_deleted = 0
<if test="dispatch.applicationNo != null and dispatch.applicationNo != ''">
AND application_no LIKE CONCAT('%', #{dispatch.applicationNo}, '%')
</if>
<if test="dispatch.plateNo != null and dispatch.plateNo != ''">
AND plate_no LIKE CONCAT('%', #{dispatch.plateNo}, '%')
</if>
<if test="dispatch.organizationName != null and dispatch.organizationName != ''">
AND organization_name LIKE CONCAT('%', #{dispatch.organizationName}, '%')
</if>
<if test="dispatch.useDepartment != null and dispatch.useDepartment != ''">
AND use_department LIKE CONCAT('%', #{dispatch.useDepartment}, '%')
</if>
<if test="dispatch.approvalStatus != null and dispatch.approvalStatus != ''">
AND approval_status = #{dispatch.approvalStatus}
</if>
ORDER BY create_time DESC
</select>
</mapper>
@@ -74,10 +74,10 @@
<if test="violationRecord.processStatus != null and violationRecord.processStatus != ''"> <if test="violationRecord.processStatus != null and violationRecord.processStatus != ''">
AND process_status = #{violationRecord.processStatus} AND process_status = #{violationRecord.processStatus}
</if> </if>
<if test="violationRecord.createTimeStart != null and violationRecord.createTimeStart != ''"> <if test="violationRecord.createTimeStart != null">
AND create_time &gt;= #{violationRecord.createTimeStart} AND create_time &gt;= #{violationRecord.createTimeStart}
</if> </if>
<if test="violationRecord.createTimeEnd != null and violationRecord.createTimeEnd != ''"> <if test="violationRecord.createTimeEnd != null">
AND create_time &lt;= #{violationRecord.createTimeEnd} AND create_time &lt;= #{violationRecord.createTimeEnd}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
@@ -0,0 +1,29 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.transport.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.transport.pojo.entity.VehicleDispatch;
import org.springblade.transport.pojo.vo.VehicleDispatchVO;
import java.util.List;
/** 车辆调度申请服务。 */
public interface IVehicleDispatchService extends BaseService<VehicleDispatch> {
IPage<VehicleDispatchVO> selectVehicleDispatchPage(IPage<VehicleDispatchVO> page, VehicleDispatchVO dispatch);
boolean submit(VehicleDispatch dispatch);
boolean submitApproval(Long id);
boolean approve(Long id);
List<VehicleDispatchVO> exportList(VehicleDispatchVO dispatch);
}
@@ -0,0 +1,127 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.transport.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.transport.mapper.TransportVehicleMapper;
import org.springblade.transport.mapper.VehicleDispatchMapper;
import org.springblade.transport.pojo.entity.TransportVehicle;
import org.springblade.transport.pojo.entity.VehicleDispatch;
import org.springblade.transport.pojo.vo.VehicleDispatchVO;
import org.springblade.transport.service.IVehicleDispatchService;
import org.springblade.transport.wrapper.VehicleDispatchWrapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
/** 车辆调度申请服务实现。 */
@Service
@RequiredArgsConstructor
public class VehicleDispatchServiceImpl extends BaseServiceImpl<VehicleDispatchMapper, VehicleDispatch> implements IVehicleDispatchService {
private static final DateTimeFormatter NO_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyyMMdd");
private final TransportVehicleMapper transportVehicleMapper;
@Override
public IPage<VehicleDispatchVO> selectVehicleDispatchPage(IPage<VehicleDispatchVO> page, VehicleDispatchVO dispatch) {
List<VehicleDispatchVO> records = baseMapper.selectVehicleDispatchPage(page, dispatch);
records.replaceAll(record -> VehicleDispatchWrapper.build().entityVO(record));
return page.setRecords(records);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(VehicleDispatch dispatch) {
if (dispatch == null || Func.isEmpty(dispatch.getPlateNo()) || Func.isEmpty(dispatch.getOrganizationName()) || Func.isEmpty(dispatch.getUseDepartment())) {
throw new ServiceException("车牌号、所属组织和使用部门不能为空");
}
if (dispatch.getRemark() != null && dispatch.getRemark().length() > 200) {
throw new ServiceException("备注不能超过200个字");
}
dispatch.setPlateNo(dispatch.getPlateNo().trim().toUpperCase());
dispatch.setOrganizationName(dispatch.getOrganizationName().trim());
dispatch.setUseDepartment(dispatch.getUseDepartment().trim());
if (Func.isEmpty(dispatch.getApprovalStatus())) dispatch.setApprovalStatus("draft");
if (Func.isEmpty(dispatch.getCurrentNode())) dispatch.setCurrentNode("草稿");
if (Func.isEmpty(dispatch.getApplicationNo())) {
dispatch.setApplicationNo("CD-" + LocalDate.now().format(NO_DATE_FORMAT) + "-" + (System.currentTimeMillis() % 1000000));
}
return saveOrUpdate(dispatch);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submitApproval(Long id) {
VehicleDispatch dispatch = getById(id);
if (dispatch == null || !"draft".equals(dispatch.getApprovalStatus()) && !"rejected".equals(dispatch.getApprovalStatus())) {
throw new ServiceException("仅草稿或已驳回申请可以提交审批");
}
VehicleDispatch update = new VehicleDispatch();
update.setId(id);
update.setApprovalStatus("reviewing");
update.setCurrentNode("车辆调度审批");
update.setCurrentProcessor(null);
return updateById(update);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean approve(Long id) {
VehicleDispatch dispatch = getById(id);
if (dispatch == null) {
throw new ServiceException("车辆调度申请不存在");
}
if (!"reviewing".equals(dispatch.getApprovalStatus())) {
throw new ServiceException("仅审批中的车辆调度申请可以审核通过");
}
TransportVehicle vehicle = transportVehicleMapper.selectOne(Wrappers.<TransportVehicle>lambdaQuery()
.eq(TransportVehicle::getIsDeleted, 0)
.eq(TransportVehicle::getPlateNo, dispatch.getPlateNo())
.last("LIMIT 1"));
if (vehicle == null) {
throw new ServiceException("调度车辆不存在,无法同步使用部门");
}
TransportVehicle vehicleUpdate = new TransportVehicle();
vehicleUpdate.setId(vehicle.getId());
vehicleUpdate.setUseDepartment(dispatch.getUseDepartment());
if (transportVehicleMapper.updateById(vehicleUpdate) <= 0) {
throw new ServiceException("车辆使用部门同步失败");
}
VehicleDispatch dispatchUpdate = new VehicleDispatch();
dispatchUpdate.setId(dispatch.getId());
dispatchUpdate.setApprovalStatus("approved");
dispatchUpdate.setCurrentNode("审批通过");
dispatchUpdate.setCurrentProcessor(AuthUtil.getUserName());
return updateById(dispatchUpdate);
}
@Override
public List<VehicleDispatchVO> exportList(VehicleDispatchVO dispatch) {
IPage<VehicleDispatchVO> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(1, 10000);
return selectVehicleDispatchPage(page, dispatch).getRecords();
}
}
@@ -0,0 +1,49 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.transport.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.transport.pojo.entity.VehicleDispatch;
import org.springblade.transport.pojo.vo.VehicleDispatchVO;
import java.util.Objects;
/** 车辆调度申请包装类。 */
public class VehicleDispatchWrapper extends BaseEntityWrapper<VehicleDispatch, VehicleDispatchVO> {
public static VehicleDispatchWrapper build() {
return new VehicleDispatchWrapper();
}
@Override
public VehicleDispatchVO entityVO(VehicleDispatch entity) {
if (entity == null) return null;
VehicleDispatchVO vo = Objects.requireNonNull(BeanUtil.copyProperties(entity, VehicleDispatchVO.class));
vo.setCreateUserName(org.springblade.system.cache.UserCache.getUserRealName(entity.getCreateUser()));
vo.setUpdateUserName(org.springblade.system.cache.UserCache.getUserRealName(entity.getUpdateUser()));
vo.setApprovalStatusName(statusName(entity.getApprovalStatus()));
return vo;
}
private String statusName(String status) {
if (status == null) return "未知";
return switch (status) {
case "draft" -> "草稿";
case "reviewing" -> "审批中";
case "rejected" -> "已驳回";
case "approved" -> "审批通过";
default -> "未知";
};
}
}
@@ -1750,4 +1750,36 @@ INSERT INTO `blade_menu` (`id`, `parent_id`, `code`, `name`, `alias`, `path`, `s
(1980000000000000077, 2075449200000000001, 'fee_item_template', '模板下载', 'template', '/api/blade-system/fee-item/export-template', 'download', 7, 2, 2, 1, '', NULL, 0), (1980000000000000077, 2075449200000000001, 'fee_item_template', '模板下载', 'template', '/api/blade-system/fee-item/export-template', 'download', 7, 2, 2, 1, '', NULL, 0),
(1980000000000000078, 2075449200000000001, 'fee_item_export', '批量导出', 'export', '/api/blade-system/fee-item/export-fee-item', 'download', 8, 2, 2, 1, '', NULL, 0); (1980000000000000078, 2075449200000000001, 'fee_item_export', '批量导出', 'export', '/api/blade-system/fee-item/export-fee-item', 'download', 8, 2, 2, 1, '', NULL, 0);
-- ----------------------------
-- Table structure for blade_measurement_unit
-- ----------------------------
DROP TABLE IF EXISTS `blade_measurement_unit`;
CREATE TABLE `blade_measurement_unit` (
`id` bigint NOT NULL COMMENT '主键',
`unit_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计量单位',
`dimension` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计量维度',
`remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_user` bigint NULL DEFAULT NULL COMMENT '修改人',
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
`status` int NULL DEFAULT 1 COMMENT '状态',
`is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `uk_measurement_unit_name`(`unit_name`) USING BTREE,
INDEX `idx_measurement_unit_dimension`(`dimension`) USING BTREE,
INDEX `idx_measurement_unit_status`(`status`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '计量单位';
-- ----------------------------
-- Records of blade_menu for measurement unit
-- ----------------------------
INSERT INTO `blade_menu` (`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `component`, `remark`, `is_deleted`) VALUES
(2075449300000000001, 1164733399668962201, 'measurement_unit', '计量单位', 'menu', '/base/measurement-unit', 'iconfont icon-shoucang', 8, 1, 0, 1, '', NULL, 0),
(2075449300000000002, 2075449300000000001, 'measurement_unit_add', '新增', 'add', '/base/measurement-unit/add', 'plus', 1, 2, 1, 1, '', NULL, 0),
(2075449300000000003, 2075449300000000001, 'measurement_unit_edit', '修改', 'edit', '/base/measurement-unit/edit', 'form', 2, 2, 2, 1, '', NULL, 0),
(2075449300000000004, 2075449300000000001, 'measurement_unit_delete', '删除', 'delete', '/api/blade-system/measurement-unit/remove', 'delete', 3, 2, 3, 1, '', NULL, 0),
(2075449300000000005, 2075449300000000001, 'measurement_unit_status', '启停', 'status', '/api/blade-system/measurement-unit/status', 'key', 4, 2, 2, 1, '', NULL, 0);
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;
@@ -0,0 +1,31 @@
-- ----------------------------
-- Table structure for blade_measurement_unit
-- ----------------------------
DROP TABLE IF EXISTS `blade_measurement_unit`;
CREATE TABLE `blade_measurement_unit` (
`id` bigint NOT NULL COMMENT '主键',
`unit_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计量单位',
`dimension` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计量维度',
`remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_user` bigint NULL DEFAULT NULL COMMENT '修改人',
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
`status` int NULL DEFAULT 1 COMMENT '状态',
`is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `uk_measurement_unit_name`(`unit_name`) USING BTREE,
INDEX `idx_measurement_unit_dimension`(`dimension`) USING BTREE,
INDEX `idx_measurement_unit_status`(`status`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '计量单位';
-- ----------------------------
-- Records of blade_menu for measurement unit
-- ----------------------------
INSERT INTO `blade_menu` (`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `component`, `remark`, `is_deleted`) VALUES
(2075449300000000001, 1164733399668962201, 'measurement_unit', '计量单位', 'measurement_unit', '/base/measurement-unit', 'iconfont icon-shoucang', 80, 1, 0, 1, NULL, '', 0),
(2075449300000000002, 2075449300000000001, 'measurement_unit_delete', '删除', 'measurement_unit_delete', '', '', 1, 2, 0, 1, NULL, '', 0),
(2075449300000000003, 2075449300000000001, 'measurement_unit_edit', '编辑', 'measurement_unit_edit', '', '', 1, 2, 0, 1, NULL, '', 0),
(2075449300000000004, 2075449300000000001, 'measurement_unit_status', '修改状态', 'measurement_unit_status', '', '', 1, 2, 0, 1, NULL, '', 0),
(2075449300000000005, 2075449300000000001, 'measurement_unit_add', '新增', 'measurement_unit_add', '', '', 1, 2, 0, 1, NULL, '', 0);
@@ -0,0 +1,44 @@
-- ----------------------------
-- Table structure for blade_transport_vehicle_dispatch
-- ----------------------------
DROP TABLE IF EXISTS `blade_transport_vehicle_dispatch`;
CREATE TABLE `blade_transport_vehicle_dispatch` (
`id` bigint(20) NOT NULL COMMENT '主键',
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '000000' COMMENT '租户ID',
`application_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '申请单号',
`plate_no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '车牌号',
`organization_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属组织',
`use_department` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '使用部门',
`approval_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'draft' COMMENT '审批状态:draft草稿/reviewing审批中/rejected已驳回/approved审批通过',
`current_node` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '当前节点',
`current_processor` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '当前处理人',
`remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
`attachments` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件JSON',
`create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_user` bigint(20) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`status` int(2) DEFAULT 1 COMMENT '状态',
`is_deleted` int(2) DEFAULT 0 COMMENT '是否已删除',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_vehicle_dispatch_application_no` (`application_no`),
KEY `idx_vehicle_dispatch_plate_no` (`plate_no`),
KEY `idx_vehicle_dispatch_approval_status` (`approval_status`),
KEY `idx_vehicle_dispatch_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='车辆调度申请';
-- ----------------------------
-- Menu records for transport capacity
-- ----------------------------
INSERT INTO `blade_menu`
(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `component`, `remark`, `is_deleted`)
VALUES
(2079000000000000100, 2079000000000000001, 'vehicle_dispatch', '车辆调度', 'vehicle_dispatch', '/transportCapacity/vehicle-dispatch', 'iconfont icon-yunshu', 3, 1, 0, 1, '', '', 0),
(2079000000000000101, 2079000000000000100, 'vehicle_dispatch_add', '新增', 'vehicle_dispatch_add', '', '', 1, 2, 0, 1, NULL, '', 0),
(2079000000000000102, 2079000000000000100, 'vehicle_dispatch_edit', '编辑', 'vehicle_dispatch_edit', '', '', 2, 2, 0, 1, NULL, '', 0),
(2079000000000000103, 2079000000000000100, 'vehicle_dispatch_delete', '删除', 'vehicle_dispatch_delete', '', '', 3, 2, 0, 1, NULL, '', 0),
(2079000000000000104, 2079000000000000100, 'vehicle_dispatch_view', '查看', 'vehicle_dispatch_view', '', '', 4, 2, 0, 1, NULL, '', 0),
(2079000000000000105, 2079000000000000100, 'vehicle_dispatch_submit', '提交审批', 'vehicle_dispatch_submit', '', '', 5, 2, 0, 1, NULL, '', 0),
(2079000000000000106, 2079000000000000100, 'vehicle_dispatch_export', '导出', 'vehicle_dispatch_export', '', '', 6, 2, 0, 1, NULL, '', 0),
(2079000000000000107, 2079000000000000100, 'vehicle_dispatch_approve', '审核通过', 'vehicle_dispatch_approve', '', '', 7, 2, 0, 1, NULL, '', 0);
+1375
View File
File diff suppressed because it is too large Load Diff