提交修改

This commit is contained in:
LEED
2025-04-13 18:00:19 +08:00
parent 988e68bdc7
commit 4201690d93
60 changed files with 2589 additions and 285 deletions

View File

@@ -52,6 +52,8 @@ public class Alert extends BaseEntity {
@Excel(name = "通知方式")
private String notify;
private String serialNumber;
private List<Scene> scenes;
private List<NotifyTemplate> notifyTemplateList;
@@ -59,6 +61,16 @@ public class Alert extends BaseEntity {
/** 租户id */
private Long tenantId;
private Long deptId;
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getTenantId() {
return tenantId;
}
@@ -75,6 +87,14 @@ public class Alert extends BaseEntity {
this.tenantName = tenantName;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
/** 租户名称 */
private String tenantName;

View File

@@ -0,0 +1,37 @@
package com.xinda.iot.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.xinda.common.annotation.Excel;
import com.xinda.common.core.domain.BaseEntity;
/**
* 监控设备关联对象 iot_sip_device
*
* @author ledo
* @date 2025-04-04
*/
@ApiModel(value = "CamDevice",description = "监控设备关联 iot_sip_device")
@Data
public class CamDevice extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键id */
private Long id;
/** 监控id */
@Excel(name = "监控id")
@ApiModelProperty("监控id")
private Long sipId;
/** 设备id */
@Excel(name = "设备id")
@ApiModelProperty("设备id")
private Long deviceId;
/** 逻辑删除标识 */
private Integer delFlag;
}

View File

@@ -173,6 +173,19 @@ public class Device extends BaseEntity {
@ApiModelProperty("定位方式(1=ip自动定位2=设备定位3=自定义)")
private Integer locationWay;
private Integer icWay;
private String iccid;
private String volt;
private String sd;
private String pd;
private String imei;
@ApiModelProperty("监控设备ID")
private Long gwId;
/** 监控设备名称 */
@ApiModelProperty("监控设备名称")
private String gwName;
/**
* 设备摘要
**/
@@ -244,6 +257,12 @@ public class Device extends BaseEntity {
private List<Long> deptIds;
private Long mDeviceId;
private List<Device> sipList;
private List<CamDevice> camDeviceList;
public static long getSerialVersionUID() {
return serialVersionUID;

View File

@@ -0,0 +1,53 @@
package com.xinda.iot.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xinda.common.annotation.Excel;
import com.xinda.common.core.domain.BaseEntity;
/**
* 档案管理对象 iot_doc
*
* @author leo
* @date 2025-04-04
*/
@ApiModel(value = "Doc",description = "档案管理 iot_doc")
@Data
public class Doc extends BaseEntity {
private static final long serialVersionUID = 1L;
/** id唯一标识 */
private Long id;
/** 机构id */
@Excel(name = "机构id")
@ApiModelProperty("机构id")
private Long deptId;
/** 机构名称 */
@Excel(name = "机构名称")
@ApiModelProperty("机构名称")
private String deptName;
/** 文件名称 */
@Excel(name = "文件名称")
@ApiModelProperty("文件名称")
private String fileName;
/** 资源请求路径 */
@Excel(name = "资源请求路径")
@ApiModelProperty("资源请求路径")
private String resourceUrl;
/** 租户id */
private Long tenantId;
/** 租户名称 */
@Excel(name = "租户名称")
@ApiModelProperty("租户名称")
private String tenantName;
}

View File

@@ -43,6 +43,8 @@ public interface AlertMapper
*/
public List<Scene> selectScenesByAlertId(Long alertId);
public int deleteSceneByAlertId(Long alertId);
/**
* 新增设备告警
*

View File

@@ -0,0 +1,63 @@
package com.xinda.iot.mapper;
import java.util.List;
import com.xinda.iot.domain.CamDevice;
/**
* 监控设备关联Mapper接口
*
* @author ledo
* @date 2025-04-04
*/
public interface CamDeviceMapper
{
/**
* 查询监控设备关联
*
* @param id 监控设备关联主键
* @return 监控设备关联
*/
public CamDevice selectCamDeviceById(Long id);
/**
* 查询监控设备关联列表
*
* @param camDevice 监控设备关联
* @return 监控设备关联集合
*/
public List<CamDevice> selectCamDeviceList(CamDevice camDevice);
/**
* 新增监控设备关联
*
* @param camDevice 监控设备关联
* @return 结果
*/
public int insertCamDevice(CamDevice camDevice);
/**
* 修改监控设备关联
*
* @param camDevice 监控设备关联
* @return 结果
*/
public int updateCamDevice(CamDevice camDevice);
/**
* 删除监控设备关联
*
* @param id 监控设备关联主键
* @return 结果
*/
public int deleteCamDeviceById(Long id);
/**
* 批量删除监控设备关联
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCamDeviceByIds(Long[] ids);
public int deleteCamDeviceBySipId(Long deviceId);
}

View File

@@ -126,6 +126,7 @@ public interface DeviceMapper
*/
public List<DeviceShortOutput> selectDeviceGShortList(Device device);
public List<DeviceShortOutput> selectDeviceShortList(Device device);
List<DeviceShortOutput> selectDeviceShortGwList(Device device);
/**
* 查询所有设备简短列表
*
@@ -364,4 +365,10 @@ public interface DeviceMapper
List<DeviceGroup> listDeviceGroupByGroupIds(List<Long> groupIds);
void deleteDeviceBygroupId();
List<DeviceShortOutput> selectDeviceShortTreeList(Device device);
List<DeviceShortOutput> selectCamDeviceListByDeviceId(Long deviceId);
}

View File

@@ -0,0 +1,61 @@
package com.xinda.iot.mapper;
import java.util.List;
import com.xinda.iot.domain.Doc;
/**
* 档案管理Mapper接口
*
* @author leo
* @date 2025-04-04
*/
public interface DocMapper
{
/**
* 查询档案管理
*
* @param id 档案管理主键
* @return 档案管理
*/
public Doc selectDocById(Long id);
/**
* 查询档案管理列表
*
* @param doc 档案管理
* @return 档案管理集合
*/
public List<Doc> selectDocList(Doc doc);
/**
* 新增档案管理
*
* @param doc 档案管理
* @return 结果
*/
public int insertDoc(Doc doc);
/**
* 修改档案管理
*
* @param doc 档案管理
* @return 结果
*/
public int updateDoc(Doc doc);
/**
* 删除档案管理
*
* @param id 档案管理主键
* @return 结果
*/
public int deleteDocById(Long id);
/**
* 批量删除档案管理
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDocByIds(Long[] ids);
}

View File

@@ -189,4 +189,6 @@ public interface ProductMapper
* @return: java.util.List<com.xinda.iot.domain.Product>
*/
List<Product> selectProductListByProductIds(@Param("productIdList") List<Long> productIdList);
Long selectScadaIdByGuid(String guid);
}

View File

@@ -45,6 +45,14 @@ public class DeviceAllShortOutput
/** wifi信号强度信号极好4格[-55— 0]信号好3格[-70— -55]信号一般2格[-85— -70]信号差1格[-100— -85] */
private Integer rssi;
private Integer icWay;
private String iccid;
private String volt;
private String sd;
private String pd;
private String imei;
/** 激活时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date activeTime;
@@ -217,4 +225,51 @@ public class DeviceAllShortOutput
return activeTime;
}
public Integer getIcWay() {
return icWay;
}
public void setIcWay(Integer icWay) {
this.icWay = icWay;
}
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
public String getVolt() {
return volt;
}
public void setVolt(String volt) {
this.volt = volt;
}
public String getSd() {
return sd;
}
public void setSd(String sd) {
this.sd = sd;
}
public String getPd() {
return pd;
}
public void setPd(String pd) {
this.pd = pd;
}
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
}

View File

@@ -1,5 +1,6 @@
package com.xinda.iot.model;
import com.xinda.iot.domain.Device;
import com.xinda.iot.model.ThingsModels.ThingsModelValueItem;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xinda.common.annotation.Excel;
@@ -79,6 +80,13 @@ public class DeviceShortOutput
@Excel(name = "wifi信号强度")
private Integer rssi;
private Integer icWay;
private String iccid;
private String volt;
private String sd;
private String pd;
private String imei;
@Excel(name = "物模型")
private String thingsModelValue;
@@ -140,6 +148,15 @@ public class DeviceShortOutput
*/
private String agenciesName;
private List<DeviceShortOutput> sipList;
public List<DeviceShortOutput> getSipList() {
return sipList;
}
public void setSipList(List<DeviceShortOutput> sipList) {
this.sipList = sipList;
}
public String getGuid() {
return guid;
@@ -430,4 +447,75 @@ public class DeviceShortOutput
return activeTime;
}
public Integer getIcWay() {
return icWay;
}
public void setIcWay(Integer icWay) {
this.icWay = icWay;
}
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
public String getVolt() {
return volt;
}
public void setVolt(String volt) {
this.volt = volt;
}
public String getSd() {
return sd;
}
public void setSd(String sd) {
this.sd = sd;
}
public String getPd() {
return pd;
}
public void setPd(String pd) {
this.pd = pd;
}
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public Long getGroupId() {
return groupId;
}
public void setGroupId(Long groupId) {
this.groupId = groupId;
}
public Long getAgenciesId() {
return agenciesId;
}
public void setAgenciesId(Long agenciesId) {
this.agenciesId = agenciesId;
}
public String getAgenciesName() {
return agenciesName;
}
public void setAgenciesName(String agenciesName) {
this.agenciesName = agenciesName;
}
}

View File

@@ -0,0 +1,43 @@
package com.xinda.iot.model;
/**
* 导入产品物模型的输入对象
*
* @author kerwincui
* @date 2021-12-16
*/
public class ImportCategoryModelInput
{
/** 产品ID */
private Long productId;
/** 产品名称 */
private String productName;
/** 通用物模型ID集合 */
private Long categoryId;
public Long getProductId() {
return productId;
}
public void setProductId(Long productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public Long getCategoryId() {
return categoryId;
}
public void setCategoryId(Long categoryId) {
this.categoryId = categoryId;
}
}

View File

@@ -38,6 +38,7 @@ public interface IAlertLogService
* @return 设备告警集合
*/
public Long selectAlertLogListCount(AlertLog alertLog);
public Long selectSceneAlertLogListCount(AlertLog alertLog);
public List<DeviceAlertCount> selectDeviceAlertCount();
public DeviceAlertCount selectDeviceAlertCountBySN(String serialNumber);
@@ -98,4 +99,6 @@ public interface IAlertLogService
* @return com.xinda.iot.model.AlertCountVO
*/
List<AlertCountVO> countAlertLevel(DataCenterParam dataCenterParam);
List<AlertLog> selectAlertLogSnList(AlertLog alertLog);
}

View File

@@ -106,4 +106,6 @@ public interface IAlertService
* @return 设备告警集合
*/
public List<AlertSceneSendVO> listByAlertIds(Long sceneId);
int insertCfgAlert(Alert alert);
}

View File

@@ -0,0 +1,62 @@
package com.xinda.iot.service;
import java.util.List;
import com.xinda.iot.domain.CamDevice;
/**
* 监控设备关联Service接口
*
* @author ledo
* @date 2025-04-04
*/
public interface ICamDeviceService
{
/**
* 查询监控设备关联
*
* @param id 监控设备关联主键
* @return 监控设备关联
*/
public CamDevice selectCamDeviceById(Long id);
/**
* 查询监控设备关联列表
*
* @param camDevice 监控设备关联
* @return 监控设备关联集合
*/
public List<CamDevice> selectCamDeviceList(CamDevice camDevice);
/**
* 新增监控设备关联
*
* @param camDevice 监控设备关联
* @return 结果
*/
public int insertCamDevice(CamDevice camDevice);
/**
* 修改监控设备关联
*
* @param camDevice 监控设备关联
* @return 结果
*/
public int updateCamDevice(CamDevice camDevice);
/**
* 批量删除监控设备关联
*
* @param ids 需要删除的监控设备关联主键集合
* @return 结果
*/
public int deleteCamDeviceByIds(Long[] ids);
/**
* 删除监控设备关联信息
*
* @param id 监控设备关联主键
* @return 结果
*/
public int deleteCamDeviceById(Long id);
}

View File

@@ -125,6 +125,8 @@ public interface IDeviceService
*/
public List<DeviceShortOutput> selectDeviceShortList(Device device);
public List<DeviceShortOutput> selectDeviceShortGwList(Device device);
/**
* 新增设备
*
@@ -338,4 +340,9 @@ public interface IDeviceService
*/
List<DeviceGroup> listDeviceGroupByGroupIds(List<Long> groupIds);
List<DeviceShortOutput> selectDeviceShortTreeList(Device device);
List<DeviceShortOutput> selectCamDeviceListByDeviceId(Long deviceId);
}

View File

@@ -0,0 +1,65 @@
package com.xinda.iot.service;
import java.util.List;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.iot.domain.Doc;
import org.springframework.web.multipart.MultipartFile;
/**
* 档案管理Service接口
*
* @author leo
* @date 2025-04-04
*/
public interface IDocService
{
/**
* 查询档案管理
*
* @param id 档案管理主键
* @return 档案管理
*/
public Doc selectDocById(Long id);
/**
* 查询档案管理列表
*
* @param doc 档案管理
* @return 档案管理集合
*/
public List<Doc> selectDocList(Doc doc);
/**
* 新增档案管理
*
* @param doc 档案管理
* @return 结果
*/
public int insertDoc(Doc doc);
/**
* 修改档案管理
*
* @param doc 档案管理
* @return 结果
*/
public int updateDoc(Doc doc);
/**
* 批量删除档案管理
*
* @param ids 需要删除的档案管理主键集合
* @return 结果
*/
public int deleteDocByIds(Long[] ids);
/**
* 删除档案管理信息
*
* @param id 档案管理主键
* @return 结果
*/
public int deleteDocById(Long id);
}

View File

@@ -4,6 +4,9 @@ import java.util.List;
import java.util.Set;
import com.xinda.iot.domain.Scene;
import com.xinda.iot.domain.SceneDevice;
import com.xinda.iot.domain.SceneScript;
import com.xinda.iot.domain.Script;
import com.xinda.iot.model.SceneTerminalUserVO;
/**
@@ -79,4 +82,7 @@ public interface ISceneService
* @return java.util.List<com.xinda.iot.model.SceneTerminalUserVO>
*/
List<SceneTerminalUserVO> selectTerminalUserBySceneIds(Set<Long> sceneIdSet);
void dynamicBuildRule(List<Script> ruleScripts, Scene scene);
String buildElData(Scene scene, List<Script> ruleScripts, List<SceneScript> sceneScripts, List<SceneDevice> sceneDevices);
String buildTriggerAction(SceneScript sceneScript, int scriptPurpose, Scene scene, List<Script> ruleScripts, List<SceneScript> sceneScripts, List<SceneDevice> sceneDevices);
}

View File

@@ -57,14 +57,21 @@ public class AlertLogServiceImpl implements IAlertLogService {
// }
// }
// 查询所属机构
if (null != user.getDeptId()) {
alertLog.setUserId(user.getDept().getDeptUserId());
} else {
alertLog.setUserId(user.getUserId());
if(user.getUserId()!=1){
if (null != user.getDeptId()) {
alertLog.setUserId(user.getDept().getDeptUserId());
} else {
alertLog.setUserId(user.getUserId());
}
}
return alertLogMapper.selectAlertLogList(alertLog);
}
@Override
public List<AlertLog> selectAlertLogSnList(AlertLog alertLog) {
return alertLogMapper.selectAlertLogList(alertLog);
}
@Override
public List<AlertLog> selectAlertLogListByCreateBy(String createBy, String remark, Integer status) {
AlertLog alertLog = new AlertLog();
@@ -80,10 +87,16 @@ public class AlertLogServiceImpl implements IAlertLogService {
* @param alertLog 设备告警
* @return 设备告警
*/
@Override
public Long selectSceneAlertLogListCount(AlertLog alertLog) {
return alertLogMapper.selectAlertLogListCount(alertLog);
}
@Override
public Long selectAlertLogListCount(AlertLog alertLog) {
SysUser user = getLoginUser().getUser();
// SysUser user = SecurityUtils.getLoginUser().getUser();
// SysUser user = getLoginUser().getUser();
SysUser user = SecurityUtils.getLoginUser().getUser();
List<SysRole> roles = user.getRoles();
for (int i = 0; i < roles.size(); i++) {
// 租户和用户,只查看自己分组

View File

@@ -1,14 +1,18 @@
package com.xinda.iot.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.xinda.common.core.domain.entity.SysUser;
import com.xinda.common.utils.DateUtils;
import com.xinda.iot.domain.Alert;
import com.xinda.iot.domain.AlertNotifyTemplate;
import com.xinda.iot.domain.AlertScene;
import com.xinda.iot.domain.Scene;
import com.xinda.iot.domain.*;
import com.xinda.iot.mapper.AlertMapper;
import com.xinda.iot.mapper.SceneDeviceMapper;
import com.xinda.iot.mapper.SceneMapper;
import com.xinda.iot.mapper.SceneScriptMapper;
import com.xinda.iot.model.AlertSceneSendVO;
import com.xinda.iot.service.IAlertService;
import com.xinda.iot.service.ISceneService;
import com.xinda.iot.service.IScriptService;
import com.xinda.notify.domain.NotifyTemplate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
@@ -34,6 +38,18 @@ public class AlertServiceImpl implements IAlertService {
@Autowired
private AlertMapper alertMapper;
@Autowired
private ISceneService sceneService;
@Autowired
private IScriptService scriptService;
@Autowired
private SceneScriptMapper sceneScriptMapper;
@Autowired
private SceneDeviceMapper sceneDeviceMapper;
/**
* 查询设备告警
*
@@ -43,7 +59,17 @@ public class AlertServiceImpl implements IAlertService {
@Override
public Alert selectAlertByAlertId(Long alertId) {
Alert alert = alertMapper.selectAlertByAlertId(alertId);
alert.setScenes(alertMapper.selectScenesByAlertId(alert.getAlertId()));
if(alert.getSerialNumber()!=null){
List<Scene> sceneList = alertMapper.selectScenesByAlertId(alert.getAlertId());
List<Scene> scenes = new ArrayList<>();
for(Scene scene : sceneList){
scenes.add(sceneService.selectSceneBySceneId(scene.getSceneId()));
}
alert.setScenes(scenes);
}else{
alert.setScenes(alertMapper.selectScenesByAlertId(alert.getAlertId()));
}
// alert.setScenes(alertMapper.selectScenesByAlertId(alert.getAlertId()));
alert.setNotifyTemplateList(alertMapper.selectNotifyTemplateListByAlertId(alert.getAlertId()));
return alert;
}
@@ -60,6 +86,7 @@ public class AlertServiceImpl implements IAlertService {
SysUser user = getLoginUser().getUser();
if (null != user.getDeptId()) {
alert.setTenantId(user.getDept().getDeptUserId());
alert.setDeptId(user.getDeptId());
} else {
alert.setTenantId(user.getUserId());
}
@@ -114,6 +141,43 @@ public class AlertServiceImpl implements IAlertService {
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int insertCfgAlert(Alert alert) {
// 新增告警配置
alert.setCreateTime(DateUtils.getNowDate());
int result=alertMapper.insertAlert(alert);
// 批量新增告警关联场景
if(alert.getScenes()!=null && alert.getScenes().size()>0) {
List<AlertScene> alertScenes = new ArrayList<>();
for (Scene scene : alert.getScenes()) {
// 保存场景联动
SysUser user = getLoginUser().getUser();
scene.setUserId(user.getUserId());
scene.setUserName(user.getUserName());
scene.setCreateBy(user.getUserName());
sceneService.insertScene(scene);
AlertScene alertScene = new AlertScene();
alertScene.setAlertId(alert.getAlertId());
alertScene.setSceneId(scene.getSceneId());
alertScenes.add(alertScene);
}
alertMapper.insertAlertSceneList(alertScenes);
}
// 批量新增通知模版
if (CollectionUtils.isNotEmpty(alert.getNotifyTemplateList())) {
List<AlertNotifyTemplate> alertNotifyTemplateList = new ArrayList<>();
for (NotifyTemplate notifyTemplate : alert.getNotifyTemplateList()) {
AlertNotifyTemplate alertNotifyTemplate = new AlertNotifyTemplate();
alertNotifyTemplate.setAlertId(alert.getAlertId());
alertNotifyTemplate.setNotifyTemplateId(notifyTemplate.getId());
alertNotifyTemplateList.add(alertNotifyTemplate);
}
alertMapper.insertAlertNotifyTemplateList(alertNotifyTemplateList);
}
return result;
}
/**
* 修改设备告警
*
@@ -134,6 +198,14 @@ public class AlertServiceImpl implements IAlertService {
if(alert.getScenes()!=null && alert.getScenes().size()>0) {
List<AlertScene> alertScenes = new ArrayList<>();
for (Scene scene : alert.getScenes()) {
if(alert.getSerialNumber()!=null){
// 保存场景联动
SysUser user = getLoginUser().getUser();
scene.setUserId(user.getUserId());
scene.setUserName(user.getUserName());
scene.setCreateBy(user.getUserName());
sceneService.updateScene(scene);
}
AlertScene alertScene = new AlertScene();
alertScene.setAlertId(alert.getAlertId());
alertScene.setSceneId(scene.getSceneId());
@@ -164,6 +236,12 @@ public class AlertServiceImpl implements IAlertService {
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteAlertByAlertIds(Long[] alertIds) {
if(alertIds.length==1){
for (Long alertId : alertIds) {
alertMapper.deleteSceneByAlertId(alertId);
}
alertMapper.deleteAlertSceneByAlertIds(alertIds);
}
// 批量删除告警场景
alertMapper.deleteAlertSceneByAlertIds(alertIds);
// 批量删除告警通知模版配置

View File

@@ -0,0 +1,96 @@
package com.xinda.iot.service.impl;
import java.util.List;
import com.xinda.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xinda.iot.mapper.CamDeviceMapper;
import com.xinda.iot.domain.CamDevice;
import com.xinda.iot.service.ICamDeviceService;
/**
* 监控设备关联Service业务层处理
*
* @author ledo
* @date 2025-04-04
*/
@Service
public class CamDeviceServiceImpl implements ICamDeviceService
{
@Autowired
private CamDeviceMapper camDeviceMapper;
/**
* 查询监控设备关联
*
* @param id 监控设备关联主键
* @return 监控设备关联
*/
@Override
public CamDevice selectCamDeviceById(Long id)
{
return camDeviceMapper.selectCamDeviceById(id);
}
/**
* 查询监控设备关联列表
*
* @param camDevice 监控设备关联
* @return 监控设备关联
*/
@Override
public List<CamDevice> selectCamDeviceList(CamDevice camDevice)
{
return camDeviceMapper.selectCamDeviceList(camDevice);
}
/**
* 新增监控设备关联
*
* @param camDevice 监控设备关联
* @return 结果
*/
@Override
public int insertCamDevice(CamDevice camDevice)
{
camDevice.setCreateTime(DateUtils.getNowDate());
return camDeviceMapper.insertCamDevice(camDevice);
}
/**
* 修改监控设备关联
*
* @param camDevice 监控设备关联
* @return 结果
*/
@Override
public int updateCamDevice(CamDevice camDevice)
{
camDevice.setUpdateTime(DateUtils.getNowDate());
return camDeviceMapper.updateCamDevice(camDevice);
}
/**
* 批量删除监控设备关联
*
* @param ids 需要删除的监控设备关联主键
* @return 结果
*/
@Override
public int deleteCamDeviceByIds(Long[] ids)
{
return camDeviceMapper.deleteCamDeviceByIds(ids);
}
/**
* 删除监控设备关联信息
*
* @param id 监控设备关联主键
* @return 结果
*/
@Override
public int deleteCamDeviceById(Long id)
{
return camDeviceMapper.deleteCamDeviceById(id);
}
}

View File

@@ -77,6 +77,8 @@ public class DeviceServiceImpl implements IDeviceService {
@Autowired
private DeviceMapper deviceMapper;
@Autowired
private CamDeviceMapper camDeviceMapper;
@Autowired
private DeviceUserMapper deviceUserMapper;
@Autowired
private ITSLCache itslCache;
@@ -129,6 +131,10 @@ public class DeviceServiceImpl implements IDeviceService {
private IGroupService groupService;
// @Autowired
// private CamDeviceChannelMapper camDeviceChannelMapper;
/**
* 查询设备
*
@@ -561,13 +567,6 @@ public class DeviceServiceImpl implements IDeviceService {
*/
@Override
public List<DeviceShortOutput> selectGDeviceShortList(Device device) {
// 清空离线并且 group_id = 0 的数据
// deviceMapper.deleteDeviceBygroupId();
List<DeviceShortOutput> list = deviceMapper.selectDeviceGShortList(device);
List<DeviceAlertCount> alist = alertLogService.selectDeviceAlertCount();
for (DeviceAlertCount item : alist) {
@@ -584,6 +583,8 @@ public class DeviceServiceImpl implements IDeviceService {
}
}
// // 组态不是所有人都买了,故单独查询组态信息
// List<String> guidList = productList.stream().map(Product::getGuid).collect(Collectors.toList());
return list;
}
@@ -607,6 +608,52 @@ public class DeviceServiceImpl implements IDeviceService {
return list;
}
@Override
public List<DeviceShortOutput> selectDeviceShortGwList(Device device) {
List<DeviceShortOutput> list = deviceMapper.selectDeviceShortGwList(device);
for (DeviceShortOutput deviceShortOutput : list )
{
Device sdevice = new Device();
sdevice.setGwId(device.getDeviceId());
sdevice.setDeviceType(3);
List<DeviceShortOutput> sipList = deviceMapper.selectDeviceShortList(sdevice);
if(sipList.size()>0){
deviceShortOutput.setSipList(sipList);
}
}
List<DeviceAlertCount> alist = alertLogService.selectDeviceAlertCount();
for (DeviceAlertCount item : alist) {
list.stream()
.filter(it -> Objects.equals(it.getSerialNumber(), item.getSerialNumber()))
.forEach(it -> it.setAlertCount(item));
}
return list;
}
@Override
public List<DeviceShortOutput> selectDeviceShortTreeList(Device device) {
List<DeviceShortOutput> list = deviceMapper.selectDeviceShortTreeList(device);
List<DeviceAlertCount> alist = alertLogService.selectDeviceAlertCount();
for (DeviceAlertCount item : alist) {
list.stream()
.filter(it -> Objects.equals(it.getSerialNumber(), item.getSerialNumber()))
.forEach(it -> it.setAlertCount(item));
}
return list;
}
@Override
public List<DeviceShortOutput> selectCamDeviceListByDeviceId(Long deviceId) {
List<DeviceShortOutput> list = deviceMapper.selectCamDeviceListByDeviceId(deviceId);
List<DeviceAlertCount> alist = alertLogService.selectDeviceAlertCount();
for (DeviceAlertCount item : alist) {
list.stream()
.filter(it -> Objects.equals(it.getSerialNumber(), item.getSerialNumber()))
.forEach(it -> it.setAlertCount(item));
}
return list;
}
/**
* 查询设备
*
@@ -817,7 +864,6 @@ public class DeviceServiceImpl implements IDeviceService {
// 连接MQTTX todo
setLocation(user.getLoginIp(), device);
deviceMapper.insertDevice(device);
// redis缓存设备默认状态物模型值
@@ -835,6 +881,13 @@ public class DeviceServiceImpl implements IDeviceService {
deviceIdList.add(device.getDeviceId());
deviceMapper.updateTenantIdByDeptIds(deptUserId, suser.getUserName(), deviceIdList);
}
if(device.getDeviceType()==3 && device.getMDeviceId()!=null ){
CamDevice camDevice = new CamDevice();
camDevice.setSipId(device.getDeviceId());
camDevice.setDeviceId(device.getMDeviceId());
camDeviceMapper.insertCamDevice(camDevice);
}
return device;
}
@Override
@@ -1009,6 +1062,7 @@ public class DeviceServiceImpl implements IDeviceService {
@CachePut(value = "device", key = "'selectShortDeviceBySerialNumber' + #device.getSerialNumber()")
})
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult updateDevice(Device device) {
// 设备编号唯一检查
Device oldDevice = deviceMapper.selectDeviceByDeviceId(device.getDeviceId());
@@ -1041,6 +1095,25 @@ public class DeviceServiceImpl implements IDeviceService {
List<Long> deviceIdList = new ArrayList<>();
deviceIdList.add(device.getDeviceId());
deviceMapper.updateTenantIdByDeptIds(deptUserId, suser.getUserName(), deviceIdList);
// if(device.getDeviceType()==3){
// SipDeviceChannel sipDeviceChannel = new SipDeviceChannel();
// sipDeviceChannel.setDeviceSipId(device.getSerialNumber());
// List<SipDeviceChannel> list = sipDeviceChannelMapper.selectSipDeviceChannelList(sipDeviceChannel);
// List<SipDeviceChannel> newList = new ArrayList<>();
// if (list != null && list.size() > 0) {
// for (SipDeviceChannel channel : list) {
// channel.setTenantId(deptUserId);
// sipDeviceChannelMapper.updateSipDeviceChannel(channel);
// }
// }
// }
}
if(device.getDeviceType()==3 && device.getMDeviceId()!=null ){
camDeviceMapper.deleteCamDeviceBySipId(device.getDeviceId());
CamDevice camDevice = new CamDevice();
camDevice.setSipId(device.getDeviceId());
camDevice.setDeviceId(device.getMDeviceId());
camDeviceMapper.insertCamDevice(camDevice);
}
return AjaxResult.success("修改成功", 1);

View File

@@ -0,0 +1,111 @@
package com.xinda.iot.service.impl;
import java.util.List;
import com.xinda.common.core.domain.entity.SysUser;
import com.xinda.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xinda.iot.mapper.DocMapper;
import com.xinda.iot.domain.Doc;
import com.xinda.iot.service.IDocService;
import static com.xinda.common.utils.SecurityUtils.getLoginUser;
/**
* 档案管理Service业务层处理
*
* @author leo
* @date 2025-04-04
*/
@Service
public class DocServiceImpl implements IDocService
{
@Autowired
private DocMapper docMapper;
/**
* 查询档案管理
*
* @param id 档案管理主键
* @return 档案管理
*/
@Override
public Doc selectDocById(Long id)
{
return docMapper.selectDocById(id);
}
/**
* 查询档案管理列表
*
* @param doc 档案管理
* @return 档案管理
*/
@Override
public List<Doc> selectDocList(Doc doc)
{
SysUser sysUser = getLoginUser().getUser();
//添加设备
doc.setTenantId(sysUser.getDept().getDeptUserId());
doc.setDeptId(sysUser.getDept().getDeptId());
return docMapper.selectDocList(doc);
}
/**
* 新增档案管理
*
* @param doc 档案管理
* @return 结果
*/
@Override
public int insertDoc(Doc doc)
{
SysUser sysUser = getLoginUser().getUser();
//添加设备
doc.setTenantId(sysUser.getDept().getDeptUserId());
doc.setTenantName(sysUser.getDept().getDeptUserName());
doc.setDeptId(sysUser.getDept().getDeptId());
doc.setDeptName(sysUser.getDept().getDeptName());
doc.setCreateTime(DateUtils.getNowDate());
return docMapper.insertDoc(doc);
}
/**
* 修改档案管理
*
* @param doc 档案管理
* @return 结果
*/
@Override
public int updateDoc(Doc doc)
{
doc.setUpdateTime(DateUtils.getNowDate());
return docMapper.updateDoc(doc);
}
/**
* 批量删除档案管理
*
* @param ids 需要删除的档案管理主键
* @return 结果
*/
@Override
public int deleteDocByIds(Long[] ids)
{
return docMapper.deleteDocByIds(ids);
}
/**
* 删除档案管理信息
*
* @param id 档案管理主键
* @return 结果
*/
@Override
public int deleteDocById(Long id)
{
return docMapper.deleteDocById(id);
}
}

View File

@@ -66,7 +66,15 @@ public class ProductServiceImpl implements IProductService
@Override
public Product selectProductByProductId(Long productId)
{
return productMapper.selectProductByProductId(productId);
Product product = productMapper.selectProductByProductId(productId);
if(product.getGuid()!=null){
Long scadaId = productMapper.selectScadaIdByGuid(product.getGuid());
if(scadaId !=null) {
product.setScadaId(scadaId);
}
}
return product;
}
@Override
public Product selectProductByMqttAccount(String mqttAccount)
@@ -86,12 +94,12 @@ public class ProductServiceImpl implements IProductService
// 组态不是所有人都买了,故单独查询组态信息
List<String> guidList = productList.stream().map(Product::getGuid).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(guidList)) {
// List<Product> scadaList = productMapper.selectListScadaIdByGuidS(guidList);
// Map<String, Long> map = scadaList.stream().collect(Collectors.toMap(Product::getGuid, Product::getScadaId));
// for (Product product1 : productList) {
// Long scadaId = map.get(product1.getGuid());
// product1.setScadaId(scadaId);
// }
List<Product> scadaList = productMapper.selectListScadaIdByGuidS(guidList);
Map<String, Long> map = scadaList.stream().collect(Collectors.toMap(Product::getGuid, Product::getScadaId));
for (Product product1 : productList) {
Long scadaId = map.get(product1.getGuid());
product1.setScadaId(scadaId);
}
}
return productList;
}

View File

@@ -170,6 +170,7 @@ public class SceneServiceImpl implements ISceneService {
SysUser user = getLoginUser().getUser();
scene.setCreateBy(user.getUserName());
scene.setCreateTime(DateUtils.getNowDate());
scene.setApplicationName("xinda");
// scene.setUserId(user.getUserId());
// scene.setUserName(user.getUserName());
// 延时不超过90秒
@@ -236,7 +237,7 @@ public class SceneServiceImpl implements ISceneService {
List<SceneScript> sceneScripts = new ArrayList<>();
List<SceneDevice> sceneDevices = new ArrayList<>();
String elData = buildElData(scene, ruleScripts, sceneScripts, sceneDevices);
scene.setApplicationName("xinda");
scene.setElData(elData);
scene.setUpdateTime(DateUtils.getNowDate());
sceneMapper.updateScene(scene);
@@ -259,7 +260,8 @@ public class SceneServiceImpl implements ISceneService {
*
* @param ruleScripts
*/
private void dynamicBuildRule(List<Script> ruleScripts, Scene scene) {
@Override
public void dynamicBuildRule(List<Script> ruleScripts, Scene scene) {
for (Script ruleScript : ruleScripts) {
// 规则引擎构建脚本组件
if (ruleScript.getScriptPurpose() == 2) {
@@ -289,7 +291,8 @@ public class SceneServiceImpl implements ISceneService {
* @param sceneDevices 场景设备集合
* @return
*/
private String buildElData(Scene scene, List<Script> ruleScripts, List<SceneScript> sceneScripts, List<SceneDevice> sceneDevices) {
@Override
public String buildElData(Scene scene, List<Script> ruleScripts, List<SceneScript> sceneScripts, List<SceneDevice> sceneDevices) {
// 排除定时后的触发器等于0不生成规则数据等于1移除AND和OR
Long triggerNodeCount = scene.getTriggers().stream().filter(x -> x.getSource() != 2).count();
Long triggerTimingCount = scene.getTriggers().stream().filter(x -> x.getSource() == 2).count();
@@ -383,7 +386,9 @@ public class SceneServiceImpl implements ISceneService {
* @param scene 场景
* @return 返回规则脚本ID
*/
private String buildTriggerAction(SceneScript sceneScript, int scriptPurpose, Scene scene, List<Script> ruleScripts, List<SceneScript> sceneScripts, List<SceneDevice> sceneDevices) {
@Override
public String buildTriggerAction(SceneScript sceneScript, int scriptPurpose, Scene scene, List<Script> ruleScripts, List<SceneScript> sceneScripts, List<SceneDevice> sceneDevices) {
// 构建规则脚本
Script ruleScript = new Script();
// 设置脚本标识,D=数据流A=执行动作T=触发器,雪花算法生成唯一数

View File

@@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="serialNumber" column="serial_number"/>
</resultMap>
<resultMap type="com.xinda.iot.domain.Scene" id="AlertSceneResult">
@@ -44,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAlertVo">
select alert_id, alert_name, alert_level, status, notify, create_by, create_time, update_by, update_time, remark, tenant_id, tenant_name from iot_alert
select alert_id, alert_name, alert_level, status, notify, create_by, create_time, update_by, update_time, remark, tenant_id, tenant_name,serial_number from iot_alert
</sql>
<select id="selectScenesByAlertId" parameterType="Long" resultMap="AlertSceneResult">
@@ -53,16 +54,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join iot_scene s on a.scene_id = s.scene_id
</select>
<delete id="deleteSceneByAlertId" parameterType="Long">
delete from iot_scene where scene_id in (select scene_id from iot_alert_scene where alert_id = #{alertId})
</delete>
<select id="selectAlertList" parameterType="Alert" resultMap="AlertResult">
<include refid="selectAlertVo"/>
select p.alert_id, p.alert_name, p.alert_level, p.status, p.notify, p.create_by, p.create_time,
p.update_by, p.update_time, p.remark, p.tenant_id, p.tenant_name,p.serial_number from iot_alert p
<where>
<if test="alertName != null and alertName != ''"> and alert_name like concat('%', #{alertName}, '%')</if>
<if test="alertLevel != null "> and alert_level = #{alertLevel}</if>
<if test="status != null "> and status = #{status}</if>
<if test="notify != null and notify != ''"> and notify = #{notify}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="alertName != null and alertName != ''"> and p.alert_name like concat('%', #{alertName}, '%')</if>
<if test="alertLevel != null "> and p.alert_level = #{alertLevel}</if>
<if test="status != null "> and p.status = #{status}</if>
<if test="notify != null and notify != ''"> and p.notify = #{notify}</if>
<if test="tenantId != null "> and p.tenant_id = #{tenantId}</if>
<!-- <if test="deptId != null ">-->
<!-- and ( p.tenant_id = #{tenantId}-->
<!-- or (p.tenant_id in (-->
<!-- SELECT de.dept_user_id-->
<!-- FROM sys_dept de-->
<!-- WHERE FIND_IN_SET( de.dept_id,(-->
<!-- SELECT d.ancestors-->
<!-- FROM sys_dept d-->
<!-- WHERE d.dept_id = #{deptId} )-->
<!-- )-->
<!-- )-->
<!-- )-->
<!-- )-->
<!-- </if>-->
<if test="serialNumber != null and serialNumber != ''">and p.serial_number = #{serialNumber}</if>
</where>
order by create_time desc
order by p.create_time desc
</select>
<select id="selectAlertByAlertId" parameterType="Long" resultMap="AlertResult">
@@ -110,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
<if test="serialNumber != null and serialNumber != ''">serial_number,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alertName != null and alertName != ''">#{alertName},</if>
@@ -123,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
</trim>
</insert>
@@ -138,6 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
</trim>
where alert_id = #{alertId}
</update>

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xinda.iot.mapper.SpDeviceMapper">
<resultMap type="CamDevice" id="CamDeviceResult">
<result property="id" column="id" />
<result property="sipId" column="sip_id" />
<result property="deviceId" column="device_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectCamDeviceVo">
select id, sip_id, device_id, create_by, create_time, update_by, update_time, del_flag from iot_sip_device
</sql>
<select id="selectCamDeviceList" parameterType="CamDevice" resultMap="CamDeviceResult">
<include refid="selectCamDeviceVo"/>
<where>
<if test="sipId != null "> and sip_id = #{sipId}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
</where>
</select>
<select id="selectCamDeviceById" parameterType="Long" resultMap="CamDeviceResult">
<include refid="selectCamDeviceVo"/>
where id = #{id}
</select>
<insert id="insertCamDevice" parameterType="CamDevice" useGeneratedKeys="true" keyProperty="id">
insert into iot_sip_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sipId != null">sip_id,</if>
<if test="deviceId != null">device_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sipId != null">#{sipId},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateCamDevice" parameterType="CamDevice">
update iot_sip_device
<trim prefix="SET" suffixOverrides=",">
<if test="sipId != null">sip_id = #{sipId},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCamDeviceById" parameterType="Long">
delete from iot_sip_device where id = #{id}
</delete>
<delete id="deleteCamDeviceBySipId" parameterType="Long">
delete from iot_sip_device where sip_id = #{sipId}
</delete>
<delete id="deleteCamDeviceByIds" parameterType="String">
delete from iot_sip_device where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -37,6 +37,14 @@
<result property="guid" column="guid"/>
<result property="groupId" column="group_id"/>
<result property="agenciesId" column="agencies_id"/>
<result property="icWay" column="ic_way"/>
<result property="iccid" column="iccid"/>
<result property="volt" column="volt"/>
<result property="sd" column="sd"/>
<result property="pd" column="pd"/>
<result property="imei" column="imei"/>
<result property="gwId" column="gw_id"/>
<result property="gwName" column="gw_name"/>
</resultMap>
<resultMap type="com.xinda.iot.model.DeviceShortOutput" id="DeviceShortResult">
@@ -67,6 +75,14 @@
<result property="guid" column="guid"/>
<result property="groupId" column="group_id"/>
<result property="agenciesId" column="agencies_id"/>
<result property="icWay" column="ic_way"/>
<result property="iccid" column="iccid"/>
<result property="volt" column="volt"/>
<result property="sd" column="sd"/>
<result property="pd" column="pd"/>
<result property="imei" column="imei"/>
<result property="gwId" column="gw_id"/>
<result property="gwName" column="gw_name"/>
</resultMap>
<resultMap type="com.xinda.iot.model.DeviceAllShortOutput" id="DeviceAllShortResult">
@@ -87,6 +103,14 @@
<result property="latitude" column="latitude"/>
<result property="isOwner" column="is_owner"/>
<result property="subDeviceCount" column="sub_device_count"/>
<result property="icWay" column="ic_way"/>
<result property="iccid" column="iccid"/>
<result property="volt" column="volt"/>
<result property="sd" column="sd"/>
<result property="pd" column="pd"/>
<result property="imei" column="imei"/>
<result property="gwId" column="gw_id"/>
<result property="gwName" column="gw_name"/>
</resultMap>
<resultMap type="com.xinda.iot.model.UserAndTenant" id="UserAndTenantResult">
@@ -192,7 +216,13 @@
img_url,
summary,
remark,
slave_id,group_id,agencies_id
slave_id,
group_id,
agencies_id,
ic_way,
iccid,
volt,
sd,pd,imei, gw_id, gw_name
from iot_device
</sql>
@@ -213,7 +243,12 @@
things_model_value,
active_time,
img_url,
slave_id,group_id,agencies_id
slave_id,
group_id,
agencies_id,
ic_way,
iccid,
volt,sd,pd,imei, gw_id, gw_name
from iot_device
</sql>
@@ -230,7 +265,9 @@
rssi,
location_way,
things_model_value,
active_time,group_id,agencies_id
active_time,
group_id,
agencies_id
from iot_device
</sql>
@@ -263,6 +300,8 @@
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''">
and active_time between #{params.beginActiveTime} and #{params.endActiveTime}
</if>
<if test="gwId != null "> and gw_id = #{gwId}</if>
<if test="gwName != null and gwName != ''"> and gw_name like concat('%', #{gwName}, '%')</if>
</where>
order by create_time desc
</select>
@@ -305,8 +344,8 @@
<select id="selectDeviceListByGroup" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceResult">
select d.device_id, d.device_name, d.product_name, d.serial_number,d.gw_dev_code, d.firmware_version,
d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude
from iot_device d
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude, d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name
from iot_device d,sd,pd
<where>
<if test="productId != null ">and d.product_id = #{productId}</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
@@ -340,7 +379,7 @@
<select id="selectAllDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceAllShortResult">
select d.device_id, d.device_name, d.product_name,p.device_type, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name
from iot_device d
left join iot_product p on p.product_id=d.product_id
<where>
@@ -354,6 +393,7 @@
<if test="deptId != null and deptId != 0 and showChild != null and !showChild">
and d.tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})
</if>
<if test="gwId != null "> and d.gw_id = #{gwId}</if>
</where>
group by d.device_id,d.tenant_id
</select>
@@ -398,7 +438,7 @@
<select id="selectDeviceGShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url)
as img_url,
case
@@ -429,7 +469,7 @@
<if test="agenciesId == null">and d.agencies_id IS NULL</if>
<if test="agenciesId != null">and d.agencies_id = #{agenciesId}</if>
<!-- <if test="groupIdExclude != null">and d.group_id != #{groupIdExclude}</if>-->
<if test="gwId != null "> and d.gw_id = #{gwId}</if>
<if test="deptId != null and deptId != 0 and showChild != null and showChild ">
and
( d.tenant_id in (SELECT u.user_id FROM sys_user u
@@ -500,7 +540,7 @@
<select id="selectDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,
case
when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0
@@ -522,24 +562,115 @@
<if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="gwId != null "> and d.gw_id = #{gwId}</if>
<if test="deptId != null and deptId != 0 ">
and
( d.agencies_id in (SELECT de.dept_id FROM sys_dept de
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
)
</if>
<!-- <if test="deptId != null and deptId != 0 and showChild != null and !showChild">-->
<!-- and (-->
<!-- d.agencies_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})-->
<!-- or d.device_id in (select du.device_id from iot_device_share du where du.user_id = #{tenantId})-->
<!-- )-->
<!-- </if>-->
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
group by d.device_id,d.tenant_id
order by d.create_time desc
</select>
<select id="selectDeviceShortGwList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,
case
when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0
else 1
end as is_owner,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
p.protocol_code,p.transport,p.guid
from iot_device d
left join iot_product p on p.product_id=d.product_id
<if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>
<where>
p.device_type != 3
and d.del_flag = '0'
<if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="gwId != null "> and d.gw_id = #{gwId}</if>
<if test="deptId != null and deptId != 0 ">
and
( d.agencies_id in (SELECT de.dept_id FROM sys_dept de
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
)
</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
group by d.device_id,d.tenant_id
order by d.create_time desc
</select>
<select id="selectDeviceShortTreeList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,
case
when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0
else 1
end as is_owner,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
p.protocol_code,p.transport,p.guid
from iot_device d
left join iot_product p on p.product_id=d.product_id
<if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>
<where>
and d.del_flag = '0'
<if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
and (p.device_type == 2 or p.device_type == 1 )
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="gwId != null "> and d.gw_id = #{gwId}</if>
<if test="deptId != null and deptId != 0 ">
and
( d.agencies_id in (SELECT de.dept_id FROM sys_dept de
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
)
</if>
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
group by d.device_id,d.tenant_id
order by d.create_time desc
</select>
<select id="selectCamDeviceListByDeviceId" parameterType="Long" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
p.protocol_code,p.transport,p.guid
from iot_device d
left join iot_product p on p.product_id=d.product_id
<where>
and d.del_flag = '0'
and
( d.device_id in ( select sd.sip_id from iot_sip_device sd where sd.device_id = #{deviceId} )
)
</where>
group by d.device_id,d.tenant_id
order by d.create_time desc
</select>
<select id="selectDeviceByDeviceId" parameterType="Long" resultMap="DeviceResult">
select d.device_id,
d.device_name,
@@ -568,7 +699,10 @@
d.remark,
p.guid,
d.group_id,
d.agencies_id
d.agencies_id,
d.ic_way,
d.iccid,
d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name
from iot_device d
left join iot_product p on p.product_id = d.product_id
@@ -749,6 +883,14 @@
<if test="slaveId != null">slave_id,</if>
<if test="groupId != null">group_id,</if>
<if test="agenciesId != null">agencies_id,</if>
<if test="icWay != null">ic_way,</if>
<if test="iccid != null">iccid,</if>
<if test="volt != null">volt,</if>
<if test="sd != null">sd,</if>
<if test="pd != null">pd,</if>
<if test="imei != null">imei,</if>
<if test="gwId != null">gw_id,</if>
<if test="gwName != null">gw_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
@@ -781,13 +923,21 @@
<if test="slaveId != null">#{slaveId},</if>
<if test="groupId != null">#{groupId},</if>
<if test="agenciesId != null">#{agenciesId},</if>
<if test="icWay != null">#{icWay},</if>
<if test="iccid != null">#{iccid},</if>
<if test="volt != null">#{volt},</if>
<if test="sd != null">#{sd},</if>
<if test="pd != null">#{pd},</if>
<if test="imei != null">#{imei},</if>
<if test="gwId != null">#{gwId},</if>
<if test="gwName != null">#{gwName},</if>
</trim>
</insert>
<insert id="insertBatchDevice" parameterType="com.xinda.iot.domain.Device" useGeneratedKeys="true"
keyProperty="deviceId">
insert into iot_device (device_name, product_id, product_name, tenant_id, tenant_name, serial_number,
firmware_version, rssi, is_shadow, location_way, create_by, create_time)
firmware_version, rssi, is_shadow, location_way, create_by, create_time,ic_way,iccid,volt,sd,pd,imei, gw_id, gw_name)
values
<foreach collection="deviceList" item="device" separator=",">
(#{device.deviceName},
@@ -801,7 +951,15 @@
#{device.isShadow},
#{device.locationWay},
#{device.createBy},
sysdate())
sysdate(),
#{device.icWay},
#{device.iccid},
#{device.volt}),
#{device.sd}),
#{device.pd}),
#{device.imei}),
#{device.gwId}),
#{device.geName})
</foreach>
</insert>
@@ -838,6 +996,14 @@
<if test="slaveId != null">slave_id = #{slaveId},</if>
<if test="groupId != null">group_id = #{groupId},</if>
<if test="agenciesId != null">agencies_id = #{agenciesId},</if>
<if test="icWay != null">ic_way = #{icWay},</if>
<if test="iccid != null">iccid = #{iccid},</if>
<if test="volt != null">volt = #{volt},</if>
<if test="pd != null">pd = #{pd},</if>
<if test="sd != null">sd = #{sd},</if>
<if test="imei != null">imei = #{imei},</if>
<if test="gwId != null">gw_id = #{gwId},</if>
<if test="gwName != null">gw_name = #{gwName},</if>
</trim>
where device_id = #{deviceId}
</update>
@@ -852,8 +1018,14 @@
<if test="latitude != null">latitude = #{latitude},</if>
<if test="activeTime != null">active_time = #{activeTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="updateTime !=null">update_time = #{updateTime,jdbcType=TIMESTAMP}</if>
<if test="updateTime !=null">update_time = #{updateTime,jdbcType=TIMESTAMP},</if>
<if test="icWay != null">ic_way = #{icWay},</if>
<if test="iccid != null">iccid = #{iccid},</if>
<if test="volt != null">volt = #{volt},</if>
<if test="rssi != null">rssi = #{rssi},</if>
<if test="pd != null">pd = #{pd},</if>
<if test="sd != null">sd = #{sd},</if>
<if test="imei != null">imei = #{imei}</if>
</trim>
where serial_number = #{serialNumber} or gw_dev_code = #{serialNumber}
</update>
@@ -905,6 +1077,14 @@
<if test="slaveId != null">slave_id = #{slaveId},</if>
<if test="groupId != null">group_id = #{groupId},</if>
<if test="agenciesId != null">agencies_id = #{agenciesId},</if>
<if test="icWay != null">ic_way = #{icWay},</if>
<if test="iccid != null">iccid = #{iccid},</if>
<if test="volt != null">volt = #{volt},</if>
<if test="pd != null">pd = #{pd},</if>
<if test="sd != null">sd = #{sd},</if>
<if test="imei != null">imei = #{imei},</if>
<if test="gwId != null">gw_id = #{gwId},</if>
<if test="gwName != null">gw_name = #{gwName},</if>
</trim>
where serial_number = #{serialNumber}
</update>
@@ -1060,7 +1240,7 @@
<select id="listTerminalUser" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, d.product_id, d.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,d.ic_way,d.iccid,d.volt,d.sd,d.pd,d.imei, d.gw_id, d.gw_name,
d.things_model_value, d.active_time,d.create_time,d.img_url,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
p.protocol_code,p.transport, u.is_owner
@@ -1132,8 +1312,7 @@
<select id="listTerminalUserByGroup" resultType="com.xinda.iot.domain.Device">
select d.device_id, d.device_name, d.product_name, d.serial_number,d.gw_dev_code, d.firmware_version,
d.status,d.rssi,d.is_shadow ,
d.location_way, d.active_time,d.network_address,d.longitude,d.latitude
d.status,d.rssi,d.is_shadow ,d.location_way, d.active_time,d.network_address,d.longitude,d.latitude, d.ic_way,d.iccid,d.voltd.sd,d.pd,d.imei, d.gw_id, d.gw_name,
from (
select device_id, 1 AS is_owner
from iot_device_user

View File

@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xinda.iot.mapper.DocMapper">
<resultMap type="Doc" id="DocResult">
<result property="id" column="id" />
<result property="deptId" column="dept_id" />
<result property="deptName" column="dept_name" />
<result property="fileName" column="file_name" />
<result property="resourceUrl" column="resource_url" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDocVo">
select d.id, d.dept_id, d.dept_name, d.file_name, d.resource_url, d.tenant_id, d.tenant_name, d.create_by, d.create_time, d.update_by, d.update_time from iot_doc d
</sql>
<select id="selectDocList" parameterType="Doc" resultMap="DocResult">
<include refid="selectDocVo"/>
<where>
<!-- <if test="deptId != null "> and dept_id = #{deptId}</if>-->
<if test="deptId != null and deptId != 0 ">
and
( d.dept_id in (SELECT de.dept_id FROM sys_dept de
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
)
</if>
<if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
<if test="fileName != null and fileName != ''"> and d.file_name like concat('%', #{fileName}, '%')</if>
<if test="resourceUrl != null and resourceUrl != ''"> and d.resource_url = #{resourceUrl}</if>
<!-- <if test="tenantId != null "> and d.tenant_id = #{tenantId}</if>-->
<if test="tenantName != null and tenantName != ''"> and d.tenant_name like concat('%', #{tenantName}, '%')</if>
</where>
</select>
<select id="selectDocById" parameterType="Long" resultMap="DocResult">
<include refid="selectDocVo"/>
where d.id = #{id}
</select>
<insert id="insertDoc" parameterType="Doc" useGeneratedKeys="true" keyProperty="id">
insert into iot_doc
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptId != null">dept_id,</if>
<if test="deptName != null">dept_name,</if>
<if test="fileName != null">file_name,</if>
<if test="resourceUrl != null">resource_url,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null">tenant_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptId != null">#{deptId},</if>
<if test="deptName != null">#{deptName},</if>
<if test="fileName != null">#{fileName},</if>
<if test="resourceUrl != null">#{resourceUrl},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null">#{tenantName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateDoc" parameterType="Doc">
update iot_doc
<trim prefix="SET" suffixOverrides=",">
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="deptName != null">dept_name = #{deptName},</if>
<if test="fileName != null">file_name = #{fileName},</if>
<if test="resourceUrl != null">resource_url = #{resourceUrl},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null">tenant_name = #{tenantName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDocById" parameterType="Long">
delete from iot_doc where id = #{id}
</delete>
<delete id="deleteDocByIds" parameterType="String">
delete from iot_doc where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -55,7 +55,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
end as is_owner,
p.location_way from iot_product p
<where>
<!-- <if test="deptId != null and showSenior and !isAdmin">-->
<if test="deptId != null and showSenior ">
and ( p.tenant_id = #{tenantId}
or (p.tenant_id in (
SELECT de.dept_user_id
FROM sys_dept de
WHERE FIND_IN_SET( de.dept_id,(
SELECT d.ancestors
FROM sys_dept d
WHERE d.dept_id = #{deptId} )
)
)
and p.is_sys = 0
)
)
</if>
<if test="deptId != null and !showSenior ">
and ( p.tenant_id = #{tenantId}
or (p.tenant_id in (
SELECT de.dept_user_id
FROM sys_dept de
WHERE de.dept_id = #{deptId} )
)
)
</if>
<!-- <if test="deptId != null">-->
<!-- and ( p.tenant_id = #{tenantId}-->
<!-- or (p.tenant_id in (-->
<!-- SELECT de.dept_user_id-->
@@ -74,7 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- and p.tenant_id = #{tenantId}-->
<!-- </if>-->
<if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if>
<if test="productNameExclude != null and productNameExclude != ''"> and p.product_name != #{productNameExclude}</if>
<!-- <if test="productNameExclude != null and productNameExclude != ''"> and p.product_name != #{productNameExclude}</if>-->
<if test="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if>
<if test="modelName != null and modelName != ''"> and p.model_name like concat('%', #{modelName}, '%')</if>
<if test="proName != null and proName != ''"> and p.pro_name like concat('%', #{proName}, '%')</if>
@@ -347,6 +371,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where p.product_id = #{productId}
</select>
<select id="selectScadaIdByGuid" resultType="Long">
select id
from scada
where guid = #{guid}
</select>
<select id="selectListScadaIdByGuidS" resultType="com.xinda.iot.domain.Product">
select id scadaId, guid
from scada