integrated_traffic/src/main/java/com/zcloud/controller/beidou/BeidouController.java

331 lines
14 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.beidou;
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.beidou.BeidouService;
import com.zcloud.service.freighttrailer.FreightTrailerService;
import com.zcloud.service.maintenance.MaintenanceService;
import com.zcloud.service.operatingvehicles.OperatingVehiclesService;
import com.zcloud.service.operations.OperationsService;
import com.zcloud.service.system.ImgFilesService;
import com.zcloud.util.Const;
import com.zcloud.util.DateUtil;
import com.zcloud.util.Jurisdiction;
import org.bytedeco.javacpp.presets.opencv_core;
import com.zcloud.util.Smb;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
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 java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 北斗管理
*/
@Controller
@RequestMapping("/beidou")
public class BeidouController extends BaseController {
@Autowired
private BeidouService beidouService;
@Autowired
private ImgFilesService imgfilesService;
@Autowired
private Smb smb;
@Autowired
private OperatingVehiclesService operatingVehiclesService;
@Autowired
private FreightTrailerService freightTrailerService;
/**
* 新增
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/add")
// @RequiresPermissions( value = {"question:add" , "courseware:add"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "机务档案", menuServer = "北斗管理", instructionsOperate = "北斗管理", instructionsType = "新增")
public Object add(@RequestParam(value="FFILE",required=false) MultipartFile file) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("BEIDOU_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("TRANSPORTATIONCOMPANY", Jurisdiction.getCORPINFO_ID()); // 运输企业
pd.put("ARCHIVES_TYPE", "0"); //档案状态
pd.put("VEHICLE", pd.get("PLATE_NUMBER")); //档案状态
String ffile = DateUtil.getDays();
if (file != null && StringUtils.isNotBlank(pd.getString("CREATORNAME"))){
String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName)) {
errInfo = "fail";
map.put("result", errInfo);
map.put("msg", "文件格式不正确!");
return map;
}
String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("TRANSPORTATIONCOMPANY") + "/" + ffile);
pd.put("CONTRACT", Const.FILEPATHFILE + pd.getString("TRANSPORTATIONCOMPANY") + "/" + ffile + "/" + fileName);
pd.put("ATTACHMENT_NAME",pd.getString("CREATORNAME"));
pd.put("CONFIRM_MESSAGE_TIME",DateUtil.date2Str(new Date()));
}
PageData operationData = new PageData();
operationData.put("OPERATING_ID", pd.get("VEHICLE"));
operationData.put("CORPINFO_ID", pd.get("CORPINFO_ID"));
PageData resData = operatingVehiclesService.findById(operationData);
if(!ObjectUtils.isEmpty(resData)) {
if(StringUtils.isNotBlank(pd.getString("DUE_DATE"))) {
String expireDate = pd.getString("DUE_DATE");
String day = DateUtil.getDay();
if(DateUtil.compareDate(expireDate, day)) {
resData.put("NETWORK_STATUS","已入网");
}else{
resData.put("NETWORK_STATUS","超时入网");
}
}
operatingVehiclesService.edit(resData);
}
beidouService.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("DELETEOR", Jurisdiction.getUSER_ID()); //删除人id
pd.put("DELETEORNAME", Jurisdiction.getName()); //删除人
pd.put("DELETTIME", DateUtil.date2Str(new Date())); //删除时间
beidouService.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())); //修改时间
PageData operationData = new PageData();
operationData.put("OPERATING_ID", pd.get("VEHICLE"));
operationData.put("CORPINFO_ID", pd.get("CORPINFO_ID"));
PageData resData = operatingVehiclesService.findById(operationData);
if(!ObjectUtils.isEmpty(resData)) {
String dueDate = pd.getString("DUE_DATE");
String day = DateUtil.getDay();
if(DateUtil.compareDate(dueDate, day)) {
resData.put("NETWORK_STATUS","已入网");
}else{
resData.put("NETWORK_STATUS","超时入网");
}
operatingVehiclesService.edit(resData);
}
beidouService.edit(pd);
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* 修改
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/edit2")
// @RequiresPermissions( value = {"question:edit" , "courseware:edit"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "机务档案", menuServer = "北斗管理", instructionsOperate = "北斗管理", instructionsType = "修改")
public Object edit2() 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())); //修改时间
beidouService.edit2(pd);
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* 列表
*
* @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 = beidouService.list(page); //列出Question列表
for (PageData operation : varList) {
if("1".equals(operation.get("OPEAR_ISSCRAP")) || "1".equals(operation.get("FREIGHT_ISSCRAP"))) {
operation.put("ARCHIVES_TYPE", "1");
}
if("1".equals(operation.get("OPEAR_ISASSIGNED")) || "1".equals(operation.get("FREIGHT_ISASSIGNED"))) {
operation.put("ARCHIVES_TYPE", "2");
}
}
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**
* 去修改页面获取数据
*
* @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 = beidouService.findById(pd); //根据ID读取
pd.put("FOREIGN_KEY", pd.getString("BEIDOU_ID"));
pd.put("TYPE",128);
List<PageData> beidouinfoImgs = imgfilesService.listAll(pd);//北斗资料图片
map.put("pd", pd);
map.put("beidouinfoImgs", beidouinfoImgs);
map.put("result", errInfo);
return map;
}
@RequestMapping(value = "/vehicleList")
@ResponseBody
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 = beidouService.list(page);
for (int i = 0; i < insAnnually.size(); i++) {
for (int j = 0; j < operatingList.size(); j++) {
if(operatingList.get(j).get("OPERATING_ID").equals(insAnnually.get(i).get("VEHICLE"))) {
operatingList.remove(j);
}
}
}
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);
}
operatingList.forEach(operating -> {
operating.put("ID", operating.getString("OPERATING_ID"));
});
map.put("list", operatingList);
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 = beidouService.list(page);
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);
}
freightList.forEach(freight -> {
freight.put("ID", freight.getString("FREIGHTTRAILER_ID"));
});
map.put("list", freightList);
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;
}
}