瀏覽代碼

后台人员管理

wwh 1 年之前
父節點
當前提交
819ebaa851

+ 11 - 0
huimv-admin/pom.xml

@@ -151,6 +151,17 @@
         <version>4.4.3</version>
     </dependency>
 
+        <dependency>
+            <groupId>org.jxls</groupId>
+            <artifactId>jxls</artifactId>
+            <version>2.6.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jxls</groupId>
+            <artifactId>jxls-poi</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+
 
 </dependencies>
     <build>

+ 344 - 0
huimv-admin/src/main/java/com/huimv/admin/common/utils/PdfUtil.java

@@ -0,0 +1,344 @@
+package com.huimv.admin.common.utils;
+
+//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;
+//    }
+}
+

+ 79 - 0
huimv-admin/src/main/java/com/huimv/admin/common/utils/Print.java

@@ -0,0 +1,79 @@
+package com.huimv.admin.common.utils;
+
+import com.huimv.admin.entity.BillPersonnelAdmission;
+import com.huimv.admin.entity.dto.PrintAdmissionDto;
+import org.jxls.common.Context;
+import org.jxls.util.JxlsHelper;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class Print {
+    /**
+     * 打印方法  不插入图片
+     *
+     * @return
+     * @throws Exception
+     */
+    public static void printAdmission(List<BillPersonnelAdmission> admissionList) throws Exception {
+
+        //准备数据
+        String path = "G://admission.xls";
+        //获取模板文件,你自己当前模板的位置  我这里为当前项目下
+        InputStream is = new FileInputStream("G://admission.xlsx");
+        //根据模板生成的文件保存路径  我这里保存在本地D盘
+        OutputStream os = new FileOutputStream(path);
+        //绑定数据
+        Context context = new Context();
+        List<PrintAdmissionDto> list = new ArrayList<>();
+        for (BillPersonnelAdmission admission : admissionList) {
+            PrintAdmissionDto dto = new PrintAdmissionDto();
+            dto.setUserName(admission.getAdmissionUserName());
+            dto.setCarNum(admission.getCarNum());
+            dto.setPhone(admission.getPhone());
+            dto.setDestName(admission.getDestName());
+            LocalDateTime date = admission.getVistitDate();
+            DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            dto.setVistitDate(dtf.format(date));
+            dto.setVistitReason(admission.getVistitReson());
+            if (admission.getBillStatus() == 0) {
+                dto.setBillStatus("待审核");
+            } else if (admission.getBillStatus() == 1) {
+                dto.setBillStatus("通过");
+            } else if (admission.getBillStatus() == 2) {
+                dto.setBillStatus("拒绝");
+            }
+
+            if (admission.getVistitType() == 0) {
+                dto.setVistitType("人员");
+            } else if (admission.getVistitType() == 1) {
+                dto.setVistitType("环保车");
+            } else if (admission.getVistitType() == 2) {
+                dto.setVistitType("拉猪车");
+            } else if (admission.getVistitType() == 3) {
+                dto.setVistitType("饲料车");
+            } else if (admission.getVistitType() == 4) {
+                dto.setVistitType("送猪车");
+            } else if (admission.getVistitType() == 5) {
+                dto.setVistitType("物资车");
+            }
+            list.add(dto);
+        }
+        context.putVar("list", list);
+        //生成
+        JxlsHelper.getInstance().processTemplate(is, os, context);
+    }
+
+
+}

+ 33 - 0
huimv-admin/src/main/java/com/huimv/admin/controller/BillPersonnelAdmissionController.java

@@ -3,6 +3,7 @@ package com.huimv.admin.controller;
 
 import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.admin.common.utils.PdfUtil;
 import com.huimv.admin.common.utils.Result;
 import com.huimv.admin.common.utils.ResultCode;
 import com.huimv.admin.entity.BillGoodsInventory;
@@ -24,10 +25,12 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.text.ParseException;
 import java.util.Map;
 
@@ -160,4 +163,34 @@ public class BillPersonnelAdmissionController {
     public Result countAdmission(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) throws ParseException {
         return admissionService.countAdmission(httpServletRequest, paramsMap);
     }
+    @RequestMapping("/listTop")
+    public Result listTop(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) throws ParseException {
+        return admissionService.listTop(httpServletRequest, paramsMap);
+    }
+    @RequestMapping("/admissionTail")
+    public Result admissionTail(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) throws ParseException {
+        return admissionService.admissionTail(httpServletRequest, paramsMap);
+    }
+    @RequestMapping("/selectList")
+    public Result selectList(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) throws ParseException {
+        return admissionService.selectList(httpServletRequest, paramsMap);
+    }
+    @RequestMapping("/delete")
+    public Result delete(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) throws ParseException {
+        String ids = paramsMap.get("ids");
+        String[] split = ids.split(",");
+        for (String s : split) {
+            admissionService.removeById(s);
+        }
+        return new Result(10000, "删除成功!", true);
+    }
+    @GetMapping("/printAdmission")
+    public void printAdmission(HttpServletResponse response, @RequestParam(name = "ids") String ids) throws Exception {
+        Map<String, String> map = new HashMap<>();
+        map.put("ids", ids);
+        admissionService.printAdmission(response, map);
+        String path = "G://admission.xls";
+        PdfUtil.returnPdfStream3(response, path, "人员管理列表");
+    }
+
 }

+ 26 - 0
huimv-admin/src/main/java/com/huimv/admin/entity/dto/PrintAdmissionDto.java

@@ -0,0 +1,26 @@
+package com.huimv.admin.entity.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+
+@Data
+public class PrintAdmissionDto {
+    private String userName;
+
+    private String vistitType;
+
+    private String phone;
+
+    private String carNum;
+
+    private String destName;
+
+    private String vistitDate;
+
+    private String vistitReason;
+
+    private String billStatus;
+}

+ 18 - 0
huimv-admin/src/main/java/com/huimv/admin/entity/vo/BillAdmissionVo.java

@@ -0,0 +1,18 @@
+package com.huimv.admin.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class BillAdmissionVo {
+    private Integer commitCount;
+
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date dateTime;
+
+    private Integer passCount;
+
+    private Integer refuseCount;
+}

+ 3 - 0
huimv-admin/src/main/java/com/huimv/admin/mapper/BillPersonnelAdmissionMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.huimv.admin.entity.BillPersonnelAdmission;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.huimv.admin.entity.vo.BillAdmissionVo;
 import com.huimv.admin.entity.vo.FactoryDirectorVo;
 import com.huimv.admin.entity.vo.ListAdmissionVo;
 import org.apache.ibatis.annotations.Param;
@@ -27,4 +28,6 @@ public interface BillPersonnelAdmissionMapper extends BaseMapper<BillPersonnelAd
     IPage<FactoryDirectorVo> listCarAll(String type, String farmId, Page<FactoryDirectorVo> page);
 
     List<ListAdmissionVo> countAdmission(@Param(Constants.WRAPPER)QueryWrapper<BillPersonnelAdmission> queryWrapper);
+
+    List<BillAdmissionVo> admissionTail(@Param(Constants.WRAPPER)QueryWrapper<BillPersonnelAdmission> queryWrapper);
 }

+ 14 - 2
huimv-admin/src/main/java/com/huimv/admin/service/IBillPersonnelAdmissionService.java

@@ -15,6 +15,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.text.ParseException;
 import java.util.Map;
 
@@ -58,6 +59,17 @@ public interface IBillPersonnelAdmissionService extends IService<BillPersonnelAd
 
     Result getDetail(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
 
-    //后台数据报表
-    Result countAdmission(HttpServletRequest httpServletRequest,Map<String,String> paramsMap);
+    //后台入场申请报表
+    Result countAdmission(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
+    //提交申请排名
+    Result listTop(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
+
+    //入场申请数量曲线
+    Result admissionTail(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
+
+    //详细数据查询
+    Result selectList(HttpServletRequest httpServletRequest, Map<String, String> paramsMap);
+
+    //导出
+    void printAdmission(HttpServletResponse httpServletRequest, Map<String,String> paramsMap) throws Exception;
 }

+ 162 - 10
huimv-admin/src/main/java/com/huimv/admin/service/impl/BillPersonnelAdmissionServiceImpl.java

@@ -4,6 +4,9 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONException;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -14,9 +17,7 @@ import com.huimv.admin.common.utils.DataUill;
 import com.huimv.admin.common.utils.Result;
 import com.huimv.admin.common.utils.ResultCode;
 import com.huimv.admin.entity.*;
-import com.huimv.admin.entity.vo.BillAdmissionAndGoods;
-import com.huimv.admin.entity.vo.CleanAndDryVo2;
-import com.huimv.admin.entity.vo.ListAdmissionVo;
+import com.huimv.admin.entity.vo.*;
 import com.huimv.admin.mapper.*;
 import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -25,10 +26,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.huimv.admin.common.token.TokenSign;
 import com.huimv.admin.common.utils.*;
 import com.huimv.admin.entity.*;
-import com.huimv.admin.entity.vo.FactoryDirectorVo;
 import com.huimv.admin.mapper.*;
 import com.huimv.admin.service.IBillPersonnelAdmissionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import jdk.nashorn.internal.scripts.JS;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -44,6 +45,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -384,20 +386,21 @@ public class BillPersonnelAdmissionServiceImpl extends ServiceImpl<BillPersonnel
             }
         } else if ("2".equals(type)) {
             // 本周
-            DateTime dateTime = DateUtil.beginOfWeek(new Date());
-            queryWrapper.ge("sub_date", dateTime);
+            Calendar calendar = Calendar.getInstance();
+            calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
+            queryWrapper.ge("sub_date", calendar.getTime());
             admissionVo = billPersonnelAdmissionMapper.countAdmission(queryWrapper);
             for (ListAdmissionVo listAdmissionVo : admissionVo) {
                 QueryWrapper<BillPersonnelAdmission> queryWrapper1 = new QueryWrapper<>();
-                queryWrapper1.eq("farm_id", farmId).ge("sub_date", dateTime)
+                queryWrapper1.eq("farm_id", farmId).ge("sub_date", calendar.getTime())
                         .eq("vistit_type", listAdmissionVo.getType()).eq("bill_status", 1);
                 QueryWrapper<BillPersonnelAdmission> queryWrapper2 = new QueryWrapper<>();
-                queryWrapper2.eq("farm_id", farmId).ge("sub_date", dateTime)
+                queryWrapper2.eq("farm_id", farmId).ge("sub_date", calendar.getTime())
                         .eq("vistit_type", listAdmissionVo.getType()).eq("bill_status", 2);
                 listAdmissionVo.setPassCount(billPersonnelAdmissionMapper.selectCount(queryWrapper1));
                 listAdmissionVo.setRefuseCount(billPersonnelAdmissionMapper.selectCount(queryWrapper2));
             }
-        } else {
+        } else if ("3".equals(type)) {
             //本月
             Date timesMonthmorning = DataUill.getTimesMonthmorning();
             queryWrapper.ge("sub_date", timesMonthmorning);
@@ -416,6 +419,155 @@ public class BillPersonnelAdmissionServiceImpl extends ServiceImpl<BillPersonnel
         return new Result(ResultCode.SUCCESS, admissionVo);
     }
 
+    @Override
+    public Result listTop(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
+        String farmId = paramsMap.get("farmId");
+        String type = paramsMap.get("type");
+        if ("".equals(type) || type == null) {
+            type = "1";
+        }
+        List<ListAdmissionVo> admissionVo = null;
+        QueryWrapper<BillPersonnelAdmission> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("farm_id", farmId);
+        //今日
+        if ("1".equals(type)) {
+            Date timesmorning = DataUill.getTimesmorning();
+            queryWrapper.ge("sub_date", timesmorning);
+            admissionVo = billPersonnelAdmissionMapper.countAdmission(queryWrapper);
+        } else if ("2".equals(type)) {
+            // 本周
+            Calendar calendar = Calendar.getInstance();
+            calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
+            queryWrapper.ge("sub_date", calendar.getTime());
+            admissionVo = billPersonnelAdmissionMapper.countAdmission(queryWrapper);
+        } else if ("3".equals(type)) {
+            //本月
+            Date timesMonthmorning = DataUill.getTimesMonthmorning();
+            queryWrapper.ge("sub_date", timesMonthmorning);
+            admissionVo = billPersonnelAdmissionMapper.countAdmission(queryWrapper);
+        }
+        JSONArray jsonArray = new JSONArray();
+        for (ListAdmissionVo listAdmissionVo : admissionVo) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("type", listAdmissionVo.getType());
+            jsonObject.put("count", listAdmissionVo.getCount());
+            jsonArray.add(jsonObject);
+        }
+        JSONArray array = jsonArraySort(jsonArray, "count", true);
+        return new Result(ResultCode.SUCCESS, array);
+    }
+
+    @Override
+    public Result admissionTail(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
+        String farmId = paramsMap.get("farmId");
+        String type = paramsMap.get("type");
+        if ("".equals(type) || type == null) {
+            type = "3";
+        }
+        //今日
+        List<BillAdmissionVo> admissionVos = null;
+        QueryWrapper<BillPersonnelAdmission> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("farm_id", farmId);
+        if ("1".equals(type)) {
+            Date timesmorning = DataUill.getTimesmorning();
+            queryWrapper.ge("sub_date", timesmorning);
+            admissionVos = billPersonnelAdmissionMapper.admissionTail(queryWrapper);
+        } else if ("2".equals(type)) {
+            // 本周
+            Calendar calendar = Calendar.getInstance();
+            calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
+            queryWrapper.ge("sub_date", calendar.getTime());
+            admissionVos = billPersonnelAdmissionMapper.admissionTail(queryWrapper);
+        } else if ("3".equals(type)) {
+            //本月
+            Date timesMonthmorning = DataUill.getTimesMonthmorning();
+            queryWrapper.ge("sub_date", timesMonthmorning);
+            admissionVos = billPersonnelAdmissionMapper.admissionTail(queryWrapper);
+        }
+        return new Result(ResultCode.SUCCESS, admissionVos);
+    }
+
+    @Override
+    public Result selectList(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
+        String farmId = paramsMap.get("farmId");
+        String type = paramsMap.get("type");//来访类型
+        String destId = paramsMap.get("destId");//目的地
+        String startTime = paramsMap.get("startTime");
+        String endTime = paramsMap.get("endTime");
+        String pageNum = paramsMap.get("pageNum");
+        String pageSize = paramsMap.get("pageSize");
+        if ("".equals(pageNum) || null == pageNum) {
+            pageNum = "1";
+        }
+        if ("".equals(pageSize) || null == pageSize) {
+            pageSize = "10";
+        }
+        QueryWrapper<BillPersonnelAdmission> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("farm_id", farmId).eq("dest_id", destId);
+        queryWrapper.between("sub_date", startTime, endTime);
+        Page<BillPersonnelAdmission> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
+        return new Result(ResultCode.SUCCESS, billPersonnelAdmissionMapper.selectPage(page, queryWrapper));
+    }
+
+    @Override
+    public void printAdmission(HttpServletResponse httpServletRequest, Map<String, String> paramsMap) throws Exception {
+        String ids = paramsMap.get("ids");
+        String[] split = ids.split(",");
+        List<BillPersonnelAdmission> list = new ArrayList<>();
+        for (String s : split) {
+            BillPersonnelAdmission admission = billPersonnelAdmissionMapper.selectById(s);
+            list.add(admission);
+        }
+        Print.printAdmission(list);
+    }
+
+    /*数组排序*/
+    public static JSONArray jsonArraySort(JSONArray jsonArr, String sortKey, boolean is_desc) {
+        //存放排序结果json数组
+        JSONArray sortedJsonArray = new JSONArray();
+        //用于排序的list
+        List<JSONObject> jsonValues = new ArrayList<JSONObject>();
+        //将参数json数组每一项取出,放入list
+
+        for (int i = 0; i < jsonArr.size(); i++) {
+            jsonValues.add(jsonArr.getJSONObject(i));
+        }
+        //快速排序,重写compare方法,完成按指定字段比较,完成排序
+        Collections.sort(jsonValues, new Comparator<JSONObject>() {
+            //排序字段
+            private final String KEY_NAME = sortKey;
+
+            //重写compare方法
+            @Override
+            public int compare(JSONObject a, JSONObject b) {
+                //如果用String接会导致一位数和两位数混合比对的时候不能准确比出来,要用int类型接
+                //String valA = new String();
+                //String valB = new String();
+                Float valA = 0.00f;
+                Float valB = 0.00f;
+                try {
+                    valA = Float.parseFloat(a.getString(KEY_NAME));
+                    valB = Float.parseFloat(b.getString(KEY_NAME));
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                }
+                //是升序还是降序
+                if (is_desc) {
+                    return -valA.compareTo(valB);
+                } else {
+                    return -valB.compareTo(valA);
+                }
+
+            }
+        });
+        //将排序后结果放入结果jsonArray
+        for (int i = 0; i < jsonArr.size(); i++) {
+            sortedJsonArray.add(jsonValues.get(i));
+        }
+
+        return sortedJsonArray;
+    }
+
     @Autowired
     private BillPcrMapper pcrMapper;
     @Autowired
