zhangback
6 天以前 ca412ade3b178fbc8ba0a4b6215a040acdede954
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
package com.ruoyi.tms.service.impl;
 
import java.util.Date;
import java.util.List;
 
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import javax.annotation.Resource;
 
import com.ruoyi.common.utils.StringUtils;
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.TmsCarKeyDispatchMapper;
import com.ruoyi.tms.domain.TmsCarKeyDispatch;
import com.ruoyi.tms.service.ITmsCarKeyDispatchService;
import com.ruoyi.common.core.text.Convert;
 
/**
 * 车钥匙分发记录Service业务层处理
 *
 * @author ruoyi
 * @date 2025-12-08
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class TmsCarKeyDispatchServiceImpl  extends BaseService<TmsCarKeyDispatchMapper, TmsCarKeyDispatch> implements ITmsCarKeyDispatchService
{
    protected final Logger logger = LoggerFactory.getLogger(getClass());
    @Resource
    private TmsCarKeyDispatchMapper tmsCarKeyDispatchMapper;
 
 
    /**
     * 查询车钥匙分发记录
     *
     * @param id 车钥匙分发记录ID
     * @return 车钥匙分发记录
     */
    @DataSource(DataSourceType.SLAVE)
    @Override
    public TmsCarKeyDispatch selectTmsCarKeyDispatchById(Integer id)
    {
        return tmsCarKeyDispatchMapper.selectTmsCarKeyDispatchById(id);
    }
 
    /**
     * 查询车钥匙分发记录 记录数
     *
     * @param tmsCarKeyDispatch 车钥匙分发记录
     * @return 车钥匙分发记录集合
     */
    @DataSource(DataSourceType.SLAVE)
    @Override
    public int selectTmsCarKeyDispatchCount(TmsCarKeyDispatch tmsCarKeyDispatch)
    {
        return tmsCarKeyDispatchMapper.selectTmsCarKeyDispatchCount(tmsCarKeyDispatch);
    }
 
    /**
     * 查询车钥匙分发记录列表
     *
     * @param tmsCarKeyDispatch 车钥匙分发记录
     * @return 车钥匙分发记录
     */
    @DataSource(DataSourceType.SLAVE)
    @Override
    public List<TmsCarKeyDispatch> selectTmsCarKeyDispatchList(TmsCarKeyDispatch tmsCarKeyDispatch)
    {
        return tmsCarKeyDispatchMapper.selectTmsCarKeyDispatchList(tmsCarKeyDispatch);
    }
 
    /**
     * 查询车钥匙分发记录列表 异步 导出
     *
     * @param tmsCarKeyDispatch 车钥匙分发记录
     * @param exportKey 导出功能的唯一标识
     * @return 车钥匙分发记录集合
     */
    @DataSource(DataSourceType.SLAVE)
    @Async
    @Override
    public void export(TmsCarKeyDispatch tmsCarKeyDispatch,String exportKey) {
 
        super.export(TmsCarKeyDispatch.class,exportKey,"tmsCarKeyDispatchData",(pageNum)->{
            PageUtils.startPage(pageNum, Constants.EXPORT_PATE_SIZE);
            return selectTmsCarKeyDispatchList(tmsCarKeyDispatch);
        });
    }
 
 
    /**
     * 新增车钥匙分发记录
     *
     * @param tmsCarKeyDispatch 车钥匙分发记录
     * @return 结果
     */
    @Override
    public int insertTmsCarKeyDispatch(TmsCarKeyDispatch tmsCarKeyDispatch)
    {
        tmsCarKeyDispatch.setCreateTime(DateUtils.getNowDate());
        return tmsCarKeyDispatchMapper.insertTmsCarKeyDispatch(tmsCarKeyDispatch);
    }
 
    /**
     * 新增车钥匙分发记录[批量]
     *
     * @param tmsCarKeyDispatchs 车钥匙分发记录
     * @return 结果
     */
    @Override
    public int insertTmsCarKeyDispatchBatch(List<TmsCarKeyDispatch> tmsCarKeyDispatchs)
    {
        int rows = tmsCarKeyDispatchMapper.insertTmsCarKeyDispatchBatch(tmsCarKeyDispatchs);
        return rows;
    }
 
    /**
     * 修改车钥匙分发记录
     *
     * @param tmsCarKeyDispatch 车钥匙分发记录
     * @return 结果
     */
    @Override
    public int updateTmsCarKeyDispatch(TmsCarKeyDispatch tmsCarKeyDispatch)
    {
        tmsCarKeyDispatch.setUpdateTime(DateUtils.getNowDate());
        return tmsCarKeyDispatchMapper.updateTmsCarKeyDispatch(tmsCarKeyDispatch);
    }
 
    /**
     * 修改车钥匙分发记录[批量]
     *
     * @param tmsCarKeyDispatchs 车钥匙分发记录
     * @return 结果
     */
    @Override
    public int updateTmsCarKeyDispatchBatch(List<TmsCarKeyDispatch> tmsCarKeyDispatchs){
        return tmsCarKeyDispatchMapper.updateTmsCarKeyDispatchBatch(tmsCarKeyDispatchs);
    }
 
    /**
     * 删除车钥匙分发记录对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTmsCarKeyDispatchByIds(String ids)
    {
        return deleteTmsCarKeyDispatchByIds(Convert.toIntArray(ids));
    }
 
    /**
     * 删除车钥匙分发记录对象
     *
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTmsCarKeyDispatchByIds(Integer[] ids)
    {
        return tmsCarKeyDispatchMapper.deleteTmsCarKeyDispatchByIds(ids);
    }
 
    /**
     * 删除车钥匙分发记录信息
     *
     * @param id 车钥匙分发记录ID
     * @return 结果
     */
    @Override
    public int deleteTmsCarKeyDispatchById(Integer id)
    {
        return tmsCarKeyDispatchMapper.deleteTmsCarKeyDispatchById(id);
    }
 
    @Override
    public TmsCarKeyDispatch selectTmsCarKeyDispatchdriverMobile(String driverCode) {
        return tmsCarKeyDispatchMapper.selectTmsCarKeyDispatchdriverMobile(driverCode);
    }
    @Override
    public AjaxResult takeReview(TmsCarKeyDispatch tmsCarKeyDispatch) {
        if (tmsCarKeyDispatch == null) {
            return AjaxResult.error("查无符合要求的调度单,请联系调度人员",3);
        }
        if (StringUtils.isEmpty(tmsCarKeyDispatch.getVehicleCarKeyNo())){
            return AjaxResult.error("车钥匙柜号为空,请联系调度人员",3);
 
        }
        tmsCarKeyDispatch.setStatus(1);
        tmsCarKeyDispatch.setCarKeyCollectionTime(new Date());
        tmsCarKeyDispatchMapper.updateTmsCarKeyDispatch(tmsCarKeyDispatch);
 
 
 
 
        AjaxResult success = new AjaxResult(0, "成功",1);
        success.put("boxNumber",tmsCarKeyDispatch.getVehicleCarKeyNo());
        logger.info("成功返回{}",success);
        return success;
    }
}