liujie
2023-05-22 9f2315d92cc93f8f431805a10ea9ce3f79fa7eb2
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
package com.stylefeng.guns.modular.system.controller;
 
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.ITCompanyFeeSettingService;
import com.stylefeng.guns.modular.system.service.ITCompanyService;
import com.stylefeng.guns.modular.system.service.ITCompanyServiceService;
import com.stylefeng.guns.modular.system.utils.tips.ErrorTip;
import com.stylefeng.guns.modular.system.utils.tips.SuccessTip;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2023-01-30 16:34:16
 */
@Controller
@Api(tags = "卡车公司")
@RequestMapping("/api/tCompany")
public class TCompanyController extends BaseController {
 
 
    @Autowired
    private ITCompanyService tCompanyService;
 
    @Autowired
    private ITCompanyFeeSettingService itCompanyFeeSettingService;
 
    @Autowired
    private ITCompanyServiceService itCompanyServiceService;
 
 
 
//    /**
//     * 获取列表
//     */
//    @ApiOperation(value = "卡车公司列表",notes="卡车公司列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "名称/id", required = false, dataType = "String"),
//            @ApiImplicitParam(name = "account", value = "account", required = false, dataType = "String"),
//    })
//    @GetMapping(value = "/list")
//    @ResponseBody
//    public Object list(int pageNumber,int pageSize,String name,String account) {
//
//        Page<TCompanyVo> tCompanyVoPage = new Page<>(pageNumber, pageSize);
//        List<TCompanyVo> tCompanyVos = tCompanyService.selectList1(tCompanyVoPage, name, account);
//        tCompanyVoPage.setRecords(tCompanyVos);
//        return new SuccessTip(tCompanyVoPage);
//    }
//
//    @ApiOperation(value = "卡车公司审核列表",notes="卡车公司审核列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "名称/id", required = false, dataType = "String"),
//            @ApiImplicitParam(name = "account", value = "account", required = false, dataType = "String"),
//            @ApiImplicitParam(name = "state", value = "state", required = false, dataType = "int"),
//    })
//    @GetMapping(value = "/listCheck")
//    @ResponseBody
//    public Object listCheck(int pageNumber,int pageSize,String name,String account,Integer state) {
//
//        Page<TCompanyVo> tCompanyVoPage = new Page<>(pageNumber, pageSize);
//        tCompanyVoPage.setRecords(tCompanyService.selectList2(tCompanyVoPage,name,account,state));
//        return new SuccessTip(tCompanyVoPage);
//    }
//
//    /**
//     * 新增
//     */
//    @ApiOperation(value = "新增卡车公司",notes="新增卡车公司")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//    })
//    @PostMapping(value = "/add")
//    @ResponseBody
//    public Object add(@RequestBody TCompanyDto tCompany)  {
//        try {
//            List<TCompany> companies = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("account", tCompany.getAccount()));
//            if(companies.size()>0){
//                return new ErrorTip(5002,"Account already exists");
//            }
//            TCompany company = new TCompany();
//            BeanUtil.copyProperties(tCompany,company);
//            tCompanyService.insert(company);
//            List<TCompanyService> list = tCompany.getList();
//            list.forEach(e->e.setCompanyId(company.getId()));
//            itCompanyServiceService.insertBatch(tCompany.getList());
//            return SUCCESS_TIP;
//        }catch (Exception e){
//            e.printStackTrace();
//            return ERROR;
//        }
//    }
//
//    /**
//     * 删除
//     */
//    @ApiOperation(value = "删除卡车公司",notes="删除卡车公司")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
//    })
//    @DeleteMapping(value = "/delete")
//    @ResponseBody
//    public Object delete(@RequestParam Integer tCompanyId) {
//        TCompany tCompany = tCompanyService.selectById(tCompanyId);
//        tCompany.setRemove(1);
//        tCompanyService.updateById(tCompany);
//        return SUCCESS_TIP;
//    }
//
//    @ApiOperation(value = "冻结卡车公司",notes="冻结卡车公司")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
//            @ApiImplicitParam(name = "type", value = "1解冻 2冻结", required = true, dataType = "int"),
//    })
//    @DeleteMapping(value = "/freeze")
//    @ResponseBody
//    public Object freeze(@RequestParam Integer tCompanyId,Integer type) {
//        TCompany tCompany = tCompanyService.selectById(tCompanyId);
//        if(type==1){
//            tCompany.setStatus(1);
//        }else if(type==2){
//            tCompany.setStatus(3);
//        }
//        tCompanyService.updateById(tCompany);
//        return SUCCESS_TIP;
//    }
 
 
//    @ApiOperation(value = "审核卡车公司",notes="审核卡车公司")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
//            @ApiImplicitParam(name = "type", value = "1通过 2拒绝", required = true, dataType = "int"),
//            @ApiImplicitParam(name = "remark", value = "拒绝原因/通过填时间(2023-01-31 17:49:08)", required = true, dataType = "String"),
//    })
//    @DeleteMapping(value = "/audit")
//    @ResponseBody
//    public Object audit(@RequestParam Integer tCompanyId,Integer type,String remark) {
//        TCompany tCompany = tCompanyService.selectById(tCompanyId);
//        if(type==1){
//            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            try {
//                Date parse = simpleDateFormat.parse(remark);
//                tCompany.setExpirationTime(parse);
//
//
//            } catch (ParseException e) {
//                e.printStackTrace();
//                return new ErrorTip(5010, "时间格式错误!");
//            }
//            tCompany.setStatus(1);
//        }else if(type==2){
//            tCompany.setStatus(2);
//            tCompany.setRemark(remark);
//        }
//        tCompanyService.updateById(tCompany);
//        return SUCCESS_TIP;
//    }
 