@@ -789,7 +941,7 @@ public class BillPersonnelAdmissionServiceImpl extends ServiceImpl<BillPersonnel
             cal1.setTime(startDate);
             cal2.setTime(endDate);
             long days = (cal2.getTimeInMillis() - cal1.getTimeInMillis()) / (1000 * 3600 * 24);
-            billIsolate.setIsolateRealDayNum(Long.toString(days) );
+            billIsolate.setIsolateRealDayNum(Long.toString(days));
             billIsolate.setBillStatus(2);
             billIsolate.setPassUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
             billIsolate.setPassUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));

+ 103 - 103
huimv-admin/src/main/java/com/huimv/admin/timer/CarmeraTimer.java

@@ -1,103 +1,103 @@
-package com.huimv.admin.timer;
-
-import cn.hutool.core.codec.Base64;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.huimv.admin.common.utils.Digests;
-import com.huimv.admin.common.utils.HttpClientSSLUtils;
-import com.huimv.admin.entity.EnvData;
-import com.huimv.admin.entity.EnvDevice;
-import com.huimv.admin.entity.EnvWarningInfo;
-import com.huimv.admin.entity.EnvWarningThreshold;
-import com.huimv.admin.entity.hkwsdto.CameraDto1;
-import com.huimv.admin.entity.hkwsdto.HkvsCameraDto;
-import com.huimv.admin.entity.zengxindto.*;
-import com.huimv.admin.service.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.*;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.client.RestTemplate;
-
-import java.lang.invoke.MethodHandleProxies;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Configuration
-@EnableScheduling
-public class CarmeraTimer {
-    private static final String APPKEY = "1c9ee657";
-    private static final String SECRET = "a5d723941c804a429447e71db2707ce8";
-    private static final String OPENAPI_IP_PORT_HTTP = "http://61.153.248.106:100";
-    private static final String OPENAPI_IP_PORT_HTTPS = "https://61.153.248.106:4430";
-    private static final String ITF_ADDRESS_GET_CAMERAS = "/openapi/service/vss/res/getCameras";
-    private static final String OP_USER_UUID = "5b2eb534696b11e89c2e438f92627767";
-
-    @Autowired
-    private ICameraBaseService cameraBaseService;
-        //数据库账号密码加密
-    //更新摄像头状态
-    @Scheduled(cron = "0 0/10 * * * ? ")
-    private void updateCameraOnlin() throws Exception {
-        String cameras = testGetCameras();
-        HkvsCameraDto hkvsCameraDto = JSONUtil.toBean(cameras, HkvsCameraDto.class);
-        if (ObjectUtil.isNotEmpty(hkvsCameraDto) && hkvsCameraDto.getErrorCode() ==0 ){
-            List<CameraDto1> list = hkvsCameraDto.getData().getList();
-            if (ObjectUtil.isNotEmpty(list)){
-                cameraBaseService.updateCameraOnlin(list);
-            }
-            System.out.println("更新成功");
-        }else {
-            System.out.println("摄像头信息为空");
-        }
-    }
-    /**
-     * HTTP方式
-     * 分页获取监控点信息 测试
-     * @return
-     * @throws Exception
-     */
-    private static String testGetCameras() throws Exception{
-        String url = OPENAPI_IP_PORT_HTTP + ITF_ADDRESS_GET_CAMERAS;
-        Map<String, Object> map = new HashMap<String, Object>();
-        map.put("appkey", APPKEY);//设置APPKEY
-        map.put("time", System.currentTimeMillis());//设置时间参数
-        map.put("pageNo", 1);//设置分页参数
-        map.put("pageSize", 1000);//设置分页参数
-        map.put("opUserUuid", OP_USER_UUID);//设置操作用户UUID
-        String params = JSON.toJSONString(map);
-        System.out.println(" ====== getCameras请求参数:【" + params + "】");
-        String data = HttpClientSSLUtils.doPost(url + "?token=" + Digests.buildToken(url + "?" + params, null, SECRET), params);
-        System.out.println(" ====== getCameras请求返回结果:【{" + data + "}】");
-        return data;
-    }
-
-
-    public static void main(String[] args) {
-        RestTemplate restTemplate = new RestTemplate();
-        String envUrl = "https://dnqyt.envchina.com/api/public/station-data";
-        LocalDate previousDay = LocalDate.now().minusDays(1);
-        LocalDateTime previousDayStart = LocalDateTime.of(previousDay, LocalTime.MIN);
-
-        String sgToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkYW9ub25nIiwidWlkIjozLCJ1biI6IlpYUUxZWktKMjMwN0EyIiwiZXhwIjoxNjg5MDcwNTYxLCJqdGkiOiIzIn0.BEFESZrKOwBej4rxOfoj7qPcHGomh6KN7xbXdjOB__w";
-        HttpHeaders headers = new HttpHeaders();
-        headers.add("token",sgToken);
-        headers.setContentType(MediaType.APPLICATION_JSON);
-        HttpEntity<Map<String, Object>> formEntity = new HttpEntity<Map<String, Object>>(headers);
-
-        String urlWithParams = envUrl + "?type=D&mn=33330424001391" + "&startTime=" + "2023-07-10 00:00:00" + "&endTime=" + "2023-07-10 00:00:00";
-        ResponseEntity<String> result = restTemplate.exchange(urlWithParams, HttpMethod.GET,formEntity,String.class);
-        System.out.println(result);
-    }
-
-}
+//package com.huimv.admin.timer;
+//
+//import cn.hutool.core.codec.Base64;
+//import cn.hutool.core.util.ObjectUtil;
+//import cn.hutool.json.JSONUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+//import com.huimv.admin.common.utils.Digests;
+//import com.huimv.admin.common.utils.HttpClientSSLUtils;
+//import com.huimv.admin.entity.EnvData;
+//import com.huimv.admin.entity.EnvDevice;
+//import com.huimv.admin.entity.EnvWarningInfo;
+//import com.huimv.admin.entity.EnvWarningThreshold;
+//import com.huimv.admin.entity.hkwsdto.CameraDto1;
+//import com.huimv.admin.entity.hkwsdto.HkvsCameraDto;
+//import com.huimv.admin.entity.zengxindto.*;
+//import com.huimv.admin.service.*;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.http.*;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.transaction.annotation.Transactional;
+//import org.springframework.web.client.RestTemplate;
+//
+//import java.lang.invoke.MethodHandleProxies;
+//import java.time.LocalDate;
+//import java.time.LocalDateTime;
+//import java.time.LocalTime;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//@Configuration
+//@EnableScheduling
+//public class CarmeraTimer {
+//    private static final String APPKEY = "1c9ee657";
+//    private static final String SECRET = "a5d723941c804a429447e71db2707ce8";
+//    private static final String OPENAPI_IP_PORT_HTTP = "http://61.153.248.106:100";
+//    private static final String OPENAPI_IP_PORT_HTTPS = "https://61.153.248.106:4430";
+//    private static final String ITF_ADDRESS_GET_CAMERAS = "/openapi/service/vss/res/getCameras";
+//    private static final String OP_USER_UUID = "5b2eb534696b11e89c2e438f92627767";
+//
+//    @Autowired
+//    private ICameraBaseService cameraBaseService;
+//        //数据库账号密码加密
+//    //更新摄像头状态
+//    @Scheduled(cron = "0 0/10 * * * ? ")
+//    private void updateCameraOnlin() throws Exception {
+//        String cameras = testGetCameras();
+//        HkvsCameraDto hkvsCameraDto = JSONUtil.toBean(cameras, HkvsCameraDto.class);
+//        if (ObjectUtil.isNotEmpty(hkvsCameraDto) && hkvsCameraDto.getErrorCode() ==0 ){
+//            List<CameraDto1> list = hkvsCameraDto.getData().getList();
+//            if (ObjectUtil.isNotEmpty(list)){
+//                cameraBaseService.updateCameraOnlin(list);
+//            }
+//            System.out.println("更新成功");
+//        }else {
+//            System.out.println("摄像头信息为空");
+//        }
+//    }
+//    /**
+//     * HTTP方式
+//     * 分页获取监控点信息 测试
+//     * @return
+//     * @throws Exception
+//     */
+//    private static String testGetCameras() throws Exception{
+//        String url = OPENAPI_IP_PORT_HTTP + ITF_ADDRESS_GET_CAMERAS;
+//        Map<String, Object> map = new HashMap<String, Object>();
+//        map.put("appkey", APPKEY);//设置APPKEY
+//        map.put("time", System.currentTimeMillis());//设置时间参数
+//        map.put("pageNo", 1);//设置分页参数
+//        map.put("pageSize", 1000);//设置分页参数
+//        map.put("opUserUuid", OP_USER_UUID);//设置操作用户UUID
+//        String params = JSON.toJSONString(map);
+//        System.out.println(" ====== getCameras请求参数:【" + params + "】");
+//        String data = HttpClientSSLUtils.doPost(url + "?token=" + Digests.buildToken(url + "?" + params, null, SECRET), params);
+//        System.out.println(" ====== getCameras请求返回结果:【{" + data + "}】");
+//        return data;
+//    }
+//
+//
+//    public static void main(String[] args) {
+//        RestTemplate restTemplate = new RestTemplate();
+//        String envUrl = "https://dnqyt.envchina.com/api/public/station-data";
+//        LocalDate previousDay = LocalDate.now().minusDays(1);
+//        LocalDateTime previousDayStart = LocalDateTime.of(previousDay, LocalTime.MIN);
+//
+//        String sgToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkYW9ub25nIiwidWlkIjozLCJ1biI6IlpYUUxZWktKMjMwN0EyIiwiZXhwIjoxNjg5MDcwNTYxLCJqdGkiOiIzIn0.BEFESZrKOwBej4rxOfoj7qPcHGomh6KN7xbXdjOB__w";
+//        HttpHeaders headers = new HttpHeaders();
+//        headers.add("token",sgToken);
+//        headers.setContentType(MediaType.APPLICATION_JSON);
+//        HttpEntity<Map<String, Object>> formEntity = new HttpEntity<Map<String, Object>>(headers);
+//
+//        String urlWithParams = envUrl + "?type=D&mn=33330424001391" + "&startTime=" + "2023-07-10 00:00:00" + "&endTime=" + "2023-07-10 00:00:00";
+//        ResponseEntity<String> result = restTemplate.exchange(urlWithParams, HttpMethod.GET,formEntity,String.class);
+//        System.out.println(result);
+//    }
+//
+//}

+ 151 - 151
huimv-admin/src/main/java/com/huimv/admin/timer/EnergyTimer.java

