package com.dsh.guns.modular.system.controller.general; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dsh.course.feignClient.account.model.CompanyQuerySuperiorIdAndTypeAndFlgAndNameReq; import com.dsh.course.feignClient.account.model.CompanyQueryTypeAndFlgAndNameReq; import com.dsh.course.feignClient.account.model.CompanyQueryTypeAndFlgReq; import com.dsh.course.feignClient.activity.CompanyClient; import com.dsh.course.feignClient.activity.DriverClient; import com.dsh.course.feignClient.activity.model.CompanyInfoRes; import com.dsh.course.feignClient.activity.model.CompanyQueryReq; import com.dsh.course.feignClient.activity.model.TDriverReq; import com.dsh.course.mapper.CarInsuranceMapper; import com.dsh.guns.config.UserExt; import com.dsh.guns.core.base.controller.BaseController; import com.dsh.guns.core.base.tips.ErrorTip; import com.dsh.guns.core.common.constant.factory.PageFactory; import com.dsh.guns.core.log.LogObjectHolder; import com.dsh.guns.core.util.SinataUtil; import com.dsh.guns.modular.system.model.*; import com.dsh.guns.modular.system.service.*; 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.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.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import com.dsh.guns.core.util.WoUtil; import javax.annotation.Resource; 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("/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 ITCarServiceService itCarServiceService; @Autowired private ITServerCarmodelService itServerCarmodelService; // @Autowired // private PushMinistryOfTransportUtil pushMinistryOfTransportUtil; @Resource private CarInsuranceMapper carInsuranceMapper; @Autowired private CompanyClient companyClient; @Autowired private DriverClient driverClient; /** * 跳转到车辆管理首页 */ @RequestMapping("") public String index(Model model) { model.addAttribute("language",UserExt.getLanguage()); return PREFIX + "tCar.html"; } /** * 跳转到添加车辆管理 */ @RequestMapping("/tCar_add") public String tCarAdd(Model model) { List companyList = companyClient.queryByTypeCompany(2); model.addAttribute("companyList",companyList); User user = UserExt.getUser(); Integer roleType = user.getRoleType(); model.addAttribute("roleType",roleType); if (2 == roleType){ // List franchiseeList = companyClient.queryByTypeCompany(new EntityWrapper().eq("type", 3).eq("superiorId",11)); List companyInfoRes = companyClient.queryByListCompany(new CompanyQueryReq(3, user.getObjectId())); model.addAttribute("franchiseeList",companyInfoRes); }else{ model.addAttribute("franchiseeList",null); } //查询当前用户所属分公司/加盟商 model.addAttribute("objectName",companyClient.queryById(UserExt.getUser().getObjectId()).getName()); //车辆品牌 car brand List brandList = tCarBrandService.list(new QueryWrapper().eq("state", 1)); model.addAttribute("brandList",brandList); //车辆类型 /*List modelList = tCarModelService.selectList(new EntityWrapper().eq("state", 1)); model.addAttribute("modelList",modelList);*/ List zcModelList = itServerCarmodelService.list(new QueryWrapper().eq("type", 1).eq("state", 1)); model.addAttribute("zcModelList",zcModelList); List kcModelList = itServerCarmodelService.list(new QueryWrapper().eq("type", 2).eq("state", 1)); model.addAttribute("kcModelList",kcModelList); model.addAttribute("language",UserExt.getLanguage()); return PREFIX + "tCar_add.html"; } /** * 查询车辆类型 * @param carBrandId * @return */ @RequestMapping(value = "/brandChange") @ResponseBody public Object brandChange(@RequestParam Integer carBrandId) { List list = new ArrayList<>(); if (SinataUtil.isNotEmpty(carBrandId)){ list = tCarModelService.list(new QueryWrapper().eq("state",1).eq("brandId", carBrandId)); } return list; } /** * 跳转到修改车辆管理 */ @RequestMapping("/tCar_update/{tCarId}") public String tCarUpdate(@PathVariable Integer tCarId, Model model) { TCar tCar = tCarService.getById(tCarId); model.addAttribute("item",tCar); LogObjectHolder.me().set(tCar); User user = UserExt.getUser(); Integer roleType = user.getRoleType(); model.addAttribute("roleType",roleType); model.addAttribute("objectName",companyClient.queryById(user.getObjectId()).getName()); if (1 == roleType){ // List companyList = tCompanyService.selectList(new EntityWrapper().eq("type", 2)); List companyInfoRes = companyClient.queryByTypeCompany(2); model.addAttribute("companyList",companyInfoRes); // List franchiseeList = tCompanyService.selectList(new EntityWrapper().eq("type", 3).eq("superiorId",tCar.getCompanyId())); List companyInfoRes1 = companyClient.queryByListCompany(new CompanyQueryReq(3, tCar.getCompanyId())); model.addAttribute("franchiseeList",companyInfoRes1); }else if (2 == roleType){ // List franchiseeList = tCompanyService.selectList(new EntityWrapper().eq("type", 3).eq("superiorId",11)); List companyInfoRes1 = companyClient.queryByListCompany(new CompanyQueryReq(3, user.getObjectId())); model.addAttribute("franchiseeList",companyInfoRes1); } //查询平台ID // TCompany company = tCompanyService.selectOne(new EntityWrapper().eq("type", 1)); CompanyInfoRes company = companyClient.queryByTypeCompany(1).get(0); //判断是平台司机还是加盟司机 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 serviceList = tCarServiceService.list(new QueryWrapper().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 zcModelList = itServerCarmodelService.list(new QueryWrapper().eq("type", 1).eq("state", 1)); model.addAttribute("zcModelList",zcModelList); List kcModelList = itServerCarmodelService.list(new QueryWrapper().eq("type", 2).eq("state", 1)); model.addAttribute("kcModelList",kcModelList); //车辆品牌 car brand List brandList = tCarBrandService.list(new QueryWrapper().eq("state", 1)); model.addAttribute("brandList",brandList); //车辆类型 List modelList = tCarModelService.list(new QueryWrapper().eq("brandId",tCar.getCarBrandId()).eq("state", 1)); model.addAttribute("modelList",modelList); model.addAttribute("language",UserExt.getLanguage()); return PREFIX + "tCar_edit.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); // new Thread(new Runnable() { // @Override // public void run() { // if(pushMinistryOfTransport){//上传数据 // pushMinistryOfTransportUtil.baseInfoVehicleInsurance(carInsurance.getId(), 1); // } // } // }).start(); }else{ carInsuranceMapper.updateById(carInsurance); // new Thread(new Runnable() { // @Override // public void run() { // if(pushMinistryOfTransport){//上传数据 // pushMinistryOfTransportUtil.baseInfoVehicleInsurance(carInsurance.getId(), 2); // } // } // }).start(); } 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 map = new HashMap<>(); List> 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); // new Thread(new Runnable() { // @Override // public void run() { // if(pushMinistryOfTransport){//上传数据 // pushMinistryOfTransportUtil.baseInfoVehicleInsurance(id, 3); // } // } // }).start(); 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> page = new PageFactory>().defaultPage(); page.setRecords(tCarService.getCarList(page,UserExt.getUser().getRoleType(),UserExt.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, String serverBox,Integer roleType,Integer companyType,Integer oneId,Integer twoId,Integer franchiseeId,String zcModel,String kcModel) { TCar tCar1 = tCarService.getBaseMapper().selectOne(new QueryWrapper().eq("carLicensePlate", tCar.getCarLicensePlate()).eq("state", 1)); if(null != tCar1){ return ResultUtil.error(UserExt.getLanguage() == 1 ? "车牌号重复" : UserExt.getLanguage() == 2 ? "Duplicate license plate" : "Kode kendaraan diulangi."); } if (1 == roleType){ //平台 platfrom 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().eq("type", 1)); CompanyInfoRes company = companyClient.queryByTypeCompany(1).get(0); tCar.setCompanyId(company.getId()); tCar.setFranchiseeId(0); } tCar.setAddType(2); tCar.setIsPlatCar(1); }else if (2 == roleType){ //分公司 sub company if (SinataUtil.isNotEmpty(UserExt.getUser().getObjectId())){ tCar.setCompanyId(UserExt.getUser().getObjectId()); } if (SinataUtil.isNotEmpty(franchiseeId)){ tCar.setFranchiseeId(franchiseeId); } tCar.setIsPlatCar(2); tCar.setAddType(3); tCar.setAddObjectId(UserExt.getUser().getObjectId()); }else if (3 == roleType){ //加盟商 Franchisee. CompanyInfoRes tCompany = companyClient.queryById(UserExt.getUser().getObjectId()); if (SinataUtil.isNotEmpty(tCompany)){ tCar.setCompanyId(tCompany.getSuperiorId()); } if (SinataUtil.isNotEmpty(UserExt.getUser().getObjectId())){ tCar.setFranchiseeId(UserExt.getUser().getObjectId()); } tCar.setIsPlatCar(2); tCar.setAddType(4); tCar.setAddObjectId(UserExt.getUser().getObjectId()); } tCar.setInsertTime(new Date()); tCar.setState(1); tCarService.save(tCar); //添加经营业务 Add business operations. String[] serverArray = serverBox.split(","); for (int i=0;i list = driverClient.queryDriverListByCarId(tCarId); for (TDriverReq obj : list){ obj.setCarId(null); driverClient.updateById(obj); } // new Thread(new Runnable() { // @Override // public void run() { // if(pushMinistryOfTransport){//上传数据 // pushMinistryOfTransportUtil.baseInfoCompanyStat(); // pushMinistryOfTransportUtil.baseInfoVehicle(tCar.getId()); // } // } // }).start(); 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) { TCar tCar1 = tCarService.getBaseMapper().selectOne(new QueryWrapper().eq("carLicensePlate", tCar.getCarLicensePlate()).eq("state", 1)); if(null != tCar1 && tCar1.getId().compareTo(tCar.getId()) != 0){ return ResultUtil.error(UserExt.getLanguage() == 1 ? "车牌号重复" : UserExt.getLanguage() == 2 ? "Duplicate license plate" : "Kode kendaraan diulangi."); } if (1 == roleType){ //平台 platfrom 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().eq("type", 1)); CompanyInfoRes company = companyClient.queryByTypeCompany(1).get(0); tCar.setCompanyId(company.getId()); tCar.setFranchiseeId(0); } }else if (2 == roleType){ //分公司 sub company if (SinataUtil.isNotEmpty(UserExt.getUser().getObjectId())){ tCar.setCompanyId(UserExt.getUser().getObjectId()); } if (SinataUtil.isNotEmpty(franchiseeId)){ tCar.setFranchiseeId(franchiseeId); } }else if (3 == roleType){ //加盟商 Franchisee CompanyInfoRes tCompany = companyClient.queryById(UserExt.getUser().getObjectId()); if (SinataUtil.isNotEmpty(tCompany)){ tCar.setCompanyId(tCompany.getSuperiorId()); } if (SinataUtil.isNotEmpty(UserExt.getUser().getObjectId())){ tCar.setFranchiseeId(UserExt.getUser().getObjectId()); } } //删除业务 Delete business tCarServiceService.remove(new QueryWrapper().eq("carId",tCar.getId())); //添加经营业务 add business String[] serverArray = serverBox.split(","); for (int i=0;i> dataList = new ArrayList>(); Integer language = UserExt.getLanguage(); if(language==1){ // 首行【封装】 first line List shellList = new ArrayList(); 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 shellList = new ArrayList(); 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 shellList = new ArrayList(); 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(); } } } /** * 导入操作 * @param request * @return */ @RequestMapping(value="/exportCar",method = RequestMethod.POST) @ResponseBody public Object exportCar(HttpServletRequest request){ Integer language = UserExt.getLanguage(); if(language==1) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartFile file = (MultipartFile) multipartRequest.getFile("myfile"); try { //定时五秒后执行 Execute after five seconds on schedule. /*Map 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); //获取到第一个表 get first table for (int i = 1; i <= sh.getLastRowNum(); i++) { Row row = sh.getRow(i); Cell cell0 = row.getCell(0); //所属机构[平台车辆/加盟车辆] Affiliated Organization [Platform Vehicles/Franchise Vehicles] String zero = null; if (SinataUtil.isNotEmpty(cell0)) { zero = String.valueOf(cell0.getStringCellValue()).trim(); } Cell cell1 = row.getCell(1); //所属分公司[提示:加盟车辆选填] Affiliated branch company [Note: Franchise vehicles are optional]. String one = null; if (SinataUtil.isNotEmpty(cell1)) { cell1.setCellType(Cell.CELL_TYPE_STRING); one = String.valueOf(cell1.getStringCellValue()).trim(); } Cell cell2 = row.getCell(2); //所属加盟商[提示:加盟车辆选填] Affiliated Franchise [Note: Franchise vehicles are optional]. String two = null; if (SinataUtil.isNotEmpty(cell2)) { two = String.valueOf(cell2.getStringCellValue()).trim(); } Cell cell3 = row.getCell(3); //服务模式:专车[是/否] Business mode: dedicated vehicle [yes/no] String three = null; if (SinataUtil.isNotEmpty(cell3)) { three = String.valueOf(cell3.getStringCellValue()).trim(); } Cell cell4 = row.getCell(4); //服务模式:出租车[是/否] Business mode: taxi [yes/no] String four = null; if (SinataUtil.isNotEmpty(cell4)) { four = String.valueOf(cell4.getStringCellValue()).trim(); } Cell cell5 = row.getCell(5); //服务模式:跨城出行[是/否] Business mode: cross-city [yes/no] String five = null; if (SinataUtil.isNotEmpty(cell5)) { five = String.valueOf(cell5.getStringCellValue()).trim(); } Cell cell6 = row.getCell(6); //服务模式:小件跨城物流[是/否] Business mode: small-scale logistics [yes/no] String six = null; if (SinataUtil.isNotEmpty(cell6)) { six = String.valueOf(cell6.getStringCellValue()).trim(); } Cell cell7 = row.getCell(7); //服务模式:小件跨城物流[是/否] Business mode: small-scale logistics [yes/no] String seven = null; if (SinataUtil.isNotEmpty(cell7)) { seven = String.valueOf(cell7.getStringCellValue()).trim(); } Cell cell8 = row.getCell(8); //服务模式:包车[是/否] Service mode: Chartered service [Yes/No] cell8.setCellType(Cell.CELL_TYPE_STRING); String eight = null; if (SinataUtil.isNotEmpty(cell8)) { eight = String.valueOf(cell8.getStringCellValue()).trim(); } Cell cell9 = row.getCell(9); //车辆品牌 car brand cell9.setCellType(Cell.CELL_TYPE_STRING); String nine = null; if (SinataUtil.isNotEmpty(cell9)) { nine = String.valueOf(cell9.getStringCellValue()).trim(); } Cell cell10 = row.getCell(10); //车辆类型 car type cell10.setCellType(Cell.CELL_TYPE_STRING); String ten = null; if (SinataUtil.isNotEmpty(cell10)) { ten = String.valueOf(cell10.getStringCellValue()).trim(); } Cell cell11 = row.getCell(11); //车辆颜色[黑色/银色/白色/红色/黄色/橙色/蓝色] Vehicle color options include black, silver, white, red, yellow, orange, and blue. cell11.setCellType(Cell.CELL_TYPE_STRING); String eleven = null; if (SinataUtil.isNotEmpty(cell11)) { eleven = String.valueOf(cell11.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)) { return new ErrorTip(500, "单元格不能为空"); } else { //判断所属机构 Determine the affiliated organization. if (!zero.equals("平台车辆") && !zero.equals("加盟车辆")) { return new ErrorTip(500, "所属机构内容不正确"); } //判断服务模式【专车】 Assessing the Service Mode "Private Car if (!three.equals("是") && !three.equals("否")) { return new ErrorTip(500, "服务模式【摩托车】内容不正确"); } //判断服务模式【出租车】Assessing the Service Mode "taxi Car if (!four.equals("是") && !four.equals("否")) { return new ErrorTip(500, "服务模式【同城快送】内容不正确"); } //判断车辆颜色Assessing the car colors if (!seven.equals("1") && !seven.equals("2") && !seven.equals("3") && !seven.equals("4") && !seven.equals("5") && !seven.equals("6") && !seven.equals("7")) { return new ErrorTip(500, "车辆颜色内容不正确"); } //判断年检到期时间格式是否正确 Verify if the format of the expiration date for inspection is correct. try { if (!isValidDate(ten)) { ten = importByExcelForDate(ten); } } catch (Exception e) { return new ErrorTip(500, "年检到期时间格式不正确"); } //判断商业保险到期时间格式是否正确 Check whether the expiration date format of the commercial insurance is correct. try { if (!isValidDate(eleven)) { eleven = importByExcelForDate(eleven); } } catch (Exception e) { return new ErrorTip(500, "商业保险到期时间格式不正确"); } //查找平台公司 Search for platform companies // TCompany platCompany = itCompanyService.selectOne(new EntityWrapper().eq("type", 1).notIn("flag", "3").last(" limit 1")); CompanyInfoRes platCompany = companyClient.queryByTypeAndFlg(new CompanyQueryTypeAndFlgReq(1, 3)); Integer companyId = platCompany.getId(); Integer franchiseeId = 0; if ("加盟车辆".equals(zero)) { //判断所属分公司是否存在 Check if the subsidiary company exists if (SinataUtil.isNotEmpty(one)) { // TCompany company = itCompanyService.selectOne(new EntityWrapper().eq("name", one).eq("type", 2).notIn("flag", "3").last(" limit 1")); CompanyInfoRes company = companyClient.queryByTypeAndFlgAndName(new CompanyQueryTypeAndFlgAndNameReq(2, 3, one)); if (SinataUtil.isNotEmpty(company)) { companyId = company.getId(); //判断加盟商是否存在 Assessing the existence of a franchisee if (SinataUtil.isNotEmpty(two)) { // TCompany franchisee = itCompanyService.selectOne(new EntityWrapper().eq("superiorId",company.getId()).eq("name", two).eq("type", 3).notIn("flag", "3").last(" limit 1")); CompanyInfoRes franchisee = companyClient.queryBySuperiorIdAndTypeAndFlgAndName(new CompanyQuerySuperiorIdAndTypeAndFlgAndNameReq(3, 3, two, company.getId())); if (SinataUtil.isNotEmpty(franchisee)) { franchiseeId = franchisee.getId(); } } } } } Integer carBrandId = null; Integer carModelId = null; //查找品牌 search brand if (SinataUtil.isNotEmpty(five)) { TCarBrand carBrand = tCarBrandService.getOne(new QueryWrapper().eq("name", five).eq("state", 1).last(" limit 1")); if (SinataUtil.isNotEmpty(carBrand)) { carBrandId = carBrand.getId(); if (SinataUtil.isNotEmpty(six)) { //查找类型 search type TCarModel carModel = tCarModelService.getOne(new QueryWrapper().eq("brandId", carBrand.getId()).eq("name", six).eq("state", 1).last(" limit 1")); if (SinataUtil.isNotEmpty(carModel)) { carModelId = carModel.getId(); } } } } //添加车辆对象 add vechcle obj 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(seven); car.setCarBrandId(carBrandId); car.setCarModelId(carModelId); car.setCarLicensePlate(eight); car.setDrivingLicenseNumber(nine); car.setAnnualInspectionTime(DateUtil.parseDate(ten)); car.setCommercialInsuranceTime(DateUtil.parseDate(eleven)); car.setInsertTime(new Date()); car.setState(1); if (UserExt.getUser().getRoleType() == 1) { car.setAddType(2); } else if (UserExt.getUser().getRoleType() == 2) { car.setAddType(3); car.setAddObjectId(UserExt.getUser().getObjectId()); } else if (UserExt.getUser().getRoleType() == 3) { car.setAddType(4); car.setAddObjectId(UserExt.getUser().getObjectId()); } tCarService.save(car); //添加专车服务模式 add special car service if ("是".equals(three)) { TCarService service = new TCarService(); service.setCarId(car.getId()); service.setType(1); tCarServiceService.save(service); } //添加小件同城物流服务模式 add small-scale local-city service model if ("是".equals(four)) { TCarService service = new TCarService(); service.setCarId(car.getId()); service.setType(4); tCarServiceService.save(service); } } } } catch (Exception e) { e.printStackTrace(); } return SUCCESS_TIP; }else if(language==2){ MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartFile file = (MultipartFile) multipartRequest.getFile("myfile"); try { //定时五秒后执行 execute after 5s on schedule /*Map 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); //获取到第一个表 get first table for (int i = 1; i <= sh.getLastRowNum(); i++) { Row row = sh.getRow(i); Cell cell0 = row.getCell(0); //所属机构[平台车辆/加盟车辆] Affiliated Organization [Platform Vehicles/Franchise Vehicles] String zero = null; if (SinataUtil.isNotEmpty(cell0)) { zero = String.valueOf(cell0.getStringCellValue()).trim(); } Cell cell1 = row.getCell(1); //所属分公司[提示:加盟车辆选填] Affiliated branch company [Note: Franchise vehicles are optional]. String one = null; if (SinataUtil.isNotEmpty(cell1)) { cell1.setCellType(Cell.CELL_TYPE_STRING); one = String.valueOf(cell1.getStringCellValue()).trim(); } Cell cell2 = row.getCell(2); //所属加盟商[提示:加盟车辆选填]Affiliated Franchise [Note: Franchise vehicles are optional]. String two = null; if (SinataUtil.isNotEmpty(cell2)) { two = String.valueOf(cell2.getStringCellValue()).trim(); } Cell cell3 = row.getCell(3); //服务模式:专车[是/否]Business mode: dedicated vehicle [yes/no] String three = null; if (SinataUtil.isNotEmpty(cell3)) { three = String.valueOf(cell3.getStringCellValue()).trim(); } Cell cell4 = row.getCell(4); //服务模式:出租车[是/否]Business mode: taxi [yes/no] String four = null; if (SinataUtil.isNotEmpty(cell4)) { four = String.valueOf(cell4.getStringCellValue()).trim(); } Cell cell5 = row.getCell(5); //服务模式:跨城出行[是/否]Business mode: cross-city [yes/no] String five = null; if (SinataUtil.isNotEmpty(cell5)) { five = String.valueOf(cell5.getStringCellValue()).trim(); } Cell cell6 = row.getCell(6); //服务模式:小件跨城物流[是/否]Business mode: small-scale logistics [yes/no] String six = null; if (SinataUtil.isNotEmpty(cell6)) { six = String.valueOf(cell6.getStringCellValue()).trim(); } Cell cell7 = row.getCell(7); //服务模式:小件跨城物流[是/否]Business mode: small-scale logistics [yes/no] String seven = null; if (SinataUtil.isNotEmpty(cell7)) { seven = String.valueOf(cell7.getStringCellValue()).trim(); } Cell cell8 = row.getCell(8); //服务模式:包车[是/否]Service mode: Chartered service [Yes/No] cell8.setCellType(Cell.CELL_TYPE_STRING); String eight = null; if (SinataUtil.isNotEmpty(cell8)) { eight = String.valueOf(cell8.getStringCellValue()).trim(); } Cell cell9 = row.getCell(9); //车辆品牌car brand cell9.setCellType(Cell.CELL_TYPE_STRING); String nine = null; if (SinataUtil.isNotEmpty(cell9)) { nine = String.valueOf(cell9.getStringCellValue()).trim(); } Cell cell10 = row.getCell(10); //车辆类型 car type cell10.setCellType(Cell.CELL_TYPE_STRING); String ten = null; if (SinataUtil.isNotEmpty(cell10)) { ten = String.valueOf(cell10.getStringCellValue()).trim(); } Cell cell11 = row.getCell(11); //车辆颜色[黑色/银色/白色/红色/黄色/橙色/蓝色]Vehicle color options include black, silver, white, red, yellow, orange, and blue. cell11.setCellType(Cell.CELL_TYPE_STRING); String eleven = null; if (SinataUtil.isNotEmpty(cell11)) { eleven = String.valueOf(cell11.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)) { return new ErrorTip(500, "Cells cannot be empty"); } else { //判断所属机构 Determine the affiliated organization. if (!zero.equals("Platform vehicle") && !zero.equals("Franchised vehicle")) { return new ErrorTip(500, "The organization content is incorrect"); } //判断服务模式【专车】Assessing the Service Mode "Private Car if (!three.equals("yes") && !three.equals("no")) { return new ErrorTip(500, "Service mode [motorcycle] content is incorrect"); } //判断服务模式【出租车】Assessing the Service Mode "taxi if (!four.equals("yes") && !four.equals("no")) { return new ErrorTip(500, "Service mode [Intra-city Express] content is incorrect"); } //判断车辆颜色 Assessing the color if (!seven.equals("1") && !seven.equals("2") && !seven.equals("3") && !seven.equals("4") && !seven.equals("5") && !seven.equals("6") && !seven.equals("7")) { return new ErrorTip(500, "The vehicle color content is incorrect"); } //判断年检到期时间格式是否正确 Verify if the format of the expiration date for inspection is correct. try { if (!isValidDate(ten)) { ten = importByExcelForDate(ten); } } catch (Exception e) { return new ErrorTip(500, "The format of the annual inspection expiration time is incorrect"); } //判断商业保险到期时间格式是否正确 Check whether the expiration date format of the commercial insurance is correct. try { if (!isValidDate(eleven)) { eleven = importByExcelForDate(eleven); } } catch (Exception e) { return new ErrorTip(500, "The format of commercial insurance expiration time is incorrect"); } //查找平台公司 Search for platform companies // TCompany platCompany = itCompanyService.selectOne(new EntityWrapper().eq("type", 1).notIn("flag", "3").last(" limit 1")); CompanyInfoRes platCompany = companyClient.queryByTypeAndFlg(new CompanyQueryTypeAndFlgReq(1, 3)); Integer companyId = platCompany.getId(); Integer franchiseeId = 0; if ("Franchised vehicle".equals(zero)) { //判断所属分公司是否存在 Checking if the subsidiary company exists. if (SinataUtil.isNotEmpty(one)) { // TCompany company = itCompanyService.selectOne(new EntityWrapper().eq("name", one).eq("type", 2).notIn("flag", "3").last(" limit 1")); CompanyInfoRes company = companyClient.queryByTypeAndFlgAndName(new CompanyQueryTypeAndFlgAndNameReq(2, 3, one)); if (SinataUtil.isNotEmpty(company)) { companyId = company.getId(); //判断加盟商是否存在 Assessing the existence of a franchisee if (SinataUtil.isNotEmpty(two)) { // TCompany franchisee = itCompanyService.selectOne(new EntityWrapper().eq("superiorId",company.getId()).eq("name", two).eq("type", 3).notIn("flag", "3").last(" limit 1")); CompanyInfoRes franchisee = companyClient.queryBySuperiorIdAndTypeAndFlgAndName(new CompanyQuerySuperiorIdAndTypeAndFlgAndNameReq(3, 3, two, company.getId())); if (SinataUtil.isNotEmpty(franchisee)) { franchiseeId = franchisee.getId(); } } } } } Integer carBrandId = null; Integer carModelId = null; //查找品牌 search brand if (SinataUtil.isNotEmpty(five)) { TCarBrand carBrand = tCarBrandService.getOne(new QueryWrapper().eq("name", five).eq("state", 1).last(" limit 1")); if (SinataUtil.isNotEmpty(carBrand)) { carBrandId = carBrand.getId(); if (SinataUtil.isNotEmpty(six)) { //查找类型 search type TCarModel carModel = tCarModelService.getOne(new QueryWrapper().eq("brandId", carBrand.getId()).eq("name", six).eq("state", 1).last(" limit 1")); if (SinataUtil.isNotEmpty(carModel)) { carModelId = carModel.getId(); } } } } //添加车辆对象 add vechcle obj TCar car = new TCar(); if ("Platform vehicle".equals(zero)) { car.setIsPlatCar(1); } else if ("Franchised vehicle".equals(zero)) { car.setIsPlatCar(2); } car.setCompanyId(companyId); car.setFranchiseeId(franchiseeId); car.setCarColor(seven); car.setCarBrandId(carBrandId); car.setCarModelId(carModelId); car.setCarLicensePlate(eight); car.setDrivingLicenseNumber(nine); car.setAnnualInspectionTime(DateUtil.parseDate(ten)); car.setCommercialInsuranceTime(DateUtil.parseDate(eleven)); car.setInsertTime(new Date()); car.setState(1); if (UserExt.getUser().getRoleType() == 1) { car.setAddType(2); } else if (UserExt.getUser().getRoleType() == 2) { car.setAddType(3); car.setAddObjectId(UserExt.getUser().getObjectId()); } else if (UserExt.getUser().getRoleType() == 3) { car.setAddType(4); car.setAddObjectId(UserExt.getUser().getObjectId()); } tCarService.save(car); //添加专车服务模式 if ("yes".equals(three)) { TCarService service = new TCarService(); service.setCarId(car.getId()); service.setType(1); tCarServiceService.save(service); } //添加小件同城物流服务模式 if ("yes".equals(four)) { TCarService service = new TCarService(); service.setCarId(car.getId()); service.setType(4); tCarServiceService.save(service); } } } } catch (Exception e) { e.printStackTrace(); } return SUCCESS_TIP; }else { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartFile file = (MultipartFile) multipartRequest.getFile("myfile"); try { //定时五秒后执行 /*Map 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); //获取到第一个表 get first table for (int i = 1; i <= sh.getLastRowNum(); i++) { Row row = sh.getRow(i); Cell cell0 = row.getCell(0); //所属机构[平台车辆/加盟车辆] Affiliated Organization [Platform Vehicles/Franchise Vehicles] String zero = null; if (SinataUtil.isNotEmpty(cell0)) { zero = String.valueOf(cell0.getStringCellValue()).trim(); } Cell cell1 = row.getCell(1); //所属分公司[提示:加盟车辆选填]Affiliated Organization [Platform Vehicles/Franchise Vehicles] String one = null; if (SinataUtil.isNotEmpty(cell1)) { cell1.setCellType(Cell.CELL_TYPE_STRING); one = String.valueOf(cell1.getStringCellValue()).trim(); } Cell cell2 = row.getCell(2); //所属加盟商[提示:加盟车辆选填]Affiliated Franchise [Platform Vehicles/Franchise Vehicles] String two = null; if (SinataUtil.isNotEmpty(cell2)) { two = String.valueOf(cell2.getStringCellValue()).trim(); } Cell cell3 = row.getCell(3); //服务模式:专车[是/否]Business mode: dedicated vehicle [yes/no] String three = null; if (SinataUtil.isNotEmpty(cell3)) { three = String.valueOf(cell3.getStringCellValue()).trim(); } Cell cell4 = row.getCell(4); //服务模式:出租车[是/否] Business mode: taxi [yes/no] String four = null; if (SinataUtil.isNotEmpty(cell4)) { four = String.valueOf(cell4.getStringCellValue()).trim(); } Cell cell5 = row.getCell(5); //服务模式:跨城出行[是/否] Business mode: cross-city [yes/no] String five = null; if (SinataUtil.isNotEmpty(cell5)) { five = String.valueOf(cell5.getStringCellValue()).trim(); } Cell cell6 = row.getCell(6); //服务模式:小件跨城物流[是/否]Business mode: small-scale logistics [yes/no] String six = null; if (SinataUtil.isNotEmpty(cell6)) { six = String.valueOf(cell6.getStringCellValue()).trim(); } Cell cell7 = row.getCell(7); //服务模式:小件跨城物流[是/否]Business mode: small-scale logistics [yes/no] String seven = null; if (SinataUtil.isNotEmpty(cell7)) { seven = String.valueOf(cell7.getStringCellValue()).trim(); } Cell cell8 = row.getCell(8); //服务模式:包车[是/否]Service mode: Chartered service [Yes/No] cell8.setCellType(Cell.CELL_TYPE_STRING); String eight = null; if (SinataUtil.isNotEmpty(cell8)) { eight = String.valueOf(cell8.getStringCellValue()).trim(); } Cell cell9 = row.getCell(9); //车辆品牌 car brand cell9.setCellType(Cell.CELL_TYPE_STRING); String nine = null; if (SinataUtil.isNotEmpty(cell9)) { nine = String.valueOf(cell9.getStringCellValue()).trim(); } Cell cell10 = row.getCell(10); //车辆类型 cell10.setCellType(Cell.CELL_TYPE_STRING); String ten = null; if (SinataUtil.isNotEmpty(cell10)) { ten = String.valueOf(cell10.getStringCellValue()).trim(); } Cell cell11 = row.getCell(11); //车辆颜色[黑色/银色/白色/红色/黄色/橙色/蓝色]Vehicle color options include black, silver, white, red, yellow, orange, and blue. cell11.setCellType(Cell.CELL_TYPE_STRING); String eleven = null; if (SinataUtil.isNotEmpty(cell11)) { eleven = String.valueOf(cell11.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)) { return new ErrorTip(500, "Sel tidak dapat kosong"); } else { //判断所属机构 if (!zero.equals("Mobil platform") && !zero.equals("Kendaraan yang dibersihkan")) { return new ErrorTip(500, "isi organisasi tidak benar"); } //判断服务模式【专车】 if (!three.equals("ya") && !three.equals("Tidak")) { return new ErrorTip(500, "Konten mode layanan [motor] tidak benar"); } //判断服务模式【出租车】 if (!four.equals("ya") && !four.equals("Tidak")) { return new ErrorTip(500, "Konten mode layanan [Intra-city Express] tidak benar"); } //判断车辆颜色 if (!seven.equals("1") && !seven.equals("2") && !seven.equals("3") && !seven.equals("4") && !seven.equals("5") && !seven.equals("6") && !seven.equals("7")) { return new ErrorTip(500, "Konten warna kendaraan tidak benar"); } //判断年检到期时间格式是否正确 try { if (!isValidDate(ten)) { ten = importByExcelForDate(ten); } } catch (Exception e) { return new ErrorTip(500, "Format waktu penggantian inspeksi tahunan tidak benar"); } //判断商业保险到期时间格式是否正确 try { if (!isValidDate(eleven)) { eleven = importByExcelForDate(eleven); } } catch (Exception e) { return new ErrorTip(500, "Format waktunya kehabisan asuransi komersial tidak benar"); } //查找平台公司 Search for platform companies // TCompany platCompany = itCompanyService.selectOne(new EntityWrapper().eq("type", 1).notIn("flag", "3").last(" limit 1")); CompanyInfoRes platCompany = companyClient.queryByTypeAndFlg(new CompanyQueryTypeAndFlgReq(1, 3)); Integer companyId = platCompany.getId(); Integer franchiseeId = 0; if ("Kendaraan yang dibersihkan".equals(zero)) { //判断所属分公司是否存在 Checking if the subsidiary company exists. if (SinataUtil.isNotEmpty(one)) { // TCompany company = itCompanyService.selectOne(new EntityWrapper().eq("name", one).eq("type", 2).notIn("flag", "3").last(" limit 1")); CompanyInfoRes company = companyClient.queryByTypeAndFlgAndName(new CompanyQueryTypeAndFlgAndNameReq(2, 3, one)); if (SinataUtil.isNotEmpty(company)) { companyId = company.getId(); //判断加盟商是否存在 Assessing the existence of a franchisee if (SinataUtil.isNotEmpty(two)) { // TCompany franchisee = itCompanyService.selectOne(new EntityWrapper().eq("superiorId",company.getId()).eq("name", two).eq("type", 3).notIn("flag", "3").last(" limit 1")); CompanyInfoRes franchisee = companyClient.queryBySuperiorIdAndTypeAndFlgAndName(new CompanyQuerySuperiorIdAndTypeAndFlgAndNameReq(3, 3, two, company.getId())); if (SinataUtil.isNotEmpty(franchisee)) { franchiseeId = franchisee.getId(); } } } } } Integer carBrandId = null; Integer carModelId = null; //查找品牌 search brand if (SinataUtil.isNotEmpty(five)) { TCarBrand carBrand = tCarBrandService.getOne(new QueryWrapper().eq("name", five).eq("state", 1).last(" limit 1")); if (SinataUtil.isNotEmpty(carBrand)) { carBrandId = carBrand.getId(); if (SinataUtil.isNotEmpty(six)) { //查找类型 search type TCarModel carModel = tCarModelService.getOne(new QueryWrapper().eq("brandId", carBrand.getId()).eq("name", six).eq("state", 1).last(" limit 1")); if (SinataUtil.isNotEmpty(carModel)) { carModelId = carModel.getId(); } } } } //添加车辆对象 add vechcle obj TCar car = new TCar(); if ("Mobil platform".equals(zero)) { car.setIsPlatCar(1); } else if ("Kendaraan yang dibersihkan".equals(zero)) { car.setIsPlatCar(2); } car.setCompanyId(companyId); car.setFranchiseeId(franchiseeId); car.setCarColor(seven); car.setCarBrandId(carBrandId); car.setCarModelId(carModelId); car.setCarLicensePlate(eight); car.setDrivingLicenseNumber(nine); car.setAnnualInspectionTime(DateUtil.parseDate(ten)); car.setCommercialInsuranceTime(DateUtil.parseDate(eleven)); car.setInsertTime(new Date()); car.setState(1); if (UserExt.getUser().getRoleType() == 1) { car.setAddType(2); } else if (UserExt.getUser().getRoleType() == 2) { car.setAddType(3); car.setAddObjectId(UserExt.getUser().getObjectId()); } else if (UserExt.getUser().getRoleType() == 3) { car.setAddType(4); car.setAddObjectId(UserExt.getUser().getObjectId()); } tCarService.save(car); //添加专车服务模式 if ("ya".equals(three)) { TCarService service = new TCarService(); service.setCarId(car.getId()); service.setType(1); tCarServiceService.save(service); } //添加小件同城物流服务模式 if ("ya".equals(four)) { TCarService service = new TCarService(); service.setCarId(car.getId()); service.setType(4); tCarServiceService.save(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> listMap = tCarService.getCarList(null,UserExt.getUser().getRoleType(),UserExt.getUser().getObjectId(),null,null,null,null,null,null,null,null,null,null,null); // 表格数据【封装】 List> dataList = new ArrayList<>(); //第一行显示【封装】 List twoList = new ArrayList(); twoList.add("总计:"); twoList.add(String.valueOf(listMap.size())+"条"); dataList.add(twoList); // 列【封装】 List shellList = new ArrayList(); shellList.add("添加时间"); shellList.add("车辆ID"); shellList.add("所属机构"); shellList.add("车辆品牌"); shellList.add("车辆类型"); shellList.add("颜色"); shellList.add("服务模式"); shellList.add("车牌号"); shellList.add("行驶证号码"); shellList.add("关联司机"); shellList.add("年检到期时间"); shellList.add("商业保险到期时间"); shellList.add("车辆剩余电量"); dataList.add(shellList); for (Map object : listMap){ // 详细数据列【封装】 detail shellList = new ArrayList(); if(SinataUtil.isNotEmpty(object.get("insertTime"))){ shellList.add(DateUtil.format(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("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("driverName"))){ shellList.add(object.get("driverName").toString()); }else{ shellList.add("-"); } if(SinataUtil.isNotEmpty(object.get("annualInspectionTime"))){ shellList.add(DateUtil.format(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.format(DateUtil.parse(object.get("commercialInsuranceTime").toString(),"YYYY-MM-dd HH:mm:ss.S"), "YYYY-MM-dd HH:mm:ss")); }else{ shellList.add("-"); } if(SinataUtil.isNotEmpty(object.get("power"))){ shellList.add(object.get("power").toString()); }else{ shellList.add("-"); } dataList.add(shellList); } try { // 调用工具类进行导出 ExcelExportUtil.easySheet("车辆信息导出记录"+DateUtil.format(new Date(), "YYYYMMddHHmmss"), "车辆信息导出记录", dataList,request, response); } catch (Exception e) { e.printStackTrace(); } } }