✨ 补充应收账单用户ID记录及迁移脚本
This commit is contained in:
@@ -12,5 +12,5 @@ public interface IArBillLogService {
|
||||
void record(ArBillLog log);
|
||||
|
||||
void recordFailure(Long arBillId, ArLogObjectType objectType, String objectId, ArLogOperationType operationType,
|
||||
String fromStatus, String message, String operator, String requestId);
|
||||
String fromStatus, String message, Long operatorId, String operatorName, String requestId);
|
||||
}
|
||||
|
||||
+2
-2
@@ -26,11 +26,11 @@ import com.bms.ar.mapper.ArBillMapper;
|
||||
import com.bms.ar.service.IArBalanceWriteoffService;
|
||||
import com.bms.ar.service.IArBillLogService;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.customer.customermoney.domain.CustomerReceipt;
|
||||
import com.bms.customer.customermoney.domain.ReceiptWriteoffPlan;
|
||||
import com.bms.customer.customermoney.mapper.CustomerMoneyMapper;
|
||||
import com.bms.customer.customermoney.mapper.ReceiptWriteoffPlanMapper;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
|
||||
/**
|
||||
@@ -286,7 +286,7 @@ public class ArBalanceWriteoffServiceImpl implements IArBalanceWriteoffService {
|
||||
log.setOperationDesc(desc);
|
||||
log.setFromStatus(fromStatus);
|
||||
log.setToStatus(toStatus);
|
||||
log.setOperatorId(operator);
|
||||
log.setOperatorId(SecurityUtils.getUserId());
|
||||
log.setOperatorName(operator);
|
||||
log.setOperationSource(ArLogOperationSource.WEB.getCode());
|
||||
log.setRequestId(requestId);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ArBillLogServiceImpl implements IArBillLogService {
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void recordFailure(Long arBillId, ArLogObjectType objectType, String objectId, ArLogOperationType operationType,
|
||||
String fromStatus, String message, String operator, String requestId) {
|
||||
String fromStatus, String message, Long operatorId, String operatorName, String requestId) {
|
||||
ArBillLog log = new ArBillLog();
|
||||
log.setArBillId(arBillId);
|
||||
log.setObjectType(objectType.getCode());
|
||||
@@ -44,8 +44,8 @@ public class ArBillLogServiceImpl implements IArBillLogService {
|
||||
log.setOperationType(operationType.getCode());
|
||||
log.setOperationDesc(message);
|
||||
log.setFromStatus(fromStatus);
|
||||
log.setOperatorId(operator);
|
||||
log.setOperatorName(operator);
|
||||
log.setOperatorId(operatorId);
|
||||
log.setOperatorName(operatorName);
|
||||
log.setOperationSource(ArLogOperationSource.WEB.getCode());
|
||||
log.setRequestId(requestId == null ? IdUtils.fastSimpleUUID() : requestId);
|
||||
log.setResult(ArLogResult.FAILED.getCode());
|
||||
|
||||
@@ -81,6 +81,7 @@ import com.bms.ar.domain.vo.ArBillQuery;
|
||||
import com.bms.common.config.BmsConfig;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.DateUtils;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
import com.bms.common.utils.file.FileUtils;
|
||||
import com.bms.common.utils.file.OssStorage;
|
||||
@@ -326,6 +327,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ArBillGenerateTask generateBill(ArBillGenerateRequest request, String operator, String requestId) {
|
||||
long startedAt = System.nanoTime();
|
||||
Long createUserId = SecurityUtils.getUserId();
|
||||
validatePeriod(request);
|
||||
ArBillGenerateTask existed = generateTaskMapper.selectByRequestToken(requestId);
|
||||
if (existed != null) {
|
||||
@@ -400,6 +402,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
bill.setBankName(bankAccount.getBankName());
|
||||
bill.setRemark(request.getRemark());
|
||||
bill.setCreateBy(operator);
|
||||
bill.setCreateUserId(createUserId);
|
||||
bill.setUpdateBy(operator);
|
||||
billMapper.insertArBill(bill);
|
||||
|
||||
@@ -417,6 +420,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
task.setStatus(ArBillGenerateTaskStatus.WAITING);
|
||||
task.setRequestToken(requestId);
|
||||
task.setCreateBy(operator);
|
||||
task.setCreateUserId(createUserId);
|
||||
generateTaskMapper.insert(task);
|
||||
eventPublisher.publishEvent(new ArBillGenerateTaskEvent(task.getTaskId()));
|
||||
log.info("应收账单生成任务已创建,operator={}, requestId={}, customerId={}, billPeriodEnd={}, selectionMode={}, selectedCount={}, excludedCount={}, taskId={}, status={}, costMs={}",
|
||||
@@ -798,7 +802,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
try {
|
||||
logService.recordFailure(task.getArBillId(), ArLogObjectType.BILL,
|
||||
String.valueOf(task.getTaskId()), ArLogOperationType.CREATE, ArBillStatus.DRAFT.getCode(),
|
||||
message, operator, requestId);
|
||||
message, task.getCreateUserId(), operator, requestId);
|
||||
} catch (Exception logException) {
|
||||
log.warn("账单生成失败日志写入失败,但任务清理已完成,taskId={}", task.getTaskId(), logException);
|
||||
}
|
||||
@@ -851,7 +855,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
}
|
||||
recordSuccess(finalBill, ArLogObjectType.BILL, ArLogOperationType.CREATE,
|
||||
"异步生成正式账单", ArBillStatus.DRAFT.getCode(), ArBillStatus.DRAFT.getCode(),
|
||||
task.getRequestToken(), task.getCreateBy());
|
||||
task.getRequestToken(), task.getCreateUserId(), task.getCreateBy());
|
||||
}
|
||||
|
||||
private String generateFailureMessage(Exception e) {
|
||||
@@ -903,7 +907,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
}
|
||||
// 应收账单只负责形成应收,不参与客户余额或授信额度变更。
|
||||
recordSuccess(bill, ArLogObjectType.BILL, ArLogOperationType.CONFIRM,
|
||||
"确认应收账单", ArBillStatus.DRAFT.getCode(), ArBillStatus.CONFIRMED.getCode(), requestId, operator);
|
||||
"确认应收账单", ArBillStatus.DRAFT.getCode(), ArBillStatus.CONFIRMED.getCode(), requestId,
|
||||
SecurityUtils.getUserId(), operator);
|
||||
ArBill result = selectArBillById(arBillId);
|
||||
log.info("应收账单确认处理完成,operator={}, requestId={}, arBillId={}, status={}, costMs={}",
|
||||
safeLogValue(operator), safeLogValue(requestId), arBillId, result.getStatus(), elapsedMillis(startedAt));
|
||||
@@ -946,7 +951,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
sourceFeeMapper.restoreUnbilledIfNoActiveArBillByArBillId(arBillId);
|
||||
sourceBillMapper.refreshArBillStatusByArBillId(arBillId);
|
||||
recordSuccess(bill, ArLogObjectType.BILL, ArLogOperationType.VOID,
|
||||
"作废应收账单:" + remark, bill.getStatus(), ArBillStatus.VOID.getCode(), requestId, operator);
|
||||
"作废应收账单:" + remark, bill.getStatus(), ArBillStatus.VOID.getCode(), requestId,
|
||||
SecurityUtils.getUserId(), operator);
|
||||
ArBill result = selectArBillById(arBillId);
|
||||
log.info("应收账单作废处理完成,operator={}, requestId={}, arBillId={}, status={}, costMs={}",
|
||||
safeLogValue(operator), safeLogValue(requestId), arBillId, result.getStatus(), elapsedMillis(startedAt));
|
||||
@@ -960,6 +966,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ArBillExport exportBill(Long arBillId, String operator, String requestId) {
|
||||
long startedAt = System.nanoTime();
|
||||
Long exportUserId = SecurityUtils.getUserId();
|
||||
ArBillLog previous = logMapper.selectSuccessByRequestId(requestId, ArLogObjectType.EXPORT.getCode(),
|
||||
ArLogResult.SUCCESS.getCode());
|
||||
if (previous != null && isNumber(previous.getObjectId())) {
|
||||
@@ -1010,13 +1017,15 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
export.setTemplateStorageType(template.getStorageType());
|
||||
export.setTemplateStorageKey(template.getStorageKey());
|
||||
export.setTemplateHash(template.getFileHash());
|
||||
export.setExportUserId(exportUserId);
|
||||
export.setExportBy(operator);
|
||||
export.setRowCount(bill.getOrderCount());
|
||||
export.setStorageKey("");
|
||||
export.setExportStatus(ArExportStatus.PROCESSING.getCode());
|
||||
exportMapper.insert(export);
|
||||
recordSuccess(bill, ArLogObjectType.EXPORT, ArLogOperationType.EXPORT,
|
||||
"已提交账单导出任务", bill.getStatus(), bill.getStatus(), requestId, operator, export.getExportId());
|
||||
"已提交账单导出任务", bill.getStatus(), bill.getStatus(), requestId,
|
||||
exportUserId, operator, export.getExportId());
|
||||
eventPublisher.publishEvent(new ArBillExportTaskEvent(export.getExportId()));
|
||||
log.info("应收账单导出任务已创建,operator={}, requestId={}, arBillId={}, exportId={}, status={}, costMs={}",
|
||||
safeLogValue(operator), safeLogValue(requestId), arBillId, export.getExportId(),
|
||||
@@ -1087,7 +1096,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
exportId, export.getArBillId(), safeLogValue(message), elapsedMillis(startedAt), e);
|
||||
if (exportMapper.markFailed(exportId, message) > 0) {
|
||||
logService.recordFailure(export.getArBillId(), ArLogObjectType.EXPORT, String.valueOf(exportId),
|
||||
ArLogOperationType.EXPORT, bill == null ? null : bill.getStatus(), message, export.getExportBy(), null);
|
||||
ArLogOperationType.EXPORT, bill == null ? null : bill.getStatus(), message,
|
||||
export.getExportUserId(), export.getExportBy(), null);
|
||||
}
|
||||
} finally {
|
||||
if (temp != null) {
|
||||
@@ -1233,12 +1243,13 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
}
|
||||
|
||||
private void recordSuccess(ArBill bill, ArLogObjectType objectType, ArLogOperationType operationType, String desc, String fromStatus,
|
||||
String toStatus, String requestId, String operator) {
|
||||
recordSuccess(bill, objectType, operationType, desc, fromStatus, toStatus, requestId, operator, null);
|
||||
String toStatus, String requestId, Long operatorId, String operatorName) {
|
||||
recordSuccess(bill, objectType, operationType, desc, fromStatus, toStatus, requestId,
|
||||
operatorId, operatorName, null);
|
||||
}
|
||||
|
||||
private void recordSuccess(ArBill bill, ArLogObjectType objectType, ArLogOperationType operationType, String desc, String fromStatus,
|
||||
String toStatus, String requestId, String operator, Long objectId) {
|
||||
String toStatus, String requestId, Long operatorId, String operatorName, Long objectId) {
|
||||
ArBillLog log = new ArBillLog();
|
||||
log.setArBillId(bill.getArBillId());
|
||||
log.setObjectType(objectType.getCode());
|
||||
@@ -1249,8 +1260,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
log.setToStatus(toStatus);
|
||||
log.setBeforeData(safeStatusJson(fromStatus));
|
||||
log.setAfterData(safeStatusJson(toStatus));
|
||||
log.setOperatorId(operator);
|
||||
log.setOperatorName(operator);
|
||||
log.setOperatorId(operatorId);
|
||||
log.setOperatorName(operatorName);
|
||||
log.setOperationSource(ArLogOperationSource.WEB.getCode());
|
||||
log.setRequestId(requestId);
|
||||
log.setResult(ArLogResult.SUCCESS.getCode());
|
||||
@@ -1259,7 +1270,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
|
||||
private ServiceException failure(Long arBillId, ArLogObjectType objectType, String objectId, ArLogOperationType operationType,
|
||||
String fromStatus, String message, String operator, String requestId) {
|
||||
logService.recordFailure(arBillId, objectType, objectId, operationType, fromStatus, message, operator, requestId);
|
||||
logService.recordFailure(arBillId, objectType, objectId, operationType, fromStatus, message,
|
||||
SecurityUtils.getUserId(), operator, requestId);
|
||||
return new ServiceException(message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user