diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 9849822d..b66131c4 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -15,10 +15,10 @@ spring: # 从库数据源 slave: # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: + enabled: true + url: jdbc:mysql://10.168.56.204:3306/jihe-md?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true + username: root + password: Platform123!@# # 初始连接数 initialSize: 5 # 最小连接池数量 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/DcShiftsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java index f14a93e7..10a4ceff 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java @@ -103,7 +103,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService * @return 结果 */ @Override - @Transactional(rollbackFor = ServiceException.class) + @Transactional(rollbackFor = Exception.class) public int insertDcShifts(DcShifts dcShifts) throws Exception{ String msg = ""; JSON employeesJson = dcShifts.getEmployeesJson(); @@ -155,7 +155,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService * @return 结果 */ @Override - @Transactional(rollbackFor = ServiceException.class) + @Transactional(rollbackFor = Exception.class) public int updateDcShifts(DcShifts dcShifts) throws Exception{ String msg = ""; dcShifts.setUpdateTime(DateUtils.getNowDate()); @@ -198,7 +198,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService * @return 结果 */ @Override - @Transactional(rollbackFor = ServiceException.class) + @Transactional(rollbackFor = Exception.class) public int deleteDcShiftsByIds(Long[] ids) throws Exception{ for (Long id:ids){ DcShifts dcShifts = dcShiftsMapper.selectDcShiftsById(id); @@ -226,7 +226,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService } @Override - @Transactional(rollbackFor = ServiceException.class) + @Transactional(rollbackFor = Exception.class) public int deleteDcShiftsListId(DcShifts dcShifts) throws Exception { List shiftsValue = dcShiftsMapper.selectDcShiftsDeleteList(dcShifts); for (DcShifts shifts:shiftsValue){ @@ -269,7 +269,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService } @Override - @Transactional(rollbackFor = ServiceException.class) + @Transactional(rollbackFor = Exception.class) public AjaxResult importEquipment(MultipartFile file) throws Exception{ String msg = ""; ExcelUtil util = new ExcelUtil(DcShifts.class); 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/DcOrganizationMapper.xml b/zc-business/src/main/resources/mapper/business/DcOrganizationMapper.xml index 1d950060..4bc03fe0 100644 --- a/zc-business/src/main/resources/mapper/business/DcOrganizationMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcOrganizationMapper.xml @@ -120,7 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select count(1) from dc_employees where organization_id=#{id} diff --git a/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml index 39edf1da..da04178f 100644 --- a/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml @@ -43,6 +43,7 @@ and warning.warning_time between #{startTime} and #{endTime} + order by warning.warning_time desc