Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07393e43ff | ||
|
|
08858f24d6 | ||
|
|
a994241400 | ||
|
|
a9be03961a | ||
|
|
7f6006ca48 | ||
|
|
defc8c3709 | ||
|
|
3c21c2c848 | ||
|
|
71936b50a7 | ||
|
|
9cfffe1224 | ||
|
|
d7574d188a | ||
|
|
1c1b06c1bf | ||
|
|
117019c55c | ||
|
|
171909b68d | ||
|
|
31c27c16c6 | ||
|
|
8dfe9545aa | ||
|
|
028afb57d7 | ||
|
|
37dd374bda | ||
|
|
d69af9ef20 | ||
|
|
9704dbfb07 | ||
|
|
3276792bb5 | ||
|
|
b57db4b8cc | ||
|
|
8a31ed9974 | ||
|
|
9777156959 | ||
|
|
ba5d78b36c | ||
|
|
dea39a1a4b | ||
|
|
0493030620 | ||
|
|
3907b126d9 | ||
|
|
7b76d5c203 | ||
|
|
f02a2d52f2 | ||
|
|
a3c0f15e39 | ||
|
|
d2a6a5a4f6 | ||
|
|
752216ad45 | ||
|
|
6a8661da63 | ||
|
|
2b6777abe4 |
@@ -19,7 +19,8 @@ import java.util.Set;
|
||||
/**
|
||||
* bms财务结算系统feign调用接口
|
||||
*/
|
||||
@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8012",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-bms-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface BmsServiceFeign {
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-oms-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.33:8017",fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface OmsServiceFeign {
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-wlhy-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.31:8014",configuration = FeignAutoConfiguration.class)
|
||||
public interface WlhyServiceFeign {
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
* @description: TODO
|
||||
* @date 2024/5/10 8:58
|
||||
**/
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-wms-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE,url = "http://10.102.192.32:8016",fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface WmsServiceFeign {
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "http://127.0.0.1:8020",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
// 目标地址由 nacos 配置项 feign.url.xxl-job-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "http://10.102.192.32:8020",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface XxlJobServiceFeign {
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ import com.mhd.system.api.feign.FeignAutoConfiguration;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,url = "http://10.102.192.33:8018",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-yms-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,url = "http://10.102.192.32:8018",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface YmsServiceFeign {
|
||||
|
||||
/**
|
||||
|
||||
+12
-4
@@ -130,9 +130,11 @@ public class TokenLoginApplicationService {
|
||||
//验证码登录校验验证码
|
||||
String key = CacheConstants.SMS_LOGIN + userPhone;
|
||||
Object object = redisService.getCacheObject(key) == null ? "":redisService.getCacheObject(key);
|
||||
if(!ObjectUtil.equal(String.valueOf(object),verificationCode) && !ObjectUtil.equal(verificationCode, SmsConstants.universalCode)){
|
||||
recordLogininfor(userPhone, Constants.LOGIN_FAIL, "验证码错误", 1);
|
||||
throw new ServiceException("验证码错误");
|
||||
if (loginDTO.getWechatFlag() != 1) {
|
||||
// if (!ObjectUtil.equal(String.valueOf(object), verificationCode) && !ObjectUtil.equal(verificationCode, SmsConstants.universalCode)) {
|
||||
// recordLogininfor(userPhone, Constants.LOGIN_FAIL, "验证码错误", 1);
|
||||
throw new ServiceException("验证码错误");
|
||||
// }
|
||||
}
|
||||
|
||||
//获取包名对应的业务(存在需要查询业务,不存在保存为无业务模式)
|
||||
@@ -168,7 +170,13 @@ public class TokenLoginApplicationService {
|
||||
throw new ServiceException("对不起,您的账号:" + userPhone + " 已停用");
|
||||
}
|
||||
//校验验证码是否正确
|
||||
sysPasswordService.validate(userPo, verificationCode, 1, null);
|
||||
if (loginDTO.getWechatFlag() != 1) {
|
||||
// if (!ObjectUtil.equal(String.valueOf(object), verificationCode) && !ObjectUtil.equal(verificationCode, SmsConstants.universalCode)) {
|
||||
// recordLogininfor(userPhone, Constants.LOGIN_FAIL, "验证码错误", 1);
|
||||
throw new ServiceException("验证码错误");
|
||||
// }
|
||||
}
|
||||
// sysPasswordService.validate(userPo, verificationCode, 1, null);
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
@@ -40,4 +40,7 @@ public class LoginDTO {
|
||||
@ApiModelProperty(name = "组织名称(司机选择组织时传入)")
|
||||
private String organizationName;
|
||||
|
||||
@ApiModelProperty(name = "微信标识")
|
||||
private Integer wechatFlag;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
# server-addr: 10.33.0.129:6010
|
||||
# server-addr: 10.102.192.31:6848
|
||||
server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
#线上正式环境
|
||||
@@ -23,8 +23,8 @@ spring:
|
||||
# username: nacos
|
||||
# password: manhuoda@2023
|
||||
config:
|
||||
server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.102.192.31:6848
|
||||
# server-addr: 127.0.0.1:8848
|
||||
server-addr: 10.102.192.31:6848
|
||||
# 测试环境配置 容器名+端口号
|
||||
# server-addr: 10.33.0.129:6010
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
|
||||
+13
-1
@@ -7,6 +7,9 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,18 +29,27 @@ public interface BiPlatformRealDataMapper {
|
||||
/** 今日作业任务数 */
|
||||
Long countTodayTasks();
|
||||
|
||||
/** 车辆状态统计(今日) */
|
||||
/** 车辆状态统计(今日,含叫号状态合计 callStatusTotal = 已签到+已叫号+已过号) */
|
||||
RealVehicleStatusPO queryVehicleStatusToday();
|
||||
|
||||
/** 本月任务量 */
|
||||
Long countMonthTasks();
|
||||
|
||||
/** 本月任务平均时长 / 完成率统计 */
|
||||
RealMonthlyTaskDurationPO queryMonthTaskStats();
|
||||
|
||||
/** 任务负荷(今日 24 小时) */
|
||||
List<RealTaskLoadPO> queryTaskLoadToday();
|
||||
|
||||
/** 今日预约-业务类型统计(按 businessName 分组统计今日预约数量) */
|
||||
List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats();
|
||||
|
||||
/** 今日作业准时率统计(total 今日预约总数;onTimeCount 今日准时车辆数) */
|
||||
RealOnTimeStatPO queryTodayOnTimeStats();
|
||||
|
||||
/** 任务类型统计(本月 YMS QMS_MAIN_BUSINESS 预约按业务类型 BUSINESS_NAME 分组) */
|
||||
List<RealTaskTypeStatPO> queryMonthTransportOrderByType();
|
||||
|
||||
/** 月台监控-按楼层统计月台车辆(楼层、月台数量、今日预约车辆、当前作业车辆) */
|
||||
List<RealPlatformFloorStatPO> queryPlatformFloorStats();
|
||||
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 本月任务平均时长 / 完成率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||
* avgDurationHours:累计 (EXIT_TIME - ENTRY_TIME) 小时数(仅 ENTRY_TIME/EXIT_TIME 都不为空时参与)
|
||||
* durationCount:参与平均时长统计的有效条数
|
||||
* completedCount:已出场(EXIT_TIME IS NOT NULL)且预约日期在本月的数量
|
||||
* totalCount:本月(TARGET_DATE)预约总数量
|
||||
*/
|
||||
@Data
|
||||
public class RealMonthlyTaskDurationPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 平均作业时长(小时) */
|
||||
private Double avgDurationHours;
|
||||
|
||||
/** 参与平均时长统计的有效条数 */
|
||||
private Long durationCount;
|
||||
|
||||
/** 本月已出场数量 */
|
||||
private Long completedCount;
|
||||
|
||||
/** 本月预约总数量(按 TARGET_DATE 统计) */
|
||||
private Long totalCount;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 今日作业准时率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||
* 准时率 = 今日实际进场时间在预约日期当天的车辆数 / 今日预约总车辆数 × 100%
|
||||
*/
|
||||
@Data
|
||||
public class RealOnTimeStatPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 今日预约总车辆数 */
|
||||
private Long total;
|
||||
|
||||
/** 今日准时车辆数(已进场且实际进场日期 = 预约日期) */
|
||||
private Long onTimeCount;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 任务类型统计(真实数据,来自 NGWL_TEST_YMS.QMS_MAIN_BUSINESS 预约登记表)
|
||||
* 按本月预约车辆数(TARGET_DATE 在当前月)以 BUSINESS_NAME 业务类型分组
|
||||
*/
|
||||
@Data
|
||||
public class RealTaskTypeStatPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 业务类型名称(qms_main_business.BUSINESS_NAME) */
|
||||
private String businessName;
|
||||
|
||||
/** 该业务类型本月预约车辆数 */
|
||||
private Long count;
|
||||
}
|
||||
+6
@@ -16,6 +16,12 @@ public class RealVehicleStatusPO implements Serializable {
|
||||
/** 当前未签到 */
|
||||
private Long notCheckedIn;
|
||||
|
||||
/** 当前等待作业(FLOW_STATUS IN '1','2','3' 已预约/已签到/已叫号) */
|
||||
private Long waiting;
|
||||
|
||||
/** 叫号状态合计:已签到 + 已叫号 + 已过号(FLOW_STATUS IN '2','3','4',预约日期为今天) */
|
||||
private Long callStatusTotal;
|
||||
|
||||
/** 当前作业中 */
|
||||
private Long operatingVehicles;
|
||||
|
||||
|
||||
+157
-6
@@ -9,12 +9,19 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
|
||||
import com.mhd.bi.domain.biPlatformSurveillance.repository.mapper.BiPlatformSurveillanceReportMapper;
|
||||
import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
|
||||
import com.mhd.bi.domain.biSnapshotSync.support.BiSnapshotWeeklyRandomDataBuilder;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO;
|
||||
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO;
|
||||
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeStatisticsVO;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeCountItemVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -91,16 +98,27 @@ public class BiPlatformRealDataService {
|
||||
if (vo.getPlatformOverview() != null) {
|
||||
fp.put("totalPlatforms", vo.getPlatformOverview().getTotalPlatforms());
|
||||
fp.put("operatingPlatforms", vo.getPlatformOverview().getOperatingPlatforms());
|
||||
fp.put("currentOccupancyRate", vo.getPlatformOverview().getCurrentOccupancyRate());
|
||||
fp.put("todayTasks", vo.getPlatformOverview().getTodayTasks());
|
||||
}
|
||||
if (vo.getEfficiencyStatistics() != null) {
|
||||
fp.put("platformOnTimeRate", vo.getEfficiencyStatistics().getPlatformOnTimeRate());
|
||||
}
|
||||
if (vo.getVehicleStatus() != null) {
|
||||
fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles());
|
||||
fp.put("notCheckedIn", vo.getVehicleStatus().getNotCheckedIn());
|
||||
fp.put("waiting", vo.getVehicleStatus().getWaiting());
|
||||
fp.put("callStatusTotal", vo.getVehicleStatus().getCallStatusTotal());
|
||||
fp.put("operatingVehicles", vo.getVehicleStatus().getOperatingVehicles());
|
||||
|
||||
|
||||
fp.put("completedVehicles", vo.getVehicleStatus().getCompletedVehicles());
|
||||
}
|
||||
|
||||
if (vo.getMonthlyTaskStatistics() != null) {
|
||||
fp.put("taskTotal", vo.getMonthlyTaskStatistics().getTaskTotal());
|
||||
fp.put("avgTaskDuration", vo.getMonthlyTaskStatistics().getAvgTaskDuration());
|
||||
fp.put("taskCompletionRate", vo.getMonthlyTaskStatistics().getTaskCompletionRate());
|
||||
}
|
||||
if (vo.getVehicles() != null) {
|
||||
List<Map<String, Object>> vehicles = new ArrayList<>();
|
||||
@@ -126,6 +144,27 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
fp.put("taskLoadStatistics", loads);
|
||||
}
|
||||
if (vo.getTaskTypeStatistics() != null) {
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
m.put("totalTasks", vo.getTaskTypeStatistics().getTotalTasks());
|
||||
if (vo.getTaskTypeStatistics().getTaskTypes() != null) {
|
||||
List<Map<String, Object>> types = new ArrayList<>();
|
||||
for (TaskTypeCountItemVO it : vo.getTaskTypeStatistics().getTaskTypes()) {
|
||||
Map<String, Object> tm = new LinkedHashMap<>();
|
||||
tm.put("type", it.getType());
|
||||
tm.put("count", it.getCount());
|
||||
types.add(tm);
|
||||
}
|
||||
m.put("taskTypes", types);
|
||||
}
|
||||
fp.put("taskTypeStatistics", m);
|
||||
}
|
||||
// 月台告警统计:按业务要求恒为 0,纳入指纹以确保旧快照(可能含非0写死值)能被覆盖更新为 0
|
||||
if (vo.getPlatformAlarmStatistics() != null) {
|
||||
fp.put("todayAlarmTotal", vo.getPlatformAlarmStatistics().getTodayAlarmTotal());
|
||||
fp.put("handled", vo.getPlatformAlarmStatistics().getHandled());
|
||||
fp.put("unhandled", vo.getPlatformAlarmStatistics().getUnhandled());
|
||||
}
|
||||
return objectMapper.writeValueAsString(fp);
|
||||
}
|
||||
|
||||
@@ -166,12 +205,34 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日作业准时率 = 今日准时车辆数 / 今日有入场时间的车辆数 × 100%(四舍五入取整)
|
||||
* 准时:实际进入时间 < 预约日期(TARGET_DATE) + 预约结束时间(BOOKING_END_TIME)。
|
||||
* 分子分母都只统计有入场时间(ENTRY_TIME 不为空)的车辆;分母为 0 时返回 0。
|
||||
*/
|
||||
public int calcTodayOnTimeRate() {
|
||||
try {
|
||||
RealOnTimeStatPO po = biPlatformRealDataMapper.queryTodayOnTimeStats();
|
||||
if (po == null) return 0;
|
||||
long total = po.getTotal() == null ? 0L : po.getTotal();
|
||||
long onTime = po.getOnTimeCount() == null ? 0L : po.getOnTimeCount();
|
||||
if (total <= 0) return 0;
|
||||
// 四舍五入到整数百分比(取整)
|
||||
return (int) Math.round(((double) onTime / (double) total) * 100.0);
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】计算今日作业准时率失败: {}", e.getMessage(), e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public RealVehicleStatusPO queryVehicleStatusToday() {
|
||||
try {
|
||||
RealVehicleStatusPO po = biPlatformRealDataMapper.queryVehicleStatusToday();
|
||||
if (po == null) po = new RealVehicleStatusPO();
|
||||
if (po.getTodayReservedVehicles() == null) po.setTodayReservedVehicles(0L);
|
||||
if (po.getNotCheckedIn() == null) po.setNotCheckedIn(0L);
|
||||
if (po.getWaiting() == null) po.setWaiting(0L);
|
||||
if (po.getCallStatusTotal() == null) po.setCallStatusTotal(0L);
|
||||
if (po.getOperatingVehicles() == null) po.setOperatingVehicles(0L);
|
||||
if (po.getCompletedVehicles() == null) po.setCompletedVehicles(0L);
|
||||
return po;
|
||||
@@ -180,10 +241,14 @@ public class BiPlatformRealDataService {
|
||||
RealVehicleStatusPO po = new RealVehicleStatusPO();
|
||||
po.setTodayReservedVehicles(0L);
|
||||
po.setNotCheckedIn(0L);
|
||||
po.setWaiting(0L);
|
||||
po.setCallStatusTotal(0L);
|
||||
po.setOperatingVehicles(0L);
|
||||
po.setCompletedVehicles(0L);
|
||||
return po;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public long countMonthTasks() {
|
||||
@@ -196,6 +261,21 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本月任务平均时长 / 完成率统计:
|
||||
* - avgDurationHours:累计(EXIT_TIME - ENTRY_TIME)小时数 / 参与数;任一为空的行不参与
|
||||
* - taskCompletionRate:已完成(EXIT_TIME 不为空 且 预约日期在本月)/ 本月预约总数量 ×100
|
||||
* 任一查询失败均返回 null,由调用方决定是否覆盖模板值。
|
||||
*/
|
||||
public RealMonthlyTaskDurationPO queryMonthTaskStats() {
|
||||
try {
|
||||
return biPlatformRealDataMapper.queryMonthTaskStats();
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】统计本月任务平均时长/完成率失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<RealTaskLoadPO> queryTaskLoadToday() {
|
||||
try {
|
||||
return biPlatformRealDataMapper.queryTaskLoadToday();
|
||||
@@ -205,6 +285,35 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务类型统计:本月(YMS QMS_MAIN_BUSINESS)预约车辆按业务类型 BUSINESS_NAME 分组;
|
||||
* 返回 {totalTasks: 当月总预约车辆数, taskTypes: [{type: 业务类型名称, count: 该类型预约数}]}
|
||||
* 按真实 BUSINESS_NAME 分组输出,不固定兜底类别;当月无数据或查询失败时返回空列表。
|
||||
*/
|
||||
public TaskTypeStatisticsVO queryMonthTransportOrderByType() {
|
||||
List<TaskTypeCountItemVO> items = new ArrayList<>();
|
||||
int total = 0;
|
||||
try {
|
||||
List<RealTaskTypeStatPO> rows = biPlatformRealDataMapper.queryMonthTransportOrderByType();
|
||||
if (rows != null) {
|
||||
for (RealTaskTypeStatPO r : rows) {
|
||||
if (r == null || r.getBusinessName() == null || r.getCount() == null) {
|
||||
continue;
|
||||
}
|
||||
int c = r.getCount().intValue();
|
||||
items.add(TaskTypeCountItemVO.builder().type(r.getBusinessName()).count(c).build());
|
||||
total += c;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】统计当月预约业务类型失败: {}", e.getMessage(), e);
|
||||
// 查询失败返回空列表(前端会显示空)
|
||||
items = new ArrayList<>();
|
||||
total = 0;
|
||||
}
|
||||
return TaskTypeStatisticsVO.builder().totalTasks(total).taskTypes(items).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日预约-业务类型统计:按业务类型分组统计今日预约数量。
|
||||
* 例:今日预约航空打板 3 条 → 返回 {businessName:"航空打板", count:3}
|
||||
@@ -271,29 +380,68 @@ public class BiPlatformRealDataService {
|
||||
template.setVehicles(vehicleVos);
|
||||
|
||||
// 月台实时概览:真实数据源,无条件覆盖
|
||||
// 总月台 / 占用月台 来源:YMS 月台管理列表 QMS_WINDOW_INFO(JOB_STATUS=1 表示占用)
|
||||
// 月台占用率 = 占用 / 全部月台
|
||||
// 今日作业任务 来源:QMS_MAIN_BUSINESS 按预约时间 TARGET_DATE = 今天 的全部数量
|
||||
// 作业准时率 = 今日(实际进场时间在预约日期当天的车辆数) / 今日预约车辆总数 × 100%
|
||||
if (template.getPlatformOverview() != null) {
|
||||
RealPlatformOverviewPO ov = queryPlatformOverview();
|
||||
int total = ov.getTotalPlatforms().intValue();
|
||||
int occ = ov.getOperatingPlatforms().intValue();
|
||||
List<RealPlatformInfoPO> platformList = queryPlatformInfoList();
|
||||
int total = platformList == null ? 0 : platformList.size();
|
||||
int occ = 0;
|
||||
if (platformList != null) {
|
||||
for (RealPlatformInfoPO p : platformList) {
|
||||
if (p != null && p.getJobStatus() != null && p.getJobStatus() == 1) {
|
||||
occ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d;
|
||||
int todayTasks = (int) countTodayTasks();
|
||||
template.getPlatformOverview().setTotalPlatforms(total);
|
||||
template.getPlatformOverview().setOperatingPlatforms(occ);
|
||||
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
||||
template.getPlatformOverview().setTodayTasks((int) countTodayTasks());
|
||||
template.getPlatformOverview().setTodayTasks(todayTasks);
|
||||
|
||||
// 作业准时率(实际进入时间 < 预约日期+预约结束时间 的车辆 / 今日预约总数 × 100% 取整)
|
||||
if (template.getEfficiencyStatistics() != null) {
|
||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(calcTodayOnTimeRate());
|
||||
}
|
||||
}
|
||||
|
||||
// 作业车辆状态统计:真实数据源,无条件覆盖
|
||||
// 作业车辆状态统计:真实数据源,无条件覆盖(含等待作业 waiting = 今日预约且 已预约/已签到/已叫号)
|
||||
if (template.getVehicleStatus() != null) {
|
||||
RealVehicleStatusPO vs = queryVehicleStatusToday();
|
||||
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
||||
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
||||
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
||||
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
|
||||
template.getVehicleStatus().setCallStatusTotal(vs.getCallStatusTotal().intValue());
|
||||
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
|
||||
|
||||
|
||||
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
|
||||
}
|
||||
|
||||
// 本月任务统计:taskTotal 有真实数据源无条件覆盖;YoY 等无真实数据源保留模板写死值
|
||||
|
||||
// 本月任务统计:taskTotal / avgTaskDuration / taskCompletionRate 均有真实数据源,无条件覆盖;YoY 保留模板写死值
|
||||
if (template.getMonthlyTaskStatistics() != null) {
|
||||
template.getMonthlyTaskStatistics().setTaskTotal((int) countMonthTasks());
|
||||
RealMonthlyTaskDurationPO monthStats = queryMonthTaskStats();
|
||||
if (monthStats != null) {
|
||||
if (monthStats.getAvgDurationHours() != null) {
|
||||
// 保留两位小数
|
||||
double v = monthStats.getAvgDurationHours();
|
||||
template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0);
|
||||
}
|
||||
Long total = monthStats.getTotalCount();
|
||||
Long completed = monthStats.getCompletedCount();
|
||||
if (total != null && total > 0 && completed != null) {
|
||||
int rate = (int) Math.round(((double) completed.longValue() / total.longValue()) * 100.0);
|
||||
template.getMonthlyTaskStatistics().setTaskCompletionRate(rate);
|
||||
} else {
|
||||
template.getMonthlyTaskStatistics().setTaskCompletionRate(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 任务负荷:有真实数据源;真实为空则清空不用模板模拟,有数据则按真实小时覆盖
|
||||
@@ -313,6 +461,9 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
// 任务类型统计:本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组(真实业务数据)
|
||||
template.setTaskTypeStatistics(queryMonthTransportOrderByType());
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -87,7 +87,9 @@ public final class BiReportSnapshotMapperSupport {
|
||||
.platformOverview(PlatformOverviewVO.builder()
|
||||
.totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0).build())
|
||||
.vehicleStatus(VehicleStatusVO.builder()
|
||||
.todayReservedVehicles(0).notCheckedIn(0).operatingVehicles(0).completedVehicles(0).build())
|
||||
.todayReservedVehicles(0).notCheckedIn(0).waiting(0)
|
||||
.callStatusTotal(0)
|
||||
.operatingVehicles(0).completedVehicles(0).build())
|
||||
.avgOperationDurationTrend(Collections.emptyList())
|
||||
.monthlyTaskStatistics(MonthlyTaskStatisticsVO.builder()
|
||||
.taskTotal(0).taskTotalYoY(0).avgTaskDuration(0d).avgDurationYoY(0)
|
||||
|
||||
+49
-11
@@ -16,7 +16,7 @@ import com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.WarehouseOperat
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.service.BiPlatformRealDataService;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformVehiclePO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformOverviewPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -173,18 +173,31 @@ public class BiReportSnapshotSyncService {
|
||||
}
|
||||
|
||||
// ====== 真实数据:月台实时概览 ======
|
||||
RealPlatformOverviewPO ov = biPlatformRealDataService.queryPlatformOverview();
|
||||
// 总月台 / 占用月台 来源:YMS 月台管理列表 QMS_WINDOW_INFO(JOB_STATUS=1 表示占用)
|
||||
// 月台占用率 = 占用 / 全部月台
|
||||
// 今日作业任务 来源:QMS_MAIN_BUSINESS 按预约时间 TARGET_DATE = 今天 的全部数量
|
||||
if (template.getPlatformOverview() != null) {
|
||||
template.getPlatformOverview().setTotalPlatforms(ov.getTotalPlatforms().intValue());
|
||||
template.getPlatformOverview().setOperatingPlatforms(ov.getOperatingPlatforms().intValue());
|
||||
int total = ov.getTotalPlatforms().intValue();
|
||||
int occ = ov.getOperatingPlatforms().intValue();
|
||||
List<RealPlatformInfoPO> platformList = biPlatformRealDataService.queryPlatformInfoList();
|
||||
int total = platformList == null ? 0 : platformList.size();
|
||||
int occ = 0;
|
||||
if (platformList != null) {
|
||||
for (RealPlatformInfoPO p : platformList) {
|
||||
if (p != null && p.getJobStatus() != null && p.getJobStatus() == 1) {
|
||||
occ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d;
|
||||
int todayTasks = (int) biPlatformRealDataService.countTodayTasks();
|
||||
template.getPlatformOverview().setTotalPlatforms(total);
|
||||
template.getPlatformOverview().setOperatingPlatforms(occ);
|
||||
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
||||
}
|
||||
long todayTasks = biPlatformRealDataService.countTodayTasks();
|
||||
if (template.getPlatformOverview() != null) {
|
||||
template.getPlatformOverview().setTodayTasks((int) todayTasks);
|
||||
template.getPlatformOverview().setTodayTasks(todayTasks);
|
||||
|
||||
// 作业准时率 = 实际进入时间 < 预约日期+预约结束时间 的车辆 / 今日预约总数 × 100%(取整)
|
||||
if (template.getEfficiencyStatistics() != null) {
|
||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(biPlatformRealDataService.calcTodayOnTimeRate());
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 真实数据:作业车辆状态统计 ======
|
||||
@@ -192,14 +205,36 @@ public class BiReportSnapshotSyncService {
|
||||
if (template.getVehicleStatus() != null) {
|
||||
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
||||
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
||||
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
||||
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
|
||||
template.getVehicleStatus().setCallStatusTotal(vs.getCallStatusTotal() == null ? 0 : vs.getCallStatusTotal().intValue());
|
||||
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
|
||||
|
||||
|
||||
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
|
||||
|
||||
}
|
||||
|
||||
// ====== 真实数据:本月任务统计 taskTotal ======
|
||||
// ====== 真实数据:本月任务统计 taskTotal / avgTaskDuration / taskCompletionRate ======
|
||||
long monthTasks = biPlatformRealDataService.countMonthTasks();
|
||||
if (template.getMonthlyTaskStatistics() != null) {
|
||||
template.getMonthlyTaskStatistics().setTaskTotal((int) monthTasks);
|
||||
com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO monthStats =
|
||||
biPlatformRealDataService.queryMonthTaskStats();
|
||||
if (monthStats != null) {
|
||||
if (monthStats.getAvgDurationHours() != null) {
|
||||
double v = monthStats.getAvgDurationHours();
|
||||
template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0);
|
||||
}
|
||||
Long total = monthStats.getTotalCount();
|
||||
Long completed = monthStats.getCompletedCount();
|
||||
if (total != null && total > 0 && completed != null) {
|
||||
int rate = (int) Math.round(((double) completed.longValue() / total.longValue()) * 100.0);
|
||||
template.getMonthlyTaskStatistics().setTaskCompletionRate(rate);
|
||||
} else {
|
||||
template.getMonthlyTaskStatistics().setTaskCompletionRate(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 真实数据:任务负荷(今日 24 小时) ======
|
||||
@@ -218,6 +253,9 @@ public class BiReportSnapshotSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 真实数据:任务类型统计(本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组) ======
|
||||
template.setTaskTypeStatistics(biPlatformRealDataService.queryMonthTransportOrderByType());
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
+9
-16
@@ -155,10 +155,13 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
VehicleStatusVO vs = VehicleStatusVO.builder()
|
||||
.todayReservedVehicles(Math.max(0, jitterInt(Baseline.P_RESV, r)))
|
||||
.notCheckedIn(Math.max(0, jitterInt(Baseline.P_NC, r)))
|
||||
.waiting(Math.max(0, jitterInt(Baseline.P_WAIT, r)))
|
||||
.callStatusTotal(Math.max(0, jitterInt(Baseline.P_CALL_STATUS_TOTAL, r)))
|
||||
.operatingVehicles(Math.max(0, jitterInt(Baseline.P_OPV, r)))
|
||||
.completedVehicles(Math.max(0, jitterInt(Baseline.P_DONE, r)))
|
||||
.build();
|
||||
|
||||
|
||||
List<AvgOperationDurationTrendItemVO> avgTrend = new ArrayList<>();
|
||||
for (int i = 0; i < Baseline.P_MO_LABELS.length; i++) {
|
||||
avgTrend.add(AvgOperationDurationTrendItemVO.builder()
|
||||
@@ -185,13 +188,8 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
.build());
|
||||
}
|
||||
|
||||
// 月台告警:按业务要求,全部置 0(趋势/统计/分布均不生成写死数据)
|
||||
List<PlatformAlarmTrendItemVO> alarmTrend = new ArrayList<>();
|
||||
for (int i = 0; i < Baseline.P_AL_D.length; i++) {
|
||||
alarmTrend.add(PlatformAlarmTrendItemVO.builder()
|
||||
.date(Baseline.P_AL_D[i])
|
||||
.alarmCount(Math.max(0, jitterInt(Baseline.P_AL_C[i], r)))
|
||||
.build());
|
||||
}
|
||||
|
||||
List<TaskTypeCountItemVO> typeCounts = new ArrayList<>();
|
||||
for (int i = 0; i < Baseline.P_TT_TYPES.length; i++) {
|
||||
@@ -201,18 +199,11 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
.build());
|
||||
}
|
||||
|
||||
int todayAl = Math.max(0, jitterInt(Baseline.P_AL_TOT, r));
|
||||
int handled = Math.max(0, jitterInt(Baseline.P_AL_H, r));
|
||||
handled = Math.min(handled, todayAl);
|
||||
int unhandled = Math.max(0, todayAl - handled);
|
||||
int todayAl = 0;
|
||||
int handled = 0;
|
||||
int unhandled = 0;
|
||||
|
||||
List<PlatformAlarmDistItemVO> dist = new ArrayList<>();
|
||||
for (int i = 0; i < Baseline.P_DIST_T.length; i++) {
|
||||
dist.add(PlatformAlarmDistItemVO.builder()
|
||||
.type(Baseline.P_DIST_T[i])
|
||||
.count(Math.max(0, jitterInt(Baseline.P_DIST_C[i], r)))
|
||||
.build());
|
||||
}
|
||||
|
||||
return PlatformSurveillanceVO.builder()
|
||||
.vehicles(vehicles)
|
||||
@@ -415,6 +406,8 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
static final int P_TASKS = 418;
|
||||
static final int P_RESV = 2_850;
|
||||
static final int P_NC = 920;
|
||||
static final int P_WAIT = 680;
|
||||
static final int P_CALL_STATUS_TOTAL = 680;
|
||||
static final int P_OPV = 1_180;
|
||||
static final int P_DONE = 1_420;
|
||||
static final String[] P_MO_LABELS = {"5月", "6月", "7月"};
|
||||
|
||||
+6
@@ -20,6 +20,12 @@ public class VehicleStatusVO {
|
||||
@ApiModelProperty("当前未签到,单位:辆")
|
||||
private Integer notCheckedIn;
|
||||
|
||||
@ApiModelProperty("当前等待作业(已预约/已签到/已叫号),单位:辆")
|
||||
private Integer waiting;
|
||||
|
||||
@ApiModelProperty("已签到+已叫号+已过号(FLOW_STATUS IN 2/3/4),单位:辆")
|
||||
private Integer callStatusTotal;
|
||||
|
||||
@ApiModelProperty("当前作业中,单位:辆")
|
||||
private Integer operatingVehicles;
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ spring:
|
||||
# username: nacos
|
||||
# password: manhuoda@2023
|
||||
#线上正式环境
|
||||
server-addr: 10.102.192.30:6848
|
||||
server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
config:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
# server-addr: 10.33.0.129:6010
|
||||
server-addr: 10.102.192.30:6848
|
||||
server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
#线上正式环境
|
||||
|
||||
@@ -40,35 +40,85 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
FROM NGWL_TEST_YMS.QMS_WINDOW_INFO
|
||||
</select>
|
||||
|
||||
<!-- 今日作业任务:实际进入时间是今日的 -->
|
||||
<!-- 今日作业任务:按预约时间 TARGET_DATE(今日)统计主业务记录数 -->
|
||||
<select id="countTodayTasks" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE ENTRY_TIME IS NOT NULL
|
||||
AND TRUNC(ENTRY_TIME) = TRUNC(SYSDATE)
|
||||
WHERE TARGET_DATE IS NOT NULL
|
||||
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
|
||||
</select>
|
||||
|
||||
<!-- 今日作业准时率统计:
|
||||
total 今日有入场时间的预约车辆数(ENTRY_TIME 不为空 且 TARGET_DATE = 今天)
|
||||
onTimeCount 今日准时车辆数(实际进入时间 < 预约日期 + 预约结束时间 BOOKING_END_TIME,即 ENTRY_TIME < TRUNC(TARGET_DATE) + 预约时段结束时分)
|
||||
「准时率 = 今日准时车辆数 / 今日有入场时间的车辆数 × 100%(四舍五入取整);分子分母都只统计有入场时间的车辆」
|
||||
BOOKING_END_TIME 存纯时分(如 18:30),故用 TO_DATE 解析后取其时分间隔加到 TARGET_DATE 上
|
||||
-->
|
||||
<select id="queryTodayOnTimeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO">
|
||||
SELECT
|
||||
SUM(CASE WHEN ENTRY_TIME IS NOT NULL
|
||||
AND TARGET_DATE IS NOT NULL
|
||||
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS total,
|
||||
SUM(CASE WHEN ENTRY_TIME IS NOT NULL
|
||||
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
|
||||
AND ENTRY_TIME < TRUNC(TARGET_DATE)
|
||||
+ (TO_DATE(BOOKING_END_TIME, 'HH24:MI') - TRUNC(TO_DATE(BOOKING_END_TIME, 'HH24:MI')))
|
||||
THEN 1 ELSE 0 END) AS onTimeCount
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
</select>
|
||||
|
||||
<!-- 车辆状态统计:今日的统计(按创建时间 CREATE_TIME / 流程状态)
|
||||
todayReservedVehicles 改为按预约日期 TARGET_DATE(其它 3 项保持 CREATE_TIME)
|
||||
waiting 等待作业:FLOW_STATUS IN ('1','2','3') 已预约/已签到/已叫号 且 预约日期 = 今天
|
||||
callStatusTotal 叫号状态合计:已签到 + 已叫号 + 已过号 = FLOW_STATUS IN ('2','3','4') 且 预约日期 = 今天
|
||||
FLOW_STATUS: 1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消 -->
|
||||
<select id="queryVehicleStatusToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO">
|
||||
SELECT
|
||||
SUM(CASE WHEN TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS todayReservedVehicles,
|
||||
SUM(CASE WHEN FLOW_STATUS = '1' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS notCheckedIn,
|
||||
SUM(CASE WHEN FLOW_STATUS IN ('1','2','3') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS waiting,
|
||||
SUM(CASE WHEN FLOW_STATUS IN ('2','3','4') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS callStatusTotal,
|
||||
SUM(CASE WHEN FLOW_STATUS IN ('5','6','7','8','9','10') AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS operatingVehicles,
|
||||
SUM(CASE WHEN FLOW_STATUS = '11' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS completedVehicles
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
</select>
|
||||
|
||||
<!-- 本月任务量:实际进入时间是本月的 -->
|
||||
|
||||
|
||||
<!-- 本月任务量:按预约日期 TARGET_DATE(Y预约日期)统计本月预约总数量 -->
|
||||
<select id="countMonthTasks" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE ENTRY_TIME IS NOT NULL
|
||||
AND TO_CHAR(ENTRY_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
WHERE TARGET_DATE IS NOT NULL
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
</select>
|
||||
|
||||
<!-- 今日预约-业务名称统计:按 BUSINESS_NAME(业务名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
|
||||
<!-- 本月任务平均作业时长 / 完成率统计:
|
||||
avgDurationHours 平均时长(小时)= AVG((EXIT_TIME - ENTRY_TIME) * 24)
|
||||
仅 ENTRY_TIME 与 EXIT_TIME 都不为空时参与;
|
||||
durationCount 参与平均时长统计的有效条数;
|
||||
completedCount 本月(TARGET_DATE)已出场(EXIT_TIME IS NOT NULL)的数量;
|
||||
totalCount 本月(TARGET_DATE)预约总数量。
|
||||
-->
|
||||
<select id="queryMonthTaskStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO">
|
||||
SELECT
|
||||
AVG(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
|
||||
THEN (EXIT_TIME - ENTRY_TIME) * 24
|
||||
END) AS avgDurationHours,
|
||||
SUM(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
|
||||
AND TO_CHAR(ENTRY_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
THEN 1 ELSE 0 END) AS durationCount,
|
||||
SUM(CASE WHEN EXIT_TIME IS NOT NULL
|
||||
AND TARGET_DATE IS NOT NULL
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
THEN 1 ELSE 0 END) AS completedCount,
|
||||
SUM(CASE WHEN TARGET_DATE IS NOT NULL
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
THEN 1 ELSE 0 END) AS totalCount
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
</select>
|
||||
|
||||
<!-- 今日预约-业务类型统计:按 BUSINESS_NAME(业务类型名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
|
||||
<select id="queryTodayBusinessTypeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO">
|
||||
SELECT
|
||||
BUSINESS_NAME AS businessName,
|
||||
@@ -102,6 +152,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ORDER BY 1 DESC
|
||||
</select>
|
||||
|
||||
<!-- 任务类型统计(来自 NGWL_TEST_YMS.QMS_MAIN_BUSINESS 预约登记表):
|
||||
按本月预约车辆数(TARGET_DATE 在当前月)按 BUSINESS_NAME 业务类型分组统计 -->
|
||||
<select id="queryMonthTransportOrderByType" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO">
|
||||
SELECT
|
||||
BUSINESS_NAME AS businessName,
|
||||
COUNT(1) AS count
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE BUSINESS_NAME IS NOT NULL
|
||||
AND TARGET_DATE IS NOT NULL
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
GROUP BY BUSINESS_NAME
|
||||
ORDER BY COUNT(1) DESC
|
||||
</select>
|
||||
|
||||
<!-- 任务负荷(今日 24 小时时段):按 EXTRACT(HOUR FROM ENTRY_TIME) 统计 -->
|
||||
<select id="queryTaskLoadToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO">
|
||||
SELECT
|
||||
|
||||
+1
@@ -26,6 +26,7 @@ import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-third-party-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(value = "mhd-third-party-service",url = "http://10.102.192.31:8012", configuration = FeignAutoConfiguration.class)
|
||||
public interface ThirdPartyServiceFeign {
|
||||
|
||||
|
||||
@@ -13,16 +13,16 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
server-addr: 10.33.0.129:6010
|
||||
server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.33.0.129:6010
|
||||
# server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
#线上正式环境
|
||||
# server-addr: 10.102.192.105:6848
|
||||
config:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
server-addr: 10.33.0.129:6010
|
||||
server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.33.0.129:6010
|
||||
# server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
|
||||
+61
@@ -97,6 +97,7 @@ import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.user.interfaces.dto.addDTO.UserDriverDTO;
|
||||
import com.mhd.user.interfaces.dto.queryDTO.UserDocumentWarningQueryDTO;
|
||||
import com.mhd.user.interfaces.dto.updateDTO.UpdateHasDefaultAddressDTO;
|
||||
import com.mhd.user.interfaces.dto.updateDTO.PasswordChangeDTO;
|
||||
import com.mhd.user.interfaces.facadeApi.Po.UserDriverCountPo;
|
||||
import com.mhd.user.interfaces.vo.QueryAllShipperInfoVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -214,6 +215,61 @@ public class UserApplicationService {
|
||||
@Autowired
|
||||
private UserShipperMapper userShipperMapper;
|
||||
|
||||
/**
|
||||
* 修改密码 - 同步 wlhy 与 yms
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void changePassword(PasswordChangeDTO passwordChangeDTO) {
|
||||
// 1. 获取当前登录用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
|
||||
Long userId = loginUser.getUserPo().getUserId();
|
||||
if (userId == null) {
|
||||
throw new ServiceException("用户未登录");
|
||||
}
|
||||
|
||||
// 2. 查询用户信息
|
||||
UserPo userPO = userDomainService.selectByUserId(userId);
|
||||
UserEntity userEntity = new UserEntity();
|
||||
BeanUtils.copyProperties(userPO,userEntity);
|
||||
if (ObjectUtil.isNull(userEntity)) {
|
||||
throw new ServiceException("用户不存在");
|
||||
}
|
||||
|
||||
// 3. 解密并加密新密码
|
||||
String salt = userEntity.getUserSalt();
|
||||
String newPassword = decrypt(passwordChangeDTO.getNewPassword());
|
||||
String encodedPassword = PasswordUtil.encrypt(userEntity.getUserAccount(), newPassword, salt);
|
||||
|
||||
// 4. 更新本地密码
|
||||
UserDO userDO = new UserDO();
|
||||
userDO.setUserId(userId);
|
||||
userDO.setUserPassword(encodedPassword);
|
||||
userDomainService.updateUser(userDO);
|
||||
|
||||
// 5. 同步到网货平台(wlhy)
|
||||
try {
|
||||
userEntity.setUserPassword(encodedPassword);
|
||||
wlhyDomainService.addOrEditPlatformUser(userEntity);
|
||||
} catch (Exception e) {
|
||||
log.warn("同步密码到网货平台失败,但不影响主流程:{}", e.getMessage());
|
||||
}
|
||||
|
||||
// 6. 同步到 YMS 平台
|
||||
try {
|
||||
Integer isQueue = userMapper.getOrdIsQueue(userEntity.getOrganizationId());
|
||||
if (isQueue != null && isQueue == 1) {
|
||||
userEntity.setUserPassword(newPassword);
|
||||
ymsDomainService.addOrEditYmsUser(userEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("同步密码到 YMS 平台失败,但不影响主流程:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description 查询用户列表
|
||||
* @Author Alex
|
||||
@@ -1971,6 +2027,11 @@ public class UserApplicationService {
|
||||
if (StrUtil.isEmpty(userDO.getUserName())) {
|
||||
userDO.setUserName("用户" + userDO.getUserPhone().substring(userDO.getUserPhone().length() - 4));
|
||||
}
|
||||
//密码为空则给默认密码
|
||||
if (StrUtil.isEmpty(userDO.getUserPassword())) {
|
||||
String defaultPassword = "Aa123456";
|
||||
userDO.setUserPassword(PasswordUtil.encrypt(userDO.getUserAccount(), defaultPassword, userDO.getUserSalt()));
|
||||
}
|
||||
UserEntity userEntity = userDomainService.addUser(userDO);
|
||||
//给小程序注册用户分配默认普通用户角色(must),本组织没有则找上级
|
||||
userEntity.setUserPassword("Aa123456"); // 三方同步需要密码
|
||||
|
||||
+1
@@ -100,6 +100,7 @@ public class UserYmsDomainService {
|
||||
ymsSysUserDTO.setPhonenumber(userEntity.getUserPhone());
|
||||
ymsSysUserDTO.setAvatar(userEntity.getAvatar());
|
||||
ymsSysUserDTO.setUserAccountType(userEntity.getUserAccountType());
|
||||
ymsSysUserDTO.setPassword(userEntity.getUserPassword());
|
||||
|
||||
if (StringUtils.isNotBlank(userEntity.getRoleCode())){
|
||||
ymsSysUserDTO.setRoleCodes(Arrays.asList(userEntity.getRoleCode().split(",")));
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.mhd.user.interfaces.dto.updateDTO;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 修改密码 DTO
|
||||
* @author AI
|
||||
* @date 2026/09/10
|
||||
*/
|
||||
@Data
|
||||
public class PasswordChangeDTO {
|
||||
|
||||
/**
|
||||
* 新密码
|
||||
*/
|
||||
@NotBlank(message = "新密码不能为空")
|
||||
private String newPassword;
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.mhd.common.security.annotation.InnerAuth;
|
||||
import com.mhd.common.security.service.TokenService;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import com.mhd.user.interfaces.dto.queryDTO.UserDocumentWarningQueryDTO;
|
||||
import com.mhd.user.interfaces.dto.updateDTO.PasswordChangeDTO;
|
||||
import com.mhd.user.interfaces.dto.updateDTO.UpdateHasDefaultAddressDTO;
|
||||
import com.mhd.user.interfaces.vo.QueryAllShipperInfoVo;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -1037,4 +1038,16 @@ public class UserAPI extends BaseController {
|
||||
public R<String> finShipperEnterpriseNamedByUserId(@PathVariable("userId") Long userId) {
|
||||
return R.ok(userApplicationService.finShipperEnterpriseNamedByUserId(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码 - 同步 wlhy 与 yms
|
||||
* 根据当前登录用户判断是谁修改,只传新密码,不需要校验旧密码
|
||||
*/
|
||||
@Log(title = "用户中台管理 - 修改密码", description ="修改当前登录用户密码",businessType = BusinessType.UPDATE)
|
||||
@ApiOperation("修改密码")
|
||||
@PostMapping("/changePassword")
|
||||
public AjaxResult changePassword(@RequestBody PasswordChangeDTO passwordChangeDTO) {
|
||||
userApplicationService.changePassword(passwordChangeDTO);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,15 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.33.0.129:6010
|
||||
server-addr: 10.102.192.31:6848
|
||||
# server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
config:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.33.0.129:6010
|
||||
server-addr: 10.102.192.31:6848
|
||||
# server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置
|
||||
@@ -50,3 +50,7 @@ feign:
|
||||
mhd-third-party-service:
|
||||
connectTimeout: 10000
|
||||
readTimeout: 120000
|
||||
#wechat:
|
||||
# miniapp:
|
||||
# appId: wxc9dd2810a77e4e30
|
||||
# appSecret: 9354ff1215a82785ef14f2355fbf2185
|
||||
+554
@@ -0,0 +1,554 @@
|
||||
package com.mhd.oms.application.service.businessDocumentOrder;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjust.entity.BusinessDocumentOrderAdjust;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjust.repository.mapper.BusinessDocumentOrderAdjustMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity.BusinessDocumentOrderAdjustDetail;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.repository.mapper.BusinessDocumentOrderAdjustDetailMapper;
|
||||
import com.mhd.oms.domain.businessOrderAccount.BusinessOrderAccount;
|
||||
import com.mhd.oms.domain.businessOrderAccount.repository.mapper.BusinessOrderAccountMapper;
|
||||
import com.mhd.oms.domain.executeOrder.entity.ExecuteOrder;
|
||||
import com.mhd.oms.domain.executeOrder.repository.mapper.ExecuteOrderMapper;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustAuditDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustQueryDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustRecordDTO;
|
||||
import com.mhd.system.api.WlhyServiceFeign;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 运输业务单「订单调整」应用服务
|
||||
*
|
||||
* 规则(定稿):
|
||||
* 1. 每次调整都生成:1 条主记录 + 1 条明细快照
|
||||
* 2. 费用数据源 = 前端回传的费用明细 business_order_account(feeDetailList);
|
||||
* 主表金额 deliveryFreight 为其 amount 合计(冗余汇总,后端自动算)。
|
||||
* 3. 是否需审核:一旦任一「金额」发生变化
|
||||
* = feeDetailList 明细 amount 变化,或主表金额列变化 -> 走业务主管审核;
|
||||
* 否则(仅改非金额字段) -> 直通。
|
||||
* 4. 涉及金额提交 -> 仅把业务单 review_status 置为「调整待审核(3)」;主记录 AUDIT_STATUS=0(待审核);
|
||||
* 不更新业务单数据,不影响其它状态(order_status / execute_status 不动)。
|
||||
* 5. 审核通过 -> 覆盖业务单(金额) + 替换费用明细;review_status 一律置为 1(已审核),
|
||||
* 不影响 order_status / execute_status。
|
||||
* 审核驳回 -> 不更新业务单数据,review_status 还原为调整前值(主记录 before_review_status),可再次调整。
|
||||
* 6. 直通(未改金额) -> 覆盖业务单可编辑字段 + deliveryFreight(明细合计),并替换 business_order_account
|
||||
* (逻辑删旧 is_delete=1 + 插新 is_delete=0);不改动任何审核/执行状态。
|
||||
* 7. 前端以 amountChanged 告知是否改金额(默认前端判定);未传时后端兜底比对。
|
||||
*
|
||||
* 说明:review_status 原枚举 0未审/1通过/2驳回,新增 3=调整待审核;不改变原有用例。
|
||||
*
|
||||
* @author dev
|
||||
* @date 2026-09-09
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BusinessDocumentOrderAdjustService {
|
||||
|
||||
private static final Integer AUDIT_WAIT = 0; // 调整记录:待审核
|
||||
private static final Integer AUDIT_PASS = 1; // 调整记录:审核通过
|
||||
private static final Integer AUDIT_REJECT = 2; // 调整记录:驳回
|
||||
|
||||
/** 主表金额(费用)字段,任一变化触发审核 */
|
||||
private static final List<String> FEE_FIELDS = Arrays.asList(
|
||||
"deliveryFreight", "collectedFreight", "uncollectedFreight", "collectLessFreight",
|
||||
"transportationUnitPrice", "infoFee", "freightUnitPrice", "cargoInsuranceAmount",
|
||||
"freightCharges", "freightFee", "unloadingFee", "customsFee", "shortageFee",
|
||||
"miscellaneousFee", "otherFee", "detentionFee");
|
||||
|
||||
/** 不允许被前端调整覆盖的系统字段 */
|
||||
private static final List<String> PROTECTED_FIELDS = Arrays.asList(
|
||||
"id", "goodsNumber",
|
||||
"orderStatus", "reviewStatus", "reviewId", "review", "reviewTime", "reviewOpinion",
|
||||
"salesManager", "auditStatus", "auditBy", "auditTime",
|
||||
"executeStatus", "executeId", "executeTime", "executor",
|
||||
"executeOrderId", "executeOrderNumber", "adjustStatus",
|
||||
"isDelete", "delFlag", "createBy", "createByName", "createTime",
|
||||
"updateBy", "updateByName", "updateTime",
|
||||
"pushStatus", "pushTime", "pushBy", "pushByName",
|
||||
"reviseApplyType", "reviseApplyStatus", "reviseApplyBy", "reviseApplyByName",
|
||||
"reviseApplyReason", "reviseApplyTime",
|
||||
"reservationOrderId", "reservationOrderNumber",
|
||||
"mainOrderId", "mainOrderNum", "mergeOrderId", "mergeOrderNum",
|
||||
"splicingOrderType", "splicingStatus", "deliveryProgress",
|
||||
"orgId", "orgName", "organizationId", "organizationName", "topOrganizationId",
|
||||
"realCreateBy", "realCreateName", "createCompanyId", "createUserId",
|
||||
"szwlUserId"
|
||||
);
|
||||
|
||||
@Autowired
|
||||
private BusinessDocumentOrderMapper businessDocumentOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private BusinessOrderAccountMapper businessOrderAccountMapper;
|
||||
|
||||
@Autowired
|
||||
private BusinessDocumentOrderAdjustMapper adjustMapper;
|
||||
|
||||
@Autowired
|
||||
private BusinessDocumentOrderAdjustDetailMapper adjustDetailMapper;
|
||||
|
||||
@Autowired
|
||||
private ExecuteOrderMapper executeOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private WlhyServiceFeign wlhyServiceFeign;
|
||||
|
||||
/**
|
||||
* 提交调整
|
||||
* 返回 data = [是否需审核, 调整记录ID]
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult adjust(BusinessDocumentOrderAdjustDTO dto) {
|
||||
if (dto == null || dto.getOrder() == null || dto.getOrder().getId() == null) {
|
||||
throw new ServiceException("参数错误:缺少业务单ID(order.id)");
|
||||
}
|
||||
BusinessDocumentOrder dbOrder = businessDocumentOrderMapper.selectById(dto.getOrder().getId());
|
||||
if (ObjectUtil.isNull(dbOrder)) {
|
||||
throw new ServiceException("业务单不存在或已被删除");
|
||||
}
|
||||
BusinessDocumentOrder front = dto.getOrder();
|
||||
|
||||
// 1. 当前库中费用明细
|
||||
List<BusinessOrderAccount> dbFeeList = businessOrderAccountMapper.selectList(
|
||||
new LambdaQueryWrapper<BusinessOrderAccount>()
|
||||
.eq(BusinessOrderAccount::getOrderId, dbOrder.getId())
|
||||
.eq(BusinessOrderAccount::getIsDelete, 0));
|
||||
|
||||
// 2. 调整后的费用明细(前端);为 null 则视为保持库中不变
|
||||
List<BusinessOrderAccount> newFeeList = dto.getFeeDetailList();
|
||||
|
||||
// 3. 生成"调整后"业务单对象:DB原值 + 前端可编辑字段覆盖(忽略null)
|
||||
BusinessDocumentOrder afterOrder = buildAfterOrder(dbOrder, front);
|
||||
|
||||
// 4. 若提供了费用明细,则 deliveryFreight(合计)=明细 amount 之和,并联动到 afterOrder
|
||||
boolean hasFeeDetail = newFeeList != null && !newFeeList.isEmpty();
|
||||
if (hasFeeDetail) {
|
||||
BigDecimal sum = sumAmount(newFeeList);
|
||||
afterOrder.setDeliveryFreight(sum);
|
||||
}
|
||||
|
||||
// 5. 判定是否修改了金额:以前端 amountChanged 为准(前端整单回传已自行判定);
|
||||
// 若前端未传则后端兜底比对(主表金额列 或 明细 amount 变化)
|
||||
boolean amountChanged;
|
||||
if (dto.getAmountChanged() != null) {
|
||||
amountChanged = dto.getAmountChanged();
|
||||
} else {
|
||||
amountChanged = isAmountChanged(dbOrder, front, hasFeeDetail, dbFeeList, newFeeList);
|
||||
}
|
||||
|
||||
// 6. 写主记录
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Date now = new Date();
|
||||
BusinessDocumentOrderAdjust adjust = buildAdjust(dbOrder, loginUser, now, amountChanged, dto.getAdjustReason());
|
||||
adjustMapper.insert(adjust);
|
||||
|
||||
// 7. 写明细快照(调整后业务单整行 + 费用明细JSON)
|
||||
BusinessDocumentOrderAdjustDetail detail = new BusinessDocumentOrderAdjustDetail();
|
||||
copySnapshot(afterOrder, detail);
|
||||
if (hasFeeDetail) {
|
||||
detail.setFeeDetailJson(JSONUtil.toJsonStr(newFeeList));
|
||||
}
|
||||
detail.setAdjustId(adjust.getId());
|
||||
detail.setOrderId(dbOrder.getId());
|
||||
detail.setGoodsNumber(dbOrder.getGoodsNumber());
|
||||
detail.setCreateBy(adjust.getAdjustBy());
|
||||
detail.setCreateName(adjust.getAdjustByName());
|
||||
detail.setCreateTime(now);
|
||||
detail.setDelFlag(1);
|
||||
adjustDetailMapper.insert(detail);
|
||||
|
||||
if (!amountChanged) {
|
||||
// 8a. 直通:覆盖主表可编辑字段(含 deliveryFreight 合计) + 替换费用明细;不改动任何审核/执行状态
|
||||
saveOrderAndFee(dbOrder.getId(), afterOrder, hasFeeDetail ? newFeeList : dbFeeList, loginUser, now, false, null);
|
||||
updateAdjustPass(adjust.getId(), adjust.getAdjustBy(), adjust.getAdjustByName(), now, null);
|
||||
syncTmsAsync(dbOrder.getGoodsNumber(), afterOrder);
|
||||
} else {
|
||||
// 8b. 涉及金额:仅把业务单 review_status 置为"调整待审核(3)",其余状态(exec/orderStatus)不动,不更新业务单数据
|
||||
BusinessDocumentOrder statusOnly = new BusinessDocumentOrder();
|
||||
statusOnly.setId(dbOrder.getId());
|
||||
statusOnly.setReviewStatus(3L); // 调整待审核
|
||||
businessDocumentOrderMapper.updateById(statusOnly);
|
||||
}
|
||||
|
||||
return AjaxResult.success(new Object[]{amountChanged, adjust.getId()});
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整记录列表(管理页:查全部,可选按订单/业务单号/审核状态等筛选,配合分页使用)
|
||||
*/
|
||||
public List<BusinessDocumentOrderAdjustRecordDTO> listAdjustRecord(BusinessDocumentOrderAdjustQueryDTO query) {
|
||||
LambdaQueryWrapper<BusinessDocumentOrderAdjust> wrapper = new LambdaQueryWrapper<BusinessDocumentOrderAdjust>()
|
||||
.eq(BusinessDocumentOrderAdjust::getDelFlag, 1);
|
||||
|
||||
// ===== 组织隔离(参考业务单 queryList 口径) =====
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long loginOrgId = loginUser.getUserPo().getOrganizationId();
|
||||
Long loginTopOrgId = loginUser.getUserPo().getTopOrganizationId();
|
||||
// 一级组织非1(集团)时,按一级组织过滤(可看本一级组织下所有)
|
||||
if (loginTopOrgId != null && loginTopOrgId != 1) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getTopOrgId, String.valueOf(loginTopOrgId));
|
||||
} else if (loginOrgId != null) {
|
||||
// 否则按当前组织过滤;若查询方显式指定了 organizationId 则以其为准
|
||||
Long effOrgId = (query != null && query.getOrganizationId() != null)
|
||||
? query.getOrganizationId() : loginOrgId;
|
||||
if (effOrgId != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getOrgId, String.valueOf(effOrgId));
|
||||
}
|
||||
}
|
||||
} else if (query != null && query.getOrganizationId() != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getOrgId, String.valueOf(query.getOrganizationId()));
|
||||
}
|
||||
|
||||
if (query != null) {
|
||||
if (query.getOrderId() != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getOrderId, query.getOrderId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getGoodsNumber())) {
|
||||
wrapper.like(BusinessDocumentOrderAdjust::getGoodsNumber, query.getGoodsNumber());
|
||||
}
|
||||
if (query.getIsAudit() != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getIsAudit, query.getIsAudit());
|
||||
}
|
||||
if (query.getAuditStatus() != null) {
|
||||
wrapper.eq(BusinessDocumentOrderAdjust::getAuditStatus, query.getAuditStatus());
|
||||
}
|
||||
if (StrUtil.isNotBlank(query.getAdjustByName())) {
|
||||
wrapper.like(BusinessDocumentOrderAdjust::getAdjustByName, query.getAdjustByName());
|
||||
}
|
||||
}
|
||||
wrapper.orderByDesc(BusinessDocumentOrderAdjust::getAdjustTime);
|
||||
List<BusinessDocumentOrderAdjust> list = adjustMapper.selectList(wrapper);
|
||||
return list.stream().map(a -> {
|
||||
BusinessDocumentOrderAdjustRecordDTO vo = new BusinessDocumentOrderAdjustRecordDTO();
|
||||
BeanUtil.copyProperties(a, vo);
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 按业务单查询调整记录(供订单详情页"调整记录"Tab用)
|
||||
*/
|
||||
public List<BusinessDocumentOrderAdjustRecordDTO> listAdjustRecordByOrder(Long orderId) {
|
||||
BusinessDocumentOrderAdjustQueryDTO query = new BusinessDocumentOrderAdjustQueryDTO();
|
||||
query.setOrderId(orderId);
|
||||
return listAdjustRecord(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整记录详情(主记录 + 调整后明细快照)
|
||||
*/
|
||||
public BusinessDocumentOrderAdjustRecordDTO getAdjustRecord(Long adjustId) {
|
||||
BusinessDocumentOrderAdjust adjust = adjustMapper.selectById(adjustId);
|
||||
if (adjust == null) {
|
||||
throw new ServiceException("调整记录不存在");
|
||||
}
|
||||
BusinessDocumentOrderAdjustRecordDTO vo = new BusinessDocumentOrderAdjustRecordDTO();
|
||||
BeanUtil.copyProperties(adjust, vo);
|
||||
BusinessDocumentOrderAdjustDetail detail = adjustDetailMapper.selectOne(
|
||||
new LambdaQueryWrapper<BusinessDocumentOrderAdjustDetail>()
|
||||
.eq(BusinessDocumentOrderAdjustDetail::getAdjustId, adjustId)
|
||||
.eq(BusinessDocumentOrderAdjustDetail::getDelFlag, 1)
|
||||
.last("LIMIT 1"));
|
||||
vo.setDetail(detail);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调整审核(通过/驳回),业务主管操作
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult auditAdjust(BusinessDocumentOrderAdjustAuditDTO auditDTO) {
|
||||
if (auditDTO == null || auditDTO.getAdjustId() == null) {
|
||||
throw new ServiceException("参数错误:缺少调整记录ID");
|
||||
}
|
||||
BusinessDocumentOrderAdjust adjust = adjustMapper.selectById(auditDTO.getAdjustId());
|
||||
if (adjust == null) {
|
||||
throw new ServiceException("调整记录不存在");
|
||||
}
|
||||
if (adjust.getAuditStatus() == null || adjust.getAuditStatus() != AUDIT_WAIT) {
|
||||
throw new ServiceException("该调整记录非待审核状态,无法审核");
|
||||
}
|
||||
Integer result = auditDTO.getAuditResult();
|
||||
if (result == null || (result != AUDIT_PASS && result != AUDIT_REJECT)) {
|
||||
throw new ServiceException("审核结果非法");
|
||||
}
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String auditBy = loginUser != null ? String.valueOf(loginUser.getUserid()) : null;
|
||||
String auditByName = loginUser != null && loginUser.getWlhyLoginUser() != null ? loginUser.getWlhyLoginUser().getRealname() : null;
|
||||
Date now = new Date();
|
||||
|
||||
if (result == AUDIT_PASS) {
|
||||
BusinessDocumentOrder order = businessDocumentOrderMapper.selectById(adjust.getOrderId());
|
||||
if (ObjectUtil.isNull(order)) {
|
||||
throw new ServiceException("业务单不存在");
|
||||
}
|
||||
BusinessDocumentOrderAdjustDetail detail = adjustDetailMapper.selectOne(
|
||||
new LambdaQueryWrapper<BusinessDocumentOrderAdjustDetail>()
|
||||
.eq(BusinessDocumentOrderAdjustDetail::getAdjustId, adjust.getId())
|
||||
.eq(BusinessDocumentOrderAdjustDetail::getDelFlag, 1)
|
||||
.last("LIMIT 1"));
|
||||
|
||||
// 还原调整后业务单(从JSON整行快照)
|
||||
BusinessDocumentOrder snapshot = null;
|
||||
if (detail != null && StrUtil.isNotBlank(detail.getOrderSnapshotJson())) {
|
||||
try {
|
||||
snapshot = JSONUtil.toBean(detail.getOrderSnapshotJson(), BusinessDocumentOrder.class);
|
||||
} catch (Exception e) {
|
||||
log.warn("解析调整快照JSON失败", e);
|
||||
}
|
||||
}
|
||||
BusinessDocumentOrder toSave = new BusinessDocumentOrder();
|
||||
toSave.setId(order.getId());
|
||||
if (snapshot != null) {
|
||||
BeanUtil.copyProperties(snapshot, toSave, CopyOptions.create().setIgnoreNullValue(true)
|
||||
.setIgnoreProperties(toArray()));
|
||||
} else if (detail != null) {
|
||||
BeanUtil.copyProperties(detail, toSave, CopyOptions.create().setIgnoreNullValue(true)
|
||||
.setIgnoreProperties(toArray()));
|
||||
}
|
||||
|
||||
// 还原调整后费用明细(从 feeDetailJson)
|
||||
List<BusinessOrderAccount> newFeeList = new ArrayList<>();
|
||||
if (detail != null && StrUtil.isNotBlank(detail.getFeeDetailJson())) {
|
||||
try {
|
||||
newFeeList = JSONUtil.toList(detail.getFeeDetailJson(), BusinessOrderAccount.class);
|
||||
} catch (Exception e) {
|
||||
log.warn("解析调整费用明细JSON失败", e);
|
||||
}
|
||||
}
|
||||
// 若快照中有明细合计则保证 deliveryFreight 一致
|
||||
if (!newFeeList.isEmpty()) {
|
||||
toSave.setDeliveryFreight(sumAmount(newFeeList));
|
||||
}
|
||||
// 审核通过后 review_status 一律置为 1(已审核);不影响 order_status / execute_status
|
||||
toSave.setReviewStatus(1L);
|
||||
// 覆盖业务单 + 替换费用明细
|
||||
saveOrderAndFee(order.getId(), toSave, newFeeList, loginUser, now, false, null);
|
||||
|
||||
updateAdjustPass(adjust.getId(), auditBy, auditByName, now, auditDTO.getAuditRemark());
|
||||
syncTmsAsync(order.getGoodsNumber(), toSave);
|
||||
} else {
|
||||
adjust.setAuditStatus(AUDIT_REJECT);
|
||||
adjust.setAuditBy(auditBy);
|
||||
adjust.setAuditByName(auditByName);
|
||||
adjust.setAuditTime(now);
|
||||
adjust.setAuditRemark(auditDTO.getAuditRemark());
|
||||
adjust.setUpdateBy(auditBy);
|
||||
adjust.setUpdateTime(now);
|
||||
adjustMapper.updateById(adjust);
|
||||
|
||||
// 驳回:不更新业务单数据,仅把 review_status 还原为调整前值(不影响其它状态)
|
||||
BusinessDocumentOrder statusOnly = new BusinessDocumentOrder();
|
||||
statusOnly.setId(adjust.getOrderId());
|
||||
statusOnly.setReviewStatus(adjust.getBeforeReviewStatus() == null ? 0L : adjust.getBeforeReviewStatus());
|
||||
businessDocumentOrderMapper.updateById(statusOnly);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// 私有工具
|
||||
// =====================================================
|
||||
|
||||
private BusinessDocumentOrder buildAfterOrder(BusinessDocumentOrder dbOrder, BusinessDocumentOrder front) {
|
||||
BusinessDocumentOrder after = new BusinessDocumentOrder();
|
||||
BeanUtil.copyProperties(dbOrder, after, CopyOptions.create().setIgnoreNullValue(true));
|
||||
BeanUtil.copyProperties(front, after, CopyOptions.create().setIgnoreNullValue(true)
|
||||
.setIgnoreProperties(toArray()));
|
||||
after.setId(dbOrder.getId());
|
||||
return after;
|
||||
}
|
||||
|
||||
private BusinessDocumentOrderAdjust buildAdjust(BusinessDocumentOrder dbOrder, LoginUser u, Date now,
|
||||
boolean amountChanged, String reason) {
|
||||
BusinessDocumentOrderAdjust adjust = new BusinessDocumentOrderAdjust();
|
||||
adjust.setOrderId(dbOrder.getId());
|
||||
adjust.setGoodsNumber(dbOrder.getGoodsNumber());
|
||||
adjust.setAdjustBy(u != null ? String.valueOf(u.getUserid()) : null);
|
||||
adjust.setAdjustByName(u != null && u.getWlhyLoginUser() != null ? u.getWlhyLoginUser().getRealname() : null);
|
||||
adjust.setAdjustTime(now);
|
||||
adjust.setAdjustReason(reason);
|
||||
adjust.setIsAudit(amountChanged ? 1 : 0);
|
||||
adjust.setAuditStatus(amountChanged ? AUDIT_WAIT : AUDIT_PASS);
|
||||
adjust.setBeforeReviewStatus(dbOrder.getReviewStatus());
|
||||
// 组织信息:参考业务单口径,取当前登录用户所属组织(调整人归属)
|
||||
if (u != null && u.getUserPo() != null) {
|
||||
if (u.getUserPo().getOrganizationId() != null) {
|
||||
adjust.setOrgId(String.valueOf(u.getUserPo().getOrganizationId()));
|
||||
} else {
|
||||
adjust.setOrgId(dbOrder.getOrgId());
|
||||
}
|
||||
if (u.getUserPo().getTopOrganizationId() != null) {
|
||||
adjust.setTopOrgId(String.valueOf(u.getUserPo().getTopOrganizationId()));
|
||||
} else if (dbOrder.getTopOrganizationId() != null) {
|
||||
adjust.setTopOrgId(String.valueOf(dbOrder.getTopOrganizationId()));
|
||||
}
|
||||
} else {
|
||||
adjust.setOrgId(dbOrder.getOrgId());
|
||||
if (dbOrder.getTopOrganizationId() != null) {
|
||||
adjust.setTopOrgId(String.valueOf(dbOrder.getTopOrganizationId()));
|
||||
}
|
||||
}
|
||||
adjust.setCreateBy(adjust.getAdjustBy());
|
||||
adjust.setCreateName(adjust.getAdjustByName());
|
||||
adjust.setCreateTime(now);
|
||||
adjust.setDelFlag(1);
|
||||
return adjust;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否修改了金额:主表金额列变化 或 明细 amount 变化
|
||||
*/
|
||||
private boolean isAmountChanged(BusinessDocumentOrder dbOrder, BusinessDocumentOrder front,
|
||||
boolean hasFeeDetail, List<BusinessOrderAccount> dbFeeList,
|
||||
List<BusinessOrderAccount> newFeeList) {
|
||||
// a) 主表金额列比对
|
||||
boolean mainChanged = FEE_FIELDS.stream().anyMatch(field -> {
|
||||
Object newVal = BeanUtil.getFieldValue(front, field);
|
||||
if (newVal == null) {
|
||||
return false;
|
||||
}
|
||||
Object oldVal = BeanUtil.getFieldValue(dbOrder, field);
|
||||
BigDecimal old = oldVal == null ? BigDecimal.ZERO : (BigDecimal) oldVal;
|
||||
BigDecimal now = (BigDecimal) newVal;
|
||||
return old.compareTo(now) != 0;
|
||||
});
|
||||
if (mainChanged) {
|
||||
return true;
|
||||
}
|
||||
// b) 若前端未传明细,则只看主表;若传了明细,比较明细金额
|
||||
if (!hasFeeDetail) {
|
||||
return false;
|
||||
}
|
||||
// 明细合计对比
|
||||
BigDecimal oldSum = sumAmount(dbFeeList);
|
||||
BigDecimal newSum = sumAmount(newFeeList);
|
||||
return oldSum.compareTo(newSum) != 0;
|
||||
}
|
||||
|
||||
private BigDecimal sumAmount(List<BusinessOrderAccount> list) {
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
if (list == null) {
|
||||
return sum;
|
||||
}
|
||||
for (BusinessOrderAccount acc : list) {
|
||||
if (acc.getAmount() != null) {
|
||||
sum = sum.add(acc.getAmount());
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖业务单可编辑字段 + 替换费用明细(逻辑删旧 + 插新)
|
||||
*/
|
||||
/**
|
||||
* 覆盖业务单可编辑字段 + 替换费用明细(逻辑删旧 + 插新)
|
||||
* @param restoreReview 是否还原审核状态(审核通过/驳回后 true;直通 false 不改任何审核状态)
|
||||
* @param beforeReviewStatus 调整前 review_status,用于还原
|
||||
*/
|
||||
private void saveOrderAndFee(Long orderId, BusinessDocumentOrder toSave,
|
||||
List<BusinessOrderAccount> newFeeList,
|
||||
LoginUser loginUser, Date now,
|
||||
boolean restoreReview, Long beforeReviewStatus) {
|
||||
if (restoreReview) {
|
||||
// 仅还原 review_status 到调整前值;不影响 order_status / execute_status 等其它状态
|
||||
toSave.setReviewStatus(beforeReviewStatus == null ? 0L : beforeReviewStatus);
|
||||
}
|
||||
businessDocumentOrderMapper.updateById(toSave);
|
||||
|
||||
// 逻辑删旧明细
|
||||
List<BusinessOrderAccount> oldFeeList = businessOrderAccountMapper.selectList(
|
||||
new LambdaQueryWrapper<BusinessOrderAccount>()
|
||||
.eq(BusinessOrderAccount::getOrderId, orderId)
|
||||
.eq(BusinessOrderAccount::getIsDelete, 0));
|
||||
if (oldFeeList != null) {
|
||||
for (BusinessOrderAccount oldAcc : oldFeeList) {
|
||||
oldAcc.setIsDelete(1);
|
||||
oldAcc.setUpdateBy(loginUser != null ? String.valueOf(loginUser.getUserid()) : null);
|
||||
oldAcc.setUpdateTime(now);
|
||||
businessOrderAccountMapper.updateById(oldAcc);
|
||||
}
|
||||
}
|
||||
// 插新明细
|
||||
if (newFeeList != null && !newFeeList.isEmpty()) {
|
||||
for (BusinessOrderAccount acc : newFeeList) {
|
||||
acc.setId(IdUtil.randomUUID());
|
||||
acc.setOrderId(String.valueOf(orderId));
|
||||
acc.setIsDelete(0);
|
||||
acc.setCreateBy(loginUser != null ? String.valueOf(loginUser.getUserid()) : null);
|
||||
acc.setCreateTime(now);
|
||||
businessOrderAccountMapper.insert(acc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void copySnapshot(BusinessDocumentOrder order, BusinessDocumentOrderAdjustDetail detail) {
|
||||
BeanUtil.copyProperties(order, detail, CopyOptions.create().setIgnoreNullValue(true)
|
||||
.setIgnoreProperties("id", "adjustId", "orderId", "createBy", "createName",
|
||||
"createTime", "updateBy", "updateTime", "delFlag",
|
||||
"orderSnapshotJson", "feeDetailJson"));
|
||||
try {
|
||||
detail.setOrderSnapshotJson(JSONUtil.toJsonStr(order));
|
||||
} catch (Exception e) {
|
||||
log.warn("生成调整快照JSON失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAdjustPass(Long adjustId, String auditBy, String auditByName, Date auditTime, String remark) {
|
||||
BusinessDocumentOrderAdjust adjust = new BusinessDocumentOrderAdjust();
|
||||
adjust.setId(adjustId);
|
||||
adjust.setAuditStatus(AUDIT_PASS);
|
||||
adjust.setAuditBy(auditBy);
|
||||
adjust.setAuditByName(auditByName);
|
||||
adjust.setAuditTime(auditTime);
|
||||
adjust.setAuditRemark(remark);
|
||||
adjust.setUpdateBy(auditBy);
|
||||
adjust.setUpdateTime(auditTime);
|
||||
adjustMapper.updateById(adjust);
|
||||
}
|
||||
|
||||
private String[] toArray() {
|
||||
return PROTECTED_FIELDS.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private void syncTmsAsync(String goodsNumber, BusinessDocumentOrder after) {
|
||||
try {
|
||||
List<ExecuteOrder> executeOrders = executeOrderMapper.selectList(
|
||||
new LambdaQueryWrapper<ExecuteOrder>()
|
||||
.eq(ExecuteOrder::getGoodsNumber, goodsNumber)
|
||||
.eq(ExecuteOrder::getDelFlag, 1));
|
||||
if (executeOrders == null || executeOrders.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
log.info("业务单[{}]调整完成,关联执行单[{}]。如需回写TMS请接入TMS改费Feign。", goodsNumber,
|
||||
executeOrders.stream().map(ExecuteOrder::getGoodsNumber).collect(Collectors.toList()));
|
||||
} catch (Exception e) {
|
||||
log.error("同步TMS失败,不影响主流程", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -659,7 +659,7 @@ public class BusinessDocumentOrder extends BaseVOEntity{
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
private Date documentDate;
|
||||
|
||||
@ApiModelProperty( "审核状态 0-未审核 1-审核通过 2-已驳回")
|
||||
@ApiModelProperty( "审核状态 0-未审核 1-审核通过 2-已驳回 3-调整待审核")
|
||||
private Long reviewStatus;
|
||||
|
||||
@ApiModelProperty("审核时间")
|
||||
@@ -825,4 +825,7 @@ public class BusinessDocumentOrder extends BaseVOEntity{
|
||||
@ApiModelProperty("车次")
|
||||
@Excel(name = "车次")
|
||||
private String shuttleNo;
|
||||
|
||||
@ApiModelProperty("业务单调整状态 0-无 1-调整待审核 2-调整驳回 3-调整已通过")
|
||||
private Integer adjustStatus;
|
||||
}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.mhd.oms.domain.businessDocumentOrderAdjust.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整主记录
|
||||
*
|
||||
* @author dev
|
||||
* @date 2026-09-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("business_document_order_adjust")
|
||||
public class BusinessDocumentOrderAdjust implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("业务单ID")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("业务单号")
|
||||
private String goodsNumber;
|
||||
|
||||
@ApiModelProperty("调整人账号")
|
||||
private String adjustBy;
|
||||
|
||||
@ApiModelProperty("调整人姓名")
|
||||
private String adjustByName;
|
||||
|
||||
@ApiModelProperty("调整时间")
|
||||
private Date adjustTime;
|
||||
|
||||
@ApiModelProperty("调整原因")
|
||||
private String adjustReason;
|
||||
|
||||
@ApiModelProperty("是否需要审核 0-否 1-是")
|
||||
private Integer isAudit;
|
||||
|
||||
@ApiModelProperty("调整前业务单审核状态(review_status原值,用于调整审核通过/驳回后还原,避免影响其它)")
|
||||
private Long beforeReviewStatus;
|
||||
|
||||
@ApiModelProperty("审核状态 0-待审核 1-审核通过 2-驳回")
|
||||
private Integer auditStatus;
|
||||
|
||||
@ApiModelProperty("审核人账号")
|
||||
private String auditBy;
|
||||
|
||||
@ApiModelProperty("审核人姓名")
|
||||
private String auditByName;
|
||||
|
||||
@ApiModelProperty("审核时间")
|
||||
private Date auditTime;
|
||||
|
||||
@ApiModelProperty("审核/驳回意见")
|
||||
private String auditRemark;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private String orgId;
|
||||
|
||||
@ApiModelProperty("一级组织ID")
|
||||
private String topOrgId;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("创建人姓名")
|
||||
private String createName;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty("更新人姓名")
|
||||
private String updateName;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("删除标记 1-正常 0-删除")
|
||||
private Integer delFlag;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.mhd.oms.domain.businessDocumentOrderAdjust.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjust.entity.BusinessDocumentOrderAdjust;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整主记录 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface BusinessDocumentOrderAdjustMapper extends BaseMapper<BusinessDocumentOrderAdjust> {
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
package com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整明细(调整后业务单整行快照)
|
||||
*
|
||||
* @author dev
|
||||
* @date 2026-09-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("business_document_order_adjust_detail")
|
||||
public class BusinessDocumentOrderAdjustDetail implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("关联调整主记录ID")
|
||||
private Long adjustId;
|
||||
|
||||
@ApiModelProperty("业务单ID")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("业务单号")
|
||||
private String goodsNumber;
|
||||
|
||||
@ApiModelProperty("货物类型ID")
|
||||
private String goodsTypeId;
|
||||
|
||||
@ApiModelProperty("货物名称")
|
||||
private String goodsName;
|
||||
|
||||
@ApiModelProperty("车型")
|
||||
private String carType;
|
||||
|
||||
@ApiModelProperty("装货地")
|
||||
private String loadingName;
|
||||
|
||||
@ApiModelProperty("装货地址")
|
||||
private String loadingAddress;
|
||||
|
||||
@ApiModelProperty("装货时间")
|
||||
private Date loadingDate;
|
||||
|
||||
@ApiModelProperty("卸货地")
|
||||
private String unloadName;
|
||||
|
||||
@ApiModelProperty("卸货地址")
|
||||
private String unloadAddress;
|
||||
|
||||
@ApiModelProperty("卸货时间")
|
||||
private Date unloadingData;
|
||||
|
||||
@ApiModelProperty("发货人")
|
||||
private String freighterName;
|
||||
|
||||
@ApiModelProperty("装货电话")
|
||||
private String loadingPhone;
|
||||
|
||||
@ApiModelProperty("收货人")
|
||||
private String dischargerName;
|
||||
|
||||
@ApiModelProperty("卸货电话")
|
||||
private String unloadPhone;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remarks;
|
||||
|
||||
@ApiModelProperty("线路")
|
||||
private String route;
|
||||
|
||||
@ApiModelProperty("单据日期")
|
||||
private Date documentDate;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private String orgId;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private Long organizationId;
|
||||
|
||||
@ApiModelProperty("组织名称")
|
||||
private String organizationName;
|
||||
|
||||
@ApiModelProperty("一级组织ID")
|
||||
private Long topOrganizationId;
|
||||
|
||||
// ==================== 金额/费用快照 ====================
|
||||
@ApiModelProperty("发货运费")
|
||||
private BigDecimal deliveryFreight;
|
||||
|
||||
@ApiModelProperty("已收运费")
|
||||
private BigDecimal collectedFreight;
|
||||
|
||||
@ApiModelProperty("未收运费")
|
||||
private BigDecimal uncollectedFreight;
|
||||
|
||||
@ApiModelProperty("少收运费")
|
||||
private BigDecimal collectLessFreight;
|
||||
|
||||
@ApiModelProperty("运费单价(元/吨)")
|
||||
private BigDecimal transportationUnitPrice;
|
||||
|
||||
@ApiModelProperty("信息费")
|
||||
private BigDecimal infoFee;
|
||||
|
||||
@ApiModelProperty("计费单价")
|
||||
private BigDecimal freightUnitPrice;
|
||||
|
||||
@ApiModelProperty("货物保险金额")
|
||||
private BigDecimal cargoInsuranceAmount;
|
||||
|
||||
@ApiModelProperty("运费")
|
||||
private BigDecimal freightCharges;
|
||||
|
||||
@ApiModelProperty("运费")
|
||||
private BigDecimal freightFee;
|
||||
|
||||
@ApiModelProperty("卸货费")
|
||||
private BigDecimal unloadingFee;
|
||||
|
||||
@ApiModelProperty("报关费")
|
||||
private BigDecimal customsFee;
|
||||
|
||||
@ApiModelProperty("差货费")
|
||||
private BigDecimal shortageFee;
|
||||
|
||||
@ApiModelProperty("杂费")
|
||||
private BigDecimal miscellaneousFee;
|
||||
|
||||
@ApiModelProperty("其他费用")
|
||||
private BigDecimal otherFee;
|
||||
|
||||
@ApiModelProperty("滞车费")
|
||||
private BigDecimal detentionFee;
|
||||
|
||||
@ApiModelProperty("税率")
|
||||
private BigDecimal taxRate;
|
||||
|
||||
@ApiModelProperty("创建人")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("创建人姓名")
|
||||
private String createName;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新人")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty("删除标记 1-正常 0-删除")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("调整后业务单整行JSON快照(用于全字段精确还原)")
|
||||
private String orderSnapshotJson;
|
||||
|
||||
@ApiModelProperty("调整后费用明细JSON快照(business_order_account列表)")
|
||||
private String feeDetailJson;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.mhd.oms.domain.businessDocumentOrderAdjustDetail.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity.BusinessDocumentOrderAdjustDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整明细 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface BusinessDocumentOrderAdjustDetailMapper extends BaseMapper<BusinessDocumentOrderAdjustDetail> {
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 三方服务 Feign
|
||||
*/
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-third-party-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "thirdPartyServiceFeign",url = "http://10.102.192.31:8012", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class)
|
||||
public interface ThirdPartyServiceFeign {
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整 审核入参
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDocumentOrderAdjustAuditDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("调整记录ID(必传)")
|
||||
private Long adjustId;
|
||||
|
||||
@ApiModelProperty("审核结果 1-通过 2-驳回")
|
||||
private Integer auditResult;
|
||||
|
||||
@ApiModelProperty("审核/驳回意见")
|
||||
private String auditRemark;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||
|
||||
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
|
||||
import com.mhd.oms.domain.businessOrderAccount.BusinessOrderAccount;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整提交入参
|
||||
*
|
||||
* 前端整单回传 business_document_order 全部字段 + 费用明细 business_order_account:
|
||||
* - amountChanged=true (本次修改了金额) -> 需要业务主管审核
|
||||
* - amountChanged=false (仅改其它字段) -> 无需审核,直接更新
|
||||
*
|
||||
* order: 前端把「调整后」业务单整单字段回传(含 id 定位;deliveryFreight 合计可由后端按明细自动算)。
|
||||
* feeDetailList: 调整后费用明细(business_order_account),其 amount 之和 = 主表 deliveryFreight。
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDocumentOrderAdjustDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("调整后业务单(整单字段,含 id 定位;金额合计 deliveryFreight 可由后端按明细自动算)")
|
||||
private BusinessDocumentOrder order;
|
||||
|
||||
@ApiModelProperty("调整后费用明细(business_order_account),amount 之和作为主表 deliveryFreight 合计")
|
||||
private List<BusinessOrderAccount> feeDetailList;
|
||||
|
||||
@ApiModelProperty("是否修改了金额(前端判定传入):true-需审核,false-直通")
|
||||
private Boolean amountChanged;
|
||||
|
||||
@ApiModelProperty("调整原因")
|
||||
private String adjustReason;
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整记录 查询条件(管理列表用,可不按订单、查全部)
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDocumentOrderAdjustQueryDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("业务单号(模糊)")
|
||||
private String goodsNumber;
|
||||
|
||||
@ApiModelProperty("业务单ID")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("是否需要审核 0-否 1-是")
|
||||
private Integer isAudit;
|
||||
|
||||
@ApiModelProperty("审核状态 0-待审核 1-审核通过 2-驳回")
|
||||
private Integer auditStatus;
|
||||
|
||||
@ApiModelProperty("调整人姓名(模糊)")
|
||||
private String adjustByName;
|
||||
|
||||
@ApiModelProperty("所属组织ID(调整人/业务单所属组织)")
|
||||
private Long organizationId;
|
||||
|
||||
@ApiModelProperty("一级组织ID(组织隔离用)")
|
||||
private Long topOrganizationId;
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust;
|
||||
|
||||
import com.mhd.oms.domain.businessDocumentOrderAdjustDetail.entity.BusinessDocumentOrderAdjustDetail;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 运输业务单 调整记录(主记录) 列表/详情返回 VO
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDocumentOrderAdjustRecordDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主记录ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("业务单ID")
|
||||
private Long orderId;
|
||||
|
||||
@ApiModelProperty("业务单号")
|
||||
private String goodsNumber;
|
||||
|
||||
@ApiModelProperty("调整人账号")
|
||||
private String adjustBy;
|
||||
|
||||
@ApiModelProperty("调整人姓名")
|
||||
private String adjustByName;
|
||||
|
||||
@ApiModelProperty("调整时间")
|
||||
private Date adjustTime;
|
||||
|
||||
@ApiModelProperty("调整原因")
|
||||
private String adjustReason;
|
||||
|
||||
@ApiModelProperty("是否需要审核 0-否 1-是")
|
||||
private Integer isAudit;
|
||||
|
||||
@ApiModelProperty("审核状态 0-待审核 1-审核通过 2-驳回")
|
||||
private Integer auditStatus;
|
||||
|
||||
@ApiModelProperty("审核人账号")
|
||||
private String auditBy;
|
||||
|
||||
@ApiModelProperty("审核人姓名")
|
||||
private String auditByName;
|
||||
|
||||
@ApiModelProperty("审核时间")
|
||||
private Date auditTime;
|
||||
|
||||
@ApiModelProperty("审核/驳回意见")
|
||||
private String auditRemark;
|
||||
|
||||
@ApiModelProperty("调整后整行快照明细(详情查询时带出)")
|
||||
private BusinessDocumentOrderAdjustDetail detail;
|
||||
}
|
||||
+65
@@ -10,7 +10,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
|
||||
import com.mhd.oms.application.service.businessDocumentOrder.BusinessDocumentOrderAdjustService;
|
||||
import com.mhd.oms.application.service.businessDocumentOrder.BusinessDocumentOrderApplicationService;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustAuditDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustQueryDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrderAdjust.BusinessDocumentOrderAdjustRecordDTO;
|
||||
import com.mhd.oms.interfaces.assembler.businessDocumentOrder.BusinessDocumentOrderAssembler;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import javax.annotation.Resource;
|
||||
@@ -33,6 +38,9 @@ public class BusinessDocumentOrderApi extends BaseController{
|
||||
@Resource
|
||||
private BusinessDocumentOrderAssembler businessDocumentOrderAssembler;
|
||||
|
||||
@Resource
|
||||
private BusinessDocumentOrderAdjustService businessDocumentOrderAdjustService;
|
||||
|
||||
/**
|
||||
* 分页查询【业务单】列表
|
||||
*/
|
||||
@@ -161,7 +169,64 @@ public class BusinessDocumentOrderApi extends BaseController{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 提交调整
|
||||
* 若修改了金额字段则进入调整待审核,否则直通更新
|
||||
*/
|
||||
@ApiOperation("订单调整 - 提交调整")
|
||||
@PostMapping("/adjust")
|
||||
public AjaxResult adjust(@RequestBody BusinessDocumentOrderAdjustDTO adjustDTO) {
|
||||
try {
|
||||
return businessDocumentOrderAdjustService.adjust(adjustDTO);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 调整记录列表(查全部,可分页/按业务单号或审核状态筛选)
|
||||
*/
|
||||
@ApiOperation("订单调整 - 调整记录列表")
|
||||
@GetMapping("/listAdjustRecord")
|
||||
public TableDataInfo listAdjustRecord(BusinessDocumentOrderAdjustQueryDTO query,
|
||||
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize) {
|
||||
PageHelper.startPage(pageNo, pageSize);
|
||||
List<BusinessDocumentOrderAdjustRecordDTO> list = businessDocumentOrderAdjustService.listAdjustRecord(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 按业务单查询调整记录(供订单详情页展示)
|
||||
*/
|
||||
@ApiOperation("订单调整 - 按业务单查询调整记录")
|
||||
@GetMapping("/listAdjustRecordByOrder/{orderId}")
|
||||
public AjaxResult listAdjustRecordByOrder(@PathVariable("orderId") Long orderId) {
|
||||
return AjaxResult.success(businessDocumentOrderAdjustService.listAdjustRecordByOrder(orderId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 调整记录详情
|
||||
*/
|
||||
@ApiOperation("订单调整 - 调整记录详情")
|
||||
@GetMapping("/getAdjustRecord/{adjustId}")
|
||||
public AjaxResult getAdjustRecord(@PathVariable("adjustId") Long adjustId) {
|
||||
return AjaxResult.success(businessDocumentOrderAdjustService.getAdjustRecord(adjustId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单调整 - 审核(通过/驳回)
|
||||
*/
|
||||
@ApiOperation("订单调整 - 审核")
|
||||
@PostMapping("/auditAdjust")
|
||||
public AjaxResult auditAdjust(@RequestBody BusinessDocumentOrderAdjustAuditDTO auditDTO) {
|
||||
try {
|
||||
return businessDocumentOrderAdjustService.auditAdjust(auditDTO);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-2
@@ -573,10 +573,11 @@ public class MaterialBaseInfoApplicationService {
|
||||
normalizeImportBarCodeWhenDuplicateOfHs(row);
|
||||
fillIdsFromExistingMasterData(row);
|
||||
fillOrganizationFromShipperIfNeeded(row);
|
||||
if (!isValidOrgId(row.getOrganizationId()) && isValidOrgId(loginOrgId)) {
|
||||
// 登录组织优先:以登录账号的组织为准,覆盖货主解析带来的组织,避免用货主组织导致包装规格等主数据查不到
|
||||
if (isValidOrgId(loginOrgId)) {
|
||||
row.setOrganizationId(loginOrgId);
|
||||
}
|
||||
if (row.getTopOrganizationId() == null && isValidOrgId(loginTopOrgId)) {
|
||||
if (isValidOrgId(loginTopOrgId)) {
|
||||
row.setTopOrganizationId(loginTopOrgId);
|
||||
}
|
||||
fillOrganizationName(row, loginUser);
|
||||
|
||||
+3
-2
@@ -128,10 +128,11 @@ public class MaterialBaseInfoAsyncService {
|
||||
materialBaseInfoApplicationService.normalizeImportBarCodeWhenDuplicateOfHs(row);
|
||||
materialBaseInfoApplicationService.fillIdsFromExistingMasterData(row);
|
||||
materialBaseInfoApplicationService.fillOrganizationFromShipperIfNeeded(row);
|
||||
if (!isValidOrgId(row.getOrganizationId()) && isValidOrgId(loginOrgId)) {
|
||||
// 登录组织优先:以登录账号的组织为准,覆盖货主解析带来的组织,避免用货主组织(如2841)导致包装规格等主数据查不到
|
||||
if (isValidOrgId(loginOrgId)) {
|
||||
row.setOrganizationId(loginOrgId);
|
||||
}
|
||||
if (row.getTopOrganizationId() == null && isValidOrgId(loginTopOrgId)) {
|
||||
if (isValidOrgId(loginTopOrgId)) {
|
||||
row.setTopOrganizationId(loginTopOrgId);
|
||||
}
|
||||
materialBaseInfoApplicationService.fillOrganizationName(row, loginUser);
|
||||
|
||||
+97
-7
@@ -2040,21 +2040,71 @@ public class StockInOrderApplicationService {
|
||||
r.getMaterialCode(), topOrganizationId, shipperId);
|
||||
List<MaterialBaseInfoPO> materialList = materialBaseInfoService.queryList(queryDO);
|
||||
log.info("料号查询结果,查询到 {} 条记录", materialList != null ? materialList.size() : 0);
|
||||
MaterialBaseInfoPO materialBaseInfoPO = null;
|
||||
if (materialList != null && !materialList.isEmpty()) {
|
||||
materialBaseInfoPO = materialList.get(0);
|
||||
MaterialBaseInfoPO materialBaseInfoPO = pickMaterialByCode(materialList, r.getMaterialCode(), shipperId, order.getShipperName());
|
||||
// 兜底:按名称解析出的shipperId可能与物料档案shipper_id不一致(系统中存在同名货主账号,
|
||||
// 按user_name精确匹配解析到了另一个同名列货主),此时去掉货主ID条件再查一次,
|
||||
// 用物料档案冗余的shipper_name与Excel客户名称等值匹配
|
||||
if (materialBaseInfoPO == null && StringUtils.isNotBlank(order.getShipperName())) {
|
||||
MaterialBaseInfoDO fallbackDO = new MaterialBaseInfoDO();
|
||||
fallbackDO.setMaterialCode(r.getMaterialCode());
|
||||
if (topOrganizationId != null) {
|
||||
fallbackDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
List<MaterialBaseInfoPO> fallbackList = materialBaseInfoService.queryList(fallbackDO);
|
||||
materialBaseInfoPO = pickMaterialByCode(fallbackList, r.getMaterialCode(), null, order.getShipperName());
|
||||
if (materialBaseInfoPO != null) {
|
||||
log.warn("导入料号校验:按解析shipperId未匹配到物料,已按档案货主名称兜底匹配。料号: [{}], 解析shipperId: {}, 档案shipperId: {}, 档案shipperName: {}",
|
||||
r.getMaterialCode(), shipperId, materialBaseInfoPO.getShipperId(), materialBaseInfoPO.getShipperName());
|
||||
// 以档案货主为准纠正单据货主信息,避免后续shipperParam按错误的shipperId反查覆盖货主名称
|
||||
if (materialBaseInfoPO.getShipperId() != null) {
|
||||
shipperId = materialBaseInfoPO.getShipperId();
|
||||
order.setShipperId(shipperId);
|
||||
}
|
||||
if (StringUtils.isNotBlank(materialBaseInfoPO.getShipperCode())) {
|
||||
order.setShipperCode(materialBaseInfoPO.getShipperCode());
|
||||
}
|
||||
if (StringUtils.isNotBlank(materialBaseInfoPO.getShipperName())) {
|
||||
order.setShipperName(materialBaseInfoPO.getShipperName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (materialBaseInfoPO != null) {
|
||||
materialBaseInfoId = materialBaseInfoPO.getMaterialBaseInfoId();
|
||||
log.info("通过料号查询到物料基础信息,料号: {}, 物料ID: {}, 货主ID: {}",
|
||||
r.getMaterialCode(), materialBaseInfoId, shipperId);
|
||||
} else {
|
||||
// 如果提供了料号但查询不到(或不属于该货主),直接报错,不允许导入
|
||||
String errorMsg = String.format("导入失败:该货主下不存在该料号(货主名称=%s,料号=%s)。请确保该料号已在物料管理中创建,且属于该货主",
|
||||
order.getShipperName(), r.getMaterialCode());
|
||||
// 诊断对照查询(仅用于日志定位,不影响流程):去掉货主ID条件再查一次,
|
||||
// 用于区分两类原因:A-按名称解析出的shipperId与物料档案shipper_id不一致(货主错配);
|
||||
// B-登录人topOrganizationId与物料档案top_organization_id不一致(组织口径不一致)
|
||||
try {
|
||||
MaterialBaseInfoDO diagDO = new MaterialBaseInfoDO();
|
||||
diagDO.setMaterialCode(r.getMaterialCode());
|
||||
if (topOrganizationId != null) {
|
||||
diagDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
List<MaterialBaseInfoPO> diagList = materialBaseInfoService.queryList(diagDO);
|
||||
if (diagList != null && !diagList.isEmpty()) {
|
||||
MaterialBaseInfoPO diagPo = diagList.get(0);
|
||||
log.error("导入料号校验诊断:去掉货主条件后可查到物料,判定为货主解析错配(原因A)。料号: [{}], 解析shipperId: {}, 登录topOrganizationId: {}, 物料ID: {}, 档案shipperId: {}, 档案shipperName: {}, 档案topOrganizationId: {}",
|
||||
r.getMaterialCode(), shipperId, topOrganizationId,
|
||||
diagPo.getMaterialBaseInfoId(), diagPo.getShipperId(), diagPo.getShipperName(), diagPo.getTopOrganizationId());
|
||||
} else {
|
||||
log.error("导入料号校验诊断:去掉货主条件后仍查不到物料,判定为组织口径不一致(原因B)。料号: [{}], 解析shipperId: {}, 登录topOrganizationId: {}",
|
||||
r.getMaterialCode(), shipperId, topOrganizationId);
|
||||
}
|
||||
} catch (Exception diagEx) {
|
||||
log.warn("导入料号校验诊断查询异常,料号: [{}], 错误: {}", r.getMaterialCode(), diagEx.getMessage());
|
||||
}
|
||||
String errorMsg = String.format("导入失败:该货主下不存在该料号(货主名称=%s,料号=%s,解析shipperId=%s,登录topOrganizationId=%s)。请确保该料号已在物料管理中创建,且属于该货主",
|
||||
order.getShipperName(), r.getMaterialCode(),
|
||||
shipperId == null ? "空" : shipperId, topOrganizationId == null ? "空" : topOrganizationId);
|
||||
log.error(errorMsg);
|
||||
throw new ServiceException(errorMsg);
|
||||
}
|
||||
// 校验料号与规格型号/SKU码一致性:按料号查到档案后逐项比对,任何一项不符直接报对应错误
|
||||
// 双方(trim后)必须完全一致:Excel留空而档案有值、或Excel填了值而档案为空,均视为不一致报错
|
||||
// 规格型号(trim后)双方必须完全一致:Excel留空而档案有值、或Excel填了值而档案为空,均视为不一致报错
|
||||
// SKU码:档案条码(barCode)为空时跳过比对(存量档案普遍未维护条码);档案有值时仍严格比对
|
||||
String excelSpec = StringUtils.trimToEmpty(r.getSpecificationModel());
|
||||
String dbSpec = StringUtils.trimToEmpty(materialBaseInfoPO.getSpecificationModel());
|
||||
if (!excelSpec.equals(dbSpec)) {
|
||||
@@ -2064,7 +2114,7 @@ public class StockInOrderApplicationService {
|
||||
}
|
||||
String excelSku = StringUtils.trimToEmpty(r.getSkuCode());
|
||||
String dbSku = StringUtils.trimToEmpty(materialBaseInfoPO.getBarCode());
|
||||
if (!excelSku.equals(dbSku)) {
|
||||
if (StringUtils.isNotEmpty(dbSku) && !excelSku.equals(dbSku)) {
|
||||
throw new ServiceException(String.format("导入失败:料号[%s](商品名称:%s)SKU码与物料档案不一致(Excel:%s / 档案:%s)",
|
||||
r.getMaterialCode(), r.getMaterialName(),
|
||||
excelSku.isEmpty() ? "空" : excelSku, dbSku.isEmpty() ? "空" : dbSku));
|
||||
@@ -2398,6 +2448,46 @@ public class StockInOrderApplicationService {
|
||||
return oid != null && loginOrganizationId.equals(oid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入校验:从按料号(SQL为LIKE模糊)查出的物料列表中挑选匹配记录。
|
||||
* 优先级:料号精确等值优先于模糊命中(避免子串料号误匹配);
|
||||
* 同级内优先 shipperId 精确匹配,其次 shipperName 等值匹配,最后取排序第一条(与原 get(0) 行为一致)。
|
||||
*/
|
||||
private MaterialBaseInfoPO pickMaterialByCode(List<MaterialBaseInfoPO> materialList, String materialCode, Long shipperId, String shipperName) {
|
||||
if (materialList == null || materialList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String code = StringUtils.trimToEmpty(materialCode);
|
||||
String name = StringUtils.trimToEmpty(shipperName);
|
||||
MaterialBaseInfoPO exactCodeFirst = null;
|
||||
MaterialBaseInfoPO anyFirst = null;
|
||||
// 第一轮:料号精确等值中优先 shipperId 精确匹配
|
||||
for (MaterialBaseInfoPO po : materialList) {
|
||||
if (anyFirst == null) {
|
||||
anyFirst = po;
|
||||
}
|
||||
if (StringUtils.isEmpty(code) || !code.equals(StringUtils.trimToEmpty(po.getMaterialCode()))) {
|
||||
continue;
|
||||
}
|
||||
if (exactCodeFirst == null) {
|
||||
exactCodeFirst = po;
|
||||
}
|
||||
if (shipperId != null && shipperId.equals(po.getShipperId())) {
|
||||
return po;
|
||||
}
|
||||
}
|
||||
// 第二轮:料号精确等值中按档案货主名称等值匹配
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
for (MaterialBaseInfoPO po : materialList) {
|
||||
if (StringUtils.isNotEmpty(code) && code.equals(StringUtils.trimToEmpty(po.getMaterialCode()))
|
||||
&& name.equals(StringUtils.trimToEmpty(po.getShipperName()))) {
|
||||
return po;
|
||||
}
|
||||
}
|
||||
}
|
||||
return exactCodeFirst != null ? exactCodeFirst : anyFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据货主名称或编号获取货主ID(用于导入时提前获取货主ID)
|
||||
* @param shipperName 货主名称
|
||||
|
||||
@@ -16,7 +16,7 @@ spring:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.33.0.129:6010
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
server-addr: 10.102.192.31:6848
|
||||
server-addr: 10.102.192.30:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
#线上正式环境
|
||||
@@ -25,7 +25,7 @@ spring:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.33.0.129:6010
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
server-addr: 10.102.192.31:6848
|
||||
server-addr: 10.102.192.30:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
#线上正式环境
|
||||
|
||||
Reference in New Issue
Block a user