321 lines
12 KiB
Java
321 lines
12 KiB
Java
package com.zcloud.controller.firemanager;
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.zcloud.aspect.DockAnnotation;
|
||
import com.zcloud.controller.base.BaseController;
|
||
import com.zcloud.entity.Page;
|
||
import com.zcloud.entity.PageData;
|
||
import com.zcloud.service.firemanager.FireCheckListService;
|
||
import com.zcloud.service.firemanager.FireCheckStandardService;
|
||
import com.zcloud.util.*;
|
||
import com.zcloud.util.logAop.LogOperation;
|
||
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 javax.annotation.Resource;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
import java.io.File;
|
||
import java.util.*;
|
||
|
||
/**
|
||
* @ClassName FireCheckStandardController
|
||
* @Description 检查标准
|
||
* @Author Dear lin
|
||
* @Version 1.0
|
||
**/
|
||
@Controller
|
||
@RequestMapping("/fireCheckStandard")
|
||
public class FireCheckStandardController extends BaseController {
|
||
|
||
@Autowired
|
||
private FireCheckStandardService fireCheckStandardService;
|
||
@Resource
|
||
private FireCheckListService fireCheckListService;
|
||
|
||
|
||
|
||
/**
|
||
* @Description: 检查标准列表
|
||
* @Author: dearLin
|
||
* @Date: 2023/2/9
|
||
* @Param: [com.zcloud.entity.Page] [page]
|
||
* @Return: java.lang.Object
|
||
*/
|
||
@RequestMapping(value = "/list")
|
||
@ResponseBody
|
||
public Object page(Page page) {
|
||
//查询条件
|
||
// 区域名称(关键字查询)、编码(关键字查询)
|
||
//Object keywords = pageData.get("KEYWORDS");
|
||
//企业ID
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
//获取当前人的公司id
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
page.setPd(pd);
|
||
List<PageData> varList = fireCheckStandardService.list(page);
|
||
List<PageData> waitList = fireCheckListService.getCheckList(pd);
|
||
map.put("varList", varList);
|
||
map.put("waitList", waitList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* @Description: 检查标准查询
|
||
* @Author: dearLin
|
||
* @Date: 2023/3/8/008 14:01
|
||
* @Param: [com.zcloud.entity.Page] [page]
|
||
* @Return: java.lang.Object
|
||
*/
|
||
@RequestMapping(value = "/getList")
|
||
@ResponseBody
|
||
public Object getList(Page page) {
|
||
//查询条件
|
||
// 区域名称(关键字查询)、编码(关键字查询)
|
||
//Object keywords = pageData.get("KEYWORDS");
|
||
//企业ID
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
//获取当前人的公司id
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
page.setPd(pd);
|
||
List<PageData> varList = fireCheckStandardService.getList(page);
|
||
map.put("varList", varList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* @Description: TODO
|
||
* @Author: dearLin
|
||
* @Date: 2023/9/13/013 16:24
|
||
* @Param: FIRE_DEVICE_TYPE
|
||
* @Return: java.lang.Object
|
||
*/
|
||
@RequestMapping(value = "/getStandardListByDeviceType")
|
||
@ResponseBody
|
||
public Object getStandardListByDeviceType (){
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = this.getPageData();
|
||
List<PageData> varList = fireCheckStandardService.getStandardListByDeviceType(pd);
|
||
map.put("varList", varList);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* @Description: 获取设备的检查项 根据设备类型
|
||
* @Author: dearLin
|
||
* @Date: 2023/2/23/023 8:59
|
||
*/
|
||
@RequestMapping(value = "/getStandardListByDeviceId")
|
||
@ResponseBody
|
||
public Object getStandardByDeviceId(Page page) {
|
||
//查询条件
|
||
// 区域名称(关键字查询)、编码(关键字查询)
|
||
//Object keywords = pageData.get("KEYWORDS");
|
||
//企业ID
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = new PageData();
|
||
pd = this.getPageData();
|
||
//获取当前人的公司id
|
||
page.setPd(pd);
|
||
List<PageData> varList = fireCheckStandardService.getStandardByDeviceId(page);
|
||
map.put("varList", varList);
|
||
map.put("page", page);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
/**
|
||
* @Description: 单个信息
|
||
* @Author: dearLin
|
||
* @Date: 2023/2/9/
|
||
* @Return: java.lang.Object
|
||
*/
|
||
@RequestMapping("/getInfo")
|
||
@ResponseBody
|
||
public Object info() {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = getPageData();
|
||
pd.put("CORPINFO_ID",Jurisdiction.getCORPINFO_ID());
|
||
PageData resdata = fireCheckStandardService.findById(pd);
|
||
map.put("res", resdata);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* @Description: 修改
|
||
* @Author: Dear lin
|
||
* @Date: 2023/2/10 13:12
|
||
* @Param: []
|
||
* @Return: java.lang.Object
|
||
*/
|
||
@LogOperation(value = "修改消防器材检查标准成功", exceptionInformation = "修改消防器材检查标准失败", isUpdate = true, updateId = "FIRE_PREPARED_ID" )
|
||
@RequestMapping("/edit")
|
||
@ResponseBody
|
||
public Object updById() {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = getPageData();
|
||
pd.put("OPERATOR", Jurisdiction.getUSER_ID());
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
||
fireCheckStandardService.updCheckStandardById(pd);
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* @Description: 保存
|
||
* @Author: dearLin
|
||
* @Date: 2023/3/8/008 17:22
|
||
* @Param: [] []
|
||
* @Return: java.lang.Object
|
||
*/
|
||
@LogOperation(value = "新增消防器材检查标准成功", exceptionInformation = "新增改消防器材检查标准失败")
|
||
@RequestMapping(value = "/add")
|
||
@ResponseBody
|
||
@DockAnnotation(isAdd = true)
|
||
public Object saveInfo() {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = getPageData();
|
||
pd.put("FIRE_CHECK_STANDARD_ID", this.get32UUID());
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
pd.put("CREATOR", Jurisdiction.getUSER_ID());
|
||
pd.put("OPERATOR", Jurisdiction.getUSER_ID());
|
||
pd.put("CREATTIME", DateUtil.date2Str(new Date()));
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
||
fireCheckStandardService.saveInfo(pd);
|
||
map.put("result", errInfo);
|
||
map.put("dockData", JSON.toJSONString(pd));
|
||
return map;
|
||
}
|
||
/**
|
||
* @Description: 删除
|
||
* @Author: Dear lin
|
||
* @Date: 2023/2/12 18:17
|
||
* @Param: []
|
||
* @Return: java.lang.Object
|
||
*/
|
||
@LogOperation(value = "删除消防器材检查标准成功", exceptionInformation = "删除改消防器材检查标准失败",isDelete = true)
|
||
@RequestMapping("/delByIds")
|
||
@ResponseBody
|
||
@DockAnnotation
|
||
public Object delByIds() {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pd = getPageData();
|
||
pd.put("OPERATOR", Jurisdiction.getUsername());
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
||
if (fireCheckStandardService.delCheckStandardByIds(pd)) {
|
||
map.put("result", errInfo);
|
||
}else {
|
||
map.put("result", "error");
|
||
map.put("msg", "检查表中有使用此检查项的数据禁止删除");
|
||
}
|
||
return map;
|
||
}
|
||
/**
|
||
* @Description: 导出点检模板
|
||
* @Author: dearLin
|
||
* @Date: 2023/3/8/008 14:01
|
||
* @Param: [javax.servlet.http.HttpServletResponse] [response]
|
||
* @Return: void
|
||
*/
|
||
@RequestMapping(value="/excelModel")
|
||
public void exportExcelModel(HttpServletResponse response) throws Exception{
|
||
FileDownload.fileDownload(response, PathUtil.getProjectpath() + Const.FILEPATHFILE + "checkStandardTemplates.xls", "checkStandardTemplates.xls");
|
||
}
|
||
|
||
/**
|
||
* @Description: 导入
|
||
* @Author: dearLin
|
||
* @Date: 2023/3/8/008 14:02
|
||
* @Param: [org.springframework.web.multipart.MultipartFile] [file]
|
||
* @Return: java.lang.Object
|
||
*/
|
||
@LogOperation(value = "导入消防器材检查标准成功", exceptionInformation = "导入消防器材检查标准失败")
|
||
@RequestMapping(value="/importExcelTemplate")
|
||
@ResponseBody
|
||
public Object importExcelTemplate(@RequestParam(name = "FFILE" ,required = false) MultipartFile file) throws Exception{
|
||
//
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
String errInfo = "success";
|
||
PageData pageData = getPageData();
|
||
String FIRE_DEVICE_TYPE = (String) pageData.get("FIRE_DEVICE_TYPE");
|
||
// 获取此类型的 对应的名字
|
||
/*
|
||
* var 0 检查标准 表格
|
||
* var 1 消防器材名称
|
||
* var 2 单位名称
|
||
* */
|
||
PageData typeName = fireCheckStandardService.getTypeName(pageData);
|
||
String name = (String) typeName.get("NAME");
|
||
if (null != file && !file.isEmpty()) {
|
||
String suffixName = Objects.requireNonNull(file.getOriginalFilename()).substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
|
||
if (!"xls".equals(suffixName)) {
|
||
errInfo = "fail";
|
||
map.put("result", errInfo);
|
||
map.put("msg", "文件格式不正确!");
|
||
return map;
|
||
}
|
||
File path = new File("./src/main/resources/upload");
|
||
if (!path.exists()) {
|
||
path = new File("");
|
||
}
|
||
File upload = new File(path.getAbsolutePath());
|
||
if (!upload.exists()) {
|
||
upload.mkdirs();
|
||
}
|
||
long time = System.currentTimeMillis();
|
||
File dest = null;
|
||
String fileName = time + "." + "xls";
|
||
dest = new File(upload.getAbsolutePath() + "/" + fileName);
|
||
file.transferTo(dest);
|
||
String corpinfo_id = Jurisdiction.getCORPINFO_ID();
|
||
//String ffile = "checkstandard/"+ DateUtil.getDays()+"/";
|
||
//String filePath = Const.FILEURL + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile;
|
||
//String fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
||
//Smb.sshSftp(file, fileName,Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
||
//List<PageData> listPd = (List) ObjectExcelRead.readExcel(filePath, fileName, 1, 0, 0);
|
||
// 执行读EXCEL操作,读出的数据导入List 2:从第3行开始;0:从第A列开始;0:第0个sheet
|
||
List<PageData> listPd = (List) ObjectExcelRead.readExcel2(dest, 2, 0, 0);
|
||
//执行读EXCEL操作,读出的数据导入List 2:从第2行开始;0:从第A列开始;0:第0个sheet
|
||
listPd.forEach(pd->{
|
||
/*
|
||
* var 0 消防器材名称
|
||
* var 1 单位名称
|
||
* var 2 检查标准
|
||
* */
|
||
pd.put("CORPINFO_ID",corpinfo_id);
|
||
pd.put("FIRE_DEVICE_TYPE",FIRE_DEVICE_TYPE);
|
||
pd.put("FIRE_CHECK_STANDARD_ID",this.get32UUID());
|
||
pd.put("CREATOR", Jurisdiction.getUSER_ID()); //添加人
|
||
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
|
||
pd.put("OPERATOR", Jurisdiction.getUSER_ID()); //修改人
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||
});
|
||
fireCheckStandardService.saveImportCheckStandard(listPd);
|
||
}
|
||
map.put("result", errInfo);
|
||
return map;
|
||
}
|
||
}
|