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

331 lines
14 KiB
Java
Raw Normal View History

2024-03-15 11:21:18 +08:00
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;
2024-03-28 18:32:23 +08:00
import com.zcloud.service.freighttrailer.FreightTrailerService;
2024-03-15 11:21:18 +08:00
import com.zcloud.service.maintenance.MaintenanceService;
import com.zcloud.service.operatingvehicles.OperatingVehiclesService;
import com.zcloud.service.operations.OperationsService;
2024-03-15 11:21:18 +08:00
import com.zcloud.service.system.ImgFilesService;
2024-03-26 18:01:53 +08:00
import com.zcloud.util.Const;
2024-03-15 11:21:18 +08:00
import com.zcloud.util.DateUtil;
import com.zcloud.util.Jurisdiction;
import org.bytedeco.javacpp.presets.opencv_core;
2024-03-26 18:01:53 +08:00
import com.zcloud.util.Smb;
import org.apache.commons.lang.StringUtils;
2024-03-15 11:21:18 +08:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
2024-03-15 11:21:18 +08:00
import org.springframework.web.bind.annotation.RequestMapping;
2024-03-26 18:01:53 +08:00
import org.springframework.web.bind.annotation.RequestParam;
2024-03-15 11:21:18 +08:00
import org.springframework.web.bind.annotation.ResponseBody;
2024-03-26 18:01:53 +08:00
import org.springframework.web.multipart.MultipartFile;
2024-03-15 11:21:18 +08:00
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;
2024-03-26 18:01:53 +08:00
@Autowired
private Smb smb;
2024-03-15 11:21:18 +08:00
@Autowired
private OperatingVehiclesService operatingVehiclesService;
2024-03-28 18:32:23 +08:00
@Autowired
private FreightTrailerService freightTrailerService;
2024-03-15 11:21:18 +08:00
/**
*
*
* @param
* @throws Exception
*/
@RequestMapping(value = "/add")
// @RequiresPermissions( value = {"question:add" , "courseware:add"}, logical = Logical.OR)
@ResponseBody
@LogAnno(menuType = "机务档案", menuServer = "北斗管理", instructionsOperate = "北斗管理", instructionsType = "新增")
2024-03-26 18:01:53 +08:00
public Object add(@RequestParam(value="FFILE",required=false) MultipartFile file) throws Exception {
2024-03-15 11:21:18 +08:00
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
2024-04-17 13:01:53 +08:00
pd.put("CREATORNAME", Jurisdiction.getName()); //添加人
2024-03-15 11:21:18 +08:00
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
pd.put("ISDELETE", "0"); //是否删除(0:有效 1删除)
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业ID
2024-03-26 18:01:53 +08:00
pd.put("TRANSPORTATIONCOMPANY", Jurisdiction.getCORPINFO_ID()); // 运输企业
2024-04-03 17:56:58 +08:00
pd.put("ARCHIVES_TYPE", "0"); //档案状态
pd.put("VEHICLE", pd.get("PLATE_NUMBER")); //档案状态
2024-03-26 18:01:53 +08:00
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);
}
2024-03-15 11:21:18 +08:00
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
2024-04-17 13:01:53 +08:00
pd.put("DELETEORNAME", Jurisdiction.getName()); //删除人
2024-03-15 11:21:18 +08:00
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
2024-04-17 13:01:53 +08:00
pd.put("OPERATORNAME", Jurisdiction.getName()); //修改人
2024-03-15 11:21:18 +08:00
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);
2024-03-27 10:04:49 +08:00
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);
}
2024-03-15 11:21:18 +08:00
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
2024-04-17 13:01:53 +08:00
pd.put("OPERATORNAME", Jurisdiction.getName()); //修改人
2024-03-15 11:21:18 +08:00
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列表
2024-04-03 17:56:58 +08:00
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");
}
}
2024-03-15 11:21:18 +08:00
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;
}
2024-03-28 18:32:23 +08:00
@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;
}
2024-03-15 11:21:18 +08:00
}