Ver Fonte

新增司机行为规则和派单系数

donglang há 1 mês atrás
pai
commit
34236fbdf4
20 ficheiros alterados com 1568 adições e 1 exclusões
  1. 1 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/ErrorCodeEnum.java
  2. 109 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfAutoDispatchController.java
  3. 16 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverConductRulesLogMapper.java
  4. 16 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverConductRulesMapper.java
  5. 16 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckDispatchCoefficientMapper.java
  6. 117 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/KwfDriverConductRules.java
  7. 69 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/KwfDriverConductRulesLog.java
  8. 129 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/KwfTruckDispatchCoefficient.java
  9. 45 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/request/DriverConductRulesLogRequest.java
  10. 35 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/request/DriverConductRulesRequest.java
  11. 76 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/request/DriverConductRulesUpdateRequest.java
  12. 95 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/request/TruckDispatchCoefficientUpdateRequest.java
  13. 81 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfDriverConductRulesLogVO.java
  14. 142 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfDriverConductRulesVO.java
  15. 157 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckDispatchCoefficientVO.java
  16. 16 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/repository/KwfDriverConductRulesLogRepository.java
  17. 16 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/repository/KwfDriverConductRulesRepository.java
  18. 16 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/repository/KwfTruckDispatchCoefficientRepository.java
  19. 380 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfAutoDispatchService.java
  20. 36 1
      sql/2025/12/01/2025_12_04_donglang.sql

+ 1 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/ErrorCodeEnum.java

@@ -18,6 +18,7 @@ public enum ErrorCodeEnum {
     PERMISSION_DENIED("100003", "权限不足"),
     NETWORK_ERROR("100004", "网络连接异常"),
     DB_OPERATE_FAIL("100005", "数据库操作异常"),
+    DATA_NOT_EXIST("100006", "数据查询结果不存在"),
 
     // ====================== 设备相关错误(20000~29999)======================
     DEVICE_OFFLINE("200000", "设备离线"),

+ 109 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfAutoDispatchController.java

@@ -0,0 +1,109 @@
+package com.sckw.fleet.controller;
+
+import com.sckw.core.web.response.BaseResult;
+import com.sckw.core.web.response.result.PageDataResult;
+import com.sckw.fleet.model.request.DriverConductRulesLogRequest;
+import com.sckw.fleet.model.request.DriverConductRulesRequest;
+import com.sckw.fleet.model.request.DriverConductRulesUpdateRequest;
+import com.sckw.fleet.model.request.TruckDispatchCoefficientUpdateRequest;
+import com.sckw.fleet.model.vo.KwfDriverConductRulesLogVO;
+import com.sckw.fleet.model.vo.KwfDriverConductRulesVO;
+import com.sckw.fleet.model.vo.KwfTruckDispatchCoefficientVO;
+import com.sckw.fleet.service.KwfAutoDispatchService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+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.RestController;
+
+/**
+ * @author zk
+ * @desc 司机
+ * @date 2023/7/6 0006
+ */
+@RestController
+@RequestMapping("/kwfDriver")
+@Tag(name = "司机行为规则", description = "提供司机行为规则相关操作接口")
+@RequiredArgsConstructor
+public class KwfAutoDispatchController {
+
+    private final KwfAutoDispatchService autoDispatchService;
+
+    /**
+     * 查询自动派车系数
+     *
+     * @param request
+     * @return
+     */
+    @Operation(summary = "查询自动派车系数", description = "查询自动派车系数")
+    @PostMapping("/queryAutoTruckDispatch")
+    public BaseResult<KwfTruckDispatchCoefficientVO> queryAutoTruckDispatch(@RequestBody @Valid DriverConductRulesRequest request){
+        KwfTruckDispatchCoefficientVO autoDispatchVO = autoDispatchService.queryAutoTruckDispatch(request);
+        return BaseResult.success(autoDispatchVO);
+    }
+
+
+    /**
+     * 修改自动派车系数
+     *
+     * @param request
+     * @return
+     */
+    @Operation(summary = "修改自动派车系数", description = "修改自动派车系数")
+    @PostMapping("/updateAutoDispatch")
+    public BaseResult updateAutoDispatch(@RequestBody @Valid TruckDispatchCoefficientUpdateRequest request){
+        autoDispatchService.updateAutoDispatch(request);
+        return BaseResult.success();
+    }
+
+
+
+    /**
+     * 查询司机行为规则
+     *
+     * @param request
+     * @return
+     */
+    @Operation(summary = "查询司机行为规则", description = "查询司机行为规则")
+    @PostMapping("/queryDriverConductRules")
+    public BaseResult<KwfDriverConductRulesVO> queryDriverConductRules(@RequestBody @Valid DriverConductRulesRequest request){
+        KwfDriverConductRulesVO driverConductRulesVO = autoDispatchService.queryDriverConductRules(request);
+        return BaseResult.success(driverConductRulesVO);
+    }
+
+    /**
+     * 修改司机行为规则
+     *
+     * @param request
+     * @return
+     */
+    @Operation(summary = "修改司机行为规则", description = "修改司机行为规则")
+    @PostMapping("/updateDriverConduct")
+    public BaseResult update(@RequestBody @Valid DriverConductRulesUpdateRequest request){
+        autoDispatchService.updateDriverConduct(request);
+        return BaseResult.success();
+    }
+
+    /**
+     * 分页查询司机行为规则日志
+     *
+     * @param request
+     * @return
+     */
+    @Operation(summary = "查询司机行为规则", description = "查询司机行为规则")
+    @PostMapping("/queryDriverRulesLogPage")
+    public BaseResult<PageDataResult<KwfDriverConductRulesLogVO>> queryDriverRulesLogPage(DriverConductRulesLogRequest request){
+        PageDataResult<KwfDriverConductRulesLogVO> driverConductRulesLogVOPage =
+                autoDispatchService.queryDriverRulesLogPage(request);
+        return BaseResult.success(driverConductRulesLogVOPage);
+    }
+
+
+
+
+
+
+}

+ 16 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverConductRulesLogMapper.java

@@ -0,0 +1,16 @@
+package com.sckw.fleet.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.fleet.model.KwfDriverConductRulesLog;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @desc 司机行为规则日志Mapper接口
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Mapper
+public interface KwfDriverConductRulesLogMapper extends BaseMapper<KwfDriverConductRulesLog> {
+
+
+}

+ 16 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverConductRulesMapper.java

@@ -0,0 +1,16 @@
+package com.sckw.fleet.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.fleet.model.KwfDriverConductRules;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @desc 司机行为规则Mapper接口
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Mapper
+public interface KwfDriverConductRulesMapper extends BaseMapper<KwfDriverConductRules> {
+
+
+}

+ 16 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckDispatchCoefficientMapper.java

@@ -0,0 +1,16 @@
+package com.sckw.fleet.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.fleet.model.KwfTruckDispatchCoefficient;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @desc 司机行为规则Mapper接口
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Mapper
+public interface KwfTruckDispatchCoefficientMapper extends BaseMapper<KwfTruckDispatchCoefficient> {
+
+
+}

+ 117 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/KwfDriverConductRules.java

@@ -0,0 +1,117 @@
+package com.sckw.fleet.model;
+
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 司机行为规则表
+ * 表名:kwf_driver_conduct_rules
+ *
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@TableName("kwf_driver_conduct_rules")
+public class KwfDriverConductRules implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 企业id
+     */
+    @TableField("net_id")
+    private Long entId;
+
+    /**
+     * 未按时到场(违规次数/扣分)
+     */
+    @TableField("not_on_time_arrive")
+    private Integer notOnTimeArrive;
+
+    /**
+     * 违规取消运单(违规次数/扣分)
+     */
+    @TableField("illegal_cancel_order")
+    private Integer illegalCancelOrder;
+
+    /**
+     * 卸货严重超时(违规次数/扣分)
+     */
+    @TableField("unload_serious_timeout")
+    private Integer unloadSeriousTimeout;
+
+    /**
+     * 虚假卸货(违规次数/扣分)
+     */
+    @TableField("fake_unload")
+    private Integer fakeUnload;
+
+    /**
+     * 单据错误/缺失(违规次数/扣分)
+     */
+    @TableField("document_error_missing")
+    private Integer documentErrorMissing;
+
+    /**
+     * 连续按时到场(达标次数/加分)
+     */
+    @TableField("continuous_on_time_arrive")
+    private Integer continuousOnTimeArrive;
+
+    /**
+     * 连续准时卸货(达标次数/加分)
+     */
+    @TableField("continuous_on_time_unload")
+    private Integer continuousOnTimeUnload;
+
+    /**
+     * 连续准确填写卸货信息(达标次数/加分)
+     */
+    @TableField("continuous_accurate_unload")
+    private Integer continuousAccurateUnload;
+
+    /**
+     * 是否删除(0未删除,1删除)
+     */
+    @TableField("del_flag")
+    private Integer delFlag;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time", fill = FieldFill.INSERT) // 插入时自动填充
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) // 插入/更新时自动填充
+    private Date updateTime;
+
+    /**
+     * 创建人(用户ID,默认-1)
+     */
+    @TableField(value = "create_user", fill = FieldFill.INSERT)
+    private Long createUser;
+
+    /**
+     * 更新人(用户ID,默认-1)
+     */
+    @TableField(value = "update_user", fill = FieldFill.INSERT_UPDATE)
+    private Long updateUser;
+
+}

