|
@@ -1,14 +1,30 @@
|
|
|
package com.yunfeiyun.agmp.iotm.device.xycb.controller;
|
|
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.domain.AjaxResult;
|
|
|
import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
|
|
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.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.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.exception.IotBizException;
|
|
|
|
|
+import com.yunfeiyun.agmp.iot.common.model.cmd.CmdGroupModel;
|
|
|
import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
|
import com.yunfeiyun.agmp.iotm.common.controller.BaseController;
|
|
import com.yunfeiyun.agmp.iotm.common.controller.BaseController;
|
|
|
-import com.yunfeiyun.agmp.iotm.device.xycb.domain.IotXycbInfoResVo;
|
|
|
|
|
-import com.yunfeiyun.agmp.iotm.device.xycb.domain.IotXycbPolylineResVo;
|
|
|
|
|
-import com.yunfeiyun.agmp.iotm.device.xycb.domain.IotXycbReqVo;
|
|
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceCommonService;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceRefreshService;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.device.xycb.domain.*;
|
|
|
import com.yunfeiyun.agmp.iotm.device.xycb.service.IIotXycbService;
|
|
import com.yunfeiyun.agmp.iotm.device.xycb.service.IIotXycbService;
|
|
|
|
|
+import com.yunfeiyun.agmp.iotm.util.ValidateUtil;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
|
|
import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListResVo;
|
|
import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotCmdtaskService;
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotCmdtaskService;
|
|
@@ -17,12 +33,11 @@ import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceconfigService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -51,6 +66,12 @@ public class IotXycbController extends BaseController
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IIotXycbService iIotXycbService;
|
|
private IIotXycbService iIotXycbService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IotDeviceRefreshService iotDeviceRefreshService;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IotDeviceCommonService iotDeviceCommonService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 性诱测报列表
|
|
* 性诱测报列表
|
|
|
* /list 所有性诱测报设备
|
|
* /list 所有性诱测报设备
|
|
@@ -111,27 +132,122 @@ public class IotXycbController extends BaseController
|
|
|
IotXycbInfoResVo iotXycbInfoResVo = iIotXycbService.getXycbInfo(devBid);
|
|
IotXycbInfoResVo iotXycbInfoResVo = iIotXycbService.getXycbInfo(devBid);
|
|
|
return AjaxResult.success(iotXycbInfoResVo);
|
|
return AjaxResult.success(iotXycbInfoResVo);
|
|
|
}
|
|
}
|
|
|
-//
|
|
|
|
|
-// /**
|
|
|
|
|
-// *
|
|
|
|
|
-// * @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));
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/refresh/{devBid}")
|
|
|
|
|
+ public AjaxResult refresh(@PathVariable("devBid") String devBid) {
|
|
|
|
|
+ String result = iotDeviceRefreshService.refresh(devBid);
|
|
|
|
|
+ return new AjaxResult(ErrorCode.SUCCESS.getCode(), result, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @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));
|
|
|
|
|
+ }
|
|
|
//
|
|
//
|
|
|
// /**
|
|
// /**
|
|
|
// * 查询图片列表
|
|
// * 查询图片列表
|
|
@@ -154,54 +270,7 @@ public class IotXycbController extends BaseController
|
|
|
// iIotXycbService.imageDelete(xycbimgBid);
|
|
// iIotXycbService.imageDelete(xycbimgBid);
|
|
|
// return AjaxResult.success();
|
|
// return AjaxResult.success();
|
|
|
// }
|
|
// }
|
|
|
-//
|
|
|
|
|
-// /**
|
|
|
|
|
-// * 下发测报灯配置指令
|
|
|
|
|
-// *
|
|
|
|
|
-// * @return
|
|
|
|
|
-// * @throws Exception
|
|
|
|
|
-// */
|
|
|
|
|
-// @PostMapping("/config/edit")
|
|
|
|
|
-// public AjaxResult sendConfigCmd(@RequestBody IotXYIIIConfigEditReqVo iotXYIIIConfigEditReqVo) {
|
|
|
|
|
-// log.info("【{}】【性诱III】【下发指令配置】客户id {}", LogCore.getSeq(), getCustomerId());
|
|
|
|
|
-// if (StringUtils.isEmpty(iotXYIIIConfigEditReqVo.getXyDataBid())) {
|
|
|
|
|
-// return AjaxResult.error(IotErrorCode.FAILURE.getCode(), "设备id不可为空");
|
|
|
|
|
-// }
|
|
|
|
|
-// IotDevice iotDevice = iIotDeviceService.findOneByBizId(iotXYIIIConfigEditReqVo.getXyDataBid());
|
|
|
|
|
-// if (iotDevice == null) {
|
|
|
|
|
-// return AjaxResult.error(IotErrorCode.FAILURE.getCode(), "设备不存在");
|
|
|
|
|
-// }
|
|
|
|
|
-// IotDeviceconfig iotDeviceconfig = iIotDeviceconfigService.selectIotDeviceConfigByDevBid(iotXYIIIConfigEditReqVo.getXyDataBid());
|
|
|
|
|
-// if (null == iotDeviceconfig) {
|
|
|
|
|
-// // 如果测报灯配置为空,则新增测报灯配置
|
|
|
|
|
-// iotDeviceconfig = new IotDeviceconfig();
|
|
|
|
|
-// iotDeviceconfig.setDevcfgBid(iotDeviceconfig.getUUId());
|
|
|
|
|
-// iotDeviceconfig.setCId(getCustomerId());
|
|
|
|
|
-// iotDeviceconfig.setDevBid(iotXYIIIConfigEditReqVo.getXyDataBid());
|
|
|
|
|
-// iotDeviceconfig.setDevcfgContext(JSONUtils.toJSONString(iotXYIIIConfigEditReqVo.getIotXyConfig()));
|
|
|
|
|
-// iotDeviceconfig.setDevcfgDelstatus("0");
|
|
|
|
|
-// iIotDeviceconfigService.insertIotDeviceconfig(iotDeviceconfig);
|
|
|
|
|
-// } else {
|
|
|
|
|
-// // 如果测报灯配置不为空,则更新测报灯配置
|
|
|
|
|
-// iotDeviceconfig.setDevcfgContext(JSONUtils.toJSONString(iotXYIIIConfigEditReqVo.getIotXyConfig()));
|
|
|
|
|
-// iIotDeviceconfigService.updateIotDeviceconfig(iotDeviceconfig);
|
|
|
|
|
-// }
|
|
|
|
|
-// CmdGroupModel cmdGroupModel = iIotDeviceconfigService.createConfigCmd(iotDeviceconfig);
|
|
|
|
|
-// log.info("【{}】【性诱III】【构建 cmdGroupModel】{}", LogCore.getSeq(), JSONUtils.toJSONString(cmdGroupModel));
|
|
|
|
|
-// cmdGroupModel.setRequestId(IdUtils.fastUUID());
|
|
|
|
|
-//
|
|
|
|
|
-// // 适配增加详细日志使用
|
|
|
|
|
-// //cmdGroupModel.setOrignRequestParam(iotCbdConfigEditReqVo);
|
|
|
|
|
-// cmdGroupModel.setDevCode(iotDevice.getDevCode());
|
|
|
|
|
-// cmdGroupModel.setCtBiztitle(IotDeviceTypeLv1Enum.XYCB.getName() + ":" + iotDevice.getDevCode());
|
|
|
|
|
-// cmdGroupModel.setCtBiztype("3");
|
|
|
|
|
-// cmdGroupModel.setCtDevtype(iotDevice.getDevtypeBid());
|
|
|
|
|
-// cmdGroupModel.setCtParam(deviceConfigurationTranslator.configTranslate(iotXYIIIConfigEditReqVo));
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// iIotCmdtaskService.handInternalCmd(cmdGroupModel);
|
|
|
|
|
-// return new AjaxResult(ErrorCode.SUCCESS.getCode(), "下发成功,等待设备响应结果", null);
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|