Commit f7252270 by 章家宝

feat: 1 校验日志中的状态、时间,改成中文描述。2 对短信模板进行检查。3 检测师h5对工单,报告进行根据生成时间倒叙展示。4 检测师h5新增一个模糊查询参数。

1 parent 27173328
......@@ -86,6 +86,11 @@ public interface JpaQueryConstants {
* 关键字,检测师名称或手机号,模糊查询
*/
String KEYWORD = "keyword";
/**
* 关键字,车牌号/VIN码/车型 模糊查询
*/
String CARTYPE = "carTypeName";
/**
* 精确匹配
*/
......
......@@ -3,7 +3,6 @@ package com.glsx.usedcar.enums.inspect;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
......@@ -89,4 +88,10 @@ public enum InspectionWorkOrderStatusEnum {
public static Boolean beableInspection(Integer status) {
return Arrays.asList(DISPATCHED.getCode(), IN_PROGRESS.getCode()).contains(status);
}
// 根据工单状态获取工单状态描述
public static String getDescByStatus(Integer status) {
InspectionWorkOrderStatusEnum statusEnum = InspectionWorkOrderStatusEnum.getByCode(status);
return statusEnum != null ? statusEnum.getDesc() : "";
}
}
\ No newline at end of file
......@@ -457,6 +457,19 @@ public class InspectionReportService {
builder.like(root.get(InspectionReport_.vehicle).get(Vehicle_.baseInfo).get(BaseInfo_.vin), likePattern)
));
}
Object carType = pagination.getFilterValueOrElseNull(JpaQueryConstants.InspectionReport.CARTYPE);
if (carType instanceof String ct && StrUtil.isNotBlank(ct)) {
pagination.removeFilter(JpaQueryConstants.InspectionReport.CARTYPE);
String likePattern = SymbolConsts.PERCENT + ct + SymbolConsts.PERCENT;
pagination.addCondition((root, query, builder) -> builder.or(
builder.like(root.get(InspectionReport_.vehicle).get(Vehicle_.baseInfo).get(BaseInfo_.licensePlate), likePattern),
builder.like(root.get(InspectionReport_.vehicle).get(Vehicle_.baseInfo).get(BaseInfo_.vin), likePattern),
builder.like(root.get(InspectionReport_.vehicle).get(Vehicle_.baseInfo).get(BaseInfo_.carTypeName), likePattern),
builder.like(root.get(InspectionReport_.vehicle).get(Vehicle_.baseInfo).get(BaseInfo_.carChildsBrandName), likePattern),
builder.like(root.get(InspectionReport_.vehicle).get(Vehicle_.baseInfo).get(BaseInfo_.carSeriesName), likePattern),
builder.like(root.get(InspectionReport_.vehicle).get(Vehicle_.baseInfo).get(BaseInfo_.carBrand), likePattern)
));
}
Object status = pagination.getFilterValueOrElseNull(JpaQueryConstants.InspectionReport.VEHICLE_STATE);
if (status instanceof String s && StrUtil.isNotBlank(s)) {
pagination.removeFilter(JpaQueryConstants.InspectionReport.VEHICLE_STATE);
......
......@@ -140,14 +140,15 @@ public class InspectionWorkOrderService {
wo.setUpdateBy(opName);
wo.setUpdateTime(now);
inspectionWorkOrderRepository.save(wo);
Object[] args = {vehicle.getBaseInfo().getCarTypeName()};
String seriesName = vehicle.getBaseInfo().getCarSeriesName() == null ? "" : vehicle.getBaseInfo().getCarSeriesName();
String carName = seriesName + vehicle.getBaseInfo().getCarTypeName();
Object[] args = {carName};
String message = messageSource.getMessage("SMS.INSPECTION.WO.ADD", args, Locale.CHINESE);
log.info("发送工单新增短信: 手机号={}, 内容={}", wo.getInspector().getPhone(), message);
gscApiInvoker.sendMsg(wo.getInspector().getPhone(), message);
String operationContent = String.format("新增检测工单,车辆ID:%s,检测师ID:%s,检测地址:%s", vehicleId, inspectorId, addVO.getInspectionAddress());
saveWorkOrderOpLog(wo, InspectionWorkOrderOperationTypeEnum.CREATE_ORDER.getCode(), 0, wo.getStatus(), operationContent, "用户新增检测工单" + operationContent, Long.valueOf(opId), opName, platTypeEnum.getCode());
String operationContent = String.format("新增检测工单,车辆ID:%s,检测师ID:%s,检测地址:%s", vehicleId, inspector.getName(), addVO.getInspectionAddress());
saveWorkOrderOpLog(wo, InspectionWorkOrderOperationTypeEnum.CREATE_ORDER.getCode(), 0, wo.getStatus(), operationContent, operationContent, Long.valueOf(opId), opName, platTypeEnum.getCode());
log.info("检测工单新增成功: ID={}, 唯一ID={}, 操作人={}, 平台={}", wo.getId(), wo.getWoId(), opName, platTypeEnum.getDesc());
}
......@@ -172,6 +173,7 @@ public class InspectionWorkOrderService {
Integer originalStatus = workOrder.getStatus();
Long originalInspectorId = workOrder.getInspector() != null ? workOrder.getInspector().getId() : null;
String originalInspectorName = workOrder.getInspector() != null ? workOrder.getInspector().getName() : null;
Inspector originalInspector = workOrder.getInspector();
String originalRemark = workOrder.getRemark();
String originalInspectionAddress = workOrder.getInspectionAddress();
......@@ -183,7 +185,7 @@ public class InspectionWorkOrderService {
Inspector inspector = inspectorRepository.findByIdAndDeleteFlag(updateVO.getInspectorId(), DeleteFlag.NOT_DELETED.getCode()).orElseThrow(() -> new BusinessCodeException(ErrorCodeEnum.PARAM_ERROR, "检测师不存在,检测师ID:" + updateVO.getInspectorId()));
if (!updateVO.getInspectorId().equals(originalInspectorId)) {
workOrder.setInspector(inspector);
modifyContent.append(String.format("检测师从ID:%s改为ID:%s;", originalInspectorId, updateVO.getInspectorId()));
modifyContent.append(String.format("检测师从ID:%s改为ID:%s;", originalInspectorName, inspector.getName()));
isModified = true;
Object[] args = {workOrder.getWoId()};
......@@ -413,7 +415,7 @@ public class InspectionWorkOrderService {
log.info("发送取消短信: 手机号={}, 内容={}", wo.getInspector().getPhone(), message);
gscApiInvoker.sendMsg(wo.getInspector().getPhone(), message);
String operationContent = String.format("取消检测工单,取消原因:%s,原状态:%s", vo.getCancelReason(), originalStatus);
String description = "取消检测工单,状态从" + originalStatus + "改为" + InspectionWorkOrderStatusEnum.CANCELED.getCode() + ", 取消类型:" + vo.getCancelType() + ", 取消原因:" + vo.getCancelReason();
String description = "取消检测工单,状态从" + InspectionWorkOrderStatusEnum.getDescByStatus(originalStatus) + "改为" + InspectionWorkOrderStatusEnum.CANCELED.getDesc() + ", 取消类型:" + vo.getCancelType() + ", 取消原因:" + vo.getCancelReason();
saveWorkOrderOpLog(wo, InspectionWorkOrderOperationTypeEnum.CANCEL_ORDER.getCode(), originalStatus, InspectionWorkOrderStatusEnum.CANCELED.getCode(), operationContent, description, Long.valueOf(opId), opName, platTypeEnum.getCode());
log.info("检测工单取消成功: ID={}, 唯一ID={}, 取消原因={}", wo.getId(), wo.getWoId(), vo.getCancelReason());
......@@ -530,7 +532,7 @@ public class InspectionWorkOrderService {
operationContent = String.format("同意审批工单,工单ID:%s,审批意见:%s,已生成检测报告", auditVO.getId(), auditVO.getAuditOpinion());
description = String.format("审批工单[%s]通过,状态从[%s]改为[%s],生成检测报告",
workOrder.getWoId(), originalAuditStatus, targetAuditStatus);
workOrder.getWoId(), InspectionWorkOrderAuditStatusEnum.WAIT_AUDIT.getDesc(), InspectionWorkOrderAuditStatusEnum.PASS.getDesc());
auditOperationType = InspectionWorkOrderOperationTypeEnum.APPROVE_PASS;
} else {
// 4.2 不同意审批:更新审批状态为拒绝, 更新工单状态为检测中,不生成报告
......@@ -543,14 +545,19 @@ public class InspectionWorkOrderService {
workOrder.setUpdateTime(now);
inspectionWorkOrderRepository.save(workOrder);
Object[] args = {workOrder.getWoId(), auditVO.getAuditOpinion()};
Object[] args = {workOrder.getWoId()};
String message = messageSource.getMessage("SMS.INSPECTION.WO.REJECT", args, Locale.CHINESE);
log.info("发送工单驳回短信: 手机号={}, 内容={}", workOrder.getInspector().getPhone(), message);
gscApiInvoker.sendMsg(workOrder.getInspector().getPhone(), message);
operationContent = String.format("驳回审批工单,工单ID:%s,审批意见:%s", auditVO.getId(), auditVO.getAuditOpinion());
description = String.format("审批工单[%s]驳回,审批状态从[%s]改为[%s], 工单状态从[%s]改为[%s],未生成检测报告",
workOrder.getWoId(), originalAuditStatus, targetAuditStatus, originalStatus, InspectionWorkOrderStatusEnum.IN_PROGRESS.getCode());
workOrder.getWoId(),
InspectionWorkOrderAuditStatusEnum.WAIT_AUDIT.getDesc(),
InspectionWorkOrderAuditStatusEnum.REJECT.getDesc(),
InspectionWorkOrderStatusEnum.getDescByStatus(originalStatus),
InspectionWorkOrderStatusEnum.getDescByStatus(InspectionWorkOrderStatusEnum.IN_PROGRESS.getCode())
);
auditOperationType = InspectionWorkOrderOperationTypeEnum.APPROVE_REJECT;
}
......@@ -613,7 +620,7 @@ public class InspectionWorkOrderService {
// 5. 保存操作日志
String operationContent = String.format("开始检测,工单ID:%s,原状态:已派单,新状态:检测中", id);
String description = String.format("操作人[%s]启动工单检测,开始时间:%s", opName, now);
String description = String.format("开始检测 操作人[%s]启动工单检测,开始时间:%s", opName, now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
saveWorkOrderOpLog(workOrder,
InspectionWorkOrderOperationTypeEnum.START_INSPECTION.getCode(),
originalStatus,
......@@ -670,7 +677,7 @@ public class InspectionWorkOrderService {
// 5. 保存操作日志
String operationContent = String.format("完成检测,工单ID:%s,原状态:检测中,新状态:已完成", id);
String description = String.format("操作人[%s]完成工单检测,结束时间:%s", opName, now);
String description = String.format("操作人[%s]完成工单检测,结束时间:%s", opName, now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
saveWorkOrderOpLog(workOrder,
InspectionWorkOrderOperationTypeEnum.COMPLETE_ORDER.getCode(),
originalStatus,
......
......@@ -86,7 +86,7 @@ public class SmsCodeUtil {
String code = RandomUtil.randomNumbers(codeLength);
redisCacheUtil.setCacheWithExpire("SMS:CODE:" + phone, code, codeExpire, TimeUnit.SECONDS);
String message = messageSource.getMessage("Inspector.Login.SMSCODE", new Object[]{code, codeExpire / 60}, Locale.CHINESE);
String message = messageSource.getMessage("Inspector.Login.SMSCODE", new Object[]{code}, Locale.CHINESE);
boolean sendResult = gscApiInvoker.sendMsg(phone, message);
if (!sendResult) {
throw new BusinessCodeException(ErrorCodeEnum.COMMON_ERROR, "发送短信失败");
......
......@@ -61,10 +61,10 @@ Account.AccountType.COMPANY=\u8F66\u5546\u7528\u6237
Deposit.RefundState.UNREFUND=\u672A\u9000\u6B3E
Deposit.RefundState.REFUNDING=\u9000\u6B3E\u4E2D
Deposit.RefundState.REFUNDED=\u5DF2\u9000\u6B3E
Inspector.Login.SMSCODE=\u60a8\u6b63\u5728\u767b\u5f55\u68c0\u6d4b\u7cfb\u7edf\u8d26\u53f7\uff0c\u9a8c\u8bc1\u7801\uff1a{0}\uff0c{1}\u5206\u949f\u5185\u6709\u6548\u3002\u5982\u975e\u672c\u4eba\u64cd\u4f5c\uff0c\u8bf7\u5ffd\u7565\u6b64\u77ed\u4fe1\u3002
SMS.INSPECTION.WO.CANCEL=\u60a8\u597d\u3002\u60a8\u6240\u8d1f\u8d23\u7684\u68c0\u6d4b\u5de5\u5355 {0} \u5df2\u88ab\u53d6\u6d88\uff0c\u4efb\u52a1\u72b6\u6001\u5df2\u66f4\u65b0\u4e3a\u201c\u5df2\u53d6\u6d88\u201d\uff0c\u8bf7\u52ff\u518d\u524d\u5f80\u68c0\u6d4b\u3002
Inspector.Login.SMSCODE=\u60a8\u6b63\u5728\u767b\u5f55\u68c0\u6d4b\u7cfb\u7edf\u8d26\u53f7\uff0c\u9a8c\u8bc1\u7801\uff1a{0}\uff0c5\u5206\u949f\u5185\u6709\u6548\u3002\u5982\u975e\u672c\u4eba\u64cd\u4f5c\uff0c\u8bf7\u5ffd\u7565\u6b64\u77ed\u4fe1\u3002
SMS.INSPECTION.WO.CANCEL=\u60a8\u597d\u3002\u60a8\u6240\u8d1f\u8d23\u7684\u68c0\u6d4b\u5de5\u5355{0}\u5df2\u88ab\u53d6\u6d88\uff0c\u4efb\u52a1\u72b6\u6001\u5df2\u66f4\u65b0\u4e3a\u201c\u5df2\u53d6\u6d88\u201d\uff0c\u8bf7\u52ff\u518d\u524d\u5f80\u68c0\u6d4b\u3002
SMS.INSPECTION.WO.ADD=\u60a8\u6709\u65b0\u7684\u8f66\u8f86\u68c0\u6d4b\u4efb\u52a1\u5f85\u68c0\u6d4b\uff0c\u8bf7\u53ca\u65f6\u5904\u7406\u3002\u4efb\u52a1\u8f66\u8f86\uff1a{0}
SMS.INSPECTION.WO.UPDATE=\u68c0\u6d4b\u5de5\u5355{0}\u4efb\u52a1\u5df2\u66f4\u65b0\uff0c\u8bf7\u53ca\u65f6\u67e5\u770b\u3002
SMS.INSPECTION.WO.UPDATE.INSPECTOR_NEW=\u60a8\u597d\uff0c\u60a8\u5df2\u88ab\u66f4\u65b0\u4e3a\u68c0\u6d4b\u4eba\u5458\u4fe1\u606f\uff0c\u5de5\u5355\u53f7\u3010{0}\u3011\u3002\u540e\u7eed\u8bf7\u6309\u8981\u6c42\u53ca\u65f6\u5f00\u5c55\u68c0\u6d4b\u5de5\u4f5c\uff0c\u4fdd\u6301\u901a\u8baf\u7545\u901a\u3002
SMS.INSPECTION.WO.UPDATE.INSPECTOR_NEW=\u60a8\u597d\uff0c\u60a8\u5df2\u88ab\u66f4\u65b0\u4e3a\u68c0\u6d4b\u4eba\u5458\u4fe1\u606f\uff0c\u5de5\u5355\u53f7{0}\u3002\u540e\u7eed\u8bf7\u6309\u8981\u6c42\u53ca\u65f6\u5f00\u5c55\u68c0\u6d4b\u5de5\u4f5c\uff0c\u4fdd\u6301\u901a\u8baf\u7545\u901a\u3002
SMS.INSPECTION.WO.UPDATE.INSPECTOR_ORIGIN=\u60a8\u597d\uff0c\u7cfb\u7edf\u5df2\u66f4\u65b0\u68c0\u6d4b\u4eba\u5458\u540d\u5355\uff0c\u60a8\u4ecd\u4fdd\u7559\u68c0\u6d4b\u4eba\u5458\u8d44\u683c\uff0c\u8bf7\u7ee7\u7eed\u6309\u89c4\u8303\u5f00\u5c55\u68c0\u6d4b\u5de5\u4f5c\uff0c\u4fdd\u6301\u901a\u8baf\u7545\u901a\uff0c\u5982\u6709\u53d8\u52a8\u5c06\u53e6\u884c\u901a\u77e5\u3002
SMS.INSPECTION.WO.REJECT=\u3010\u68c0\u6d4b\u5de5\u5355\u9a73\u56de\u901a\u77e5\u3011\u60a8\u63d0\u4ea4\u7684\u68c0\u6d4b\u5de5\u5355\uff08\u7f16\u53f7\uff1a{0}\uff09\u5df2\u9a73\u56de\uff0c\u9a73\u56de\u539f\u56e0\uff1a{1}\u3002
SMS.INSPECTION.WO.REJECT=\u60a8\u63d0\u4ea4\u7684\u68c0\u6d4b\u5de5\u5355\u7f16\u53f7\uff1a{0}\u5df2\u9a73\u56de\uff0c\u8bf7\u67e5\u770b
......@@ -19,7 +19,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
/**
......@@ -94,7 +93,7 @@ public class AuthController {
return BaseResp.fail("用户不存在");
}
String code = loginRequest.getVerifyCode();
if (!smsCodeUtil.validateCode(phone, code) && !envProfileUtils.isDevEnvironment() && !envProfileUtils.isTestEnvironment()) {
if (!smsCodeUtil.validateCode(phone, code) && !envProfileUtils.isDevEnvironment()) {
log.warn("用户手机号{}验证码错误", phone);
return BaseResp.fail("验证码错误或已过期");
}
......@@ -111,7 +110,6 @@ public class AuthController {
* 退出登录接口(需携带有效登录Token)
* 注:当前仅返回退出成功,实际生产环境可补充Token黑名单/失效逻辑
*
* @param request HttpServletRequest:用于获取登录态中的检测员手机号
* @return 退出结果:success=true表示退出成功
*/
@Operation(
......@@ -120,9 +118,7 @@ public class AuthController {
)
@PostMapping("/logout")
@RequireLogin
public BaseResp<Boolean> logout(
@Parameter(hidden = true)
HttpServletRequest request) {
public BaseResp<Boolean> logout() {
String phone = InspectorContext.getPhone();
log.info("检测员{}执行退出登录操作", phone);
return BaseResp.success(true);
......
......@@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.summerframework.orm.paging.Operator;
......@@ -47,7 +48,12 @@ public class InspectionReportController {
try {
// 2. 构建分页对象(offset = (页码-1)*每页条数)
Pagination<InspectionReport> pagination = new Pagination<>((page - 1) * size, size);
if (StringUtils.isNotBlank(req.getKeyword())) {
pagination.addFilter(JpaQueryConstants.InspectionReport.CARTYPE, req.getKeyword(), Operator.eq);
}
pagination.addFilter(JpaQueryConstants.InspectionReport.INSPECTOR_ID, InspectorContext.getInspectorId(), Operator.eq);
pagination.setSort("createTime");
pagination.setOrder("desc");
// 3. 调用Service查询(若有关键词过滤,可在此添加pagination.addFilter逻辑)
Page<InspectionReportRespVO> result = inspectionReportService.pageList(pagination);
return BaseResp.success(result);
......
......@@ -50,6 +50,8 @@ public class InspectionWorkOrderController {
Pagination<InspectionWorkOrder> pagination = new Pagination<>((page - 1) * size, size);
pagination.addFilter(JpaQueryConstants.InspectionWorkOrder.STATUS, req.getStatus(), Operator.eq);
pagination.addFilter(JpaQueryConstants.InspectionWorkOrder.INSPECTOR_ID, InspectorContext.getInspectorId(), Operator.eq);
pagination.setSort("createTime");
pagination.setOrder("desc");
if (StringUtils.isNotBlank(req.getKeyword())) {
pagination.addFilter(JpaQueryConstants.InspectionWorkOrder.CARTYPE, req.getKeyword(), Operator.eq);
}
......
......@@ -18,4 +18,7 @@ public class InspectionReportReq {
@Schema(description = "页码,默认1(从1开始)", example = "1")
private Integer page;
@Schema(description = "模糊查询参数", example = "1")
private String keyword;
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!