提交修改

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

@@ -114,6 +114,8 @@ public class SysDept extends BaseEntity
*/
private String deptUserName;
private String url;
public String getDeptUserName() {
return deptUserName;
}
@@ -288,6 +290,14 @@ public class SysDept extends BaseEntity
this.children = children;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@@ -391,7 +391,7 @@ public class SceneContext {
alertLog.setSerialNumber(deviceNum);
alertLog.setStatus(2);
alertLog.setCreateBy(sceneId.toString());
Long count = alertLogService.selectAlertLogListCount(alertLog);
Long count = alertLogService.selectSceneAlertLogListCount(alertLog);
// 查询设备告警对应的场景是否有未处理告警
if (count > 0) {
return true;

View File

@@ -69,6 +69,12 @@ public class DeviceOtherMsgHandler {
data.setRuleEngine(true);
dataHandler.reportData(data);
break;
// case FUNCTION_POST:
// data.setShadow(false);
// data.setType(2);
// data.setRuleEngine(true);
// dataHandler.reportData(data);
// break;
case EVENT_POST:
data.setType(3);
data.setRuleEngine(true);

View File

@@ -84,7 +84,6 @@ public class RuleEngineHandler implements IRuleEngine {
for(Script script : list) {
requestId = requestId + "/" + script.getScriptId();
}
// String requestId = "scene/" + scene.getChainName();
flowExecutor.execute2FutureWithRid(scene.getChainName(), null, requestId, context);
}
}

View File

@@ -34,6 +34,10 @@
<artifactId>xinda-ruleEngine</artifactId>
<version>3.8.5</version>
</dependency>
<dependency>
<groupId>com.xinda</groupId>
<artifactId>xinda-scada</artifactId>
</dependency>
</dependencies>

View File

@@ -112,6 +112,21 @@ public class AlertController extends BaseController
return toAjax(alertService.insertAlert(alert));
}
@Log(title = "设备告警", businessType = BusinessType.INSERT)
@PostMapping("/addCfg")
public AjaxResult addCfg(@RequestBody Alert alert)
{
// 查询所属机构
SysUser user = getLoginUser().getUser();
if (null != user.getDeptId()) {
alert.setTenantId(user.getDept().getDeptUserId());
alert.setTenantName(user.getDept().getDeptUserName());
}
return toAjax(alertService.insertCfgAlert(alert));
}
/**
* 修改设备告警
*/

View File

@@ -60,6 +60,15 @@ public class AlertLogController extends BaseController
return getDataTable(list);
}
@GetMapping("/snList")
public TableDataInfo snList(AlertLog alertLog)
{
startPage();
List<AlertLog> list = alertLogService.selectAlertLogSnList(alertLog);
return getDataTable(list);
}
/**
* 导出设备告警列表
*/

View File

@@ -4,6 +4,7 @@ import com.xinda.common.annotation.Log;
import com.xinda.common.constant.HttpStatus;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.core.domain.entity.SysDept;
import com.xinda.common.core.domain.entity.SysRole;
import com.xinda.common.core.domain.model.LoginUser;
import com.xinda.common.core.page.TableDataInfo;
@@ -14,16 +15,24 @@ import com.xinda.common.utils.SecurityUtils;
import com.xinda.common.utils.StringUtils;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.iot.domain.Device;
import com.xinda.iot.model.DeviceAssignmentVO;
import com.xinda.iot.model.DeviceImportVO;
import com.xinda.iot.model.DeviceRelateUserInput;
import com.xinda.iot.model.SerialNumberVO;
import com.xinda.iot.domain.Product;
import com.xinda.iot.model.*;
import com.xinda.iot.service.IDeviceService;
import com.xinda.iot.service.IProductService;
import com.xinda.mq.service.IMqttMessagePublish;
import com.xinda.iot.model.dto.ThingsModelDTO;
import com.xinda.iot.service.IDeviceService;
import com.xinda.mq.service.IMqttMessagePublish;
import com.github.pagehelper.PageInfo;
import com.xinda.scada.domain.Scada;
import com.xinda.scada.domain.ScadaDeviceBind;
import com.xinda.scada.service.IScadaDeviceBindService;
import com.xinda.scada.service.IScadaService;
import com.xinda.sip.domain.SipDeviceChannel;
import com.xinda.sip.service.ISipDeviceChannelService;
import com.xinda.system.service.ISysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
@@ -37,6 +46,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
/**
@@ -53,10 +63,25 @@ public class DeviceController extends BaseController
@Autowired
private IDeviceService deviceService;
@Autowired
private ISysDeptService sysDeptService;
@Autowired
private ISipDeviceChannelService sipDeviceChannelService;
// @Lazy
@Autowired
private IMqttMessagePublish messagePublish;
@Autowired
private IProductService productService;
@Autowired
private IScadaService scadaService;
@Autowired
private IScadaDeviceBindService scadaDeviceBindService;
/**
* 查询设备列表
*/
@@ -162,6 +187,57 @@ public class DeviceController extends BaseController
return getDataTable(deviceService.selectDeviceShortList(device));
}
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/shortListWg")
@ApiOperation("设备分页简短列表")
public TableDataInfo shortListWg(Device device)
{
startPage();
LoginUser loginUser = getLoginUser();
if (null == loginUser.getDeptId()) {
// 终端用户查询设备
device.setTenantId(loginUser.getUserId());
return getDataTable(deviceService.listTerminalUser(device));
}
if (null == device.getDeptId()) {
device.setDeptId(getLoginUser().getDeptId());
}
if (Objects.isNull(device.getTenantId())){
device.setTenantId(getLoginUser().getUserId());
}
if (null == device.getShowChild()) {
device.setShowChild(false);
}
return getDataTable(deviceService.selectDeviceShortGwList(device));
}
/**
* 查询设备简短列表,主页列表数据
*/
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/shortTreeList")
@ApiOperation("设备分页简短列表")
public List<DeviceShortOutput> shortTreeList(Device device)
{
startPage();
if (null == device.getDeptId()) {
device.setDeptId(getLoginUser().getDeptId());
}
if (Objects.isNull(device.getTenantId())){
device.setTenantId(getLoginUser().getUserId());
}
if (null == device.getShowChild()) {
device.setShowChild(false);
}
List<DeviceShortOutput> shortOutputs = deviceService.selectDeviceShortTreeList(device);
for(DeviceShortOutput shortOutput :shortOutputs){
List<DeviceShortOutput> sipDevices = deviceService.selectCamDeviceListByDeviceId(shortOutput.getDeviceId());
shortOutput.setSipList(sipDevices);
}
return shortOutputs;
}
/**
* 查询所有设备简短列表
*/
@@ -271,7 +347,24 @@ public class DeviceController extends BaseController
@ApiOperation("添加设备")
public AjaxResult add(@RequestBody Device device)
{
return AjaxResult.success(deviceService.insertDevice(device));
Product product = productService.selectProductByProductId(device.getProductId());
//复制组态信息
if(StringUtils.isNotEmpty(product.getGuid())){
Scada scada = scadaService.selectScadaByGuid(product.getGuid());
UUID uuid = UUID.randomUUID();
scada.setGuid(uuid.toString());
scadaService.insertScada(scada);
device.setGuid(uuid.toString());
}
deviceService.insertDevice(device);
//复制组态信息
if(StringUtils.isNotEmpty(product.getGuid())){
ScadaDeviceBind scadaDeviceBind = new ScadaDeviceBind();
scadaDeviceBind.setScadaGuid(device.getGuid());
scadaDeviceBind.setSerialNumber(device.getSerialNumber());
scadaDeviceBindService.insertScadaDeviceBind(scadaDeviceBind);
}
return AjaxResult.success();
}
/**
@@ -302,6 +395,25 @@ public class DeviceController extends BaseController
@ApiOperation("修改设备")
public AjaxResult edit(@RequestBody Device device)
{
if(null != device.getAgenciesId()) {
SysDept sysDept = sysDeptService.selectDeptById(device.getAgenciesId());
Long deptUserId = sysDept.getDeptUserId();
if (null == deptUserId) {
deptUserId = sysDeptService.selectDeptById(sysDept.getParentId()).getDeptUserId();
}
if(device.getDeviceType()==3){
SipDeviceChannel sipDeviceChannel = new SipDeviceChannel();
sipDeviceChannel.setDeviceSipId(device.getSerialNumber());
List<SipDeviceChannel> list = sipDeviceChannelService.selectSipDeviceChannelList(sipDeviceChannel);
List<SipDeviceChannel> newList = new ArrayList<>();
if (list != null && list.size() > 0) {
for (SipDeviceChannel channel : list) {
channel.setTenantId(deptUserId);
sipDeviceChannelService.updateSipDeviceChannel(channel);
}
}
}
}
return deviceService.updateDevice(device);
}
@@ -327,6 +439,12 @@ public class DeviceController extends BaseController
@DeleteMapping("/{deviceIds}")
@ApiOperation("批量删除设备")
public AjaxResult remove(@PathVariable Long[] deviceIds) throws SchedulerException {
for(Long deviceId:deviceIds){
Device device=deviceService.selectDeviceByDeviceId(deviceId);
if(StringUtils.isNotEmpty(device.getGuid())){
scadaService.deleteScadaByGuid(device.getGuid());
}
}
return deviceService.deleteDeviceByDeviceId(deviceIds[0]);
}

View File

@@ -0,0 +1,113 @@
package com.xinda.data.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.xinda.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinda.common.annotation.Log;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.enums.BusinessType;
import com.xinda.iot.domain.Doc;
import com.xinda.iot.service.IDocService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 档案管理Controller
*
* @author leo
* @date 2025-04-04
*/
@RestController
@RequestMapping("/iot/doc")
@Api(tags = "档案管理")
public class DocController extends BaseController
{
@Autowired
private IDocService docService;
/**
* 查询档案管理列表
*/
@PreAuthorize("@ss.hasPermi('iot:doc:list')")
@GetMapping("/list")
@ApiOperation("查询档案管理列表")
public TableDataInfo list(Doc doc)
{
startPage();
List<Doc> list = docService.selectDocList(doc);
return getDataTable(list);
}
/**
* 导出档案管理列表
*/
@ApiOperation("导出档案管理列表")
@PreAuthorize("@ss.hasPermi('iot:doc:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, Doc doc)
{
List<Doc> list = docService.selectDocList(doc);
ExcelUtil<Doc> util = new ExcelUtil<Doc>(Doc.class);
util.exportExcel(response, list, "档案管理数据");
}
/**
* 获取档案管理详细信息
*/
@PreAuthorize("@ss.hasPermi('iot:doc:query')")
@GetMapping(value = "/{id}")
@ApiOperation("获取档案管理详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(docService.selectDocById(id));
}
/**
* 新增档案管理
*/
@PreAuthorize("@ss.hasPermi('iot:doc:add')")
@PostMapping
@ApiOperation("新增档案管理")
public AjaxResult add(@RequestBody Doc doc)
{
return toAjax(docService.insertDoc(doc));
}
/**
* 修改档案管理
*/
@PreAuthorize("@ss.hasPermi('iot:doc:edit')")
@PutMapping
@ApiOperation("修改档案管理")
public AjaxResult edit(@RequestBody Doc doc)
{
return toAjax(docService.updateDoc(doc));
}
/**
* 删除档案管理
*/
@PreAuthorize("@ss.hasPermi('iot:doc:remove')")
@DeleteMapping("/{ids}")
@ApiOperation("删除档案管理")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(docService.deleteDocByIds(ids));
}
}