+ 69 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/KwfDriverConductRulesLog.java

@@ -0,0 +1,69 @@
+package com.sckw.fleet.model;
+
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 司机行为规则日志表
+ * 表名:kwf_driver_conduct_rules_Log
+ *
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("kwf_driver_conduct_rules_log")
+public class KwfDriverConductRulesLog implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -4512558808118804362L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 业务id
+     */
+    @TableField("biz_id")
+    private Long bizId;
+
+    /**
+     * 状态(0-自动派单,1-司机行为规则)
+     */
+    @TableField("status")
+    private int status;
+
+    /**
+     * 日志内容
+     */
+    @TableField("description")
+    private String description;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time", fill = FieldFill.INSERT) // 插入时自动填充
+    private Date createTime;
+
+    /**
+     * 创建人(用户ID,默认-1)
+     */
+    @TableField(value = "create_user", fill = FieldFill.INSERT)
+    private Long createUser;
+
+    /**
+     * 更新人(用户ID,默认-1)
+     */
+    @TableField(value = "update_user", fill = FieldFill.INSERT_UPDATE)
+    private Long updateUser;
+
+}

+ 129 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/KwfTruckDispatchCoefficient.java

@@ -0,0 +1,129 @@
+package com.sckw.fleet.model;
+
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 自动派车系数表
+ * 表名:kwf_driver_conduct_rules
+ *
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("kwf_truck_dispatch_coefficient")
+public class KwfTruckDispatchCoefficient implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 3044887895472142092L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 企业id
+     */
+    @TableField("ent_id")
+    private Long entId;
+
+    /**
+     * 车辆工作时长
+     */
+    @TableField("vehicle_work_hours")
+    private BigDecimal vehicleWorkHours;
+
+    /**
+     * 车辆装货时长
+     */
+    @TableField("vehicle_loading_hours")
+    private BigDecimal vehicleLoadingHours;
+
+    /**
+     * 车辆卸货时长
+     */
+    @TableField("vehicle_unloading_hours")
+    private BigDecimal vehicleUnloadingHours;
+
+    /**
+     * 司机超时限制
+     */
+    @TableField("driver_timeout_limit")
+    private BigDecimal driverTimeoutLimit;
+
+    /**
+     * 车辆平均载重
+     */
+    @TableField("vehicle_avg_load")
+    private BigDecimal vehicleAvgLoad;
+
+    /**
+     * 车辆平均速度
+     */
+    @TableField("vehicle_avg_speed")
+    private BigDecimal vehicleAvgSpeed;
+
+    /**
+     * 车辆最大任务数
+     */
+    @TableField("vehicle_max_tasks")
+    private Integer vehicleMaxTasks;
+
+    /**
+     * 司机接单限制
+     */
+    @TableField("driver_order_limit")
+    private BigDecimal driverOrderLimit;
+
+    /**
+     * 场内车辆容量
+     */
+    @TableField("yard_vehicle_capacity")
+    private Integer yardVehicleCapacity;
+
+    /**
+     * 最大占比
+     */
+    @TableField("max_ratio")
+    private BigDecimal maxRatio;
+
+    /**
+     * 缓冲系数
+     */
+    @TableField("buffer_coefficient")
+    private BigDecimal bufferCoefficient;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time", fill = FieldFill.INSERT) // 插入时自动填充
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) // 插入/更新时自动填充
+    private Date updateTime;
+
+    /**
+     * 创建人(用户ID,默认-1)
+     */
+    @TableField(value = "create_user", fill = FieldFill.INSERT)
+    private Long createUser;
+
+    /**
+     * 更新人(用户ID,默认-1)
+     */
+    @TableField(value = "update_user", fill = FieldFill.INSERT_UPDATE)
+    private Long updateUser;
+}

+ 45 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/request/DriverConductRulesLogRequest.java

