Explorar o código

新增 性诱测报获取配置,下发配置功能

zhaiyifei hai 1 ano
pai
achega
b0bf059e58

+ 60 - 30
src/main/java/com/yunfeiyun/agmp/iotm/device/common/service/impl/IotDeviceBaseServiceImpl.java

@@ -15,10 +15,7 @@ import org.springframework.stereotype.Component;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author 123
@@ -250,43 +247,76 @@ public abstract class IotDeviceBaseServiceImpl implements IotDeviceBaseService {
         }
     }
 
+    /**
+     * 通用方法调用,仅支持一个参数的方法
+     * @param iotDeviceBaseFunReqVo
+     * @return
+     * @param <T>
+     */
     @Override
     public <T> T func(IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo) {
         // 获取将要执行的方法
         String methodName = iotDeviceBaseFunReqVo.getMethodName();
         // 获取类下所有的方法
+//        Method[] methods = this.getClass().getDeclaredMethods();
+//        Method[] parentMethods = this.getClass().getSuperclass().getDeclaredMethods();
+//        Map<String, Method> parentMethodMap = new HashMap<>();
+//        for (Method item : parentMethods) {
+//            String mn = item.getName();
+//            int pc = item.getParameterCount();
+//            String key = mn + pc;
+//            parentMethodMap.put(key, item);
+//        }
+
+        // 根据methodName通过反射获取对应方法,并对参数进行预处理
+//        for (Method item : methods) {
+//            // 判断方法名称与参数数量
+//            String metname = item.getName();
+//            int parameCount = item.getParameterCount();
+//            if (!metname.equals(methodName) || parameCount > 1) {
+//                if(parentMethodMap.containsKey(methodName + parameCount)){
+//                    item = parentMethodMap.get(methodName + parameCount);
+//                }else{
+//                    continue;
+//                }
+//            }
+//            method = item;
+//            // 获取方法的参数类型
+//            Class<?>[] paramClass = item.getParameterTypes();
+//            // 方法若是无参,则无需进行转化
+//            if (paramClass.length == 1) {
+//                param = transFuncParm(paramClass[0], iotDeviceBaseFunReqVo);
+//            }
+//            break;
+//        }
+
         Method[] methods = this.getClass().getDeclaredMethods();
         Method[] parentMethods = this.getClass().getSuperclass().getDeclaredMethods();
-        Map<String, Method> parentMethodMap = new HashMap<>();
-        for (Method item : parentMethods) {
-            String mn = item.getName();
-            int pc = item.getParameterCount();
-            String key = mn + pc;
-            parentMethodMap.put(key, item);
+        List<Method[]> methodList = new ArrayList<>();
+        methodList.add(parentMethods);
+        methodList.add(methods);
+
+        Map<String, Method> methodMap = new HashMap<>();
+        for (Method[] method : methodList) {
+            for (Method item : method) {
+                String mn = item.getName();
+                int pc = item.getParameterCount();
+                String key = mn + pc;
+                methodMap.put(key, item);
+            }
         }
         Method method = null;
         T param = null;
-        // 根据methodName通过反射获取对应方法,并对参数进行预处理
-        for (Method item : methods) {
-            // 判断方法名称与参数数量
-            String metname = item.getName();
-            int parameCount = item.getParameterCount();
-            if (!metname.equals(methodName) || parameCount > 1) {
-                if(parentMethodMap.containsKey(methodName + parameCount)){
-                    item = parentMethodMap.get(methodName + parameCount);
-                }else{
-                    continue;
-                }
-            }
-            method = item;
-            // 获取方法的参数类型
-            Class<?>[] paramClass = item.getParameterTypes();
-            // 方法若是无参,则无需进行转化
-            if (paramClass.length == 1) {
-                param = transFuncParm(paramClass[0], iotDeviceBaseFunReqVo);
-            }
-            break;
+
+        String key = methodName + 1;
+        if(methodMap.containsKey(key)){
+            method = methodMap.get(key);
+            param = transFuncParm(method.getParameterTypes()[0], iotDeviceBaseFunReqVo);
         }
+        if(method == null){
+            throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备未实现方法");
+        }
+
         try {
             return (T) method.invoke(getProxy(method), param);
         } catch (InvocationTargetException e) {

+ 190 - 179
src/main/java/com/yunfeiyun/agmp/iotm/device/xycb/controller/IotXycbController.java

@@ -1,27 +1,26 @@
 package com.yunfeiyun.agmp.iotm.device.xycb.controller;
 
 import com.alibaba.fastjson2.JSONObject;
-import com.yunfeiyun.agmp.common.annotation.Log;
 import com.yunfeiyun.agmp.common.constant.ErrorCode;
 import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
 import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
-import com.yunfeiyun.agmp.common.enums.BusinessType;
 import com.yunfeiyun.agmp.common.log.LogCore;
-import com.yunfeiyun.agmp.common.utils.JSONUtils;
+import com.yunfeiyun.agmp.common.utils.DateUtils;
 import com.yunfeiyun.agmp.common.utils.StringUtils;
-import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
-import com.yunfeiyun.agmp.common.utils.uuid.IdUtils;
 import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
 import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
 import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
-import com.yunfeiyun.agmp.iot.common.domain.IotDeviceconfig;
+import com.yunfeiyun.agmp.iot.common.domain.IotPest;
+import com.yunfeiyun.agmp.iot.common.enums.IotDeviceStatusTypeEnum;
 import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
-import com.yunfeiyun.agmp.iot.common.model.cmd.CmdGroupModel;
 import com.yunfeiyun.agmp.iot.common.service.MongoService;
 import com.yunfeiyun.agmp.iotm.common.controller.BaseController;
+import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceBaseFunReqVo;
 import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
+import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceExportReqVo;
 import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceCommonService;
 import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceRefreshService;
+import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestService;
 import com.yunfeiyun.agmp.iotm.device.xycb.domain.*;
 import com.yunfeiyun.agmp.iotm.device.xycb.service.IIotXycbService;
 import com.yunfeiyun.agmp.iotm.util.ValidateUtil;
@@ -32,14 +31,12 @@ import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
 import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceconfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 
 /**
  * 性诱测报Controller
@@ -62,7 +59,6 @@ public class IotXycbController extends BaseController
     @Autowired
     private IIotDeviceService iIotDeviceService;
 
-//    private DeviceConfigurationTranslator deviceConfigurationTranslator = new XyIIIConfigurationTranslator();
     @Autowired
     private IIotXycbService iIotXycbService;
 
@@ -72,182 +68,16 @@ public class IotXycbController extends BaseController
     @Resource
     private IotDeviceCommonService iotDeviceCommonService;
 
-    /**
-     * 性诱测报列表
-     * /list  所有性诱测报设备
-     * /pt/list 普通性诱测报设备
-     * /III/list 性诱测报III设备
-     * @param reqVo
-     * @return
-     */
-    @GetMapping({"/list", "/pt/list", "/III/list"})
-    public TableDataInfo list(HttpServletRequest request, IotDeviceListReqVo reqVo) {
-        startPage();
-        String reqUri = request.getRequestURI();
-        String[] devTypeList = new String[]{
-                IotDeviceDictConst.TYPE_YF_XYCB_III
-        };
-
-        if(reqUri.endsWith("/pt/list")){
-            devTypeList = new String[]{IotDeviceDictConst.TYPE_YF_XYCB_III};
-        } else if (reqUri.endsWith("/III/list")) {
-            devTypeList = new String[]{IotDeviceDictConst.TYPE_YF_XYCB_III};
-        }
-        reqVo.setDevtypeBidList(Arrays.asList(devTypeList));
-        List<IotDeviceListResVo> list = iIotDeviceService.selectIotDeviceListByType(reqVo);
-        return getDataTable(list);
-    }
-
-
-    /**
-     * 性诱测报数据列表
-     */
-    @PreAuthorize("@ss.hasPermi('iot:xycb:data:list')")
-    @GetMapping("/data/list")
-    public TableDataInfo list(IotXycbReqVo iotXycbReqVo)
-    {
-        return getDataTable(iIotXycbService.getXycbDataList(iotXycbReqVo));
-    }
-
-
-    /**
-     * 获取性诱测报折线图数据
-     * @param
-     * @return
-     */
-    @GetMapping("/polyline")
-    public AjaxResult polyline(IotXycbReqVo iotXycbReqVo){
-        List<IotXycbPolylineResVo> iotXycbPolylineResVoList = iIotXycbService.getXycbPolyline(iotXycbReqVo);
-        return AjaxResult.success(iotXycbPolylineResVoList);
-    }
-
-    /**
-     * 获取性诱测报信息接口
-     * @param reqVo
-     * @return
-     */
-    @PreAuthorize("@ss.hasPermi('iot:xycb:info')")
-    @GetMapping("/info")
-    public AjaxResult getInfo(String devBid){
-        IotXycbInfoResVo iotXycbInfoResVo = iIotXycbService.getXycbInfo(devBid);
-        return AjaxResult.success(iotXycbInfoResVo);
-    }
-
-    @GetMapping("/refresh/{devBid}")
-    public AjaxResult refresh(@PathVariable("devBid") String devBid) {
-        String result = iotDeviceRefreshService.refresh(devBid);
-        return new AjaxResult(ErrorCode.SUCCESS.getCode(), result, null);
-    }
+    @Autowired
+    private IIotPestService iotPestService;
 
-    @Log(title = "设备数据", businessType = BusinessType.EXPORT)
-    @PostMapping("/data/export")
-    public void dataExport(HttpServletResponse response, @RequestBody IotDeviceDataListReqVo reqVo) {
-        ValidateUtil.validateDevBid(reqVo.getDevBid());
-        String devBid = reqVo.getDevBid();
-        String startTime = reqVo.getStartTime();
-        String endTime = reqVo.getEndTime();
-        String[] params = {devBid, startTime, endTime};
-        for (String k : params) {
-            if (StringUtils.isEmpty(k)) {
-                throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "参数不能为空");
-            }
-        }
 
-        IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
 
-        //性诱III  数据导出
-        IotXycbReqVo reqVo1 = new IotXycbReqVo();
-        reqVo1.setDevBid(reqVo.getDevBid());
-        reqVo1.setStartDate(reqVo.getStartTime());
-        reqVo1.setEndDate(reqVo.getEndTime());
-        List<IotYfXycbDataListRspVo> list = iIotXycbService.exportXYIIIDataList(reqVo1,iotDevice);
-        ExcelUtil util = new ExcelUtil<>(IotYfXycbDataListRspVo.class);
-        util.exportExcel(response, list, "设备数据");
-    }
 
 
-    /**
-     * 下发测报灯配置指令
-     *
-     * @return
-     * @throws Exception
-     */
-    @PostMapping("/config/edit")
-    public AjaxResult sendConfigCmd(@RequestBody IotXYIIIConfigEditReqVo reqVo) {
-        log.info("【{}】【性诱III】【下发指令配置】客户id {}", LogCore.getSeq(), getCustomerId());
-        String devBid = reqVo.getDevBid();
-        if (StringUtils.isEmpty(devBid)) {
-            return AjaxResult.error(IotErrorCode.FAILURE.getCode(), "设备id不可为空");
-        }
-        IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
-        if (iotDevice == null) {
-            return AjaxResult.error(IotErrorCode.FAILURE.getCode(), "设备不存在");
-        }
-        IotDeviceconfig iotDeviceconfig = iIotDeviceconfigService.selectIotDeviceConfigByDevBid(devBid);
-        if (null == iotDeviceconfig) {
-            // 如果测报灯配置为空,则新增测报灯配置
-            iotDeviceconfig = new IotDeviceconfig();
-            iotDeviceconfig.setDevcfgBid(iotDeviceconfig.getUUId());
-            iotDeviceconfig.setTid(iotDevice.getTid());
-            iotDeviceconfig.setDevBid(devBid);
-            iotDeviceconfig.setDevcfgContext(JSONUtils.toJSONString(reqVo.getIotXyConfig()));
-            iotDeviceconfig.setDevcfgDelstatus("0");
-            iIotDeviceconfigService.insertIotDeviceconfig(iotDeviceconfig);
-        } else {
-            // 如果测报灯配置不为空,则更新测报灯配置
-            iotDeviceconfig.setDevcfgContext(JSONUtils.toJSONString(reqVo.getIotXyConfig()));
-            iIotDeviceconfigService.updateIotDeviceconfig(iotDeviceconfig);
-        }
-        CmdGroupModel cmdGroupModel = iIotDeviceconfigService.createConfigCmd(iotDeviceconfig);
-        log.info("【{}】【性诱III】【构建 cmdGroupModel】{}", LogCore.getSeq(), JSONUtils.toJSONString(cmdGroupModel));
-        cmdGroupModel.setRequestId(IdUtils.fastUUID());
-
-        // 适配增加详细日志使用
-        cmdGroupModel.setDevCode(iotDevice.getDevCode());
-        cmdGroupModel.setCtBiztitle(iotDevice.getDevtypeName() + ":" + iotDevice.getDevCode());
-        cmdGroupModel.setCtBiztype("3");
-        cmdGroupModel.setCtDevtype(iotDevice.getDevtypeBid());
-        cmdGroupModel.setCtParam(JSONUtils.toJSONString(reqVo));
-        iIotCmdtaskService.handInternalCmd(cmdGroupModel);
-        String taskId = cmdGroupModel.getTaskUuid();
-        return new AjaxResult(ErrorCode.SUCCESS.getCode(), "下发成功,等待设备响应结果", taskId);
-    }
-
-    @GetMapping("/config/info/{devBid}")
-    public AjaxResult configInfo(@PathVariable("devBid") String devBid){
-        if(StringUtils.isEmpty(devBid)){
-            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"参数不能为空");
-        }
-        IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
-        if(iotDevice == null){
-            throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"设备不存在");
-        }
-        IotDeviceconfig iotDeviceconfig = iIotDeviceconfigService.selectIotDeviceConfigByDevBid(devBid);
-        JSONObject jsonObject = JSONObject.parseObject(iotDeviceconfig.getDevcfgContext());
-        return AjaxResult.success(jsonObject);
-    }
 
 
-    /**
-     *
-     * @param reqVo
-     * @return
-     */
-    @PreAuthorize("@ss.hasPermi('iot:xycb:lure')")
-    @PostMapping("/lure")
-    public AjaxResult modifyLure(@RequestBody IotXycbModifyLureReqVo iotXycbModifyLureReqVo){
-        return AjaxResult.success(iIotXycbService.modifyLure(iotXycbModifyLureReqVo));
-    }
 
-    /**
-     * 查询诱芯列表
-     */
-    @PreAuthorize("@ss.hasPermi('iot:xycb:lure:list')")
-    @GetMapping("/lure/list")
-    public TableDataInfo list(IotXycbLureListReqVo iotXycbLureListReqVo)
-    {
-        return getDataTable(iIotXycbService.getLureList(iotXycbLureListReqVo));
-    }
 //
 //    /**
 //     * 查询图片列表
@@ -371,4 +201,185 @@ public class IotXycbController extends BaseController
 //    {
 //        return toAjax(iotPestService.deleteIotPestByIds(ids));
 //    }
+
+    /**
+     * 性诱测报列表
+     * /list  所有性诱测报设备
+     * /pt/list 普通性诱测报设备
+     * /III/list 性诱测报III设备
+     * @param reqVo
+     * @return
+     */
+    @GetMapping({"/list", "/pt/list", "/III/list"})
+    public TableDataInfo list(HttpServletRequest request, IotDeviceListReqVo reqVo) {
+        startPage();
+        String reqUri = request.getRequestURI();
+        String[] devTypeList = new String[]{
+                IotDeviceDictConst.TYPE_YF_XYCB_III
+        };
+
+        if(reqUri.endsWith("/pt/list")){
+            devTypeList = new String[]{IotDeviceDictConst.TYPE_YF_XYCB_III};
+        } else if (reqUri.endsWith("/III/list")) {
+            devTypeList = new String[]{IotDeviceDictConst.TYPE_YF_XYCB_III};
+        }
+        reqVo.setDevtypeBidList(Arrays.asList(devTypeList));
+        List<IotDeviceListResVo> list = iIotDeviceService.selectIotDeviceListByType(reqVo);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 数据列表
+     * @param reqVo
+     * @return
+     */
+    @GetMapping("/data/list")
+    public TableDataInfo dataList(IotDeviceDataListReqVo reqVo) {
+        ValidateUtil.validateDevBid(reqVo.getDevBid());
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("dataList");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        return iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+    }
+
+    /**
+     * 数据折线图列表
+     * @param reqVo
+     * @return
+     */
+    @GetMapping("/chart/list")
+    public AjaxResult chartList(IotDeviceDataListReqVo reqVo) {
+        ValidateUtil.validateDevBid(reqVo.getDevBid());
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("chartList");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        List<IotXycbPolylineResVo> list = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * 获取性诱测报信息接口
+     * @param reqVo
+     * @return
+     */
+    @GetMapping("/info")
+    public AjaxResult info(IotDeviceDataListReqVo reqVo) {
+        ValidateUtil.validateDevBid(reqVo.getDevBid());
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("info");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        IotXycbInfoResVo xycbInfoResVo = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+        return AjaxResult.success(xycbInfoResVo);
+    }
+
+    @GetMapping("/refresh/{devBid}")
+    public AjaxResult refresh(@PathVariable("devBid") String devBid) {
+        String result = iotDeviceRefreshService.refresh(devBid);
+        return new AjaxResult(ErrorCode.SUCCESS.getCode(), result, null);
+    }
+
+    @PostMapping("/data/export")
+    public void dataExport(HttpServletResponse response, @RequestBody IotDeviceDataListReqVo reqVo){
+        ValidateUtil.validateDevBid(reqVo.getDevBid());
+        IotDeviceExportReqVo iotDeviceExportReqVo = new IotDeviceExportReqVo();
+        iotDeviceExportReqVo.setResponse(response);
+        iotDeviceExportReqVo.setReqVo(reqVo);
+
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("dataExport");
+        iotDeviceBaseFunReqVo.setParam(iotDeviceExportReqVo);
+        iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+    }
+
+    @GetMapping("/config/info/{devBid}")
+    public AjaxResult configInfo(@PathVariable("devBid") String devBid){
+        IotDeviceDataListReqVo reqVo = new IotDeviceDataListReqVo();
+        reqVo.setDevBid(devBid);
+
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("configInfo");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        JSONObject jsonObject = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+        return AjaxResult.success(jsonObject);
+    }
+
+    /**
+     * 下发配置指令
+     *
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/config/edit")
+    public AjaxResult sendConfigCmd(@RequestBody IotXycbConfigEditReqVo reqVo) {
+        ValidateUtil.validateDevBid(reqVo.getDevBid());
+        log.info("【{}】【性诱测报】【下发指令配置】客户id {}", LogCore.getSeq(), getCustomerId());
+        String devBid = reqVo.getDevBid();
+        JSONObject xycbConfig = reqVo.getIotXyConfig();
+        if(StringUtils.isEmpty(devBid) || xycbConfig == null){
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"参数不能为空");
+        }
+        IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
+        if(iotDevice == null){
+            throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"设备不存在");
+        }
+        String devStatus = iotDevice.getDevStatus();
+        String devCreateddate = iotDevice.getDevCreateddate();
+        Date createdDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, devCreateddate);
+        Date nowDate = DateUtils.getNowDate();
+        long diffTime = nowDate.getTime() - createdDate.getTime();
+        if(diffTime > 10 * 1000){
+            if (!Objects.equals(devStatus, IotDeviceStatusTypeEnum.ONLINE.getCode()) && !Objects.equals(devStatus, IotDeviceStatusTypeEnum.WAIT_ACTIVATE.getCode())) {
+                throw new IotBizException(IotErrorCode.FAILURE.getCode(), "设备离线无法操作");
+            }
+        }
+
+        reqVo.setIotDevice(iotDevice);
+
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("sendConfigCmd");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        String taskId = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+
+        return new AjaxResult(ErrorCode.SUCCESS.getCode(), "下发成功,等待设备响应结果", taskId);
+    }
+
+    @GetMapping("/lure")
+    public AjaxResult modifyLure(IotXycbModifyLureReqVo reqVo){
+        IotDeviceBaseFunReqVo iotDeviceBaseFunReqVo = new IotDeviceBaseFunReqVo();
+        iotDeviceBaseFunReqVo.setDevBid(reqVo.getDevBid());
+        iotDeviceBaseFunReqVo.setMethodName("modifyLure");
+        iotDeviceBaseFunReqVo.setParam(reqVo);
+        int status = iotDeviceCommonService.func(iotDeviceBaseFunReqVo);
+        return AjaxResult.success(status);
+    }
+
+    /**
+     * 数据列表
+     * @param reqVo
+     * @return
+     */
+    @GetMapping("/lure/list")
+    public TableDataInfo lureList(IotXycbLureListReqVo reqVo) {
+        IotPest selectIotPest = new IotPest();
+        selectIotPest.setPestName(reqVo.getPestName());
+
+        startPage();
+        List<IotPest> iotPestList = iotPestService.selectIotPestList(selectIotPest);
+        List<IotXycbLureListRspVo> iotXycbLureListRspVoList = new ArrayList<>();
+        for(IotPest iotPest: iotPestList){
+            IotXycbLureListRspVo iotXycbLureListRspVo = new IotXycbLureListRspVo();
+            iotXycbLureListRspVo.setPestName(iotPest.getPestName());
+            iotXycbLureListRspVo.setPestBusid(iotPest.getPestBid());
+
+            iotXycbLureListRspVoList.add(iotXycbLureListRspVo);
+        }
+        return getDataTable(iotXycbLureListRspVoList);
+    }
 }

+ 12 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/xycb/domain/IotXycbConfigEditReqVo.java

@@ -0,0 +1,12 @@
+package com.yunfeiyun.agmp.iotm.device.xycb.domain;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
+import lombok.Data;
+
+@Data
+public class IotXycbConfigEditReqVo {
+    private String devBid;
+    private JSONObject iotXyConfig;
+    private IotDevice iotDevice;
+}

+ 410 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/xycb/service/IIotXycbCommService.java

@@ -0,0 +1,410 @@
+package com.yunfeiyun.agmp.iotm.device.xycb.service;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
+import com.yunfeiyun.agmp.common.core.page.PageDomain;
+import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
+import com.yunfeiyun.agmp.common.core.page.TableSupport;
+import com.yunfeiyun.agmp.common.log.LogCore;
+import com.yunfeiyun.agmp.common.utils.DateUtils;
+import com.yunfeiyun.agmp.common.utils.JSONUtils;
+import com.yunfeiyun.agmp.common.utils.SecurityUtils;
+import com.yunfeiyun.agmp.common.utils.StringUtils;
+import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
+import com.yunfeiyun.agmp.common.utils.uuid.IdUtils;
+import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
+import com.yunfeiyun.agmp.iot.common.domain.*;
+import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
+import com.yunfeiyun.agmp.iot.common.model.cmd.CmdGroupModel;
+import com.yunfeiyun.agmp.iot.common.service.IotWeatherService;
+import com.yunfeiyun.agmp.iot.common.service.MongoService;
+import com.yunfeiyun.agmp.iotm.device.common.domin.DeviceRefreshDto;
+import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
+import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceExportReqVo;
+import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceBaseService;
+import com.yunfeiyun.agmp.iotm.device.common.service.impl.IotDeviceBaseServiceImpl;
+import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestService;
+import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestrecogService;
+import com.yunfeiyun.agmp.iotm.device.xycb.domain.*;
+import com.yunfeiyun.agmp.iotm.util.MongoUtil;
+import com.yunfeiyun.agmp.iotm.web.service.IIotCmdtaskService;
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
+import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceconfigService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.aggregation.*;
+import org.springframework.data.mongodb.core.query.Criteria;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+
+@Slf4j
+public class IIotXycbCommService extends IotDeviceBaseServiceImpl implements IotDeviceBaseService {
+    @Autowired
+    private IIotDeviceService iotDeviceService;
+
+    @Autowired
+    private MongoService mongoService;
+
+    @Autowired
+    private IIotCmdtaskService iIotCmdtaskService;
+
+    @Resource
+    private IIotDeviceconfigService iIotDeviceconfigService;
+
+    @Autowired
+    private IIotDeviceService iIotDeviceService;
+
+    @Autowired
+    private IIotXyinfoService iIotXyinfoService;
+
+    @Autowired
+    private IotWeatherService iotWeatherService;
+
+    @Autowired
+    private IIotPestrecogService iIotPestrecogService;
+
+    @Autowired
+    private IIotXycbService iIotXycbService;
+
+    @Autowired
+    private IIotPestService iotPestService;
+
+    public Class getTableClass(String devtypeBid) {
+        Class tableClass = null;
+        switch (devtypeBid){
+            case IotDeviceDictConst.TYPE_YF_XYCB_III:
+                tableClass = IotYfXycbIIIdata.class;
+                break;
+            default:
+                break;
+        }
+        return tableClass;
+    }
+
+    public TableDataInfo dataList(IotDeviceDataListReqVo reqVo){
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(ErrorCode.SUCCESS.getCode());
+        rspData.setMsg(ErrorCode.SUCCESS.getMessage());
+        rspData.setData(new ArrayList<>());
+        rspData.setTotal(0);
+
+        String devBid = reqVo.getDevBid();
+        String startTime = reqVo.getStartTime();
+        String endTime = reqVo.getEndTime();
+
+        if (startTime == null || endTime == null) {
+            throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "请输入正确的起止时间");
+        }
+
+        IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
+        if (findDevice == null) {
+            throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备不存在");
+        }
+
+        Map<String, Object> cases = new HashMap<>();
+        cases.put("devBid", devBid);
+        cases.put("time_xycbdataCreatedDate", startTime +  "," + endTime);
+
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        if(Objects.equals(pageDomain.getOrderByColumn(), "xycbdataCreatedDate")){
+            pageDomain.setOrderByColumn("xycbdataCreatedDate");
+        }
+        Class tableClass = getTableClass(findDevice.getDevtypeBid());
+        IPage listPage = mongoService.findListPage(tableClass, cases, pageDomain);
+
+        List<IotYfXycbdata> iotYfXycbdataList = listPage.getRecords();
+        List<IotYfXycbDataListRspVo> iotYfXycbDataListRspVoList = new ArrayList<>();
+        for(IotYfXycbdata xycbdata: iotYfXycbdataList){
+            JSONObject jsonObject = xycbdata.getXycbdataContent();
+            String cs = "0";
+            if(!Objects.equals(jsonObject.getInteger("b_c"), 0)){
+                cs = "1";
+            }
+            IotYfXycbDataListRspVo xycbDataListRspVo = new IotYfXycbDataListRspVo();
+            xycbDataListRspVo.setDevBid(devBid);
+            xycbDataListRspVo.setDs("1");
+            xycbDataListRspVo.setWs("1");
+            xycbDataListRspVo.setAt(jsonObject.getString("at"));
+            xycbDataListRspVo.setAh(jsonObject.getString("ah"));
+            xycbDataListRspVo.setBs("0");
+            xycbDataListRspVo.setCs(cs);
+            xycbDataListRspVo.setCv(jsonObject.getString("cv"));
+            xycbDataListRspVo.setBv(jsonObject.getString("bv"));
+            xycbDataListRspVo.setCt((String) jsonObject.getOrDefault("infr_ct", "0"));
+            xycbDataListRspVo.setCreatedDate(xycbdata.getXycbdataCreatedDate());
+
+            iotYfXycbDataListRspVoList.add(xycbDataListRspVo);
+        }
+        rspData.setData(iotYfXycbDataListRspVoList);
+        rspData.setTotal(listPage.getTotal());
+        return rspData;
+    }
+
+    /**
+     * 获取折线图数据列表接口
+     *
+     * @param reqVo
+     */
+    public List<IotXycbPolylineResVo> chartList(IotDeviceDataListReqVo reqVo) {
+        String devBid = reqVo.getDevBid();
+        if (StringUtils.isEmpty(devBid)) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
+        }
+        String startDate = reqVo.getStartTime();
+        String endDate = reqVo.getEndTime();
+        String unit = "day";
+
+        Criteria criteria = new Criteria().and("devBid").is(devBid);
+
+        //必须设置起止时间
+        if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){
+            //限制 起止时间
+            criteria = criteria.andOperator(
+                    Criteria.where("xycbdataCreatedDate").gte(startDate),
+                    Criteria.where("xycbdataCreatedDate").lte(endDate)
+            );
+            //选择 数据粒度
+            unit = MongoUtil.getDateTruncUnit(startDate, endDate);
+        }
+
+        MatchOperation matchOperation = Aggregation.match(criteria);
+
+        ProjectionOperation projectionOperation = Aggregation.project()
+                .and("xycbdataContent.ah").as("ah")
+                .and("xycbdataContent.at").as("at")
+                .and("xycbdataContent.ct").as("ct")
+                .and("xycbdataCreatedDate").as("createDate");
+
+        ProjectionOperation projectionOperation2 = Aggregation.project()
+                .andExpression("{$convert: {input: '$ct', to: 'int', onError: 0, onNull: 0}}").as("ct")
+                .andExpression("{$convert: {input: '$at', to: 'double', onError: -99, onNull: -99}}").as("at")
+                .andExpression("{$convert: {input: '$ah', to: 'double', onError: -99, onNull: -99}}").as("ah")
+                .andExpression("{$dateTrunc: {date: {$toDate: '$createDate'}, unit:'" + unit + "'}}").as("createDate");
+
+        GroupOperation groupOperation = Aggregation.group("createDate")
+                .avg("ah").as("ah")
+                .avg("at").as("at")
+                .sum("ct").as("ct");
+
+        ProjectionOperation projectionOperation3 = Aggregation.project("ct")
+                .andExpression("{$trunc: {'$ah', 1}}").as("ah")
+                .andExpression("{$trunc: {'$at', 1}}").as("at")
+                .andExpression("{$dateToString: {format: '%Y-%m-%d %H:%M:%S', date: '$_id'}}").as("createDate");
+
+        SortOperation sortOperation = Aggregation.sort(Sort.Direction.ASC, "createDate");
+
+        Aggregation aggregation = Aggregation.newAggregation(
+                matchOperation,
+                projectionOperation,
+                projectionOperation2,
+                groupOperation,
+                projectionOperation3,
+                sortOperation
+        );
+
+        List<IotXycbPolylineResVo> iotXycbPolylineResVos = mongoService.aggregate(
+                IotYfXycbIIIdata.class, aggregation, IotXycbPolylineResVo.class
+        );
+        return iotXycbPolylineResVos;
+    }
+
+    /**
+     * 获取性诱测报信息接口
+     *
+     * @param reqVo
+     */
+    public IotXycbInfoResVo info(IotDeviceDataListReqVo reqVo) {
+        String devBid = reqVo.getDevBid();
+        if (StringUtils.isEmpty(devBid)) {
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
+        }
+        IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
+        if(iotDevice == null){
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
+        }
+
+        IotXycbInfoResVo iotXycbInfoResVo = new IotXycbInfoResVo();
+        iotXycbInfoResVo.setDevStatus(iotDevice.getDevStatus());
+
+        IotXyinfoDto iotXyinfoDto = iIotXyinfoService.selectIotXyinfoByDevBid(devBid);
+        if(iotXyinfoDto != null){
+            iotXycbInfoResVo.setXyinfoLurename(iotXyinfoDto.getXyinfoLurename());
+            iotXycbInfoResVo.setXyinfoLureexpireddate(iotXyinfoDto.getXyinfoLureexpireddate());
+        }
+
+        String province = StringUtils.isEmpty(iotDevice.getDevProvincealign()) ? iotDevice.getDevProvince(): iotDevice.getDevProvincealign();
+        String city = StringUtils.isEmpty(iotDevice.getDevCityalign()) ? iotDevice.getDevCity(): iotDevice.getDevCityalign();
+        String district = StringUtils.isEmpty(iotDevice.getDevDistrictalign()) ? iotDevice.getDevDistrict(): iotDevice.getDevDistrictalign();
+        if(StringUtils.isNotEmpty(province) && StringUtils.isNotEmpty(city)){
+            JSONObject weatherInfo = iotWeatherService.getWeatherByAddress(province, city, district);
+            iotXycbInfoResVo.setWea(weatherInfo.getString("wea"));
+            iotXycbInfoResVo.setWin(weatherInfo.getString("win"));
+            iotXycbInfoResVo.setWin_speed(weatherInfo.getString("win_speed"));
+            String rainStatusName = !Objects.equals(weatherInfo.getString("rain_pcpn"), "0") ? "是" : "否";
+            iotXycbInfoResVo.setRainStatusName(rainStatusName);
+        }
+
+        HashMap<String, String> params = new HashMap<>();
+        params.put("devBid", devBid);
+
+        Class tableClass = getTableClass(iotDevice.getDevtypeBid());
+        IotYfXycbdata iotYfXycbdata = (IotYfXycbdata) mongoService.findOne(tableClass, params, "xycbdataCreatedDate", "desc");
+        if(iotYfXycbdata != null){
+            JSONObject xyData = iotYfXycbdata.getXycbdataContent();
+            iotXycbInfoResVo.setAt(xyData.getString("at"));
+            iotXycbInfoResVo.setAh(xyData.getString("ah"));
+        }
+
+        List<String> devBidList = new ArrayList<>();
+        devBidList.add(devBid);
+
+        Map<String, IotXyinfoPestTotalDto>  iotXyinfoPestTotalDtoMap = iIotPestrecogService.getIotXyIIIinfoPestTotalMap(devBidList);
+        if(iotXyinfoPestTotalDtoMap.containsKey(devBid)){
+            iotXycbInfoResVo.setPestTotal(String.valueOf(iotXyinfoPestTotalDtoMap.get(devBid).getPestTotal()));
+        }
+        return iotXycbInfoResVo;
+    }
+
+    /**
+     * 刷新指令集
+     *
+     * @param reqVo
+     */
+    public void refresh(DeviceRefreshDto reqVo) {
+
+        IotDevice findDevice = reqVo.getIotDevice();
+        String devBid = findDevice.getDevBid();
+        log.info("创建【“刷新”指令集任务】,设备类型:{}", findDevice.getDevtypeName());
+        JSONObject payload = new JSONObject();
+        payload.put("cmd", "read");
+        payload.put("ext", "data");
+        IotDeviceconfig iotDeviceconfig = new IotDeviceconfig();
+        iotDeviceconfig.setTid(findDevice.getTid());
+        iotDeviceconfig.setDevBid(devBid);
+        iotDeviceconfig.setDevcfgContext(JSONUtils.toJSONString(payload));
+
+        CmdGroupModel cmdGroupModel = iIotDeviceconfigService.createRefreshCmd(iotDeviceconfig);
+
+        // 构建日志需要用的内容
+        cmdGroupModel.setRequestId(IdUtils.fastUUID());
+        cmdGroupModel.setDevCode(findDevice.getDevCode());
+        cmdGroupModel.setCtBiztype("3");
+        cmdGroupModel.setCtDevtype(findDevice.getDevtypeBid());
+        cmdGroupModel.setCtBiztitle(findDevice.getDevtypeName() + ":" + findDevice.getDevCode());
+        cmdGroupModel.setCtParam("设备id:" + devBid);
+        iIotCmdtaskService.handInternalCmd(cmdGroupModel);
+        String taskUuid = cmdGroupModel.getTaskUuid();
+        log.info("【“刷新”指令集任务】创建成功,taskUuid:{}", taskUuid);
+    }
+
+    /**
+     * 数据导出
+     *
+     * @param iotDeviceExportReqVo
+     */
+    public void dataExport(IotDeviceExportReqVo iotDeviceExportReqVo) {
+        HttpServletResponse response = iotDeviceExportReqVo.getResponse();
+        IotDeviceDataListReqVo reqVo = iotDeviceExportReqVo.getReqVo();
+
+        String devBid = reqVo.getDevBid();
+        String startTime = reqVo.getStartTime();
+        String endTime = reqVo.getEndTime();
+        String[] params = {devBid, startTime, endTime};
+        for (String k : params) {
+            if (StringUtils.isEmpty(k)) {
+                throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(), "参数不能为空");
+            }
+        }
+
+        IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
+
+        //性诱III  数据导出
+        IotXycbReqVo reqVo1 = new IotXycbReqVo();
+        reqVo1.setDevBid(reqVo.getDevBid());
+        reqVo1.setStartDate(reqVo.getStartTime());
+        reqVo1.setEndDate(reqVo.getEndTime());
+        List<IotYfXycbDataListRspVo> list = iIotXycbService.exportXYIIIDataList(reqVo1,iotDevice);
+        ExcelUtil util = new ExcelUtil<>(IotYfXycbDataListRspVo.class);
+        util.exportExcel(response, list, "设备数据");
+    }
+
+    public JSONObject configInfo(IotDeviceDataListReqVo reqVo){
+        String devBid = reqVo.getDevBid();
+        if(StringUtils.isEmpty(devBid)){
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"参数不能为空");
+        }
+        IotDeviceconfig iotDeviceconfig = iIotDeviceconfigService.selectIotDeviceConfigByDevBid(devBid);
+        return JSONObject.parseObject(iotDeviceconfig.getDevcfgContext());
+    }
+
+    public String sendConfigCmd(IotXycbConfigEditReqVo reqVo) {
+        String devBid = reqVo.getDevBid();
+        if (StringUtils.isEmpty(devBid)) {
+            throw new IotBizException(IotErrorCode.PARAM_INVALID.getCode(),"设备标识不能为空");
+        }
+        IotDevice iotDevice = reqVo.getIotDevice();
+        IotDeviceconfig iotDeviceconfig = iIotDeviceconfigService.selectIotDeviceConfigByDevBid(devBid);
+        if (null == iotDeviceconfig) {
+            // 如果测报灯配置为空,则新增测报灯配置
+            iotDeviceconfig = new IotDeviceconfig();
+            iotDeviceconfig.setDevcfgBid(iotDeviceconfig.getUUId());
+            iotDeviceconfig.setTid(iotDevice.getTid());
+            iotDeviceconfig.setDevBid(devBid);
+            iotDeviceconfig.setDevcfgContext(JSONUtils.toJSONString(reqVo.getIotXyConfig()));
+            iotDeviceconfig.setDevcfgDelstatus("0");
+            iIotDeviceconfigService.insertIotDeviceconfig(iotDeviceconfig);
+        } else {
+            // 如果测报灯配置不为空,则更新测报灯配置
+            iotDeviceconfig.setDevcfgContext(JSONUtils.toJSONString(reqVo.getIotXyConfig()));
+            iIotDeviceconfigService.updateIotDeviceconfig(iotDeviceconfig);
+        }
+        CmdGroupModel cmdGroupModel = iIotDeviceconfigService.createConfigCmd(iotDeviceconfig);
+        log.info("【{}】【性诱测报】【构建 cmdGroupModel】{}", LogCore.getSeq(), JSONUtils.toJSONString(cmdGroupModel));
+        cmdGroupModel.setRequestId(IdUtils.fastUUID());
+
+        // 适配增加详细日志使用
+        cmdGroupModel.setDevCode(iotDevice.getDevCode());
+        cmdGroupModel.setCtBiztitle(iotDevice.getDevtypeName() + ":" + iotDevice.getDevCode());
+        cmdGroupModel.setCtBiztype("3");
+        cmdGroupModel.setCtDevtype(iotDevice.getDevtypeBid());
+        cmdGroupModel.setCtParam(JSONUtils.toJSONString(reqVo));
+        iIotCmdtaskService.handInternalCmd(cmdGroupModel);
+        return cmdGroupModel.getTaskUuid();
+    }
+
+    public int modifyLure(IotXycbModifyLureReqVo reqVo) {
+        String devBid = reqVo.getDevBid();
+        String pestBusid = reqVo.getPestBusid();
+        IotPest iotPest = iotPestService.selectIotPestByPestBid(pestBusid);
+        if(iotPest == null){
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "诱芯不存在");
+        }
+        IotXyinfoDto iotXyinfoDto = iIotXyinfoService.selectIotXyinfoByDevBid(devBid);
+
+        IotXyinfo iotXyinfo = new IotXyinfo();
+        iotXyinfo.setDevBid(reqVo.getDevBid());
+        iotXyinfo.setPestBusid(iotPest.getPestBid());
+        iotXyinfo.setXyinfoLurename(iotPest.getPestName());
+        iotXyinfo.setXyinfoLureexpireddate(reqVo.getXyinfoLureexpireddate());
+        iotXyinfo.setXyinfoModifier(SecurityUtils.getUserId());
+        iotXyinfo.setXyinfoModifieddate(DateUtils.dateTimeNow());
+
+        int status = 0;
+        if(iotXyinfoDto == null){
+            iotXyinfo.setXyinfoBid(iotXyinfo.getUUId());
+            iotXyinfo.setXyinfoCreator(SecurityUtils.getUserId());
+            iotXyinfo.setXyinfoCreatedDate(DateUtils.dateTimeNow());
+            iotXyinfo.setXyinfoDelstatus("0");
+
+            status = iIotXyinfoService.insertIotXyinfo(iotXyinfo);
+        }else{
+            status = iIotXyinfoService.updateIotXyinfo(iotXyinfo);
+        }
+        return status;
+    }
+}