@@ -1,151 +1,151 @@
-package com.huimv.admin.timer;
-
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.huimv.admin.common.utils.NumberUtils;
-import com.huimv.admin.entity.*;
-import com.huimv.admin.mapper.*;
-import org.apache.commons.lang.time.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-
-import java.text.DecimalFormat;
-import java.util.Date;
-import java.util.List;
-
-@Configuration
-@EnableScheduling
-public class EnergyTimer {
-
-    @Autowired
-    private EnergyEnvDeviceMapper deviceMapper;
-    @Autowired
-    private EnergyDataMapper dataMapper;
-    @Autowired
-    private BasePigpenMapper basePigpenMapper;
-    @Autowired
-    private EnergyWarningThresholdMapper warningThresholdMapper;
-    @Autowired
-    private EnergyWarningInfoMapper infoMapper;
-
-    //    能耗数据
-    @Scheduled(cron = "0 0 */1 * * ? ")
-//    @Scheduled(cron = "0 */1 * * * ? ")
-    private void getShenChan() throws Exception {
-        List<EnergyEnvDevice> energyEnvDevices = deviceMapper.selectList(null);
-
-        for (EnergyEnvDevice energyEnvDevice : energyEnvDevices) {
-            QueryWrapper<BasePigpen> basePigpenQueryWrapper = new QueryWrapper<>();
-            basePigpenQueryWrapper.eq("id", energyEnvDevice.getUnitId()).eq("farm_id", energyEnvDevice.getFarmId());
-            BasePigpen basePigpen1 = basePigpenMapper.selectOne(basePigpenQueryWrapper);
-            QueryWrapper<BasePigpen> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("id", basePigpen1.getParentId());
-            BasePigpen basePigpen = basePigpenMapper.selectOne(queryWrapper);
-
-            String feed = NumberUtils.getNumFloat2(6.00, 6.50);
-            String water = NumberUtils.getNumFloat2(0.08, 0.15);
-//            String gas = NumberUtils.getNum(200, 280, 1);
-            String gas = "0";
-            String electricity = NumberUtils.getNumFloat2(1.0, 1.45);
-
-            EnergyData energyData = new EnergyData();
-            energyData.setCreateDate(new Date());
-            energyData.setFarmId(energyEnvDevice.getFarmId());
-            energyData.setUnitId(energyEnvDevice.getUnitId());
-            if (energyEnvDevice.getFarmId() == 23) {
-                energyData.setFeedValue("0");
-            } else {
-                energyData.setFeedValue(feed);
-            }
-
-            energyData.setWaterValue(water);
-            energyData.setGasValue(gas);
-            energyData.setElectricityValue(electricity);
-            if (energyEnvDevice.getFarmId() == 24) {
-                String feed1 = NumberUtils.getNumFloat2(1.40, 1.50);
-                String water1 = NumberUtils.getNumFloat2(20.80, 20.84);
-                String electricity1 = NumberUtils.getNumFloat2(333.30, 333.34);
-                energyData.setElectricityValue(electricity1);
-                energyData.setWaterValue(water1);
-                energyData.setFeedValue(feed1);
-            }
-            dataMapper.insert(energyData);
-
-            QueryWrapper<EnergyWarningThreshold> wrapper = new QueryWrapper<>();
-            wrapper.eq("other1", basePigpen.getStageCode()).eq("farm_id", energyEnvDevice.getFarmId());
-            EnergyWarningThreshold threshold = warningThresholdMapper.selectOne(wrapper);
-
-            QueryWrapper<EnergyData> dataQueryWrapper = new QueryWrapper<>();
-            dataQueryWrapper.eq("farm_id", energyEnvDevice.getFarmId()).eq("unit_id", energyEnvDevice.getUnitId());
-            DateTime dateTime = DateUtil.beginOfDay(new Date());
-            dataQueryWrapper.ge("create_date", dateTime);
-            EnergyData energyData1 = dataMapper.listDataCount(dataQueryWrapper);
-
-            if (Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water) > Float.parseFloat(threshold.getMaxWater())) {
-                float waterCount = Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water);
-                DecimalFormat df = new DecimalFormat("#.00");
-                String format = df.format(waterCount);
-                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
-                warningInfo.setWarningType(1);
-                warningInfo.setWarningContent("今日累计用水量" + format + "t,超过阈值");
-                warningInfo.setUnitName(basePigpen1.getBuildName());
-                warningInfo.setUnitId(energyEnvDevice.getUnitId());
-                warningInfo.setDeviceId(energyEnvDevice.getId());
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(energyEnvDevice.getFarmId());
-                warningInfo.setUserIds(threshold.getUserIds());
-                infoMapper.insert(warningInfo);
-            }
-            if (Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity) > Float.parseFloat(threshold.getMaxElectricity())) {
-                float electricityCount = Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity);
-                DecimalFormat df = new DecimalFormat("#.00");
-                String format = df.format(electricityCount);
-                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
-                warningInfo.setWarningType(2);
-                warningInfo.setWarningContent("今日累计用电量" + format + "kw/h,超过阈值");
-                warningInfo.setUnitName(basePigpen1.getBuildName());
-                warningInfo.setUnitId(energyEnvDevice.getUnitId());
-                warningInfo.setDeviceId(energyEnvDevice.getId());
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(energyEnvDevice.getFarmId());
-                warningInfo.setUserIds(threshold.getUserIds());
-                infoMapper.insert(warningInfo);
-            }
-            if (Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed) > Float.parseFloat(threshold.getMaxFeed())) {
-                float feedCount = Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed);
-                DecimalFormat df = new DecimalFormat("#.00");
-                String format = df.format(feedCount);
-                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
-                warningInfo.setWarningType(3);
-                warningInfo.setWarningContent("今日累计用料量" + format + "kg,超过阈值");
-                warningInfo.setUnitName(basePigpen.getBuildName());
-                warningInfo.setUnitId(energyEnvDevice.getUnitId());
-                warningInfo.setDeviceId(energyEnvDevice.getId());
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(energyEnvDevice.getFarmId());
-                warningInfo.setUserIds(threshold.getUserIds());
-                infoMapper.insert(warningInfo);
-            }
-            if (Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas) > Float.parseFloat(threshold.getMaxGas())) {
-                float gasCount = Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas);
-                DecimalFormat df = new DecimalFormat("#.00");
-                String format = df.format(gasCount);
-                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
-                warningInfo.setWarningType(4);
-                warningInfo.setWarningContent("今日累计用气量" + format + "m³,超过阈值");
-                warningInfo.setUnitName(basePigpen.getBuildName());
-                warningInfo.setUnitId(energyEnvDevice.getUnitId());
-                warningInfo.setDeviceId(energyEnvDevice.getId());
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(energyEnvDevice.getFarmId());
-                warningInfo.setUserIds(threshold.getUserIds());
-                infoMapper.insert(warningInfo);
-            }
-
-        }
-
-    }
-}
+//package com.huimv.admin.timer;
+//
+//import cn.hutool.core.date.DateTime;
+//import cn.hutool.core.date.DateUtil;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.huimv.admin.common.utils.NumberUtils;
+//import com.huimv.admin.entity.*;
+//import com.huimv.admin.mapper.*;
+//import org.apache.commons.lang.time.DateUtils;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//
+//import java.text.DecimalFormat;
+//import java.util.Date;
+//import java.util.List;
+//
+//@Configuration
+//@EnableScheduling
+//public class EnergyTimer {
+//
+//    @Autowired
+//    private EnergyEnvDeviceMapper deviceMapper;
+//    @Autowired
+//    private EnergyDataMapper dataMapper;
+//    @Autowired
+//    private BasePigpenMapper basePigpenMapper;
+//    @Autowired
+//    private EnergyWarningThresholdMapper warningThresholdMapper;
+//    @Autowired
+//    private EnergyWarningInfoMapper infoMapper;
+//
+//    //    能耗数据
+//    @Scheduled(cron = "0 0 */1 * * ? ")
+////    @Scheduled(cron = "0 */1 * * * ? ")
+//    private void getShenChan() throws Exception {
+//        List<EnergyEnvDevice> energyEnvDevices = deviceMapper.selectList(null);
+//
+//        for (EnergyEnvDevice energyEnvDevice : energyEnvDevices) {
+//            QueryWrapper<BasePigpen> basePigpenQueryWrapper = new QueryWrapper<>();
+//            basePigpenQueryWrapper.eq("id", energyEnvDevice.getUnitId()).eq("farm_id", energyEnvDevice.getFarmId());
+//            BasePigpen basePigpen1 = basePigpenMapper.selectOne(basePigpenQueryWrapper);
+//            QueryWrapper<BasePigpen> queryWrapper = new QueryWrapper<>();
+//            queryWrapper.eq("id", basePigpen1.getParentId());
+//            BasePigpen basePigpen = basePigpenMapper.selectOne(queryWrapper);
+//
+//            String feed = NumberUtils.getNumFloat2(6.00, 6.50);
+//            String water = NumberUtils.getNumFloat2(0.08, 0.15);
+////            String gas = NumberUtils.getNum(200, 280, 1);
+//            String gas = "0";
+//            String electricity = NumberUtils.getNumFloat2(1.0, 1.45);
+//
+//            EnergyData energyData = new EnergyData();
+//            energyData.setCreateDate(new Date());
+//            energyData.setFarmId(energyEnvDevice.getFarmId());
+//            energyData.setUnitId(energyEnvDevice.getUnitId());
+//            if (energyEnvDevice.getFarmId() == 23) {
+//                energyData.setFeedValue("0");
+//            } else {
+//                energyData.setFeedValue(feed);
+//            }
+//
+//            energyData.setWaterValue(water);
+//            energyData.setGasValue(gas);
+//            energyData.setElectricityValue(electricity);
+//            if (energyEnvDevice.getFarmId() == 24) {
+//                String feed1 = NumberUtils.getNumFloat2(1.40, 1.50);
+//                String water1 = NumberUtils.getNumFloat2(20.80, 20.84);
+//                String electricity1 = NumberUtils.getNumFloat2(333.30, 333.34);
+//                energyData.setElectricityValue(electricity1);
+//                energyData.setWaterValue(water1);
+//                energyData.setFeedValue(feed1);
+//            }
+//            dataMapper.insert(energyData);
+//
+//            QueryWrapper<EnergyWarningThreshold> wrapper = new QueryWrapper<>();
+//            wrapper.eq("other1", basePigpen.getStageCode()).eq("farm_id", energyEnvDevice.getFarmId());
+//            EnergyWarningThreshold threshold = warningThresholdMapper.selectOne(wrapper);
+//
+//            QueryWrapper<EnergyData> dataQueryWrapper = new QueryWrapper<>();
+//            dataQueryWrapper.eq("farm_id", energyEnvDevice.getFarmId()).eq("unit_id", energyEnvDevice.getUnitId());
+//            DateTime dateTime = DateUtil.beginOfDay(new Date());
+//            dataQueryWrapper.ge("create_date", dateTime);
+//            EnergyData energyData1 = dataMapper.listDataCount(dataQueryWrapper);
+//
+//            if (Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water) > Float.parseFloat(threshold.getMaxWater())) {
+//                float waterCount = Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water);
+//                DecimalFormat df = new DecimalFormat("#.00");
+//                String format = df.format(waterCount);
+//                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+//                warningInfo.setWarningType(1);
+//                warningInfo.setWarningContent("今日累计用水量" + format + "t,超过阈值");
+//                warningInfo.setUnitName(basePigpen1.getBuildName());
+//                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+//                warningInfo.setDeviceId(energyEnvDevice.getId());
+//                warningInfo.setDate(new Date());
+//                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+//                warningInfo.setUserIds(threshold.getUserIds());
+//                infoMapper.insert(warningInfo);
+//            }
+//            if (Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity) > Float.parseFloat(threshold.getMaxElectricity())) {
+//                float electricityCount = Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity);
+//                DecimalFormat df = new DecimalFormat("#.00");
+//                String format = df.format(electricityCount);
+//                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+//                warningInfo.setWarningType(2);
+//                warningInfo.setWarningContent("今日累计用电量" + format + "kw/h,超过阈值");
+//                warningInfo.setUnitName(basePigpen1.getBuildName());
+//                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+//                warningInfo.setDeviceId(energyEnvDevice.getId());
+//                warningInfo.setDate(new Date());
+//                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+//                warningInfo.setUserIds(threshold.getUserIds());
+//                infoMapper.insert(warningInfo);
+//            }
+//            if (Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed) > Float.parseFloat(threshold.getMaxFeed())) {
+//                float feedCount = Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed);
+//                DecimalFormat df = new DecimalFormat("#.00");
+//                String format = df.format(feedCount);
+//                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+//                warningInfo.setWarningType(3);
+//                warningInfo.setWarningContent("今日累计用料量" + format + "kg,超过阈值");
+//                warningInfo.setUnitName(basePigpen.getBuildName());
+//                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+//                warningInfo.setDeviceId(energyEnvDevice.getId());
+//                warningInfo.setDate(new Date());
+//                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+//                warningInfo.setUserIds(threshold.getUserIds());
+//                infoMapper.insert(warningInfo);
+//            }
+//            if (Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas) > Float.parseFloat(threshold.getMaxGas())) {
+//                float gasCount = Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas);
+//                DecimalFormat df = new DecimalFormat("#.00");
+//                String format = df.format(gasCount);
+//                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+//                warningInfo.setWarningType(4);
+//                warningInfo.setWarningContent("今日累计用气量" + format + "m³,超过阈值");
+//                warningInfo.setUnitName(basePigpen.getBuildName());
+//                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+//                warningInfo.setDeviceId(energyEnvDevice.getId());
+//                warningInfo.setDate(new Date());
+//                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+//                warningInfo.setUserIds(threshold.getUserIds());
+//                infoMapper.insert(warningInfo);
+//            }
+//
+//        }
+//
+//    }
+//}

+ 430 - 430
huimv-admin/src/main/java/com/huimv/admin/timer/EnvTimer.java

