forked from integrated_whb/integrated_whb
192 lines
9.6 KiB
Java
192 lines
9.6 KiB
Java
|
package com.zcloud.controller.operatingvehicles;
|
|||
|
|
|||
|
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.operatingvehicles.OperatingVehiclesService;
|
|||
|
import com.zcloud.util.*;
|
|||
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
import org.springframework.stereotype.Controller;
|
|||
|
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("/operatingvehicles")
|
|||
|
public class OperatingVehiclesController extends BaseController {
|
|||
|
|
|||
|
@Autowired
|
|||
|
private OperatingVehiclesService operatingVehiclesService;
|
|||
|
|
|||
|
@Autowired
|
|||
|
private Smb smb;
|
|||
|
|
|||
|
/**新增
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/add")
|
|||
|
@ResponseBody
|
|||
|
public Object add(
|
|||
|
@RequestParam(value="headstockFile",required=false) MultipartFile headstockFile,
|
|||
|
@RequestParam(value="drivinglicenseFile",required=false) MultipartFile drivinglicenseFile,
|
|||
|
@RequestParam(value="operatingCertificateFile",required=false) MultipartFile operatingCertificateFile
|
|||
|
) throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
pd.put("OPERATING_ID", this.get32UUID()); //运营车辆主键
|
|||
|
pd.put("ISDELETE", "0"); //是否删除(0:有效 1:删除)
|
|||
|
pd.put("CREATOR", Jurisdiction.getUSER_ID()); //添加人id
|
|||
|
pd.put("CREATORNAME", Jurisdiction.getUsername()); //添加人名字
|
|||
|
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
|
|||
|
pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //修改人id
|
|||
|
pd.put("OPERATORNAME", Jurisdiction.getUsername()); // 修改人名字
|
|||
|
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); // 修改时间
|
|||
|
if (null != headstockFile && !headstockFile.isEmpty()) {
|
|||
|
String ffile = DateUtil.getDays();
|
|||
|
//本地
|
|||
|
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile; //文件上传路径
|
|||
|
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
|||
|
//服务器
|
|||
|
String fileName = this.get32UUID()+headstockFile.getOriginalFilename().substring(headstockFile.getOriginalFilename().lastIndexOf("."));
|
|||
|
smb.sshSftp(headstockFile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
|||
|
pd.put("HEADSTOCK_PHOTO", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
|
|||
|
}
|
|||
|
if (null != drivinglicenseFile && !drivinglicenseFile.isEmpty()) {
|
|||
|
String ffile = DateUtil.getDays();
|
|||
|
//本地
|
|||
|
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile; //文件上传路径
|
|||
|
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
|||
|
//服务器
|
|||
|
String fileName = this.get32UUID()+drivinglicenseFile.getOriginalFilename().substring(drivinglicenseFile.getOriginalFilename().lastIndexOf("."));
|
|||
|
smb.sshSftp(drivinglicenseFile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
|||
|
pd.put("DRIVINGLICENSE_PHOTO", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
|
|||
|
}
|
|||
|
if (null != operatingCertificateFile && !operatingCertificateFile.isEmpty()) {
|
|||
|
String ffile = DateUtil.getDays();
|
|||
|
//本地
|
|||
|
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile; //文件上传路径
|
|||
|
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
|||
|
//服务器
|
|||
|
String fileName = this.get32UUID()+operatingCertificateFile.getOriginalFilename().substring(operatingCertificateFile.getOriginalFilename().lastIndexOf("."));
|
|||
|
smb.sshSftp(operatingCertificateFile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
|||
|
pd.put("OPERATING_CERTIFICATE_PHOTO", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
|
|||
|
}
|
|||
|
operatingVehiclesService.save(pd);
|
|||
|
map.put("pd", pd);
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
/**删除
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/delete")
|
|||
|
@ResponseBody
|
|||
|
public Object delete() throws Exception{
|
|||
|
Map<String,String> map = new HashMap<String,String>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
map.put("result", errInfo); //返回结果
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
/**修改
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/edit")
|
|||
|
@ResponseBody
|
|||
|
public Object edit(
|
|||
|
@RequestParam(value="headstockFile",required=false) MultipartFile headstockFile,
|
|||
|
@RequestParam(value="drivinglicenseFile",required=false) MultipartFile drivinglicenseFile,
|
|||
|
@RequestParam(value="operatingCertificateFile",required=false) MultipartFile operatingCertificateFile
|
|||
|
) throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
pd.put("OPERATOR", Jurisdiction.getCORPINFO_ID());
|
|||
|
pd.put("OPERATORNAME", Jurisdiction.getUsername());
|
|||
|
pd.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
|||
|
if (null != headstockFile && !headstockFile.isEmpty()) {
|
|||
|
String ffile = DateUtil.getDays();
|
|||
|
//本地
|
|||
|
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile; //文件上传路径
|
|||
|
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
|||
|
//服务器
|
|||
|
String fileName = this.get32UUID()+headstockFile.getOriginalFilename().substring(headstockFile.getOriginalFilename().lastIndexOf("."));
|
|||
|
smb.sshSftp(headstockFile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
|||
|
pd.put("HEADSTOCK_PHOTO", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
|
|||
|
}
|
|||
|
if (null != drivinglicenseFile && !drivinglicenseFile.isEmpty ()) {
|
|||
|
String ffile = DateUtil.getDays();
|
|||
|
//本地
|
|||
|
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile; //文件上传路径
|
|||
|
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
|||
|
//服务器
|
|||
|
String fileName = this.get32UUID()+drivinglicenseFile.getOriginalFilename().substring(drivinglicenseFile.getOriginalFilename().lastIndexOf("."));
|
|||
|
smb.sshSftp(drivinglicenseFile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
|||
|
pd.put("DRIVINGLICENSE_PHOTO", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
|
|||
|
}
|
|||
|
if (null != operatingCertificateFile && !operatingCertificateFile.isEmpty()) {
|
|||
|
String ffile = DateUtil.getDays();
|
|||
|
//本地
|
|||
|
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile; //文件上传路径
|
|||
|
// String fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
|||
|
//服务器
|
|||
|
String fileName = this.get32UUID()+operatingCertificateFile.getOriginalFilename().substring(operatingCertificateFile.getOriginalFilename().lastIndexOf("."));
|
|||
|
smb.sshSftp(operatingCertificateFile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
|||
|
pd.put("OPERATING_CERTIFICATE_PHOTO", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
|
|||
|
}
|
|||
|
operatingVehiclesService.edit(pd);
|
|||
|
map.put("pd", pd);
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
}
|
|||
|
/**去修改页面获取数据
|
|||
|
* @param
|
|||
|
* @throws Exception
|
|||
|
*/
|
|||
|
@RequestMapping(value="/goEdit")
|
|||
|
@ResponseBody
|
|||
|
public Object goEdit() throws Exception{
|
|||
|
Map<String,Object> map = new HashMap<String,Object>();
|
|||
|
String errInfo = "success";
|
|||
|
PageData pd = new PageData();
|
|||
|
pd = this.getPageData();
|
|||
|
pd = operatingVehiclesService.findById(pd);
|
|||
|
map.put("pd", pd);
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
}
|
|||
|
|
|||
|
@RequestMapping(value="/list")
|
|||
|
@ResponseBody
|
|||
|
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();
|
|||
|
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
|
|||
|
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
|
|||
|
page.setPd(pd);
|
|||
|
List<PageData> varList = operatingVehiclesService.list(page); //列出MajorDangerSource列表
|
|||
|
map.put("varList", varList);
|
|||
|
map.put("page", page);
|
|||
|
map.put("result", errInfo);
|
|||
|
return map;
|
|||
|
}
|
|||
|
}
|