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;
|
}
|
|
}
|