Newspaper 1 年之前
父節點
當前提交
0f2ddc42ca
共有 18 個文件被更改,包括 360 次插入33 次删除
  1. 5 2
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/java/com/huimv/admin/system/controller/LoginController.java
  2. 0 1
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/java/com/huimv/admin/system/mapper/FeedEggDetailMapper.java
  3. 344 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/java/com/huimv/admin/system/util/PdfUtil.java
  4. 8 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/java/com/huimv/admin/system/util/Print.java
  5. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/AccountGroupMapper.xml
  6. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/AppAccountGroupMapper.xml
  7. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/AppGroupMenuMapper.xml
  8. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/AppMenuMapper.xml
  9. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/FarmMapper.xml
  10. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/FeedEggDetailMapper.xml
  11. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/GroupMenuMapper.xml
  12. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/MenuMapper.xml
  13. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/ProdFarmNameMapper.xml
  14. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/ScreenAccountGroupMapper.xml
  15. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/ScreenGroupMenuMapper.xml
  16. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/ScreenMenuMapper.xml
  17. 0 0
      huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/UserMapper.xml
  18. 3 30
      huimv-farm-datacenter-egg/huimv-farm-environ/src/main/resources/mapper/FeedEggDetailMapper.xml

+ 5 - 2
huimv-farm-datacenter-egg/huimv-farm-admin/src/main/java/com/huimv/admin/system/controller/LoginController.java

@@ -8,6 +8,7 @@ import com.huimv.admin.system.service.IBaseFarmXService;
 import com.huimv.admin.system.service.IFeedEggDetailService;
 import com.huimv.admin.system.service.ILoginService;
 import com.huimv.admin.system.session.AccessToken;
+import com.huimv.admin.system.util.PdfUtil;
 import com.huimv.common.exception.ExceptionEnum;
 import com.huimv.common.exception.MiException;
 import com.huimv.common.token.TokenSign;
@@ -194,14 +195,16 @@ public class LoginController {
     }
 
     @GetMapping("/print")