@@ -0,0 +1,45 @@
+package com.sckw.fleet.model.request;
+
+import com.sckw.core.web.request.PageReq;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author zk
+ * @desc 司机行为规则日志查询模型
+ * @date 2023/7/12 0012
+ */
+@Data
+public class DriverConductRulesLogRequest extends PageReq implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -205819475634182202L;
+
+    /**
+     * 业务id
+     */
+    @Schema(description = "业务id")
+    @NotNull(message = "业务id不能为空!")
+    private Long bizId;
+
+    /**
+     * 状态(0-自动派单,1-司机行为规则)
+     */
+    @Schema(description = "状态(0-自动派单,1-司机行为规则)")
+    @NotNull(message = "状态不能为空!")
+    private int status;
+
+    /**
+     * 内容
+     */
+    @Schema(description = "内容")
+    private String description;
+
+
+
+
+}

+ 35 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/request/DriverConductRulesRequest.java

@@ -0,0 +1,35 @@
+package com.sckw.fleet.model.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author zk
+ * @desc 司机行为规则
+ * @date 2023/7/12 0012
+ */
+@Data
+public class DriverConductRulesRequest implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -1143520801815863768L;
+
+    /**
+     * 企业id
+     */
+    @Schema(description = "企业id")
+    @NotNull(message = "企业id不能为空!")
+    private Long entId;
+
+    /**
+     * 是否初始化
+     */
+    @Schema(description = "是否初始化")
+    @NotNull(message = "是否初始化不能为空!")
+    private Boolean isInit = false;
+
+}

+ 76 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/request/DriverConductRulesUpdateRequest.java

@@ -0,0 +1,76 @@
+package com.sckw.fleet.model.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author zk
+ * @desc 司机行为规则
+ * @date 2023/7/12 0012
+ */
+@Data
+public class DriverConductRulesUpdateRequest implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -2169056896415427633L;
+
+    /**
+     * 主键
+     */
+    @Schema(description = "主键id")
+    private Long id;
+
+    /**
+     * 未按时到场(违规次数/扣分)
+     */
+    @Schema(description = "未按时到场")
+    private Integer notOnTimeArrive;
+
+    /**
+     * 违规取消运单(违规次数/扣分)
+     */
+    @Schema(description = "违规取消运单")
+    private Integer illegalCancelOrder;
+
+    /**
+     * 卸货严重超时(违规次数/扣分)
+     */
+    @Schema(description = "卸货严重超时")
+    private Integer unloadSeriousTimeout;
+
+    /**
+     * 虚假卸货(违规次数/扣分)
+     */
+    @Schema(description = "虚假卸货")
+    private Integer fakeUnload;
+
+    /**
+     * 单据错误/缺失(违规次数/扣分)
+     */
+    @Schema(description = "单据错误/缺失")
+    private Integer documentErrorMissing;
+
+    /**
+     * 连续按时到场(达标次数/加分)
+     */
+    @Schema(description = "连续按时到场")
+    private Integer continuousOnTimeArrive;
+
+    /**
+     * 连续准时卸货(达标次数/加分)
+     */
+    @Schema(description = "连续准时卸货")
+    private Integer continuousOnTimeUnload;
+
+    /**
+     * 连续准确填写卸货信息(达标次数/加分)
+     */
+    @Schema(description = "连续准确填写卸货信息")
+    private Integer continuousAccurateUnload;
+
+
+
+}

+ 95 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/request/TruckDispatchCoefficientUpdateRequest.java

@@ -0,0 +1,95 @@
+package com.sckw.fleet.model.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author zk
+ * @desc 司机行为规则
+ * @date 2023/7/12 0012
+ */
+@Data
+public class TruckDispatchCoefficientUpdateRequest implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -5148978183713446040L;
+
+    /**
+     * 主键
+     */
+    @Schema(description = "主键id")
+    private Long id;
+
+    /**
+     * 车辆工作时长
+     */
+    @Schema(description = "车辆工作时长")
+    private BigDecimal vehicleWorkHours;
+
+    /**
+     * 车辆装货时长
+     */
+    @Schema(description = "车辆装货时长")
+    private BigDecimal vehicleLoadingHours;
+
+    /**
+     * 车辆卸货时长
+     */
+    @Schema(description = "车辆卸货时长")
+    private BigDecimal vehicleUnloadingHours;
+
+    /**
+     * 司机超时限制
+     */
+    @Schema(description = "司机超时限制")
+    private BigDecimal driverTimeoutLimit;
+
+    /**
+     * 车辆平均载重
+     */
+    @Schema(description = "车辆平均载重")
+    private BigDecimal vehicleAvgLoad;
+
+    /**
+     * 车辆平均速度
+     */
+    @Schema(description = "车辆平均速度")
+    private BigDecimal vehicleAvgSpeed;
+
+    /**
+     * 车辆最大任务数
+     */
+    @Schema(description = "车辆最大任务数")
+    private Integer vehicleMaxTasks;
+
+    /**
+     * 司机接单限制
+     */
+    @Schema(description = "司机接单限制")
+    private BigDecimal driverOrderLimit;
+
+    /**
+     * 场内车辆容量
+     */
+    @Schema(description = "场内车辆容量")
+    private Integer yardVehicleCapacity;
+
+    /**
+     * 最大占比
+     */
+    @Schema(description = "最大占比")
+    private BigDecimal maxRatio;
+
+    /**
+     * 缓冲系数
+     */
+    @Schema(description = "缓冲系数")
+    private BigDecimal bufferCoefficient;
+
+
+
+}

+ 81 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfDriverConductRulesLogVO.java

@@ -0,0 +1,81 @@
+package com.sckw.fleet.model.vo;
+
+import com.sckw.fleet.model.KwfDriverConductRulesLog;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 司机行为规则返回模型
+ *
+ * @author Generated
+ * @since 2024
+ */
+@Data
+public class KwfDriverConductRulesLogVO implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -5360767484446805797L;
+
+    /**
+     * 主键
+     */
+    @Schema(description = "主键id")
+    private Long id;
+
+    /**
+     * 业务id
+     */
+    @Schema(description = "业务id")
+
+    private Long bizId;
+
+    /**
+     * 状态(0-自动派单,1-司机行为规则)
+     */
+    @Schema(description = "状态(0-自动派单,1-司机行为规则)")
+    private int status;
+
+    /**
+     * 日志内容
+     */
+    @Schema(description = "主键id")
+    private String description;
+
+    /**
+     * 创建时间
+     */
+    @Schema(description = "主键id")
+    private Date createTime;
+
+    /**
+     * 创建人(用户ID,默认-1)
+     */
+    @Schema(description = "创建人")
+    private Long createUser;
+
+
+    private static KwfDriverConductRulesLogVO getInstance(){
+        return new KwfDriverConductRulesLogVO();
+    }
+
+    public static KwfDriverConductRulesLogVO toVO(KwfDriverConductRulesLog rules){
+        if (rules == null) {
+            return KwfDriverConductRulesLogVO.getInstance();
+        }
+        KwfDriverConductRulesLogVO rulesVO = KwfDriverConductRulesLogVO.getInstance();
+        rulesVO.setId(rules.getId());
+        rulesVO.setBizId(rules.getBizId());
+        rulesVO.setStatus(rules.getStatus());
+        rulesVO.setDescription(rules.getDescription());
+        rulesVO.setCreateTime(rules.getCreateTime());
+        rulesVO.setCreateUser(rules.getCreateUser());
+
+        return rulesVO;
+    }
+
+
+}