+ 0 - 45
src/main/java/com/yunfeiyun/agmp/iotm/device/xycb/service/IIotXycbIIIService.java

@@ -1,45 +0,0 @@
-//package com.yunfeiyun.agmp.iotm.device.xycb.service;
-//
-//import com.baomidou.mybatisplus.core.metadata.IPage;
-//import com.yunfeiyun.agmp.iot.common.domain.resvo.IotDeviceResVo;
-//import com.yunfeiyun.agmp.iotm.device.xycb.domain.*;
-//
-//import java.util.List;
-//
-//public interface IIotXycbIIIService {
-//    /**
-//     * 获取性诱设备数据列表
-//     * @param iotXycbReqVo
-//     */
-//    public IPage<IotYfXycbDataListRspVo> getXycbDataList(IotXycbReqVo iotXycbReqVo);
-//
-//    /**
-//     * 获取性诱测报折线图数据
-//     * @param iotXycbReqVo
-//     */
-//    public List<IotXycbPolylineResVo> getXycbPolyline(IotXycbReqVo iotXycbReqVo);
-//
-//    /**
-//     * 获取性诱测报信息
-//     * @param
-//     */
-//    public IotXycbInfoResVo getXycbInfo(String devBid);
-//
-//    /**
-//     * 修改诱芯信息
-//     * @param
-//     */
-//    public int modifyLure(IotXycbModifyLureReqVo iotXycbModifyLureReqVo);
-//
-//    /**
-//     * 获取诱芯列表
-//     * @return
-//     */
-//    public List<IotXycbLureListRspVo> getLureList(IotXycbLureListReqVo iotXycbLureListReqVo);
-//
-//    public List<IotYfXycbDataListRspVo> exportDataList(IotXycbReqVo iotXycbReqVo, IotDeviceResVo device);
-//
-//    public IPage getImageList(IotXycbReqVo iotXycbReqVo);
-//
-//    public void imageDelete(String xycbimgBid);
-//}