View File

@@ -48,23 +48,44 @@ public class ProductController extends BaseController
public TableDataInfo list(Product product)
{
startPage();
SysUser user = getLoginUser().getUser();
if (null == user.getDeptId()) {
product.setTenantId(user.getUserId());
return getDataTable(productService.selectTerminalUserProduct(product));
}
// SysUser user = getLoginUser().getUser();
// if (null == user.getDeptId()) {
// product.setTenantId(user.getUserId());
// return getDataTable(productService.selectTerminalUserProduct(product));
// }
Boolean showSenior = product.getShowSenior();
if (Objects.isNull(showSenior)){
//默认展示上级产品
product.setShowSenior(true);
}
if(product.getDeptId()==null){
Long deptUserId = getLoginUser().getUser().getDept().getDeptUserId();
product.setAdmin(SecurityUtils.isAdmin(deptUserId));
// product.setAdmin(SecurityUtils.isAdmin(deptUserId));
product.setDeptId(getLoginUser().getDeptId());
product.setTenantId(deptUserId);
}
return getDataTable(productService.selectProductList(product));
}
@GetMapping("/longList")
@ApiOperation("产品分页列表")
public List<Product> longList(Product product)
{
Boolean showSenior = product.getShowSenior();
if (Objects.isNull(showSenior)){
//默认展示上级产品
product.setShowSenior(true);
}
if(product.getDeptId()==null){
Long deptUserId = getLoginUser().getUser().getDept().getDeptUserId();
product.setDeptId(getLoginUser().getDeptId());
product.setTenantId(deptUserId);
}
return productService.selectProductList(product);
}
/**
* 查询产品简短列表
*/

View File