+ 142 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfDriverConductRulesVO.java

@@ -0,0 +1,142 @@
+package com.sckw.fleet.model.vo;
+
+import com.sckw.fleet.model.KwfDriverConductRules;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 司机行为规则返回模型
+ *
+ * @author Generated
+ * @since 2024
+ */
+@Data
+public class KwfDriverConductRulesVO implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -5360767484446805797L;
+
+    /**
+     * 主键
+     */
+    @Schema(description = "主键id")
+    private Long id;
+
+    /**
+     * 企业id
+     */
+    @Schema(description = "企业id")
+    private Long entId;
+
+    /**
+     * 未按时到场(违规次数/扣分)
+     */
+    @Schema(description = "未按时到场")
+    private Integer notOnTimeArrive;
+
+    /**
+     * 违规取消运单(违规次数/扣分)
+     */
+    @Schema(description = "违规取消运单")
+    private Integer illegalCancelOrder;
+
+    /**
+     * 卸货严重超时(违规次数/扣分)
+     */
+    @Schema(description = "卸货严重超时")
+    private Integer unloadSeriousTimeout;
+
+    /**
+     * 虚假卸货(违规次数/扣分)
+     */
+    @Schema(description = "虚假卸货")
+    private Integer fakeUnload;
+
+    /**
+     * 单据错误/缺失(违规次数/扣分)
+     */
+    @Schema(description = "单据错误/缺失")
+    private Integer documentErrorMissing;
+
+    /**
+     * 连续按时到场(达标次数/加分)
+     */
+    @Schema(description = "连续按时到场")
+    private Integer continuousOnTimeArrive;
+
+    /**
+     * 连续准时卸货(达标次数/加分)
+     */
+    @Schema(description = "连续准时卸货")
+    private Integer continuousOnTimeUnload;
+
+    /**
+     * 连续准确填写卸货信息(达标次数/加分)
+     */
+    @Schema(description = "连续准确填写卸货信息")
+    private Integer continuousAccurateUnload;
+
+    /**
+     * 是否删除(0未删除,1删除)
+     */
+    @Schema(description = "是否删除")
+    private Integer delFlag;
+
+    /**
+     * 创建时间
+     */
+    @Schema(description = "创建时间")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @Schema(description = "更新时间")
+    private Date updateTime;
+
+    /**
+     * 创建人(用户ID,默认-1)
+     */
+    @Schema(description = "创建人")
+    private Long createUser;
+
+    /**
+     * 更新人(用户ID,默认-1)
+     */
+    @Schema(description = "更新人")
+    private Long updateUser;
+
+    private static KwfDriverConductRulesVO getInstance(){
+        return new KwfDriverConductRulesVO();
+    }
+
+    public static KwfDriverConductRulesVO toVO(KwfDriverConductRules rules){
+        if (rules == null) {
+            return KwfDriverConductRulesVO.getInstance();
+        }
+        KwfDriverConductRulesVO rulesVO = KwfDriverConductRulesVO.getInstance();
+        rulesVO.setId(rules.getId());
+        rulesVO.setEntId(rules.getEntId());
+        rulesVO.setNotOnTimeArrive(rules.getNotOnTimeArrive());
+        rulesVO.setIllegalCancelOrder(rules.getIllegalCancelOrder());
+        rulesVO.setUnloadSeriousTimeout(rules.getUnloadSeriousTimeout());
+        rulesVO.setFakeUnload(rules.getFakeUnload());
+        rulesVO.setDocumentErrorMissing(rules.getDocumentErrorMissing());
+        rulesVO.setContinuousOnTimeArrive(rules.getContinuousOnTimeArrive());
+        rulesVO.setContinuousOnTimeUnload(rules.getContinuousOnTimeUnload());
+        rulesVO.setContinuousAccurateUnload(rules.getContinuousAccurateUnload());
+        rulesVO.setDelFlag(rules.getDelFlag());
+        rulesVO.setCreateTime(rules.getCreateTime());
+        rulesVO.setUpdateTime(rules.getUpdateTime());
+        rulesVO.setCreateUser(rules.getCreateUser());
+        rulesVO.setUpdateUser(rules.getUpdateUser());
+
+        return rulesVO;
+    }
+
+
+}

+ 157 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckDispatchCoefficientVO.java

@@ -0,0 +1,157 @@
+package com.sckw.fleet.model.vo;
+
+import com.sckw.fleet.model.KwfTruckDispatchCoefficient;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 司机行为规则返回模型
+ *
+ * @author Generated
+ * @since 2024
+ */
+@Data
+public class KwfTruckDispatchCoefficientVO implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -5360767484446805797L;
+
+    /**
+     * 主键
+     */
+    @Schema(description = "主键id")
+    private Long id;
+
+    /**
+     * 企业id
+     */
+    @Schema(description = "企业id")
+    private Long entId;
+
+    /**
+     * 车辆工作时长
+     */
+    @Schema(description = "车辆工作时长")
+    private BigDecimal vehicleWorkHours;
+
+    /**
+     * 车辆装货时长
+     */
+    @Schema(description = "车辆装货时长")
+    private BigDecimal vehicleLoadingHours;
+
+    /**
+     * 车辆卸货时长
+     */
+    @Schema(description = "车辆卸货时长")
+    private BigDecimal vehicleUnloadingHours;
+
+    /**
+     * 司机超时限制
+     */
+    @Schema(description = "司机超时限制")
+    private BigDecimal driverTimeoutLimit;
+
+    /**
+     * 车辆平均载重
+     */
+    @Schema(description = "车辆平均载重")
+    private BigDecimal vehicleAvgLoad;
+
+    /**
+     * 车辆平均速度
+     */
+    @Schema(description = "车辆平均速度")
+    private BigDecimal vehicleAvgSpeed;
+
+    /**
+     * 车辆最大任务数
+     */
+    @Schema(description = "车辆最大任务数")
+    private Integer vehicleMaxTasks;
+
+    /**
+     * 司机接单限制
+     */
+    @Schema(description = "司机接单限制")
+    private BigDecimal driverOrderLimit;
+
+    /**
+     * 场内车辆容量
+     */
+    @Schema(description = "场内车辆容量")
+    private Integer yardVehicleCapacity;
+
+    /**
+     * 最大占比
+     */
+    @Schema(description = "最大占比")
+    private BigDecimal maxRatio;
+
+    /**
+     * 缓冲系数
+     */
+    @Schema(description = "缓冲系数")
+    private BigDecimal bufferCoefficient;
+
+    /**
+     * 创建时间
+     */
+    @Schema(description = "创建时间")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @Schema(description = "更新时间")
+    private Date updateTime;
+
+    /**
+     * 创建人(用户ID,默认-1)
+     */
+    @Schema(description = "创建人")
+    private Long createUser;
+
+    /**
+     * 更新人(用户ID,默认-1)
+     */
+    @Schema(description = "更新人")
+    private Long updateUser;
+
+    private static KwfTruckDispatchCoefficientVO getInstance(){
+        return new KwfTruckDispatchCoefficientVO();
+    }
+
+    public static KwfTruckDispatchCoefficientVO toVO(KwfTruckDispatchCoefficient result){
+        if (result == null) {
+            return KwfTruckDispatchCoefficientVO.getInstance();
+        }
+        KwfTruckDispatchCoefficientVO rulesVO = KwfTruckDispatchCoefficientVO.getInstance();
+        rulesVO.setId(result.getId());
+        rulesVO.setEntId(result.getEntId());
+        rulesVO.setVehicleWorkHours(result.getVehicleWorkHours());
+        rulesVO.setVehicleLoadingHours(result.getVehicleLoadingHours());
+        rulesVO.setVehicleUnloadingHours(result.getVehicleUnloadingHours());
+        rulesVO.setDriverTimeoutLimit(result.getDriverTimeoutLimit());
+        rulesVO.setVehicleAvgLoad(result.getVehicleAvgLoad());
+        rulesVO.setVehicleAvgSpeed(result.getVehicleAvgSpeed());
+        rulesVO.setVehicleMaxTasks(result.getVehicleMaxTasks());
+        rulesVO.setDriverOrderLimit(result.getDriverOrderLimit());
+        rulesVO.setYardVehicleCapacity(result.getYardVehicleCapacity());
+        rulesVO.setMaxRatio(result.getMaxRatio());
+        rulesVO.setBufferCoefficient(result.getBufferCoefficient());
+        rulesVO.setCreateTime(result.getCreateTime());
+        rulesVO.setUpdateTime(result.getUpdateTime());
+        rulesVO.setCreateUser(result.getCreateUser());
+        rulesVO.setUpdateUser(result.getUpdateUser());
+
+        return rulesVO;
+    }
+
+
+}

