integrated_traffic/src/main/java/com/zcloud/controller/freighttrailer/FreighttTrailerController.java

664 lines
30 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.zcloud.controller.freighttrailer;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.logs.LogAnno;
import com.zcloud.service.assignedManage.AssignedManageService;
import com.zcloud.service.freighttrailer.FreightTrailerService;
import com.zcloud.service.inspectAnnually.InspectAnnuallyService;
import com.zcloud.service.operatingvehicles.OperatingVehiclesService;
import com.zcloud.service.scrapManage.ScrapManageService;
import com.zcloud.service.system.ImgFilesService;
import com.zcloud.service.taxationManage.TaxationManageService;
import com.zcloud.util.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
/**
* 企业信息管理-货运挂车
*/
@Controller
@RequestMapping("/freightTrailer")
public class FreighttTrailerController extends BaseController {
@Autowired
private FreightTrailerService freightTrailerService;
@Autowired
private ImgFilesService imgfilesService;
@Autowired
private ScrapManageService scrapManageService;
@Autowired
private TaxationManageService taxationManageService;
@Autowired
private AssignedManageService assignedManageService;
@Autowired
private OperatingVehiclesService operatingVehiclesService;
@Autowired
private InspectAnnuallyService inspectAnnuallyService;
/**
* 新增
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/add")
// @RequiresPermissions( value = {"question:add" , "courseware:add"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "基础信息管理", menuServer = "货运挂车", instructionsOperate = "货运挂车", instructionsType = "新增")
public Object add() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("FREIGHTTRAILER_ID", this.get32UUID()); //主键
pd.put("CREATOR", Jurisdiction.getUSER_ID()); //添加人id
pd.put("CREATORNAME", Jurisdiction.getName()); //添加人
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
pd.put("ISDELETE", "0"); //是否删除(0:有效 1删除)
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业ID
pd.put("ISSCRAP", "0");
pd.put("ISASSIGNED", "0");
freightTrailerService.save(pd);
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* 删除
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/delete")
// @RequiresPermissions( value = {"question:del" , "courseware:del"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "基础信息管理", menuServer = "货运挂车", instructionsOperate = "货运挂车", instructionsType = "删除")
public Object delete() throws Exception {
Map<String, String> map = new HashMap<String, String>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
if(Tools.notEmpty(pd.getString("FREIGHTTRAILER_ID"))) {
PageData findPageData = freightTrailerService.findById(pd);
PageData scrapAddData = new PageData();
scrapAddData.put("SCRAP_ID",this.get32UUID());
scrapAddData.put("RECORD_NUMBER", findPageData.get("NUM"));
scrapAddData.put("FRAMES_NUMBER", findPageData.get("VIN"));
scrapAddData.put("PLATE_NUMBER", findPageData.get("PLATE_NUMBER"));
scrapAddData.put("SCRAP_VEHICLEMODEL", "货运挂车");
scrapAddData.put("VEHICLEOWNER", findPageData.get("CAR_OWNERS"));
scrapAddData.put("CONTACT_NUMBER", findPageData.get("CONTACT_PHONE"));
scrapAddData.put("SCRAP_DATE", DateUtil.date2Str(new Date()));
scrapAddData.put("REGISTRANT", Jurisdiction.getName());
scrapAddData.put("CREATTIME", DateUtil.date2Str(new Date()));
scrapAddData.put("OPERATTIME", DateUtil.date2Str(new Date()));
scrapAddData.put("VEHICLEOWNER_NUMBER", findPageData.get("CAR_OWNERS_TEL"));
scrapAddData.put("FIRSTSHOW_DATE", findPageData.get("INITIAL_REGISTRATION_DATE"));
scrapAddData.put("BRAND", findPageData.get("TRAILER_BRAND"));
scrapAddData.put("VEHICLE_MODEL", findPageData.get("TRAILER_MODEL"));
scrapAddData.put("TRANSACTION_DATE", DateUtil.date2Str(new Date()));
scrapAddData.put("CORPINFO_ID", findPageData.get("CORPINFO_ID"));
scrapAddData.put("SCRAP_VEHICLE", findPageData.get("PLATE_NUMBER"));
scrapAddData.put("ISDELETE", "0");
scrapAddData.put("SCRAPFLAG", "1");
scrapManageService.save(scrapAddData);
}
pd.put("DELETEOR", Jurisdiction.getUSER_ID()); //删除人id
pd.put("DELETEORNAME", Jurisdiction.getName()); //删除人
pd.put("DELETTIME", DateUtil.date2Str(new Date())); //删除时间
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
freightTrailerService.delete(pd);
map.put("result", errInfo); //返回结果
return map;
}
/**
* 修改
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/edit")
// @RequiresPermissions( value = {"question:edit" , "courseware:edit"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "基础信息管理", menuServer = "货运挂车", instructionsOperate = "货运挂车", instructionsType = "修改")
public Object edit() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //修改人id
pd.put("OPERATORNAME", Jurisdiction.getName()); //修改人
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
PageData freightTrailer = freightTrailerService.findById(pd);
if(StringUtils.equals(freightTrailer.getString("ISSCRAP"), "1")) {
pd.put("ISSCRAP", "1");
} else{
pd.put("ISSCRAP", "0");
}
if (StringUtils.equals(freightTrailer.getString("ISASSIGNED"), "1")) {
pd.put("ISASSIGNED", "1");
}else{
pd.put("ISASSIGNED", "0");
}
PageData trailerInfo = taxationManageService.findByTrailerId(pd);
if(!Tools.isEmpty(trailerInfo)) {
BeanUtil.copyProperties(pd,trailerInfo);
trailerInfo.put("FRAMES_NUMBER", pd.getString("VIN"));
trailerInfo.put("VEHICLE_TYPE", pd.getString("TRAILER_TYPE"));
trailerInfo.put("VEHICLEOWNER", pd.getString("CAR_OWNERS"));
trailerInfo.put("CONTACT_NUMBER", pd.getString("CONTACT_PHONE"));
trailerInfo.put("FIRSTSHOW_DATE", pd.getString("INITIAL_REGISTRATION_DATE"));
taxationManageService.edit(trailerInfo);
}
// 挂车 处理 更新 过户信息
PageData vehicleInfo = new PageData();
vehicleInfo.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
vehicleInfo.put("ID", pd.getString("FREIGHTTRAILER_ID"));
PageData trailerAssignedInfo = assignedManageService.findByRawVehicleId(vehicleInfo);
if (!Tools.isEmpty(trailerAssignedInfo)) {
BeanUtil.copyProperties(pd,trailerAssignedInfo);
trailerAssignedInfo.put("FRAMES_NUMBER", pd.getString("VIN"));
trailerAssignedInfo.put("RAW_CONTACT_NUMBER", pd.getString("CONTACT_PHONE"));
trailerAssignedInfo.put("RAW_OPERATION_CERTIFICATE", pd.getString("OPER_CERTIFICATE_NUM"));
assignedManageService.edit(trailerAssignedInfo);
}
PageData data = scrapManageService.findByScrapVehicleId(vehicleInfo);
if(!ObjectUtil.isEmpty(data)) {
BeanUtil.copyProperties(pd,data);
data.put("FRAMES_NUMBER", pd.getString("VIN"));
data.put("VEHICLEOWNER", pd.getString("CAR_OWNERS"));
data.put("VEHICLEOWNER_NUMBER", pd.getString("CAR_OWNERS_TEL"));
data.put("FIRSTSHOW_DATE", pd.getString("INITIAL_REGISTRATION_DATE"));
data.put("BRAND", pd.getString("TRAILER_BRAND"));
data.put("VEHICLE_MODEL", pd.getString("TRAILER_MODEL"));
scrapManageService.edit(data);
}
freightTrailerService.edit(pd);
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* 下载模版
*
* @param response
* @throws Exception
*/
@RequestMapping(value = "/downExcel")
public void downExcel(HttpServletResponse response) throws Exception {
FileDownload.fileDownload(response, PathUtil.getProjectpath() + Const.FILEPATHFILE + "truckExcelTemplate.xls", "货车挂车导入模板.xls");
}
/**
* 列表
*
* @param page
* @throws Exception
*/
@RequestMapping(value = "/list")
// @RequiresPermissions( value = {"question:list" , "courseware:list"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "基础信息管理", menuServer = "货运挂车", instructionsOperate = "货运挂车", instructionsType = "列表")
public Object list(Page page) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业ID
page.setPd(pd);
List<PageData> varList = freightTrailerService.list(page); //列出Question列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**从EXCEL导入到数据库
* @param file
* @return
* @throws Exception
*/
@RequestMapping(value = "/readExcel")
@SuppressWarnings("unchecked")
@ResponseBody
@Transactional
@LogAnno(menuType= "双重预防",menuServer= "风险管控",instructionsOperate = "风险点(单元)",instructionsType = "上传附件")
public Object readExcel(@RequestParam(value = "FFILE", required = false) MultipartFile file) throws Exception {
Map<String, String> map = new HashMap<String, String>();
String errInfo = "success";
StringBuffer errorStr = new StringBuffer();
if (null != file && !file.isEmpty()) {
File tempFile = new File(file.getOriginalFilename()); //新建file
FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile); //将MultipartFile复制到File
List<PageData> listPd = (List) ObjectExcelRead.readExcel(tempFile, 1, 0, 0); // 执行读EXCEL操作,读出的数据导入List
// 2:从第3行开始0:从第A列开始0:第0个sheet
/**
* var0 :风险点(单元) var1 :所属部门
*/
try {
if (listPd.size() < 1) {
map.put("result", "error"); // 返回结果
map.put("resultStr", "Excel数据为空请检查数据后重新上传");
FileUtils.deleteQuietly(tempFile);//删除临时文件
return map;
}
List<PageData> riskunitList = new ArrayList<>();
PageData pd = new PageData();
pd.put("ISDELETE", "0");
pd.put("BELONGING_DEPT", Jurisdiction.getCORPINFO_ID());
List<PageData> riskunitListAll = freightTrailerService.listAll(pd);
Map<String, Object> riskunitMapAll = new HashMap<>();
for (PageData pageData : riskunitListAll) {
// 使用车牌号作为键
String plateNumberKey = Tools.excelHandle(pageData.getString("PLATE_NUMBER"));
riskunitMapAll.put(plateNumberKey, pageData);
}
List<String> header = new ArrayList<>();
header.add("自编号");
header.add("车牌号");
header.add("车架号");
header.add("车身编号");
header.add("挂车类型");
header.add("运营证号");
header.add("归属部门");
header.add("车主");
header.add("车主电话");
header.add("联系人");
header.add("联系电话");
header.add("初登日期");
header.add("发证日期");
header.add("到期日期");
header.add("挂车品牌");
header.add("挂车型号");
header.add("核定总质量");
header.add("核定载质量");
header.add("容积");
header.add("备注");
Map<String, Object> hasRiskUnit = new HashMap<>();
int succeeNum = 1;
for (PageData lpd : listPd) {
succeeNum++;
convertExcelDate(lpd, "var11"); // 初登日期 INITIAL_REGISTRATION_DATE
convertExcelDate(lpd, "var12"); // 发证日期 CERTIFICATE_DATE
convertExcelDate(lpd, "var13"); // 到期日期 DUE_DATE
System.out.println(lpd.get("var11")+"--"+lpd.get("var12")+"--"+lpd.get("var13"));
for (int i = 0; i < header.size(); i++) {
if (!lpd.containsKey("var" + i)) {
errorStr.append("<p>第" + succeeNum + "行的\"" + header.get(i) + "\"无数据</p>");
continue;
}
if (Tools.isEmpty(lpd.get("var" + i))) {
errorStr.append("<p>第" + succeeNum + "行的\"" + header.get(i) + "\"无数据</p>");
continue;
}
}
String plateNumberVar = Tools.isEmpty(lpd.get("var1")) ? "" : Tools.excelHandle(lpd.get("var1"));
if (riskunitMapAll.containsKey(plateNumberVar)) {
errorStr.append("<p>第" + succeeNum + "行:" + "车牌号为\"" + plateNumberVar + "\"的记录已存在,请检查!" + "</p>");
continue;
}
if (hasRiskUnit.containsKey(plateNumberVar)) {
errorStr.append("<p>第" + succeeNum + "行:" + "车牌号重复,请重新检查内容!" + "</p>");
continue;
}
hasRiskUnit.put(plateNumberVar, "1");
PageData riskunit = new PageData();
riskunit.put("NUM", lpd.get("var0"));
riskunit.put("PLATE_NUMBER", lpd.get("var1"));
riskunit.put("VIN", lpd.get("var2"));
riskunit.put("VEHICLE_BODY_NUMBER", lpd.get("var3"));
riskunit.put("TRAILER_TYPE", lpd.get("var4"));
riskunit.put("OPER_CERTIFICATE_NUM", lpd.get("var5"));
riskunit.put("BELONGING_DEPT", lpd.get("var6"));
riskunit.put("CAR_OWNERS", lpd.get("var7"));
riskunit.put("CAR_OWNERS_TEL", lpd.get("var8"));
riskunit.put("CONTACTS", lpd.get("var9"));
riskunit.put("CONTACT_PHONE", lpd.get("var10"));
riskunit.put("INITIAL_REGISTRATION_DATE", lpd.get("var11"));
riskunit.put("CERTIFICATE_DATE", lpd.get("var12"));
riskunit.put("DUE_DATE", lpd.get("var13"));
riskunit.put("TRAILER_BRAND", lpd.get("var14"));
riskunit.put("TRAILER_MODEL", lpd.get("var15"));
riskunit.put("APPROVED_TOTAL_MASS", lpd.get("var16"));
riskunit.put("APPROVED_LOAD_CAPACITY", lpd.get("var17"));
riskunit.put("VOLUME", lpd.get("var18"));
riskunit.put("NOTES", lpd.get("var19"));
riskunit.put("FREIGHTTRAILER_ID", this.get32UUID());
riskunit.put("ISDELETE", "0");
riskunit.put("CREATOR", Jurisdiction.getName());
riskunit.put("CREATTIME", DateUtil.date2Str(new Date()));
riskunit.put("OPERATOR", Jurisdiction.getName());
riskunit.put("OPERATTIME", DateUtil.date2Str(new Date()));
riskunit.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
riskunitList.add(riskunit);
}
if (Tools.isEmpty(errorStr.toString())) {
for (PageData riskunit : riskunitList) {
freightTrailerService.save(riskunit);
}
errorStr.append("成功导入" + riskunitList.size() + "条数据!");
} else {
errInfo = "error";
}
FileUtils.deleteQuietly(tempFile);//删除临时文件
} catch (Exception e) {
map.put("result", "fail"); // 返回结果
map.put("resultStr", errorStr.toString());
FileUtils.deleteQuietly(tempFile);//删除临时文件
return map;
}
}
map.put("result", "success");//返回结果
map.put("resultType", errInfo);//返回message类型
map.put("isExcel","1");//返回类型
map.put("resultStr", errorStr.toString());
return map;
}
private void convertExcelDate(PageData lpd, String field) {
Object excelDateObj = lpd.get(field);
if (excelDateObj != null) {
// 尝试将对象转换为Double因为Excel中的日期是以Double类型的数字存储的
double excelDate = Double.parseDouble(excelDateObj.toString());
// 使用Apache POI的DateUtil获取Java日期对象
Date javaDate = org.apache.poi.ss.usermodel.DateUtil.getJavaDate(excelDate);
// 使用您的DateUtil工具类进行日期格式化
String formattedDate = DateUtil.date2Str(javaDate, "yyyy-MM-dd");
// 更新lpd对象中的日期字段
lpd.put(field, formattedDate);
}
}
/**
* 去修改页面获取数据
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/goEdit")
// @RequiresPermissions( value = {"question:edit" , "courseware:edit"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "基础信息管理", menuServer = "货运挂车", instructionsOperate = "货运挂车", instructionsType = "去修改页面获取数据")
public Object goEdit() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
pd = freightTrailerService.findById(pd); //根据ID读取
pd.put("FOREIGN_KEY", pd.getString("FREIGHTTRAILER_ID"));
pd.put("TYPE",120);
List<PageData> trailerImgs = imgfilesService.listAll(pd);//挂车照片
pd.put("TYPE",121);
List<PageData> drivingLicenseImgs = imgfilesService.listAll(pd);//行驶证照片
pd.put("TYPE",122);
List<PageData> operCertificateImgs = imgfilesService.listAll(pd);//运营证照片
pd.put("TYPE",123);
List<PageData> trailerInfoImgs = imgfilesService.listAll(pd);//挂车资料图片
PageData pd2 = new PageData();
pd2.put("TRAFFIC_TYPE",2);
pd2.put("ID", pd.getString("FREIGHTTRAILER_ID"));
pd2.put("CORPINFO_ID", pd.get("CORPINFO_ID"));
List<PageData> pdData = freightTrailerService.vehicleList(pd2);
PageData resData = pdData.get(0);
String[] companyAreas = resData.getString("COMPANY_AREA").split("/");
pd.put("PROVINCE",companyAreas[0]);
pd.put("CITY",companyAreas[1]);
pd.put("COUNTY",companyAreas[2]);
map.put("pd", pd);
map.put("trailerImgs", trailerImgs);
map.put("drivingLicenseImgs", drivingLicenseImgs);
map.put("operCertificateImgs", operCertificateImgs);
map.put("trailerInfoImgs", trailerInfoImgs);
map.put("result", errInfo);
return map;
}
/**导出到excel
* @param
* @throws Exception
*/
@RequestMapping(value="/excel")
// // @RequiresPermissions("toExcel")
public ModelAndView exportExcel() throws Exception{
ModelAndView mv = new ModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
String DATA_IDS = pd.getString("DATA_IDS");
if(Tools.notEmpty(DATA_IDS)){
String[] ArrayDATA_IDS = DATA_IDS.split(",");
pd.put("ArrayDATA_IDS",ArrayDATA_IDS);
}
Map<String,Object> dataMap = new HashMap<String,Object>();
List<String> titles = new ArrayList<String>();
titles.add("车牌号"); //1
titles.add("车架号"); //2
titles.add("车身编号"); //3
titles.add("挂车类型"); //4
titles.add("运营证号"); //5
titles.add("归属部门"); //6
titles.add("车主"); //7
titles.add("车主电话"); //8
titles.add("初登日期"); //9
titles.add("发证日期"); //10
titles.add("到期日期"); //11
titles.add("挂车品牌"); //12
titles.add("挂车型号"); //13
titles.add("核定总质量"); //14
titles.add("核定载质量"); //15
titles.add("容积"); //16
dataMap.put("titles", titles);
List<PageData> varOList = freightTrailerService.listOut(pd);
List<PageData> varList = new ArrayList<PageData>();
for(int i=0;i<varOList.size();i++){
PageData vpd = new PageData();
vpd.put("var1", varOList.get(i).getString("PLATE_NUMBER"));//1
vpd.put("var2", varOList.get(i).getString("VIN"));//2
vpd.put("var3", varOList.get(i).getString("VEHICLE_BODY_NUMBER"));//3
vpd.put("var4", varOList.get(i).getString("TRAILER_TYPE"));//4
vpd.put("var5", varOList.get(i).getString("OPER_CERTIFICATE_NUM"));//5
vpd.put("var6", varOList.get(i).getString("BELONGING_DEPT"));//6
vpd.put("var7", varOList.get(i).getString("CAR_OWNERS"));//7
vpd.put("var8", varOList.get(i).getString("CAR_OWNERS_TEL"));//8
vpd.put("var9", varOList.get(i).getString("INITIAL_REGISTRATION_DATE"));//9
vpd.put("var10", varOList.get(i).getString("CERTIFICATE_DATE"));//10
vpd.put("var11", varOList.get(i).getString("DUE_DATE"));//11
vpd.put("var12", varOList.get(i).getString("TRAILER_BRAND"));//12
vpd.put("var13", varOList.get(i).getString("TRAILER_MODEL"));//13
vpd.put("var14", varOList.get(i).getString("APPROVED_TOTAL_MASS"));//14
vpd.put("var15", varOList.get(i).getString("APPROVED_LOAD_CAPACITY"));//15
vpd.put("var16", varOList.get(i).getString("VOLUME"));//16
varList.add(vpd);
}
dataMap.put("varList", varList);
ObjectExcelView erv = new ObjectExcelView();
mv = new ModelAndView(erv,dataMap);
return mv;
}
/**
* 列表
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/corpList")
// @RequiresPermissions( value = {"question:list" , "courseware:list"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "基础信息管理", menuServer = "所属企业", instructionsOperate = "所属企业", instructionsType = "列表")
public Object corpList() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
String corpId = Jurisdiction.getCORPINFO_ID();
List<PageData> list = freightTrailerService.corpList(corpId); //列出Question列表
map.put("list", list);
map.put("result", errInfo);
return map;
}
/**
* 列表
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/trailerList")
// @RequiresPermissions( value = {"question:list" , "courseware:list"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "基础信息管理", menuServer = "货运挂车", instructionsOperate = "货运挂车", instructionsType = "列表")
public Object trailerList() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
String corpId = Jurisdiction.getCORPINFO_ID();
List<PageData> list = freightTrailerService.trailerList(corpId); //列出Question列表
map.put("list", list);
map.put("result", errInfo);
return map;
}
/**
* 列表
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/vehicleList")
// @RequiresPermissions( value = {"question:list" , "courseware:list"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "基础信息管理", menuServer = "营运车辆", instructionsOperate = "营运车辆", instructionsType = "列表")
public Object vehicleList(Page page) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
if(!StringUtils.isEmpty(pd.getString("TRAFFIC_TYPE")) && pd.getString("TRAFFIC_TYPE").equals("1")) {
// 营运车辆
List<PageData> operatingList = operatingVehiclesService.operationVehicleList(pd.getString("CORPINFO_ID"));
page.setPd(pd);
List<PageData> insAnnually = inspectAnnuallyService.annuallyList(page);
// 获取所有的营运车辆
List<PageData> operatings = insAnnually.stream().filter(data -> StringUtils.equals("1",data.getString("VEHICLE_MODEL")))
.collect(Collectors.toList());
// 过滤掉年检车辆中已经存在的营运车辆
List<PageData> varList = new ArrayList<>();
if(!CollectionUtils.isEmpty(operatings)) {
varList = operatingList.stream().parallel().filter(operating -> operatings.stream()
.noneMatch(ins -> Objects.equals(operating.getString("OPERATING_ID"), ins.getString("VEHICLE"))))
.collect(Collectors.toList());
}else{
varList = operatingList;
}
if(pd.containsKey("ID")){
pd.put("OPERATING_ID", pd.getString("ID"));
pd.put("FOREIGN_KEY", pd.getString("OPERATING_ID"));
pd.put("TYPE",121);
List<PageData> drivingLicenseImgs = imgfilesService.listAll(pd);//行驶证照片
map.put("drivingLicenseImgs", drivingLicenseImgs);
}
varList.forEach(operating -> {
operating.put("ID", operating.getString("OPERATING_ID"));
});
map.put("list", varList);
map.put("result", errInfo);
return map;
}
if("2".equals(pd.getString("TRAFFIC_TYPE"))) {
// 货运挂车
List<PageData> freightList = freightTrailerService.trailerList(pd.getString("CORPINFO_ID"));
page.setPd(pd);
List<PageData> insAnnually = inspectAnnuallyService.annuallyList(page);
// 获取所有的货运挂车
List<PageData> freights = insAnnually.stream().filter(data -> "2".equals(data.getString("VEHICLE_MODEL")))
.collect(Collectors.toList());
// 过滤掉年检列表中的所有货运挂车信息
List<PageData> varList = new ArrayList<>();
if(!CollectionUtils.isEmpty(freights)) {
varList = freightList.stream().parallel().filter(freight -> freights.stream()
.noneMatch(ins -> freight.getString("FREIGHTTRAILER_ID").equals(ins.getString("VEHICLE"))))
.collect(Collectors.toList());
}else{
varList = freightList;
}
/*for (int i = 0; i < insAnnually.size(); i++) {
for (int j = 0; j < freightList.size(); j++) {
if(freightList.get(j).get("FREIGHTTRAILER_ID").equals(insAnnually.get(i).get("VEHICLE"))) {
freightList.remove(j);
}
}
}*/
if(pd.containsKey("ID")){
pd.put("FREIGHTTRAILER_ID", pd.getString("ID"));
pd.put("FOREIGN_KEY", pd.getString("FREIGHTTRAILER_ID"));
pd.put("TYPE",121);
List<PageData> drivingLicenseImgs = imgfilesService.listAll(pd);//行驶证照片
map.put("drivingLicenseImgs", drivingLicenseImgs);
}
varList.forEach(freight -> {
freight.put("ID", freight.getString("FREIGHTTRAILER_ID"));
});
map.put("list", varList);
map.put("result", errInfo);
return map;
}
List<PageData> resData = freightTrailerService.vehicleList(pd);
if(pd.containsKey("ID")){
pd.put("FOREIGN_KEY", pd.getString("ID"));
pd.put("TYPE",121);
List<PageData> drivingLicenseImgs = imgfilesService.listAll(pd);//行驶证照片
map.put("drivingLicenseImgs", drivingLicenseImgs);
}
map.put("list", resData);
map.put("result", errInfo);
return map;
}
}