-    public void print(@RequestParam(name = "startDate") String startDate,
-                      @RequestParam(name = "endDate") String endDate) throws IOException {
+    public void print(HttpServletResponse response, @RequestParam(name = "startDate") String startDate,
+                      @RequestParam(name = "endDate") String endDate) throws Exception {
         Map<String, String> map = new HashMap();
         startDate = startDate.replace("-","/");
         endDate = endDate.replace("-","/");
         map.put("startDate",startDate);
         map.put("endDate",endDate);
         feedEggDetailService.print(map);
+        String path = "/opt/jar/FeedEggReport.xls";
+        PdfUtil.returnPdfStream3(response, path, startDate +" - " + endDate +"报表");
     }
 
 

+ 0 - 1
huimv-farm-datacenter-egg/huimv-farm-admin/src/main/java/com/huimv/admin/system/mapper/FeedEggDetailMapper.java

@@ -1,7 +1,6 @@
 package com.huimv.admin.system.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.huimv.admin.system.entity.FeedEggDetail;
 import com.huimv.admin.system.entity.FeedEggVo;
 import org.springframework.stereotype.Repository;

+ 344 - 0
huimv-farm-datacenter-egg/huimv-farm-admin/src/main/java/com/huimv/admin/system/util/PdfUtil.java

@@ -0,0 +1,344 @@
+package com.huimv.admin.system.util;
+
+//import cn.bt.common.utils.StringUtils;
+//import cn.bt.modules.process.instance.enums.InstanceStatusEnum;
+//import com.itextpdf.text.*;
+//import com.itextpdf.text.pdf.*;
+
+import cn.hutool.core.io.IoUtil;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+/**
+ * @Author: xp
+ * @Date: 2021/7/14
+ */
+public class PdfUtil {
+
+    /**
+     * 返回PDF流
+     *
+     * @param response 相应设置
+     * @param pathName 水印文件路径和名称
+     * @throws Exception 异常
+     */
+    /*public static void returnPdfStream(HttpServletResponse response, String pathName) throws Exception {
+        response.setContentType("application/pdf");
+
+        File file = new File(pathName);
+        if (file.exists()) {
+            FileInputStream in = new FileInputStream(file);
+            OutputStream out = response.getOutputStream();
+            byte[] b = new byte[1024 * 4];
+            int n;
+            while ((n = in.read(b)) > -1) {
+                out.write(b, 0, n);
+            }
+            out.flush();
+            in.close();
+            out.close();
+        }
+    }*/
+    public static void returnPdfStream2(HttpServletResponse response, String pathName, String subsidyNane) throws Exception {
+        InputStream in = null;
+        try {
+            File file = new File(pathName);
+             in = new BufferedInputStream(new FileInputStream(file));
+            String filename = new String((subsidyNane+".pdf").getBytes(), "ISO8859_1");
+            response.setContentType("application/binary;charset=ISO8859_1");
+            response.setHeader("Content-disposition", "attachment; filename=" + filename);// 组装附件名称和格式
+            IoUtil.copy(in, response.getOutputStream());
+        } catch (Exception e) {
+            System.out.println("------------ 这里除了问题!!!-----------");
+            System.out.println(e);
+        }finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+    }
+
+    public static void returnPdfStream3(HttpServletResponse response, String pathName, String subsidyNane) throws Exception {
+        InputStream in = null;
+        try {
+            File file = new File(pathName);
+            in = new BufferedInputStream(new FileInputStream(file));
+            String filename = new String((subsidyNane+".xls").getBytes(), "ISO8859_1");
+            response.setContentType("application/binary;charset=ISO8859_1");
+            response.setHeader("Content-disposition", "attachment; filename=" + filename);// 组装附件名称和格式
+            IoUtil.copy(in, response.getOutputStream());
+        } catch (Exception e) {
+            System.out.println("------------ 这里除了问题!!!-----------");
+            System.out.println(e);
+        }finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+    }
+
+    /**
+     * 返回水印图片路径
+     *
+     * @param instanceStatus 流程状态
+     * @return 水印图片路径
+     */
+//    public static String returnWatermarkPath(int instanceStatus) {
+//        String watermarkPath = "ioffice-api/src/main/resources/static/watermark";
+//        if (InstanceStatusEnum.E_0.getCode().equals(instanceStatus)) {
+//            watermarkPath = watermarkPath + "/已作废.png";
+//
+//        } else if (InstanceStatusEnum.E_2.getCode().equals(instanceStatus)) {
+//            watermarkPath = watermarkPath + "/审批通过.png";
+//
+//        } else {
+//            watermarkPath = watermarkPath + "/审批中.png";
+//        }
+//        return watermarkPath;
+//    }
+//
+//    /**
+//     * 建立一个书写器(Writer)与document对象关联,通过书写器(Writer)可以将文档写入到磁盘中。
+//     *
+//     * @param pdfPath     保存路径
+//     * @param document    文档
+//     * @param pdfPathName 文件保存路径和名称
+//     * @return 书写器(Writer)
+//     * @throws Exception
+//     */
+//    public static PdfWriter createPdfWriter(String pdfPath, Document document, String pdfPathName) throws Exception {
+//
+//        //判断文件夹是否存在
+//        File file = new File(pdfPath);
+//        if (!file.exists()) {
+//            file.mkdir();
+//        }
+//        file = new File(pdfPathName);
+//
+//        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
+//        writer.setViewerPreferences(PdfWriter.PageModeUseThumbs);
+//
+//        return writer;
+//    }
+//
+//    /**
+//     * 设置第一标题内容
+//     *
+//     * @param title    第一标题
+//     * @param document 文档
+//     * @throws Exception 异常
+//     */
+//    public static void setPdfFirstTitle(String title, Document document) throws Exception {
+//        Paragraph paragraph = new Paragraph(title, getPdfChineseFont(0));
+//        paragraph.setAlignment(Element.ALIGN_CENTER);
+//        paragraph.setSpacingAfter(2);
+//        document.add(paragraph);
+//    }
+//
+//    /**
+//     * 设置第二标题内容
+//     *
+//     * @param title           第二标题
+//     * @param document        文档
+//     * @param alignment       对齐方式
+//     * @param firstLineIndent 第一行缩进
+//     * @param spacingAfter    之后间隔
+//     * @throws Exception
+//     */
+//    public static void setPdfSecondTitle(String title, Document document, int alignment, int firstLineIndent, int spacingAfter) throws Exception {
+//        Paragraph lsh = new Paragraph(title, getPdfChineseFont(1));
+//        lsh.setAlignment(alignment);
+//        lsh.setFirstLineIndent(firstLineIndent);
+//        lsh.setSpacingAfter(spacingAfter);
+//        document.add(lsh);
+//    }
+//
+//    /**
+//     * 设置表格内容 并将表格加入文档中
+//     *
+//     * @param dates    数据
+//     * @param document 文档
+//     * @param table    表格
+//     * @throws Exception 异常
+//     */
+//    public static void setPdfTableContent(Object[][] dates, Document document, PdfPTable table) throws Exception {
+//        for (int i = 0; i < dates.length; i++) {
+//            for (int j = 0; j < dates[i].length; j++) {
+//                //表格的单元格
+//                PdfPCell pdfCell = new PdfPCell();
+//                //设置表格行高
+//                if (i > 0 && i < 3) {
+//                    pdfCell.setMinimumHeight(50);
+//                } else {
+//                    pdfCell.setMinimumHeight(25);
+//                }
+//                Paragraph paragraph = new Paragraph(dates[i][j] + "", getPdfChineseFont(1));
+//                pdfCell.setPhrase(paragraph);
+//
+//                setCellStyle(pdfCell);
+//                table.addCell(pdfCell);
+//            }
+//        }
+//
+//        document.add(table);
+//    }
+//
+//    /**
+//     * 设置水印
+//     *
+//     * @param inputFile 要这设置水印的文件路径
+//     * @param imageFile 水印图片路径
+//     * @param tag       标记
+//     * @return 生成水印文件的路径
+//     */
+//    public static String imageWaterMark(String inputFile, String imageFile, String tag) throws Exception {
+//        String[] spe = separatePath(inputFile);
+//        String outputFile = spe[0] + tag + "." + spe[1];
+//
+//        PdfReader reader = new PdfReader(inputFile);
+//        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputFile));
+//
+//        int total = reader.getNumberOfPages() + 1;
+//
+//        Image image = Image.getInstance(imageFile);
+//        //坐标
+//        image.setAbsolutePosition(389, 730);
+//        //自定义大小
+//        image.scaleAbsolute(80, 80);
+//        //旋转 弧度
+//        image.setRotation(-55);
+//
+//        //旋转 角度
+//        image.setRotationDegrees(0);
+//        //依照比例缩放
+//        image.scalePercent(50);
+//
+//        PdfGState gs = new PdfGState();
+//        // 设置透明度为0.2
+//        gs.setFillOpacity(0.2f);
+//
+//
+//        PdfContentByte under;
+//        //给每一页加水印
+//        for (int i = 1; i < total; i++) {
+//            under = stamper.getUnderContent(i);
+//            under.beginText();
+//            // 添加水印图片
+//            under.addImage(image);
+//            under.setGState(gs);
+//        }
+//        stamper.close();
+//        reader.close();
+//        return outputFile;
+//    }
+//
+//    /**
+//     * 拆分原文件路径
+//     *
+//     * @param path 原文件路径
+//     * @return 拆分原路径的数组
+//     */
+//    public static String[] separatePath(String path) {
+//        if (StringUtils.isBlank(path)) {
+//            return null;
+//        }
+//        String[] sep = path.split("\\.");
+//        return new String[]{sep[0], sep[1]};
+//    }
+//
+//    /**
+//     * 设置表格单元格样式
+//     *
+//     * @param pdfCell 单元格对象
+//     */
+//    public static void setCellStyle(PdfPCell pdfCell) {
+//        pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
+//        pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+//        pdfCell.setBackgroundColor(new BaseColor(0xdd7e6b));
+//        pdfCell.setBorderWidthTop(0.1f);
+//        pdfCell.setBorderWidthBottom(0.1f);
+//        pdfCell.setBorderWidthLeft(0.1f);
+//        pdfCell.setBorderWidthRight(0.1f);
+//    }
+//
+//    /**
+//     * 设置pdf字体及大小
+//     *
+//     * @param type 标题或者内容 0-内容 1-标题
+//     * @return 字体
+//     * @throws Exception 异常
+//     */
+//    public static Font getPdfChineseFont(int type) throws Exception {
+//        // 使用系统字体
+//        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
+//        Font font;
+//        if (type == 1) {
+//            font = new Font(bfChinese);
+//        } else {
+//            font = new Font(bfChinese, 18, Font.BOLD);
+//        }
+//
+//        return font;
+//    }
+//
+//    /**
+//     * 删除文件夹
+//     *
+//     * @param folderPath 文件路基
+//     */
+//    public static void delFolder(String folderPath) {
+//        // 删除完里面所有内容
+//        delAllFile(folderPath);
+//        String filePath = folderPath;
+//        filePath = filePath.toString();
+//        java.io.File myFilePath = new java.io.File(filePath);
+//        // 删除空文件夹
+//        myFilePath.delete();
+//    }
+//
+//    /**
+//     * 删除指定文件夹下所有文件
+//     *
+//     * @param path 文件路基
+//     * @return 是否成功
+//     */
+//    public static boolean delAllFile(String path) {
+//        boolean flag = false;
+//        File file = new File(path);
+//        String[] tempList = file.list();
+//        File temp = null;
+//        for (int i = 0; i < tempList.length; i++) {
+//            if (path.endsWith(File.separator)) {
+//                temp = new File(path + tempList[i]);
+//            } else {
+//                temp = new File(path + File.separator + tempList[i]);
+//            }
+//            if (temp.isFile()) {
+//                temp.delete();
+//            }
+//            if (temp.isDirectory()) {
+//                // 先删除文件夹里面的文件
+//                delAllFile(path + "/" + tempList[i]);
+//                // 再删除空文件夹
+//                delFolder(path + "/" + tempList[i]);
+//                flag = true;
+//            }
+//        }
+//        return flag;
+//    }
+//    public static boolean delAllFile(String path) {
+//        boolean flag = false;
+//        File file = new File(path);
+//        File temp = null;
+//
+//            if (temp.isFile()) {
+//                temp.delete();
+//            }
+//        return flag;
+//    }
+}
+

+ 8 - 0
huimv-farm-datacenter-egg/huimv-farm-admin/src/main/java/com/huimv/admin/system/util/Print.java

@@ -79,6 +79,14 @@ public class Print {
             feedEggPrintVo.setFeedConsume6(list1.get(5).getFeedConsume()+"Kg");
             feedEggPrintVo.setFeedEggRatio6(list1.get(5).getFeedEggRatio()+":1");
 
+            feedEggPrintVo.setStock7(list1.get(6).getStock());
+            feedEggPrintVo.setEggProduction7(list1.get(6).getEggProduction());
+            feedEggPrintVo.setLayEggRate7(list1.get(6).getLayEggRate()+"%");
+            feedEggPrintVo.setEggWeight7(list1.get(6).getEggWeight()+"吨");
+            feedEggPrintVo.setAvgWeight7(list1.get(6).getAvgWeight()+"克");
+            feedEggPrintVo.setFeedConsume7(list1.get(6).getFeedConsume()+"Kg");
+            feedEggPrintVo.setFeedEggRatio7(list1.get(6).getFeedEggRatio()+":1");
+
             list.add(feedEggPrintVo);
         }
         context.putVar("list", list);

huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/AccountGroupMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/AccountGroupMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/AppAccountGroupMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/AppAccountGroupMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/AppGroupMenuMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/AppGroupMenuMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/AppMenuMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/AppMenuMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/FarmMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/FarmMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/FeedEggDetailMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/FeedEggDetailMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/GroupMenuMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/GroupMenuMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/MenuMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/MenuMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/ProdFarmNameMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/ProdFarmNameMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/ScreenAccountGroupMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/ScreenAccountGroupMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/ScreenGroupMenuMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/ScreenGroupMenuMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/ScreenMenuMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/ScreenMenuMapper.xml


huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com.huimv.admin.system.mapper/UserMapper.xml → huimv-farm-datacenter-egg/huimv-farm-admin/src/main/resources/com/huimv/admin/system/mapper/UserMapper.xml


+ 3 - 30
huimv-farm-datacenter-egg/huimv-farm-environ/src/main/resources/mapper/FeedEggDetailMapper.xml

@@ -31,39 +31,12 @@
                  used_date) u
         ON
             e.date = u.date