+ 16 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/repository/KwfDriverConductRulesLogRepository.java

@@ -0,0 +1,16 @@
+package com.sckw.fleet.repository;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sckw.fleet.dao.KwfDriverConductRulesLogMapper;
+import com.sckw.fleet.model.KwfDriverConductRulesLog;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @desc 司机行为规则日志 Repository接口
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Repository
+public class KwfDriverConductRulesLogRepository extends ServiceImpl<KwfDriverConductRulesLogMapper, KwfDriverConductRulesLog> {
+
+}

+ 16 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/repository/KwfDriverConductRulesRepository.java

@@ -0,0 +1,16 @@
+package com.sckw.fleet.repository;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sckw.fleet.dao.KwfDriverConductRulesMapper;
+import com.sckw.fleet.model.KwfDriverConductRules;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @desc 司机行为规则 Repository接口
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Repository
+public class KwfDriverConductRulesRepository extends ServiceImpl<KwfDriverConductRulesMapper, KwfDriverConductRules> {
+
+}

+ 16 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/repository/KwfTruckDispatchCoefficientRepository.java

@@ -0,0 +1,16 @@
+package com.sckw.fleet.repository;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sckw.fleet.dao.KwfTruckDispatchCoefficientMapper;
+import com.sckw.fleet.model.KwfTruckDispatchCoefficient;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @desc 司机行为规则 Repository接口
+ * @author donglang
+ * @date 2025-12-04
+ */
+@Repository
+public class KwfTruckDispatchCoefficientRepository extends ServiceImpl<KwfTruckDispatchCoefficientMapper, KwfTruckDispatchCoefficient> {
+
+}

+ 380 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfAutoDispatchService.java

