|
|
@@ -107,36 +107,47 @@ public class KwfAutoDispatchService {
|
|
|
*/
|
|
|
public void updateAutoDispatch(TruckDispatchCoefficientUpdateRequest request) {
|
|
|
log.info("更新自动派车系数:{}", JSON.toJSONString(request));
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
+ if (entId == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR, "当前登录用户未关联企业ID,无法查询规则");
|
|
|
+ }
|
|
|
+ //如果id为空则是新增
|
|
|
+ if (request.getId() == null) {
|
|
|
+ saveAutoDispatch(request, entId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 修改
|
|
|
KwfTruckDispatchCoefficient oldDispatchCoefficient = truckDispatchCoefficientRepository.getById(request.getId());
|
|
|
if (oldDispatchCoefficient == null) {
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "查询自动派车系数数据不存在!");
|
|
|
}
|
|
|
|
|
|
+ // 生成差异化修改文案
|
|
|
+ String modifyDesc = getAutoDispatchModifyDesc(oldDispatchCoefficient, request);
|
|
|
+ if (StringUtils.isEmpty(modifyDesc)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
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());
|
|
|
+ newDispatchCoefficient.setVehicleWorkHours(request.getVehicleWorkHours());
|
|
|
+ newDispatchCoefficient.setVehicleLoadingHours(request.getVehicleLoadingHours());
|
|
|
+ newDispatchCoefficient.setVehicleUnloadingHours(request.getVehicleUnloadingHours());
|
|
|
+ newDispatchCoefficient.setDriverTimeoutLimit(request.getDriverTimeoutLimit());
|
|
|
+ newDispatchCoefficient.setVehicleAvgLoad(request.getVehicleAvgLoad());
|
|
|
+ newDispatchCoefficient.setVehicleAvgSpeed(request.getVehicleAvgSpeed());
|
|
|
+ newDispatchCoefficient.setVehicleMaxTasks(request.getVehicleMaxTasks());
|
|
|
+ newDispatchCoefficient.setDriverOrderLimit(request.getDriverOrderLimit());
|
|
|
+ newDispatchCoefficient.setYardVehicleCapacity(request.getYardVehicleCapacity());
|
|
|
+ newDispatchCoefficient.setMaxRatio(request.getMaxRatio());
|
|
|
+ newDispatchCoefficient.setBufferCoefficient(request.getBufferCoefficient());
|
|
|
+ newDispatchCoefficient.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();
|
|
|
@@ -153,8 +164,29 @@ public class KwfAutoDispatchService {
|
|
|
log.info("更新自动派车系数成功!修改内容:{}", modifyDesc);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 保存自动派车系数表
|
|
|
+ * @param request
|
|
|
+ */
|
|
|
+ private void saveAutoDispatch(TruckDispatchCoefficientUpdateRequest request, Long entId) {
|
|
|
+ log.info("新增自动派车系数:{}", JSON.toJSONString(request));
|
|
|
+ KwfTruckDispatchCoefficient dispatchCoefficient = new KwfTruckDispatchCoefficient();
|
|
|
+ dispatchCoefficient.setEntId(entId);
|
|
|
+ dispatchCoefficient.setVehicleWorkHours(request.getVehicleWorkHours());
|
|
|
+ dispatchCoefficient.setVehicleLoadingHours(request.getVehicleLoadingHours());
|
|
|
+ dispatchCoefficient.setVehicleUnloadingHours(request.getVehicleUnloadingHours());
|
|
|
+ dispatchCoefficient.setDriverTimeoutLimit(request.getDriverTimeoutLimit());
|
|
|
+ dispatchCoefficient.setVehicleAvgLoad(request.getVehicleAvgLoad());
|
|
|
+ dispatchCoefficient.setVehicleAvgSpeed(request.getVehicleAvgSpeed());
|
|
|
+ dispatchCoefficient.setVehicleMaxTasks(request.getVehicleMaxTasks());
|
|
|
+ dispatchCoefficient.setDriverOrderLimit(request.getDriverOrderLimit());
|
|
|
+ dispatchCoefficient.setYardVehicleCapacity(request.getYardVehicleCapacity());
|
|
|
+ dispatchCoefficient.setMaxRatio(request.getMaxRatio());
|
|
|
+ dispatchCoefficient.setBufferCoefficient(request.getBufferCoefficient());
|
|
|
+ dispatchCoefficient.setCreateUser(LoginUserHolder.getUserId());
|
|
|
+ dispatchCoefficient.setUpdateUser(LoginUserHolder.getUserId());
|
|
|
+ truckDispatchCoefficientRepository.save(dispatchCoefficient);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 生成司机行为规则修改的差异化文案
|
|
|
@@ -187,6 +219,19 @@ public class KwfAutoDispatchService {
|
|
|
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));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 对比单个字段值,有变化则添加到文案列表
|
|
|
@@ -197,12 +242,11 @@ public class KwfAutoDispatchService {
|
|
|
*/
|
|
|
private void compareAndAddItem(List<String> items, String fieldName, BigDecimal oldValue, BigDecimal newValue) {
|
|
|
// 仅当值不同时添加文案
|
|
|
- if (Objects.equals(oldValue, newValue)) {
|
|
|
+ if (oldValue.compareTo(newValue) != 0) {
|
|
|
items.add(String.format("%s由【%s】设置为【%s】", fieldName, oldValue, newValue));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 查询司机行为规则
|
|
|
* @param request
|
|
|
@@ -259,12 +303,27 @@ public class KwfAutoDispatchService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateDriverConduct(DriverConductRulesUpdateRequest request) {
|
|
|
log.info("更新司机行为规则:{}", JSON.toJSONString(request));
|
|
|
-
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
+ if (entId == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR, "当前登录用户未关联企业ID,无法查询规则");
|
|
|
+ }
|
|
|
+ // 新增
|
|
|
+ if (request.getId() == null) {
|
|
|
+ saveDriverConductRules(request, entId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 修改
|
|
|
KwfDriverConductRules oldDriverConductRules = driverConductRulesRepository.getById(request.getId());
|
|
|
if (oldDriverConductRules == null) {
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "查询司机行为规则数据不存在!");
|
|
|
}
|
|
|
|
|
|
+ // 生成差异化修改文案
|
|
|
+ String modifyDesc = getDriverModifyDesc(oldDriverConductRules, request);
|
|
|
+ if (StringUtils.isEmpty(modifyDesc)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
KwfDriverConductRules newDriverConductRules = new KwfDriverConductRules();
|
|
|
BeanUtils.copyProperties(oldDriverConductRules, newDriverConductRules);
|
|
|
|
|
|
@@ -288,11 +347,6 @@ public class KwfAutoDispatchService {
|
|
|
if (!updateResult) {
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_UPDATE_FAIL, "更新司机行为规则失败");
|
|
|
}
|
|
|
- // 生成差异化修改文案
|
|
|
- String modifyDesc = getDriverModifyDesc(oldDriverConductRules, request);
|
|
|
- if (StringUtils.isEmpty(modifyDesc)) {
|
|
|
- return;
|
|
|
- }
|
|
|
|
|
|
//生成规则更新日志
|
|
|
KwfDriverConductRulesLog rulesLog = new KwfDriverConductRulesLog();
|
|
|
@@ -309,6 +363,28 @@ public class KwfAutoDispatchService {
|
|
|
log.info("更新司机行为规则成功!修改内容:{}", modifyDesc);
|
|
|
}
|
|
|
|
|
|
+ private void saveDriverConductRules(DriverConductRulesUpdateRequest request, Long entId) {
|
|
|
+ KwfDriverConductRules driverConductRules = new KwfDriverConductRules();
|
|
|
+ driverConductRules.setEntId(entId);
|
|
|
+ driverConductRules.setUnloadSeriousTimeoutScore(request.getUnloadSeriousTimeoutScore());
|
|
|
+ driverConductRules.setUnloadSeriousTimeoutMultiple(request.getUnloadSeriousTimeoutMultiple());
|
|
|
+ driverConductRules.setDocumentErrorMissingScore(request.getDocumentErrorMissingScore());
|
|
|
+ driverConductRules.setNotOnTimeArriveScore(request.getNotOnTimeArriveScore());
|
|
|
+ driverConductRules.setFakeUnloadScore(request.getFakeUnloadScore());
|
|
|
+ driverConductRules.setFakeUnloadDistance(request.getFakeUnloadDistance());
|
|
|
+ driverConductRules.setIllegalCancelOrderScore(request.getIllegalCancelOrderScore());
|
|
|
+ driverConductRules.setIllegalCancelOrderMinutes(request.getIllegalCancelOrderMinutes());
|
|
|
+ driverConductRules.setContinuousOnTimeArriveScore(request.getContinuousOnTimeArriveScore());
|
|
|
+ driverConductRules.setContinuousOnTimeArriveTimes(request.getContinuousOnTimeArriveTimes());
|
|
|
+ driverConductRules.setContinuousOnTimeUnloadScore(request.getContinuousOnTimeUnloadScore());
|
|
|
+ driverConductRules.setContinuousOnTimeUnloadTimes(request.getContinuousOnTimeUnloadTimes());
|
|
|
+ driverConductRules.setContinuousAccurateUnloadScore(request.getContinuousAccurateUnloadScore());
|
|
|
+ driverConductRules.setContinuousAccurateUnloadTimes(request.getContinuousAccurateUnloadTimes());
|
|
|
+ driverConductRules.setCreateUser(LoginUserHolder.getUserId());
|
|
|
+ driverConductRules.setUpdateUser(LoginUserHolder.getUserId());
|
|
|
+ driverConductRulesRepository.save(driverConductRules);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 生成司机行为规则修改的差异化文案
|
|
|
* @param oldRule 旧规则数据
|
|
|
@@ -343,21 +419,6 @@ public class KwfAutoDispatchService {
|
|
|
return StringUtils.join(changeItems, ",");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 对比单个字段值,有变化则添加到文案列表
|
|
|
- * @param items 文案列表
|
|
|
- * @param fieldName 字段业务名称
|
|
|
- * @param oldValue 旧值
|
|
|
- * @param newValue 新值
|
|
|
- */
|
|
|
- private void compareAndAddItem(List<String> items, String fieldName, Integer oldValue, Integer newValue) {
|
|
|
- // 仅当值不同时添加文案 //TODO donglang BigDecimal
|
|
|
- if (Objects.equals(oldValue, newValue)) {
|
|
|
- items.add(String.format("%s由【%s】设置为【%s】", fieldName, oldValue, newValue));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 查询司机行为规则
|
|
|
* @param request
|