From db2ccfedfa17eb3cb5ca73ac3b6bc4b5a05d4148 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 19 四月 2023 11:09:26 +0800 Subject: [PATCH] 优化notify性能,增加notify超出处理能力时直接回复错误码,不做处理。 --- src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 2 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java | 264 +++++++++++++++++++++++++++++ src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java | 31 +++ src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java | 41 ++++ src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java | 10 + src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java | 27 ++ src/main/resources/all-application.yml | 2 doc/_content/ability/_media/img_16.png | 0 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java | 114 ++++++++--- 9 files changed, 451 insertions(+), 40 deletions(-) diff --git a/doc/_content/ability/_media/img_16.png b/doc/_content/ability/_media/img_16.png index f7ce9e7..b09e8cd 100644 --- a/doc/_content/ability/_media/img_16.png +++ b/doc/_content/ability/_media/img_16.png Binary files differ diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index d181a4a..31fe7a4 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -62,6 +62,8 @@ private List<String> allowedOrigins = new ArrayList<>(); + private int maxNotifyCountQueue = 10000; + public Boolean getSavePositionHistory() { return savePositionHistory; } @@ -257,4 +259,12 @@ public void setRecordPath(String recordPath) { this.recordPath = recordPath; } + + public int getMaxNotifyCountQueue() { + return maxNotifyCountQueue; + } + + public void setMaxNotifyCountQueue(int maxNotifyCountQueue) { + this.maxNotifyCountQueue = maxNotifyCountQueue; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java new file mode 100644 index 0000000..56fa187 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java @@ -0,0 +1,264 @@ +package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; + +import com.genersoft.iot.vmp.conf.DynamicTask; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; +import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; +import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; +import com.genersoft.iot.vmp.gb28181.utils.SipUtils; +import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; +import com.genersoft.iot.vmp.service.IDeviceChannelService; +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.sip.RequestEvent; +import javax.sip.header.FromHeader; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; + +/** + * SIP鍛戒护绫诲瀷锛� NOTIFY璇锋眰涓殑鐩綍璇锋眰澶勭悊 + */ +@Component +public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent { + + + private final static Logger logger = LoggerFactory.getLogger(NotifyRequestForCatalogProcessor.class); + + private final List<DeviceChannel> updateChannelOnlineList = new CopyOnWriteArrayList<>(); + private final List<DeviceChannel> updateChannelOfflineList = new CopyOnWriteArrayList<>(); + private final Map<String, DeviceChannel> updateChannelMap = new ConcurrentHashMap<>(); + + private final Map<String, DeviceChannel> addChannelMap = new ConcurrentHashMap<>(); + private final List<DeviceChannel> deleteChannelList = new CopyOnWriteArrayList<>(); + + + @Autowired + private UserSetting userSetting; + + @Autowired + private EventPublisher eventPublisher; + + @Autowired + private IRedisCatchStorage redisCatchStorage; + + @Autowired + private IDeviceChannelService deviceChannelService; + + @Autowired + private DynamicTask dynamicTask; + + private final static String talkKey = "notify-request-for-catalog-task"; + + public void process(RequestEvent evt) { + try { + long start = System.currentTimeMillis(); + FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); + String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader); + + Device device = redisCatchStorage.getDevice(deviceId); + if (device == null || device.getOnline() == 0) { + logger.warn("[鏀跺埌鐩綍璁㈤槄]锛歿}, 浣嗘槸璁惧宸茬粡绂荤嚎", (device != null ? device.getDeviceId():"" )); + return; + } + Element rootElement = getRootElement(evt, device.getCharset()); + if (rootElement == null) { + logger.warn("[ 鏀跺埌鐩綍璁㈤槄 ] content cannot be null, {}", evt.getRequest()); + return; + } + Element deviceListElement = rootElement.element("DeviceList"); + if (deviceListElement == null) { + return; + } + Iterator<Element> deviceListIterator = deviceListElement.elementIterator(); + if (deviceListIterator != null) { + + // 閬嶅巻DeviceList + while (deviceListIterator.hasNext()) { + Element itemDevice = deviceListIterator.next(); + Element channelDeviceElement = itemDevice.element("DeviceID"); + if (channelDeviceElement == null) { + continue; + } + Element eventElement = itemDevice.element("Event"); + String event; + if (eventElement == null) { + logger.warn("[鏀跺埌鐩綍璁㈤槄]锛歿}, 浣嗘槸Event涓虹┖, 璁句负榛樿鍊� ADD", (device != null ? device.getDeviceId():"" )); + event = CatalogEvent.ADD; + }else { + event = eventElement.getText().toUpperCase(); + } + DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event); + + channel.setDeviceId(device.getDeviceId()); + logger.info("[鏀跺埌鐩綍璁㈤槄]锛歿}/{}", device.getDeviceId(), channel.getChannelId()); + switch (event) { + case CatalogEvent.ON: + // 涓婄嚎 + logger.info("[鏀跺埌閫氶亾涓婄嚎閫氱煡] 鏉ヨ嚜璁惧: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + updateChannelOnlineList.add(channel); + if (updateChannelOnlineList.size() > 300) { + executeSaveForOnline(); + } + break; + case CatalogEvent.OFF : + // 绂荤嚎 + logger.info("[鏀跺埌閫氶亾绂荤嚎閫氱煡] 鏉ヨ嚜璁惧: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + if (userSetting.getRefuseChannelStatusChannelFormNotify()) { + updateChannelOfflineList.add(channel); + if (updateChannelOfflineList.size() > 300) { + executeSaveForOffline(); + } + }else { + logger.info("[鏀跺埌閫氶亾绂荤嚎閫氱煡] 浣嗘槸骞冲彴宸查厤缃嫆缁濇娑堟伅锛屾潵鑷澶�: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + } + break; + case CatalogEvent.VLOST: + // 瑙嗛涓㈠け + logger.info("[鏀跺埌閫氶亾瑙嗛涓㈠け閫氱煡] 鏉ヨ嚜璁惧: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + if (userSetting.getRefuseChannelStatusChannelFormNotify()) { + updateChannelOfflineList.add(channel); + if (updateChannelOfflineList.size() > 300) { + executeSaveForOffline(); + } + }else { + logger.info("[鏀跺埌閫氶亾瑙嗛涓㈠け閫氱煡] 浣嗘槸骞冲彴宸查厤缃嫆缁濇娑堟伅锛屾潵鑷澶�: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + } + break; + case CatalogEvent.DEFECT: + // 鏁呴殰 + logger.info("[鏀跺埌閫氶亾瑙嗛鏁呴殰閫氱煡] 鏉ヨ嚜璁惧: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + if (userSetting.getRefuseChannelStatusChannelFormNotify()) { + updateChannelOfflineList.add(channel); + if (updateChannelOfflineList.size() > 300) { + executeSaveForOffline(); + } + }else { + logger.info("[鏀跺埌閫氶亾瑙嗛鏁呴殰閫氱煡] 浣嗘槸骞冲彴宸查厤缃嫆缁濇娑堟伅锛屾潵鑷澶�: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + } + break; + case CatalogEvent.ADD: + // 澧炲姞 + logger.info("[鏀跺埌澧炲姞閫氶亾閫氱煡] 鏉ヨ嚜璁惧: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + // 鍒ゆ柇姝ら�氶亾鏄惁瀛樺湪 + DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channel.getChannelId()); + if (deviceChannel != null) { + channel.setId(deviceChannel.getId()); + updateChannelMap.put(channel.getChannelId(), channel); + if (updateChannelMap.keySet().size() > 300) { + executeSaveForUpdate(); + } + }else { + addChannelMap.put(channel.getChannelId(), channel); + if (addChannelMap.keySet().size() > 300) { + executeSaveForAdd(); + } + } + + break; + case CatalogEvent.DEL: + // 鍒犻櫎 + logger.info("[鏀跺埌鍒犻櫎閫氶亾閫氱煡] 鏉ヨ嚜璁惧: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + deleteChannelList.add(channel); + if (deleteChannelList.size() > 300) { + executeSaveForDelete(); + } + break; + case CatalogEvent.UPDATE: + // 鏇存柊 + logger.info("[鏀跺埌鏇存柊閫氶亾閫氱煡] 鏉ヨ嚜璁惧: {}, 閫氶亾 {}", device.getDeviceId(), channel.getChannelId()); + // 鍒ゆ柇姝ら�氶亾鏄惁瀛樺湪 + DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId()); + if (deviceChannelForUpdate != null) { + channel.setId(deviceChannelForUpdate.getId()); + updateChannelMap.put(channel.getChannelId(), channel); + if (updateChannelMap.keySet().size() > 300) { + executeSaveForUpdate(); + } + }else { + addChannelMap.put(channel.getChannelId(), channel); + if (addChannelMap.keySet().size() > 300) { + executeSaveForAdd(); + } + } + break; + default: + logger.warn("[ NotifyCatalog ] event not found 锛� {}", event ); + + } + // 杞彂鍙樺寲淇℃伅 + eventPublisher.catalogEventPublish(null, channel, event); + + if (updateChannelMap.keySet().size() > 0 + || addChannelMap.keySet().size() > 0 + || updateChannelOnlineList.size() > 0 + || updateChannelOfflineList.size() > 0 + || deleteChannelList.size() > 0) { + + if (!dynamicTask.contains(talkKey)) { + dynamicTask.startDelay(talkKey, this::executeSave, 1000); + } + } + } + } + } catch (DocumentException e) { + logger.error("鏈鐞嗙殑寮傚父 ", e); + } + } + + private void executeSave(){ + System.out.println("瀹氭椂瀛樺偍鏁版嵁"); + executeSaveForUpdate(); + executeSaveForDelete(); + executeSaveForOnline(); + executeSaveForOffline(); + dynamicTask.stop(talkKey); + } + + private void executeSaveForUpdate(){ + if (updateChannelMap.values().size() > 0) { + ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(updateChannelMap.values()); + updateChannelMap.clear(); + deviceChannelService.batchUpdateChannel(deviceChannels); + } + + } + + private void executeSaveForAdd(){ + if (addChannelMap.values().size() > 0) { + ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(addChannelMap.values()); + addChannelMap.clear(); + deviceChannelService.batchAddChannel(deviceChannels); + } + } + + private void executeSaveForDelete(){ + if (deleteChannelList.size() > 0) { + deviceChannelService.deleteChannels(deleteChannelList); + deleteChannelList.clear(); + } + } + + private void executeSaveForOnline(){ + if (updateChannelOnlineList.size() > 0) { + deviceChannelService.channelsOnline(updateChannelOnlineList); + updateChannelOnlineList.clear(); + } + } + + private void executeSaveForOffline(){ + if (updateChannelOfflineList.size() > 0) { + deviceChannelService.channelsOffline(updateChannelOfflineList); + updateChannelOfflineList.clear(); + } + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index 4260641..5dae826 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -76,11 +76,16 @@ @Autowired private IDeviceChannelService deviceChannelService; + @Autowired + private NotifyRequestForCatalogProcessor notifyRequestForCatalogProcessor; + private ConcurrentLinkedQueue<HandlerCatchData> taskQueue = new ConcurrentLinkedQueue<>(); @Qualifier("taskExecutor") @Autowired private ThreadPoolTaskExecutor taskExecutor; + + private int maxQueueCount = 30000; @Override public void afterPropertiesSet() throws Exception { @@ -91,7 +96,15 @@ @Override public void process(RequestEvent evt) { try { - responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null); + + if (taskQueue.size() >= userSetting.getMaxNotifyCountQueue()) { + responseAck((SIPRequest) evt.getRequest(), Response.BUSY_HERE, null, null); + logger.error("[notify] 寰呭鐞嗘秷鎭槦鍒楀凡婊� {}锛岃繑鍥�486 BUSY_HERE锛屾秷鎭笉鍋氬鐞�", userSetting.getMaxNotifyCountQueue()); + return; + }else { + responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null); + } + }catch (SipException | InvalidArgumentException | ParseException e) { logger.error("鏈鐞嗙殑寮傚父 ", e); } @@ -103,6 +116,9 @@ while (!taskQueue.isEmpty()) { try { HandlerCatchData take = taskQueue.poll(); + if (take == null) { + continue; + } Element rootElement = getRootElement(take.getEvt()); if (rootElement == null) { logger.error("澶勭悊NOTIFY娑堟伅鏃舵湭鑾峰彇鍒版秷鎭綋,{}", take.getEvt().getRequest()); @@ -112,7 +128,8 @@ if (CmdType.CATALOG.equals(cmd)) { logger.info("鎺ユ敹鍒癈atalog閫氱煡"); - processNotifyCatalogList(take.getEvt()); +// processNotifyCatalogList(take.getEvt()); + notifyRequestForCatalogProcessor.process(take.getEvt()); } else if (CmdType.ALARM.equals(cmd)) { logger.info("鎺ユ敹鍒癆larm閫氱煡"); processNotifyAlarm(take.getEvt()); @@ -132,7 +149,7 @@ /** * 澶勭悊MobilePosition绉诲姩浣嶇疆Notify - * + * * @param evt */ private void processNotifyMobilePosition(RequestEvent evt) { @@ -236,7 +253,7 @@ /*** * 澶勭悊alarm璁惧鎶ヨNotify - * + * * @param evt */ private void processNotifyAlarm(RequestEvent evt) { @@ -346,7 +363,7 @@ /*** * 澶勭悊catalog璁惧鐩綍鍒楄〃Notify - * + * * @param evt */ private void processNotifyCatalogList(RequestEvent evt) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java index c192dd5..66dbe07 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -56,4 +56,35 @@ * 鏌ヨ閫氶亾鎵�灞炵殑璁惧 */ List<Device> getDeviceByChannelId(String channelId); + + /** + * 鎵归噺鍒犻櫎閫氶亾 + * @param deleteChannelList 寰呭垹闄ょ殑閫氶亾鍒楄〃 + */ + int deleteChannels(List<DeviceChannel> deleteChannelList); + + /** + * 鎵归噺涓婄嚎 + */ + int channelsOnline(List<DeviceChannel> channels); + + /** + * 鎵归噺涓嬬嚎 + */ + int channelsOffline(List<DeviceChannel> channels); + + /** + * 鑾峰彇涓�涓�氶亾 + */ + DeviceChannel getOne(String deviceId, String channelId); + + /** + * 鐩存帴鎵归噺鏇存柊閫氶亾 + */ + void batchUpdateChannel(List<DeviceChannel> channels); + + /** + * 鐩存帴鎵归噺娣诲姞 + */ + void batchAddChannel(List<DeviceChannel> deviceChannels); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index 9223ced..229bc0d 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -209,6 +209,47 @@ @Override public List<Device> getDeviceByChannelId(String channelId) { + return channelMapper.getDeviceByChannelId(channelId); } + + @Override + public int deleteChannels(List<DeviceChannel> deleteChannelList) { + return channelMapper.batchDel(deleteChannelList); + } + + @Override + public int channelsOnline(List<DeviceChannel> channels) { + return channelMapper.batchOnline(channels); + } + + @Override + public int channelsOffline(List<DeviceChannel> channels) { + return channelMapper.batchOffline(channels); + } + + @Override + public DeviceChannel getOne(String deviceId, String channelId){ + return channelMapper.queryChannel(deviceId, channelId); + } + + @Override + public void batchUpdateChannel(List<DeviceChannel> channels) { + channelMapper.batchUpdate(channels); + for (DeviceChannel channel : channels) { + if (channel.getParentId() != null) { + channelMapper.updateChannelSubCount(channel.getDeviceId(), channel.getParentId()); + } + } + } + + @Override + public void batchAddChannel(List<DeviceChannel> channels) { + channelMapper.batchAdd(channels); + for (DeviceChannel channel : channels) { + if (channel.getParentId() != null) { + channelMapper.updateChannelSubCount(channel.getDeviceId(), channel.getParentId()); + } + } + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index a3dd6a7..48de5d2 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -644,4 +644,6 @@ public List<Device> getAll() { return deviceMapper.getAll(); } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 93f2a09..3f4d804 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -197,6 +197,60 @@ @Update(value = {"UPDATE device_channel SET status=0 WHERE deviceId=#{deviceId}"}) void offlineByDeviceId(String deviceId); +// @Insert("<script> " + +// "insert into device_channel " + +// "(channelId, deviceId, name, manufacture, model, owner, civilCode, block, subCount, " + +// " address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " + +// " ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " + +// " longitudeWgs84, latitudeWgs84, hasAudio, createTime, updateTime, businessGroupId, gpsTime) " + +// "values " + +// "<foreach collection='addChannels' index='index' item='item' separator=','> " + +// "(#{item.channelId}, #{item.deviceId}, #{item.name}, #{item.manufacture}, #{item.model}, " + +// "#{item.owner}, #{item.civilCode}, #{item.block},#{item.subCount}," + +// "#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, " + +// "#{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.secrecy}, " + +// "#{item.ipAddress}, #{item.port}, #{item.password}, #{item.PTZType}, #{item.status}, " + +// "#{item.streamId}, #{item.longitude}, #{item.latitude},#{item.longitudeGcj02}, " + +// "#{item.latitudeGcj02},#{item.longitudeWgs84}, #{item.latitudeWgs84}, #{item.hasAudio}, now(), now(), " + +// "#{item.businessGroupId}, #{item.gpsTime}) " + +// "</foreach> " + +// "ON DUPLICATE KEY UPDATE " + +// "updateTime=VALUES(updateTime), " + +// "name=VALUES(name), " + +// "manufacture=VALUES(manufacture), " + +// "model=VALUES(model), " + +// "owner=VALUES(owner), " + +// "civilCode=VALUES(civilCode), " + +// "block=VALUES(block), " + +// "subCount=VALUES(subCount), " + +// "address=VALUES(address), " + +// "parental=VALUES(parental), " + +// "parentId=VALUES(parentId), " + +// "safetyWay=VALUES(safetyWay), " + +// "registerWay=VALUES(registerWay), " + +// "certNum=VALUES(certNum), " + +// "certifiable=VALUES(certifiable), " + +// "errCode=VALUES(errCode), " + +// "secrecy=VALUES(secrecy), " + +// "ipAddress=VALUES(ipAddress), " + +// "port=VALUES(port), " + +// "password=VALUES(password), " + +// "PTZType=VALUES(PTZType), " + +// "status=VALUES(status), " + +// "streamId=VALUES(streamId), " + +// "longitude=VALUES(longitude), " + +// "latitude=VALUES(latitude), " + +// "longitudeGcj02=VALUES(longitudeGcj02), " + +// "latitudeGcj02=VALUES(latitudeGcj02), " + +// "longitudeWgs84=VALUES(longitudeWgs84), " + +// "latitudeWgs84=VALUES(latitudeWgs84), " + +// "hasAudio=VALUES(hasAudio), " + +// "businessGroupId=VALUES(businessGroupId), " + +// "gpsTime=VALUES(gpsTime)" + +// "</script>") +// int batchAdd(List<DeviceChannel> addChannels); + + @Insert("<script> " + "insert into device_channel " + "(channelId, deviceId, name, manufacture, model, owner, civilCode, block, subCount, " + @@ -214,39 +268,6 @@ "#{item.latitudeGcj02},#{item.longitudeWgs84}, #{item.latitudeWgs84}, #{item.hasAudio}, now(), now(), " + "#{item.businessGroupId}, #{item.gpsTime}) " + "</foreach> " + - "ON DUPLICATE KEY UPDATE " + - "updateTime=VALUES(updateTime), " + - "name=VALUES(name), " + - "manufacture=VALUES(manufacture), " + - "model=VALUES(model), " + - "owner=VALUES(owner), " + - "civilCode=VALUES(civilCode), " + - "block=VALUES(block), " + - "subCount=VALUES(subCount), " + - "address=VALUES(address), " + - "parental=VALUES(parental), " + - "parentId=VALUES(parentId), " + - "safetyWay=VALUES(safetyWay), " + - "registerWay=VALUES(registerWay), " + - "certNum=VALUES(certNum), " + - "certifiable=VALUES(certifiable), " + - "errCode=VALUES(errCode), " + - "secrecy=VALUES(secrecy), " + - "ipAddress=VALUES(ipAddress), " + - "port=VALUES(port), " + - "password=VALUES(password), " + - "PTZType=VALUES(PTZType), " + - "status=VALUES(status), " + - "streamId=VALUES(streamId), " + - "longitude=VALUES(longitude), " + - "latitude=VALUES(latitude), " + - "longitudeGcj02=VALUES(longitudeGcj02), " + - "latitudeGcj02=VALUES(latitudeGcj02), " + - "longitudeWgs84=VALUES(longitudeWgs84), " + - "latitudeWgs84=VALUES(latitudeWgs84), " + - "hasAudio=VALUES(hasAudio), " + - "businessGroupId=VALUES(businessGroupId), " + - "gpsTime=VALUES(gpsTime)" + "</script>") int batchAdd(List<DeviceChannel> addChannels); @@ -264,7 +285,7 @@ "<if test='item.owner != null'>, owner=#{item.owner}</if>" + "<if test='item.civilCode != null'>, civilCode=#{item.civilCode}</if>" + "<if test='item.block != null'>, block=#{item.block}</if>" + - "<if test='item.subCount != null'>, block=#{item.subCount}</if>" + + "<if test='item.subCount != null'>, subCount=#{item.subCount}</if>" + "<if test='item.address != null'>, address=#{item.address}</if>" + "<if test='item.parental != null'>, parental=#{item.parental}</if>" + "<if test='item.parentId != null'>, parentId=#{item.parentId}</if>" + @@ -289,7 +310,8 @@ "<if test='item.latitudeWgs84 != null'>, latitudeWgs84=#{item.latitudeWgs84}</if>" + "<if test='item.businessGroupId != null'>, businessGroupId=#{item.businessGroupId}</if>" + "<if test='item.gpsTime != null'>, gpsTime=#{item.gpsTime}</if>" + - "WHERE deviceId=#{item.deviceId} AND channelId=#{item.channelId}"+ + "<if test='item.id > 0'>WHERE id=#{item.id}</if>" + + "<if test='item.id == 0'>WHERE deviceId=#{item.deviceId} AND channelId=#{item.channelId}</if>" + "</foreach>" + "</script>"}) int batchUpdate(List<DeviceChannel> updateChannels); @@ -403,4 +425,26 @@ @Select("select de.* from device de left join device_channel dc on de.deviceId = dc.deviceId where dc.channelId=#{channelId}") List<Device> getDeviceByChannelId(String channelId); + + + @Delete({"<script>" + + "<foreach collection='deleteChannelList' item='item' separator=';'>" + + "DELETE FROM device_channel WHERE deviceId=#{item.deviceId} AND channelId=#{item.channelId}" + + "</foreach>" + + "</script>"}) + int batchDel(List<DeviceChannel> deleteChannelList); + + @Update({"<script>" + + "<foreach collection='channels' item='item' separator=';'>" + + "UPDATE device_channel SET status=1 WHERE deviceId=#{item.deviceId} AND channelId=#{item.channelId}" + + "</foreach>" + + "</script>"}) + int batchOnline(List<DeviceChannel> channels); + + @Update({"<script>" + + "<foreach collection='channels' item='item' separator=';'>" + + "UPDATE device_channel SET status=0 WHERE deviceId=#{item.deviceId} AND channelId=#{item.channelId}" + + "</foreach>" + + "</script>"}) + int batchOffline(List<DeviceChannel> channels); } diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index d0a8289..bae9904 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -178,6 +178,8 @@ send-to-platforms-when-id-lost: true # 淇濇寔閫氶亾鐘舵�侊紝涓嶆帴鍙梟otify閫氶亾鐘舵�佸彉鍖栵紝 鍏煎娴峰悍骞冲彴鍙戦�侀敊璇秷鎭� refuse-channel-status-channel-form-notify: false + # 璁剧疆notify缂撳瓨闃熷垪鏈�澶ч暱搴︼紝瓒呰繃姝ら暱搴︾殑鏁版嵁灏嗚繑鍥�486 BUSY_HERE锛屾秷鎭涪寮�, 榛樿10000 + max-notify-count-queue: 10000 # 璺ㄥ煙閰嶇疆锛岄厤缃綘璁块棶鍓嶇椤甸潰鐨勫湴鍧�鍗冲彲锛� 鍙互閰嶇疆澶氫釜 allowed-origins: - http://localhost:8008 -- Gitblit v1.8.0