@@ -0,0 +1,380 @@
+package com.sckw.fleet.service;
+
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sckw.core.common.enums.enums.ErrorCodeEnum;
+import com.sckw.core.exception.BusinessPlatfromException;
+import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.core.web.response.result.PageDataResult;
+import com.sckw.fleet.model.KwfDriverConductRules;
+import com.sckw.fleet.model.KwfDriverConductRulesLog;
+import com.sckw.fleet.model.KwfTruckDispatchCoefficient;
+import com.sckw.fleet.model.request.DriverConductRulesLogRequest;
+import com.sckw.fleet.model.request.DriverConductRulesRequest;
+import com.sckw.fleet.model.request.DriverConductRulesUpdateRequest;
+import com.sckw.fleet.model.request.TruckDispatchCoefficientUpdateRequest;
+import com.sckw.fleet.model.vo.KwfDriverConductRulesLogVO;
+import com.sckw.fleet.model.vo.KwfDriverConductRulesVO;
+import com.sckw.fleet.model.vo.KwfTruckDispatchCoefficientVO;
+import com.sckw.fleet.repository.KwfDriverConductRulesLogRepository;
+import com.sckw.fleet.repository.KwfDriverConductRulesRepository;
+import com.sckw.fleet.repository.KwfTruckDispatchCoefficientRepository;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+*Author: donglang
+*Time: 2025-12-04
+*Des: 司机行为规则
+*Version: 1.0
+*/
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class KwfAutoDispatchService {
+
+    private final KwfDriverConductRulesRepository driverConductRulesRepository;
+
+    private final KwfDriverConductRulesLogRepository driverConductRulesLogRepository;
+
+    private final KwfTruckDispatchCoefficientRepository truckDispatchCoefficientRepository;
+
+
+    /**
+     * 查询自动派车系数
+     * @param request
+     * @return
+     */
+    public KwfTruckDispatchCoefficientVO queryAutoTruckDispatch(DriverConductRulesRequest request) {
+        log.info("查询自动派车系数:{}", JSON.toJSONString(request));
+        Long entId = LoginUserHolder.getEntId();
+        if (entId == null) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR, "当前登录用户未关联企业ID,无法查询规则");
+        }
+        KwfTruckDispatchCoefficient dispatchCoefficient = truckDispatchCoefficientRepository.getOne(Wrappers.<KwfTruckDispatchCoefficient>lambdaQuery()
+                .eq(KwfTruckDispatchCoefficient::getEntId, LoginUserHolder.getEntId()));
+        //无数据则初始化
+        if (dispatchCoefficient == null && request.getIsInit()) {
+            log.info("当前企业[{}]无自动派车系数数据,执行初始化", entId);
+            dispatchCoefficient = initAutoDispatchCoefficient(entId);
+        }
+        KwfTruckDispatchCoefficientVO driverConductRulesVO = KwfTruckDispatchCoefficientVO.toVO(dispatchCoefficient);
+        log.info("查询自动派车系数完成,企业ID:{},规则数据:{}", entId, JSON.toJSONString(driverConductRulesVO));
+        return driverConductRulesVO;
+    }
+
+    /**
+     * 初始化自动派车系数
+     */
+    private KwfTruckDispatchCoefficient initAutoDispatchCoefficient(Long entId) {
+        KwfTruckDispatchCoefficient dispatchCoefficient = new KwfTruckDispatchCoefficient();
+        dispatchCoefficient.setEntId(entId);
+        dispatchCoefficient.setVehicleWorkHours(new BigDecimal("10.00"));
+        dispatchCoefficient.setVehicleLoadingHours(new BigDecimal("1.00"));
+        dispatchCoefficient.setVehicleUnloadingHours(new BigDecimal("1.00"));
+        dispatchCoefficient.setDriverTimeoutLimit(new BigDecimal("2.00"));
+        dispatchCoefficient.setVehicleAvgLoad(new BigDecimal("26.00"));
+        dispatchCoefficient.setVehicleAvgSpeed(new BigDecimal("50.00"));
+        dispatchCoefficient.setVehicleMaxTasks(3);
+        dispatchCoefficient.setDriverOrderLimit(new BigDecimal("10.00"));
+        dispatchCoefficient.setYardVehicleCapacity(70);
+        dispatchCoefficient.setMaxRatio(new BigDecimal("50.00"));
+        dispatchCoefficient.setBufferCoefficient(new BigDecimal("1.20"));
+        dispatchCoefficient.setCreateUser(LoginUserHolder.getUserId());
+        dispatchCoefficient.setUpdateUser(LoginUserHolder.getUserId());
+
+        boolean saveResult = truckDispatchCoefficientRepository.save(dispatchCoefficient);
+        if (!saveResult) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DATA_SAVE_FAIL, "新增自动派车系数失败");
+        }
+        log.info("企业[{}]自动派车系数初始化保存成功,规则ID:{}", entId, dispatchCoefficient.getId());
+        return dispatchCoefficient;
+    }
+
+
+    /**
+     * 修改自动派车系数
+     * @param request
+     * @return
+     */
+    public void updateAutoDispatch(TruckDispatchCoefficientUpdateRequest request) {
+        log.info("更新自动派车系数:{}", JSON.toJSONString(request));
+        KwfTruckDispatchCoefficient oldDispatchCoefficient = truckDispatchCoefficientRepository.getById(request.getId());
+        if (oldDispatchCoefficient == null) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "查询自动派车系数数据不存在!");
+        }
+
+        KwfTruckDispatchCoefficient newDispatchCoefficient = new KwfTruckDispatchCoefficient();
+        BeanUtils.copyProperties(oldDispatchCoefficient, newDispatchCoefficient);
+
+        oldDispatchCoefficient.setVehicleWorkHours(request.getVehicleWorkHours());
+        oldDispatchCoefficient.setVehicleLoadingHours(request.getVehicleLoadingHours());
+        oldDispatchCoefficient.setVehicleUnloadingHours(request.getVehicleUnloadingHours());
+        oldDispatchCoefficient.setDriverTimeoutLimit(request.getDriverTimeoutLimit());
+        oldDispatchCoefficient.setVehicleAvgLoad(request.getVehicleAvgLoad());
+        oldDispatchCoefficient.setVehicleAvgSpeed(request.getVehicleAvgSpeed());
+        oldDispatchCoefficient.setVehicleMaxTasks(request.getVehicleMaxTasks());
+        oldDispatchCoefficient.setDriverOrderLimit(request.getDriverOrderLimit());
+        oldDispatchCoefficient.setYardVehicleCapacity(request.getYardVehicleCapacity());
+        oldDispatchCoefficient.setMaxRatio(request.getMaxRatio());
+        oldDispatchCoefficient.setBufferCoefficient(request.getBufferCoefficient());
+        oldDispatchCoefficient.setUpdateUser(LoginUserHolder.getUserId());
+
+        boolean updateResult = truckDispatchCoefficientRepository.updateById(newDispatchCoefficient);
+        if (!updateResult) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DATA_UPDATE_FAIL, "更新自动派车系数失败");
+        }
+        // 生成差异化修改文案
+        String modifyDesc = getAutoDispatchModifyDesc(oldDispatchCoefficient, request);
+        if (StringUtils.isEmpty(modifyDesc)) {
+            return;
+        }
+
+        //生成规则更新日志
+        KwfDriverConductRulesLog rulesLog = new KwfDriverConductRulesLog();
+        rulesLog.setBizId(request.getId());
+        rulesLog.setDescription(modifyDesc);
+        rulesLog.setStatus(0);
+        rulesLog.setCreateUser(LoginUserHolder.getUserId());
+        rulesLog.setUpdateUser(LoginUserHolder.getUserId());
+
+        boolean saveResult = driverConductRulesLogRepository.save(rulesLog);
+        if (!saveResult) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DATA_SAVE_FAIL, "新增自动派车系数日志失败");
+        }
+        log.info("更新自动派车系数成功!修改内容:{}", modifyDesc);
+    }
+
+
+
+
+    /**
+     * 生成司机行为规则修改的差异化文案
+     * @param oldDispatch 旧派车系数
+     * @param request 新的更新入参
+     * @return 差异化修改文案
+     */
+    private String getAutoDispatchModifyDesc(KwfTruckDispatchCoefficient oldDispatch, TruckDispatchCoefficientUpdateRequest request) {
+        if (oldDispatch == null || request == null) {
+            return "";
+        }
+        List<String> changeItems = new ArrayList<>();
+        // 对比所有字段
+        compareAndAddItem(changeItems, "车辆工作时长", oldDispatch.getVehicleWorkHours(), request.getVehicleWorkHours());
+        compareAndAddItem(changeItems, "车辆装货时长", oldDispatch.getVehicleLoadingHours(), request.getVehicleLoadingHours());
+        compareAndAddItem(changeItems, "车辆卸货时长", oldDispatch.getVehicleUnloadingHours(), request.getVehicleUnloadingHours());
+        compareAndAddItem(changeItems, "司机超时限制", oldDispatch.getDriverTimeoutLimit(), request.getDriverTimeoutLimit());
+        compareAndAddItem(changeItems, "车辆平均载重", oldDispatch.getVehicleAvgLoad(), request.getVehicleAvgLoad());
+        compareAndAddItem(changeItems, "车辆平均速度", oldDispatch.getVehicleAvgSpeed(), request.getVehicleAvgSpeed());
+        compareAndAddItem(changeItems, "车辆最大任务数", oldDispatch.getVehicleMaxTasks(), request.getVehicleMaxTasks());
+        compareAndAddItem(changeItems, "司机接单限制", oldDispatch.getDriverOrderLimit(), request.getDriverOrderLimit());
+        compareAndAddItem(changeItems, "场内车辆容量", oldDispatch.getYardVehicleCapacity(), request.getYardVehicleCapacity());
+        compareAndAddItem(changeItems, "最大占比", oldDispatch.getMaxRatio(), request.getMaxRatio());
+        compareAndAddItem(changeItems, "缓冲系数", oldDispatch.getBufferCoefficient(), request.getBufferCoefficient());
+
+        if (changeItems.isEmpty()) {
+            return "";
+        }
+        // 修改项拼接
+        return StringUtils.join(changeItems, ",");
+    }
+
+
+    /**
+     * 对比单个字段值,有变化则添加到文案列表
+     * @param items 文案列表
+     * @param fieldName 字段业务名称
+     * @param oldValue 旧值
+     * @param newValue 新值
+     */
+    private void compareAndAddItem(List<String> items, String fieldName, BigDecimal oldValue, BigDecimal newValue) {
+        // 仅当值不同时添加文案
+        if (Objects.equals(oldValue, newValue)) {
+            items.add(String.format("%s由【%s】设置为【%s】", fieldName, oldValue, newValue));
+        }
+    }
+
+
+    /**
+     * 查询司机行为规则
+     * @param request
+     * @return
+     */
+    public KwfDriverConductRulesVO queryDriverConductRules(DriverConductRulesRequest request) {
+        log.info("查询司机行为规则:{}", JSON.toJSONString(request));
+        Long entId = LoginUserHolder.getEntId();
+        if (entId == null) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR, "当前登录用户未关联企业ID,无法查询规则");
+        }
+        KwfDriverConductRules driverConductRules = driverConductRulesRepository.getOne(Wrappers.<KwfDriverConductRules>lambdaQuery()
+                .eq(KwfDriverConductRules::getDelFlag, 0)
+                .eq(KwfDriverConductRules::getEntId, LoginUserHolder.getEntId()));
+        //无数据则初始化
+        if (driverConductRules == null && request.getIsInit()) {
+            log.info("当前企业[{}]无司机行为规则数据,执行初始化", entId);
+            driverConductRules = initDriverConductRules(entId);
+        }
+        KwfDriverConductRulesVO resultVO = KwfDriverConductRulesVO.toVO(driverConductRules);
+        log.info("查询司机行为规则完成,企业ID:{},规则数据:{}", entId, JSON.toJSONString(resultVO));
+        return resultVO;
+    }
+
+    /**
+     * 初始化司机行为规则
+     */
+    private KwfDriverConductRules initDriverConductRules(Long entId) {
+        KwfDriverConductRules rules = new KwfDriverConductRules();
+        rules.setEntId(entId);
+        rules.setNotOnTimeArrive(2);
+        rules.setIllegalCancelOrder(2);
+        rules.setUnloadSeriousTimeout(2);
+        rules.setFakeUnload(2);
+        rules.setDocumentErrorMissing(2);
+        rules.setContinuousOnTimeArrive(2);
+        rules.setContinuousOnTimeUnload(2);
+        rules.setContinuousAccurateUnload(2);
+        rules.setCreateUser(LoginUserHolder.getUserId());
+        rules.setUpdateUser(LoginUserHolder.getUserId());
+
+        boolean saveResult = driverConductRulesRepository.save(rules);
+        if (!saveResult) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DATA_SAVE_FAIL, "新增司机行为规则失败");
+        }
+        log.info("企业[{}]司机行为规则初始化保存成功,规则ID:{}", entId, rules.getId());
+        return rules;
+    }
+
+    /**
+     * 更新司机行为规则
+     * @param request
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateDriverConduct(DriverConductRulesUpdateRequest request) {
+        log.info("更新司机行为规则:{}", JSON.toJSONString(request));
+
+        KwfDriverConductRules oldDriverConductRules = driverConductRulesRepository.getById(request.getId());
+        if (oldDriverConductRules == null) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "查询司机行为规则数据不存在!");
+        }
+
+        KwfDriverConductRules newDriverConductRules = new KwfDriverConductRules();
+        BeanUtils.copyProperties(oldDriverConductRules, newDriverConductRules);
+
+        newDriverConductRules.setNotOnTimeArrive(request.getNotOnTimeArrive());
+        newDriverConductRules.setIllegalCancelOrder(request.getIllegalCancelOrder());
+        newDriverConductRules.setUnloadSeriousTimeout(request.getUnloadSeriousTimeout());
+        newDriverConductRules.setFakeUnload(request.getFakeUnload());
+        newDriverConductRules.setDocumentErrorMissing(request.getDocumentErrorMissing());
+        newDriverConductRules.setContinuousOnTimeArrive(request.getContinuousOnTimeArrive());
+        newDriverConductRules.setContinuousOnTimeUnload(request.getContinuousOnTimeUnload());
+        newDriverConductRules.setContinuousAccurateUnload(request.getContinuousAccurateUnload());
+        newDriverConductRules.setUpdateUser(LoginUserHolder.getUserId());
+        boolean updateResult = driverConductRulesRepository.updateById(newDriverConductRules);
+        if (!updateResult) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DATA_UPDATE_FAIL, "更新司机行为规则失败");
+        }
+        // 生成差异化修改文案
+        String modifyDesc = getDriverModifyDesc(oldDriverConductRules, request);
+        if (StringUtils.isEmpty(modifyDesc)) {
+            return;
+        }
+
+        //生成规则更新日志
+        KwfDriverConductRulesLog rulesLog = new KwfDriverConductRulesLog();
+        rulesLog.setBizId(request.getId());
+        rulesLog.setDescription(modifyDesc);
+        rulesLog.setStatus(1);
+        rulesLog.setCreateUser(LoginUserHolder.getUserId());
+        rulesLog.setUpdateUser(LoginUserHolder.getUserId());
+
+        boolean saveResult = driverConductRulesLogRepository.save(rulesLog);
+        if (!saveResult) {
+            throw new BusinessPlatfromException(ErrorCodeEnum.DATA_SAVE_FAIL, "新增司机行为规则日志失败");
+        }
+        log.info("更新司机行为规则成功!修改内容:{}", modifyDesc);
+    }
+
+    /**
+     * 生成司机行为规则修改的差异化文案
+     * @param oldRule 旧规则数据
+     * @param request 新的更新入参
+     * @return 差异化修改文案
+     */
+    private String getDriverModifyDesc(KwfDriverConductRules oldRule, DriverConductRulesUpdateRequest request) {
+        if (oldRule == null || request == null) {
+            return "";
+        }
+        List<String> changeItems = new ArrayList<>();
+        // 对比所有字段
+        compareAndAddItem(changeItems, "未按时到场", oldRule.getNotOnTimeArrive(), request.getNotOnTimeArrive());
+        compareAndAddItem(changeItems, "违规取消运单", oldRule.getIllegalCancelOrder(), request.getIllegalCancelOrder());
+        compareAndAddItem(changeItems, "卸货严重超时", oldRule.getUnloadSeriousTimeout(), request.getUnloadSeriousTimeout());
+        compareAndAddItem(changeItems, "虚假卸货", oldRule.getFakeUnload(), request.getFakeUnload());
+        compareAndAddItem(changeItems, "单据错误/缺失", oldRule.getDocumentErrorMissing(), request.getDocumentErrorMissing());
+        compareAndAddItem(changeItems, "连续按时到场", oldRule.getContinuousOnTimeArrive(), request.getContinuousOnTimeArrive());
+        compareAndAddItem(changeItems, "连续准时卸货", oldRule.getContinuousOnTimeUnload(), request.getContinuousOnTimeUnload());
+        compareAndAddItem(changeItems, "连续准确填写卸货信息", oldRule.getContinuousAccurateUnload(), request.getContinuousAccurateUnload());
+
+        if (changeItems.isEmpty()) {
+            return "";
+        }
+        // 修改项拼接
+        return StringUtils.join(changeItems, ",");
+    }
+
+    /**
+     * 对比单个字段值,有变化则添加到文案列表
+     * @param items 文案列表
+     * @param fieldName 字段业务名称
+     * @param oldValue 旧值
+     * @param newValue 新值
+     */
+    private void compareAndAddItem(List<String> items, String fieldName, Integer oldValue, Integer newValue) {
+        // 仅当值不同时添加文案
+        if (Objects.equals(oldValue, newValue)) {
+            items.add(String.format("%s由【%s】设置为【%s】", fieldName, oldValue, newValue));
+        }
+    }
+
+
+    /**
+     * 查询司机行为规则
+     * @param request
+     * @return
+     */
+    public PageDataResult<KwfDriverConductRulesLogVO> queryDriverRulesLogPage(DriverConductRulesLogRequest request) {
+        log.info("查询司机行为规则日志:{}", JSON.toJSONString(request));
+        LambdaQueryWrapper<KwfDriverConductRulesLog> queryWrapper = Wrappers.<KwfDriverConductRulesLog>lambdaQuery()
+                .eq(KwfDriverConductRulesLog::getBizId, request.getBizId())
+                .eq(KwfDriverConductRulesLog::getStatus, request.getStatus())
+                .like(StringUtils.isNotBlank(request.getDescription()), KwfDriverConductRulesLog::getDescription, request.getDescription())
+                .orderByDesc(KwfDriverConductRulesLog::getCreateTime);
+        //查询司机行为规则日志
+        Page<KwfDriverConductRulesLog> driverConductRulesLog = driverConductRulesLogRepository.page(
+                new Page<>(request.getPageNum(), request.getPageSize()), queryWrapper);
+        List<KwfDriverConductRulesLog> records = driverConductRulesLog.getRecords();
+        if (CollectionUtils.isEmpty(records)) {
+            log.info("当前无司机行为规则日志数据,bizId:{}", request.getBizId());
+            return PageDataResult.empty(request.getPageNum(), request.getPageSize());
+        }
+        List<KwfDriverConductRulesLogVO> rulesLogVOS = records.stream().map(KwfDriverConductRulesLogVO::toVO).collect(Collectors.toList());
+        log.info("查询司机行为规则日志成功!");
+        return PageDataResult.success(request.getPageNum(), request.getPageSize(), (long) rulesLogVOS.size(), rulesLogVOS);
+    }
+
+}

