forked from integrated_whb/integrated_whb
181 lines
8.1 KiB
Java
181 lines
8.1 KiB
Java
package com.zcloud.controller.comprehensive;
|
|
|
|
import com.zcloud.controller.base.BaseController;
|
|
import com.zcloud.entity.Page;
|
|
import com.zcloud.entity.PageData;
|
|
import com.zcloud.service.comprehensive.TrafficSecurityAccidentInvestigationService;
|
|
import com.zcloud.service.comprehensive.TrafficSecurityViolationRegistrationService;
|
|
import com.zcloud.util.*;
|
|
import org.apache.commons.lang.StringUtils;
|
|
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("/accidentinvestigation")
|
|
public class TrafficSecurityAccidentInvestigationController extends BaseController {
|
|
@Autowired
|
|
private TrafficSecurityAccidentInvestigationService accidentInvestigationService;
|
|
@Autowired
|
|
private Smb smb;
|
|
|
|
@RequestMapping(value = "/add")
|
|
@ResponseBody
|
|
public Object add(@RequestParam(value="FFILEONE",required=false) MultipartFile fileOne,
|
|
@RequestParam(value="FFILETWO",required=false) MultipartFile fileTwo) throws Exception {
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
String errInfo = "success";
|
|
PageData pd = this.getPageData();
|
|
|
|
String accidentinvestigation_id = this.get32UUID();
|
|
pd.put("CREATOR", Jurisdiction.getUSER_ID()); // 创建人id
|
|
pd.put("CREATORNAME", Jurisdiction.getName()); // 创建人姓名
|
|
pd.put("ACCIDENTINVESTIGATION_ID", accidentinvestigation_id); // 主键
|
|
pd.put("INCIDENTNUMBER", this.get32UUID()); // 事故编号
|
|
pd.put("CERTIFICATIONNUMBER", this.get32UUID()); // 认定书编号
|
|
pd.put("CREATETIME", DateUtil.date2Str(new Date())); // 添加时间
|
|
pd.put("DEPARTMENT", Jurisdiction.getCORPINFO_ID()); // 部门
|
|
pd.put("ISDELETE", "0");
|
|
|
|
String ffile = DateUtil.getDays();
|
|
if (fileOne != null && StringUtils.isNotBlank(pd.getString("CREATORNAME"))){
|
|
String suffixName = fileOne.getOriginalFilename().substring(fileOne.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() + fileOne.getOriginalFilename().substring(fileOne.getOriginalFilename().lastIndexOf("."));
|
|
smb.sshSftp(fileOne, fileName, Const.FILEPATHFILE + pd.getString("TRANSPORTATIONCOMPANY") + "/" + ffile);
|
|
pd.put("ACCIDENTREPORTRECORD", Const.FILEPATHFILE + pd.getString("TRANSPORTATIONCOMPANY") + "/" + ffile + "/" + fileName);
|
|
pd.put("ATTACHMENT_NAME",pd.getString("CREATORNAME"));
|
|
pd.put("CONFIRM_MESSAGE_TIME",DateUtil.date2Str(new Date()));
|
|
}
|
|
if (fileTwo != null && StringUtils.isNotBlank(pd.getString("CREATORNAME"))){
|
|
String suffixName = fileTwo.getOriginalFilename().substring(fileTwo.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() + fileTwo.getOriginalFilename().substring(fileTwo.getOriginalFilename().lastIndexOf("."));
|
|
smb.sshSftp(fileTwo, fileName, Const.FILEPATHFILE + pd.getString("TRANSPORTATIONCOMPANY") + "/" + ffile);
|
|
pd.put("ACCIDENTANALYSISRECORD", Const.FILEPATHFILE + pd.getString("TRANSPORTATIONCOMPANY") + "/" + ffile + "/" + fileName);
|
|
pd.put("ATTACHMENT_NAME",pd.getString("CREATORNAME"));
|
|
pd.put("CONFIRM_MESSAGE_TIME",DateUtil.date2Str(new Date()));
|
|
}
|
|
|
|
accidentInvestigationService.save(pd);
|
|
map.put("result", errInfo);
|
|
map.put("pd", pd);
|
|
return map;
|
|
}
|
|
|
|
//列表
|
|
@RequestMapping(value = "/listForAccidentInvestigation")
|
|
@ResponseBody
|
|
public Object listForAccidentInvestigation(Page page) throws Exception {
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
String errInfo = "success";
|
|
PageData pd = new PageData();
|
|
pd = this.getPageData();
|
|
|
|
String USER_ID = pd.getString("USER_ID");
|
|
if (Tools.notEmpty(USER_ID))
|
|
pd.put("USER_ID", USER_ID.trim());
|
|
|
|
String ACCIDENTDATE = pd.getString("ACCIDENTDATE"); // 运输车辆
|
|
if (Tools.notEmpty(ACCIDENTDATE))
|
|
pd.put("ACCIDENTDATE", ACCIDENTDATE.trim());
|
|
|
|
page.setPd(pd);
|
|
List<PageData> varList = accidentInvestigationService.listForAccidentInvestigation(page);
|
|
map.put("varList", varList);
|
|
map.put("page", page);
|
|
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();
|
|
pd.put("DELETOR", Jurisdiction.getUSER_ID());//删除人id
|
|
pd.put("DELETORNAME", Jurisdiction.getUsername());//删除人姓名
|
|
pd.put("DELETETIME", DateUtil.date2Str(new Date()));//删除时间
|
|
accidentInvestigationService.delete(pd);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
/**
|
|
* 查看详情
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value="/goEdit")
|
|
@ResponseBody
|
|
public Object goEdit() throws Exception {
|
|
Map<String, Object> map = new HashMap<>();
|
|
String errInfo = "success";
|
|
PageData pd = this.getPageData();
|
|
pd = accidentInvestigationService.findById(pd); // 根据ID读取
|
|
map.put("pd", pd);
|
|
map.put("result", errInfo);
|
|
return map;
|
|
}
|
|
|
|
//修改
|
|
@RequestMapping(value = "/edit")
|
|
@ResponseBody
|
|
public Object edit(@RequestParam(value="FFILE",required=false) MultipartFile file) throws Exception {
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
String errInfo = "success";
|
|
PageData pd = this.getPageData();
|
|
|
|
pd.put("OPERATOR", Jurisdiction.getUSER_ID()); // 修改人id
|
|
pd.put("OPERATORNAME", Jurisdiction.getName()); // 修改人姓名
|
|
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); // 修改时间
|
|
|
|
String ffile = DateUtil.getDays();
|
|
if (file != null && StringUtils.isNotBlank(pd.getString("OPERATORNAME"))){
|
|
pd.put("COMPLETIONSTATUS", "1");
|
|
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("OPERATINGCOMPANY") + "/" + ffile);
|
|
pd.put("ATTACHMENT_ROUTE", Const.FILEPATHFILE + pd.getString("OPERATINGCOMPANY") + "/" + ffile + "/" + fileName);
|
|
pd.put("ATTACHMENT_NAME",pd.getString("CREATORNAME"));
|
|
pd.put("CONFIRM_MESSAGE_TIME",DateUtil.date2Str(new Date()));
|
|
}
|
|
|
|
accidentInvestigationService.edit(pd);
|
|
|
|
map.put("result", errInfo);
|
|
map.put("pd", pd);
|
|
return map;
|
|
}
|
|
}
|