    /**
     * 修改
     */
    @ApiOperation(value = "卡车公司-修改卡车公司",notes="卡车公司-修改卡车公司")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    @PostMapping(value = "/update")
    @ResponseBody
    public Object update(@RequestBody TCompanyDto tCompany) {
        try {
            List<TCompany> companies = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("account", tCompany.getAccount()).ne("id",tCompany.getId()));
            if(companies.size()>0){
                return new ErrorTip(5002,"Account already exists");
            }
            TCompany company = new TCompany();
            BeanUtil.copyProperties(tCompany,company);
            tCompanyService.updateById(company);
            itCompanyServiceService.updateBatchById(tCompany.getList());
            return SUCCESS_TIP;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
 
    }
 
    /**
     * 详情
     */
    @ApiOperation(value = "卡车公司-详情-卡车公司",notes="卡车公司-详情-卡车公司")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
    })
    @GetMapping(value = "/detail/{tCompanyId}")
    @ResponseBody
    public Object detail(@PathVariable("tCompanyId") Integer tCompanyId) {
        TCompanyDto tCompanyDto = new TCompanyDto();
        TCompany company = tCompanyService.selectById(tCompanyId);
        BeanUtil.copyProperties(company,tCompanyDto);
        List<TCompanyService> companyServiceList = itCompanyServiceService.selectList(new EntityWrapper<TCompanyService>().eq("company_id", tCompanyId).eq("type",0));
        tCompanyDto.setList(companyServiceList);
        return new SuccessTip(tCompanyDto);
    }
 
    /**
     * 详情
     */
    @ApiOperation(value = "详情-卡车公司-服务",notes="详情-卡车公司-服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
    })
    @GetMapping(value = "/detailOne/{tCompanyId}")
    @ResponseBody
    public Object detailOne(@PathVariable("tCompanyId") Integer tCompanyId) {
        ArrayList<List<TCompanyService>> objects = new ArrayList<>();
        List<TCompanyService> companyServiceList = itCompanyServiceService.selectList(new EntityWrapper<TCompanyService>().eq("company_id", tCompanyId).eq("type",1));
        List<TCompanyService> companyServiceListOne = itCompanyServiceService.selectList(new EntityWrapper<TCompanyService>().eq("company_id", tCompanyId).eq("type",2));
        objects.add(companyServiceList);
        objects.add(companyServiceListOne);
        return new SuccessTip(objects);
    }
 