+ 36 - 1
sql/2025/12/01/2025_12_04_donglang.sql

@@ -2,7 +2,7 @@
 create table kwf_driver_conduct_rules
 (
     id                              bigint          NOT NULL AUTO_INCREMENT COMMENT '主键',
-    net_id                          bigint          NOT NULL comment '企业id',
+    ent_id                          bigint          NOT NULL comment '企业id',
     not_on_time_arrive              int             NOT NULL comment '未按时到场(违规次数/扣分)',
     illegal_cancel_order            int             NOT NULL comment '违规取消运单(违规次数/扣分)',
     unload_serious_timeout          int             NOT NULL comment '卸货严重超时(违规次数/扣分)',
@@ -21,5 +21,40 @@ create table kwf_driver_conduct_rules
 
 
 
+create table kwf_driver_conduct_rules_log
+(
+    id                              bigint          NOT NULL AUTO_INCREMENT COMMENT '主键',
+    dcr_id                          bigint          NOT NULL comment '司机行为规则id',
+    description                  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '日志内容',
+    del_flag                        int             NOT NULL DEFAULT '0' COMMENT '是否删除(0未删除,1删除)',
+    create_time                     datetime        NOT NULL default CURRENT_TIMESTAMP comment '创建时间',
+    update_time                     datetime        NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '更新时间',
+    create_user                     bigint          NOT NULL DEFAULT '-1' comment '创建人',
+    update_user                     bigint          NOT NULL DEFAULT '-1' comment '更新人',
+    PRIMARY KEY (`id`) USING BTREE
+) comment '司机行为规则日志表';
+
+
+create table kwt_truck_dispatch_coefficient
+(
+    id                              bigint          NOT NULL AUTO_INCREMENT COMMENT '主键',
+    ent_id                          bigint          NOT NULL comment '企业id',
+    vehicle_work_hours              decimal(8,2)    NOT NULL DEFAULT '00.00' comment '车辆工作时长',
+    vehicle_loading_hours           decimal(8,2)    NOT NULL DEFAULT '00.00' comment '车辆装货时长',
+    vehicle_unloading_hours         decimal(8,2)    NOT NULL DEFAULT '00.00' comment '车辆卸货时长',
+    driver_timeout_limit            decimal(8,2)    NOT NULL DEFAULT '00.00' comment '司机超时限制',
+    vehicle_avg_load                decimal(8,2)    NOT NULL DEFAULT '00.00' comment '车辆平均载重',
+    vehicle_avg_speed               decimal(8,2)    NOT NULL DEFAULT '00.00' comment '车辆平均速度',
+    vehicle_max_tasks               int             NOT NULL comment '车辆最大任务数',
+    driver_order_limit              decimal(8,2)    NOT NULL DEFAULT '00.00' comment '司机接单限制',
+    yard_vehicle_capacity           int             NOT NULL comment '场内车辆容量',
+    max_ratio                       decimal(8,2)    NOT NULL DEFAULT '00.00' comment '最大占比',
+    buffer_coefficient              decimal(8,2)    NOT NULL DEFAULT '00.00' comment '缓冲系数',
+    create_time                     datetime        NOT NULL default CURRENT_TIMESTAMP comment '创建时间',
+    update_time                     datetime        NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '更新时间',
+    create_user                     bigint          NOT NULL DEFAULT '-1' comment '创建人',
+    update_user                     bigint          NOT NULL DEFAULT '-1' comment '更新人',
+    PRIMARY KEY (`id`) USING BTREE
+) comment '自动派单系数表';