Browse Source

收到添加事件时同步添加到中间库

develop
lau572 9 months ago
parent
commit
32ff4b3256
  1. 3
      zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java
  2. 1
      zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java
  3. 13
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  4. 18
      zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java

3
zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java

@ -1,5 +1,8 @@
package com.zc.business.mapper;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.zc.business.domain.DcBoardReleaseLog;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.MdDeviceData;

1
zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java

@ -1,5 +1,6 @@
package com.zc.business.service;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcBoardPublish;
import com.zc.business.domain.DcDevice;

13
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -12,6 +12,7 @@ import com.ruoyi.system.service.ISysDeptService;
import com.zc.business.domain.*;
import com.zc.business.mapper.*;
import com.zc.business.service.IDcEventService;
import com.zc.business.service.IMiddleDatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -58,6 +59,8 @@ private DcEventAbnormalWeatherMapper dcEventAbnormalWeatherMapper;
//部门信息
@Autowired
private ISysDeptService deptService;
@Autowired
private IMiddleDatabaseService middleDatabaseService;
@ -131,6 +134,11 @@ dcEvent.setUserId(SecurityUtils.getUserId());
int i7 = dcEventMapper.insertDcEvent(dcEvent);
if (i7>0){
//中间库
// MdEvent mdEvent = new MdEvent(dcEvent);
// middleDatabaseService.insertMiddleDatabaseEvent(mdEvent);
//获取事件类型
int eventType = Math.toIntExact(dcEvent.getEventType());
switch (eventType){
@ -205,6 +213,11 @@ dcEvent.setUserId(SecurityUtils.getUserId());
dcEvent.setUpdateTime(DateUtils.getNowDate());
int i7 = dcEventMapper.updateDcEvent(dcEvent);
if (i7>0) {
//中间库
// MdEvent mdEvent = new MdEvent(dcEvent);
// middleDatabaseService.updateMiddleDatabaseEvent(mdEvent);
int eventType = Math.toIntExact(dcEvent.getEventType());
switch (eventType){
//交通事故

18
zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java

@ -1,5 +1,6 @@
package com.zc.business.service.impl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.DataSourceType;
@ -11,6 +12,8 @@ import com.zc.business.mapper.MiddleDatabaseMapper;
import com.zc.business.service.IMiddleDatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@ -21,6 +24,8 @@ import java.util.List;
* @date 2024-01-03
*/
@Service
@DataSource(value = DataSourceType.SLAVE)//切换数据源
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
@ -34,7 +39,7 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param mdDeviceData 气象检测器数据
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
// @DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData)
{
@ -48,7 +53,7 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param listDevice 设备列表
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
// @DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean updateMiddleDatabaseDeviceByList(List<DcDevice> listDevice)
{
@ -65,7 +70,7 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param device 设备
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
// @DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean updateMiddleDatabaseDevice(DcDevice device)
{
@ -78,13 +83,12 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param mdEvent 事件
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean insertMiddleDatabaseEvent(MdEvent mdEvent){
LoginUser loginUser = SecurityUtils.getLoginUser();
/* LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
mdEvent.setCreatorUserId(loginUser.getUserId());
}
}*/
return middleDatabaseMapper.insertMiddleDatabaseEvent(mdEvent);
}
@ -94,7 +98,7 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
* @param mdEvent 事件
* @return 结果
*/
@DataSource(value = DataSourceType.SLAVE)//切换数据源
// @DataSource(value = DataSourceType.SLAVE)//切换数据源
@Override
public boolean updateMiddleDatabaseEvent(MdEvent mdEvent){
LoginUser loginUser = SecurityUtils.getLoginUser();

Loading…
Cancel
Save