//    @ApiOperation(value = "根据卡车公司id获取卡车公司费用设置",notes="根据卡车公司id获取卡车公司费用设置")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//            @ApiImplicitParam(name = "tCompanyId", value = "卡车公司id", required = true, dataType = "int"),
//    })
//    @GetMapping(value = "/getCompanySetting/{tCompanyId}")
//    @ResponseBody
//    public Object getCompanySetting(@PathVariable("tCompanyId") Integer tCompanyId) {
//        List<TCompanyFeeSetting> feeSettings = itCompanyFeeSettingService.selectList(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", tCompanyId));
//        ArrayList<TCompanyFeeSettingVo> vos = new ArrayList<>();
//        feeSettings.stream().forEach(e->{
//            TCompanyFeeSettingVo tCompanyFeeSettingVo = new TCompanyFeeSettingVo();
//            BeanUtil.copyProperties(e,tCompanyFeeSettingVo);
//            vos.add(tCompanyFeeSettingVo);
//        });
//        vos.forEach(e->{
//            if(("Pool chassis").equals(e.getSetName()) ||"wccp chassis".equals(e.getSetName()) || "trl-axle chassis".equals(e.getSetName())){
//                e.setCost("Chassis fee");
//            }
//        });
//        return new SuccessTip(vos);
//    }
 
 
//    @ApiOperation(value = "卡车公司服务修改设置",notes="卡车公司服务修改设置")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
//    })
//    @GetMapping(value = "/updateSetting")
//    @ResponseBody
//    public Object updateSetting(TCompanySettingDto dto) {
//        TCompany tCompany = tCompanyService.selectById(dto.getId());
//        tCompany.setClass9(dto.getClass9());
//        tCompany.setClass8(dto.getClass8());
//        tCompany.setClass7(dto.getClass7());
//        tCompany.setClass6(dto.getClass6());
//        tCompany.setClass5(dto.getClass5());
//        tCompany.setClass4(dto.getClass4());
//        tCompany.setClass3(dto.getClass3());
//        tCompany.setClass2(dto.getClass2());
//        tCompany.setClass1(dto.getClass1());
//        tCompany.setDg(dto.getDg());
//        tCompany.setFr(dto.getFr());
//        tCompany.setTk(dto.getTk());
//        tCompany.setOt(dto.getOt());
//        tCompany.setRh(dto.getRh());
//        tCompany.setRf(dto.getRf());
//        tCompany.setHc(dto.getHc());
//        tCompany.setHq(dto.getHq());
//        tCompany.setGp(dto.getGp());
//        tCompany.setLanguage(dto.getLanguage());
//        tCompany.setEld(dto.getEld());
//        tCompany.setTwic(dto.getTwic());
//        tCompany.setPrivateChassis(dto.getPrivateChassis());
//        tCompany.setIsoTankDrayage(dto.getIsoTankDrayage());
//        tCompany.setTankEndorsedDrayage(dto.getTankEndorsedDrayage());
//        tCompany.setOpenTopDrayage(dto.getOpenTopDrayage());
//        tCompany.setReeferDrayage(dto.getReeferDrayage());
//        tCompany.setDryContainerDrayage(dto.getDryContainerDrayage());
//        tCompany.setRailRampDrayage(dto.getRailRampDrayage());
//        tCompany.setOceanPortDrayage(dto.getOceanPortDrayage());
//        tCompany.setContainerSizes(dto.getContainerSizes());
//        tCompany.setChains(dto.getChains());
//        tCompany.setTransloadService(dto.getTransloadService());
//        tCompany.setAmazon(dto.getAmazon());
//        tCompany.setTsa(dto.getTsa());
//        tCompany.setResidentialDelivery(dto.getResidentialDelivery());
//        tCompany.setHouseholdGoods(dto.getHouseholdGoods());
//        tCompany.setLiquor(dto.getLiquor());
//        tCompany.setOverweightPermit(dto.getOverweightPermit());
//        tCompany.setHAZMAT(dto.getHAZMAT());
//        return tCompanyService.updateById(tCompany);
//    }
 
 
}