From 3d07f0c2ddec76c51ff0b14a0b7ec88a7e35defb Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Wed, 21 Feb 2024 17:21:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E9=97=B4=E5=BA=93=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/mapper/MiddleDatabaseMapper.java | 17 +++ .../service/IMiddleDatabaseService.java | 17 +++ .../impl/MiddleDatabaseServiceImpl.java | 35 +++++ .../mapper/business/MiddleDatabaseMapper.xml | 129 +++++++++++++++++- 4 files changed, 197 insertions(+), 1 deletion(-) diff --git a/zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java b/zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java index f2ed25e0..9b72f0a6 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java @@ -3,6 +3,7 @@ package com.zc.business.mapper; import com.zc.business.domain.DcBoardReleaseLog; import com.zc.business.domain.DcDevice; import com.zc.business.domain.MdDeviceData; +import com.zc.business.domain.MdEvent; import java.util.List; @@ -30,4 +31,20 @@ public interface MiddleDatabaseMapper * @return 结果 */ boolean updateMiddleDatabaseDevice(DcDevice dcDevice); + + /** + * 中间库新增事件 + * + * @param mdEvent 事件 + * @return 结果 + */ + boolean insertMiddleDatabaseEvent(MdEvent mdEvent); + + /** + * 中间库更新事件 + * + * @param mdEvent 事件 + * @return 结果 + */ + boolean updateMiddleDatabaseEvent(MdEvent mdEvent); } diff --git a/zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java b/zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java index 926a56e0..9ebaf619 100644 --- a/zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java +++ b/zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.zc.business.domain.DcBoardPublish; import com.zc.business.domain.DcDevice; import com.zc.business.domain.MdDeviceData; +import com.zc.business.domain.MdEvent; import java.util.List; @@ -40,4 +41,20 @@ public interface IMiddleDatabaseService */ boolean updateMiddleDatabaseDevice(DcDevice device); + /** + * 中间库新增事件 + * + * @param + * @return 结果 + */ + boolean insertMiddleDatabaseEvent(MdEvent mdEvent); + + /** + * 中间库更新事件 + * + * @param + * @return 结果 + */ + boolean updateMiddleDatabaseEvent(MdEvent mdEvent); + } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java index 0e47d6f5..be315357 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java @@ -1,9 +1,12 @@ package com.zc.business.service.impl; import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.common.utils.SecurityUtils; import com.zc.business.domain.DcDevice; import com.zc.business.domain.MdDeviceData; +import com.zc.business.domain.MdEvent; import com.zc.business.mapper.MiddleDatabaseMapper; import com.zc.business.service.IMiddleDatabaseService; import org.springframework.beans.factory.annotation.Autowired; @@ -68,4 +71,36 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService { { return middleDatabaseMapper.updateMiddleDatabaseDevice(device); } + + /** + * 中间库新增事件 + * + * @param mdEvent 事件 + * @return 结果 + */ + @DataSource(value = DataSourceType.SLAVE)//切换数据源 + @Override + public boolean insertMiddleDatabaseEvent(MdEvent mdEvent){ + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + mdEvent.setCreatorUserId(loginUser.getUserId()); + } + return middleDatabaseMapper.insertMiddleDatabaseEvent(mdEvent); + } + + /** + * 中间库更新事件 + * + * @param mdEvent 事件 + * @return 结果 + */ + @DataSource(value = DataSourceType.SLAVE)//切换数据源 + @Override + public boolean updateMiddleDatabaseEvent(MdEvent mdEvent){ + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + mdEvent.setLastModifierUserId(loginUser.getUserId()); + } + return middleDatabaseMapper.updateMiddleDatabaseEvent(mdEvent); + } } diff --git a/zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml b/zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml index ed10eb0f..f26ca694 100644 --- a/zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml +++ b/zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml @@ -33,8 +33,135 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + insert into event + + fusionId, + event_name, + event_type_code, + event_desc, + occur_time, + end_time, + stake_number, + longitude, + latitude, + lane, + direction, + location, + event_source_code, + event_source, + event_status, + event_level, + section_id, + event_type_code2, + event_cause, + accident_weather, + accident_queue, + congestion_pile, + congestion_reason, + control_category, + control_reason, + control_reason_type, + control_station, + control_pile, + control_strategy, + control_type, + control_vehicle_type, + CreatorUserId, + LastModificationTime, + LastModifierUserId, + IsDeleted, + DeleterUserId, + DeletionTime, + CreationTime, + + + #{fusionId}, + #{eventName}, + #{eventTypeCode}, + #{eventDesc}, + #{occurTime}, + #{endTime}, + #{stakeNumber}, + #{longitude}, + #{latitude}, + #{lane}, + #{direction}, + #{location}, + #{eventSourceCode}, + #{eventSource}, + #{eventStatus}, + #{eventLevel}, + #{sectionId}, + #{eventTypeCode2}, + #{eventCause}, + #{accidentWeather}, + #{accidentQueue}, + #{congestionPile}, + #{congestionReason}, + #{controlCategory}, + #{controlReason}, + #{controlReasonType}, + #{controlStation}, + #{controlPile}, + #{controlStrategy}, + #{controlType}, + #{controlVehicleType}, + #{creatorUserId}, + #{lastModificationTime}, + #{lastModifierUserId}, + #{isDeleted}, + #{deleterUserId}, + #{deletionTime}, + now() + + + + update device set dev_status = #{deviceState} where dev_no = #{iotDeviceId} + + update event + + fusionId = #{fusionId}, + event_name = #{eventName}, + event_type_code = #{eventTypeCode}, + event_desc = #{eventDesc}, + occur_time = #{occurTime}, + end_time = #{endTime}, + stake_number = #{stakeNumber}, + longitude = #{longitude}, + latitude = #{latitude}, + lane = #{lane}, + direction = #{direction}, + location = #{location}, + event_source_code = #{eventSourceCode}, + event_source = #{eventSource}, + event_status = #{eventStatus}, + event_level = #{eventLevel}, + section_id = #{sectionId}, + event_type_code2 = #{eventTypeCode2}, + event_cause = #{eventCause}, + accident_weather = #{accidentWeather}, + accident_queue = #{accidentQueue}, + congestion_pile = #{congestionPile}, + congestion_reason = #{congestionReason}, + control_category = #{controlCategory}, + control_reason = #{controlReason}, + control_reason_type = #{controlReasonType}, + control_station = #{controlStation}, + control_pile = #{controlPile}, + control_strategy = #{controlStrategy}, + control_type = #{controlType}, + control_vehicle_type = #{controlVehicleType}, + LastModificationTime = now(), + LastModifierUserId = #{lastModifierUserId}, + IsDeleted = #{isDeleted}, + DeleterUserId = #{deleterUserId}, + DeletionTime = #{deletionTime}, + + where id = #{id} + +