diff --git a/pom.xml b/pom.xml index f2b44715..69424592 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,16 @@ jaxen jaxen - + + com.google.zxing + core + 3.4.1 + + + com.google.zxing + javase + 3.4.1 + org.jdom diff --git a/src/main/java/com/zcloud/controller/app/AppUsersController.java b/src/main/java/com/zcloud/controller/app/AppUsersController.java index 97c26102..b4ee3bf7 100644 --- a/src/main/java/com/zcloud/controller/app/AppUsersController.java +++ b/src/main/java/com/zcloud/controller/app/AppUsersController.java @@ -7,6 +7,7 @@ import java.util.Map; import com.zcloud.service.system.*; import com.zcloud.util.*; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.DisabledAccountException; @@ -397,4 +398,23 @@ public class AppUsersController extends BaseController { map.put("result", errInfo); return map; } + + + //根据用户id查询部门 + @RequestMapping(value="/getDepartmentByUserId") + @ResponseBody + public Object getDepartmentByUserId()throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + PageData pd = new PageData(); + pd = this.getPageData(); + PageData data = usersService.findById(pd); + if (data == null || StringUtils.equals(data.getString("DEPARTMENT_ID"),"")) { + map.put("result", errInfo); + return map; + } + map.put("data", data); + map.put("result", errInfo); + return map; + } } diff --git a/src/main/java/com/zcloud/controller/firemanager/FirePointController.java b/src/main/java/com/zcloud/controller/firemanager/FirePointController.java index d6635edf..ab7aa19f 100644 --- a/src/main/java/com/zcloud/controller/firemanager/FirePointController.java +++ b/src/main/java/com/zcloud/controller/firemanager/FirePointController.java @@ -1,6 +1,10 @@ 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; @@ -10,19 +14,22 @@ 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.DateUtil; -import com.zcloud.util.InitPageDataUtil; -import com.zcloud.util.Jurisdiction; +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.*; /** @@ -273,27 +280,80 @@ public class FirePointController extends BaseController { } /** - * @Description: 获取当前部门下的所有员工 - * @Author: dearLin - * @Date: 2023/2/10/010 10:43 - * @Param: [] [] - * @Return: java.lang.Object + * 导出到excel + * 1.查询什么 导出什么 + * 2.增加 整改资金 字段 + * 3.导出慢 + * 4.没有图标 + * 5.增加进度条 + * + * @param + * @throws Exception */ - @RequestMapping(value = "/getDepartmentPeople") - @ResponseBody - public Object getDepartmentPeople(Page page) throws Exception { - Map map = new HashMap(); - String errInfo = "success"; + @RequestMapping(value = "/excel2") +// // @RequiresPermissions("toExcel") + public ModelAndView exportExcel2() throws Exception { + ModelAndView mv = new ModelAndView(); + PageData pdx = this.getPageData(); PageData pd = new PageData(); - pd = this.getPageData(); - List userList = usersService.getDepartmentId(pd.getString("DEPARTMENT_ID")); - //列出用户列表 - pd.put("ROLE_ID", "1"); - map.put("userList", userList); - map.put("page", page); - map.put("pd", pd); - map.put("result", errInfo); - return map; + 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; + } } diff --git a/src/main/java/com/zcloud/controller/firemanager/app/AppFireRecordController.java b/src/main/java/com/zcloud/controller/firemanager/app/AppFireRecordController.java index 1dcdb34a..08cfba56 100644 --- a/src/main/java/com/zcloud/controller/firemanager/app/AppFireRecordController.java +++ b/src/main/java/com/zcloud/controller/firemanager/app/AppFireRecordController.java @@ -613,4 +613,21 @@ public class AppFireRecordController extends BaseController { map.put("varList", varList); return map; } + + /** + * 检查人id获取检查人所涉及的查询点位列表 + * @Author: limingyu + * @Date: 2024/3/18/008 09:11 + * @throws Exception + */ + @RequestMapping("/getPointListByUserId") + public Object getPointListByUserId() throws Exception { + String errInfo = "success"; + Map map = new HashMap(); + PageData pageData = getPageData(); + List varList = fireCheckStandardService.getPointListByUserId(pageData); + map.put("result", errInfo); + map.put("varList", varList); + return map; + } } diff --git a/src/main/java/com/zcloud/mapper/datasource/firemanager/FireCheckStandardMapper.java b/src/main/java/com/zcloud/mapper/datasource/firemanager/FireCheckStandardMapper.java index b40ed73a..9cf4e2f0 100644 --- a/src/main/java/com/zcloud/mapper/datasource/firemanager/FireCheckStandardMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/firemanager/FireCheckStandardMapper.java @@ -42,4 +42,6 @@ public interface FireCheckStandardMapper { List getListAll(PageData pd) ; List getStandardListByDeviceType(PageData pd); + + List getPointListByUserId(PageData pd); } diff --git a/src/main/java/com/zcloud/mapper/datasource/firemanager/FirePointMapper.java b/src/main/java/com/zcloud/mapper/datasource/firemanager/FirePointMapper.java index 9c3d17fa..8537b122 100644 --- a/src/main/java/com/zcloud/mapper/datasource/firemanager/FirePointMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/firemanager/FirePointMapper.java @@ -3,6 +3,7 @@ package com.zcloud.mapper.datasource.firemanager; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -22,6 +23,8 @@ public interface FirePointMapper { */ public List datalistPage(Page page); + public List listForExcel(PageData pd); + void savePosition(PageData pd); /** @@ -79,4 +82,6 @@ public interface FirePointMapper { void removeQualifiedByQIds(PageData pd); List getFirePointCheckPhotos(PageData pd); + + List findByIds(@Param("pointIds") List pointIds); } diff --git a/src/main/java/com/zcloud/service/firemanager/FireCheckStandardService.java b/src/main/java/com/zcloud/service/firemanager/FireCheckStandardService.java index 9c5036de..d96e190b 100644 --- a/src/main/java/com/zcloud/service/firemanager/FireCheckStandardService.java +++ b/src/main/java/com/zcloud/service/firemanager/FireCheckStandardService.java @@ -67,4 +67,6 @@ public interface FireCheckStandardService { * @Return: java.lang.Object */ List goRecordDeviceByPid(PageData pd); + + List getPointListByUserId(PageData pageData); } diff --git a/src/main/java/com/zcloud/service/firemanager/FirePointService.java b/src/main/java/com/zcloud/service/firemanager/FirePointService.java index a94f7b78..5bdeabdd 100644 --- a/src/main/java/com/zcloud/service/firemanager/FirePointService.java +++ b/src/main/java/com/zcloud/service/firemanager/FirePointService.java @@ -45,4 +45,7 @@ public interface FirePointService { void removeQualifiedByQIds(PageData pd); List getFirePointCheckPhotos(PageData pd); + + List findByIds(List pointIds); + List listForExcel(PageData pd); } diff --git a/src/main/java/com/zcloud/service/firemanager/impl/FireCheckStandardServiceImpl.java b/src/main/java/com/zcloud/service/firemanager/impl/FireCheckStandardServiceImpl.java index 574ccc83..0ef955a6 100644 --- a/src/main/java/com/zcloud/service/firemanager/impl/FireCheckStandardServiceImpl.java +++ b/src/main/java/com/zcloud/service/firemanager/impl/FireCheckStandardServiceImpl.java @@ -5,16 +5,17 @@ import com.zcloud.entity.PageData; import com.zcloud.mapper.datasource.firemanager.FireCheckStandardMapper; import com.zcloud.service.bus.SysDateService; import com.zcloud.service.firemanager.FireCheckStandardService; +import com.zcloud.service.firemanager.FirePointService; import com.zcloud.service.firemanager.FirePreparedCheckListService; import com.zcloud.service.firemanager.FireRecordService; import com.zcloud.util.DateUtil; -import com.zcloud.util.Jurisdiction; import com.zcloud.util.PeriodDateUtil; import com.zcloud.util.UuidUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; @@ -33,7 +34,8 @@ public class FireCheckStandardServiceImpl implements FireCheckStandardService { @Resource private FirePreparedCheckListService firePreparedCheckListService; - + @Resource + private FirePointService firePointService; @Resource private SysDateService sysDateService; @Resource @@ -245,4 +247,20 @@ public class FireCheckStandardServiceImpl implements FireCheckStandardService { }); return list; } + + + @Override + public List getPointListByUserId(PageData pageData) { + List pointListByUserId = fireCheckStandardMapper.getPointListByUserId(pageData); + List pointIds = new ArrayList<>(); + List dataList = new ArrayList<>(); + if (pointListByUserId.size() > 0) { + for (PageData data : pointListByUserId) { + pointIds.add(data.getString("FIRE_POINT_ID")); + } + dataList = firePointService.findByIds(pointIds); + } + return dataList; + } + } diff --git a/src/main/java/com/zcloud/service/firemanager/impl/FirePointServiceImpl.java b/src/main/java/com/zcloud/service/firemanager/impl/FirePointServiceImpl.java index b11771f6..c0158074 100644 --- a/src/main/java/com/zcloud/service/firemanager/impl/FirePointServiceImpl.java +++ b/src/main/java/com/zcloud/service/firemanager/impl/FirePointServiceImpl.java @@ -36,6 +36,11 @@ public class FirePointServiceImpl implements FirePointService { return firePointMapper.datalistPage(page); } + @Override + public List listForExcel(PageData pd) { + return firePointMapper.listForExcel(pd); + } + @Override public void savePosition(PageData pd)throws Exception{ firePointMapper.savePosition(pd); @@ -156,4 +161,10 @@ public class FirePointServiceImpl implements FirePointService { public List getFirePointCheckPhotos(PageData pd) { return firePointMapper.getFirePointCheckPhotos(pd); } + + @Override + public List findByIds(List pointIds) { + return firePointMapper.findByIds(pointIds); + } + } diff --git a/src/main/java/com/zcloud/util/FirePointExcelImgToSessionView.java b/src/main/java/com/zcloud/util/FirePointExcelImgToSessionView.java new file mode 100644 index 00000000..d770af49 --- /dev/null +++ b/src/main/java/com/zcloud/util/FirePointExcelImgToSessionView.java @@ -0,0 +1,207 @@ +package com.zcloud.util; + +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.entity.PageData; +import net.coobird.thumbnailator.Thumbnails; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.shiro.session.Session; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.servlet.view.document.AbstractXlsView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.file.Files; +import java.text.DecimalFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 说明:导出到EXCEL + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +public class FirePointExcelImgToSessionView extends AbstractXlsView{ + + @Value("${http.file.url}") + private String fileUrl; + + @Override + protected void buildExcelDocument(Map model, + Workbook workbook, HttpServletRequest request, + HttpServletResponse response) throws Exception { + // TODO Auto-generated method stub + String proPath = PathUtil.getProjectpath(); + Session session = Jurisdiction.getSession(); + String beji = fileUrl; + //beji =beji.replaceAll("\\\\", "/"); +// String beji = "https://qgqy.qhdsafety.com/file/"; + Date date = new Date(); + String filename = DateUtil.date2Str(date, "yyyyMMddHHmmss"); + HSSFSheet sheet; + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename="+filename+".xls"); + + HSSFWorkbook book = (HSSFWorkbook) workbook; + sheet = book.createSheet("sheet1"); + + List titles = (List) model.get("titles"); + int len = titles.size(); + HSSFCellStyle headerStyle = book.createCellStyle(); //标题样式 + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); + HSSFFont headerFont = book.createFont(); //标题字体 + headerFont.setBold(true); + headerFont.setFontHeightInPoints((short)11); + headerStyle.setFont(headerFont); + short height=25*20; + HSSFRow row = sheet.createRow(0); + if(len>250) { + len = 250; + } + for(int i=0; i250) { + row.createCell(i).setCellValue(title.substring(0, 250)); + }else { + row.createCell(i).setCellValue(title); + } + } + sheet.getRow(0).setHeight(height); + + HSSFCellStyle contentStyle = book.createCellStyle(); //内容样式 + HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); + + contentStyle.setAlignment(HorizontalAlignment.CENTER); + List varList = (List) model.get("varList"); + + Integer imgCountToSession = (Integer) model.get("imgCountToSession"); + String sessionID = (String) model.get("sessionID"); + Integer exImg = 0; + int varCount = varList.size(); + for(int i=0; i desFileSize * ONE_ZERO_TWO_FOUR) { + ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(imageBytes.length); + Thumbnails.of(inputStream) + .scale(accuracy) + .outputQuality(accuracy) + .toOutputStream(outputStream); + imageBytes = outputStream.toByteArray(); + } + System.out.println("图片原大小={}kb | 压缩后大小={}kb"); +// logger.info("图片原大小={}kb | 压缩后大小={}kb", +// srcSize / ONE_ZERO_TWO_FOUR, imageBytes.length / ONE_ZERO_TWO_FOUR); + } catch (Exception e) { +// logger.error("【图片压缩】msg=图片压缩失败!", e); + } + return imageBytes; + } + public static String getDivisionTwoNumbers(Integer a , Integer b){ + if (b.equals(0)){ + return "0"; + } + float v = a.floatValue() / b.floatValue()*100; + //格式化小数 + float v1 = (float) (Math.round(v * 100)) / 100; + DecimalFormat decimalFormat=new DecimalFormat(".00"); + return decimalFormat.format(v1); + } +} diff --git a/src/main/resources/mybatis/datasource/firemanager/FireCheckStandardMapper.xml b/src/main/resources/mybatis/datasource/firemanager/FireCheckStandardMapper.xml index 72068872..174a9a3d 100644 --- a/src/main/resources/mybatis/datasource/firemanager/FireCheckStandardMapper.xml +++ b/src/main/resources/mybatis/datasource/firemanager/FireCheckStandardMapper.xml @@ -341,4 +341,21 @@ and FIRE_DEVICE_TYPE = #{FIRE_DEVICE_TYPE} + + diff --git a/src/main/resources/mybatis/datasource/firemanager/FirePonitMapper.xml b/src/main/resources/mybatis/datasource/firemanager/FirePonitMapper.xml index 8ab49429..345301a7 100644 --- a/src/main/resources/mybatis/datasource/firemanager/FirePonitMapper.xml +++ b/src/main/resources/mybatis/datasource/firemanager/FirePonitMapper.xml @@ -149,6 +149,45 @@ p.OPERATTIME desc + + + +