| | |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | |
| | | private CommonFileServiceImpl commonFileService; |
| | | @Autowired |
| | | private ISysNoticeService sysNoticeService; |
| | | |
| | | @Autowired |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | |
| | | @Override |
| | | public void addApprove(ApproveProcessVO approveProcessVO) throws Exception { |
| | |
| | | |
| | | // 发货审批查询 |
| | | else if (record.getApproveType() == 7) { |
| | | String reason = record.getApproveReason(); // 格式为 "xx:...-..." |
| | | String reason = record.getApproveReason(); // 格式为 "xx:CONTRACT_NO" |
| | | if (StringUtils.hasText(reason) && reason.contains(":")) { |
| | | // 提取冒号后面的发货单号 |
| | | String shippingNo = reason.split(":")[1]; |
| | | // 根据发货单号查询发货台账记录 |
| | | // 提取冒号后面的标识符 (可能是合同号或发货单号) |
| | | String identifier = reason.split(":")[1]; |
| | | // 1. 优先尝试找销售台账 (新逻辑:合同号同步审批) |
| | | SalesLedger ledger = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>() |
| | | .eq(SalesLedger::getSalesContractNo, identifier) |
| | | .last("limit 1")); |
| | | if (ledger != null) { |
| | | allFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>() |
| | | .eq(CommonFile::getCommonId, ledger.getId()) |
| | | .eq(CommonFile::getType, FileNameType.SALE.getValue())); |
| | | } else { |
| | | // 2. 回退到旧逻辑:发货单号 |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getShippingNo, shippingNo) |
| | | .eq(ShippingInfo::getShippingNo, identifier) |
| | | .last("limit 1")); |
| | | if (shippingInfo != null) { |
| | | // 使用发货台账的 销售台账ID 去查附件 |
| | | allFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>() |
| | | .eq(CommonFile::getCommonId, shippingInfo.getSalesLedgerId()) |
| | | .eq(CommonFile::getType, FileNameType.SALE.getValue())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 查询审批单自身的附件 |
| | | else { |