+ 12 - 713
src/main/java/com/yunfeiyun/agmp/iotm/device/xycb/service/impl/IotXycbIIIServiceImpl.java

@@ -1,713 +1,12 @@
-//package com.yunfeiyun.agmp.iotm.device.xycb.service.impl;
-//
-//import com.alibaba.fastjson2.JSONObject;
-//import com.baomidou.mybatisplus.core.metadata.IPage;
-//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-//import com.yunfeiyun.agmp.common.core.page.PageDomain;
-//import com.yunfeiyun.agmp.common.core.page.TableSupport;
-//import com.yunfeiyun.agmp.common.utils.DateUtils;
-//import com.yunfeiyun.agmp.common.utils.SecurityUtils;
-//import com.yunfeiyun.agmp.common.utils.StringUtils;
-//import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
-//import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
-//import com.yunfeiyun.agmp.iot.common.domain.*;
-//import com.yunfeiyun.agmp.iot.common.domain.resvo.IotDeviceResVo;
-//import com.yunfeiyun.agmp.iot.common.domain.resvo.IotXycbimgListResVo;
-//import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
-//import com.yunfeiyun.agmp.iot.common.service.IotWeatherService;
-//import com.yunfeiyun.agmp.iot.common.service.MongoService;
-//import com.yunfeiyun.agmp.iotm.device.domain.dtovo.IotXyinfoDto;
-//import com.yunfeiyun.agmp.iotm.device.domain.dtovo.IotXyinfoPestTotalDto;
-//import com.yunfeiyun.agmp.iotm.device.domain.reqvo.IotXycbLureListReqVo;
-//import com.yunfeiyun.agmp.iotm.device.domain.reqvo.IotXycbModifyLureReqVo;
-//import com.yunfeiyun.agmp.iotm.device.domain.reqvo.IotXycbReqVo;
-//import com.yunfeiyun.agmp.iotm.device.domain.resvo.*;
-//import com.yunfeiyun.agmp.iotm.device.service.*;
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.data.domain.Sort;
-//import org.springframework.data.mongodb.core.aggregation.*;
-//import org.springframework.data.mongodb.core.query.Criteria;
-//import org.springframework.data.mongodb.core.query.Query;
-//import org.springframework.stereotype.Service;
-//
-//import java.util.*;
-//
-//import static com.yunfeiyun.agmp.common.utils.PageUtils.startPage;
-//
-//@Slf4j
-//@Service
-//public class IotXycbIIIServiceImpl implements IIotXycbIIIService {
-//
-//    @Autowired
-//    private IIotDeviceService iIotDeviceService;
-//
-//    @Autowired
-//    private MongoService mongoService;
-//
-//    @Autowired
-//    private IotWeatherService iotWeatherService;
-//
-//    @Autowired
-//    private IIotXyinfoService iIotXyinfoService;
-//
-//    @Autowired
-//    private IIotPestrecogService iIotPestrecogService;
-//
-//    @Autowired
-//    private IIotPestService iotPestService;
-//
-//
-//    /**
-//     * 性诱测报2.0
-//     * @param reqVo
-//     * @return
-//     */
-//    private IPage<IotYfXycbDataListRspVo> getYfXycb2DataList(IotXycbReqVo reqVo){
-//        String devBid = reqVo.getDevBid();
-//
-//        Map<String, Object> cases = new HashMap<>();
-//        cases.put("devBid", devBid);
-//
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isEmpty(reqVo.getEndDate())) {
-//            cases.put("gte_xycb2dataCreatedDate", reqVo.getStartDate());
-//        }
-//        if (StringUtils.isEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("lte_xycb2dataCreatedDate", reqVo.getEndDate());
-//        }
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("time_xycb2dataCreatedDate", reqVo.getStartDate() + "," + reqVo.getEndDate());
-//        }
-//        cases.remove("startDate");
-//        cases.remove("endDate");
-//
-//        PageDomain pageDomain = TableSupport.buildPageRequest();
-//        if(Objects.equals(pageDomain.getOrderByColumn(), "xycbdataCreatedDate")){
-//            pageDomain.setOrderByColumn("xycb2dataCreatedDate");
-//        }
-//
-//        IPage listPage = mongoService.findListPage(IotYfXycb2data.class, cases, pageDomain);
-//        List<IotYfXycb2data> iotYfXycb2dataList = listPage.getRecords();
-//        List<IotYfXycbDataListRspVo> iotYfXycbDataListRspVoList = new ArrayList<>();
-//        for(IotYfXycb2data iotYfXycb2data: iotYfXycb2dataList){
-//            JSONObject jsonObject = iotYfXycb2data.getXycb2dataContent();
-//            String cs = "0";
-//            if(!Objects.equals(jsonObject.getInteger("b_c"), 0)){
-//                cs = "1";
-//            }
-//            IotYfXycbDataListRspVo xycbDataListRspVo = new IotYfXycbDataListRspVo();
-//            xycbDataListRspVo.setDevBid(devBid);
-//            xycbDataListRspVo.setDs("1");
-//            xycbDataListRspVo.setWs("1");
-//            xycbDataListRspVo.setAt(jsonObject.getString("at"));
-//            xycbDataListRspVo.setAh(jsonObject.getString("ah"));
-//            xycbDataListRspVo.setBs("0");
-//            xycbDataListRspVo.setCs(cs);
-//            xycbDataListRspVo.setCv("0");
-//            xycbDataListRspVo.setBv(jsonObject.getString("b_v"));
-//            xycbDataListRspVo.setCt((String) jsonObject.getOrDefault("ct", "0"));
-//            xycbDataListRspVo.setCreatedDate(iotYfXycb2data.getXycb2dataCreatedDate());
-//
-//            iotYfXycbDataListRspVoList.add(xycbDataListRspVo);
-//        }
-//        listPage.setRecords(iotYfXycbDataListRspVoList);
-//
-//        return listPage;
-//    }
-//
-//    /**
-//     * 性诱测报2.0
-//     * @param reqVo
-//     * @return
-//     */
-//    private IPage<IotYfXycbDataListRspVo> getZjsfXycbDataList(IotXycbReqVo reqVo){
-//        String devBid = reqVo.getDevBid();
-//
-//        Map<String, Object> cases = new HashMap<>();
-//        cases.put("devBid", devBid);
-//
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isEmpty(reqVo.getEndDate())) {
-//            cases.put("gte_xycbdataCreatedDate", reqVo.getStartDate());
-//        }
-//        if (StringUtils.isEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("lte_xycbdataCreatedDate", reqVo.getEndDate());
-//        }
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("time_xycbdataCreatedDate", reqVo.getStartDate() + "," + reqVo.getEndDate());
-//        }
-//        cases.remove("startDate");
-//        cases.remove("endDate");
-//
-//        PageDomain pageDomain = TableSupport.buildPageRequest();
-//        if(Objects.equals(pageDomain.getOrderByColumn(), "xycbdataCreatedDate")){
-//            pageDomain.setOrderByColumn("xycbdataCreatedDate");
-//        }
-//
-//        IPage listPage = mongoService.findListPage(IotZjsfXycbdata.class, cases, pageDomain);
-//        List<IotZjsfXycbdata> iotZjsfXycbdataList = listPage.getRecords();
-//
-//        List<IotYfXycbDataListRspVo> iotYfXycbDataListRspVoList = new ArrayList<>();
-//        for(IotZjsfXycbdata iotZjsfXycbdata: iotZjsfXycbdataList){
-//            JSONObject jsonObject = iotZjsfXycbdata.getXycbdataContent();
-//            String cs = "0";
-//            if(Objects.equals(jsonObject.getInteger("cs"), 2)){
-//                cs = "1";
-//            }
-//            IotZjsfXycbDataListRspVo xycbDataListRspVo = new IotZjsfXycbDataListRspVo();
-//            xycbDataListRspVo.setDevBid(devBid);
-//            xycbDataListRspVo.setDs("1");
-//            xycbDataListRspVo.setWs("1");
-//            xycbDataListRspVo.setAt(jsonObject.getString("at"));
-//            xycbDataListRspVo.setAh(jsonObject.getString("ah"));
-//            xycbDataListRspVo.setBs("0");
-//            xycbDataListRspVo.setCs(cs);
-//            xycbDataListRspVo.setCv("0");
-//            xycbDataListRspVo.setBv(jsonObject.getString("b_v"));
-//            xycbDataListRspVo.setLp(jsonObject.getString("lp"));
-//            xycbDataListRspVo.setLt(jsonObject.getString("lt"));
-//            xycbDataListRspVo.setSs(jsonObject.getString("ss"));
-//            xycbDataListRspVo.setWin(jsonObject.getString("win"));
-//            xycbDataListRspVo.setWin_speed(jsonObject.getString("win_speed"));
-//            xycbDataListRspVo.setCt((String) jsonObject.getOrDefault("ct", "0"));
-//
-//
-//            xycbDataListRspVo.setCreatedDate(iotZjsfXycbdata.getXycbdataCreatedDate());
-//
-//            iotYfXycbDataListRspVoList.add(xycbDataListRspVo);
-//        }
-//        listPage.setRecords(iotYfXycbDataListRspVoList);
-//
-//        return listPage;
-//    }
-//
-//    private IPage<IotYfXycbDataListRspVo> getZjsfXycbIIIDataList(IotXycbReqVo reqVo){
-//        String devBid = reqVo.getDevBid();
-//
-//        Map<String, Object> cases = new HashMap<>();
-//        cases.put("devBid", devBid);
-//
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isEmpty(reqVo.getEndDate())) {
-//            cases.put("gte_xycbdataCreatedDate", reqVo.getStartDate());
-//        }
-//        if (StringUtils.isEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("lte_xycbdataCreatedDate", reqVo.getEndDate());
-//        }
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("time_xycbdataCreatedDate", reqVo.getStartDate() + "," + reqVo.getEndDate());
-//        }
-//        cases.remove("startDate");
-//        cases.remove("endDate");
-//
-//        PageDomain pageDomain = TableSupport.buildPageRequest();
-//        if(Objects.equals(pageDomain.getOrderByColumn(), "xycbdataCreatedDate")){
-//            pageDomain.setOrderByColumn("xycbdataCreatedDate");
-//        }
-//
-//        IPage listPage = mongoService.findListPage(IotZjsfXycbdata.class, cases, pageDomain);
-//        List<IotZjsfXycbdata> iotZjsfXycbdataList = listPage.getRecords();
-//
-//        List<IotYfXycbDataListRspVo> iotYfXycbDataListRspVoList = new ArrayList<>();
-//        for(IotZjsfXycbdata iotZjsfXycbdata: iotZjsfXycbdataList){
-//            JSONObject jsonObject = iotZjsfXycbdata.getXycbdataContent();
-//            String cs = "0";
-//            if(Objects.equals(jsonObject.getInteger("cs"), 2)){
-//                cs = "1";
-//            }
-//            IotZjsfXycbDataListRspVo xycbDataListRspVo = new IotZjsfXycbDataListRspVo();
-//            xycbDataListRspVo.setDevBid(devBid);
-//            xycbDataListRspVo.setDs("1");
-//            xycbDataListRspVo.setWs("1");
-//            xycbDataListRspVo.setAt(jsonObject.getString("at"));
-//            xycbDataListRspVo.setAh(jsonObject.getString("ah"));
-//            xycbDataListRspVo.setBs("0");
-//            xycbDataListRspVo.setCs(cs);
-//            xycbDataListRspVo.setCv("0");
-//            xycbDataListRspVo.setBv(jsonObject.getString("b_v"));
-//            xycbDataListRspVo.setLp(jsonObject.getString("lp"));
-//            xycbDataListRspVo.setLt(jsonObject.getString("lt"));
-//            xycbDataListRspVo.setSs(jsonObject.getString("ss"));
-//            xycbDataListRspVo.setWin(jsonObject.getString("win"));
-//            xycbDataListRspVo.setWin_speed(jsonObject.getString("win_speed"));
-//            xycbDataListRspVo.setCt((String) jsonObject.getOrDefault("ct", "0"));
-//
-//
-//            xycbDataListRspVo.setCreatedDate(iotZjsfXycbdata.getXycbdataCreatedDate());
-//
-//            iotYfXycbDataListRspVoList.add(xycbDataListRspVo);
-//        }
-//        listPage.setRecords(iotYfXycbDataListRspVoList);
-//
-//        return listPage;
-//    }
-//
-//    /**
-//     * 性诱测报2.0   工作数据导出
-//     * @param reqVo
-//     * @return
-//     */
-//    public List<IotYfXycbDataListRspVo> exportDataList(IotXycbReqVo reqVo ,IotDeviceResVo device){
-//        String devBid = reqVo.getDevBid();
-//
-//        Map<String, Object> cases = new HashMap<>();
-//        cases.put("devBid", devBid);
-//
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isEmpty(reqVo.getEndDate())) {
-//            cases.put("gte_xycb2dataCreatedDate", reqVo.getStartDate());
-//        }
-//        if (StringUtils.isEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("lte_xycb2dataCreatedDate", reqVo.getEndDate());
-//        }
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("time_xycb2dataCreatedDate", reqVo.getStartDate() + "," + reqVo.getEndDate());
-//        }
-//        cases.remove("startDate");
-//        cases.remove("endDate");
-//
-//        List<IotYfXycb2data> iotYfXycb2dataList = mongoService.findAll(IotYfXycb2data.class, cases, "xycb2dataCreatedDate desc");
-//        List<IotYfXycbDataListRspVo> iotYfXycbDataListRspVoList = new ArrayList<>();
-//        int i=0;
-//        for(IotYfXycb2data iotYfXycb2data: iotYfXycb2dataList){
-//            i++;
-//            JSONObject jsonObject = iotYfXycb2data.getXycb2dataContent();
-//            String cs = "0";
-//            if(!Objects.equals(jsonObject.getInteger("b_c"), 0)){
-//                cs = "1";
-//            }
-//            IotYfXycbDataListRspVo xycbDataListRspVo = new IotYfXycbDataListRspVo();
-//            xycbDataListRspVo.setDevBid(devBid);
-//            xycbDataListRspVo.setDs("1");
-//            xycbDataListRspVo.setWs("1");
-//            xycbDataListRspVo.setAt(jsonObject.getString("at"));
-//            xycbDataListRspVo.setAh(jsonObject.getString("ah"));
-//            xycbDataListRspVo.setBs("0");
-//            xycbDataListRspVo.setCs(cs);
-//            xycbDataListRspVo.setCv("0");
-//            xycbDataListRspVo.setBv(jsonObject.getString("b_v"));
-//            xycbDataListRspVo.setCt((String) jsonObject.getOrDefault("ct", "0"));
-//            xycbDataListRspVo.setCreatedDate(iotYfXycb2data.getXycb2dataCreatedDate());
-//
-//            xycbDataListRspVo.setId(""+i);
-//            xycbDataListRspVo.setDevCode(device.getDevCode());
-//
-//            iotYfXycbDataListRspVoList.add(xycbDataListRspVo);
-//        }
-//
-//        return iotYfXycbDataListRspVoList;
-//    }
-//
-//    /**
-//     * @param iotXycbReqVo
-//     * @return
-//     */
-//    @Override
-//    public IPage getImageList(IotXycbReqVo reqVo) {
-//        String devBid = reqVo.getDevBid();
-//        if (StringUtils.isEmpty(devBid)) {
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
-//        }
-//        IotDevice iotDevice = iIotDeviceService.findOneByBizId(devBid);
-//        if(iotDevice == null){
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
-//        }
-//
-//        Map<String, Object> cases = new HashMap<>();
-//        cases.put("devBid", devBid);
-//        cases.put("xycbimgDelstatus", "0");
-//
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isEmpty(reqVo.getEndDate())) {
-//            cases.put("gte_xycbimgCreatedDate", reqVo.getStartDate());
-//        }
-//        if (StringUtils.isEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("lte_xycbimgCreatedDate", reqVo.getEndDate());
-//        }
-//        if (StringUtils.isNotEmpty(reqVo.getStartDate()) && StringUtils.isNotEmpty(reqVo.getEndDate())) {
-//            cases.put("time_xycbimgCreatedDate", reqVo.getStartDate() + "," + reqVo.getEndDate());
-//        }
-//        cases.remove("startDate");
-//        cases.remove("endDate");
-//
-//        PageDomain pageDomain = TableSupport.buildPageRequest();
-//        pageDomain.setOrderByColumn("xycbimgCreatedDate");
-//        pageDomain.setIsAsc("desc");
-//
-//        IPage listPage = mongoService.findListPage(IotXycbimg.class, cases, pageDomain);
-//        List records = listPage.getRecords();
-//        List<IotXycbimgListResVo> iotXycbimgListResVoList = new ArrayList<>();
-//        for (Object obj : records) {
-//            IotXycbimg iotXycbimg = (IotXycbimg) obj;
-//            IotXycbimgListResVo iotXycbimgListResVo = new IotXycbimgListResVo();
-//            iotXycbimgListResVo.setDevBid(iotXycbimg.getDevBid());
-//            iotXycbimgListResVo.setXycbimgBid(iotXycbimg.getXycbimgBid());
-//            iotXycbimgListResVo.setXycbimgAddr(iotXycbimg.getXycbimgAddr());
-//            iotXycbimgListResVo.setXycbimgCreatedDate(iotXycbimg.getXycbimgCreatedDate());
-//
-//            iotXycbimgListResVoList.add(iotXycbimgListResVo);
-//        }
-//        listPage.setRecords(iotXycbimgListResVoList);
-//
-//        return listPage;
-//    }
-//
-//    /**
-//     * @param xycbimgBid
-//     * @return
-//     */
-//    @Override
-//    public void imageDelete(String xycbimgBid) {
-//        Map<String, String> selectMap = new HashMap<>();
-//        selectMap.put("xycbimgBid", xycbimgBid);
-//        IotXycbimg iotXycbimg = (IotXycbimg) mongoService.findOne(IotXycbimg.class, selectMap, null, null);
-//        if(iotXycbimg == null){
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "图片不存在");
-//        }
-//
-//        Criteria criteria = Criteria.where("xycbimgBid").is(xycbimgBid);
-//        Query query = new Query(criteria);
-//
-//        Map<String, Object> updateField = new HashMap<>();
-//        updateField.put("xycbimgDelstatus", "1");
-//        updateField.put("xycbimgModifieddate", DateUtils.dateTimeNow());
-//
-//        mongoService.update(IotXycbimg.class, query, updateField);
-//    }
-//
-//    /**
-//     * 获取性诱设备数据列表
-//     *
-//     * @param iotXycbReqVo
-//     */
-//    @Override
-//    public IPage<IotYfXycbDataListRspVo> getXycbDataList(IotXycbReqVo iotXycbReqVo) {
-//        String devBid = iotXycbReqVo.getDevBid();
-//        IPage<IotYfXycbDataListRspVo> iPage = new Page<>();
-//
-//        IotDevice iotDevice = iIotDeviceService.findOneByBizId(devBid);
-//        if(iotDevice == null){
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
-//        }
-//        String devtypeBid = iotDevice.getDevtypeBid();
-//        if (IotDeviceDictConst.TYPE_YF_XYCB_2.equals(devtypeBid)) {
-//            iPage = getYfXycb2DataList(iotXycbReqVo);
-//        }else if (IotDeviceDictConst.TYPE_ZJSF_XYCB.equals(devtypeBid)) {
-//            iPage = getZjsfXycbDataList(iotXycbReqVo);
-//        }
-//        return iPage;
-//    }
-//
-//    /**
-//     * 性诱测报2.0
-//     * @param
-//     */
-//    public List<IotXycbPolylineResVo> getXycb2Polyline(IotXycbReqVo reqVo){
-//        String devBid = reqVo.getDevBid();
-//        String startDate = reqVo.getStartDate();
-//        String endDate = reqVo.getEndDate();
-//
-//        String unit = "day";
-//        Criteria criteria = new Criteria().and("devBid").is(devBid);
-//        if (StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)) {
-//            criteria = criteria.andOperator(
-//                    Criteria.where("xycb2dataCreatedDate").gte(startDate),
-//                    Criteria.where("xycb2dataCreatedDate").lte(endDate)
-//            );
-//            long diffTime = DateUtils.parseDate(endDate).getTime() - DateUtils.parseDate(startDate).getTime();
-//            if (diffTime <= 48 * 60 * 60 * 1000) {
-//                unit = "minute";
-//            } else if (diffTime <= 30L * 24 * 60 * 60 * 1000) {
-//                unit = "hour";
-//            }
-//        } else if (StringUtils.isNotEmpty(startDate)) {
-//            criteria = criteria.and("xycb2dataCreatedDate").gte(startDate);
-//        } else if (StringUtils.isNotEmpty(endDate)) {
-//            criteria = criteria.and("xycb2dataCreatedDate").lte(endDate);
-//        }
-//        MatchOperation matchOperation = Aggregation.match(criteria);
-//
-//        ProjectionOperation projectionOperation = Aggregation.project()
-//                .and("xycb2dataContent.ah").as("ah")
-//                .and("xycb2dataContent.at").as("at")
-//                .and("xycb2dataContent.ct").as("ct")
-//                .and("xycb2dataCreatedDate").as("createDate");
-//
-//        ProjectionOperation projectionOperation2 = Aggregation.project()
-//                .andExpression("{$convert: {input: '$ct', to: 'int', onError: 0, onNull: 0}}").as("ct")
-//                .andExpression("{$convert: {input: '$at', to: 'double', onError: -99, onNull: -99}}").as("at")
-//                .andExpression("{$convert: {input: '$ah', to: 'double', onError: -99, onNull: -99}}").as("ah")
-//                .andExpression("{$dateTrunc: {date: {$toDate: '$createDate'}, unit:'" + unit + "'}}").as("createDate");
-//
-//        GroupOperation groupOperation = Aggregation.group("createDate")
-//                .avg("ah").as("ah")
-//                .avg("at").as("at")
-//                .sum("ct").as("ct");
-//
-//        ProjectionOperation projectionOperation3 = Aggregation.project("ct")
-//                .andExpression("{$trunc: {'$ah', 1}}").as("ah")
-//                .andExpression("{$trunc: {'$at', 1}}").as("at")
-//                .andExpression("{$dateToString: {format: '%Y-%m-%d %H:%M:%S', date: '$_id'}}").as("createDate");
-//
-//        SortOperation sortOperation = Aggregation.sort(Sort.Direction.ASC, "createDate");
-//
-//        Aggregation aggregation = Aggregation.newAggregation(
-//                matchOperation,
-//                projectionOperation,
-//                projectionOperation2,
-//                groupOperation,
-//                projectionOperation3,
-//                sortOperation
-//        );
-//
-//        List<IotXycbPolylineResVo> iotXycbPolylineResVos = mongoService.aggregate(
-//                IotYfXycb2data.class, aggregation, IotXycbPolylineResVo.class
-//        );
-//        return iotXycbPolylineResVos;
-//    }
-//
-//    /**
-//     * 性诱测报2.0
-//     * @param
-//     */
-//    public List<IotXycbPolylineResVo> getZjsfXycbPolyline(IotXycbReqVo reqVo){
-//        String devBid = reqVo.getDevBid();
-//        String startDate = reqVo.getStartDate();
-//        String endDate = reqVo.getEndDate();
-//
-//        String unit = "day";
-//        Criteria criteria = new Criteria().and("devBid").is(devBid);
-//        if (StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)) {
-//            criteria = criteria.andOperator(
-//                    Criteria.where("xycbdataCreatedDate").gte(startDate),
-//                    Criteria.where("xycbdataCreatedDate").lte(endDate)
-//            );
-//            long diffTime = DateUtils.parseDate(endDate).getTime() - DateUtils.parseDate(startDate).getTime();
-//            if (diffTime <= 48 * 60 * 60 * 1000) {
-//                unit = "minute";
-//            } else if (diffTime <= 30L * 24 * 60 * 60 * 1000) {
-//                unit = "hour";
-//            }
-//        } else if (StringUtils.isNotEmpty(startDate)) {
-//            criteria = criteria.and("xycbdataCreatedDate").gte(startDate);
-//        } else if (StringUtils.isNotEmpty(endDate)) {
-//            criteria = criteria.and("xycbdataCreatedDate").lte(endDate);
-//        }
-//        MatchOperation matchOperation = Aggregation.match(criteria);
-//
-//        ProjectionOperation projectionOperation = Aggregation.project()
-//                .and("xycbdataContent.ah").as("ah")
-//                .and("xycbdataContent.at").as("at")
-//                .and("xycbdataContent.ct").as("ct")
-//                .and("xycbdataCreatedDate").as("createDate");
-//
-//        ProjectionOperation projectionOperation2 = Aggregation.project()
-//                .andExpression("{$convert: {input: '$ct', to: 'int', onError: 0, onNull: 0}}").as("ct")
-//                .andExpression("{$convert: {input: '$at', to: 'double', onError: -99, onNull: -99}}").as("at")
-//                .andExpression("{$convert: {input: '$ah', to: 'double', onError: -99, onNull: -99}}").as("ah")
-//                .andExpression("{$dateTrunc: {date: {$toDate: '$createDate'}, unit:'" + unit + "'}}").as("createDate");
-//
-//        GroupOperation groupOperation = Aggregation.group("createDate")
-//                .avg("ah").as("ah")
-//                .avg("at").as("at")
-//                .sum("ct").as("ct");
-//
-//        ProjectionOperation projectionOperation3 = Aggregation.project("ct")
-//                .andExpression("{$trunc: {'$ah', 1}}").as("ah")
-//                .andExpression("{$trunc: {'$at', 1}}").as("at")
-//                .andExpression("{$dateToString: {format: '%Y-%m-%d %H:%M:%S', date: '$_id'}}").as("createDate");
-//
-//        SortOperation sortOperation = Aggregation.sort(Sort.Direction.ASC, "createDate");
-//
-//        Aggregation aggregation = Aggregation.newAggregation(
-//                matchOperation,
-//                projectionOperation,
-//                projectionOperation2,
-//                groupOperation,
-//                projectionOperation3,
-//                sortOperation
-//        );
-//
-//        List<IotXycbPolylineResVo> iotXycbPolylineResVos = mongoService.aggregate(
-//                IotZjsfXycbdata.class, aggregation, IotXycbPolylineResVo.class
-//        );
-//        return iotXycbPolylineResVos;
-//    }
-//
-//    /**
-//     * 获取性诱测报折线图数据
-//     *
-//     * @param iotXycbReqVo
-//     */
-//    @Override
-//    public List<IotXycbPolylineResVo> getXycbPolyline(IotXycbReqVo iotXycbReqVo) {
-//        String devBid = iotXycbReqVo.getDevBid();
-//        if (StringUtils.isEmpty(devBid)) {
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
-//        }
-//        IotDevice iotDevice = iIotDeviceService.findOneByBizId(devBid);
-//        if(iotDevice == null){
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
-//        }
-//
-//        List<IotXycbPolylineResVo> iotXycbPolylineResVoList = new ArrayList<>();
-//        if (IotDeviceDictConst.TYPE_YF_XYCB_2.equals(iotDevice.getDevtypeBid())) {
-//            iotXycbPolylineResVoList = getXycb2Polyline(iotXycbReqVo);
-//        }else if (IotDeviceDictConst.TYPE_ZJSF_XYCB.equals(iotDevice.getDevtypeBid())) {
-//            iotXycbPolylineResVoList = getZjsfXycbPolyline(iotXycbReqVo);
-//        }
-//        return iotXycbPolylineResVoList;
-//    }
-//
-//    private IotXycbInfoResVo getXycb2Info(String devBid, IotXycbInfoResVo iotXycbInfoResVo){
-//        HashMap<String, String> params = new HashMap<>();
-//        params.put("devBid", devBid);
-//
-//        IotYfXycb2data iotYfXycb2data = (IotYfXycb2data) mongoService.findOne(IotYfXycb2data.class, params, "xycb2dataCreatedDate", "desc");
-//        if(iotYfXycb2data != null){
-//            JSONObject xyData = iotYfXycb2data.getXycb2dataContent();
-//            iotXycbInfoResVo.setAt(xyData.getString("at"));
-//            iotXycbInfoResVo.setAh(xyData.getString("ah"));
-//        }
-//
-//        List<String> devBidList = new ArrayList<>();
-//        devBidList.add(devBid);
-//
-//        Map<String, IotXyinfoPestTotalDto>  iotXyinfoPestTotalDtoMap = iIotPestrecogService.getIotXyinfoPestTotalMap(devBidList);
-//        if(iotXyinfoPestTotalDtoMap.containsKey(devBid)){
-//            iotXycbInfoResVo.setPestTotal(String.valueOf(iotXyinfoPestTotalDtoMap.get(devBid).getPestTotal()));
-//        }
-//        return iotXycbInfoResVo;
-//    }
-//
-//    private IotXycbInfoResVo getZjsfXycbInfo(String devBid, IotXycbInfoResVo iotXycbInfoResVo){
-//        HashMap<String, String> params = new HashMap<>();
-//        params.put("devBid", devBid);
-//
-//        IotZjsfXycbdata iotZjsfXycbdata = (IotZjsfXycbdata) mongoService.findOne(
-//                IotZjsfXycbdata.class, params, "xycbdataCreatedDate", "desc");
-//        if(iotZjsfXycbdata != null){
-//            JSONObject xyData = iotZjsfXycbdata.getXycbdataContent();
-//            iotXycbInfoResVo.setAt(xyData.getString("at"));
-//            iotXycbInfoResVo.setAh(xyData.getString("ah"));
-//        }
-//
-//        List<String> devBidList = new ArrayList<>();
-//        devBidList.add(devBid);
-//
-//        Map<String, IotXyinfoPestTotalDto>  iotXyinfoPestTotalDtoMap = iIotPestrecogService.getIotXyinfoPestTotalMap(devBidList);
-//        iotXycbInfoResVo.setPestTotal("0");
-//        if(iotXyinfoPestTotalDtoMap.containsKey(devBid)){
-//            Integer pestTotal = iotXyinfoPestTotalDtoMap.get(devBid).getPestTotal();
-//            if(pestTotal == null){
-//                pestTotal = 0;
-//            }
-//            iotXycbInfoResVo.setPestTotal(String.valueOf(pestTotal));
-//        }
-//        return iotXycbInfoResVo;
-//    }
-//
-//    /**
-//     * 获取性诱测报信息
-//     *
-//     * @param devBid
-//     */
-//    @Override
-//    public IotXycbInfoResVo getXycbInfo(String devBid) {
-//        if (StringUtils.isEmpty(devBid)) {
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
-//        }
-//        IotDevice iotDevice = iIotDeviceService.findOneByBizId(devBid);
-//        if(iotDevice == null){
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
-//        }
-//
-//        IotXycbInfoResVo iotXycbInfoResVo = new IotXycbInfoResVo();
-//        iotXycbInfoResVo.setDevStatus(iotDevice.getDevStatus());
-//
-//        IotXyinfoDto iotXyinfoDto = iIotXyinfoService.selectIotXyinfoByDevBid(devBid);
-//        if(iotXyinfoDto != null){
-//            iotXycbInfoResVo.setXyinfoLurename(iotXyinfoDto.getXyinfoLurename());
-//            iotXycbInfoResVo.setXyinfoLureexpireddate(iotXyinfoDto.getXyinfoLureexpireddate());
-//        }
-//
-//        String province = StringUtils.isEmpty(iotDevice.getDevProvincealign()) ? iotDevice.getDevProvince(): iotDevice.getDevProvincealign();
-//        String city = StringUtils.isEmpty(iotDevice.getDevCityalign()) ? iotDevice.getDevCity(): iotDevice.getDevCityalign();
-//        String district = StringUtils.isEmpty(iotDevice.getDevDistrictalign()) ? iotDevice.getDevDistrict(): iotDevice.getDevDistrictalign();
-//        if(StringUtils.isNotEmpty(province) && StringUtils.isNotEmpty(city)){
-//            JSONObject weatherInfo = iotWeatherService.getWeatherByAddress(province, city, district);
-//            iotXycbInfoResVo.setWea(weatherInfo.getString("wea"));
-//            iotXycbInfoResVo.setWin(weatherInfo.getString("win"));
-//            iotXycbInfoResVo.setWin_speed(weatherInfo.getString("win_speed"));
-//            String rainStatusName = !Objects.equals(weatherInfo.getString("rain_pcpn"), "0") ? "是" : "否";
-//            iotXycbInfoResVo.setRainStatusName(rainStatusName);
-//        }
-//
-//        if (IotDeviceDictConst.TYPE_YF_XYCB_2.equals(iotDevice.getDevtypeBid())) {
-//            iotXycbInfoResVo = getXycb2Info(devBid, iotXycbInfoResVo);
-//        }else if (IotDeviceDictConst.TYPE_ZJSF_XYCB.equals(iotDevice.getDevtypeBid())){
-//            iotXycbInfoResVo = getZjsfXycbInfo(devBid, iotXycbInfoResVo);
-//        }
-//        return iotXycbInfoResVo;
-//    }
-//
-//    /**
-//     * 修改诱芯信息
-//     *
-//     * @param iotXycbModifyLureReqVo
-//     */
-//    @Override
-//    public int modifyLure(IotXycbModifyLureReqVo iotXycbModifyLureReqVo) {
-//        String devBid = iotXycbModifyLureReqVo.getDevBid();
-//        String pestBusid = iotXycbModifyLureReqVo.getPestBusid();
-//        IotPest iotPest = iotPestService.selectIotPestByPestBid(pestBusid);
-//        if(iotPest == null){
-//            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "诱芯不存在");
-//        }
-//        IotXyinfoDto iotXyinfoDto = iIotXyinfoService.selectIotXyinfoByDevBid(devBid);
-//
-//        IotXyinfo iotXyinfo = new IotXyinfo();
-//        iotXyinfo.setDevBid(iotXycbModifyLureReqVo.getDevBid());
-//        iotXyinfo.setPestBusid(iotPest.getPestBid());
-//        iotXyinfo.setXyinfoLurename(iotPest.getPestName());
-//        iotXyinfo.setXyinfoLureexpireddate(iotXycbModifyLureReqVo.getXyinfoLureexpireddate());
-//        iotXyinfo.setXyinfoModifier(SecurityUtils.getUserId());
-//        iotXyinfo.setXyinfoModifieddate(DateUtils.dateTimeNow());
-//
-//        int status = 0;
-//        if(iotXyinfoDto == null){
-//            iotXyinfo.setXyinfoBid(iotXyinfo.getUUId());
-//            iotXyinfo.setXyinfoCreator(SecurityUtils.getUserId());
-//            iotXyinfo.setXyinfoCreatedDate(DateUtils.dateTimeNow());
-//            iotXyinfo.setXyinfoDelstatus("0");
-//
-//            status = iIotXyinfoService.insertIotXyinfo(iotXyinfo);
-//        }else{
-//            status = iIotXyinfoService.updateIotXyinfo(iotXyinfo);
-//        }
-//
-//        return status;
-//    }
-//
-//    /**
-//     * 获取诱芯列表
-//     *
-//     * @param iotXycbLureListReqVo
-//     * @return
-//     */
-//    @Override
-//    public List<IotXycbLureListRspVo> getLureList(IotXycbLureListReqVo iotXycbLureListReqVo) {
-//        IotPest selectIotPest = new IotPest();
-//        selectIotPest.setPestName(iotXycbLureListReqVo.getPestName());
-//
-//        startPage();
-//        List<IotPest> iotPestList = iotPestService.selectIotPestList(selectIotPest);
-//        List<IotXycbLureListRspVo> iotXycbLureListRspVoList = new ArrayList<>();
-//        for(IotPest iotPest: iotPestList){
-//            IotXycbLureListRspVo iotXycbLureListRspVo = new IotXycbLureListRspVo();
-//            iotXycbLureListRspVo.setPestName(iotPest.getPestName());
-//            iotXycbLureListRspVo.setPestBusid(iotPest.getPestBid());
-//
-//            iotXycbLureListRspVoList.add(iotXycbLureListRspVo);
-//        }
-//        return iotXycbLureListRspVoList;
-//    }
-//
-//
-//}
+package com.yunfeiyun.agmp.iotm.device.xycb.service.impl;
+
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.ServiceNameConst;
+import com.yunfeiyun.agmp.iotm.device.xycb.service.IIotXycbCommService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service(value = ServiceNameConst.SERVICE_YF_XYCB_III)
+public class IotXycbIIIServiceImpl extends IIotXycbCommService {
+
+}

+ 1 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotDeviceServiceImpl.java

@@ -132,6 +132,7 @@ public class IotDeviceServiceImpl implements IIotDeviceService
             iotDevice.setDevDistrictalign(reqVo.getDevDistrictalign());
             iotDevice.setDevCreator(SecurityUtils.getUserId());
             iotDevice.setDevCreateddate(DateUtils.dateTimeNow());
+            iotDevice.setDevPositionstatus("1");
             iotDevice.setDevDelstatus(IotDeviceDelStatusEnum.NOT_DELETE.getCode());
 
             insertIotDeviceList.add(iotDevice);