qa-prevention-gwj/src/main/java/com/zcloud/controller/app/AppPoliceController.java

214 lines
7.0 KiB
Java
Raw Normal View History

2023-11-07 09:32:12 +08:00
package com.zcloud.controller.app;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.service.system.PoliceService;
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;
/**
*
* yangming
* 2022-12-29
*/
@Controller
@RequestMapping("/app/police")
public class AppPoliceController extends BaseController {
@Autowired
private PoliceService policeService;
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/unLockUser")
@ResponseBody
public Object unLockUser () throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("FIRE_STATUS", "1");
pd.put("DISPOSAL_PERSON",pd.getString("DISPOSAL_PERSONs"));// 登录人
policeService.lockUser(pd);
map.put("result", errInfo);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/getUserPolice")
@ResponseBody
public Object getUserPolice() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd = policeService.findPolice(pd); //根据ID读取
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/add")
@ResponseBody
public Object add() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("ALARM_PERSON",pd.getString("ALARM_PERSONs"));// 报警人
pd.put("ALARM_UNIT",pd.getString("ALARM_UNITs"));// 报警部门 通过前台登录人id查询得出
pd.put("POLICE_ID", this.get32UUID()); //主键
pd.put("CREATOR", pd.getString("CREATORs")); //创建人
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
pd.put("RECEIVING_TIME", DateUtil.date2Str(new Date())); //接包时间
pd.put("RECEIVING_WAY", "0"); //报警方式 系统报警
pd.put("ISDELETE", "0"); //是否删除
pd.put("FIRE_STATUS", "0"); //火灾状态
policeService.save(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 = policeService.findByPoliceId(pd); //根据ID读取
map.put("pd", pd);
map.put("result", errInfo);
return map;
}
/**
* @param page
* @throws Exception
*/
@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 = policeService.list(page); //列出police列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**
* @param page
* @throws Exception
*/
@RequestMapping(value="/goRes")
@ResponseBody
public Object goRes(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 = policeService.findByResId(page); //列出police列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/edit")
@ResponseBody
public Object edit(@RequestParam(value="FILEURL",required=false) MultipartFile planFile,
@RequestParam(value="FIRE_IMG",required=false) MultipartFile file
) throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
if (null != planFile && !planFile.isEmpty()) {
String suffixName = planFile.getOriginalFilename().substring(planFile.getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
if (!"mp4".equals(suffixName)) {
map.put("result", errInfo);
map.put("msg", "上传文件格式不正确");
return map;
}
String ffile = DateUtil.getDays();
Long size = file.getSize()/1024;
String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
Smb.sshSftp(file, fileName,Const.FILEPATHFXSST + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
pd.put("FILESIZE",size);
pd.put("FILEURL", Const.FILEPATHFXSST + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
}
if (null != file && !file.isEmpty()) {
String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase(); //获取后缀 .png .jpd .mp4 .exe .text .
if ( !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
errInfo = "fail";
map.put("result", errInfo);
map.put("msg", "文件格式不正确!");
return map;
}
String ffile = DateUtil.getDays();
Long size = file.getSize()/1024;
String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
Smb.sshSftp(file, fileName,Const.FILEPATHFXSST + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
pd.put("FILESIZE",size);
pd.put("FIRE_IMG", Const.FILEPATHFXSST + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
}
policeService.edit(pd);
map.put("result", errInfo);
return map;
}
/**
* @param
* @throws Exception
*/
@RequestMapping(value="/editOpinion")
@ResponseBody
public Object editOpinion() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("REPORTING_ID", this.get32UUID()); //主键
pd.put("CREATOR", Jurisdiction.getUsername()); //添加人
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
policeService.editOpinion(pd);
map.put("result", errInfo);
return map;
}
}