@@ -1,430 +1,430 @@
-package com.huimv.admin.timer;
-
-
-import cn.hutool.core.codec.Base64;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.http.HttpUtil;
-import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.huimv.admin.common.utils.HttpClientSSLUtils;
-import com.huimv.admin.common.utils.NumberUtils;
-import com.huimv.admin.entity.*;
-import com.huimv.admin.entity.dto.WeatherDto;
-import com.huimv.admin.entity.dto.WeatherLives;
-import com.huimv.admin.entity.zengxindto.*;
-import com.huimv.admin.service.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.client.RestTemplate;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.NumberFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Configuration
-@EnableScheduling
-public class EnvTimer {
-
-    @Autowired
-    private RestTemplate restTemplate;
-    @Autowired
-    private IEnvDeviceService envDeviceService;
-    @Autowired
-    private IEnvDeviceOnlineService envDeviceOnlineService;
-    @Autowired
-    private IFarmService farmService;
-
-    @Autowired
-    private IBasePigpenService basePigpenService;
-
-    @Autowired
-    private IEnvDataService envDataService;
-    @Autowired
-    private IEnvWarningThresholdService envWarningThresholdService;
-
-    @Autowired
-    private IEnvWarningInfoService envWarningInfoService;
-    //环控数据
-    String username = "华统";
-    String password = "888888";
-    String passwordMD5 = "21218cca77804d2ba1922c33e0151105";
-    String baseurl = "https://yzwlw.loongk.com/";
-
-    @Scheduled(cron = "0 0/11 * * * ? ")
-//    @Scheduled(cron = "0 * * * * ? ")
-    @Transactional
-    public void getHuanKong() throws Exception {
-        //目前是这家
-        Integer farmId = 21;
-        String encode = loginOnly();
-//        System.out.println("encode" + encode);
-        //获取阈值
-        EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId));
-        HttpHeaders headers = new HttpHeaders();
-        headers.add("Authorization", encode);
-        HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
-        //TODO 只有一家,先拿全部
-        List<EnvDevice> list = envDeviceService.list();
-        for (EnvDevice envDevice : list) {
-            if (ObjectUtil.isNotEmpty(envDevice) && StringUtils.isNotBlank(envDevice.getDeviceCode())) {
-                System.out.println(envDevice.getDeviceCode());
-                String shishiBody = "";
-                try {
-                    ResponseEntity<String> exchange = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackDatas/" + envDevice.getDeviceCode(), HttpMethod.GET, requestEntity, String.class);
-                    shishiBody = exchange.getBody();
-                } catch (Exception e) {
-                    System.out.println(e);
-                }
-
-                if (StringUtils.isBlank(shishiBody)) {
-                    System.out.println(new Date() + "实时数据" + shishiBody);
-                    continue;
-                }
-                ShackDatasDto shackDatasDto = JSONUtil.toBean(shishiBody, ShackDatasDto.class);
-
-                ShackDatasDataDto data = shackDatasDto.getData();
-                if (ObjectUtil.isEmpty(data)){
-                    continue;
-                }
-                String onLine = shackDatasDto.getData().getOnLine();
-                if ("N".equals(onLine)) {
-                    envDevice.setDeviceStatus(0);
-                } else {
-                    envDevice.setDeviceStatus(1);
-                }
-                envDeviceService.updateById(envDevice);
-                List<ShackDatasSensor> sensorDatas = shackDatasDto.getData().getSensorDatas();
-                EnvData envData = new EnvData();
-                for (ShackDatasSensor sensorData : sensorDatas) {
-                    if (sensorData.getId().equals(envDevice.getOhter1())) {
-                        String val = sensorData.getVal();
-                        //TODO 预警
-                        saveTemWarning(val, envWarningThreshold, envDevice, farmId);
-                        envData.setEnvTemp(val);
-                    }
-                    if (sensorData.getId().equals(envDevice.getOhter2())) {
-                        String val = sensorData.getVal();
-                        //TODO 预警
-                        saveHumWarning(val, envWarningThreshold, envDevice, farmId);
-                        envData.setEnvHum(val);
-                    }
-                }
-                envData.setCreateTime(new Date());
-                envData.setDeviceId(envDevice.getDeviceCode());
-                envData.setFarmId(farmId);
-                envData.setUnitId(envDevice.getUnitId());
-                envDataService.save(envData);
-            }
-        }
-    }
-
-    @Scheduled(cron = "0 0/12 * * * ?")
-    @Transactional
-    public void getHuanKongs()  {
-        Integer farmId = 21;
-        EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId));
-
-        List<BasePigpen> list = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId).eq("f_type", 3).ne("id", 178).ne("id", 181));
-//        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
-//        String result = HttpUtil.get(url);
-//        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
-//        List<WeatherLives> lives = weatherDto.getLives();
-//        WeatherLives weatherLives = lives.get(0);
-//        int humidity = Integer.parseInt(weatherLives.getHumidity());
-//        int temperature = Integer.parseInt(weatherLives.getTemperature());
-
-        for (BasePigpen basePigpen : list) {
-            EnvData envData = new EnvData();
-            envData.setCreateTime(new Date());
-            envData.setFarmId(farmId);
-            envData.setUnitId(basePigpen.getId());
-            EnvDevice envDevice = new EnvDevice();
-            envDevice.setUnitName(basePigpen.getBuildName());
-            envDevice.setUnitId(basePigpen.getId());
-            envDevice.setFarmId(farmId);
-
-            String tem = NumberUtils.getNum(17, 23, 1);
-            String hum = NumberUtils.getNum(65, 80, 0);
-            saveTemWarning(tem, envWarningThreshold, envDevice, farmId);
-            envData.setEnvTemp(tem);
-            saveHumWarning(hum, envWarningThreshold, envDevice, farmId);
-            envData.setEnvHum(hum);
-            envDataService.save(envData);
-        }
-        Integer farmId1 = 23;
-        EnvWarningThreshold envWarningThreshold1 = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId1));
-
-        List<BasePigpen> list1 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId1).eq("f_type", 3).ne("id", 225));
-//        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
-//        String result = HttpUtil.get(url);
-//        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
-//        List<WeatherLives> lives = weatherDto.getLives();
-//        WeatherLives weatherLives = lives.get(0);
-//        int humidity = Integer.parseInt(weatherLives.getHumidity());
-//        int temperature = Integer.parseInt(weatherLives.getTemperature());
-
-        for (BasePigpen basePigpen : list1) {
-            EnvData envData = new EnvData();
-            envData.setCreateTime(new Date());
-            envData.setFarmId(farmId1);
-            envData.setUnitId(basePigpen.getId());
-            EnvDevice envDevice = new EnvDevice();
-            envDevice.setUnitName(basePigpen.getBuildName());
-            envDevice.setUnitId(basePigpen.getId());
-            envDevice.setFarmId(farmId1);
-
-            String tem = NumberUtils.getNum(17, 23, 1);
-            String hum = NumberUtils.getNum(65, 80, 0);
-            saveTemWarning(tem, envWarningThreshold1, envDevice, farmId1);
-            envData.setEnvTemp(tem);
-            saveHumWarning(hum, envWarningThreshold1, envDevice, farmId1);
-            envData.setEnvHum(hum);
-            envDataService.save(envData);
-        }
-        Integer farmId2 = 24;
-        EnvWarningThreshold envWarningThreshold2 = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId2));
-
-        List<BasePigpen> list2 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId2).eq("f_type", 3).ne("id", 217));
-//        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
-//        String result = HttpUtil.get(url);
-//        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
-//        List<WeatherLives> lives = weatherDto.getLives();
-//        WeatherLives weatherLives = lives.get(0);
-//        int humidity = Integer.parseInt(weatherLives.getHumidity());
-//        int temperature = Integer.parseInt(weatherLives.getTemperature());
-
-        for (BasePigpen basePigpen : list2) {
-            EnvData envData = new EnvData();
-            envData.setCreateTime(new Date());
-            envData.setFarmId(farmId2);
-            envData.setUnitId(basePigpen.getId());
-            EnvDevice envDevice = new EnvDevice();
-            envDevice.setUnitName(basePigpen.getBuildName());
-            envDevice.setUnitId(basePigpen.getId());
-            envDevice.setFarmId(farmId2);
-
-            String tem = NumberUtils.getNum(17, 23, 1);
-            String hum = NumberUtils.getNum(65, 80, 0);
-            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId2);
-            envData.setEnvTemp(tem);
-            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId2);
-            envData.setEnvHum(hum);
-            envDataService.save(envData);
-        }
-
-        Integer farmId3 = 26;
-        List<BasePigpen> list3 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId3).eq("f_type", 3));
-//        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
-//        String result = HttpUtil.get(url);
-//        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
-//        List<WeatherLives> lives = weatherDto.getLives();
-//        WeatherLives weatherLives = lives.get(0);
-//        int humidity = Integer.parseInt(weatherLives.getHumidity());
-//        int temperature = Integer.parseInt(weatherLives.getTemperature());
-
-        for (BasePigpen basePigpen : list3) {
-            EnvData envData = new EnvData();
-            envData.setCreateTime(new Date());
-            envData.setFarmId(farmId3);
-            envData.setUnitId(basePigpen.getId());
-            EnvDevice envDevice = new EnvDevice();
-            envDevice.setUnitName(basePigpen.getBuildName());
-            envDevice.setUnitId(basePigpen.getId());
-            envDevice.setFarmId(farmId3);
-
-            String tem = NumberUtils.getNum(17, 23, 1);
-            String hum = NumberUtils.getNum(65, 80, 0);
-            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId3);
-            envData.setEnvTemp(tem);
-            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId3);
-            envData.setEnvHum(hum);
-            envDataService.save(envData);
-        }
-
-        Integer farmId4 = 27;
-        List<BasePigpen> list4 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId4).eq("f_type", 3));
-//        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
-//        String result = HttpUtil.get(url);
-//        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
-//        List<WeatherLives> lives = weatherDto.getLives();
-//        WeatherLives weatherLives = lives.get(0);
-//        int humidity = Integer.parseInt(weatherLives.getHumidity());
-//        int temperature = Integer.parseInt(weatherLives.getTemperature());
-
-        for (BasePigpen basePigpen : list4) {
-            EnvData envData = new EnvData();
-            envData.setCreateTime(new Date());
-            envData.setFarmId(farmId4);
-            envData.setUnitId(basePigpen.getId());
-            EnvDevice envDevice = new EnvDevice();
-            envDevice.setUnitName(basePigpen.getBuildName());
-            envDevice.setUnitId(basePigpen.getId());
-            envDevice.setFarmId(farmId4);
-
-            String tem = NumberUtils.getNum(17, 23, 1);
-            String hum = NumberUtils.getNum(65, 80, 0);
-            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId4);
-            envData.setEnvTemp(tem);
-            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId4);
-            envData.setEnvHum(hum);
-            envDataService.save(envData);
-        }
-    }
-
-    public void saveHumWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice, Integer farmId) {
-        if (StringUtils.isNotBlank(val)) {
-            String maxHum;
-            String minHum;
-            if (ObjectUtil.isEmpty(envWarningThreshold) || StringUtils.isBlank(envWarningThreshold.getMaxHum())) {
-                maxHum = "90";
-            } else {
-                maxHum = envWarningThreshold.getMaxHum();
-            }
-            if (ObjectUtil.isEmpty(envWarningThreshold) || StringUtils.isBlank(envWarningThreshold.getMinHum())) {
-                minHum = "0";
-            } else {
-                minHum = envWarningThreshold.getMinHum();
-            }
-            if (Double.parseDouble(maxHum) < Double.parseDouble(val)) {
-                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
-                envWarningInfo.setBuildLocation(envDevice.getUnitName());
-                envWarningInfo.setDate(new Date());
-                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
-                envWarningInfo.setFarmId(envDevice.getFarmId());
-                envWarningInfo.setUnitId(envDevice.getUnitId());
-                envWarningInfo.setUnitName(envDevice.getUnitName());
-                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
-                envWarningInfo.setWarningContent("当前湿度为" + val + "%超过阈值,请及时检查");
-                envWarningInfo.setWarningType(2);
-                envWarningInfoService.save(envWarningInfo);
-            }
-            if (Double.parseDouble(minHum) > Double.parseDouble(val)) {
-                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
-                envWarningInfo.setBuildLocation(envDevice.getUnitName());
-                envWarningInfo.setDate(new Date());
-                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
-                envWarningInfo.setFarmId(envDevice.getFarmId());
-                envWarningInfo.setUnitId(envDevice.getUnitId());
-                envWarningInfo.setUnitName(envDevice.getUnitName());
-                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
-                envWarningInfo.setWarningContent("当前湿度为" + val + "%低于阈值,请及时检查");
-                envWarningInfo.setWarningType(2);
-                envWarningInfoService.save(envWarningInfo);
-            }
-        }
-    }
-
-    private void saveTemWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice, Integer farmId) {
-        if (StringUtils.isNotBlank(val)) {
-            String maxTem;
-            String minTem;
-            if (ObjectUtil.isEmpty(envWarningThreshold) || StringUtils.isBlank(envWarningThreshold.getMaxTem())) {
-                maxTem = "40";
-            } else {
-                maxTem = envWarningThreshold.getMaxTem();
-            }
-            if (ObjectUtil.isEmpty(envWarningThreshold) || StringUtils.isBlank(envWarningThreshold.getMinTem())) {
-                minTem = "0";
-            } else {
-                minTem = envWarningThreshold.getMinTem();
-            }
-            System.out.println("maxTem:" + Double.parseDouble(maxTem) + "  minTem:" + Double.parseDouble(minTem) + "   val:" + Double.parseDouble(val));
-            if (Double.parseDouble(maxTem) < Double.parseDouble(val)) {
-                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
-                envWarningInfo.setBuildLocation(envDevice.getUnitName());
-                envWarningInfo.setDate(new Date());
-                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
-                envWarningInfo.setFarmId(envDevice.getFarmId());
-                envWarningInfo.setUnitId(envDevice.getUnitId());
-                envWarningInfo.setUnitName(envDevice.getUnitName());
-                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
-                envWarningInfo.setWarningContent("当前温度为" + val + "°超过阈值,请及时检查");
-                envWarningInfo.setWarningType(1);
-                envWarningInfoService.save(envWarningInfo);
-            }
-            if (Double.parseDouble(minTem) > Double.parseDouble(val)) {
-                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
-                envWarningInfo.setBuildLocation(envDevice.getUnitName());
-                envWarningInfo.setDate(new Date());
-                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
-                envWarningInfo.setFarmId(envDevice.getFarmId());
-                envWarningInfo.setUnitId(envDevice.getUnitId());
-                envWarningInfo.setUnitName(envDevice.getUnitName());
-                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
-                envWarningInfo.setWarningContent("当前温度为" + val + "°低于阈值,请及时检查");
-                envWarningInfo.setWarningType(1);
-                envWarningInfoService.save(envWarningInfo);
-            }
-        }
-    }
-
-    private String loginOnly() throws Exception {
-        Map<String, Object> map = new HashMap<String, Object>();
-        String s = HttpClientSSLUtils.doPost(baseurl + "/mobile/login?username=" + username + "&password=" + passwordMD5, JSON.toJSONString(map));
-        LoginOnlyDto loginDto = JSONUtil.toBean(s, LoginOnlyDto.class);
-        LonginOnlyDtoToken token = loginDto.getData().getToken();
-        return Base64.encode(token.getUserId() + "_" + token.getToken());
-    }
-
-    @Scheduled(cron = "0 0 0 * * ? ")
-    public void update() throws Exception {
-        Date date = new Date();
-        DateTime beginOfMonth = DateUtil.beginOfMonth(date);
-        List<Farm> list = farmService.list();
-        for (Farm farm : list) {
-            Integer farmId = farm.getId();
-            QueryWrapper<EnvDevice> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("farm_id", farmId);
-            Integer count = envDeviceService.count(queryWrapper);
-            QueryWrapper<EnvDevice> queryWrapper1 = new QueryWrapper<>();
-            queryWrapper1.eq("device_status", 0).eq("farm_id", farmId);
-            Integer count1 = envDeviceService.count(queryWrapper1);//离线
-            Integer OnDeviceCount = count - count1;//在线
-            //创建一个数值格式化对象
-            NumberFormat numberFormat = NumberFormat.getInstance();
-            //设置精确到小数点后两位
-            numberFormat.setMaximumFractionDigits(2);
-            String onDeviceRate = numberFormat.format((float) OnDeviceCount / (float) count * 100);
-
-            EnvDeviceOnline envDeviceOnline = envDeviceOnlineService.getOne(new QueryWrapper<EnvDeviceOnline>().eq("farm_id", farmId).ge("creat_time", beginOfMonth));
-            if (ObjectUtil.isEmpty(envDeviceOnline)) {
-                envDeviceOnline = new EnvDeviceOnline();
-                envDeviceOnline.setCreatTime(date);
-                envDeviceOnline.setDeviceOff(count1);
-                envDeviceOnline.setDeviceOn(OnDeviceCount);
-                envDeviceOnline.setFarmId(farmId + "");
-                envDeviceOnline.setOnlineRate(onDeviceRate);
-                envDeviceOnline.setNowMonth(beginOfMonth.month());
-                envDeviceOnline.setNowYear(beginOfMonth.year());
-                envDeviceOnlineService.save(envDeviceOnline);
-            } else {
-                envDeviceOnline = new EnvDeviceOnline();
-                envDeviceOnline.setCreatTime(date);
-                envDeviceOnline.setDeviceOff(count1);
-                envDeviceOnline.setDeviceOn(OnDeviceCount);
-                envDeviceOnline.setFarmId(farmId + "");
-                envDeviceOnline.setOnlineRate(onDeviceRate);
-                envDeviceOnline.setNowMonth(beginOfMonth.month());
-                envDeviceOnline.setNowYear(beginOfMonth.year());
-                envDeviceOnlineService.updateById(envDeviceOnline);
-            }
-
-        }
-
-    }
-
-}
+//package com.huimv.admin.timer;
+//
+//
+//import cn.hutool.core.codec.Base64;
+//import cn.hutool.core.date.DateTime;
+//import cn.hutool.core.date.DateUtil;
+//import cn.hutool.core.util.ObjectUtil;
+//import cn.hutool.http.HttpUtil;
+//import cn.hutool.json.JSONUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+//import com.huimv.admin.common.utils.HttpClientSSLUtils;
+//import com.huimv.admin.common.utils.NumberUtils;
+//import com.huimv.admin.entity.*;
+//import com.huimv.admin.entity.dto.WeatherDto;
+//import com.huimv.admin.entity.dto.WeatherLives;
+//import com.huimv.admin.entity.zengxindto.*;
+//import com.huimv.admin.service.*;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.http.HttpEntity;
+//import org.springframework.http.HttpHeaders;
+//import org.springframework.http.HttpMethod;
+//import org.springframework.http.ResponseEntity;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.transaction.annotation.Transactional;
+//import org.springframework.web.client.RestTemplate;
+//
+//import javax.servlet.http.HttpServletRequest;
+//import java.text.NumberFormat;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//@Configuration
+//@EnableScheduling
+//public class EnvTimer {
+//
+//    @Autowired
+//    private RestTemplate restTemplate;
+//    @Autowired
+//    private IEnvDeviceService envDeviceService;
+//    @Autowired
+//    private IEnvDeviceOnlineService envDeviceOnlineService;
+//    @Autowired
+//    private IFarmService farmService;
+//
+//    @Autowired
+//    private IBasePigpenService basePigpenService;
+//
+//    @Autowired
+//    private IEnvDataService envDataService;
+//    @Autowired
+//    private IEnvWarningThresholdService envWarningThresholdService;
+//
+//    @Autowired
+//    private IEnvWarningInfoService envWarningInfoService;
+//    //环控数据
+//    String username = "华统";
+//    String password = "888888";
+//    String passwordMD5 = "21218cca77804d2ba1922c33e0151105";
+//    String baseurl = "https://yzwlw.loongk.com/";
+//
+//    @Scheduled(cron = "0 0/11 * * * ? ")
+////    @Scheduled(cron = "0 * * * * ? ")
+//    @Transactional
+//    public void getHuanKong() throws Exception {
+//        //目前是这家
+//        Integer farmId = 21;
+//        String encode = loginOnly();
+////        System.out.println("encode" + encode);
+//        //获取阈值
+//        EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId));
+//        HttpHeaders headers = new HttpHeaders();
+//        headers.add("Authorization", encode);
+//        HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
+//        //TODO 只有一家,先拿全部
+//        List<EnvDevice> list = envDeviceService.list();
+//        for (EnvDevice envDevice : list) {
+//            if (ObjectUtil.isNotEmpty(envDevice) && StringUtils.isNotBlank(envDevice.getDeviceCode())) {
+//                System.out.println(envDevice.getDeviceCode());
+//                String shishiBody = "";
+//                try {
+//                    ResponseEntity<String> exchange = restTemplate.exchange("https://yzwlw.loongk.com/mobile/loadShackDatas/" + envDevice.getDeviceCode(), HttpMethod.GET, requestEntity, String.class);
+//                    shishiBody = exchange.getBody();
+//                } catch (Exception e) {
+//                    System.out.println(e);
+//                }
+//
+//                if (StringUtils.isBlank(shishiBody)) {
+//                    System.out.println(new Date() + "实时数据" + shishiBody);
+//                    continue;
+//                }
+//                ShackDatasDto shackDatasDto = JSONUtil.toBean(shishiBody, ShackDatasDto.class);
+//
+//                ShackDatasDataDto data = shackDatasDto.getData();
+//                if (ObjectUtil.isEmpty(data)){
+//                    continue;
+//                }
+//                String onLine = shackDatasDto.getData().getOnLine();
+//                if ("N".equals(onLine)) {
+//                    envDevice.setDeviceStatus(0);
+//                } else {
+//                    envDevice.setDeviceStatus(1);
+//                }
+//                envDeviceService.updateById(envDevice);
+//                List<ShackDatasSensor> sensorDatas = shackDatasDto.getData().getSensorDatas();
+//                EnvData envData = new EnvData();
+//                for (ShackDatasSensor sensorData : sensorDatas) {
+//                    if (sensorData.getId().equals(envDevice.getOhter1())) {
+//                        String val = sensorData.getVal();
+//                        //TODO 预警
+//                        saveTemWarning(val, envWarningThreshold, envDevice, farmId);
+//                        envData.setEnvTemp(val);
+//                    }
+//                    if (sensorData.getId().equals(envDevice.getOhter2())) {
+//                        String val = sensorData.getVal();
+//                        //TODO 预警
+//                        saveHumWarning(val, envWarningThreshold, envDevice, farmId);
+//                        envData.setEnvHum(val);
+//                    }
+//                }
+//                envData.setCreateTime(new Date());
+//                envData.setDeviceId(envDevice.getDeviceCode());
+//                envData.setFarmId(farmId);
+//                envData.setUnitId(envDevice.getUnitId());
+//                envDataService.save(envData);
+//            }
+//        }
+//    }
+//
+//    @Scheduled(cron = "0 0/12 * * * ?")
+//    @Transactional
+//    public void getHuanKongs()  {
+//        Integer farmId = 21;
+//        EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId));
+//
+//        List<BasePigpen> list = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId).eq("f_type", 3).ne("id", 178).ne("id", 181));
+////        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
+////        String result = HttpUtil.get(url);
+////        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
+////        List<WeatherLives> lives = weatherDto.getLives();
+////        WeatherLives weatherLives = lives.get(0);
+////        int humidity = Integer.parseInt(weatherLives.getHumidity());
+////        int temperature = Integer.parseInt(weatherLives.getTemperature());
+//
+//        for (BasePigpen basePigpen : list) {
+//            EnvData envData = new EnvData();
+//            envData.setCreateTime(new Date());
+//            envData.setFarmId(farmId);
+//            envData.setUnitId(basePigpen.getId());
+//            EnvDevice envDevice = new EnvDevice();
+//            envDevice.setUnitName(basePigpen.getBuildName());
+//            envDevice.setUnitId(basePigpen.getId());
+//            envDevice.setFarmId(farmId);
+//
+//            String tem = NumberUtils.getNum(17, 23, 1);
+//            String hum = NumberUtils.getNum(65, 80, 0);
+//            saveTemWarning(tem, envWarningThreshold, envDevice, farmId);
+//            envData.setEnvTemp(tem);
+//            saveHumWarning(hum, envWarningThreshold, envDevice, farmId);
+//            envData.setEnvHum(hum);
+//            envDataService.save(envData);
+//        }
+//        Integer farmId1 = 23;
+//        EnvWarningThreshold envWarningThreshold1 = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId1));
+//
+//        List<BasePigpen> list1 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId1).eq("f_type", 3).ne("id", 225));
+////        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
+////        String result = HttpUtil.get(url);
+////        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
+////        List<WeatherLives> lives = weatherDto.getLives();
+////        WeatherLives weatherLives = lives.get(0);
+////        int humidity = Integer.parseInt(weatherLives.getHumidity());
+////        int temperature = Integer.parseInt(weatherLives.getTemperature());
+//
+//        for (BasePigpen basePigpen : list1) {
+//            EnvData envData = new EnvData();
+//            envData.setCreateTime(new Date());
+//            envData.setFarmId(farmId1);
+//            envData.setUnitId(basePigpen.getId());
+//            EnvDevice envDevice = new EnvDevice();
+//            envDevice.setUnitName(basePigpen.getBuildName());
+//            envDevice.setUnitId(basePigpen.getId());
+//            envDevice.setFarmId(farmId1);
+//
+//            String tem = NumberUtils.getNum(17, 23, 1);
+//            String hum = NumberUtils.getNum(65, 80, 0);
+//            saveTemWarning(tem, envWarningThreshold1, envDevice, farmId1);
+//            envData.setEnvTemp(tem);
+//            saveHumWarning(hum, envWarningThreshold1, envDevice, farmId1);
+//            envData.setEnvHum(hum);
+//            envDataService.save(envData);
+//        }
+//        Integer farmId2 = 24;
+//        EnvWarningThreshold envWarningThreshold2 = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId2));
+//
+//        List<BasePigpen> list2 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId2).eq("f_type", 3).ne("id", 217));
+////        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
+////        String result = HttpUtil.get(url);
+////        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
+////        List<WeatherLives> lives = weatherDto.getLives();
+////        WeatherLives weatherLives = lives.get(0);
+////        int humidity = Integer.parseInt(weatherLives.getHumidity());
+////        int temperature = Integer.parseInt(weatherLives.getTemperature());
+//
+//        for (BasePigpen basePigpen : list2) {
+//            EnvData envData = new EnvData();
+//            envData.setCreateTime(new Date());
+//            envData.setFarmId(farmId2);
+//            envData.setUnitId(basePigpen.getId());
+//            EnvDevice envDevice = new EnvDevice();
+//            envDevice.setUnitName(basePigpen.getBuildName());
+//            envDevice.setUnitId(basePigpen.getId());
+//            envDevice.setFarmId(farmId2);
+//
+//            String tem = NumberUtils.getNum(17, 23, 1);
+//            String hum = NumberUtils.getNum(65, 80, 0);
+//            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId2);
+//            envData.setEnvTemp(tem);
+//            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId2);
+//            envData.setEnvHum(hum);
+//            envDataService.save(envData);
+//        }
+//
+//        Integer farmId3 = 26;
+//        List<BasePigpen> list3 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId3).eq("f_type", 3));
+////        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
+////        String result = HttpUtil.get(url);
+////        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
+////        List<WeatherLives> lives = weatherDto.getLives();
+////        WeatherLives weatherLives = lives.get(0);
+////        int humidity = Integer.parseInt(weatherLives.getHumidity());
+////        int temperature = Integer.parseInt(weatherLives.getTemperature());
+//
+//        for (BasePigpen basePigpen : list3) {
+//            EnvData envData = new EnvData();
+//            envData.setCreateTime(new Date());
+//            envData.setFarmId(farmId3);
+//            envData.setUnitId(basePigpen.getId());
+//            EnvDevice envDevice = new EnvDevice();
+//            envDevice.setUnitName(basePigpen.getBuildName());
+//            envDevice.setUnitId(basePigpen.getId());
+//            envDevice.setFarmId(farmId3);
+//
+//            String tem = NumberUtils.getNum(17, 23, 1);
+//            String hum = NumberUtils.getNum(65, 80, 0);
+//            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId3);
+//            envData.setEnvTemp(tem);
+//            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId3);
+//            envData.setEnvHum(hum);
+//            envDataService.save(envData);
+//        }
+//
+//        Integer farmId4 = 27;
+//        List<BasePigpen> list4 = basePigpenService.list(new QueryWrapper<BasePigpen>().eq("farm_id", farmId4).eq("f_type", 3));
+////        String url="https://restapi.amap.com/v3/weather/weatherInfo?parameters&key=c1d8179ed2dda7ed48c56bed06c0c86e&city=330782&extensions=base&output=JSON";
+////        String result = HttpUtil.get(url);
+////        WeatherDto weatherDto = JSONUtil.toBean(result, WeatherDto.class);
+////        List<WeatherLives> lives = weatherDto.getLives();
+////        WeatherLives weatherLives = lives.get(0);
+////        int humidity = Integer.parseInt(weatherLives.getHumidity());
+////        int temperature = Integer.parseInt(weatherLives.getTemperature());
+//
+//        for (BasePigpen basePigpen : list4) {
+//            EnvData envData = new EnvData();
+//            envData.setCreateTime(new Date());
+//            envData.setFarmId(farmId4);
+//            envData.setUnitId(basePigpen.getId());
+//            EnvDevice envDevice = new EnvDevice();
+//            envDevice.setUnitName(basePigpen.getBuildName());
+//            envDevice.setUnitId(basePigpen.getId());
+//            envDevice.setFarmId(farmId4);
+//
+//            String tem = NumberUtils.getNum(17, 23, 1);
+//            String hum = NumberUtils.getNum(65, 80, 0);
+//            saveTemWarning(tem, envWarningThreshold2, envDevice, farmId4);
+//            envData.setEnvTemp(tem);
+//            saveHumWarning(hum, envWarningThreshold2, envDevice, farmId4);
+//            envData.setEnvHum(hum);
+//            envDataService.save(envData);
+//        }
+//    }
+//
+//    public void saveHumWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice, Integer farmId) {
+//        if (StringUtils.isNotBlank(val)) {
+//            String maxHum;
+//            String minHum;
+//            if (ObjectUtil.isEmpty(envWarningThreshold) || StringUtils.isBlank(envWarningThreshold.getMaxHum())) {
+//                maxHum = "90";
+//            } else {
+//                maxHum = envWarningThreshold.getMaxHum();
+//            }
+//            if (ObjectUtil.isEmpty(envWarningThreshold) || StringUtils.isBlank(envWarningThreshold.getMinHum())) {
+//                minHum = "0";
+//            } else {
+//                minHum = envWarningThreshold.getMinHum();
+//            }
+//            if (Double.parseDouble(maxHum) < Double.parseDouble(val)) {
+//                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
+//                envWarningInfo.setBuildLocation(envDevice.getUnitName());
+//                envWarningInfo.setDate(new Date());
+//                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
+//                envWarningInfo.setFarmId(envDevice.getFarmId());
+//                envWarningInfo.setUnitId(envDevice.getUnitId());
+//                envWarningInfo.setUnitName(envDevice.getUnitName());
+//                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
+//                envWarningInfo.setWarningContent("当前湿度为" + val + "%超过阈值,请及时检查");
+//                envWarningInfo.setWarningType(2);
+//                envWarningInfoService.save(envWarningInfo);
+//            }
+//            if (Double.parseDouble(minHum) > Double.parseDouble(val)) {
+//                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
+//                envWarningInfo.setBuildLocation(envDevice.getUnitName());
+//                envWarningInfo.setDate(new Date());
+//                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
+//                envWarningInfo.setFarmId(envDevice.getFarmId());
+//                envWarningInfo.setUnitId(envDevice.getUnitId());
+//                envWarningInfo.setUnitName(envDevice.getUnitName());
+//                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
+//                envWarningInfo.setWarningContent("当前湿度为" + val + "%低于阈值,请及时检查");
+//                envWarningInfo.setWarningType(2);
+//                envWarningInfoService.save(envWarningInfo);
+//            }
+//        }
+//    }
+//
+//    private void saveTemWarning(String val, EnvWarningThreshold envWarningThreshold, EnvDevice envDevice, Integer farmId) {
+//        if (StringUtils.isNotBlank(val)) {
+//            String maxTem;
+//            String minTem;
+//            if (ObjectUtil.isEmpty(envWarningThreshold) || StringUtils.isBlank(envWarningThreshold.getMaxTem())) {
+//                maxTem = "40";
+//            } else {
+//                maxTem = envWarningThreshold.getMaxTem();
+//            }
+//            if (ObjectUtil.isEmpty(envWarningThreshold) || StringUtils.isBlank(envWarningThreshold.getMinTem())) {
+//                minTem = "0";
+//            } else {
+//                minTem = envWarningThreshold.getMinTem();
+//            }
+//            System.out.println("maxTem:" + Double.parseDouble(maxTem) + "  minTem:" + Double.parseDouble(minTem) + "   val:" + Double.parseDouble(val));
+//            if (Double.parseDouble(maxTem) < Double.parseDouble(val)) {
+//                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
+//                envWarningInfo.setBuildLocation(envDevice.getUnitName());
+//                envWarningInfo.setDate(new Date());
+//                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
+//                envWarningInfo.setFarmId(envDevice.getFarmId());
+//                envWarningInfo.setUnitId(envDevice.getUnitId());
+//                envWarningInfo.setUnitName(envDevice.getUnitName());
+//                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
+//                envWarningInfo.setWarningContent("当前温度为" + val + "°超过阈值,请及时检查");
+//                envWarningInfo.setWarningType(1);
+//                envWarningInfoService.save(envWarningInfo);
+//            }
+//            if (Double.parseDouble(minTem) > Double.parseDouble(val)) {
+//                EnvWarningInfo envWarningInfo = new EnvWarningInfo();
+//                envWarningInfo.setBuildLocation(envDevice.getUnitName());
+//                envWarningInfo.setDate(new Date());
+//                envWarningInfo.setDeviceId(envDevice.getDeviceCode());
+//                envWarningInfo.setFarmId(envDevice.getFarmId());
+//                envWarningInfo.setUnitId(envDevice.getUnitId());
+//                envWarningInfo.setUnitName(envDevice.getUnitName());
+//                envWarningInfo.setUserIds(envWarningThreshold.getUserIds());
+//                envWarningInfo.setWarningContent("当前温度为" + val + "°低于阈值,请及时检查");
+//                envWarningInfo.setWarningType(1);
+//                envWarningInfoService.save(envWarningInfo);
+//            }
+//        }
+//    }
+//
+//    private String loginOnly() throws Exception {
+//        Map<String, Object> map = new HashMap<String, Object>();
+//        String s = HttpClientSSLUtils.doPost(baseurl + "/mobile/login?username=" + username + "&password=" + passwordMD5, JSON.toJSONString(map));
+//        LoginOnlyDto loginDto = JSONUtil.toBean(s, LoginOnlyDto.class);
+//        LonginOnlyDtoToken token = loginDto.getData().getToken();
+//        return Base64.encode(token.getUserId() + "_" + token.getToken());
+//    }
+//
+//    @Scheduled(cron = "0 0 0 * * ? ")
+//    public void update() throws Exception {
+//        Date date = new Date();
+//        DateTime beginOfMonth = DateUtil.beginOfMonth(date);
+//        List<Farm> list = farmService.list();
+//        for (Farm farm : list) {
+//            Integer farmId = farm.getId();
+//            QueryWrapper<EnvDevice> queryWrapper = new QueryWrapper<>();
+//            queryWrapper.eq("farm_id", farmId);
+//            Integer count = envDeviceService.count(queryWrapper);
+//            QueryWrapper<EnvDevice> queryWrapper1 = new QueryWrapper<>();
+//            queryWrapper1.eq("device_status", 0).eq("farm_id", farmId);
+//            Integer count1 = envDeviceService.count(queryWrapper1);//离线
+//            Integer OnDeviceCount = count - count1;//在线
+//            //创建一个数值格式化对象
+//            NumberFormat numberFormat = NumberFormat.getInstance();
+//            //设置精确到小数点后两位
+//            numberFormat.setMaximumFractionDigits(2);
+//            String onDeviceRate = numberFormat.format((float) OnDeviceCount / (float) count * 100);
+//
+//            EnvDeviceOnline envDeviceOnline = envDeviceOnlineService.getOne(new QueryWrapper<EnvDeviceOnline>().eq("farm_id", farmId).ge("creat_time", beginOfMonth));
+//            if (ObjectUtil.isEmpty(envDeviceOnline)) {
+//                envDeviceOnline = new EnvDeviceOnline();
+//                envDeviceOnline.setCreatTime(date);
+//                envDeviceOnline.setDeviceOff(count1);
+//                envDeviceOnline.setDeviceOn(OnDeviceCount);
+//                envDeviceOnline.setFarmId(farmId + "");
+//                envDeviceOnline.setOnlineRate(onDeviceRate);
+//                envDeviceOnline.setNowMonth(beginOfMonth.month());
+//                envDeviceOnline.setNowYear(beginOfMonth.year());
+//                envDeviceOnlineService.save(envDeviceOnline);
+//            } else {
+//                envDeviceOnline = new EnvDeviceOnline();
+//                envDeviceOnline.setCreatTime(date);
+//                envDeviceOnline.setDeviceOff(count1);
+//                envDeviceOnline.setDeviceOn(OnDeviceCount);
+//                envDeviceOnline.setFarmId(farmId + "");
+//                envDeviceOnline.setOnlineRate(onDeviceRate);
+//                envDeviceOnline.setNowMonth(beginOfMonth.month());
+//                envDeviceOnline.setNowYear(beginOfMonth.year());
+//                envDeviceOnlineService.updateById(envDeviceOnline);
+//            }
+//
+//        }
+//
+//    }
+//
+//}

