From 3dc5aac3acde478686cfee8b72be17397c1e3630 Mon Sep 17 00:00:00 2001 From: songwenxuan <1924103812@qq.com> Date: Fri, 10 May 2024 11:29:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=9A=90=E6=82=A3=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6=E5=AF=BC=E5=87=BA=E6=B2=A1=E6=9C=89=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=20=E4=B8=80=E8=88=AC?= =?UTF-8?q?=E9=9A=90=E6=82=A3=E5=8F=B0=E8=B4=A6=EF=BC=8C=E9=9A=90=E6=82=A3?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E5=92=8C=E9=9A=90=E6=82=A3=E6=B1=87=E6=80=BB?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E5=AF=BC=E5=87=BA=E3=80=82=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=9A=90=E6=82=A3=E5=8F=B0=E8=B4=A6=20?= =?UTF-8?q?=E9=9A=90=E6=82=A3=E7=B1=BB=E5=9E=8B=20=E7=AD=89=E7=BA=A7=20?= =?UTF-8?q?=E9=9A=90=E6=82=A3=E4=BD=8D=E7=BD=AE=20=E9=9A=90=E6=82=A3?= =?UTF-8?q?=E7=AE=80=E8=A6=81=E6=83=85=E5=86=B5=20=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E6=B2=BB=E7=90=86=E6=8E=AA=E6=96=BD=20=E5=8F=91=E7=8E=B0?= =?UTF-8?q?=E9=9A=90=E6=82=A3=E6=97=A5=E6=9C=9F=20=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=97=B6=E9=99=90=20=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E8=B4=A3=E4=BB=BB=E9=83=A8=E9=97=A8=20=E6=95=B4=E6=94=B9?= =?UTF-8?q?=E8=B4=A3=E4=BB=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=8C=E7=BB=99=E6=B6=88?= =?UTF-8?q?=E9=98=B2=E7=AE=A1=E7=90=86=E6=8C=AA=E5=88=B0=20=E5=8F=8C?= =?UTF-8?q?=E9=A2=84=E9=98=B2=E9=87=8C=E8=BE=B9=E5=92=8C=E6=B8=AF=E8=82=A1?= =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=AB=AF=E4=B8=80=E6=A0=B7=E3=80=82=20?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=EF=BC=8C?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E4=B8=8E=E6=B8=AF=E5=8A=A1=E5=B1=80=E7=9B=91?= =?UTF-8?q?=E7=AE=A1=E7=AB=AF=E7=9C=8B=E5=88=B0=E7=9A=84=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E3=80=82=20=E5=9C=A8=E7=BA=BF=E7=8A=B6=E6=80=81=E7=9A=84?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=8E=89=E7=BA=BF?= =?UTF-8?q?=E5=88=99=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 11 +- .../controller/app/AppUsersController.java | 20 ++ .../firemanager/FirePointController.java | 104 +++++++-- .../app/AppFireRecordController.java | 17 ++ .../firemanager/FireCheckStandardMapper.java | 2 + .../firemanager/FirePointMapper.java | 5 + .../firemanager/FireCheckStandardService.java | 2 + .../service/firemanager/FirePointService.java | 3 + .../impl/FireCheckStandardServiceImpl.java | 22 +- .../impl/FirePointServiceImpl.java | 11 + .../util/FirePointExcelImgToSessionView.java | 207 ++++++++++++++++++ .../firemanager/FireCheckStandardMapper.xml | 17 ++ .../firemanager/FirePonitMapper.xml | 49 +++++ 13 files changed, 445 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/zcloud/util/FirePointExcelImgToSessionView.java 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 + + + +