wwh 2 лет назад
Родитель
Сommit
9008fe9169

+ 20 - 0
admin/src/main/java/com/huimv/farm/damsubsidy/controller/AreaAllController.java

@@ -0,0 +1,20 @@
+package com.huimv.farm.damsubsidy.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * all areas 前端控制器
+ * </p>
+ *
+ * @author author
+ * @since 2023-05-16
+ */
+@RestController
+@RequestMapping("/area-all")
+public class AreaAllController {
+
+}

+ 40 - 9
admin/src/main/java/com/huimv/farm/damsubsidy/controller/BillSubsidyController.java

@@ -3,16 +3,19 @@ package com.huimv.farm.damsubsidy.controller;
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.UUID;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.farm.damsubsidy.common.utils.Result;
 import com.huimv.farm.damsubsidy.common.utils.UploadImage;
+import com.huimv.farm.damsubsidy.entity.AreaAll;
 import com.huimv.farm.damsubsidy.entity.BillSubsidy;
+import com.huimv.farm.damsubsidy.entity.SysUser;
+import com.huimv.farm.damsubsidy.service.IAreaAllService;
 import com.huimv.farm.damsubsidy.service.IBillSubsidyService;
 import com.huimv.farm.damsubsidy.common.utils.PdfUtil;
+import com.huimv.farm.damsubsidy.test.QrCodeExcelPrinter;
 import com.huimv.farm.test.Print;
 import com.huimv.farm.test.Print2;
-import com.spire.xls.FileFormat;
-import com.spire.xls.Workbook;
-import com.spire.xls.Worksheet;
+import com.spire.xls.*;
 import org.apache.tomcat.util.http.fileupload.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