+ 470 - 470
huimv-admin/src/main/java/com/huimv/admin/timer/GasTimer.java

@@ -1,470 +1,470 @@
-package com.huimv.admin.timer;
-
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.huimv.admin.common.utils.NumberUtils;
-import com.huimv.admin.entity.GasData;
-import com.huimv.admin.entity.GasThreshold;
-import com.huimv.admin.entity.GasWarningInfo;
-import com.huimv.admin.mapper.GasDataMapper;
-import com.huimv.admin.mapper.GasThresholdMapper;
-import com.huimv.admin.mapper.GasWarningInfoMapper;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-
-import java.util.Date;
-
-@Configuration
-@EnableScheduling
-public class  GasTimer {
-
-    @Autowired
-    private GasDataMapper gasDataMapper;
-    @Autowired
-    private GasWarningInfoMapper warningInfoMapper;
-    @Autowired
-    private GasThresholdMapper thresholdMapper;
-
-    @Scheduled(cron = "0 0 */1 * * ? ")
-    private void getShenChan() throws Exception {
-
-        String type = NumberUtils.getNum(1, 5, 0);//loc_type
-        for (int i = 1; i < 21; i++) {
-
-            String nh3n = NumberUtils.getNumFloat(0.0, 10.5);//NH3N
-            String jlm = NumberUtils.getNumFloat(0.0, 10.5);//jlm
-            String elht = NumberUtils.getNumFloat(0.0, 10.5);//elht
-            String ejel = NumberUtils.getNumFloat(0.0, 10.5);//ejel
-            String h2s = NumberUtils.getNumFloat(0.0, 10.5);//h2s
-            String byx = NumberUtils.getNumFloat(0.0, 20.5);//byx
-            String ch3 = NumberUtils.getNumFloat(0.0, 10.5);//ch3
-            String sja = NumberUtils.getNumFloat(0.0,10.5);//sja
-
-
-            GasData gasData = new GasData();
-            gasData.setNh3N(nh3n);
-            gasData.setJlm(jlm);
-            gasData.setElht(elht);
-            gasData.setEjel(ejel);
-            gasData.setH2s(h2s);
-            gasData.setByx(byx);
-            gasData.setCh3sh(ch3);
-            gasData.setSja(sja);
-            if (i > 16) {
-                gasData.setLoctionType(i - 16);//天台
-                gasData.setFarmId(27);
-            } else if (i > 12) {
-                gasData.setLoctionType(i - 12);//横路
-                gasData.setFarmId(26);
-            } else if (i > 8) {
-                gasData.setLoctionType(i - 8);//浦江
-                gasData.setFarmId(23);
-            } else if (i > 4) {
-                gasData.setLoctionType(i - 4);//东阳
-                gasData.setFarmId(24);
-            } else {
-                gasData.setLoctionType(i);
-                gasData.setFarmId(21);
-            }
-            gasData.setCreateTime(new Date());
-
-
-            QueryWrapper<GasThreshold> queryWrapper = new QueryWrapper<>();
-            GasWarningInfo warningInfo = new GasWarningInfo();
-            if (i==1||i==5||i==9||i==13||i==17) {
-                String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
-                gasData.setCq(cq);
-                if (i == 1) {
-                    queryWrapper.eq("farm_id", 21).eq("gas_type", 1);
-                } else if (i == 5) {
-                    queryWrapper.eq("farm_id", 24).eq("gas_type", 1);
-                } else if (i == 9) {
-                    queryWrapper.eq("farm_id", 23).eq("gas_type", 1);
-                } else if (i == 13) {
-                    queryWrapper.eq("farm_id", 26).eq("gas_type", 1);
-                } else {
-                    queryWrapper.eq("farm_id", 27).eq("gas_type", 1);
-                }
-                GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
-                if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
-                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(0);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
-                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(1);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
-                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(2);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
-                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(3);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
-                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(4);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
-                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(5);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
-                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(6);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
-                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(7);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
-                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(8);
-                    warningInfo.setBuildLocation("屋顶");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-
-            } else if (i==2||i==6||i==10||i==14||i==18) {
-                String cq = NumberUtils.getNumFloat(0.0, 5000.5);//cq
-                gasData.setCq(cq);
-                if (i == 2) {
-                    queryWrapper.eq("farm_id", 21).eq("gas_type", 2);
-                } else if (i == 6) {
-                    queryWrapper.eq("farm_id", 24).eq("gas_type", 2);
-                } else if (i == 10) {
-                    queryWrapper.eq("farm_id", 23).eq("gas_type", 2);
-                } else if (i == 14) {
-                    queryWrapper.eq("farm_id", 26).eq("gas_type", 2);
-                } else {
-                    queryWrapper.eq("farm_id", 27).eq("gas_type", 2);
-                }
-                GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
-                if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
-                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(0);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
-                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(1);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
-                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(2);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
-                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(3);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
-                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(4);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-
-                }
-                if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
-                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(5);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
-                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(6);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
-                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(7);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
-                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(8);
-                    warningInfo.setBuildLocation("厂界上");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-
-            } else if (i==3||i==7||i==11||i==15||i==19) {
-                String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
-                gasData.setCq(cq);
-                if (i == 3) {
-                    queryWrapper.eq("farm_id", 21).eq("gas_type", 3);
-                } else if (i == 7) {
-                    queryWrapper.eq("farm_id", 24).eq("gas_type", 3);
-                } else if (i == 11) {
-                    queryWrapper.eq("farm_id", 23).eq("gas_type", 3);
-                } else if (i == 15) {
-                    queryWrapper.eq("farm_id", 26).eq("gas_type", 3);
-                } else {
-                    queryWrapper.eq("farm_id", 27).eq("gas_type", 3);
-                }
-                GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
-                if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
-                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(0);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
-                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(1);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
-                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(2);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
-                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(3);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
-                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(4);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-
-                }
-                if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
-                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(5);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
-                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(6);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
-                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(7);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
-                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(8);
-                    warningInfo.setBuildLocation("厂界下");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-
-            } else if (i==4||i==8||i==12||i==16||i==20) {
-                String cq = NumberUtils.getNumFloat(0.0, 10000.5);//cq
-                gasData.setCq(cq);
-                if (i == 4) {
-                    queryWrapper.eq("farm_id", 21).eq("gas_type", 4);
-                } else if (i == 8) {
-                    queryWrapper.eq("farm_id", 24).eq("gas_type", 4);
-                } else if (i == 12) {
-                    queryWrapper.eq("farm_id", 23).eq("gas_type", 4);
-                } else if (i == 16) {
-                    queryWrapper.eq("farm_id", 26).eq("gas_type", 4);
-                } else {
-                    queryWrapper.eq("farm_id", 27).eq("gas_type", 4);
-                }
-                GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
-                if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
-                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(0);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
-                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(1);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
-                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(2);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
-                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(3);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
-                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(4);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
-                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(5);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
-                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(6);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
-                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(7);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-                if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
-                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
-                    warningInfo.setWarningType(8);
-                    warningInfo.setBuildLocation("厂界居民");
-                    warningInfo.setDate(new Date());
-                    warningInfo.setFarmId(gasThreshold.getFarmId());
-                    warningInfo.setUserIds(gasThreshold.getUserIds());
-                    warningInfoMapper.insert(warningInfo);
-                }
-
-            }
-            gasDataMapper.insert(gasData);
-        }
-    }
-}
+//package com.huimv.admin.timer;
+//
+//
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.huimv.admin.common.utils.NumberUtils;
+//import com.huimv.admin.entity.GasData;
+//import com.huimv.admin.entity.GasThreshold;
+//import com.huimv.admin.entity.GasWarningInfo;
+//import com.huimv.admin.mapper.GasDataMapper;
+//import com.huimv.admin.mapper.GasThresholdMapper;
+//import com.huimv.admin.mapper.GasWarningInfoMapper;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//
+//import java.util.Date;
+//
+//@Configuration
+//@EnableScheduling
+//public class  GasTimer {
+//
+//    @Autowired
+//    private GasDataMapper gasDataMapper;
+//    @Autowired
+//    private GasWarningInfoMapper warningInfoMapper;
+//    @Autowired
+//    private GasThresholdMapper thresholdMapper;
+//
+//    @Scheduled(cron = "0 0 */1 * * ? ")
+//    private void getShenChan() throws Exception {
+//
+//        String type = NumberUtils.getNum(1, 5, 0);//loc_type
+//        for (int i = 1; i < 21; i++) {
+//
+//            String nh3n = NumberUtils.getNumFloat(0.0, 10.5);//NH3N
+//            String jlm = NumberUtils.getNumFloat(0.0, 10.5);//jlm
+//            String elht = NumberUtils.getNumFloat(0.0, 10.5);//elht
+//            String ejel = NumberUtils.getNumFloat(0.0, 10.5);//ejel
+//            String h2s = NumberUtils.getNumFloat(0.0, 10.5);//h2s
+//            String byx = NumberUtils.getNumFloat(0.0, 20.5);//byx
+//            String ch3 = NumberUtils.getNumFloat(0.0, 10.5);//ch3
+//            String sja = NumberUtils.getNumFloat(0.0,10.5);//sja
+//
+//
+//            GasData gasData = new GasData();
+//            gasData.setNh3N(nh3n);
+//            gasData.setJlm(jlm);
+//            gasData.setElht(elht);
+//            gasData.setEjel(ejel);
+//            gasData.setH2s(h2s);
+//            gasData.setByx(byx);
+//            gasData.setCh3sh(ch3);
+//            gasData.setSja(sja);
+//            if (i > 16) {
+//                gasData.setLoctionType(i - 16);//天台
+//                gasData.setFarmId(27);
+//            } else if (i > 12) {
+//                gasData.setLoctionType(i - 12);//横路
+//                gasData.setFarmId(26);
+//            } else if (i > 8) {
+//                gasData.setLoctionType(i - 8);//浦江
+//                gasData.setFarmId(23);
+//            } else if (i > 4) {
+//                gasData.setLoctionType(i - 4);//东阳
+//                gasData.setFarmId(24);
+//            } else {
+//                gasData.setLoctionType(i);
+//                gasData.setFarmId(21);
+//            }
+//            gasData.setCreateTime(new Date());
+//
+//
+//            QueryWrapper<GasThreshold> queryWrapper = new QueryWrapper<>();
+//            GasWarningInfo warningInfo = new GasWarningInfo();
+//            if (i==1||i==5||i==9||i==13||i==17) {
+//                String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
+//                gasData.setCq(cq);
+//                if (i == 1) {
+//                    queryWrapper.eq("farm_id", 21).eq("gas_type", 1);
+//                } else if (i == 5) {
+//                    queryWrapper.eq("farm_id", 24).eq("gas_type", 1);
+//                } else if (i == 9) {
+//                    queryWrapper.eq("farm_id", 23).eq("gas_type", 1);
+//                } else if (i == 13) {
+//                    queryWrapper.eq("farm_id", 26).eq("gas_type", 1);
+//                } else {
+//                    queryWrapper.eq("farm_id", 27).eq("gas_type", 1);
+//                }
+//                GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
+//                if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
+//                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(0);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
+//                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(1);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
+//                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(2);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
+//                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(3);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
+//                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(4);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
+//                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(5);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
+//                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(6);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
+//                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(7);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
+//                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(8);
+//                    warningInfo.setBuildLocation("屋顶");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//
+//            } else if (i==2||i==6||i==10||i==14||i==18) {
+//                String cq = NumberUtils.getNumFloat(0.0, 5000.5);//cq
+//                gasData.setCq(cq);
+//                if (i == 2) {
+//                    queryWrapper.eq("farm_id", 21).eq("gas_type", 2);
+//                } else if (i == 6) {
+//                    queryWrapper.eq("farm_id", 24).eq("gas_type", 2);
+//                } else if (i == 10) {
+//                    queryWrapper.eq("farm_id", 23).eq("gas_type", 2);
+//                } else if (i == 14) {
+//                    queryWrapper.eq("farm_id", 26).eq("gas_type", 2);
+//                } else {
+//                    queryWrapper.eq("farm_id", 27).eq("gas_type", 2);
+//                }
+//                GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
+//                if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
+//                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(0);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
+//                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(1);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
+//                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(2);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
+//                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(3);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
+//                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(4);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//
+//                }
+//                if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
+//                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(5);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
+//                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(6);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
+//                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(7);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
+//                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(8);
+//                    warningInfo.setBuildLocation("厂界上");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//
+//            } else if (i==3||i==7||i==11||i==15||i==19) {
+//                String cq = NumberUtils.getNumFloat(0.0, 1000.5);//cq
+//                gasData.setCq(cq);
+//                if (i == 3) {
+//                    queryWrapper.eq("farm_id", 21).eq("gas_type", 3);
+//                } else if (i == 7) {
+//                    queryWrapper.eq("farm_id", 24).eq("gas_type", 3);
+//                } else if (i == 11) {
+//                    queryWrapper.eq("farm_id", 23).eq("gas_type", 3);
+//                } else if (i == 15) {
+//                    queryWrapper.eq("farm_id", 26).eq("gas_type", 3);
+//                } else {
+//                    queryWrapper.eq("farm_id", 27).eq("gas_type", 3);
+//                }
+//                GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
+//                if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
+//                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(0);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
+//                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(1);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
+//                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(2);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
+//                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(3);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
+//                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(4);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//
+//                }
+//                if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
+//                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(5);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
+//                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(6);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
+//                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(7);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
+//                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(8);
+//                    warningInfo.setBuildLocation("厂界下");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//
+//            } else if (i==4||i==8||i==12||i==16||i==20) {
+//                String cq = NumberUtils.getNumFloat(0.0, 10000.5);//cq
+//                gasData.setCq(cq);
+//                if (i == 4) {
+//                    queryWrapper.eq("farm_id", 21).eq("gas_type", 4);
+//                } else if (i == 8) {
+//                    queryWrapper.eq("farm_id", 24).eq("gas_type", 4);
+//                } else if (i == 12) {
+//                    queryWrapper.eq("farm_id", 23).eq("gas_type", 4);
+//                } else if (i == 16) {
+//                    queryWrapper.eq("farm_id", 26).eq("gas_type", 4);
+//                } else {
+//                    queryWrapper.eq("farm_id", 27).eq("gas_type", 4);
+//                }
+//                GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
+//                if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
+//                    warningInfo.setWarningContent("NH3N为"+nh3n + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(0);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
+//                    warningInfo.setWarningContent("甲硫醚为"+jlm + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(1);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
+//                    warningInfo.setWarningContent("二硫化碳为"+elht + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(2);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
+//                    warningInfo.setWarningContent("二甲二硫为"+ejel + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(3);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
+//                    warningInfo.setWarningContent("H2S为"+h2s + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(4);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
+//                    warningInfo.setWarningContent("苯乙烯为"+byx + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(5);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
+//                    warningInfo.setWarningContent("CH3SH为"+ch3 + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(6);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
+//                    warningInfo.setWarningContent("三甲胺为"+sja + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(7);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//                if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
+//                    warningInfo.setWarningContent("臭气为"+cq + "超过阈值,系统预警提醒");
+//                    warningInfo.setWarningType(8);
+//                    warningInfo.setBuildLocation("厂界居民");
+//                    warningInfo.setDate(new Date());
+//                    warningInfo.setFarmId(gasThreshold.getFarmId());
+//                    warningInfo.setUserIds(gasThreshold.getUserIds());
+//                    warningInfoMapper.insert(warningInfo);
+//                }
+//
+//            }
+//            gasDataMapper.insert(gasData);
+//        }
+//    }
+//}

