✨ 小程序用户独立为 blade_mp_user,并兼容司机/车辆 OCR 宽松日期
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+3
-4
@@ -33,6 +33,7 @@ import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.cache.UserDisplayCache;
|
||||
import org.springblade.transport.mapper.TransportCertRecordMapper;
|
||||
import org.springblade.transport.pojo.dto.PersonCertSubmitRequest;
|
||||
import org.springblade.transport.pojo.dto.VehicleCertSubmitRequest;
|
||||
@@ -124,10 +125,8 @@ public class CertAuditServiceImpl implements ICertAuditService {
|
||||
detail.setStatusText(CertificationRuleSupport.statusText(record.getStatus()));
|
||||
detail.setSubmitTime(record.getSubmitTime());
|
||||
detail.setSubmitUser(record.getSubmitUser());
|
||||
// 面向前端的展示字段必须由服务端填好,否则审核页「提交人」一栏恒为空白
|
||||
detail.setSubmitUserName(UserCache.getUserRealName(record.getSubmitUser()));
|
||||
// 审核留痕同理:审核人姓名由服务端查好,前端不做用户ID → 姓名的二次请求。
|
||||
// 记录还在「审核中」时审核人与审核时间都为空,由前端显示占位符
|
||||
// 提交人来自小程序用户;审核人来自后台系统用户
|
||||
detail.setSubmitUserName(UserDisplayCache.getUserRealName(record.getSubmitUser()));
|
||||
detail.setAuditUser(record.getAuditUser());
|
||||
detail.setAuditTime(record.getAuditTime());
|
||||
detail.setAuditUserName(UserCache.getUserRealName(record.getAuditUser()));
|
||||
|
||||
+5
-6
@@ -29,8 +29,8 @@ import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.feign.IUserClient;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.feign.IMpUserClient;
|
||||
import org.springblade.system.pojo.entity.MpUser;
|
||||
import org.springblade.transport.pojo.entity.Driver;
|
||||
import org.springblade.transport.pojo.entity.TransportVehicle;
|
||||
import org.springblade.transport.pojo.vo.DriverVehicleCardVO;
|
||||
@@ -57,7 +57,7 @@ public class DriverAppServiceImpl implements IDriverAppService {
|
||||
|
||||
private final IDriverService driverService;
|
||||
private final ITransportVehicleService transportVehicleService;
|
||||
private final IUserClient userClient;
|
||||
private final IMpUserClient mpUserClient;
|
||||
|
||||
@Override
|
||||
public DriverVO currentByPhone(String mobile) {
|
||||
@@ -205,10 +205,9 @@ public class DriverAppServiceImpl implements IDriverAppService {
|
||||
if (isMobileLike(account)) {
|
||||
return account.trim();
|
||||
}
|
||||
// 用户中心的 phone 带 @Sensitive(MOBILE),经 Feign 回来是「175****12082」这类脱敏串,
|
||||
// 拿它去 eq(mobile) 永远查不到、拿它比对本人的真实号码又必然不等。
|
||||
// 小程序用户 phone 带 @Sensitive(MOBILE),经 Feign 回来是脱敏串,
|
||||
// 因此这里只取未脱敏的 account;脱敏的 phone 一律不用。
|
||||
R<User> result = userClient.userInfoById(userId);
|
||||
R<MpUser> result = mpUserClient.userById(userId);
|
||||
if (result != null && R.isSuccess(result) && result.getData() != null) {
|
||||
String userAccount = result.getData().getAccount();
|
||||
if (isMobileLike(userAccount)) {
|
||||
|
||||
+1
-1
@@ -327,7 +327,7 @@ public class DriverCertServiceImpl implements IDriverCertService {
|
||||
* 状态必须显式设置为待审:框架在插入时会把空的 {@code status} 静默填成 1,
|
||||
* 而 1 在本表是「已通过」,那会让一次提交凭空变成审核通过。
|
||||
*
|
||||
* @param submitUser 提交人**用户ID**(blade_user.id)——审核页要靠它翻译成姓名。
|
||||
* @param submitUser 提交人**用户ID**(blade_mp_user.id)——审核页要靠它翻译成姓名。
|
||||
* 不要传司机档案ID:两者都是雪花ID、类型也相同,传错不会报任何错,
|
||||
* 只会让「提交人」一栏显示成一串数字。
|
||||
*/
|
||||
|
||||
+48
-61
@@ -36,12 +36,11 @@ import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.feign.IMpUserClient;
|
||||
import org.springblade.system.feign.ISysClient;
|
||||
import org.springblade.system.feign.IUserClient;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.pojo.entity.UserInfo;
|
||||
import org.springblade.system.pojo.entity.MpUser;
|
||||
import org.springblade.system.pojo.enums.MpUserIdentity;
|
||||
import org.springblade.system.pojo.enums.UserSex;
|
||||
import org.springblade.system.pojo.enums.UserType;
|
||||
import org.springblade.transport.excel.DriverExcel;
|
||||
import org.springblade.transport.mapper.DriverMapper;
|
||||
import org.springblade.transport.pojo.entity.Driver;
|
||||
@@ -76,7 +75,7 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
||||
private static final int DEFAULT_ENABLED_STATUS = 1;
|
||||
private static final int DEFAULT_FALSE = 0;
|
||||
|
||||
private final IUserClient userClient;
|
||||
private final IMpUserClient mpUserClient;
|
||||
private final ISysClient sysClient;
|
||||
|
||||
@Override
|
||||
@@ -310,13 +309,13 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
||||
tenantId = driver.getTenantId();
|
||||
}
|
||||
if (Func.isEmpty(tenantId)) {
|
||||
throw new ServiceException("租户信息为空,无法同步系统用户");
|
||||
throw new ServiceException("租户信息为空,无法同步小程序用户");
|
||||
}
|
||||
String mobile = driver.getMobile();
|
||||
if (Func.isEmpty(mobile) || mobile.length() < 6) {
|
||||
throw new ServiceException("手机号长度不足,无法同步系统用户");
|
||||
throw new ServiceException("手机号长度不足,无法同步小程序用户");
|
||||
}
|
||||
// 编辑时前端可能不传 userId,从库中补齐已关联用户
|
||||
// 编辑时前端可能不传 userId,从库中补齐已关联小程序用户
|
||||
if (Func.isEmpty(driver.getUserId()) && Func.isNotEmpty(driver.getId())) {
|
||||
Driver dbDriver = getById(driver.getId());
|
||||
if (dbDriver != null && Func.isNotEmpty(dbDriver.getUserId())) {
|
||||
@@ -324,95 +323,83 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
||||
}
|
||||
}
|
||||
|
||||
R<String> roleResult = sysClient.getRoleIdByAlias(tenantId, "driver");
|
||||
if (roleResult == null || !R.isSuccess(roleResult) || Func.isEmpty(roleResult.getData())) {
|
||||
throw new ServiceException("未配置角色别名为driver的角色,请先在系统角色中维护");
|
||||
}
|
||||
String roleId = roleResult.getData();
|
||||
|
||||
// 部门可选:匹配到则写入小程序用户,匹配不到不阻断同步
|
||||
String deptId = null;
|
||||
R<String> deptResult = sysClient.getDeptIds(tenantId, driver.getOrganizationName());
|
||||
if (deptResult == null || !R.isSuccess(deptResult) || Func.isEmpty(deptResult.getData())) {
|
||||
throw new ServiceException("所属组织未匹配到系统部门,无法同步用户");
|
||||
if (deptResult != null && R.isSuccess(deptResult) && Func.isNotEmpty(deptResult.getData())) {
|
||||
deptId = deptResult.getData();
|
||||
}
|
||||
String deptId = deptResult.getData();
|
||||
|
||||
User existing = findExistingUser(driver, tenantId, mobile);
|
||||
MpUser existing = findExistingMpUser(driver, tenantId, mobile);
|
||||
if (existing == null || Func.isEmpty(existing.getId())) {
|
||||
// 司机未关联有效用户时新建;初始密码由系统用户保存逻辑按默认参数/强度规则填充
|
||||
createAndLinkDriverUser(driver, tenantId, mobile, roleId, deptId);
|
||||
createAndLinkDriverMpUser(driver, tenantId, mobile, deptId);
|
||||
} else {
|
||||
updateAndLinkDriverUser(driver, existing, tenantId, mobile, roleId, deptId);
|
||||
updateAndLinkDriverMpUser(driver, existing, tenantId, mobile, deptId);
|
||||
}
|
||||
}
|
||||
|
||||
private User findExistingUser(Driver driver, String tenantId, String mobile) {
|
||||
private MpUser findExistingMpUser(Driver driver, String tenantId, String mobile) {
|
||||
if (Func.isNotEmpty(driver.getUserId())) {
|
||||
R<User> byId = userClient.userInfoById(driver.getUserId());
|
||||
R<MpUser> byId = mpUserClient.userById(driver.getUserId());
|
||||
if (byId != null && R.isSuccess(byId) && byId.getData() != null && Func.isNotEmpty(byId.getData().getId())) {
|
||||
return byId.getData();
|
||||
}
|
||||
// 关联的用户已不存在,清空后按手机号重建
|
||||
// 关联的小程序用户已不存在,清空后按手机号重建
|
||||
driver.setUserId(null);
|
||||
}
|
||||
return findExistingUserByAccountOrPhone(tenantId, mobile);
|
||||
return findExistingMpUserByPhone(tenantId, mobile);
|
||||
}
|
||||
|
||||
private User findExistingUserByAccountOrPhone(String tenantId, String mobile) {
|
||||
R<User> byAccount = userClient.userByAccount(tenantId, mobile);
|
||||
if (byAccount != null && R.isSuccess(byAccount) && byAccount.getData() != null
|
||||
&& Func.isNotEmpty(byAccount.getData().getId())) {
|
||||
return byAccount.getData();
|
||||
}
|
||||
R<UserInfo> byPhone = userClient.userInfoByPhone(tenantId, mobile, UserType.WEB.getName());
|
||||
private MpUser findExistingMpUserByPhone(String tenantId, String mobile) {
|
||||
R<MpUser> byPhone = mpUserClient.userByPhone(tenantId, mobile);
|
||||
if (byPhone != null && R.isSuccess(byPhone) && byPhone.getData() != null
|
||||
&& byPhone.getData().getUser() != null && Func.isNotEmpty(byPhone.getData().getUser().getId())) {
|
||||
return byPhone.getData().getUser();
|
||||
&& Func.isNotEmpty(byPhone.getData().getId())) {
|
||||
return byPhone.getData();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createAndLinkDriverUser(Driver driver, String tenantId, String mobile, String roleId, String deptId) {
|
||||
User user = buildSyncUser(null, tenantId, mobile, driver.getDriverName(), driver.getGender(), roleId, deptId);
|
||||
// 不传密码:交由 UserServiceImpl.saveUser 使用系统默认初始密码或自动生成合规密码
|
||||
user.setUserType(UserType.WEB.getCategory());
|
||||
private void createAndLinkDriverMpUser(Driver driver, String tenantId, String mobile, String deptId) {
|
||||
MpUser user = buildSyncMpUser(null, tenantId, mobile, driver.getDriverName(), driver.getGender(),
|
||||
deptId, MpUserIdentity.DRIVER.getCode());
|
||||
|
||||
R<Boolean> saveResult = null;
|
||||
R<Boolean> saveResult;
|
||||
try {
|
||||
saveResult = userClient.saveUser(user);
|
||||
saveResult = mpUserClient.saveUser(user);
|
||||
} catch (Exception ex) {
|
||||
User existed = findExistingUserByAccountOrPhone(tenantId, mobile);
|
||||
MpUser existed = findExistingMpUserByPhone(tenantId, mobile);
|
||||
if (existed != null) {
|
||||
updateAndLinkDriverUser(driver, existed, tenantId, mobile, roleId, deptId);
|
||||
updateAndLinkDriverMpUser(driver, existed, tenantId, mobile, deptId);
|
||||
return;
|
||||
}
|
||||
throw new ServiceException(Func.isNotEmpty(ex.getMessage()) ? ex.getMessage() : "同步系统用户失败");
|
||||
throw new ServiceException(Func.isNotEmpty(ex.getMessage()) ? ex.getMessage() : "同步小程序用户失败");
|
||||
}
|
||||
if (!isFeignSuccess(saveResult)) {
|
||||
User existed = findExistingUserByAccountOrPhone(tenantId, mobile);
|
||||
MpUser existed = findExistingMpUserByPhone(tenantId, mobile);
|
||||
if (existed != null) {
|
||||
updateAndLinkDriverUser(driver, existed, tenantId, mobile, roleId, deptId);
|
||||
updateAndLinkDriverMpUser(driver, existed, tenantId, mobile, deptId);
|
||||
return;
|
||||
}
|
||||
throw new ServiceException(resolveFeignError(saveResult, "同步系统用户失败"));
|
||||
throw new ServiceException(resolveFeignError(saveResult, "同步小程序用户失败"));
|
||||
}
|
||||
|
||||
R<User> created = userClient.userByAccount(tenantId, mobile);
|
||||
User createdUser = (created != null && R.isSuccess(created)) ? created.getData() : null;
|
||||
MpUser createdUser = findExistingMpUserByPhone(tenantId, mobile);
|
||||
if (createdUser == null || Func.isEmpty(createdUser.getId())) {
|
||||
createdUser = findExistingUserByAccountOrPhone(tenantId, mobile);
|
||||
}
|
||||
if (createdUser == null || Func.isEmpty(createdUser.getId())) {
|
||||
throw new ServiceException("系统用户创建成功但无法回查用户ID");
|
||||
throw new ServiceException("小程序用户创建成功但无法回查用户ID");
|
||||
}
|
||||
linkDriverUserId(driver, createdUser.getId());
|
||||
}
|
||||
|
||||
private void updateAndLinkDriverUser(Driver driver, User existing, String tenantId, String mobile, String roleId, String deptId) {
|
||||
User user = buildSyncUser(existing.getId(), tenantId, mobile, driver.getDriverName(), driver.getGender(), roleId, deptId);
|
||||
R<Boolean> updateResult = userClient.updateUser(user);
|
||||
// updateById 无字段变化时可能返回 false,但业务上仍视为成功,以接口 code 为准
|
||||
private void updateAndLinkDriverMpUser(Driver driver, MpUser existing, String tenantId, String mobile, String deptId) {
|
||||
// 保留已有管理员等身份,确保包含司机身份
|
||||
String identities = MpUserIdentity.merge(existing.getIdentities(), MpUserIdentity.DRIVER.getCode());
|
||||
MpUser user = buildSyncMpUser(existing.getId(), tenantId, mobile, driver.getDriverName(), driver.getGender(),
|
||||
deptId, identities);
|
||||
// 更新时不覆盖 openid
|
||||
user.setOpenid(null);
|
||||
R<Boolean> updateResult = mpUserClient.updateUser(user);
|
||||
if (!isFeignSuccess(updateResult)) {
|
||||
throw new ServiceException(resolveFeignError(updateResult, "同步更新系统用户失败"));
|
||||
throw new ServiceException(resolveFeignError(updateResult, "同步更新小程序用户失败"));
|
||||
}
|
||||
linkDriverUserId(driver, existing.getId());
|
||||
}
|
||||
@@ -433,9 +420,9 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
||||
return msg;
|
||||
}
|
||||
|
||||
private User buildSyncUser(Long userId, String tenantId, String mobile, String driverName, String gender,
|
||||
String roleId, String deptId) {
|
||||
User user = new User();
|
||||
private MpUser buildSyncMpUser(Long userId, String tenantId, String mobile, String driverName, String gender,
|
||||
String deptId, String identities) {
|
||||
MpUser user = new MpUser();
|
||||
user.setId(userId);
|
||||
user.setTenantId(tenantId);
|
||||
user.setAccount(mobile);
|
||||
@@ -443,8 +430,8 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
||||
user.setName(driverName);
|
||||
user.setRealName(driverName);
|
||||
user.setSex(UserSex.getCodeByName(gender));
|
||||
user.setRoleId(roleId);
|
||||
user.setDeptId(deptId);
|
||||
user.setIdentities(identities);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
+75
-4
@@ -32,7 +32,10 @@ import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.feign.IMpUserClient;
|
||||
import org.springblade.system.pojo.entity.MpUser;
|
||||
import org.springblade.transport.mapper.ExceptionDisposalMapper;
|
||||
import org.springblade.transport.mapper.WaybillEnroutePunchMapper;
|
||||
import org.springblade.transport.mapper.WaybillNodePunchMapper;
|
||||
@@ -56,6 +59,7 @@ import org.springblade.transport.pojo.vo.DriverPunchPhotoVO;
|
||||
import org.springblade.transport.pojo.vo.DriverWaybillCardVO;
|
||||
import org.springblade.transport.pojo.vo.DriverWaybillPreviewVO;
|
||||
import org.springblade.transport.pojo.vo.DriverWaybillTabCountsVO;
|
||||
import org.springblade.transport.pojo.vo.WaybillTrackVO;
|
||||
import org.springblade.transport.service.IDriverService;
|
||||
import org.springblade.transport.service.IDriverWaybillService;
|
||||
import org.springblade.transport.service.IProcessConfigService;
|
||||
@@ -120,6 +124,7 @@ public class DriverWaybillServiceImpl implements IDriverWaybillService {
|
||||
|
||||
private final IWaybillService waybillService;
|
||||
private final IDriverService driverService;
|
||||
private final IMpUserClient mpUserClient;
|
||||
private final IProcessConfigService processConfigService;
|
||||
private final ITransportVehicleService transportVehicleService;
|
||||
private final CertificationGate certificationGate;
|
||||
@@ -239,6 +244,52 @@ public class DriverWaybillServiceImpl implements IDriverWaybillService {
|
||||
return toCard(normalizeAcceptStatus(waybill), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaybillTrackVO track(Long id) {
|
||||
Driver driver = requireCurrentDriver();
|
||||
Waybill waybill = loadDriverWaybill(id, currentBoundPlates(driver));
|
||||
LocalDate[] range = resolveTrackDateRange(waybill);
|
||||
return waybillService.trackVehicle(waybill.getId(), range[0].toString(), range[1].toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 按打卡记录 / 计划时间推导轨迹查询起止日期
|
||||
*/
|
||||
private LocalDate[] resolveTrackDateRange(Waybill waybill) {
|
||||
LocalDate today = LocalDate.now();
|
||||
List<LocalDate> punchDates = new ArrayList<>();
|
||||
nodePunchMapper.selectList(Wrappers.<WaybillNodePunch>lambdaQuery()
|
||||
.eq(WaybillNodePunch::getWaybillId, waybill.getId())
|
||||
.isNotNull(WaybillNodePunch::getPunchTime)
|
||||
.orderByAsc(WaybillNodePunch::getPunchTime)).forEach(punch -> {
|
||||
if (punch.getPunchTime() != null) {
|
||||
punchDates.add(punch.getPunchTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
||||
}
|
||||
});
|
||||
enroutePunchMapper.selectList(Wrappers.<WaybillEnroutePunch>lambdaQuery()
|
||||
.eq(WaybillEnroutePunch::getWaybillId, waybill.getId())
|
||||
.isNotNull(WaybillEnroutePunch::getPunchTime)
|
||||
.orderByAsc(WaybillEnroutePunch::getPunchTime)).forEach(punch -> {
|
||||
if (punch.getPunchTime() != null) {
|
||||
punchDates.add(punch.getPunchTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
|
||||
}
|
||||
});
|
||||
punchDates.sort(LocalDate::compareTo);
|
||||
if (punchDates.size() > 1) {
|
||||
return new LocalDate[]{punchDates.get(0), punchDates.get(punchDates.size() - 1)};
|
||||
}
|
||||
if (punchDates.size() == 1) {
|
||||
return new LocalDate[]{punchDates.get(0), today};
|
||||
}
|
||||
if (waybill.getEstimatedStartTime() != null) {
|
||||
return new LocalDate[]{waybill.getEstimatedStartTime(), today};
|
||||
}
|
||||
if (waybill.getStartDate() != null) {
|
||||
return new LocalDate[]{waybill.getStartDate(), today};
|
||||
}
|
||||
return new LocalDate[]{today.minusDays(3), today};
|
||||
}
|
||||
|
||||
@Override
|
||||
public DriverWaybillCardVO detailPunchSnapshot(Long id) {
|
||||
if (id == null) {
|
||||
@@ -590,7 +641,7 @@ public class DriverWaybillServiceImpl implements IDriverWaybillService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前登录司机:优先 userId,其次 JWT 账号(手机号)匹配 driver.mobile
|
||||
* 当前登录司机:优先 userId,其次手机号(JWT 账号 / 小程序用户 account)匹配 driver.mobile
|
||||
*/
|
||||
private Driver currentDriver() {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
@@ -603,16 +654,36 @@ public class DriverWaybillServiceImpl implements IDriverWaybillService {
|
||||
if (driver != null) {
|
||||
return driver;
|
||||
}
|
||||
String account = AuthUtil.getUserAccount();
|
||||
if (Func.isNotEmpty(account) && account.matches("^1\\d{10}$")) {
|
||||
String phone = resolveSelfPhone(userId);
|
||||
if (Func.isNotEmpty(phone)) {
|
||||
return driverService.getOne(Wrappers.<Driver>lambdaQuery()
|
||||
.eq(Driver::getMobile, account.trim())
|
||||
.eq(Driver::getMobile, phone)
|
||||
.orderByDesc(Driver::getUpdateTime)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析当前小程序用户可用于匹配司机档案的手机号
|
||||
*/
|
||||
private String resolveSelfPhone(Long userId) {
|
||||
String account = AuthUtil.getUserAccount();
|
||||
if (isMobileLike(account)) {
|
||||
return account.trim();
|
||||
}
|
||||
R<MpUser> result = mpUserClient.userById(userId);
|
||||
if (result != null && R.isSuccess(result) && result.getData() != null
|
||||
&& isMobileLike(result.getData().getAccount())) {
|
||||
return result.getData().getAccount().trim();
|
||||
}
|
||||
return Func.isEmpty(account) ? null : account.trim();
|
||||
}
|
||||
|
||||
private boolean isMobileLike(String value) {
|
||||
return Func.isNotEmpty(value) && value.trim().matches("^1\\d{10,14}$");
|
||||
}
|
||||
|
||||
private List<String> splitPlates(String drivingVehicle) {
|
||||
return VehiclePlateSupport.splitPlates(drivingVehicle);
|
||||
}
|
||||
|
||||
+6
-6
@@ -31,7 +31,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.cache.UserDisplayCache;
|
||||
import org.springblade.transport.mapper.ExceptionDisposalFollowRecordMapper;
|
||||
import org.springblade.transport.mapper.ExceptionDisposalMapper;
|
||||
import org.springblade.transport.pojo.dto.ExceptionDisposalFollowRequest;
|
||||
@@ -131,7 +131,7 @@ public class ExceptionDisposalServiceImpl
|
||||
disposal.setDisposalStatus(STATUS_PENDING);
|
||||
disposal.setReportTime(LocalDateTime.now());
|
||||
disposal.setReporterId(AuthUtil.getUserId());
|
||||
disposal.setReporterName(UserCache.getUserRealName(AuthUtil.getUserId()));
|
||||
disposal.setReporterName(UserDisplayCache.getUserRealName(AuthUtil.getUserId()));
|
||||
|
||||
fillFromWaybill(disposal, request.getWaybillId(), request.getWaybillNo());
|
||||
|
||||
@@ -267,7 +267,7 @@ public class ExceptionDisposalServiceImpl
|
||||
record.setDisposalId(disposal.getId());
|
||||
record.setFollowContent(changeLog);
|
||||
record.setFollowUser(AuthUtil.getUserId());
|
||||
record.setFollowUserName(UserCache.getUserRealName(AuthUtil.getUserId()));
|
||||
record.setFollowUserName(UserDisplayCache.getUserRealName(AuthUtil.getUserId()));
|
||||
record.setFollowTime(LocalDateTime.now());
|
||||
followRecordMapper.insert(record);
|
||||
}
|
||||
@@ -344,7 +344,7 @@ public class ExceptionDisposalServiceImpl
|
||||
record.setFollowContent(Func.isBlank(followContent) ? "已上传跟进附件" : followContent);
|
||||
record.setAttachmentsJson(hasAttachments ? request.getAttachmentsJson() : null);
|
||||
record.setFollowUser(AuthUtil.getUserId());
|
||||
record.setFollowUserName(UserCache.getUserRealName(AuthUtil.getUserId()));
|
||||
record.setFollowUserName(UserDisplayCache.getUserRealName(AuthUtil.getUserId()));
|
||||
record.setFollowTime(LocalDateTime.now());
|
||||
followRecordMapper.insert(record);
|
||||
}
|
||||
@@ -417,8 +417,8 @@ public class ExceptionDisposalServiceImpl
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
vo.setCreateUserName(UserCache.getUserRealName(entity.getCreateUser()));
|
||||
vo.setUpdateUserName(UserCache.getUserRealName(entity.getUpdateUser()));
|
||||
vo.setCreateUserName(UserDisplayCache.getUserRealName(entity.getCreateUser()));
|
||||
vo.setUpdateUserName(UserDisplayCache.getUserRealName(entity.getUpdateUser()));
|
||||
vo.setDisposalStatusName(statusName(entity.getDisposalStatus()));
|
||||
vo.setScenePhotoList(splitPhotos(entity.getScenePhotos()));
|
||||
fillRouteAndCargo(vo, entity.getWaybillId());
|
||||
|
||||
+5
-4
@@ -30,7 +30,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.cache.UserDisplayCache;
|
||||
import org.springblade.transport.pojo.entity.Driver;
|
||||
import org.springblade.transport.pojo.entity.ExceptionDisposal;
|
||||
import org.springblade.transport.pojo.entity.RiskDisposal;
|
||||
@@ -688,11 +688,12 @@ public class ManageWaybillServiceImpl implements IManageWaybillService {
|
||||
}
|
||||
|
||||
private String resolveUserName() {
|
||||
String realName = UserCache.getUserRealName(AuthUtil.getUserId());
|
||||
if (Func.isNotBlank(realName)) {
|
||||
String realName = UserDisplayCache.getUserRealName(AuthUtil.getUserId());
|
||||
if (Func.isNotBlank(realName) && !Func.toStr(AuthUtil.getUserId()).equals(realName)) {
|
||||
return realName;
|
||||
}
|
||||
return Func.toStr(AuthUtil.getUserName(), "");
|
||||
String jwtName = Func.toStr(AuthUtil.getNickName(), AuthUtil.getUserName());
|
||||
return Func.toStr(jwtName, realName);
|
||||
}
|
||||
|
||||
/** 相对时间文案;时间取不到时留空,避免把「现在」当成发生时刻显示成「刚刚」 */
|
||||
|
||||
+5
-3
@@ -28,6 +28,7 @@ package org.springblade.transport.wrapper;
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.cache.UserDisplayCache;
|
||||
import org.springblade.transport.pojo.entity.TransportCertRecord;
|
||||
import org.springblade.transport.pojo.vo.TransportCertRecordVO;
|
||||
import org.springblade.transport.support.CertificationRuleSupport;
|
||||
@@ -62,9 +63,10 @@ public class TransportCertRecordWrapper extends BaseEntityWrapper<TransportCertR
|
||||
* @return 同一个对象,便于链式调用
|
||||
*/
|
||||
public TransportCertRecordVO fillDisplayFields(TransportCertRecordVO transportCertRecordVO) {
|
||||
transportCertRecordVO.setCreateUserName(UserCache.getUserRealName(transportCertRecordVO.getCreateUser()));
|
||||
transportCertRecordVO.setUpdateUserName(UserCache.getUserRealName(transportCertRecordVO.getUpdateUser()));
|
||||
transportCertRecordVO.setSubmitUserName(UserCache.getUserRealName(transportCertRecordVO.getSubmitUser()));
|
||||
// create/update/submit 可能来自小程序用户;audit 一般为后台系统用户
|
||||
transportCertRecordVO.setCreateUserName(UserDisplayCache.getUserRealName(transportCertRecordVO.getCreateUser()));
|
||||
transportCertRecordVO.setUpdateUserName(UserDisplayCache.getUserRealName(transportCertRecordVO.getUpdateUser()));
|
||||
transportCertRecordVO.setSubmitUserName(UserDisplayCache.getUserRealName(transportCertRecordVO.getSubmitUser()));
|
||||
transportCertRecordVO.setAuditUserName(UserCache.getUserRealName(transportCertRecordVO.getAuditUser()));
|
||||
// 状态文案统一在此翻译,避免小程序、Web、接口各处各造一套说法
|
||||
transportCertRecordVO.setStatusText(CertificationRuleSupport.statusText(transportCertRecordVO.getStatus()));
|
||||
|
||||
+10
-11
@@ -8,13 +8,13 @@ import org.mockito.MockedStatic;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.feign.IMpUserClient;
|
||||
import org.springblade.system.pojo.entity.MpUser;
|
||||
import org.springblade.transport.pojo.entity.Driver;
|
||||
import org.springblade.transport.pojo.entity.TransportVehicle;
|
||||
import org.springblade.transport.pojo.vo.DriverVehicleCardVO;
|
||||
import org.springblade.transport.service.IDriverService;
|
||||
import org.springblade.transport.service.ITransportVehicleService;
|
||||
import org.springblade.system.feign.IUserClient;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
@@ -46,7 +46,7 @@ class DriverAppServiceImplTest {
|
||||
void setUp() {
|
||||
driverService = mock(IDriverService.class);
|
||||
transportVehicleService = mock(ITransportVehicleService.class);
|
||||
service = new DriverAppServiceImpl(driverService, transportVehicleService, mock(IUserClient.class));
|
||||
service = new DriverAppServiceImpl(driverService, transportVehicleService, mock(IMpUserClient.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,9 +94,9 @@ class DriverAppServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("用户中心 phone 是脱敏串时改用其 account——脱敏 phone 既查不到档案,也会把本人真实号码误判成越权")
|
||||
@DisplayName("小程序用户 phone 是脱敏串时改用其 account——脱敏 phone 既查不到档案,也会把本人真实号码误判成越权")
|
||||
void maskedUserPhoneFallsBackToAccount() {
|
||||
User user = new User();
|
||||
MpUser user = new MpUser();
|
||||
user.setPhone("175****12082");
|
||||
user.setAccount("175874212082");
|
||||
|
||||
@@ -156,14 +156,14 @@ class DriverAppServiceImplTest {
|
||||
*
|
||||
* @param mobileHint 前端传入的 mobile,可为 null
|
||||
* @param account JWT 里的账号,可为 null
|
||||
* @param user 用户中心返回的用户,可为 null(表示走不到用户中心)
|
||||
* @param user 小程序用户,可为 null(表示走不到小程序用户中心)
|
||||
*/
|
||||
private Driver currentByPhone(String mobileHint, String account, User user) {
|
||||
IUserClient userClient = mock(IUserClient.class);
|
||||
private Driver currentByPhone(String mobileHint, String account, MpUser user) {
|
||||
IMpUserClient mpUserClient = mock(IMpUserClient.class);
|
||||
if (user != null) {
|
||||
when(userClient.userInfoById(USER_ID)).thenReturn(R.data(user));
|
||||
when(mpUserClient.userById(USER_ID)).thenReturn(R.data(user));
|
||||
}
|
||||
DriverAppServiceImpl scoped = new DriverAppServiceImpl(driverService, transportVehicleService, userClient);
|
||||
DriverAppServiceImpl scoped = new DriverAppServiceImpl(driverService, transportVehicleService, mpUserClient);
|
||||
|
||||
Driver driver = new Driver();
|
||||
driver.setId(9002L);
|
||||
@@ -178,5 +178,4 @@ class DriverAppServiceImplTest {
|
||||
return scoped.currentByPhone(mobileHint);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.cache.UserDisplayCache;
|
||||
import org.springblade.transport.mapper.ExceptionDisposalFollowRecordMapper;
|
||||
import org.springblade.transport.mapper.ExceptionDisposalMapper;
|
||||
import org.springblade.transport.pojo.entity.ExceptionDisposal;
|
||||
@@ -320,9 +320,9 @@ class ExceptionDisposalReportGateTest {
|
||||
|
||||
private void runSubmit(ExceptionDisposal request) {
|
||||
try (MockedStatic<AuthUtil> authUtil = mockStatic(AuthUtil.class);
|
||||
MockedStatic<UserCache> userCache = mockStatic(UserCache.class)) {
|
||||
MockedStatic<UserDisplayCache> userCache = mockStatic(UserDisplayCache.class)) {
|
||||
authUtil.when(AuthUtil::getUserId).thenReturn(USER_ID);
|
||||
userCache.when(() -> UserCache.getUserRealName(USER_ID)).thenReturn("韦司机");
|
||||
userCache.when(() -> UserDisplayCache.getUserRealName(USER_ID)).thenReturn("韦司机");
|
||||
service.submitReport(request);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user