liujie
2023-07-25 9b1188a004df6585d1836e85e22ee24a91b5fd62
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
package com.dsh.guns.modular.system.controller.code;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.course.feignClient.course.CourseClient;
import com.dsh.guns.config.UserExt;
import com.dsh.guns.core.base.controller.BaseController;
import com.dsh.guns.core.common.constant.factory.PageFactory;
import com.dsh.guns.core.util.SinataUtil;
import com.dsh.guns.modular.system.util.DateUtil;
import com.dsh.guns.modular.system.util.ExcelExportUtil;
import com.dsh.guns.modular.system.util.ResultUtil;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
 
/**
 * 车辆管理控制器
 *
 * @author fengshuonan
 * @Date 2020-06-05 17:25:12
 */
@Controller
@RequestMapping("/TCompetition")
public class TCompetitionController extends BaseController {
 
    private String PREFIX = "/system/TCompetition/";
 
    @Autowired
    private CourseClient courseClient;
 
 
    /**
     * 跳转到车辆管理首页
     */
    @RequestMapping("")
    public String index(Model model) {
        return PREFIX + "TCompetition.html";
    }
 
    /**
     * 跳转到添加车辆管理
     */
    @RequestMapping("/tCompetition_add")
    public String tCompetitionAdd(Model model) {
        return PREFIX + "tCompetition_add.html";
    }
 
 
    /**
     * 跳转到修改车辆管理
     */
    @RequestMapping("/tCompetition_update/{id}")
    public String tCarUpdate(@PathVariable Integer id, Model model) {
        return PREFIX + "tCompetition_edit.html";
    }
 
 
 
 
    /**
     * 获取车辆管理列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String createTime,
                       String id,
                       String brandName,
                       String modelName,
                       String carColor,
                       String serverStr,
                       String carLicensePlate,
                       String driverName,
                       String companyName,
                       String franchiseeName) {
        String beginTime = null;
        String endTime = null;
        if (SinataUtil.isNotEmpty(createTime)){
            String[] timeArray = createTime.split(" - ");
            beginTime = timeArray[0];
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        return super.packForBT(page);
    }
 
    /**
     * 新增车辆管理
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add( ) {
        return ResultUtil.success();
    }
 
    /**
     * 删除车辆管理
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tCarId) {
        return SUCCESS_TIP;
    }
 
    /**
     * 修改车辆管理
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update() {
        return ResultUtil.success();
    }
 
    /**
     * 车辆管理详情
     */
    @RequestMapping(value = "/detail/{tCarId}")
    @ResponseBody
    public Object detail(@PathVariable("tCarId") Integer tCarId) {
        return null;
    }
 
    /**
     * 下载模板
     * @param request
     * @param response
     */
    @RequestMapping(value = "/uploadCarModel")
    public void uploadCarModel(HttpServletRequest request, HttpServletResponse response) {
        // 表格数据【封装】 Table datas
        List<List<String>> dataList = new ArrayList<List<String>>();
        Integer language = UserExt.getLanguage();
        if(language==1){
            // 首行【封装】 first line 
            List<String> shellList = new ArrayList<String>();
            shellList.add("所属机构[平台车辆/加盟车辆]");
            shellList.add("所属分公司[提示:加盟车辆选填]");
            shellList.add("所属加盟商[提示:加盟车辆选填]");
            shellList.add("服务模式:摩托车车[是/否]");
            shellList.add("服务模式:同城快送[是/否]");
            shellList.add("车辆品牌");
            shellList.add("车辆类型");
            shellList.add("车辆颜色[1(黑色)/2(银色)/3(白色)/4(红色)/5(黄色)/6(橙色)/7(蓝色)]");
            shellList.add("车牌号");
            shellList.add("行驶证编号");
            shellList.add("年检到期时间[例如 2020-02-02]");
            shellList.add("商业保险到期时间[例如 2020-02-02]");
            dataList.add(shellList);
 
            try {
                // 调用工具类进行导出 Invoke the utility class to carry out data export.
                ExcelExportUtil.easySheet("平台导入车辆模板"+DateUtil.format(new Date(), "YYYYMMddHHmmss"), "平台导入车辆模板", dataList, request, response);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else if(language==2){
            // 首行【封装】 first line 
            List<String> shellList = new ArrayList<String>();
            shellList.add("Affiliated Organization [Platform Vehicle/Franchised Vehicle]");
            shellList.add("Affiliated branch [Tip: Select for franchised vehicle]");
            shellList.add("Franchisee [Tip: Select Franchised vehicle]");
            shellList.add("Service mode: Motorcycle [Yes/No]");
            shellList.add("Service mode: intra-city express [Yes/No]");
            shellList.add("Vehicle brand");
            shellList.add("Vehicle type");
            shellList.add("Vehicle color [1(Black)/2(Silver)/3(white)/4(red)/5(yellow)/6(orange)/7(Blue)]");
            shellList.add("License plate number");
            shellList.add("License number");
            shellList.add("Annual inspection expiration time [e.g. 2020-02-02]");
            shellList.add("Commercial Insurance Expiration Time [e.g. 2020-02-02]");
            dataList.add(shellList);
 
            try {
                // 调用工具类进行导出 Invoke the utility class to carry out data export.
                ExcelExportUtil.easySheet("Platform import vehicle template"+DateUtil.format(new Date(), "YYYYMMddHHmmss"), "Platform import vehicle template", dataList, request, response);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else {
            // 首行【封装】 first line
            List<String> shellList = new ArrayList<String>();
            shellList.add("Organisasi Berkait [Platform Vehicle/Franchised Vehicle]");
            shellList.add("Branch terkait [Tip: Pilih untuk kendaraan terkait]");
            shellList.add("Franchisee [Tip: Pilih kendaraan Franchised]");
            shellList.add("Mod layanan: Motosikal [Ya/Tidak]");
            shellList.add("Modus layanan: ekspres intra-kota [Ya/Tidak]");
            shellList.add("Tanda kendaraan");
            shellList.add("Jenis kendaraan");
            shellList.add("Warna kendaraan [1(Hitam)/2(Perak)/3(putih)/4(merah)/5(kuning)/6(oranye)/7(Biru)]");
            shellList.add("Nomor plat lisensi");
            shellList.add("Nomor lisensi");
            shellList.add("Waktu penggantian inspeksi tahunan [contohnya 2020-02-02]");
            shellList.add("Waktu Expiration Insurance Commercial [contohnya 2020-02-02]");
            dataList.add(shellList);
 
            try {
                // 调用工具类进行导出 Invoke the utility class to carry out data export.
                ExcelExportUtil.easySheet("templat kendaraan import platform"+DateUtil.format(new Date(), "YYYYMMddHHmmss"), "templat kendaraan import platform", dataList, request, response);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
 
 
    }
 
 
    /**
     * 判断日期是否满足yyyy-MM-dd格式
     * @param str
     * @return
     */
    public static boolean isValidDate(String str) {
        boolean convertSuccess=true;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        try {
            format.setLenient(false);
            format.parse(str);
        } catch (Exception e) {
            convertSuccess=false;
        }
        return convertSuccess;
    }
 
 
    /**
     * 转换日期
     * @return
     */
    public static String importByExcelForDate(String value) {//value就是它的天数
        String currentCellValue = "";
        if(value != null && !value.equals("")){
            Calendar calendar = new GregorianCalendar(1900,0,-1);
            Date d = calendar.getTime();
            Date dd = DateUtils.addDays(d,Integer.valueOf(value));
            DateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
            currentCellValue = formater.format(dd);
        }
        return currentCellValue;
    }
 
}