文件差異過大導致無法顯示
+ 547 - 547
huimv-admin/src/main/java/com/huimv/admin/timer/ProtTimer.java


+ 54 - 54
huimv-admin/src/main/java/com/huimv/admin/timer/SafeTimer.java

@@ -1,54 +1,54 @@
-package com.huimv.admin.timer;
-
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.huimv.admin.common.utils.NumberUtils;
-import com.huimv.admin.entity.BillIsolate;
-import com.huimv.admin.entity.GasData;
-import com.huimv.admin.entity.GasThreshold;
-import com.huimv.admin.entity.GasWarningInfo;
-import com.huimv.admin.mapper.GasDataMapper;
-import com.huimv.admin.mapper.GasThresholdMapper;
-import com.huimv.admin.mapper.GasWarningInfoMapper;
-import com.huimv.admin.service.IBillIsolateService;
-import com.huimv.admin.service.IBillPcrService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-@Configuration
-@EnableScheduling
-public class SafeTimer {
-
-
-    @Autowired
-    private IBillPcrService pcrService;
-    @Autowired
-    private IBillIsolateService isolateService;
-
-
-    @Scheduled(cron = "0 0/1 * * * ? ")
-    private void getShenChan() throws Exception {
-        QueryWrapper<BillIsolate> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("bill_status", 1);
-        List<BillIsolate> isolates = isolateService.list(queryWrapper);
-        Date date = new Date();
-        for (BillIsolate isolate : isolates) {
-            if (isolate.getIsolateEndDate().getTime() <= date.getTime()) {
-                isolate.setIsolateRealEndDate(date);
-                isolate.setIsolateRealDayNum(isolate.getIsolateDayNum());
-                isolate.setBillStatus(2);
-                isolate.setPassUserName("自然解除隔离");
-                isolate.setPassDate(date);
-                isolateService.updateById(isolate);
-            }
-        }
-    }
-
-}
+//package com.huimv.admin.timer;
+//
+//
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.huimv.admin.common.utils.NumberUtils;
+//import com.huimv.admin.entity.BillIsolate;
+//import com.huimv.admin.entity.GasData;
+//import com.huimv.admin.entity.GasThreshold;
+//import com.huimv.admin.entity.GasWarningInfo;
+//import com.huimv.admin.mapper.GasDataMapper;
+//import com.huimv.admin.mapper.GasThresholdMapper;
+//import com.huimv.admin.mapper.GasWarningInfoMapper;
+//import com.huimv.admin.service.IBillIsolateService;
+//import com.huimv.admin.service.IBillPcrService;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//
+//import java.text.ParseException;
+//import java.text.SimpleDateFormat;
+//import java.util.Date;
+//import java.util.List;
+//
+//@Configuration
+//@EnableScheduling
+//public class SafeTimer {
+//
+//
+//    @Autowired
+//    private IBillPcrService pcrService;
+//    @Autowired
+//    private IBillIsolateService isolateService;
+//
+//
+//    @Scheduled(cron = "0 0/1 * * * ? ")
+//    private void getShenChan() throws Exception {
+//        QueryWrapper<BillIsolate> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("bill_status", 1);
+//        List<BillIsolate> isolates = isolateService.list(queryWrapper);
+//        Date date = new Date();
+//        for (BillIsolate isolate : isolates) {
+//            if (isolate.getIsolateEndDate().getTime() <= date.getTime()) {
+//                isolate.setIsolateRealEndDate(date);
+//                isolate.setIsolateRealDayNum(isolate.getIsolateDayNum());
+//                isolate.setBillStatus(2);
+//                isolate.setPassUserName("自然解除隔离");
+//                isolate.setPassDate(date);
+//                isolateService.updateById(isolate);
+//            }
+//        }
+//    }
+//
+//}