+            <if test="startDate != null and startDate != ''">
+                WHERE e.date BETWEEN '${startDate}' AND '${endDate}'
+            </if>
         ORDER BY
             e.date DESC
 
     </select>
-    <select id="listPrint" resultType="com.huimv.environ.eco.entity.eggvo.FeedEggVo">
-        SELECT
-            e.date,
-            e.total_egg_weight AS 'totalEggWeight',
-            COALESCE(ROUND(u.total_feed_consume / 1000, 2), 0) AS 'totalFeedConsume',
-            ROUND(CASE WHEN e.egg_production = 0 THEN 0 ELSE u.total_feed_consume / e.egg_production END, 2) AS 'totalFeedEggRate'
-        FROM
-            (SELECT
-                DATE AS DATE,
-                SUM(total_weight) AS total_egg_weight,
-                SUM(egg_production) AS egg_production
-             FROM
-                `lay_egg`
-            GROUP BY
-                 DATE) e
-        LEFT JOIN
-            (SELECT
-                 used_date AS DATE,
-                SUM(total_consume) AS total_feed_consume
-            FROM
-                 `feed_usage`
-             GROUP BY
-                 used_date) u
-        ON
-            e.date = u.date
-        WHERE
-            e.date BETWEEN '${startDate}' AND '${endDate}'
-        ORDER BY
-            e.date ASC
-    </select>
 
 </mapper>