package com.zcloud.controller.firemanager; import com.alibaba.fastjson.JSON; import com.google.zxing.BarcodeFormat; import com.google.zxing.client.j2se.MatrixToImageWriter; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; import com.zcloud.aspect.DockAnnotation; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; import com.zcloud.entity.system.Department; import com.zcloud.service.bus.ImgFilesService; import com.zcloud.service.firemanager.FirePointService; import com.zcloud.service.system.DepartmentService; import com.zcloud.service.system.UsersService; import com.zcloud.util.*; import com.zcloud.util.logAop.LogOperation; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.session.Session; 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 org.springframework.web.servlet.ModelAndView; import java.io.File; import java.util.*; /** * 说明:消防点位管理 * 作者:wangxuan * 官网:www.zcloudchina.com */ @Controller @RequestMapping("/firePoint") public class FirePointController extends BaseController { @Autowired private FirePointService firePointService; @Autowired private InitPageDataUtil initPageDataUtil; @Autowired private ImgFilesService imgFilesService; @Autowired private DepartmentService departmentService; @Autowired private UsersService usersService; /** * 定位 * * @param * @throws Exception */ @RequestMapping(value = "/getFirePointCheckPhotos") @ResponseBody public Object getFirePointCheckPhotos() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = this.getPageData(); List checkImages = firePointService.getFirePointCheckPhotos(pd); if (checkImages != null && checkImages.size() > 0) { checkImages.forEach(item -> { String[] checkImagesItems = item.getString("FILEPATHLIST").split("@@"); item.put("FILEPATH_LIST", checkImagesItems); }); } map.put("imgList", checkImages); map.put("result", errInfo); return map; } /** * @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 map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); //获取当前人的公司id pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); page.setPd(pd); //消防区域名称与编码是否要加索引? List varList = firePointService.list(page); map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } /** * 定位 * * @param * @throws Exception */ @RequestMapping(value = "/savePosition") @ResponseBody public Object savePosition() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); firePointService.savePosition(pd); map.put("result", errInfo); return map; } /** * @Description: 消防点位单个信息 * @Author: dearLin * @Date: 2023/2/9/ * @Return: java.lang.Object */ @RequestMapping("/getFirPointInfo") @ResponseBody public Object info() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = getPageData(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); PageData resdata = firePointService.findById(pd); PageData imgPage = new PageData(); imgPage.put("FOREIGN_KEY",pd.getString("FIRE_POINT_ID")); List dataList = imgFilesService.listAll(imgPage); map.put("res", resdata); map.put("imgList", dataList); map.put("result", errInfo); return map; } /** * @Description: 修改消防点位信息 * @Author: dearLin * @Date: 2023/2/9/ * @Return: java.lang.Object */ @LogOperation(value = "修改消防风险点位成功", exceptionInformation = "修改消防风险点位失败", isUpdate = true, updateId = "FIRE_POINT_ID") @RequestMapping("/updFireRegionById") @ResponseBody @DockAnnotation public Object updFirePointById(@RequestParam(value = "files",required = false) MultipartFile[] files) { Map map = new HashMap(); String errInfo = "success"; PageData pd = getPageData(); pd.put("OPERATOR", Jurisdiction.getUsername()); pd.put("OPERATTIME", DateUtil.date2Str(new Date())); firePointService.updFirePointById(files,pd); map.put("result", errInfo); map.put("dockData",JSON.toJSONString(pd)); return map; } /** * @Description: 删除消防点位 * @Author: dearLin * @Date: 2023/2/9/ * @Return: java.lang.Object */ @LogOperation(value = "删除消防风险点位成功", exceptionInformation = "删除消防风险点位失败", isDelete = true) @RequestMapping("/delFirePointByIds") @ResponseBody public Object delFireRegionByIds() { Map map = new HashMap(); String errInfo = "success"; PageData pd = getPageData(); pd.put("OPERATOR", Jurisdiction.getUsername()); pd.put("OPERATTIME", DateUtil.date2Str(new Date())); if (firePointService.delFirePointByIds(pd)) { map.put("result", errInfo); } else { map.put("result", "error"); map.put("msg", "有设备在使用此点位禁止删除"); } return map; } @RequestMapping("/removeFirePointByIds") @ResponseBody @DockAnnotation public Object removeFirePointByIds() { Map map = new HashMap(); String errInfo = "success"; PageData pd = getPageData(); pd.put("OPERATOR", Jurisdiction.getUsername()); pd.put("OPERATTIME", DateUtil.date2Str(new Date())); firePointService.removeFirePointByIds(pd); map.put("result", errInfo); map.put("dockData",JSON.toJSONString(pd)); return map; } /** * @Description: 保存点位信息 * @Author: dearLin * @Date: 2023/2/9/ * @Return: java.lang.Object */ @LogOperation(value = "新增消防风险点位成功", exceptionInformation = "新增消防风险点位失败") @RequestMapping(value = "/savePointInfo") @ResponseBody @DockAnnotation(isAdd = true) public Object saveInfo(@RequestParam(value = "files",required = false) MultipartFile[] files) { Map map = new HashMap(); String errInfo = "success"; PageData pd = getPageData(); String uuid = this.get32UUID(); pd.put("FIRE_POINT_ID", uuid); PageData initData = initPageDataUtil.initSave(pd); pd.put("initData", JSON.toJSONString(initData)); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); firePointService.savePointInfo(pd); imgFilesService.uploadPicture(files,"118",pd.getString("FIRE_POINT_ID")); map.put("result", errInfo); map.put("dockData", JSON.toJSONString(pd)); return map; } //-----------负责部门与负责人接口---------------// /** * @Description: 获取当前公司下的所有部门 * @Author: dearLin * @Date: 2023/2/10/010 10:43 * @Param: [] [] * @Return: java.lang.Object */ @RequestMapping(value = "/getDepartmentId") @ResponseBody public Object getDepartmentId() throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd; pd = this.getPageData(); String url = pd.get("url") == null ? "department_list.html?DEPARTMENT_ID=" : pd.getString("url"); List zdepartmentPdList = new ArrayList(); PageData dept = new PageData(); dept.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); dept = this.departmentService.findByCorpId(dept); Department depar = new Department(); depar.setDEPARTMENT_ID(dept.getString("DEPARTMENT_ID")); depar.setPARENT_ID(dept.getString("PARENT_ID")); depar.setBIANMA(dept.getString("LEVEL")); depar.setNAME(dept.getString("NAME")); depar.setTreeurl(url + depar.getDEPARTMENT_ID()); depar.setSubDepartment(departmentService.listAllDepartment(depar.getDEPARTMENT_ID(), url)); depar.setTarget("treeFrame"); depar.setIcon("../../../assets/images/user.gif"); zdepartmentPdList.add(depar); JSONArray arr = JSONArray.fromObject(zdepartmentPdList); String json = arr.toString(); json = json.replaceAll("DEPARTMENT_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("NAME", "name").replaceAll("subDepartment", "nodes").replaceAll("hasDepartment", "checked").replaceAll("treeurl", "url").replaceAll("BIANMA", "LEVEL"); map.put("USER_ID", Jurisdiction.getUSER_ID()); map.put("zTreeNodes", json); map.put("result", errInfo); return map; } /** * 导出到excel * 1.查询什么 导出什么 * 2.增加 整改资金 字段 * 3.导出慢 * 4.没有图标 * 5.增加进度条 * * @param * @throws Exception */ @RequestMapping(value = "/excel2") // // @RequiresPermissions("toExcel") public ModelAndView exportExcel2() throws Exception { ModelAndView mv = new ModelAndView(); PageData pdx = this.getPageData(); PageData pd = new PageData(); Set> set = pdx.entrySet(); for (Map.Entry stringObjectEntry : set) { if (!Tools.isEmpty(pdx.getString(stringObjectEntry.getKey()))) { pd.put(stringObjectEntry.getKey(), pdx.getString(stringObjectEntry.getKey())); } } Integer imgCountToSession = 0; Session session = Jurisdiction.getSession(); session.setAttribute(pd.getString("sessionID"), "0"); Map dataMap = new HashMap<>(); List wertitles = this.setTitles(); List varList = new ArrayList<>(); pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); List dataList = firePointService.listForExcel(pd); for (int i = 0; i < dataList.size(); i++) { PageData firePoint = dataList.get(i); PageData vpd = new PageData(); vpd.put("var1", firePoint.getString("FIRE_REGION_NAME")); // 消防区域名称 vpd.put("var2", firePoint.getString("FIRE_POINT_NAME")); // 消防点位名称 vpd.put("var3", firePoint.getString("DEPARTMENT_NAME")); // 部门名称 vpd.put("var4", firePoint.getString("USERNAME")); // 人员名称 JSONObject jsonObject = new JSONObject(); jsonObject.put("FIRE_POINT_ID",firePoint.getString("FIRE_POINT_ID")); jsonObject.put("MANAGER_TYPE","fireListManager"); vpd.put("img5", jsonObject.toString()); // 二维码 varList.add(vpd); } dataMap.put("titles", wertitles); dataMap.put("varList", varList); dataMap.put("sessionID", pd.getString("sessionID")); dataMap.put("imgCountToSession", imgCountToSession); session.setAttribute(pd.getString("sessionID"), "10"); FirePointExcelImgToSessionView erv2 = new FirePointExcelImgToSessionView(); mv = new ModelAndView(erv2, dataMap); System.out.println("|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); return mv; } /** * 写入上方的列信息 * * @return */ public List setTitles() { List titles = new ArrayList(); titles.add("消防区域"); //1 titles.add("消防点位"); //2 titles.add("负责部门"); //3 titles.add("负责人"); //4 titles.add("二维码"); //5 return titles; } }