+ 271 - 271
huimv-admin/src/main/java/com/huimv/admin/timer/ShenChanTimer.java

@@ -1,279 +1,279 @@
-package com.huimv.admin.timer;
-
-
-import cn.hutool.core.codec.Base64;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.huimv.admin.common.utils.Digests;
-import com.huimv.admin.common.utils.HttpClientSSLUtils;
-import com.huimv.admin.entity.*;
-import com.huimv.admin.entity.zengxindto.*;
-import com.huimv.admin.service.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.*;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.client.RestTemplate;
-
-import java.time.LocalDate;
-import java.util.*;
-
-@Configuration
-@EnableScheduling
-public class ShenChanTimer {
-
-    //生产数据
-    @Autowired
-    private RestTemplate restTemplate;
-    @Autowired
-    private IProdStockService prodStockService;
-
-
-    @Scheduled(cron = "0 0 */4 * * ? ")
-//    @Scheduled(cron = "0 * * * * ?")
-    @GetMapping("/test")
-    private void getShenChan() throws Exception {
-        Integer farmId = 21;
-        List<Integer> farmIds = new ArrayList();
-        farmIds.add(21);
-        farmIds.add(23);
-//        farmIds.add(24);
-        farmIds.add(26);
-        farmIds.add(27);
-        String time = LocalDate.now().toString();
-        String token = login();
-//        System.out.println("token"+token);
-        DateTime dateTime = DateUtil.beginOfDay(new Date());
-        System.out.println(token);
-
-        String url = "http://test.htpig.cn/rest/db/storedproc";
-        Map<String, Object> map = new HashMap<String, Object>();
-        map.put("db_name","MSSQL");
-        map.put("proc_name","rep_yz_kc_hz");
-        map.put("method","open_proc");
-        HashMap<String, Object> maps = new HashMap<>();
-        List list = new ArrayList();
-        maps.put("name","@fdate");
-        maps.put("value",time);
-        list.add(maps);
-
-        map.put("params",list);
-        String params = JSON.toJSONString(map);
-        System.out.println(" ====== getStock请求参数:【" + params + "】");
-        String data = HttpClientSSLUtils.doPost(url+"?token="+token+"&data=", params);
-        ProdStockDto prodStockDto = JSONUtil.toBean(data, ProdStockDto.class);
-        List<List<Object>> stockData = prodStockDto.getData();
-        System.out.println(prodStockDto.toString());
-        for (Integer id : farmIds) {
-            ProdStock prodStock = prodStockService.getOne(new QueryWrapper<ProdStock>().ge("creat_time",dateTime).eq("farm_id", id).orderByDesc("creat_time").last("limit 1"));
-
-            for (List stock : stockData) {
-                if ("正康".equals(stock.get(0))){
-                    if (ObjectUtil.isNotEmpty(prodStock)){
-                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(21);
-                        prodStockService.updateById(prodStock);
-                    }else {
-                        prodStock = new ProdStock();
-                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setMzcl(100);
-                        prodStock.setGzcl(200);
-                        prodStock.setBrzcl(452);
-                        prodStock.setHbzcl(100);
-                        prodStock.setRszcl(30);
-                        prodStock.setBrmzcl(20);
-                        prodStock.setKhzcl(212);
-                        prodStock.setSpzcl(1020);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(21);
-                        prodStockService.save(prodStock);
-                    }
-
-                }
-
-              /*  if ("东阳".equals(stock.get(0))){
-                    if (ObjectUtil.isNotEmpty(prodStock)){
-//                    prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setZzcl(5433);
-//                    prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setByzcl(6760);
-//                    prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setYfzcl(4361);
-//                    prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setZcl(16554);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(24);
-                        prodStockService.updateById(prodStock);
-                        System.out.println("东阳--》");
-                    }else {
-                        prodStock = new ProdStock();
-                        //                    prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setZzcl(5433);
-//                    prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setByzcl(6760);
-//                    prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setYfzcl(4361);
-//                    prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setZcl(16554);
-                        prodStock.setMzcl(100);
-                        prodStock.setGzcl(200);
-                        prodStock.setBrzcl(452);
-                        prodStock.setHbzcl(100);
-                        prodStock.setRszcl(30);
-                        prodStock.setBrmzcl(20);
-                        prodStock.setKhzcl(212);
-                        prodStock.setSpzcl(1020);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(24);
-                        prodStockService.save(prodStock);
-                        System.out.println("东阳");
-                    }
-                }*/
-                if ("浦江".equals(stock.get(0))){
-                    if (ObjectUtil.isNotEmpty(prodStock)){
+//package com.huimv.admin.timer;
+//
+//
+//import cn.hutool.core.codec.Base64;
+//import cn.hutool.core.date.DateTime;
+//import cn.hutool.core.date.DateUtil;
+//import cn.hutool.core.util.ObjectUtil;
+//import cn.hutool.json.JSONObject;
+//import cn.hutool.json.JSONUtil;
+//import com.alibaba.fastjson.JSON;
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+//import com.huimv.admin.common.utils.Digests;
+//import com.huimv.admin.common.utils.HttpClientSSLUtils;
+//import com.huimv.admin.entity.*;
+//import com.huimv.admin.entity.zengxindto.*;
+//import com.huimv.admin.service.*;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.http.*;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.transaction.annotation.Transactional;
+//import org.springframework.web.bind.annotation.GetMapping;
+//import org.springframework.web.client.RestTemplate;
+//
+//import java.time.LocalDate;
+//import java.util.*;
+//
+//@Configuration
+//@EnableScheduling
+//public class ShenChanTimer {
+//
+//    //生产数据
+//    @Autowired
+//    private RestTemplate restTemplate;
+//    @Autowired
+//    private IProdStockService prodStockService;
+//
+//
+//    @Scheduled(cron = "0 0 */4 * * ? ")
+////    @Scheduled(cron = "0 * * * * ?")
+//    @GetMapping("/test")
+//    private void getShenChan() throws Exception {
+//        Integer farmId = 21;
+//        List<Integer> farmIds = new ArrayList();
+//        farmIds.add(21);
+//        farmIds.add(23);
+////        farmIds.add(24);
+//        farmIds.add(26);
+//        farmIds.add(27);
+//        String time = LocalDate.now().toString();
+//        String token = login();
+////        System.out.println("token"+token);
+//        DateTime dateTime = DateUtil.beginOfDay(new Date());
+//        System.out.println(token);
+//
+//        String url = "http://test.htpig.cn/rest/db/storedproc";
+//        Map<String, Object> map = new HashMap<String, Object>();
+//        map.put("db_name","MSSQL");
+//        map.put("proc_name","rep_yz_kc_hz");
+//        map.put("method","open_proc");
+//        HashMap<String, Object> maps = new HashMap<>();
+//        List list = new ArrayList();
+//        maps.put("name","@fdate");
+//        maps.put("value",time);
+//        list.add(maps);
+//
+//        map.put("params",list);
+//        String params = JSON.toJSONString(map);
+//        System.out.println(" ====== getStock请求参数:【" + params + "】");
+//        String data = HttpClientSSLUtils.doPost(url+"?token="+token+"&data=", params);
+//        ProdStockDto prodStockDto = JSONUtil.toBean(data, ProdStockDto.class);
+//        List<List<Object>> stockData = prodStockDto.getData();
+//        System.out.println(prodStockDto.toString());
+//        for (Integer id : farmIds) {
+//            ProdStock prodStock = prodStockService.getOne(new QueryWrapper<ProdStock>().ge("creat_time",dateTime).eq("farm_id", id).orderByDesc("creat_time").last("limit 1"));
+//
+//            for (List stock : stockData) {
+//                if ("正康".equals(stock.get(0))){
+//                    if (ObjectUtil.isNotEmpty(prodStock)){
 //                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setZzcl(9980);
 //                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setByzcl(16384);
 //                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setYfzcl(32999);
 //                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setZcl(66381);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(23);
-                        prodStockService.updateById(prodStock);
-                        System.out.println("浦江--》");
-                    }else {
-                        prodStock = new ProdStock();
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(21);
+//                        prodStockService.updateById(prodStock);
+//                    }else {
+//                        prodStock = new ProdStock();
 //                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setZzcl(9980);
 //                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setByzcl(16384);
 //                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setYfzcl(32999);
 //                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setZcl(66381);
-                        prodStock.setMzcl(100);
-                        prodStock.setGzcl(200);
-                        prodStock.setBrzcl(452);
-                        prodStock.setHbzcl(100);
-                        prodStock.setRszcl(30);
-                        prodStock.setBrmzcl(20);
-                        prodStock.setKhzcl(212);
-                        prodStock.setSpzcl(1020);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(23);
-                        prodStockService.save(prodStock);
-                        System.out.println("浦江--》");
-                    }
-
-                }
-
-                if ("横路".equals(stock.get(0))){
-                    if (ObjectUtil.isNotEmpty(prodStock)){
-//                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setZzcl(9980);
-//                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setByzcl(16384);
-//                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setYfzcl(32999);
-//                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setZcl(66381);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(26);
-                        prodStockService.updateById(prodStock);
-                        System.out.println("横路--》");
-                    }else {
-                        prodStock = new ProdStock();
-//                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setZzcl(9980);
-//                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setByzcl(16384);
-//                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setYfzcl(32999);
-//                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setZcl(66381);
-                        prodStock.setMzcl(100);
-                        prodStock.setGzcl(200);
-                        prodStock.setBrzcl(452);
-                        prodStock.setHbzcl(100);
-                        prodStock.setRszcl(30);
-                        prodStock.setBrmzcl(20);
-                        prodStock.setKhzcl(212);
-                        prodStock.setSpzcl(1020);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(26);
-                        prodStockService.save(prodStock);
-                        System.out.println("横路--》");
-                    }
-
-                }
-                if ("天台".equals(stock.get(0))){
-                    if (ObjectUtil.isNotEmpty(prodStock)){
-//                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setZzcl(9980);
-//                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setByzcl(16384);
-//                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setYfzcl(32999);
-//                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setZcl(66381);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(27);
-                        prodStockService.updateById(prodStock);
-                        System.out.println("天台--》");
-                    }else {
-                        prodStock = new ProdStock();
-//                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
-                        prodStock.setZzcl(9980);
-//                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
-                        prodStock.setByzcl(16384);
-//                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
-                        prodStock.setYfzcl(32999);
-//                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
-                        prodStock.setZcl(66381);
-                        prodStock.setMzcl(100);
-                        prodStock.setGzcl(200);
-                        prodStock.setBrzcl(452);
-                        prodStock.setHbzcl(100);
-                        prodStock.setRszcl(30);
-                        prodStock.setBrmzcl(20);
-                        prodStock.setKhzcl(212);
-                        prodStock.setSpzcl(1020);
-                        prodStock.setCreatTime(new Date());
-                        prodStock.setFarmId(27);
-                        prodStockService.save(prodStock);
-                        System.out.println("天台--》");
-                    }
-
-                }
-            }
-        }
-    }
-
-
-    private String login() throws Exception {
-        StockLoginDto stockLoginDto = restTemplate.getForObject("http://test.htpig.cn/rest/user/login?user_name=test&password=e10adc3949ba59abbe56e057f20f883e&db_name=MSSQL", StockLoginDto.class);
-        if (stockLoginDto.getStatus() != 0){
-            return null;
-        }
-        return stockLoginDto.getToken();
-    }
-
-}
+//                        prodStock.setMzcl(100);
+//                        prodStock.setGzcl(200);
+//                        prodStock.setBrzcl(452);
+//                        prodStock.setHbzcl(100);
+//                        prodStock.setRszcl(30);
+//                        prodStock.setBrmzcl(20);
+//                        prodStock.setKhzcl(212);
+//                        prodStock.setSpzcl(1020);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(21);
+//                        prodStockService.save(prodStock);
+//                    }
+//
+//                }
+//
+//              /*  if ("东阳".equals(stock.get(0))){
+//                    if (ObjectUtil.isNotEmpty(prodStock)){
+////                    prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
+//                        prodStock.setZzcl(5433);
+////                    prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
+//                        prodStock.setByzcl(6760);
+////                    prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
+//                        prodStock.setYfzcl(4361);
+////                    prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
+//                        prodStock.setZcl(16554);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(24);
+//                        prodStockService.updateById(prodStock);
+//                        System.out.println("东阳--》");
+//                    }else {
+//                        prodStock = new ProdStock();
+//                        //                    prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
+//                        prodStock.setZzcl(5433);
+////                    prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
+//                        prodStock.setByzcl(6760);
+////                    prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
+//                        prodStock.setYfzcl(4361);
+////                    prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
+//                        prodStock.setZcl(16554);
+//                        prodStock.setMzcl(100);
+//                        prodStock.setGzcl(200);
+//                        prodStock.setBrzcl(452);
+//                        prodStock.setHbzcl(100);
+//                        prodStock.setRszcl(30);
+//                        prodStock.setBrmzcl(20);
+//                        prodStock.setKhzcl(212);
+//                        prodStock.setSpzcl(1020);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(24);
+//                        prodStockService.save(prodStock);
+//                        System.out.println("东阳");
+//                    }
+//                }*/
+//                if ("浦江".equals(stock.get(0))){
+//                    if (ObjectUtil.isNotEmpty(prodStock)){
+////                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
+//                        prodStock.setZzcl(9980);
+////                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
+//                        prodStock.setByzcl(16384);
+////                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
+//                        prodStock.setYfzcl(32999);
+////                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
+//                        prodStock.setZcl(66381);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(23);
+//                        prodStockService.updateById(prodStock);
+//                        System.out.println("浦江--》");
+//                    }else {
+//                        prodStock = new ProdStock();
+////                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
+//                        prodStock.setZzcl(9980);
+////                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
+//                        prodStock.setByzcl(16384);
+////                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
+//                        prodStock.setYfzcl(32999);
+////                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
+//                        prodStock.setZcl(66381);
+//                        prodStock.setMzcl(100);
+//                        prodStock.setGzcl(200);
+//                        prodStock.setBrzcl(452);
+//                        prodStock.setHbzcl(100);
+//                        prodStock.setRszcl(30);
+//                        prodStock.setBrmzcl(20);
+//                        prodStock.setKhzcl(212);
+//                        prodStock.setSpzcl(1020);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(23);
+//                        prodStockService.save(prodStock);
+//                        System.out.println("浦江--》");
+//                    }
+//
+//                }
+//
+//                if ("横路".equals(stock.get(0))){
+//                    if (ObjectUtil.isNotEmpty(prodStock)){
+////                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
+//                        prodStock.setZzcl(9980);
+////                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
+//                        prodStock.setByzcl(16384);
+////                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
+//                        prodStock.setYfzcl(32999);
+////                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
+//                        prodStock.setZcl(66381);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(26);
+//                        prodStockService.updateById(prodStock);
+//                        System.out.println("横路--》");
+//                    }else {
+//                        prodStock = new ProdStock();
+////                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
+//                        prodStock.setZzcl(9980);
+////                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
+//                        prodStock.setByzcl(16384);
+////                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
+//                        prodStock.setYfzcl(32999);
+////                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
+//                        prodStock.setZcl(66381);
+//                        prodStock.setMzcl(100);
+//                        prodStock.setGzcl(200);
+//                        prodStock.setBrzcl(452);
+//                        prodStock.setHbzcl(100);
+//                        prodStock.setRszcl(30);
+//                        prodStock.setBrmzcl(20);
+//                        prodStock.setKhzcl(212);
+//                        prodStock.setSpzcl(1020);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(26);
+//                        prodStockService.save(prodStock);
+//                        System.out.println("横路--》");
+//                    }
+//
+//                }
+//                if ("天台".equals(stock.get(0))){
+//                    if (ObjectUtil.isNotEmpty(prodStock)){
+////                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
+//                        prodStock.setZzcl(9980);
+////                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
+//                        prodStock.setByzcl(16384);
+////                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
+//                        prodStock.setYfzcl(32999);
+////                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
+//                        prodStock.setZcl(66381);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(27);
+//                        prodStockService.updateById(prodStock);
+//                        System.out.println("天台--》");
+//                    }else {
+//                        prodStock = new ProdStock();
+////                        prodStock.setZzcl(Integer.parseInt(stock.get(11).toString()));
+//                        prodStock.setZzcl(9980);
+////                        prodStock.setByzcl(Integer.parseInt(stock.get(13).toString()));
+//                        prodStock.setByzcl(16384);
+////                        prodStock.setYfzcl(Integer.parseInt(stock.get(14).toString()));
+//                        prodStock.setYfzcl(32999);
+////                        prodStock.setZcl(Integer.parseInt(stock.get(15).toString()));
+//                        prodStock.setZcl(66381);
+//                        prodStock.setMzcl(100);
+//                        prodStock.setGzcl(200);
+//                        prodStock.setBrzcl(452);
+//                        prodStock.setHbzcl(100);
+//                        prodStock.setRszcl(30);
+//                        prodStock.setBrmzcl(20);
+//                        prodStock.setKhzcl(212);
+//                        prodStock.setSpzcl(1020);
+//                        prodStock.setCreatTime(new Date());
+//                        prodStock.setFarmId(27);
+//                        prodStockService.save(prodStock);
+//                        System.out.println("天台--》");
+//                    }
+//
+//                }
+//            }
+//        }
+//    }
+//
+//
+//    private String login() throws Exception {
+//        StockLoginDto stockLoginDto = restTemplate.getForObject("http://test.htpig.cn/rest/user/login?user_name=test&password=e10adc3949ba59abbe56e057f20f883e&db_name=MSSQL", StockLoginDto.class);
+//        if (stockLoginDto.getStatus() != 0){
+//            return null;
+//        }
+//        return stockLoginDto.getToken();
+//    }
+//
+//}

