zhangback
2025-12-29 13796df077a2ccba587667e233f7cb48ea6c73b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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<TmsQuoteFeeMapper, TmsQuoteFee> 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<TmsQuoteFee> 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<TmsQuoteFee> quoteFeeItems = dispatchOrder.getQuoteFeeItems();
        if (quoteFeeItems != null && !quoteFeeItems.isEmpty()){
            quoteFeeItems.forEach(quoteFeeItem -> {
                quoteFeeItem.setDispatchId(dispatchOrder.getId());
                if (quoteFeeItem.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<TmsQuoteFee> 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<TmsQuoteFee> 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);
    }
}