@@ -38,6 +41,8 @@ import java.util.*;
 public class BillSubsidyController {
     @Autowired
     private IBillSubsidyService iBillSubsidyService;
+    @Autowired
+    private IAreaAllService iAreaAllService;
 
     @PostMapping("/addApplication")
     public Result addApplication(HttpServletRequest httpServletRequest, @RequestBody BillSubsidy billSubsidy){
@@ -138,12 +143,21 @@ public class BillSubsidyController {
     public void print(HttpServletResponse response, HttpServletRequest httpServletRequest,@RequestParam(name = "id", required = true) Integer id) throws Exception {
 //        Integer id=Integer.parseInt(parasMap.get("id"));
         BillSubsidy subsidy = subsidyService.getById(id);
+        QrCodeExcelPrinter codeExcelPrinter = new QrCodeExcelPrinter();
+        codeExcelPrinter.test();
+
         Print.print(subsidy);
         String path = "/opt/subsidy/order_contract.xls";
 
         //加载Excel文档
         Workbook wb = new Workbook();
         wb.loadFromFile(path);
+        Worksheet sheet = wb.getWorksheets().get(0);
+        //添加图片
+        ExcelPicture picture = sheet.getPictures().add(37,10,"/opt/subsidy/a.png");
+        picture.setHeight(70);//设置图片高度
+        picture.setWidth(75);//设置图片宽度
+
 
         Worksheet worksheet = wb.getWorksheets().get(0);
         worksheet.getRange().get("E3").getStyle().setWrapText(true);//地址自动换行
@@ -153,9 +167,8 @@ public class BillSubsidyController {
         //调用方法保存为PDF格式
        String pdfPath = "/opt/subsidy/"+subsidy.getFarmerName()+".pdf";
         wb.saveToFile(pdfPath, FileFormat.PDF);
-//        wb.getConverterSetting().setSheetFitToPage(true);
-//        OutputStream outputStream = null;
-//        wb.saveToStream(outputStream);
+        wb.dispose();
+
 
         PdfUtil.returnPdfStream2(response,pdfPath,subsidy.getFarmerName());
         //文件删除 TODO
@@ -196,13 +209,31 @@ public class BillSubsidyController {
 
     //阶段性统计表
     @GetMapping("/printAmount")
-    public void printAmount(HttpServletResponse response) throws Exception {
+    public void printAmount(HttpServletResponse response, @RequestParam(name = "country", required = true) String country
+            , @RequestParam(name = "startDate", required = true) String startDate, @RequestParam(name = "endDate", required = true) String endDate) throws Exception {
+        Map<String, String> map = new HashMap<>();
+        map.put("start", startDate);
+        map.put("end", endDate);
+        map.put("code", country);
+        iBillSubsidyService.printAmount(response, map);
+
+        String path = "/opt/subsidy/amount.xls";
+        PdfUtil.returnPdfStream2(response,path,"阶段性统计表");
+        //文件删除 TODO
+    }
+
+    //阶段性待支付统计表
+    @GetMapping("/printWaitPay")
+    public void printWaitPay(HttpServletResponse response, @RequestParam(name = "country", required = true) String country
+            , @RequestParam(name = "startDate", required = true) String startDate, @RequestParam(name = "endDate", required = true) String endDate) throws Exception {
+        startDate = startDate + " 00:00:00";
+        endDate = endDate + " 23:59:59";
+
         String path = "G://amount.xls";
 
+//        queryWrapper.eq()
 //        Print2.print();
 //        PdfUtil.returnPdfStream2(response,path,subsidy.getFarmerName());
         //文件删除 TODO
-
-
     }
 }

+ 14 - 11
admin/src/main/java/com/huimv/farm/damsubsidy/entity/vo/BillSubsidyVo.java

@@ -30,24 +30,27 @@ public class BillSubsidyVo extends BaseEntity implements Serializable {
 
     private String name;
 
-    private String type1;
-    private String type2;
-    private String type3;
+    private Integer type1;
+    private Integer type2;
+    private Integer type3;
 
     private Integer count;
     private Integer number;
-    private Integer money;
+    private BigDecimal money;
     private Integer count1;
     private Integer number1;
-    private Integer money1;
+    private BigDecimal money1;
     private Integer count2;
     private Integer number2;
-    private Integer money2;
+    private BigDecimal money2;
     private Integer count3;
-    private Integer number3;
-    private Integer money3;
+    private BigDecimal number3;
+    private BigDecimal money3;
     private Integer count4;
-    private Integer number4;
-    private Integer money4;
-    private Integer moneycount;
+    private BigDecimal number4;
+    private BigDecimal money4;
+    private Integer count5;
+    private BigDecimal number5;
+    private BigDecimal money5;
+    private BigDecimal moneycount;
 }

+ 16 - 0
admin/src/main/java/com/huimv/farm/damsubsidy/mapper/AreaAllMapper.java

@@ -0,0 +1,16 @@
+package com.huimv.farm.damsubsidy.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.huimv.farm.damsubsidy.entity.AreaAll;
+
+/**
+ * <p>
+ * all areas Mapper 接口
+ * </p>
+ *
+ * @author author
+ * @since 2023-05-16
+ */
+public interface AreaAllMapper extends BaseMapper<AreaAll> {
+
+}

+ 16 - 0
admin/src/main/java/com/huimv/farm/damsubsidy/service/IAreaAllService.java

@@ -0,0 +1,16 @@
+package com.huimv.farm.damsubsidy.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.huimv.farm.damsubsidy.entity.AreaAll;
+
+/**
+ * <p>
+ * all areas 服务类
+ * </p>
+ *
+ * @author author
+ * @since 2023-05-16
+ */
+public interface IAreaAllService extends IService<AreaAll> {
+
+}

+ 3 - 1
admin/src/main/java/com/huimv/farm/damsubsidy/service/IBillSubsidyService.java

@@ -49,5 +49,7 @@ public interface IBillSubsidyService extends IService<BillSubsidy> {
 
     void printPay2(HttpServletResponse response,String startDate,String endDate) throws IOException;
 
-//    void printAmount(HttpServletResponse httpServletResponse);
+    void printAmount(HttpServletResponse httpServletResponse,Map<String,String> paramsMap);
+
+    void printWaitPay(HttpServletResponse httpServletResponse,Map<String,String> paramsMap);
 }

+ 20 - 0
admin/src/main/java/com/huimv/farm/damsubsidy/service/impl/AreaAllServiceImpl.java

@@ -0,0 +1,20 @@
+package com.huimv.farm.damsubsidy.service.impl;
+
+import com.huimv.farm.damsubsidy.entity.AreaAll;
+import com.huimv.farm.damsubsidy.mapper.AreaAllMapper;
+import com.huimv.farm.damsubsidy.service.IAreaAllService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * all areas 服务实现类
+ * </p>
+ *
+ * @author author
+ * @since 2023-05-16
+ */
+@Service
+public class AreaAllServiceImpl extends ServiceImpl<AreaAllMapper, AreaAll> implements IAreaAllService {
+
+}

+ 28 - 4
admin/src/main/java/com/huimv/farm/damsubsidy/service/impl/BillSubsidyServiceImpl.java

@@ -18,11 +18,14 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.farm.damsubsidy.common.utils.Result;
 import com.huimv.farm.damsubsidy.common.utils.ResultCode;
+import com.huimv.farm.damsubsidy.entity.vo.BillSubsidyReportVo;
+import com.huimv.farm.damsubsidy.mapper.AreaAllMapper;
 import com.huimv.farm.damsubsidy.mapper.BaseAnimalMapper;
 import com.huimv.farm.damsubsidy.mapper.BillSubsidyMapper;
 import com.huimv.farm.damsubsidy.mapper.SysUserMapper;
 import com.huimv.farm.damsubsidy.service.IBillSubsidyService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.huimv.farm.test.Print2;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -55,6 +58,8 @@ public class BillSubsidyServiceImpl extends ServiceImpl<BillSubsidyMapper, BillS
     private SysUserMapper sysUserMapper;
     @Autowired
     private BaseAnimalMapper animalMapper;
+    @Autowired
+    private AreaAllMapper areaAllMapper;
 
     @Override
     public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
@@ -739,8 +744,27 @@ public class BillSubsidyServiceImpl extends ServiceImpl<BillSubsidyMapper, BillS
         }
     }
 
-//    @Override
-//    public void printAmount(HttpServletResponse httpServletResponse) {
-//
-//    }
+    @Override
+    public void printAmount(HttpServletResponse httpServletResponse, Map<String, String> paramsMap) {
+        String code = paramsMap.get("code");
+        String start = paramsMap.get("start");
+        String end = paramsMap.get("end");
+        QueryWrapper<AreaAll> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("id",code);
+        AreaAll areaAll = areaAllMapper.selectOne(queryWrapper);//得到乡镇地址
+        List<BillSubsidyReportVo> billSubsidyReportVos = subsidyMapper.listReport(code, start, end);
+        try {
+            Print2.print(billSubsidyReportVos,areaAll.getName(),end);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    @Override
+    public void printWaitPay(HttpServletResponse httpServletResponse, Map<String, String> paramsMap) {
+
+    }
+
+
 }

+ 5 - 31
admin/src/main/java/com/huimv/farm/damsubsidy/test/QrCodeExcelPrinter.java

@@ -15,44 +15,18 @@ import com.google.zxing.qrcode.QRCodeWriter;
 
 public class QrCodeExcelPrinter {
     
-    private static final String QRCODE_IMAGE_PATH = "D://qrcode.png"; // 二维码图片路径
+    private static final String QRCODE_IMAGE_PATH = "/opt/subsidy/a.png"; // 二维码图片路径
 //    private static final String EXCEL_PATH = "qrcode_excel.xls"; // Excel文件路径
-    
-    public static void main(String[] args) throws Exception {
+
+    public void test() throws Exception {
         String content = "https://www.baidu.com"; // 二维码内容
         int width = 300; // 二维码宽度
-        
+
         // 生成二维码图片
         BufferedImage qrCodeImage = generateQrCodeImage(content, width);
         ImageIO.write(qrCodeImage, "png", new File(QRCODE_IMAGE_PATH));
-        
-        // 使用JXL库生成Excel
-      /*  WritableWorkbook workbook = Workbook.createWorkbook(new File(EXCEL_PATH));
-        WritableSheet sheet = workbook.createSheet("Sheet1", 0);
-
-        // 设置单元格格式
-        Font font = new WritableFont(WritableFont.TIMES, 12, WritableFont.BOLD);
-        CellFormat labelFormat = new WritableCellFormat(font);
-        labelFormat.setAlignment(jxl.format.Alignment.CENTRE);
-        labelFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
-        labelFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
-
-        // 插入二维码图片
-        WritableImage qrCodeWritableImage = new WritableImage(0, 0, 5, 5, new File(QRCODE_IMAGE_PATH));
-        sheet.addImage(qrCodeWritableImage);
-        sheet.setRowView(0, 800); // 设置第1行的行高
-
-        // 插入二维码内容
-        String[] contentArray = splitContent(content, 20); // 将二维码内容每20个字符分割为一行
-        for (int i = 0; i < contentArray.length; i++) {
-            Label contentLabel = new Label(1, i, contentArray[i], labelFormat);
-            sheet.addCell(contentLabel);
-            sheet.setRowView(i, 800); // 设置行高
-        }
-
-        workbook.write();
-        workbook.close();*/
     }
+
     
     /**
      * 生成二维码图片

+ 24 - 21
admin/src/main/java/com/huimv/farm/test/Print.java

@@ -21,12 +21,16 @@ public class Print {
      */
     public  static void print(BillSubsidy subsidy) throws Exception {
         //准备数据
+        //
         String path ="/opt/subsidy/order_contract.xls";
         //获取模板文件,你自己当前模板的位置  我这里为当前项目下
         //如果为系统路径 为: InputStream is = new FileInputStream("F://student.xlsx");
         InputStream is = new FileInputStream("/opt/subsidy/order_contract.xlsx");
 //        InputStream is = Print.class.getClassLoader().getResourceAsStream("student.xlsx");
 //        InputStream is = Print.class.getClassLoader().getResourceAsStream("order_contract.xls");
+
+
+        //绑定数据
         //根据模板生成的文件保存路径  我这里保存在本地D盘
         OutputStream os = new FileOutputStream(path);
         //绑定数据
@@ -73,6 +77,7 @@ public class Print {
         context.putVar("earNum", subsidy.getEartagNo());
         context.putVar("money", subsidy.getApplyMoney());
         context.putVar("userNum", subsidy.getBankCardId());
+
         //生成
         JxlsHelper.getInstance().processTemplate(is, os, context);
 //        String path = String.valueOf(os);
@@ -80,41 +85,39 @@ public class Print {
     }
 
 
-//    /**
-//     * 打印方法  不插入图片
-//     *
-//     * 模板文件为student1.xlsx
-//     * 注意事项:模板文件新加入了一行,所以整体范围也就有所改变,大家注意一下批注中的结束范围
-//     * 图片所占用的范围为B2到C2
-//     *
-//     *
-//     * @throws Exception
-//     */
+    /**
+     * 打印方法  不插入图片
+     *
+     * 模板文件为student1.xlsx
+     * 注意事项:模板文件新加入了一行,所以整体范围也就有所改变,大家注意一下批注中的结束范围
+     * 图片所占用的范围为B2到C2
+     *
+     *
+     * @throws Exception
+     */
 //    public static void print1() throws Exception {
 //        //准备数据
-//
 //        //获取模板文件,你自己当前模板的位置  我这里为当前项目下
 //        //如果为系统路径 为: InputStream is = new FileInputStream("F://student.xlsx");
-//        InputStream is = Print.class.getClassLoader().getResourceAsStream("student1.xlsx");
+//        InputStream is = Print.class.getClassLoader().getResourceAsStream("G://test.xlsx");
 //        //根据模板生成的文件保存路径  我这里保存在本地D盘
-//        OutputStream os = new FileOutputStream("D://student1.xlsx");
+//        OutputStream os = new FileOutputStream("G://test01.xlsx");
 //
 //        //图片路径
-//        InputStream imageInputStream =Print.class.getClassLoader().getResourceAsStream("a.png");
+//        InputStream is2 = new FileInputStream("G://a.png");
 //        //转为字节码,插入的图片只能是字节码格式
-//        byte[] imageBytes = Util.toByteArray(imageInputStream);
+//        byte[] imageBytes = Util.toByteArray(is2);
 //        //绑定数据
 //        Context context = new Context();
-//        context.putVar("imageBytes", imageBytes);
-//        context.putVar("title", "学上统计表");
-////        context.putVar("list", list);
+//        context.putVar("image", imageBytes);
+//
 //        //生成
 //        JxlsHelper.getInstance().processTemplate(is, os, context);
 //    }
-//
+
 //    public static void main(String[] args) throws Exception {
-//        print();
-////        print1();
+////        print();
+//        print1();
 //    }
 
 }

+ 39 - 32
admin/src/main/java/com/huimv/farm/test/Print2.java

@@ -1,6 +1,6 @@
 package com.huimv.farm.test;
 
-import com.huimv.farm.damsubsidy.entity.BillSubsidy;
+import com.huimv.farm.damsubsidy.entity.vo.BillSubsidyReportVo;
 import com.huimv.farm.damsubsidy.entity.vo.BillSubsidyVo;
 import org.jxls.common.Context;
 import org.jxls.util.JxlsHelper;
@@ -9,6 +9,7 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -18,49 +19,55 @@ public class Print2 {
      * @throws Exception
      * @return
      */
-    public  static void print(List<BillSubsidy> subsidies) throws Exception {
+    public  static void print(List<BillSubsidyReportVo> billSubsidyReportVos, String address, String date) throws Exception {
         //准备数据
-        String path ="G://mount.xls";
+        String path ="/opt/subsidy/amount.xls";
         //获取模板文件,你自己当前模板的位置  我这里为当前项目下
         //如果为系统路径 为: InputStream is = new FileInputStream("F://student.xlsx");
-        InputStream is = new FileInputStream("G://amount.xlsx");
+        InputStream is = new FileInputStream("/opt/subsidy/amount.xlsx");
 //        InputStream is = Print.class.getClassLoader().getResourceAsStream("student.xlsx");
 //        InputStream is = Print.class.getClassLoader().getResourceAsStream("order_contract.xls");
         //根据模板生成的文件保存路径  我这里保存在本地D盘
         OutputStream os = new FileOutputStream(path);
         //绑定数据
-        List<BillSubsidy> list = new ArrayList<>();
+        List<BillSubsidyVo> list = new ArrayList<>();
         Context context = new Context();
-        //涉及太多只写了一个单独的
-        for (int i = 0; i < subsidies.size(); i++) {
+        BigDecimal count = BigDecimal.valueOf(0);
+        Integer i = 1;
+        for (BillSubsidyReportVo reportVo : billSubsidyReportVos) {
             BillSubsidyVo subsidyVo = new BillSubsidyVo();
             subsidyVo.setId(i);
-            subsidyVo.setName(subsidies.get(i).getBriefAddress());
-            if (subsidies.get(i).getFarmerType()==0) {
-                subsidyVo.setType1("1");
-            } else if (subsidies.get(i).getFarmerType()==1) {
-                subsidyVo.setType2("2");
-            } else {
-                subsidyVo.setType3("2");
-            }
-            if (subsidies.get(i).getRewardType() == 0) {
-
-
-                subsidyVo.setNumber(subsidies.get(i).getRewardNum());
-
-            } else if (subsidies.get(i).getRewardType() == 1) {
-
-            } else if (subsidies.get(i).getRewardType() == 2) {
-
-            } else if (subsidies.get(i).getRewardType() == 3){
-
-            } else if (subsidies.get(i).getRewardType() == 4) {
-
-            } else {
-
-            }
+            subsidyVo.setName(reportVo.getVillageName());
+            subsidyVo.setType1(reportVo.getJcdx());
+            subsidyVo.setType2(reportVo.getYtph());
+            subsidyVo.setType3(reportVo.getQt());
+            subsidyVo.setCount(reportVo.getRnhs());
+            subsidyVo.setNumber(reportVo.getRnts());
+            subsidyVo.setMoney(reportVo.getRnje());
+            subsidyVo.setCount1(reportVo.getRyhs());
+            subsidyVo.setNumber1(reportVo.getRyts());
+            subsidyVo.setMoney1(reportVo.getRyje());
+            subsidyVo.setCount2(reportVo.getSzhs());
+            subsidyVo.setNumber2(reportVo.getSzts());
+            subsidyVo.setMoney2(reportVo.getSzje());
+            subsidyVo.setCount3(reportVo.getLgshs());
+            subsidyVo.setNumber3(reportVo.getLgsmj());
+            subsidyVo.setMoney3(reportVo.getLgsje());
+            subsidyVo.setCount4(reportVo.getQzchs());
+            subsidyVo.setNumber4(reportVo.getQzcmj());
+            subsidyVo.setMoney4(reportVo.getQzcje());
+            subsidyVo.setCount5(reportVo.getSths());
+            subsidyVo.setNumber5(reportVo.getStmj());
+            subsidyVo.setMoney5(reportVo.getStje());
+            subsidyVo.setMoneycount(reportVo.getJe());
+            list.add(subsidyVo);
+            i = i + 1;
+            count = reportVo.getJe().add(count);
         }
-//        context.putVar("orderTime", new Date());
+        context.putVar("list", list);
+        context.putVar("address", address);
+        context.putVar("date", date);
+        context.putVar("moneyamount", count);
 
         //生成
         JxlsHelper.getInstance().processTemplate(is, os, context);

+ 5 - 0
admin/src/main/resources/com/huimv/farm/damsubsidy/mapper/AreaAllMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.huimv.farm.damsubsidy.mapper.AreaAllMapper">
+
+</mapper>

+ 1 - 1
admin/src/main/resources/com/huimv/farm/damsubsidy/mapper/BillSubsidyMapper.xml

@@ -66,7 +66,7 @@
         (SELECT COALESCE(SUM(s1.pay_money),0) FROM `bill_subsidy` s1 WHERE s1.reward_type = 4 AND s1.detailed_adress_code = aa.id AND s1.subsidy_sch = 3 AND DATE_FORMAT(s1.create_time,'%Y-%m-%d') BETWEEN #{startTime} and #{endTime}) AS 'stje',
         (SELECT COALESCE(SUM(s1.pay_money),0) FROM `bill_subsidy` s1 WHERE s1.detailed_adress_code = aa.id AND s1.subsidy_sch = 3 AND DATE_FORMAT(s1.create_time,'%Y-%m-%d') BETWEEN #{startTime} and #{endTime}) AS 'je'
         FROM `area_all` aa LEFT JOIN `bill_subsidy` s ON aa.id = s.detailed_adress_code
-        WHERE aa.id LIKE '#{townCode}%'  AND aa.id &lt;&gt; '#{townCode}'
+        WHERE aa.id LIKE concat(#{townCode},'%')  AND aa.id &lt;&gt; #{townCode}
         ORDER BY aa.id ASC
     </select>