forked from integrated_whb/integrated_whb
164 lines
6.7 KiB
Java
164 lines
6.7 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.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("/violationregistration")
|
|
public class TrafficSecurityViolationRegistrationController extends BaseController {
|
|
@Autowired
|
|
private TrafficSecurityViolationRegistrationService violationRegistrationService;
|
|
@Autowired
|
|
private Smb smb;
|
|
|
|
@RequestMapping(value = "/add")
|
|
@ResponseBody
|
|
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 = this.getPageData();
|
|
|
|
String registration_id = this.get32UUID();
|
|
|
|
pd.put("CREATOR", Jurisdiction.getUSER_ID()); // 创建人id
|
|
pd.put("CREATORNAME", Jurisdiction.getName()); // 创建人姓名
|
|
pd.put("REGISTRATION_ID", registration_id); // 主键
|
|
pd.put("CREATETIME", DateUtil.date2Str(new Date())); // 添加时间
|
|
pd.put("TRANSPORTATIONCOMPANY", Jurisdiction.getCORPINFO_ID()); // 运输企业
|
|
pd.put("ISDELETE", "0");
|
|
|
|
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("ATTACHMENT_ROUTE", Const.FILEPATHFILE + pd.getString("TRANSPORTATIONCOMPANY") + "/" + ffile + "/" + fileName);
|
|
pd.put("ATTACHMENT_NAME",pd.getString("CREATORNAME"));
|
|
pd.put("CONFIRM_MESSAGE_TIME",DateUtil.date2Str(new Date()));
|
|
}
|
|
|
|
violationRegistrationService.save(pd);
|
|
map.put("result", errInfo);
|
|
map.put("pd", pd);
|
|
return map;
|
|
}
|
|
|
|
//列表
|
|
@RequestMapping(value = "/listForViolationRegistration")
|
|
@ResponseBody
|
|
public Object listForViolationRegistration(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 PENALTYTIME = pd.getString("PENALTYTIME"); // 运输车辆
|
|
if (Tools.notEmpty(PENALTYTIME))
|
|
pd.put("PENALTYTIME", PENALTYTIME.trim());
|
|
|
|
page.setPd(pd);
|
|
List<PageData> varList = violationRegistrationService.listForViolationRegistration(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()));//删除时间
|
|
violationRegistrationService.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 = violationRegistrationService.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()));
|
|
}
|
|
|
|
violationRegistrationService.edit(pd);
|
|
|
|
map.put("result", errInfo);
|
|
map.put("pd", pd);
|
|
return map;
|
|
}
|
|
}
|