package com.ruoyi.tms.service.impl; import java.util.List; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.utils.DateUtils; import javax.annotation.Resource; import com.ruoyi.tms.domain.TmsDispatchOrder; import org.springframework.transaction.annotation.Transactional; import org.springframework.stereotype.Service; import org.springframework.scheduling.annotation.Async; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ruoyi.common.utils.PageUtils; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.core.service.BaseService; import com.ruoyi.tms.mapper.TmsQuoteFeeMapper; import com.ruoyi.tms.domain.TmsQuoteFee; import com.ruoyi.tms.service.ITmsQuoteFeeService; import com.ruoyi.common.core.text.Convert; /** * 报价费用Service业务层处理 * * @author ruoyi * @date 2025-12-12 */ @Service @Transactional(rollbackFor = Exception.class) public class TmsQuoteFeeServiceImpl extends BaseService implements ITmsQuoteFeeService { protected final Logger logger = LoggerFactory.getLogger(getClass()); @Resource private TmsQuoteFeeMapper tmsQuoteFeeMapper; /** * 查询报价费用 * * @param id 报价费用ID * @return 报价费用 */ @DataSource(DataSourceType.SLAVE) @Override public TmsQuoteFee selectTmsQuoteFeeById(Integer id) { return tmsQuoteFeeMapper.selectTmsQuoteFeeById(id); } /** * 查询报价费用 记录数 * * @param tmsQuoteFee 报价费用 * @return 报价费用集合 */ @DataSource(DataSourceType.SLAVE) @Override public int selectTmsQuoteFeeCount(TmsQuoteFee tmsQuoteFee) { return tmsQuoteFeeMapper.selectTmsQuoteFeeCount(tmsQuoteFee); } /** * 查询报价费用列表 * * @param tmsQuoteFee 报价费用 * @return 报价费用 */ @DataSource(DataSourceType.SLAVE) @Override public List selectTmsQuoteFeeList(TmsQuoteFee tmsQuoteFee) { return tmsQuoteFeeMapper.selectTmsQuoteFeeList(tmsQuoteFee); } /** * 查询报价费用列表 异步 导出 * * @param tmsQuoteFee 报价费用 * @param exportKey 导出功能的唯一标识 * @return 报价费用集合 */ @DataSource(DataSourceType.SLAVE) @Async @Override public void export(TmsQuoteFee tmsQuoteFee,String exportKey) { super.export(TmsQuoteFee.class,exportKey,"tmsQuoteFeeData",(pageNum)->{ PageUtils.startPage(pageNum, Constants.EXPORT_PATE_SIZE); return selectTmsQuoteFeeList(tmsQuoteFee); }); } /** * 新增报价费用 * * @param tmsQuoteFee 报价费用 * @return 结果 */ @Override public int insertTmsQuoteFee(TmsQuoteFee tmsQuoteFee) { tmsQuoteFee.setCreateTime(DateUtils.getNowDate()); return tmsQuoteFeeMapper.insertTmsQuoteFee(tmsQuoteFee); } @Override public int pushTmsQuoteFee(TmsDispatchOrder dispatchOrder) { List quoteFeeItems = dispatchOrder.getQuoteFeeItems(); if (quoteFeeItems != null && !quoteFeeItems.isEmpty()){ quoteFeeItems.forEach(quoteFeeItem -> { quoteFeeItem.setDispatchId(dispatchOrder.getId()); if (quoteFeeItem.getIsYF()!=null &"eFeeItem.getIsYF() == 0){ quoteFeeItem.setYfCount(null); quoteFeeItem.setYfPrice(null); quoteFeeItem.setYfSum(null); quoteFeeItem.setYfCurrency(null); quoteFeeItem.setYfId(null); quoteFeeItem.setIsCZYF(null); quoteFeeItem.setServiceProviderId(null); quoteFeeItem.setServiceProviderType(null); } TmsQuoteFee tmsQuoteFee = tmsQuoteFeeMapper.selectOne(new LambdaQueryWrapper<>(TmsQuoteFee.class) .eq(TmsQuoteFee::getDispatchId, quoteFeeItem.getDispatchId()) .eq(TmsQuoteFee::getFree, quoteFeeItem.getFree()) .last("limit 1") ); if (tmsQuoteFee == null){ tmsQuoteFeeMapper.insertTmsQuoteFee(quoteFeeItem); }else{ BeanUtil.copyProperties(quoteFeeItem,tmsQuoteFee,"id"); tmsQuoteFeeMapper.updateTmsQuoteFee(tmsQuoteFee); } }); } return 1; } /** * 新增报价费用[批量] * * @param tmsQuoteFees 报价费用 * @return 结果 */ @Override public int insertTmsQuoteFeeBatch(List tmsQuoteFees) { int rows = tmsQuoteFeeMapper.insertTmsQuoteFeeBatch(tmsQuoteFees); return rows; } /** * 修改报价费用 * * @param tmsQuoteFee 报价费用 * @return 结果 */ @Override public int updateTmsQuoteFee(TmsQuoteFee tmsQuoteFee) { tmsQuoteFee.setUpdateTime(DateUtils.getNowDate()); return tmsQuoteFeeMapper.updateTmsQuoteFee(tmsQuoteFee); } /** * 修改报价费用[批量] * * @param tmsQuoteFees 报价费用 * @return 结果 */ @Override public int updateTmsQuoteFeeBatch(List tmsQuoteFees){ return tmsQuoteFeeMapper.updateTmsQuoteFeeBatch(tmsQuoteFees); } /** * 删除报价费用对象 * * @param ids 需要删除的数据ID * @return 结果 */ @Override public int deleteTmsQuoteFeeByIds(String ids) { return deleteTmsQuoteFeeByIds(Convert.toIntArray(ids)); } /** * 删除报价费用对象 * * * @param ids 需要删除的数据ID * @return 结果 */ @Override public int deleteTmsQuoteFeeByIds(Integer[] ids) { return tmsQuoteFeeMapper.deleteTmsQuoteFeeByIds(ids); } /** * 删除报价费用信息 * * @param id 报价费用ID * @return 结果 */ @Override public int deleteTmsQuoteFeeById(Integer id) { return tmsQuoteFeeMapper.deleteTmsQuoteFeeById(id); } }