+ 36 - 21
huimv-admin/src/main/resources/com/huimv/admin/mapper/BillPersonnelAdmissionMapper.xml

@@ -4,27 +4,27 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.huimv.admin.entity.BillPersonnelAdmission">
-        <id column="id" property="id" />
-        <result column="admission_type" property="admissionType" />
-        <result column="vistit_type" property="vistitType" />
-        <result column="dest_name" property="destName" />
-        <result column="dest_id" property="destId" />
-        <result column="admission_user_name" property="admissionUserName" />
-        <result column="admission_user_id" property="admissionUserId" />
-        <result column="vistit_date" property="vistitDate" />
-        <result column="sub_date" property="subDate" />
-        <result column="phone" property="phone" />
-        <result column="work_name" property="workName" />
-        <result column="papers_type" property="papersType" />
-        <result column="papers_code" property="papersCode" />
-        <result column="img_url" property="imgUrl" />
-        <result column="vistit_reson" property="vistitReson" />
-        <result column="farm_id" property="farmId" />
-        <result column="bill_status" property="billStatus" />
-        <result column="pass_date" property="passDate" />
-        <result column="pass_user_name" property="passUserName" />
-        <result column="pass_user_id" property="passUserId" />
-        <result column="process_id" property="processId" />
+        <id column="id" property="id"/>
+        <result column="admission_type" property="admissionType"/>
+        <result column="vistit_type" property="vistitType"/>
+        <result column="dest_name" property="destName"/>
+        <result column="dest_id" property="destId"/>
+        <result column="admission_user_name" property="admissionUserName"/>
+        <result column="admission_user_id" property="admissionUserId"/>
+        <result column="vistit_date" property="vistitDate"/>
+        <result column="sub_date" property="subDate"/>
+        <result column="phone" property="phone"/>
+        <result column="work_name" property="workName"/>
+        <result column="papers_type" property="papersType"/>
+        <result column="papers_code" property="papersCode"/>
+        <result column="img_url" property="imgUrl"/>
+        <result column="vistit_reson" property="vistitReson"/>
+        <result column="farm_id" property="farmId"/>
+        <result column="bill_status" property="billStatus"/>
+        <result column="pass_date" property="passDate"/>
+        <result column="pass_user_name" property="passUserName"/>
+        <result column="pass_user_id" property="passUserId"/>
+        <result column="process_id" property="processId"/>
     </resultMap>
     <select id="listAll" resultType="com.huimv.admin.entity.vo.FactoryDirectorVo">
         SELECT count(*) count,id,admission_user_name AS 'userName', bill_status, isolate_location, isolate_start_date AS check_date, isolate_start_date AS 'startTime', isolate_end_date AS 'endTime', NULL AS test_location, NULL AS vistit_type, NULL AS dest_name, NULL AS vistit_date,3 AS 'type',sub_date
@@ -79,5 +79,20 @@ ORDER BY sub_date DESC
         ${ew.customSqlSegment}
         group by vistit_type
     </select>
+    <select id="admissionTail" resultType="com.huimv.admin.entity.vo.BillAdmissionVo">
+SELECT
+    DATE(sub_date) as dateTime,
+    SUM(CASE WHEN bill_status = 0 THEN 1 ELSE 0 END) AS commitCount,
+    SUM(CASE WHEN bill_status = 1 THEN 1 ELSE 0 END) AS passCount,
+    SUM(CASE WHEN bill_status = 2 THEN 1 ELSE 0 END) AS refuseCount
+FROM
+    `bill_personnel_admission`
+
+    ${ew.customSqlSegment}
+GROUP BY
+    DATE(sub_date)
+ORDER BY
+    DATE(sub_date)
+    </select>
 
 </mapper>