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

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,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">
AND accident_date &lt;= #{accidentRecord.accidentAssessmentDateEnd}
</if>
<if test="accidentRecord.createTimeStart != null and accidentRecord.createTimeStart != ''">
<if test="accidentRecord.createTimeStart != null">
AND create_time &gt;= #{accidentRecord.createTimeStart}
</if>
<if test="accidentRecord.createTimeEnd != null and accidentRecord.createTimeEnd != ''">
<if test="accidentRecord.createTimeEnd != null">
AND create_time &lt;= #{accidentRecord.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -69,10 +69,10 @@
<if test="annualInspectionRecord.inspectionAssessmentDateEnd != null">
AND inspection_assessment_date &lt;= #{annualInspectionRecord.inspectionAssessmentDateEnd}
</if>
<if test="annualInspectionRecord.createTimeStart != null and annualInspectionRecord.createTimeStart != ''">
<if test="annualInspectionRecord.createTimeStart != null">
AND create_time &gt;= #{annualInspectionRecord.createTimeStart}
</if>
<if test="annualInspectionRecord.createTimeEnd != null and annualInspectionRecord.createTimeEnd != ''">
<if test="annualInspectionRecord.createTimeEnd != null">
AND create_time &lt;= #{annualInspectionRecord.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -45,10 +45,10 @@
<if test="quantification.status != null">
AND csq.status = #{quantification.status}
</if>
<if test="quantification.createTimeStart != null and quantification.createTimeStart != ''">
<if test="quantification.createTimeStart != null">
AND csq.create_time &gt;= #{quantification.createTimeStart}
</if>
<if test="quantification.createTimeEnd != null and quantification.createTimeEnd != ''">
<if test="quantification.createTimeEnd != null">
AND csq.create_time &lt;= #{quantification.createTimeEnd}
</if>
ORDER BY csq.create_time DESC
@@ -135,10 +135,10 @@
<bind name="deptNameLike" value="'%' + customer.deptName + '%'"/>
AND dept_name LIKE #{deptNameLike}
</if>
<if test="customer.createTimeStart != null and customer.createTimeStart != ''">
<if test="customer.createTimeStart != null">
AND create_time &gt;= #{customer.createTimeStart}
</if>
<if test="customer.createTimeEnd != null and customer.createTimeEnd != ''">
<if test="customer.createTimeEnd != null">
AND create_time &lt;= #{customer.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -68,10 +68,10 @@
<if test="insuranceRecord.insuranceType != null and insuranceRecord.insuranceType != ''">
AND insurance_type = #{insuranceRecord.insuranceType}
</if>
<if test="insuranceRecord.createTimeStart != null and insuranceRecord.createTimeStart != ''">
<if test="insuranceRecord.createTimeStart != null">
AND create_time &gt;= #{insuranceRecord.createTimeStart}
</if>
<if test="insuranceRecord.createTimeEnd != null and insuranceRecord.createTimeEnd != ''">
<if test="insuranceRecord.createTimeEnd != null">
AND create_time &lt;= #{insuranceRecord.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -69,10 +69,10 @@
<bind name="vehicleNoLike" value="'%' + maintenancePlan.vehicleNo + '%'"/>
AND vehicle_no LIKE #{vehicleNoLike}
</if>
<if test="maintenancePlan.createTimeStart != null and maintenancePlan.createTimeStart != ''">
<if test="maintenancePlan.createTimeStart != null">
AND create_time &gt;= #{maintenancePlan.createTimeStart}
</if>
<if test="maintenancePlan.createTimeEnd != null and maintenancePlan.createTimeEnd != ''">
<if test="maintenancePlan.createTimeEnd != null">
AND create_time &lt;= #{maintenancePlan.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -69,10 +69,10 @@
<bind name="vehicleNoLike" value="'%' + maintenanceRecord.vehicleNo + '%'"/>
AND vehicle_no LIKE #{vehicleNoLike}
</if>
<if test="maintenanceRecord.createTimeStart != null and maintenanceRecord.createTimeStart != ''">
<if test="maintenanceRecord.createTimeStart != null">
AND create_time &gt;= #{maintenanceRecord.createTimeStart}
</if>
<if test="maintenanceRecord.createTimeEnd != null and maintenanceRecord.createTimeEnd != ''">
<if test="maintenanceRecord.createTimeEnd != null">
AND create_time &lt;= #{maintenanceRecord.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -63,10 +63,10 @@
<if test="mileageRecord.totalMileageEnd != null">
AND total_mileage &lt;= #{mileageRecord.totalMileageEnd}
</if>
<if test="mileageRecord.createTimeStart != null and mileageRecord.createTimeStart != ''">
<if test="mileageRecord.createTimeStart != null">
AND create_time &gt;= #{mileageRecord.createTimeStart}
</if>
<if test="mileageRecord.createTimeEnd != null and mileageRecord.createTimeEnd != ''">
<if test="mileageRecord.createTimeEnd != null">
AND create_time &lt;= #{mileageRecord.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -84,10 +84,10 @@
<if test="oilElectricRecord.transactionAmountEnd != null">
AND transaction_amount &lt;= #{oilElectricRecord.transactionAmountEnd}
</if>
<if test="oilElectricRecord.createTimeStart != null and oilElectricRecord.createTimeStart != ''">
<if test="oilElectricRecord.createTimeStart != null">
AND create_time &gt;= #{oilElectricRecord.createTimeStart}
</if>
<if test="oilElectricRecord.createTimeEnd != null and oilElectricRecord.createTimeEnd != ''">
<if test="oilElectricRecord.createTimeEnd != null">
AND create_time &lt;= #{oilElectricRecord.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -64,10 +64,10 @@
<if test="otherExpenseRecord.expenseDateEnd != null">
AND expense_date &lt;= #{otherExpenseRecord.expenseDateEnd}
</if>
<if test="otherExpenseRecord.createTimeStart != null and otherExpenseRecord.createTimeStart != ''">
<if test="otherExpenseRecord.createTimeStart != null">
AND create_time &gt;= #{otherExpenseRecord.createTimeStart}
</if>
<if test="otherExpenseRecord.createTimeEnd != null and otherExpenseRecord.createTimeEnd != ''">
<if test="otherExpenseRecord.createTimeEnd != null">
AND create_time &lt;= #{otherExpenseRecord.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -54,10 +54,10 @@
<bind name="vehicleNoLike" value="'%' + tireReplacementRecord.vehicleNo + '%'"/>
AND vehicle_no LIKE #{vehicleNoLike}
</if>
<if test="tireReplacementRecord.createTimeStart != null and tireReplacementRecord.createTimeStart != ''">
<if test="tireReplacementRecord.createTimeStart != null">
AND create_time &gt;= #{tireReplacementRecord.createTimeStart}
</if>
<if test="tireReplacementRecord.createTimeEnd != null and tireReplacementRecord.createTimeEnd != ''">
<if test="tireReplacementRecord.createTimeEnd != null">
AND create_time &lt;= #{tireReplacementRecord.createTimeEnd}
</if>
ORDER BY create_time DESC
@@ -55,10 +55,10 @@
<bind name="changeContentLike" value="'%' + transportChangeRecord.changeContent + '%'"/>
AND change_content LIKE #{changeContentLike}
</if>
<if test="transportChangeRecord.createTimeStart != null and transportChangeRecord.createTimeStart != ''">
<if test="transportChangeRecord.createTimeStart != null">
AND create_time &gt;= #{transportChangeRecord.createTimeStart}
</if>
<if test="transportChangeRecord.createTimeEnd != null and transportChangeRecord.createTimeEnd != ''">
<if test="transportChangeRecord.createTimeEnd != null">
AND create_time &lt;= #{transportChangeRecord.createTimeEnd}
</if>
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 != ''">
AND process_status = #{violationRecord.processStatus}
</if>
<if test="violationRecord.createTimeStart != null and violationRecord.createTimeStart != ''">
<if test="violationRecord.createTimeStart != null">
AND create_time &gt;= #{violationRecord.createTimeStart}
</if>
<if test="violationRecord.createTimeEnd != null and violationRecord.createTimeEnd != ''">
<if test="violationRecord.createTimeEnd != null">
AND create_time &lt;= #{violationRecord.createTimeEnd}
</if>
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 -> "未知";
};
}
}