@@ -35,7 +35,6 @@ public class ThingsModelStandardController extends BaseController {
/**
* 查询通用物模型列表
*/
@PreAuthorize("@ss.hasPermi('iot:standard:list')")
@GetMapping("/list")
@ApiOperation("通用物模型分页列表")
public TableDataInfo list(ThingsModelStandard thingsModelStandard) {
@@ -46,7 +45,7 @@ public class ThingsModelStandardController extends BaseController {
/**
* 导出通用物模型列表
*/
@PreAuthorize("@ss.hasPermi('iot:standard:export')")
@Log(title = "通用物模型", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ApiOperation("导出通用物模型")
@@ -59,7 +58,7 @@ public class ThingsModelStandardController extends BaseController {
/**
* 获取通用物模型详细信息
*/
@PreAuthorize("@ss.hasPermi('iot:standard:query')")
@GetMapping(value = "/{templateId}")
@ApiOperation("获取通用物模型详情")
public AjaxResult getInfo(@PathVariable("templateId") Long templateId) {
@@ -69,7 +68,6 @@ public class ThingsModelStandardController extends BaseController {
/**
* 新增通用物模型
*/
@PreAuthorize("@ss.hasPermi('iot:standard:add')")
@Log(title = "通用物模型", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("添加通用物模型")
@@ -99,7 +97,7 @@ public class ThingsModelStandardController extends BaseController {
/**
* 删除通用物模型
*/
@PreAuthorize("@ss.hasPermi('iot:standard:remove')")
@Log(title = "通用物模型", businessType = BusinessType.DELETE)
@DeleteMapping("/{templateIds}")
@ApiOperation("批量删除通用物模型")
@@ -125,7 +123,7 @@ public class ThingsModelStandardController extends BaseController {
/**
* 导入采集点
*/
@PreAuthorize("@ss.hasPermi('iot:standard:add')")
@ApiOperation(value = "采集点导入")
@PostMapping(value = "/importData")
public AjaxResult importData(MultipartFile file, String tempSlaveId) throws Exception {

View File

@@ -97,13 +97,6 @@ public class PubMqttCallBack implements MqttCallbackExtended {
log.info("MQTT内部客户端已经连接!");
System.out.print("" +
" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n" +
" * _⚲_⚲_ ______ _ ____ * \n" +
" * | / \\ | | ____| | | | _ \\ * \n" +
" * | | | ● | | | | |__ __ _ ___| |_ | |_) | ___ ___ * \n" +
" * | \\ / | | __/ _` / __| __| | _ < / _ \\/ _ \\ * \n" +
" * \\ / | | | (_| \\__ \\ |_ | |_) | __/ __/ * \n" +
" * V |_| \\__,_|___/\\__| |____/ \\___|\\___| * \n" +
" * * \n" +
" * * * * * * * * * * * * XinDa物联网平台[✔启动成功] * * * * * * * * * * * * \n");
//连接后订阅, enable为false表示使用emq

View File

@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
*/
@Slf4j
@Component
@SysProtocol(name = "IECF6113-JSON协议",protocolCode = XinDaConstant.PROTOCOL.IECF6113,description = "IECF6113-JSON协议")
@SysProtocol(name = "IECF6113-JSON协议", protocolCode = XinDaConstant.PROTOCOL.IECF6113, description = "IECF6113-JSON协议")
public class IECF6113ProtocolService implements IProtocol {
@@ -67,7 +67,7 @@ public class IECF6113ProtocolService implements IProtocol {
* "AD2": 0.27333333333333,
* "AD5": 0.27333333333333
* }
*
* <p>
* {
* "I0.1": 0,
* "I0.3": 0,
@@ -76,18 +76,18 @@ public class IECF6113ProtocolService implements IProtocol {
* "I0.5": 0,
* "I0.2": 0
* }
*
* <p>
* {
* "lng": "104.0902886",
* "lat": "030.8176553"
* }
*
* <p>
* {
* "PAD": 3905
* }
*
*
*
* <p>
* <p>
* <p>
* 下发报文格式<p>
* device 从机编号 <p>
* name 标识符 <p>
@@ -100,7 +100,7 @@ public class IECF6113ProtocolService implements IProtocol {
* "serNo": "213245489543789"
* }
* </p>
*
* <p>
* 下发指令回复格式<p>
* serNo 平台的流水号,用于对应回复消息 <p>
* ack 下发指令状态 0是失败 1是成功 <p>
@@ -109,7 +109,7 @@ public class IECF6113ProtocolService implements IProtocol {
* "ack": 1
* }
* </p>
*
* <p>
* {"AD6":0.20666666666667,"AD15":0.22,"AD14":0.22,"AD7":0.20666666666667,"AD11":0.20666666666667,
* "AD1":18.886666666667,"AD4":0.22,"AD3":0.22,"AD10":0.22,"AD8":15.526666666667,"AD16":0.22,"AD12":0.22,
* "AD13":0.22,"AD9":0.20666666666667,"AD2":0.22,"AD5":0.22}
@@ -118,58 +118,103 @@ public class IECF6113ProtocolService implements IProtocol {
* {"lng":"104.1536100","lat":"030.8336398","PAD":4185,"CSQ":28}
*/
private static final Set<String> EXCLUDE_KEYS = new HashSet<>(Arrays.asList(
"AD1", "AD2", "AD3","AD4", "AD5", "AD6","AD7", "AD8", "AD9","AD10", "AD11", "AD12",
"AD13", "AD14", "AD15","AD16", "I0.1", "I0.2","I0.3", "I0.4", "I0.5","I0.6","lng", "lat", "PAD", "CSQ",
"K0", "K1", "温度","温度1", "标况流量", "工况流量", "压力"
"AD1", "AD2", "AD3", "AD4", "AD5", "AD6", "AD7", "AD8", "AD9", "AD10", "AD11", "AD12",
"AD13", "AD14", "AD15", "AD16", "I0.1", "I0.2", "I0.3", "I0.4", "I0.5", "I0.6", "lng", "lat", "PAD", "CSQ",
"K0", "K1", "温度", "温度1", "标况流量", "工况流量", "压力"
));
@Override
public DeviceReport decode(DeviceData deviceData, String clientId) {
try {
DeviceReport reportMessage = new DeviceReport();
String data = new String(deviceData.getData(),StandardCharsets.UTF_8);
String data = new String(deviceData.getData(), StandardCharsets.UTF_8);
List<ThingsModelSimpleItem> result = new ArrayList<>();
if(data.trim().equals("ok")||data.trim().equals("ERROR")){
if (data.trim().equals("ok") || data.trim().equals("ERROR")) {
log.info(data);
}else{
Map<String,Object> values = JSON.parseObject(data, Map.class);
} else {
Map<String, Object> values = JSON.parseObject(data, Map.class);
// if (values.containsKey("AD1") || values.containsKey("lng") || values.containsKey("I0.1")||values.containsKey("PAD")||values.containsKey("K1")){
// 初始化纬度变量使用BigDecimal来存储高精度值
BigDecimal latitude = new BigDecimal("39.9042");
// 初始化经度变量同样使用BigDecimal
BigDecimal longitude = new BigDecimal("116.4074");
String volt = "";
Integer rssi = 0;
String sd = "";
String pd = "";
String imei = "";
String iccid = "";
Device device = new Device();
for (Map.Entry<String, Object> entry : values.entrySet()) {
// if (EXCLUDE_KEYS.contains(entry.getKey())){
ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem();
simpleItem.setTs(DateUtils.getNowDate());
simpleItem.setId(entry.getKey());
simpleItem.setValue(entry.getValue()+"");
simpleItem.setValue(entry.getValue() + "");
result.add(simpleItem);
if(values.containsKey("lng")) {
if (entry.getKey().equals("lng")) {
longitude = new BigDecimal(entry.getValue() + "");
device.setLongitude(longitude);
}
if (entry.getKey().equals("lat")) {
latitude = new BigDecimal(entry.getValue() + "");
device.setLatitude(latitude);
}
if (entry.getKey().equals("PAD")) {
// volt = entry.getValue() + "";
BigDecimal num = new BigDecimal( entry.getValue() + "");
volt = num.divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP).toPlainString();
device.setVolt(volt);
}
if (entry.getKey().equals("CSQ")) {
rssi = Integer.parseInt(entry.getValue() + "");
device.setRssi(rssi);
}
if (entry.getKey().equals("SD")) {
BigDecimal num1 = new BigDecimal( entry.getValue() + "");
sd = num1.divide(new BigDecimal("1000"), 3, BigDecimal.ROUND_HALF_UP).toPlainString();
device.setSd(sd);
}
if (entry.getKey().equals("BD")) {
BigDecimal num2 = new BigDecimal( entry.getValue() + "");
pd = num2.divide(new BigDecimal("1000"), 3, BigDecimal.ROUND_HALF_UP).toPlainString();
device.setPd(pd);
}
if (entry.getKey().equals("ICCID")) {
iccid = entry.getValue() + "";
device.setIccid(iccid);
}
if (entry.getKey().equals("IMEI")) {
imei = entry.getValue() + "";
device.setImei(imei);
}
// }
}
if (values.containsKey("lng")) {
//更新设备经纬度信息
Device device = new Device();
// Device device = new Device();
device.setSerialNumber(deviceData.getSerialNumber());
device.setLongitude(longitude);
device.setLatitude(latitude);
// device.setLongitude(longitude);
// device.setLatitude(latitude);
// device.setVolt(volt);
// device.setRssi(rssi);
// device.setSd(sd);
// device.setPd(pd);
deviceService.updateDeviceStatus(device);
}
// }
}
// }
}
reportMessage.setThingsModelSimpleItem(result);
reportMessage.setClientId(clientId);
reportMessage.setSerialNumber(clientId);
return reportMessage;
}catch (Exception e){
throw new ServiceException("数据解析异常"+e.getMessage());
} catch (Exception e) {
throw new ServiceException("数据解析异常" + e.getMessage());
}
}
@@ -181,6 +226,7 @@ public class IECF6113ProtocolService implements IProtocol {
* 5.通 信 控制 GKB29810,MODBUS, {"KO":12}
* 6.开关量输出控制 GKB29810,OUT,{"Q0.1":0,"Q0.2":0,"Q0.3":0,"Q0.4":0,"Q0.5":0,"Q0.6":0}
* GKB29810,0UT,{"Q0.1":1 ,"Q0.2":1,"Q0.3":1,"Q0.4":1,"Q0.5":1 "Q0.6":1)
*
* @param message
* @return
*/
@@ -238,18 +284,18 @@ public class IECF6113ProtocolService implements IProtocol {
callBack.setMessage(msg.toString().getBytes());
}
if(params.containsKey("select")) {
if (params.containsKey("select")) {
String msg = params.get("select") + "";
callBack.setSources(msg);
callBack.setMessage(msg.getBytes());
}
if(params.containsKey("OUT")){
if (params.containsKey("OUT")) {
String msg = params.get("OUT") + "";
callBack.setSources(msg);
callBack.setMessage(msg.getBytes());
}
if(params.containsKey("TIME")){
String msg = "GKB29810,JCZ,{\"TIME\":" + params.get("TIME")+ "}";
if (params.containsKey("TIME")) {
String msg = "GKB29810,JCZ,{\"TIME\":" + params.get("TIME") + "}";
callBack.setSources(msg);
callBack.setMessage(msg.getBytes());
}

View File

@@ -7,10 +7,12 @@ import com.xinda.common.config.RuoYiConfig;
import com.xinda.common.constant.HttpStatus;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.core.domain.entity.SysUser;
import com.xinda.common.core.page.TableDataInfo;
import com.xinda.common.enums.BusinessType;
import com.xinda.common.exception.ServiceException;
import com.xinda.common.exception.file.InvalidExtensionException;
import com.xinda.common.utils.MessageUtils;
import com.xinda.common.utils.StringUtils;
import com.xinda.common.utils.file.MimeTypeUtils;
import com.xinda.common.utils.poi.ExcelUtil;
@@ -23,15 +25,13 @@ import com.xinda.iot.service.IDeviceService;
import com.xinda.scada.domain.Scada;
import com.xinda.scada.domain.ScadaDeviceBind;
import com.xinda.scada.domain.ScadaGallery;
import com.xinda.scada.enums.ScadaTypeEnum;
import com.xinda.scada.service.IScadaDeviceBindService;
import com.xinda.scada.service.IScadaService;
import com.xinda.scada.utils.ScadaCollectionUtils;
import com.xinda.scada.utils.ScadaFileUploadUtils;
import com.xinda.scada.utils.ScadaFileUtils;
import com.xinda.scada.vo.DeviceRealDataVO;
import com.xinda.scada.vo.FavoritesVO;
import com.xinda.scada.vo.ScadaDeviceBindDTO;
import com.xinda.scada.vo.ThingsModelHistoryParam;
import com.xinda.scada.vo.*;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -115,9 +115,9 @@ public class ScadaController extends BaseController
@PreAuthorize("@ss.hasPermi('scada:center:add')")
@Log(title = "组态中心", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Scada scada)
public AjaxResult add(@RequestBody ScadaVO scadaVO)
{
return scadaService.insertScada(scada);
return scadaService.insertScada(scadaVO);
}
/**
@@ -127,9 +127,9 @@ public class ScadaController extends BaseController
@PreAuthorize("@ss.hasPermi('scada:center:edit')")
@Log(title = "组态中心", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Scada scada)
public AjaxResult edit(@RequestBody ScadaVO scadaVO)
{
return toAjax(scadaService.updateScada(scada));
return toAjax(scadaService.updateScada(scadaVO));
}
/**
@@ -164,32 +164,43 @@ public class ScadaController extends BaseController
@Log(title = "组态中心", businessType = BusinessType.INSERT)
@PreAuthorize("@ss.hasPermi('scada:center:edit')")
@PostMapping("/save")
public AjaxResult save(@RequestBody Scada scada)
public AjaxResult save(@RequestBody ScadaVO scadaVO)
{
if (StringUtils.isEmpty(scada.getGuid())) {
return AjaxResult.error("guid不能为空");
if (StringUtils.isEmpty(scadaVO.getGuid())) {
return AjaxResult.error(MessageUtils.message("scada.guid.cannot.empty"));
}
if (null == scadaVO.getType()) {
scadaVO.setType(ScadaTypeEnum.PUBLIC.getType());
}
Scada scadaQuery = new Scada();
scadaQuery.setGuid(scada.getGuid());
List<Scada> scadaList = scadaService.selectScadaList(scadaQuery);
if (StringUtils.isNotEmpty(scada.getBase64())) {
MultipartFile multipartFile = ScadaFileUtils.base64toMultipartFile(scada.getBase64());
scadaQuery.setGuid(scadaVO.getGuid());
List<ScadaVO> scadaVOList = scadaService.listScadaVO(scadaQuery);
if (StringUtils.isNotEmpty(scadaVO.getBase64())) {
MultipartFile multipartFile = ScadaFileUtils.base64toMultipartFile(scadaVO.getBase64());
String url;
try {
url = ScadaFileUploadUtils.upload(RuoYiConfig.getUploadPath(), multipartFile, MimeTypeUtils.IMAGE_EXTENSION);
} catch (IOException | InvalidExtensionException e) {
throw new ServiceException("修改组态base64转图片异常" + e.getMessage());
throw new ServiceException(StringUtils.format(MessageUtils.message("scada.base64.change.image.exception"), e.getMessage()));
}
scada.setPageImage(url);
scadaVO.setPageImage(url);
}
if (CollectionUtils.isNotEmpty(scadaList)) {
Scada updateScada = scadaList.get(0);
updateScada.setScadaData(scada.getScadaData());
updateScada.setPageImage(scada.getPageImage());
scadaService.updateScada(updateScada);
if (CollectionUtils.isNotEmpty(scadaVOList)) {
ScadaVO updateScadaVO = scadaVOList.get(0);
updateScadaVO.setScadaData(scadaVO.getScadaData());
updateScadaVO.setPageImage(scadaVO.getPageImage());
scadaService.updateScada(updateScadaVO);
} else {
scadaService.insertScada(scada);
// scadaDeviceBindService.insertScadaDeviceBind()
// 多租户版本使用
SysUser user = getLoginUser().getUser();
if (null != user.getDeptId()) {
scadaVO.setTenantId(user.getDept().getDeptUserId());
scadaVO.setTenantName(user.getDept().getDeptUserName());
} else {
scadaVO.setTenantId(user.getUserId());
scadaVO.setTenantName(user.getUserName());
}
scadaService.insertScada(scadaVO);
}
return AjaxResult.success();
}
@@ -374,39 +385,7 @@ public class ScadaController extends BaseController
// @PreAuthorize("@ss.hasPermi('scada:center:add')")
@PostMapping("/importJson")
public AjaxResult importJson(MultipartFile file, String guid) throws IOException {
InputStream inputStream = file.getInputStream();
if(file.isEmpty()){
return AjaxResult.error("无效的配置文件");
}
if(file.getOriginalFilename().indexOf("json")==-1){
return AjaxResult.error("无效的配置文件");
}
Scada scada = new Scada();
try {
scada = JSON.parseObject(inputStream, Scada.class);
}catch (Exception e){
return AjaxResult.error("无效的配置文件");
}finally {
inputStream.close();
}
Scada oldScada = new Scada();
if (StringUtils.isNotEmpty(guid)) {
Scada queryScada = new Scada();
queryScada.setGuid(guid);
List<Scada> scadaList = scadaService.selectScadaList(queryScada);
if (CollectionUtils.isNotEmpty(scadaList)) {
oldScada = scadaList.get(0);
}
}
if (oldScada == null) {
guid= UUID.randomUUID().toString();
scada.setGuid(guid);
scadaService.insertScada(scada);
} else {
scada.setId(oldScada.getId());
scadaService.updateScada(scada);
}
return AjaxResult.success("导入成功");
return scadaService.importJson(file, guid);
}
/**

View File

@@ -0,0 +1,70 @@
package com.xinda.scada.convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinda.scada.domain.Scada;
import com.xinda.scada.vo.ScadaVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 组态页面Convert转换类
*
* @author zhuangpeng.li
* @date 2024-12-04
*/
@Mapper
public interface ScadaConvert
{
ScadaConvert INSTANCE = Mappers.getMapper(ScadaConvert.class);
/**
* 实体类转换为VO类
*
* @param scada
* @return 组态页面集合
*/
ScadaVO convertScadaVO(Scada scada);
/**
* VO类转换为实体类集合
*
* @param scadaVO
* @return 组态页面集合
*/
Scada convertScada(ScadaVO scadaVO);
/**
* 实体类转换为VO类集合
*
* @param scadaList
* @return 组态页面集合
*/
List<ScadaVO> convertScadaVOList(List<Scada> scadaList);
/**
* VO类转换为实体类
*
* @param scadaVOList
* @return 组态页面集合
*/
List<Scada> convertScadaList(List<ScadaVO> scadaVOList);
/**
* 实体类转换为VO类分页
*
* @param scadaPage
* @return 组态页面分页
*/
Page<ScadaVO> convertScadaVOPage(Page<Scada> scadaPage);
/**
* VO类转换为实体类
*
* @param scadaVOPage
* @return 组态页面分页
*/
Page<Scada> convertScadaPage(Page<ScadaVO> scadaVOPage);
}

View File

@@ -4,6 +4,7 @@ import com.xinda.common.annotation.Excel;
import com.xinda.common.core.domain.BaseEntity;
import com.xinda.scada.vo.ScadaBindDeviceSimVO;
import com.xinda.scada.vo.ScadaDeviceBindVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@@ -70,6 +71,8 @@ public class Scada extends BaseEntity
@Excel(name = "页面图片")
private String pageImage;
private Long deptId;
/** 租户id */
@Excel(name = "租户id")
private Long tenantId;
@@ -83,6 +86,10 @@ public class Scada extends BaseEntity
private String base64;
/** 组态类型 1- 模板组态 2- 场景组态 3-公共组态 */
@ApiModelProperty("组态类型 1- 模板组态 2- 场景组态 3-公共组态")
private Integer type;
private List<ScadaBindDeviceSimVO> bindDeviceList;
}

View File

@@ -0,0 +1,38 @@
package com.xinda.scada.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
/**
* 组态类型枚举
* @author fastb
* @date 2024-05-22 10:01
* @version 1.0
*/
@Getter
@AllArgsConstructor
public enum ScadaTypeEnum {
PRODUCT_TEMPLATE(1, "模版组态"),
SCENE_MODEL(2, "场景组态"),
PUBLIC(3, "公共组态");
private final Integer type;
private final String name;
public static ScadaTypeEnum getByType(Integer type) {
for (ScadaTypeEnum scadaTypeEnum : ScadaTypeEnum.values()) {
if (scadaTypeEnum.getType().equals(type)) {
return scadaTypeEnum;
}
}
return null;
}
}

View File

@@ -69,4 +69,6 @@ public interface ScadaDeviceBindMapper
* @return java.util.List<com.xinda.scada.vo.ScadaBindDeviceSimVO>
*/
List<ScadaBindDeviceSimVO> listDeviceSimByGuid(String guid);
List<ScadaDeviceBind> selectScadaDeviceBindListByIds(List<String> guidList);
}

View File

@@ -59,6 +59,7 @@ public interface ScadaMapper
*/
public int deleteScadaById(Long id);
public int deleteScadaByGuid(String guid);
/**
* 批量删除组态中心
*
@@ -96,4 +97,20 @@ public interface ScadaMapper
* @return java.util.List<com.xinda.scada.vo.ScadaHistoryModelVO>
*/
List<ScadaHistoryModelVO> listEventLogHistory(EventLog eventLog);
String selectGuidBySceneModelId(Long sceneModelId);
String selectGuidByProductId(Long productId);
void updateProductGuid(@Param("productId") Long productId, @Param("guid") String guid);
void updateSceneModelGuid( @Param("sceneModelId") Long sceneModelId, @Param("guid") String guid);
void deleteProductByGuids(List<String> guids);
void deleteSceneModelByGuids(List<String> guids);
Long selectProductByGuid(String guid);
Long selectSceneModelByGuid(String guid);
}

View File

@@ -3,19 +3,17 @@ package com.xinda.scada.service;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.scada.domain.Scada;
import com.xinda.scada.domain.ScadaGallery;
import com.xinda.scada.vo.FavoritesVO;
import com.xinda.scada.vo.ScadaHistoryModelVO;
import com.xinda.scada.vo.ScadaStatisticVO;
import com.xinda.scada.vo.ThingsModelHistoryParam;
import com.xinda.scada.vo.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* 组态中心Service接口
*
* @author kerwincui
* @author kerwincuiIScadaService
* @date 2023-11-10
*/
public interface IScadaService
@@ -26,7 +24,7 @@ public interface IScadaService
* @param id 组态中心主键
* @return 组态中心
*/
public Scada selectScadaById(Long id);
public ScadaVO selectScadaById(Long id);
/**
* 查询组态中心列表
@@ -39,18 +37,20 @@ public interface IScadaService
/**
* 新增组态中心
*
* @param scada 组态中心
* @param scadaVO 组态中心
* @return 结果
*/
public AjaxResult insertScada(ScadaVO scadaVO);
public AjaxResult insertScada(Scada scada);
/**
* 修改组态中心
*
* @param scada 组态中心
* @param scadaVO 组态中心
* @return 结果
*/
public int updateScada(Scada scada);
public int updateScada(ScadaVO scadaVO);
/**
* 批量删除组态中心
@@ -68,6 +68,8 @@ public interface IScadaService
*/
public int deleteScadaById(Long id);
public int deleteScadaByGuid(String guid);
/**
* 根据guid获取组态详情
* @param guid 组态id
@@ -120,4 +122,8 @@ public interface IScadaService
* @return com.xinda.common.core.domain.AjaxResult
*/
ScadaStatisticVO selectStatistic();
List<ScadaVO> listScadaVO(Scada scadaQuery);
AjaxResult importJson(MultipartFile file, String guid) throws IOException;
}

View File

@@ -1,12 +1,17 @@
package com.xinda.scada.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xinda.common.config.RuoYiConfig;
import com.xinda.common.constant.HttpStatus;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.core.domain.entity.SysRole;
import com.xinda.common.core.domain.entity.SysUser;
import com.xinda.common.core.domain.model.LoginUser;
import com.xinda.common.core.redis.RedisCache;
import com.xinda.common.exception.ServiceException;
import com.xinda.common.utils.DateUtils;
import com.xinda.common.utils.MessageUtils;
import com.xinda.common.utils.StringUtils;
import com.xinda.common.utils.bean.BeanUtils;
import com.xinda.common.utils.file.FileUploadUtils;
@@ -15,8 +20,11 @@ import com.xinda.iot.domain.EventLog;
import com.xinda.iot.domain.FunctionLog;
import com.xinda.iot.model.HistoryModel;
import com.xinda.iot.service.IDeviceLogService;
import com.xinda.scada.convert.ScadaConvert;
import com.xinda.scada.domain.Scada;
import com.xinda.scada.domain.ScadaDeviceBind;
import com.xinda.scada.domain.ScadaGallery;
import com.xinda.scada.enums.ScadaTypeEnum;
import com.xinda.scada.mapper.ScadaDeviceBindMapper;
import com.xinda.scada.mapper.ScadaGalleryMapper;
import com.xinda.scada.mapper.ScadaMapper;
@@ -27,6 +35,8 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
@@ -59,9 +69,21 @@ public class ScadaServiceImpl implements IScadaService
* @return 组态中心
*/
@Override
public Scada selectScadaById(Long id)
public ScadaVO selectScadaById(Long id)
{
return scadaMapper.selectScadaById(id);
Scada scada = scadaMapper.selectScadaById(id);
if (Objects.isNull(scada)) {
return null;
}
ScadaVO scadaVO = ScadaConvert.INSTANCE.convertScadaVO(scada);
if (ScadaTypeEnum.PRODUCT_TEMPLATE.getType().equals(scada.getType())) {
Long productId = scadaMapper.selectProductByGuid(scada.getGuid());
scadaVO.setProductId(productId);
} else if (ScadaTypeEnum.SCENE_MODEL.getType().equals(scada.getType())) {
Long sceneModelId = scadaMapper.selectSceneModelByGuid(scada.getGuid());
scadaVO.setSceneModelId(sceneModelId);
}
return scadaVO;
}
/**
@@ -79,32 +101,126 @@ public class ScadaServiceImpl implements IScadaService
/**
* 新增组态中心
*
* @param scada 组态中心
* @param scadaVO 组态中心
* @return 结果
*/
@Override
public AjaxResult insertScada(Scada scada)
public AjaxResult insertScada(ScadaVO scadaVO)
{
// scadaVO.setPageName("综合测试GKB-29813组态");
// scadaVO.setProductId(219L);
// scadaVO.setType(1);
LoginUser loginUser = getLoginUser();
if (loginUser == null) {
return AjaxResult.error("请登录后重试!");
return AjaxResult.error(MessageUtils.message("scada.please.login"));
}
if (ScadaTypeEnum.PRODUCT_TEMPLATE.getType().equals(scadaVO.getType())) {
String guid = scadaMapper.selectGuidByProductId(scadaVO.getProductId());
if (StringUtils.isNotEmpty(guid)){
return AjaxResult.warn(MessageUtils.message("scada.product.has.relate.please.select.again"));
}
}
if (ScadaTypeEnum.SCENE_MODEL.getType().equals(scadaVO.getType())) {
String guid = scadaMapper.selectGuidBySceneModelId(scadaVO.getSceneModelId());
if (StringUtils.isNotEmpty(guid)){
return AjaxResult.warn(MessageUtils.message("scada.scene.has.relate.please.select.again"));
}
}
// 多租户版本使用
SysUser user = getLoginUser().getUser();
if (null != user.getDeptId()) {
scadaVO.setTenantId(user.getDept().getDeptUserId());
scadaVO.setTenantName(user.getDept().getDeptUserName());
} else {
scadaVO.setTenantId(user.getUserId());
scadaVO.setTenantName(user.getUserName());
}
scadaVO.setCreateBy(loginUser.getUserId().toString());
UUID uuid = UUID.randomUUID();
scadaVO.setGuid(uuid.toString());
Scada scada = ScadaConvert.INSTANCE.convertScada(scadaVO);
int result = scadaMapper.insertScada(scada);
if (result >0){
if (ScadaTypeEnum.PRODUCT_TEMPLATE.getType().equals(scadaVO.getType())) {
scadaMapper.updateProductGuid(scadaVO.getProductId(), uuid.toString());
}
if (ScadaTypeEnum.SCENE_MODEL.getType().equals(scadaVO.getType())) {
scadaMapper.updateSceneModelGuid(scadaVO.getSceneModelId(), uuid.toString());
}
return AjaxResult.success(uuid.toString());
}else {
return AjaxResult.error();
}
}
@Override
public AjaxResult insertScada(Scada scada){
LoginUser loginUser = getLoginUser();
if (loginUser == null) {
return AjaxResult.error(MessageUtils.message("scada.please.login"));
}
// 多租户版本使用
SysUser user = getLoginUser().getUser();
if (null != user.getDeptId()) {
scada.setTenantId(user.getDept().getDeptUserId());
scada.setTenantName(user.getDept().getDeptUserName());
} else {
scada.setTenantId(user.getUserId());
scada.setTenantName(user.getUserName());
}
scada.setCreateBy(loginUser.getUserId().toString());
UUID uuid = UUID.randomUUID();
scada.setGuid(uuid.toString());
return scadaMapper.insertScada(scada) > 0 ? AjaxResult.success() : AjaxResult.error();
int result = scadaMapper.insertScada(scada);
if (result >0){
return AjaxResult.success(scada.getGuid());
}else {
return AjaxResult.error();
}
}
/**
* 查询组态页面列表
*
* @param scada 组态页面
* @return 组态页面
*/
@Override
public List<ScadaVO> listScadaVO(Scada scada) {
List<Scada> scadaList = scadaMapper.selectScadaList(scada);
return ScadaConvert.INSTANCE.convertScadaVOList(scadaList);
}
/**
* 修改组态中心
*
* @param scada 组态中心
* @param scadaVO 组态中心
* @return 结果
*/
@Override
public int updateScada(Scada scada)
public int updateScada(ScadaVO scadaVO)
{
scada.setUpdateTime(DateUtils.getNowDate());
if (ScadaTypeEnum.PRODUCT_TEMPLATE.getType().equals(scadaVO.getType()) && null != scadaVO.getProductId()) {
String guid = scadaMapper.selectGuidByProductId(scadaVO.getProductId());
if (StringUtils.isNotEmpty(guid) && !guid.equals(scadaVO.getGuid())){
throw new ServiceException(MessageUtils.message("scada.product.has.relate.please.select.again"), HttpStatus.WARN);
}
if (StringUtils.isEmpty(guid)) {
scadaMapper.deleteProductByGuids(Collections.singletonList(scadaVO.getGuid()));
scadaMapper.updateProductGuid(scadaVO.getProductId(), scadaVO.getGuid());
}
}
if (ScadaTypeEnum.SCENE_MODEL.getType().equals(scadaVO.getType()) && null != scadaVO.getSceneModelId()) {
String guid = scadaMapper.selectGuidBySceneModelId(scadaVO.getSceneModelId());
if (StringUtils.isNotEmpty(guid) && !guid.equals(scadaVO.getGuid())){
throw new ServiceException(MessageUtils.message("scada.scene.has.relate.please.select.again"), HttpStatus.WARN);
}
if (StringUtils.isEmpty(guid)) {
scadaMapper.deleteSceneModelByGuids(Collections.singletonList(scadaVO.getGuid()));
scadaMapper.updateSceneModelGuid(scadaVO.getSceneModelId(), scadaVO.getGuid());
}
}
Scada scada = ScadaConvert.INSTANCE.convertScada(scadaVO);
return scadaMapper.updateScada(scada);
}
@@ -132,6 +248,11 @@ public class ScadaServiceImpl implements IScadaService
return scadaMapper.deleteScadaById(id);
}
@Override
public int deleteScadaByGuid(String guid) {
return scadaMapper.deleteScadaByGuid(guid);
}
/**
* 根据guid获取组态详情
* @param guid 组态id
@@ -301,4 +422,60 @@ public class ScadaServiceImpl implements IScadaService
}
return statistic;
}
@Override
public AjaxResult importJson(MultipartFile file, String guid) throws IOException {
InputStream inputStream = file.getInputStream();
if(file.isEmpty()){
return AjaxResult.error(MessageUtils.message("scada.invalid.profile"));
}
if(file.getOriginalFilename().indexOf("json")==-1){
return AjaxResult.error(MessageUtils.message("scada.invalid.profile"));
}
Scada scada = new Scada();
try {
scada = JSON.parseObject(inputStream, Scada.class);
}catch (Exception e){
return AjaxResult.error(MessageUtils.message("scada.invalid.profile"));
}finally {
inputStream.close();
}
Scada oldScada = new Scada();
if (StringUtils.isNotEmpty(guid)) {
Scada queryScada = new Scada();
queryScada.setGuid(guid);
List<Scada> scadaList = scadaMapper.selectScadaList(queryScada);
if (CollectionUtils.isNotEmpty(scadaList)) {
oldScada = scadaList.get(0);
}
}
String importGuid = scada.getGuid();
Long tenantId = scada.getTenantId();
oldScada.setScadaData(scada.getScadaData());
int i = scadaMapper.updateScada(oldScada);
if (i <= 0) {
return AjaxResult.error(MessageUtils.message("import.fail"));
}
if (!tenantId.equals(oldScada.getTenantId())) {
return AjaxResult.success(MessageUtils.message("scada.import.success.need.replace.variable"));
}
if (StringUtils.isNotEmpty(importGuid) && ScadaTypeEnum.PUBLIC.getType().equals(oldScada.getType())
&& ScadaTypeEnum.PUBLIC.getType().equals(scada.getType())) {
List<String> guidList = Arrays.asList(guid, importGuid);
List<ScadaDeviceBind> scadaDeviceBinds = scadaDeviceBindMapper.selectScadaDeviceBindListByIds(guidList);
if (CollectionUtils.isNotEmpty(scadaDeviceBinds)) {
List<String> serialNumbers = scadaDeviceBinds.stream().filter(d -> guid.equals(d.getScadaGuid())).map(ScadaDeviceBind::getSerialNumber).collect(Collectors.toCollection(ArrayList::new));
List<String> importSerialNumbers = scadaDeviceBinds.stream().filter(d -> importGuid.equals(d.getScadaGuid())).map(ScadaDeviceBind::getSerialNumber).collect(Collectors.toCollection(ArrayList::new));
importSerialNumbers.removeAll(serialNumbers);
for (String importSerialNumber : importSerialNumbers) {
ScadaDeviceBind scadaDeviceBind = new ScadaDeviceBind();
scadaDeviceBind.setScadaGuid(guid);
scadaDeviceBind.setSerialNumber(importSerialNumber);
scadaDeviceBindMapper.insertScadaDeviceBind(scadaDeviceBind);
}
}
return AjaxResult.success(MessageUtils.message("import.success"));
}
return AjaxResult.success(MessageUtils.message("scada.import.success.need.replace.variable"));
}
}

View File

@@ -0,0 +1,162 @@
package com.xinda.scada.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.xinda.common.annotation.Excel;
import com.xinda.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import java.io.Serializable;
import java.util.*;
/**
* 组态页面对象 scada
*
* @author zhuangpeng.li
* @date 2024-12-04
*/
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "ScadaVO", description = "组态页面 scada")
@Data
public class ScadaVO extends BaseEntity {
/** id唯一标识 */
@Excel(name = "id唯一标识")
@ApiModelProperty("id唯一标识")
private Long id;
/** 组态id */
@Excel(name = "组态id")
@ApiModelProperty("组态id")
private String guid;
/** 组态信息 */
@Excel(name = "组态信息")
@ApiModelProperty("组态信息")
private String scadaData;
/** 设备编号 */
@Excel(name = "设备编号")
@ApiModelProperty("设备编号")
private String serialNumbers;
/** 设备名称 */
@Excel(name = "设备名称")
@ApiModelProperty("设备名称")
private String deviceName;
/** 是否主界面 */
@Excel(name = "是否主界面")
@ApiModelProperty("是否主界面")
private Integer isMainPage;
/** 页面名称 */
@Excel(name = "页面名称")
@ApiModelProperty("页面名称")
private String pageName;
/** 页面大小 */
@Excel(name = "页面大小")
@ApiModelProperty("页面大小")
private String pageResolution;
/** 是否分享 */
@Excel(name = "是否分享")
@ApiModelProperty("是否分享")
private Integer isShare;
/** 分享链接 */
@Excel(name = "分享链接")
@ApiModelProperty("分享链接")
private String shareUrl;
/** 分享密码 */
@Excel(name = "分享密码")
@ApiModelProperty("分享密码")
private String sharePass;
/** 页面图片 */
@Excel(name = "页面图片")
@ApiModelProperty("页面图片")
private String pageImage;
/** 租户id */
@Excel(name = "租户id")
@ApiModelProperty("租户id")
private Long tenantId;
/** 租户名称 */
@Excel(name = "租户名称")
@ApiModelProperty("租户名称")
private String tenantName;
/** 创建人 */
@Excel(name = "创建人")
@ApiModelProperty("创建人")
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("创建时间")
@Excel(name = "创建时间")
private Date createTime;
/** 更新人 */
@Excel(name = "更新人")
@ApiModelProperty("更新人")
private String updateBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("更新时间")
@Excel(name = "更新时间")
private Date updateTime;
/** 逻辑删除标识 */
@Excel(name = "逻辑删除标识")
@ApiModelProperty("逻辑删除标识")
private Integer delFlag;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty("备注")
private String remark;
/** 组态类型 1- 模板组态 2- 场景组态 3-公共组态 */
@Excel(name = "组态类型 1- 模板组态 2- 场景组态 3-公共组态")
@ApiModelProperty("组态类型 1- 模板组态 2- 场景组态 3-公共组态")
private Integer type;
/** 分享短链接 */
@Excel(name = "分享短链接")
@ApiModelProperty("分享短链接")
private String shareShortUrl;
/**
* 绑定的产品id
*/
private Long productId;
/**
* 场景id
*/
private Long sceneModelId;
private List<ScadaBindDeviceSimVO> bindDeviceList = new ArrayList<>();
private String base64;
/**
* 设备编号
*/
private String serialNumber;
}

View File

@@ -22,6 +22,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectScadaDeviceBindListByIds" parameterType="String" resultMap="ScadaDeviceBindResult">
<include refid="selectScadaDeviceBindVo"/>
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="selectScadaDeviceBindById" parameterType="Long" resultMap="ScadaDeviceBindResult">
<include refid="selectScadaDeviceBindVo"/>
where id = #{id}
@@ -54,6 +62,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<select id="selectProductByGuid" resultType="java.lang.Long">
select product_id
from iot_product
where guid = #{guid}
and del_flag = '0'
</select>
<select id="selectSceneModelByGuid" resultType="java.lang.Long">
select scene_model_id
from scene_model
where guid = #{guid}
and del_flag = 0
</select>
<update id="updateScadaDeviceBind" parameterType="ScadaDeviceBind">
update scada_device_bind
<trim prefix="SET" suffixOverrides=",">

View File

@@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="shareUrl" column="share_url" />
<result property="sharePass" column="share_pass" />
<result property="pageImage" column="page_image" />
<result property="deptId" column="dept_id" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
<result property="createBy" column="create_by" />
@@ -24,28 +25,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="delFlag" column="del_flag" />
<result property="type" column="type"/>
</resultMap>
<sql id="selectScadaVo">
select id, guid, scada_data, serial_numbers, device_name, is_main_page, page_name, page_resolution, is_share, share_url, share_pass, page_image, tenant_id, tenant_name, create_by, create_time, update_by, update_time, del_flag from scada
select id, guid, scada_data, serial_numbers, device_name, is_main_page, page_name, page_resolution, is_share, share_url, share_pass, page_image, dept_id,tenant_id, tenant_name, create_by, create_time, update_by, update_time, del_flag, type from scada
</sql>
<select id="selectScadaList" parameterType="Scada" resultMap="ScadaResult">
<include refid="selectScadaVo"/>
select s.id, s.guid, s.scada_data, s.serial_numbers, s.device_name, s.is_main_page, s.page_name, s.page_resolution, s.is_share, s.share_url, s.share_pass, s.page_image, s.dept_id, s.tenant_id, s.tenant_name, s.create_by, s.create_time, s.update_by, s.update_time, s.del_flag, s.type
from scada s
<where>
<if test="guid != null and guid != ''"> and guid = #{guid}</if>
<if test="scadaData != null and scadaData != ''"> and scada_data = #{scadaData}</if>
<if test="serialNumbers != null and serialNumbers != ''"> and serial_numbers = #{serialNumbers}</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="isMainPage != null "> and is_main_page = #{isMainPage}</if>
<if test="pageName != null and pageName != ''"> and page_name like concat('%', #{pageName}, '%')</if>
<if test="pageResolution != null and pageResolution != ''"> and page_resolution = #{pageResolution}</if>
<if test="isShare != null "> and is_share = #{isShare}</if>
<if test="shareUrl != null and shareUrl != ''"> and share_url = #{shareUrl}</if>
<if test="sharePass != null and sharePass != ''"> and share_pass = #{sharePass}</if>
<if test="pageImage != null and pageImage != ''"> and page_image = #{pageImage}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="guid != null and guid != ''"> and s.guid = #{guid}</if>
<if test="scadaData != null and scadaData != ''"> and s.scada_data = #{scadaData}</if>
<if test="serialNumbers != null and serialNumbers != ''"> and s.serial_numbers = #{serialNumbers}</if>
<if test="deviceName != null and deviceName != ''"> and s.device_name like concat('%', #{deviceName}, '%')</if>
<if test="isMainPage != null "> and s.is_main_page = #{isMainPage}</if>
<if test="pageName != null and pageName != ''"> and s.page_name like concat('%', #{pageName}, '%')</if>
<if test="pageResolution != null and pageResolution != ''"> and s.page_resolution = #{pageResolution}</if>
<if test="isShare != null "> and s.is_share = #{isShare}</if>
<if test="shareUrl != null and shareUrl != ''"> and s.share_url = #{shareUrl}</if>
<if test="sharePass != null and sharePass != ''"> and s.share_pass = #{sharePass}</if>
<if test="pageImage != null and pageImage != ''"> and s.page_image = #{pageImage}</if>
<if test="deptId != null ">
and ( s.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="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>-->
<if test="type != null">and s.type = #{type}</if>
</where>
</select>
@@ -74,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="userId != null and userId != 0"> and u.user_id = #{userId}</if>
<if test="tenantId != null and tenantId != 0"> and d.tenant_id = #{tenantId}</if>
</where>
) as deviceCount,
@@ -216,6 +225,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="shareUrl != null">share_url,</if>
<if test="sharePass != null">share_pass,</if>
<if test="pageImage != null">page_image,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null">tenant_name,</if>
<if test="createBy != null">create_by,</if>
@@ -224,6 +234,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
<if test="delFlag != null">del_flag,</if>
<if test="remark != null">remark,</if>
<if test="type != null">type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="guid != null">#{guid},</if>
@@ -237,6 +248,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="shareUrl != null">#{shareUrl},</if>
<if test="sharePass != null">#{sharePass},</if>
<if test="pageImage != null">#{pageImage},</if>
<if test="deptId != null">#{deptId},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null">#{tenantName},</if>
<if test="createBy != null">#{createBy},</if>
@@ -245,6 +257,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
@@ -262,6 +275,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="shareUrl != null">share_url = #{shareUrl},</if>
<if test="sharePass != null">share_pass = #{sharePass},</if>
<if test="pageImage != null">page_image = #{pageImage},</if>
<if test="deptId != null ">dept_id = #{deptId},</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>
@@ -270,6 +284,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="type != null">type = #{type},</if>
</trim>
where id = #{id}
</update>
@@ -278,10 +293,79 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from scada where id = #{id}
</delete>
<delete id="deleteScadaByGuid" parameterType="String">
delete from scada where guid = #{guid}
</delete>
<delete id="deleteScadaByIds" parameterType="String">
delete from scada where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectUserIdByDeptId" resultType="java.lang.Long">
select user_id
from sys_user
where dept_id = #{deptId}
and status = 0
and del_flag = 0
</select>
<select id="selectGuidByProductId" resultType="java.lang.String">
select p.guid from iot_product p
where p.product_id = #{productId}
and p.del_flag = '0'
</select>
<select id="selectGuidBySceneModelId" resultType="java.lang.String">
select guid
from scene_model
where scene_model_id = #{sceneModelId}
and del_flag = 0
</select>
<select id="selectProductByGuid" resultType="java.lang.Long">
select product_id
from iot_product
where guid = #{guid}
and del_flag = '0'
</select>
<select id="selectSceneModelByGuid" resultType="java.lang.Long">
select scene_model_id
from scene_model
where guid = #{guid}
and del_flag = 0
</select>
<update id="updateProductGuid">
update iot_product
set guid = #{guid}
where product_id = #{productId}
</update>
<update id="updateSceneModelGuid">
update scene_model
set guid = #{guid}
where scene_model_id = #{sceneModelId}
</update>
<update id="deleteSceneModelByGuids">
update scene_model
set guid = null
where guid in
<foreach collection="guids" item="guid" open="(" separator="," close=")">
#{guid}
</foreach>
</update>
<update id="deleteProductByGuids">
update iot_product
set guid = null
where guid in
<foreach collection="guids" item="guid" open="(" separator="," close=")">
#{guid}
</foreach>
</update>
</mapper>

View File

@@ -136,6 +136,7 @@ public class MqttPublish implements MqttHandler {
reportBo.setReportType(1);
}
// 规则引擎脚本处理,完成后返回结果
// MsgContext context = ruleProcess.processRuleScript(topicsUtils.parseSerialNumber(topicName), 1, topicName, new String(source));
MsgContext context;
if (topicName.startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())) {
context = ruleProcess.processNoRuleScript(topicsUtils.parseNewSerialNumber(topicName), 1, topicName, new String(source));

View File

@@ -136,6 +136,7 @@ public class MqttMessagePublishImpl implements IMqttMessagePublish {
switch (serverType) {
case MQTT:
// 规则引擎脚本处理,完成后返回结果
// MsgContext context = ruleProcess.processRuleScript(serialNumber, 2, backBo.getTopicName(), new String(backBo.getMessage()));
MsgContext context;
if (backBo.getTopicName().startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())) {
context = ruleProcess.processNoRuleScript(serialNumber, 2, backBo.getTopicName(), new String(backBo.getMessage()));

View File

@@ -1,5 +1,6 @@
package com.xinda.sip.service.impl;
import com.xinda.common.core.domain.entity.SysRole;
import com.xinda.common.core.domain.entity.SysUser;
import com.xinda.common.core.redis.RedisCache;
import com.xinda.common.core.redis.RedisKeyBuilder;
@@ -109,7 +110,7 @@ public class SipDeviceChannelServiceImpl implements ISipDeviceChannelService {
public List<SipDeviceChannel> selectSipDeviceChannelList(SipDeviceChannel sipDeviceChannel) {
SysUser user = getLoginUser().getUser();
// List<SysRole> roles=user.getRoles();
// 租户
//// 租户
// if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
// sipDeviceChannel.setTenantId(user.getUserId());
// }
@@ -183,9 +184,10 @@ public class SipDeviceChannelServiceImpl implements ISipDeviceChannelService {
@Override
public int insertSipDeviceChannel(SipDeviceChannel sipDeviceChannel) {
SysUser sysUser = getLoginUser().getUser();
Product product = productService.getProductBySerialNumber(sipDeviceChannel.getDeviceSipId());
if (product != null) {
sipDeviceChannel.setTenantId(product.getTenantId());
sipDeviceChannel.setTenantId(sysUser.getDept().getDeptUserId());
sipDeviceChannel.setTenantName(product.getTenantName());
sipDeviceChannel.setProductId(product.getProductId());
sipDeviceChannel.setProductName(product.getProductName());

View File

@@ -136,7 +136,7 @@
from sip_device_channel s
left join iot_sip_relation d on s.channel_sip_id = d.channel_id
<where>
<if test="tenantId != null ">and s.tenant_id = #{tenantId}</if>
<if test="tenantId != null and tenantId !=1 ">and s.tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''">and s.tenant_name like concat('%', #{tenantName}, '%')</if>
<if test="productId != null ">and s.product_id = #{productId}</if>
<if test="productName != null and productName != ''">and s.product_name like concat('%', #{productName},'%')</if>

View File

@@ -161,7 +161,6 @@
<artifactId>commons-jexl3</artifactId>
<version>3.2.1</version>
</dependency>
</dependencies>
</project>

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,11 +57,18 @@ public class AlertLogServiceImpl implements IAlertLogService {
// }
// }
// 查询所属机构
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);
}
@@ -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);
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

View File

@@ -22,10 +22,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="deptType" column="dept_type" />
<result property="url" column="url" />
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.dept_user_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.dept_type
select d.dept_id, d.dept_user_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.dept_type, d.url
from sys_dept d
</sql>
@@ -61,7 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.dept_type, d.dept_user_id,
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.dept_type, d.url, d.dept_user_id,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
from sys_dept d
where d.dept_id = #{deptId}
@@ -135,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="deptType != null and deptType != ''">dept_type,</if>
<if test="url != null and url != ''">url,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -149,6 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="deptType != null and deptType != ''">#{deptType},</if>
<if test="url != null and url != ''">#{url},</if>
sysdate()
)
</insert>
@@ -165,6 +168,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="url != null and url != ''">url = #{url},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>