| | |
| | | package com.ruoyi.cwgl.controller; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | import java.util.Objects; |
| | | import com.ruoyi.cwgl.domain.InvoiceManage; |
| | | import com.ruoyi.cwgl.domain.PayableBillManagement; |
| | | import com.ruoyi.cwgl.domain.PayableBillManagementLog; |
| | | import com.ruoyi.cwgl.domain.PayableInvoiceBusiness; |
| | | import com.ruoyi.cwgl.domain.dto.BillAuditDto; |
| | | import com.ruoyi.cwgl.domain.dto.PayableAuditLog; |
| | | import com.ruoyi.cwgl.service.IInvoiceManageService; |
| | | import com.ruoyi.cwgl.service.IPayableBillManagementLogService; |
| | | import com.ruoyi.cwgl.service.IPayableBillManagementService; |
| | | import com.ruoyi.cwgl.service.IPayableInvoiceBusinessService; |
| | | import com.ruoyi.cwgl.service.ITmsAuditLogPushService; |
| | |
| | | |
| | | @Autowired |
| | | private ITmsAuditLogPushService tmsAuditLogPushService; |
| | | |
| | | @Autowired |
| | | private IPayableBillManagementLogService payableBillManagementLogService; |
| | | |
| | | |
| | | |
| | |
| | | // 6. 如果来源系统是TMS,推送审核日志到TMS |
| | | if (tmsAuditLogPushService.isPayableBillFromTms(bill.getSystemNo())) { |
| | | try { |
| | | PayableAuditLog auditLog = createPayableAuditLog(billAuditDto, bill, beforeAuditStatus); |
| | | PayableAuditLog auditLog = createPayableAuditLog(billAuditDto, bill); |
| | | tmsAuditLogPushService.pushPayableAuditLog(auditLog); |
| | | } catch (Exception e) { |
| | | logger.error("推送应付账单审核日志到TMS失败,账单ID:{}", bill.getId(), e); |
| | |
| | | * 保存应付账单审核日志 |
| | | */ |
| | | private void savePayableAuditLog(BillAuditDto billAuditDto, PayableBillManagement bill, Integer beforeAuditStatus) { |
| | | // 这里需要实现日志记录逻辑 |
| | | // 可以使用原有的日志服务或系统日志 |
| | | logger.info("应付账单审核日志 - 账单ID:{},账单编号:{},审核前状态:{},审核结果:{},审核意见:{}", |
| | | bill.getId(), bill.getSystemNo(), |
| | | getAuditStatusText(beforeAuditStatus), |
| | | getAuditResultText(billAuditDto.getAuditResult()), |
| | | billAuditDto.getAuditComment() != null ? billAuditDto.getAuditComment() : "无"); |
| | | try { |
| | | PayableBillManagementLog log = new PayableBillManagementLog(); |
| | | log.setBillId(bill.getId()); |
| | | log.setSourceSystemId(bill.getSourceSystemId()); // 设置来源系统ID |
| | | log.setCreateBy(getUsername()); |
| | | log.setCreateTime(new Date()); |
| | | |
| | | // 构建操作说明 |
| | | String operation = String.format("应付账单审核 - 账单编号:%s,审核前状态:%s,审核结果:%s,审核意见:%s", |
| | | bill.getSystemNo(), |
| | | getAuditStatusText(beforeAuditStatus), |
| | | getAuditResultText(billAuditDto.getAuditResult()), |
| | | billAuditDto.getAuditComment() != null ? billAuditDto.getAuditComment() : "无"); |
| | | log.setOperation(operation); |
| | | |
| | | // 保存到数据库 |
| | | payableBillManagementLogService.insertPayableBillManagementLog(log); |
| | | |
| | | logger.info("应付账单审核日志保存成功 - 账单ID:{},来源系统ID:{}", bill.getId(), bill.getSourceSystemId()); |
| | | |
| | | } catch (Exception e) { |
| | | logger.error("保存应付账单审核日志失败,账单ID:{}", bill.getId(), e); |
| | | // 日志保存失败不影响主流程,只记录错误日志 |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 创建应付账单审核日志对象 |
| | | */ |
| | | private PayableAuditLog createPayableAuditLog(BillAuditDto billAuditDto, PayableBillManagement bill, Integer beforeAuditStatus) { |
| | | private PayableAuditLog createPayableAuditLog(BillAuditDto billAuditDto, PayableBillManagement bill) { |
| | | PayableAuditLog auditLog = new PayableAuditLog(); |
| | | auditLog.setBillId(bill.getId()); |
| | | auditLog.setBillNo(bill.getSystemNo()); |
| | | auditLog.setBillName(bill.getBillName()); |
| | | auditLog.setSupplierName(bill.getSupplierName()); |
| | | auditLog.setSourceSystem(tmsAuditLogPushService.getPayableBillSourceSystem(bill.getSystemNo())); |
| | | auditLog.setBeforeAuditStatus(beforeAuditStatus); |
| | | auditLog.setAuditResult(billAuditDto.getAuditResult()); |
| | | auditLog.setAuditComment(billAuditDto.getAuditComment()); |
| | | auditLog.setAuditUser(getUsername()); |
| | | auditLog.setAuditTime(new java.util.Date()); |
| | | auditLog.setTotalAmount(bill.getTotalAmount()); |
| | | auditLog.setHeadId(bill.getSourceSystemId()); |
| | | auditLog.setCreateBy(getUsername()); |
| | | auditLog.setCreateTime(new Date()); |
| | | |
| | | String opertion = ""; |
| | | if (billAuditDto.getAuditResult() != null&& billAuditDto.getAuditResult().equals(1)) { |
| | | opertion = "审核通过"; |
| | | if (StringUtils.isNotEmpty(billAuditDto.getAuditComment())){ |
| | | opertion += ",审核意见 :" + billAuditDto.getAuditComment(); |
| | | } |
| | | }else { |
| | | opertion = "审核驳回"; |
| | | if (StringUtils.isNotEmpty(billAuditDto.getAuditComment())){ |
| | | opertion += ",审核意见:" + billAuditDto.getAuditComment(); |
| | | } |
| | | } auditLog.setOperation(opertion); |
| | | |
| | | return auditLog; |
| | | } |
| | | } |