Files
contract-manager/client/src/main/java/com/ecep/contract/service/ContractInvoiceService.java
songqq 71a358fa77 feat(contract): 新增合同发票管理功能
实现合同发票的增删改查功能,包括:
1. 添加ContractInvoiceVo实体类及相关ViewModel
2. 创建合同发票数据库表CONTRACT_INVOICE
3. 实现前后端发票管理服务ContractInvoiceService
4. 开发发票管理界面及标签页
5. 添加发票表格单元格组件
6. 完善销售订单表结构,增加客户联系人字段
7. 更新pom.xml版本至0.0.122-SNAPSHOT

修复销售订单界面搜索字段命名不一致问题
2025-10-16 15:47:33 +08:00

67 lines
2.3 KiB
Java

package com.ecep.contract.service;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;
import com.ecep.contract.vm.ContractInvoiceViewModel;
import com.ecep.contract.vo.ContractInvoiceVo;
@Service
@CacheConfig(cacheNames = "contract-invoice")
public class ContractInvoiceService extends QueryService<ContractInvoiceVo, ContractInvoiceViewModel> {
@Cacheable(key = "#p0")
@Override
public ContractInvoiceVo findById(Integer id) {
return super.findById(id);
}
@Caching(evict = {
@CacheEvict(key = "#p0.id"),
@CacheEvict(key = "'code-'+#p0.code")
})
public ContractInvoiceVo save(ContractInvoiceVo invoice) {
return super.save(invoice);
}
@Caching(evict = {
@CacheEvict(key = "#p0.id"),
@CacheEvict(key = "'code-'+#p0.code")
})
public void delete(ContractInvoiceVo invoice) {
super.delete(invoice);
}
@Cacheable(key = "'code-'+#p0")
public ContractInvoiceVo findByCode(String code) {
try {
return async("findByCode", code, String.class).handle((response, ex) -> {
if (ex != null) {
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
}
if (response != null) {
return updateValue(createNewEntity(), response);
}
return null;
}).get();
} catch (Exception e) {
throw new RuntimeException("查找合同发票 " + code + " 时发生错误", e);
}
}
public ContractInvoiceVo findByContractId(Integer contractId) {
try {
return async("findByContractId", contractId, Integer.class).handle((response, ex) -> {
if (response != null) {
return updateValue(createNewEntity(), response);
}
return null;
}).get();
} catch (Exception e) {
throw new RuntimeException("查找合同ID为 " + contractId + " 的发票时发生错误", e);
}
}
}