package com.stylefeng.guns.modular.system.controller.general;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.base.tips.ErrorTip;
|
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.core.util.DateUtil;
|
import com.stylefeng.guns.core.util.ExcelExportUtil;
|
import com.stylefeng.guns.core.util.SinataUtil;
|
import com.stylefeng.guns.core.util.WoUtil;
|
import com.stylefeng.guns.modular.system.dao.CarInsuranceMapper;
|
import com.stylefeng.guns.modular.system.model.*;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.system.util.EmailUtil;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import org.apache.commons.lang.time.DateUtils;
|
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Workbook;
|
import org.jsoup.Jsoup;
|
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Element;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.ui.Model;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.stylefeng.guns.core.log.LogObjectHolder;
|
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.File;
|
import java.text.DateFormat;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
/**
|
* 车辆管理控制器
|
*
|
* @author fengshuonan
|
* @Date 2020-06-05 17:25:12
|
*/
|
@Controller
|
@RequestMapping("/tCar")
|
public class TCarController extends BaseController {
|
|
private String PREFIX = "/system/tCar/";
|
|
@Autowired
|
private ITCarService tCarService;
|
|
@Autowired
|
private ITCompanyService tCompanyService;
|
|
@Autowired
|
private ITCarServiceService tCarServiceService;
|
|
@Autowired
|
private ITDriverLineService tDriverLineService;
|
|
@Autowired
|
private ITCarBrandService tCarBrandService;
|
|
@Autowired
|
private ITCarModelService tCarModelService;
|
|
@Autowired
|
private ITDriverService tDriverService;
|
|
@Autowired
|
private ITCompanyService itCompanyService;
|
|
@Autowired
|
private ITCarServiceService itCarServiceService;
|
|
@Autowired
|
private ITServerCarmodelService itServerCarmodelService;
|
|
@Resource
|
private CarInsuranceMapper carInsuranceMapper;
|
|
@Autowired
|
private ITCarColorService carColorService;
|
|
@Value("${spring.mail.template-path}")
|
private String templatePath;
|
|
|
|
|
/**
|
* 跳转到车辆管理首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tCar.html";
|
}
|
@RequestMapping("auth")
|
public String auth() {
|
return PREFIX + "tCarAuth.html";
|
}
|
|
/**
|
* 跳转到添加车辆管理
|
*/
|
@RequestMapping("/tCar_add")
|
public String tCarAdd(Model model) {
|
List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2));
|
model.addAttribute("companyList",companyList);
|
|
Integer roleType = ShiroKit.getUser().getRoleType();
|
model.addAttribute("roleType",roleType);
|
if (2 == roleType){
|
List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId",ShiroKit.getUser().getObjectId()));
|
model.addAttribute("franchiseeList",franchiseeList);
|
}else{
|
model.addAttribute("franchiseeList",null);
|
}
|
//查询当前用户所属分公司/加盟商
|
model.addAttribute("objectName",tCompanyService.selectById(ShiroKit.getUser().getObjectId()).getName());
|
|
//车辆品牌
|
List<TCarBrand> brandList = tCarBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
|
model.addAttribute("brandList",brandList);
|
//车辆类型
|
/*List<TCarModel> modelList = tCarModelService.selectList(new EntityWrapper<TCarModel>().eq("state", 1));
|
model.addAttribute("modelList",modelList);*/
|
|
List<TServerCarmodel> zcModelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 1).eq("state", 1));
|
model.addAttribute("zcModelList",zcModelList);
|
List<TServerCarmodel> kcModelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 2).eq("state", 1));
|
model.addAttribute("kcModelList",kcModelList);
|
List<TCarColor> state = carColorService.selectList(new EntityWrapper<TCarColor>().eq("state", 1));
|
model.addAttribute("color", state);
|
return PREFIX + "tCar_add.html";
|
}
|
|
/**
|
* 查询车辆类型
|
* @param carBrandId
|
* @return
|
*/
|
@RequestMapping(value = "/brandChange")
|
@ResponseBody
|
public Object brandChange(@RequestParam Integer carBrandId) {
|
List<TCarModel> list = new ArrayList<>();
|
if (SinataUtil.isNotEmpty(carBrandId)){
|
list = tCarModelService.selectList(new EntityWrapper<TCarModel>().eq("state",1).eq("brandId", carBrandId));
|
}
|
return list;
|
}
|
|
/**
|
* 跳转到修改车辆管理
|
*/
|
@RequestMapping("/tCar_update/{tCarId}")
|
public String tCarUpdate(@PathVariable Integer tCarId, Model model) {
|
TCar tCar = tCarService.selectById(tCarId);
|
model.addAttribute("item",tCar);
|
LogObjectHolder.me().set(tCar);
|
|
Integer roleType = ShiroKit.getUser().getRoleType();
|
model.addAttribute("roleType",roleType);
|
model.addAttribute("objectName",tCompanyService.selectById(ShiroKit.getUser().getObjectId()).getName());
|
|
if (1 == roleType){
|
List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2));
|
model.addAttribute("companyList",companyList);
|
List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId",tCar.getCompanyId()));
|
model.addAttribute("franchiseeList",franchiseeList);
|
}else if (2 == roleType){
|
List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("superiorId",ShiroKit.getUser().getObjectId()));
|
model.addAttribute("franchiseeList",franchiseeList);
|
}
|
|
//查询平台ID
|
TCompany company = tCompanyService.selectOne(new EntityWrapper<TCompany>().eq("type", 1));
|
//判断是平台司机还是加盟司机
|
if ((SinataUtil.isEmpty(tCar.getCompanyId()) || tCar.getCompanyId() == 0 || tCar.getCompanyId() == company.getId()) && (SinataUtil.isEmpty(tCar.getFranchiseeId()) || tCar.getFranchiseeId() == 0)){
|
model.addAttribute("companyType",1);
|
}else{
|
model.addAttribute("companyType",2);
|
}
|
|
//获取经营业务
|
List<TCarService> serviceList = tCarServiceService.selectList(new EntityWrapper<TCarService>().eq("carId", tCar.getId()));
|
Integer one = 1;
|
Integer two = 1;
|
Integer three = 1;
|
Integer four = 1;
|
Integer five = 1;
|
Integer six = 1;
|
Integer zcModel = 0;
|
Integer kcModel = 0;
|
for (TCarService obj : serviceList){
|
if (obj.getType() == 1){
|
one = 2;
|
zcModel = obj.getServerCarModelId();
|
}
|
if (obj.getType() == 2){
|
two = 2;
|
}
|
if (obj.getType() == 3){
|
three = 2;
|
kcModel = obj.getServerCarModelId();
|
}
|
if (obj.getType() == 4){
|
four = 2;
|
}
|
if (obj.getType() == 5){
|
five = 2;
|
}
|
if (obj.getType() == 6){
|
six = 2;
|
}
|
}
|
model.addAttribute("one",one);
|
model.addAttribute("two",two);
|
model.addAttribute("three",three);
|
model.addAttribute("four",four);
|
model.addAttribute("five",five);
|
model.addAttribute("six",six);
|
model.addAttribute("zcModel",zcModel);
|
model.addAttribute("kcModel",kcModel);
|
|
List<TServerCarmodel> zcModelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 1).eq("state", 1));
|
model.addAttribute("zcModelList",zcModelList);
|
List<TServerCarmodel> kcModelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 2).eq("state", 1));
|
model.addAttribute("kcModelList",kcModelList);
|
|
//车辆品牌
|
List<TCarBrand> brandList = tCarBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
|
model.addAttribute("brandList",brandList);
|
//车辆类型
|
List<TCarModel> modelList = tCarModelService.selectList(new EntityWrapper<TCarModel>().eq("brandId",tCar.getCarBrandId()).eq("state", 1));
|
model.addAttribute("modelList",modelList);
|
List<TCarColor> state = carColorService.selectList(new EntityWrapper<TCarColor>().eq("state", 1));
|
model.addAttribute("color", state);
|
return PREFIX + "tCar_edit.html";
|
}
|
@RequestMapping("/tCar_auth/{tCarId}")
|
public String tCarAuth(@PathVariable Integer tCarId, Model model) {
|
TCar tCar = tCarService.selectById(tCarId);
|
model.addAttribute("item",tCar);
|
//获取经营业务
|
List<TCarService> serviceList = tCarServiceService.selectList(new EntityWrapper<TCarService>().eq("carId", tCar.getId()));
|
Integer one = 1;
|
Integer two = 1;
|
Integer three = 1;
|
Integer four = 1;
|
Integer five = 1;
|
Integer six = 1;
|
Integer zcModel = 0;
|
Integer kcModel = 0;
|
for (TCarService obj : serviceList){
|
if (obj.getType() == 1){
|
one = 2;
|
zcModel = obj.getServerCarModelId();
|
}
|
if (obj.getType() == 1){
|
four = 2;
|
zcModel = obj.getServerCarModelId();
|
}
|
}
|
model.addAttribute("one",one);
|
model.addAttribute("four",four);
|
model.addAttribute("zcModel",zcModel);
|
List<TServerCarmodel> zcModelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 1).eq("state", 1));
|
model.addAttribute("zcModelList",zcModelList);
|
LogObjectHolder.me().set(tCar);
|
return PREFIX + "tCar_auth.html";
|
}
|
|
/**
|
* 跳转到保险列表页
|
* @param carId
|
* @param model
|
* @return
|
*/
|
@RequestMapping("/carInsurance")
|
public String carInsurance(Integer carId, Model model){
|
model.addAttribute("carId", carId);
|
return PREFIX + "carInsurance.html";
|
}
|
|
/**
|
* 跳转到添加页面
|
* @param carId
|
* @param model
|
* @return
|
*/
|
@RequestMapping("/showAddCarInsurance")
|
public String showAddCarInsurance(Integer carId, Model model){
|
model.addAttribute("carId", carId);
|
model.addAttribute("id", "");
|
return PREFIX + "carInsuranceInfo.html";
|
}
|
|
/**
|
* 跳转到编辑页
|
* @param id
|
* @param carId
|
* @param model
|
* @return
|
*/
|
@RequestMapping("/showEditCarInsurance")
|
public String showEditCarInsurance(Integer id, Integer carId, Model model){
|
model.addAttribute("carId", carId);
|
model.addAttribute("id", id);
|
return PREFIX + "carInsuranceInfo.html";
|
}
|
|
/**
|
* 添加保险数据
|
* @param carInsurance
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/saveCarInsurance", method = RequestMethod.POST)
|
public ResultUtil saveCarInsurance(CarInsurance carInsurance){
|
if(carInsurance.getId() == null){
|
carInsuranceMapper.insert(carInsurance);
|
}else{
|
carInsuranceMapper.updateById(carInsurance);
|
}
|
|
return ResultUtil.success();
|
}
|
|
/**
|
* 获取保险详情
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/queryCarInsurance", method = RequestMethod.POST)
|
public ResultUtil queryCarInsurance(Integer id){
|
CarInsurance carInsurance = carInsuranceMapper.selectById(id);
|
return ResultUtil.success(carInsurance);
|
}
|
|
|
/**
|
* 获取保险列表
|
* @param carId
|
* @param offset
|
* @param limit
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/queryInsuranceList", method = RequestMethod.POST)
|
public Object queryInsuranceList(Integer carId, Integer offset,Integer limit){
|
try {
|
Map<String, Object> map = new HashMap<>();
|
List<Map<String, Object>> list = carInsuranceMapper.queryInsuranceList(carId, offset, limit);
|
int i = carInsuranceMapper.queryInsuranceListCount(carId);
|
map.put("rows", list);
|
map.put("total", i);
|
return map;
|
}catch (Exception e){
|
e.printStackTrace();
|
return ResultUtil.runErr();
|
}
|
}
|
|
/**
|
* 删除保险
|
* @param id
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/delCarInsurance", method = RequestMethod.POST)
|
public ResultUtil delCarInsurance(Integer id){
|
carInsuranceMapper.deleteById(id);
|
return ResultUtil.success();
|
}
|
|
|
/**
|
* 获取车辆管理列表
|
*/
|
@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();
|
page.setRecords(tCarService.getCarList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,id,brandName,modelName,carColor,serverStr,carLicensePlate,driverName,companyName,franchiseeName));
|
return super.packForBT(page);
|
}
|
|
|
/**
|
* 获取车辆管理列表
|
*/
|
@RequestMapping(value = "/listAuth")
|
@ResponseBody
|
public Object listAuth(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();
|
page.setRecords(tCarService.getCarListAuth(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,id,brandName,modelName,carColor,serverStr,carLicensePlate,driverName,companyName,franchiseeName));
|
return super.packForBT(page);
|
}
|
/**
|
* 新增车辆管理
|
*/
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object add(TCar tCar,@RequestParam String serverBox,Integer roleType,Integer companyType,Integer oneId,Integer twoId,Integer franchiseeId,String zcModel,String kcModel) {
|
if (1 == roleType){ //平台
|
if (2 == companyType.intValue()){
|
if (SinataUtil.isNotEmpty(oneId)){
|
tCar.setCompanyId(oneId);
|
}
|
if (SinataUtil.isNotEmpty(twoId)){
|
tCar.setFranchiseeId(twoId);
|
}
|
}else if (1 == companyType.intValue()){
|
TCompany company = tCompanyService.selectOne(new EntityWrapper<TCompany>().eq("type", 1));
|
tCar.setCompanyId(company.getId());
|
tCar.setFranchiseeId(0);
|
}
|
tCar.setAddType(2);
|
tCar.setIsPlatCar(1);
|
}else if (2 == roleType){ //分公司
|
if (SinataUtil.isNotEmpty(ShiroKit.getUser().getObjectId())){
|
tCar.setCompanyId(ShiroKit.getUser().getObjectId());
|
}
|
if (SinataUtil.isNotEmpty(franchiseeId)){
|
tCar.setFranchiseeId(franchiseeId);
|
}
|
tCar.setIsPlatCar(2);
|
tCar.setAddType(3);
|
tCar.setAddObjectId(ShiroKit.getUser().getObjectId());
|
}else if (3 == roleType){ //加盟商
|
TCompany tCompany = tCompanyService.selectById(ShiroKit.getUser().getObjectId());
|
if (SinataUtil.isNotEmpty(tCompany)){
|
tCar.setCompanyId(tCompany.getSuperiorId());
|
}
|
if (SinataUtil.isNotEmpty(ShiroKit.getUser().getObjectId())){
|
tCar.setFranchiseeId(ShiroKit.getUser().getObjectId());
|
}
|
tCar.setIsPlatCar(2);
|
tCar.setAddType(4);
|
tCar.setAddObjectId(ShiroKit.getUser().getObjectId());
|
}
|
tCar.setInsertTime(new Date());
|
tCar.setState(1);
|
tCar.setAuthState(1);
|
tCarService.insert(tCar);
|
|
//添加经营业务
|
String[] serverArray = serverBox.split(",");
|
for (int i=0;i<serverArray.length;i++){
|
TCarService service = new TCarService();
|
service.setCarId(tCar.getId());
|
service.setType(Integer.valueOf(serverArray[i]));
|
if (1 == service.getType()){
|
service.setServerCarModelId(Integer.valueOf(zcModel));
|
}else if (3 == service.getType()){
|
service.setServerCarModelId(Integer.valueOf(kcModel));
|
}
|
tCarServiceService.insert(service);
|
}
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除车辆管理
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tCarId) {
|
TCar tCar = tCarService.selectById(tCarId);
|
tCar.setState(2);
|
tCarService.updateById(tCar);
|
|
//清除相对应的司机关联车辆ID
|
List<TDriver> list = tDriverService.selectList(new EntityWrapper<TDriver>().eq("carId", tCarId));
|
for (TDriver obj : list){
|
obj.setCarId(null);
|
tDriverService.updateById(obj);
|
}
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改车辆管理
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(TCar tCar,@RequestParam String serverBox,Integer roleType,Integer companyType,Integer oneId,Integer twoId,Integer franchiseeId,String zcModel,String kcModel) {
|
if (1 == roleType){ //平台
|
if (2 == companyType.intValue()){
|
if (SinataUtil.isNotEmpty(oneId)){
|
tCar.setCompanyId(oneId);
|
}
|
if (SinataUtil.isNotEmpty(twoId)){
|
tCar.setFranchiseeId(twoId);
|
}
|
}else if (1 == companyType.intValue()){
|
TCompany company = tCompanyService.selectOne(new EntityWrapper<TCompany>().eq("type", 1));
|
tCar.setCompanyId(company.getId());
|
tCar.setFranchiseeId(0);
|
}
|
}else if (2 == roleType){ //分公司
|
if (SinataUtil.isNotEmpty(ShiroKit.getUser().getObjectId())){
|
tCar.setCompanyId(ShiroKit.getUser().getObjectId());
|
}
|
if (SinataUtil.isNotEmpty(franchiseeId)){
|
tCar.setFranchiseeId(franchiseeId);
|
}
|
}else if (3 == roleType){ //加盟商
|
TCompany tCompany = tCompanyService.selectById(ShiroKit.getUser().getObjectId());
|
if (SinataUtil.isNotEmpty(tCompany)){
|
tCar.setCompanyId(tCompany.getSuperiorId());
|
}
|
if (SinataUtil.isNotEmpty(ShiroKit.getUser().getObjectId())){
|
tCar.setFranchiseeId(ShiroKit.getUser().getObjectId());
|
}
|
}
|
|
//删除业务
|
tCarServiceService.delete(new EntityWrapper<TCarService>().eq("carId",tCar.getId()));
|
|
//添加经营业务
|
String[] serverArray = serverBox.split(",");
|
for (int i=0;i<serverArray.length;i++){
|
TCarService service = new TCarService();
|
service.setCarId(tCar.getId());
|
service.setType(Integer.valueOf(serverArray[i]));
|
if (1 == service.getType()){
|
service.setServerCarModelId(Integer.valueOf(zcModel));
|
}else if (3 == service.getType()){
|
service.setServerCarModelId(Integer.valueOf(kcModel));
|
}
|
tCarServiceService.insert(service);
|
}
|
|
tCarService.updateById(tCar);
|
return SUCCESS_TIP;
|
}
|
@RequestMapping(value = "/updateAuth")
|
@ResponseBody
|
public Object updateAuth(TCar tCar,String zcModel,@RequestParam String serverBox) {
|
//添加经营业务
|
if(tCar.getAuthState()==2){
|
String[] serverArray = serverBox.split(",");
|
for (int i=0;i<serverArray.length;i++){
|
TCarService tCarService = tCarServiceService.selectOne(new EntityWrapper<TCarService>().eq("carId", tCar.getId()).eq("type", Integer.valueOf(serverArray[i])));
|
if(null == tCarService){
|
tCarService = new TCarService();
|
tCarService.setCarId(tCar.getId());
|
tCarService.setType(Integer.valueOf(serverArray[i]));
|
if (1 == tCarService.getType()){
|
tCarService.setServerCarModelId(Integer.valueOf(zcModel));
|
}
|
tCarServiceService.insert(tCarService);
|
}else{
|
if (1 == tCarService.getType()){
|
tCarService.setServerCarModelId(Integer.valueOf(zcModel));
|
}
|
tCarServiceService.updateById(tCarService);
|
}
|
|
|
}
|
}
|
tCarService.updateById(tCar);
|
tCar = tCarService.selectById(tCar.getId());
|
TDriver tDriver = tDriverService.selectById(tCar.getDriverId());
|
|
TCar finalTCar = tCar;
|
new Thread(new Runnable() {
|
@Override
|
public void run() {
|
try {
|
String path = templatePath + "driver/index.html";
|
Document document = Jsoup.parse(new File(path), "UTF-8");
|
document.getElementById("chinese").attr("style", "display: none;");
|
document.getElementById("french").attr("style", "display: none;");
|
document.getElementById("invite1").attr("style", "display: none;");
|
document.getElementById("user1").attr("style", "display: none;");
|
document.getElementById("settle1").attr("style", "display: none;");
|
document.getElementById("pass1").attr("style", "display: none;");
|
document.getElementById("email1").attr("style", "display: none;");
|
document.getElementById("bill1").attr("style", "display: none;");
|
document.getElementById("reward1").attr("style", "display: none;");
|
document.getElementById("rewardToday1").attr("style", "display: none;");
|
document.getElementById("driverAudit1").attr("style", "display: none;");
|
Element car_audit1_user = document.getElementById("car_audit1_user");
|
car_audit1_user.text("Hello " + tDriver.getFirstName() + " " + tDriver.getLastName() + ",");
|
Element car_audit1_content = document.getElementById("car_audit1_content");
|
if(2 == finalTCar.getAuthState()){
|
car_audit1_content.text("You vehicle application has been approved. See the I-GO platform for details.");
|
}else{
|
car_audit1_content.text("Sorry, your vehicle application was not approved. The reason for the failure is: incomplete filling of vehicle information.");
|
}
|
EmailUtil.send(tDriver.getEmail(), "Vehicle audit notice", document.html());
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
}).start();
|
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 车辆管理详情
|
*/
|
@RequestMapping(value = "/detail/{tCarId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tCarId") Integer tCarId) {
|
return tCarService.selectById(tCarId);
|
}
|
|
/**
|
* 下载模板
|
* @param request
|
* @param response
|
*/
|
@RequestMapping(value = "/uploadCarModel")
|
public void uploadCarModel(HttpServletRequest request, HttpServletResponse response) {
|
// 表格数据【封装】
|
List<List<String>> dataList = new ArrayList<List<String>>();
|
|
// 首行【封装】
|
List<String> shellList = new ArrayList<String>();
|
shellList.add("所属机构[平台车辆/加盟车辆]");
|
shellList.add("所属分公司[提示:加盟车辆选填]");
|
shellList.add("所属加盟商[提示:加盟车辆选填]");
|
shellList.add("服务模式:专车[是/否]");
|
// shellList.add("服务模式:出租车[是/否]");
|
// shellList.add("服务模式:跨城出行[是/否]");
|
shellList.add("服务模式:市内小件物流[是/否]");
|
// shellList.add("服务模式:小件跨城物流[是/否]");
|
// shellList.add("服务模式:包车[是/否]");
|
shellList.add("车辆品牌");
|
shellList.add("车辆类型");
|
shellList.add("车辆颜色[黑色/银色/白色/红色/黄色/橙色/蓝色]");
|
shellList.add("车牌号");
|
shellList.add("roadworthiness sticker");
|
shellList.add("年检到期时间[例如 2020-02-02]");
|
shellList.add("商业保险到期时间[例如 2020-02-02]");
|
dataList.add(shellList);
|
|
try {
|
// 调用工具类进行导出
|
ExcelExportUtil.easySheet("平台导入车辆模板"+DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "平台导入车辆模板", dataList, request, response);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* 导入操作
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value="/exportCar",method = RequestMethod.POST)
|
@ResponseBody
|
public Object exportCar(HttpServletRequest request){
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
MultipartFile file = (MultipartFile) multipartRequest.getFile("myfile");
|
try {
|
//定时五秒后执行
|
/*Map<String,Object> maps=new HashMap<>();
|
Workbook book = WoUtil.ImportFile(file);
|
maps.put("book",book);
|
QuartzManager.addJob(AddContract.class, (AddContract.name+new Date().getTime()).toUpperCase(), TimeJobType.ADMIN,DateUtil.getDate_strYMdHms(new Date().getTime() + 1*1000) , maps);*/
|
|
Workbook book = WoUtil.ImportFile(file);
|
Sheet sh = book.getSheetAt(0); //获取到第一个表
|
for (int i = 1; i <= sh.getLastRowNum(); i++) {
|
Row row = sh.getRow(i);
|
|
Cell cell0 = row.getCell(0); //所属机构[平台车辆/加盟车辆]
|
String zero = null;
|
if (SinataUtil.isNotEmpty(cell0)){
|
zero = String.valueOf(cell0.getStringCellValue()).trim();
|
}
|
|
Cell cell1 = row.getCell(1); //所属分公司[提示:加盟车辆选填]
|
String one = null;
|
if (SinataUtil.isNotEmpty(cell1)){
|
one = String.valueOf(cell1.getStringCellValue()).trim();
|
}
|
|
Cell cell2 = row.getCell(2); //所属加盟商[提示:加盟车辆选填]
|
String two = null;
|
if (SinataUtil.isNotEmpty(cell2)){
|
two = String.valueOf(cell2.getStringCellValue()).trim();
|
}
|
|
Cell cell3 = row.getCell(3); //服务模式:专车[是/否]
|
String three = null;
|
if (SinataUtil.isNotEmpty(cell3)){
|
three = String.valueOf(cell3.getStringCellValue()).trim();
|
}
|
|
// Cell cell4 = row.getCell(4); //服务模式:出租车[是/否]
|
// String four = null;
|
// if (SinataUtil.isNotEmpty(cell4)){
|
// four = String.valueOf(cell4.getStringCellValue()).trim();
|
// }
|
//
|
// Cell cell5 = row.getCell(5); //服务模式:跨城出行[是/否]
|
// String five = null;
|
// if (SinataUtil.isNotEmpty(cell5)){
|
// five = String.valueOf(cell5.getStringCellValue()).trim();
|
// }
|
|
Cell cell6 = row.getCell(4); //服务模式:小件跨城物流[是/否]
|
String six = null;
|
if (SinataUtil.isNotEmpty(cell6)){
|
six = String.valueOf(cell6.getStringCellValue()).trim();
|
}
|
|
// Cell cell7 = row.getCell(7); //服务模式:小件跨城物流[是/否]
|
// String seven = null;
|
// if (SinataUtil.isNotEmpty(cell7)){
|
// seven = String.valueOf(cell7.getStringCellValue()).trim();
|
// }
|
//
|
// Cell cell8 = row.getCell(8); //服务模式:包车[是/否]
|
// String eight = null;
|
// if (SinataUtil.isNotEmpty(cell8)){
|
// eight = String.valueOf(cell8.getStringCellValue()).trim();
|
// }
|
|
Cell cell9 = row.getCell(5); //车辆品牌
|
String nine = null;
|
if (SinataUtil.isNotEmpty(cell9)){
|
nine = String.valueOf(cell9.getStringCellValue()).trim();
|
}
|
|
Cell cell10 = row.getCell(6); //车辆类型
|
String ten = null;
|
if (SinataUtil.isNotEmpty(cell10)){
|
ten = String.valueOf(cell10.getStringCellValue()).trim();
|
}
|
|
Cell cell11 = row.getCell(7); //车辆颜色[黑色/银色/白色/红色/黄色/橙色/蓝色]
|
String eleven = null;
|
if (SinataUtil.isNotEmpty(cell11)){
|
eleven = String.valueOf(cell11.getStringCellValue()).trim();
|
}
|
|
Cell cell12 = row.getCell(8); //车牌号
|
String twelve = null;
|
if (SinataUtil.isNotEmpty(cell12)){
|
twelve = String.valueOf(cell12.getStringCellValue()).trim();
|
}
|
|
Cell cell13 = row.getCell(9); //行驶证编号
|
String thirteen = null;
|
if (SinataUtil.isNotEmpty(cell13)){
|
thirteen = String.valueOf(cell13.getStringCellValue()).trim();
|
}
|
|
Cell cell14 = row.getCell(10); //年检到期时间
|
String fourteen = null;
|
if (SinataUtil.isNotEmpty(cell14)){
|
fourteen = String.valueOf(cell14.getStringCellValue()).trim();
|
}
|
|
Cell cell15 = row.getCell(11); //商业保险到期时间
|
String fifteen = null;
|
if (SinataUtil.isNotEmpty(cell15)){
|
fifteen = String.valueOf(cell15.getStringCellValue()).trim();
|
}
|
|
if (SinataUtil.isEmpty(zero) || SinataUtil.isEmpty(three) /*|| SinataUtil.isEmpty(four)
|
|| SinataUtil.isEmpty(five) */|| SinataUtil.isEmpty(six) || /*SinataUtil.isEmpty(seven)
|
|| SinataUtil.isEmpty(eight) || */SinataUtil.isEmpty(nine) || SinataUtil.isEmpty(ten)
|
|| SinataUtil.isEmpty(eleven) || SinataUtil.isEmpty(twelve) || SinataUtil.isEmpty(thirteen)
|
|| SinataUtil.isEmpty(fourteen) || SinataUtil.isEmpty(fifteen)){
|
return new ErrorTip(500, "单元格不能为空");
|
}else{
|
//判断所属机构
|
if (!zero.equals("平台车辆") && !zero.equals("加盟车辆")){
|
return new ErrorTip(500, "所属机构内容不正确");
|
}
|
//判断服务模式【专车】
|
if (!three.equals("是") && !three.equals("否")){
|
return new ErrorTip(500, "服务模式【专车】内容不正确");
|
}
|
// //判断服务模式【出租车】
|
// if (!four.equals("是") && !four.equals("否")){
|
// return new ErrorTip(500, "服务模式【出租车】内容不正确");
|
// }
|
// //判断服务模式【跨城出行】
|
// if (!five.equals("是") && !five.equals("否")){
|
// return new ErrorTip(500, "服务模式【跨城出行】内容不正确");
|
// }
|
//判断服务模式【小件同城物流】
|
if (!six.equals("是") && !six.equals("否")){
|
return new ErrorTip(500, "服务模式【小件市内物流】内容不正确");
|
}
|
// //判断服务模式【小件跨城物流】
|
// if (!seven.equals("是") && !seven.equals("否")){
|
// return new ErrorTip(500, "服务模式【小件跨城物流】内容不正确");
|
// }
|
// //判断服务模式【包车】
|
// if (!eight.equals("是") && !eight.equals("否")){
|
// return new ErrorTip(500, "服务模式【包车】内容不正确");
|
// }
|
//判断车辆颜色
|
if (!eleven.equals("黑色") && !eleven.equals("银色") && !eleven.equals("白色") && !eleven.equals("红色") && !eleven.equals("黄色") && !eleven.equals("橙色") && !eleven.equals("蓝色")){
|
return new ErrorTip(500, "车辆颜色内容不正确");
|
}
|
//判断年检到期时间格式是否正确
|
try {
|
if (!isValidDate(fourteen)) {
|
fourteen = importByExcelForDate(fourteen);
|
}
|
}catch (Exception e){
|
return new ErrorTip(500, "年检到期时间格式不正确");
|
}
|
//判断商业保险到期时间格式是否正确
|
try {
|
if (!isValidDate(fifteen)) {
|
fifteen = importByExcelForDate(fifteen);
|
}
|
}catch (Exception e){
|
return new ErrorTip(500, "商业保险到期时间格式不正确");
|
}
|
|
//查找平台公司
|
TCompany platCompany = itCompanyService.selectOne(new EntityWrapper<TCompany>().eq("type", 1).notIn("flag", "3").last(" limit 1"));
|
Integer companyId = platCompany.getId();
|
Integer franchiseeId = 0;
|
if ("加盟车辆".equals(zero)){
|
//判断所属分公司是否存在
|
if (SinataUtil.isNotEmpty(one)){
|
TCompany company = itCompanyService.selectOne(new EntityWrapper<TCompany>().eq("name", one).eq("type", 2).notIn("flag", "3").last(" limit 1"));
|
if (SinataUtil.isNotEmpty(company)){
|
companyId = company.getId();
|
//判断加盟商是否存在
|
if (SinataUtil.isNotEmpty(two)){
|
TCompany franchisee = itCompanyService.selectOne(new EntityWrapper<TCompany>().eq("superiorId",company.getId()).eq("name", two).eq("type", 3).notIn("flag", "3").last(" limit 1"));
|
if (SinataUtil.isNotEmpty(franchisee)){
|
franchiseeId = franchisee.getId();
|
}
|
}
|
}
|
}
|
}
|
|
Integer carBrandId = null;
|
Integer carModelId = null;
|
//查找品牌
|
if (SinataUtil.isNotEmpty(nine)){
|
TCarBrand carBrand = tCarBrandService.selectOne(new EntityWrapper<TCarBrand>().eq("name", nine).eq("state", 1).last(" limit 1"));
|
if (SinataUtil.isNotEmpty(carBrand)){
|
carBrandId = carBrand.getId();
|
if (SinataUtil.isNotEmpty(ten)){
|
//查找类型
|
TCarModel carModel = tCarModelService.selectOne(new EntityWrapper<TCarModel>().eq("brandId", carBrand.getId()).eq("name", ten).eq("state", 1).last(" limit 1"));
|
if (SinataUtil.isNotEmpty(carModel)){
|
carModelId = carModel.getId();
|
}
|
}
|
}
|
}
|
|
//添加车辆对象
|
TCar car = new TCar();
|
if ("平台车辆".equals(zero)){
|
car.setIsPlatCar(1);
|
}else if ("加盟车辆".equals(zero)){
|
car.setIsPlatCar(2);
|
}
|
car.setCompanyId(companyId);
|
car.setFranchiseeId(franchiseeId);
|
car.setCarColor(eleven);
|
car.setCarBrandId(carBrandId);
|
car.setCarModelId(carModelId);
|
car.setCarLicensePlate(twelve);
|
car.setDrivingLicenseNumber(thirteen);
|
car.setAnnualInspectionTime(DateUtil.parseDate(fourteen));
|
car.setCommercialInsuranceTime(DateUtil.parseDate(fifteen));
|
car.setInsertTime(new Date());
|
car.setState(1);
|
if (ShiroKit.getUser().getRoleType() == 1){
|
car.setAddType(2);
|
}else if (ShiroKit.getUser().getRoleType() == 2){
|
car.setAddType(3);
|
car.setAddObjectId(ShiroKit.getUser().getObjectId());
|
}else if (ShiroKit.getUser().getRoleType() == 3){
|
car.setAddType(4);
|
car.setAddObjectId(ShiroKit.getUser().getObjectId());
|
}
|
tCarService.insert(car);
|
|
//添加专车服务模式
|
if ("是".equals(three)){
|
TCarService service = new TCarService();
|
service.setCarId(car.getId());
|
service.setType(1);
|
tCarServiceService.insert(service);
|
}
|
// //添加出租车服务模式
|
// if ("是".equals(four)){
|
// TCarService service = new TCarService();
|
// service.setCarId(car.getId());
|
// service.setType(2);
|
// tCarServiceService.insert(service);
|
// }
|
// //添加跨城出行服务模式
|
// if ("是".equals(five)){
|
// TCarService service = new TCarService();
|
// service.setCarId(car.getId());
|
// service.setType(3);
|
// tCarServiceService.insert(service);
|
// }
|
//添加小件同城物流服务模式
|
if ("是".equals(six)){
|
TCarService service = new TCarService();
|
service.setCarId(car.getId());
|
service.setType(4);
|
tCarServiceService.insert(service);
|
}
|
// //添加小件跨城物流服务模式
|
// if ("是".equals(seven)){
|
// TCarService service = new TCarService();
|
// service.setCarId(car.getId());
|
// service.setType(5);
|
// tCarServiceService.insert(service);
|
// }
|
// //添加包车服务模式
|
// if ("是".equals(eight)){
|
// TCarService service = new TCarService();
|
// service.setCarId(car.getId());
|
// service.setType(6);
|
// tCarServiceService.insert(service);
|
// }
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 判断日期是否满足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;
|
}
|
|
/**
|
* 导出车辆信息
|
*/
|
@RequestMapping(value = "/outCar")
|
public void outCar(HttpServletRequest request, HttpServletResponse response) {
|
List<Map<String,Object>> listMap = tCarService.getCarListNoPage(ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId());
|
|
// 表格数据【封装】
|
List<List<String>> dataList = new ArrayList<>();
|
|
//第一行显示【封装】
|
List<String> twoList = new ArrayList<String>();
|
twoList.add("总计:");
|
twoList.add(String.valueOf(listMap.size())+"条");
|
dataList.add(twoList);
|
|
// 列【封装】
|
List<String> shellList = new ArrayList<String>();
|
shellList.add("添加时间");
|
shellList.add("车辆ID");
|
shellList.add("所属分公司");
|
shellList.add("所属加盟商");
|
shellList.add("车辆品牌");
|
shellList.add("车辆类型");
|
shellList.add("颜色");
|
shellList.add("服务模式");
|
shellList.add("车牌号");
|
shellList.add("roadworthiness sticker");
|
shellList.add("座位数");
|
shellList.add("关联司机");
|
shellList.add("年检到期时间");
|
shellList.add("商业保险到期时间");
|
dataList.add(shellList);
|
|
for (Map<String,Object> object : listMap){
|
// 详细数据列【封装】
|
shellList = new ArrayList<String>();
|
if(SinataUtil.isNotEmpty(object.get("insertTime"))){
|
shellList.add(DateUtil.formatDate(DateUtil.parse(object.get("insertTime").toString(),"YYYY-MM-dd HH:mm:ss.S"), "YYYY-MM-dd HH:mm:ss"));
|
}else{
|
shellList.add("-");
|
}
|
shellList.add(String.valueOf(object.get("id")));
|
if(SinataUtil.isNotEmpty(object.get("companyName"))){
|
shellList.add(object.get("companyName").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("franchiseeName"))){
|
shellList.add(object.get("franchiseeName").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("brandName"))){
|
shellList.add(object.get("brandName").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("modelName"))){
|
shellList.add(object.get("modelName").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("carColor"))){
|
shellList.add(object.get("carColor").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("serverStr"))){
|
shellList.add(object.get("serverStr").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("carLicensePlate"))){
|
shellList.add(object.get("carLicensePlate").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("drivingLicenseNumber"))){
|
shellList.add(object.get("drivingLicenseNumber").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("seat"))){
|
shellList.add(object.get("seat").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("driverName"))){
|
shellList.add(object.get("driverName").toString());
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("annualInspectionTime"))){
|
shellList.add(DateUtil.formatDate(DateUtil.parse(object.get("annualInspectionTime").toString(),"YYYY-MM-dd HH:mm:ss.S"), "YYYY-MM-dd HH:mm:ss"));
|
}else{
|
shellList.add("-");
|
}
|
if(SinataUtil.isNotEmpty(object.get("commercialInsuranceTime"))){
|
shellList.add(DateUtil.formatDate(DateUtil.parse(object.get("commercialInsuranceTime").toString(),"YYYY-MM-dd HH:mm:ss.S"), "YYYY-MM-dd HH:mm:ss"));
|
}else{
|
shellList.add("-");
|
}
|
dataList.add(shellList);
|
}
|
try {
|
// 调用工具类进行导出
|
ExcelExportUtil.easySheet("车辆信息导出记录"+DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "车辆信息导出记录", dataList,request, response);
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
}
|