Browse Source

中间库设备修改

develop
lau572 9 months ago
parent
commit
3d07f0c2dd
  1. 17
      zc-business/src/main/java/com/zc/business/mapper/MiddleDatabaseMapper.java
  2. 17
      zc-business/src/main/java/com/zc/business/service/IMiddleDatabaseService.java
  3. 35
      zc-business/src/main/java/com/zc/business/service/impl/MiddleDatabaseServiceImpl.java
  4. 129
      zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

17
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.DcBoardReleaseLog;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
import com.zc.business.domain.MdDeviceData; import com.zc.business.domain.MdDeviceData;
import com.zc.business.domain.MdEvent;
import java.util.List; import java.util.List;
@ -30,4 +31,20 @@ public interface MiddleDatabaseMapper
* @return 结果 * @return 结果
*/ */
boolean updateMiddleDatabaseDevice(DcDevice dcDevice); boolean updateMiddleDatabaseDevice(DcDevice dcDevice);
/**
* 中间库新增事件
*
* @param mdEvent 事件
* @return 结果
*/
boolean insertMiddleDatabaseEvent(MdEvent mdEvent);
/**
* 中间库更新事件
*
* @param mdEvent 事件
* @return 结果
*/
boolean updateMiddleDatabaseEvent(MdEvent mdEvent);
} }

17
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.DcBoardPublish;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
import com.zc.business.domain.MdDeviceData; import com.zc.business.domain.MdDeviceData;
import com.zc.business.domain.MdEvent;
import java.util.List; import java.util.List;
@ -40,4 +41,20 @@ public interface IMiddleDatabaseService
*/ */
boolean updateMiddleDatabaseDevice(DcDevice device); boolean updateMiddleDatabaseDevice(DcDevice device);
/**
* 中间库新增事件
*
* @param
* @return 结果
*/
boolean insertMiddleDatabaseEvent(MdEvent mdEvent);
/**
* 中间库更新事件
*
* @param
* @return 结果
*/
boolean updateMiddleDatabaseEvent(MdEvent mdEvent);
} }

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

@ -1,9 +1,12 @@
package com.zc.business.service.impl; package com.zc.business.service.impl;
import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.SecurityUtils;
import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcDevice;
import com.zc.business.domain.MdDeviceData; import com.zc.business.domain.MdDeviceData;
import com.zc.business.domain.MdEvent;
import com.zc.business.mapper.MiddleDatabaseMapper; import com.zc.business.mapper.MiddleDatabaseMapper;
import com.zc.business.service.IMiddleDatabaseService; import com.zc.business.service.IMiddleDatabaseService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -68,4 +71,36 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService {
{ {
return middleDatabaseMapper.updateMiddleDatabaseDevice(device); 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);
}
} }

129
zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

@ -33,8 +33,135 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
</insert> </insert>
<update id="updateMiddleDatabaseDevice"> <insert id="insertMiddleDatabaseEvent" parameterType="MdEvent">
insert into event
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="fusionId != null">fusionId,</if>
<if test="eventName != null">event_name,</if>
<if test="eventTypeCode != null">event_type_code,</if>
<if test="eventDesc != null">event_desc,</if>
<if test="occurTime != null">occur_time,</if>
<if test="endTime != null">end_time,</if>
<if test="stakeNumber != null and stakeNumber != ''">stake_number,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="lane != null">lane,</if>
<if test="direction != null and direction != ''">direction,</if>
<if test="location != null">location,</if>
<if test="eventSourceCode != null">event_source_code,</if>
<if test="eventSource != null">event_source,</if>
<if test="eventStatus != null">event_status,</if>
<if test="eventLevel != null">event_level,</if>
<if test="sectionId != null">section_id,</if>
<if test="eventTypeCode2 != null">event_type_code2,</if>
<if test="eventCause != null">event_cause,</if>
<if test="accidentWeather != null">accident_weather,</if>
<if test="accidentQueue != null">accident_queue,</if>
<if test="congestionPile != null">congestion_pile,</if>
<if test="congestionReason != null">congestion_reason,</if>
<if test="controlCategory != null">control_category,</if>
<if test="controlReason != null">control_reason,</if>
<if test="controlReasonType != null">control_reason_type,</if>
<if test="controlStation != null">control_station,</if>
<if test="controlPile != null">control_pile,</if>
<if test="controlStrategy != null">control_strategy,</if>
<if test="controlType != null">control_type,</if>
<if test="controlVehicleType != null">control_vehicle_type,</if>
<if test="creatorUserId != null">CreatorUserId,</if>
<if test="lastModificationTime != null">LastModificationTime,</if>
<if test="lastModifierUserId != null">LastModifierUserId,</if>
<if test="isDeleted != null">IsDeleted,</if>
<if test="deleterUserId != null">DeleterUserId,</if>
<if test="deletionTime != null">DeletionTime,</if>
CreationTime,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="fusionId != null">#{fusionId},</if>
<if test="eventName != null">#{eventName},</if>
<if test="eventTypeCode != null">#{eventTypeCode},</if>
<if test="eventDesc != null">#{eventDesc},</if>
<if test="occurTime != null">#{occurTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="stakeNumber != null and stakeNumber != ''">#{stakeNumber},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="lane != null">#{lane},</if>
<if test="direction != null and direction != ''">#{direction},</if>
<if test="location != null">#{location},</if>
<if test="eventSourceCode != null">#{eventSourceCode},</if>
<if test="eventSource != null">#{eventSource},</if>
<if test="eventStatus != null">#{eventStatus},</if>
<if test="eventLevel != null">#{eventLevel},</if>
<if test="sectionId != null">#{sectionId},</if>
<if test="eventTypeCode2 != null">#{eventTypeCode2},</if>
<if test="eventCause != null">#{eventCause},</if>
<if test="accidentWeather != null">#{accidentWeather},</if>
<if test="accidentQueue != null">#{accidentQueue},</if>
<if test="congestionPile != null">#{congestionPile},</if>
<if test="congestionReason != null">#{congestionReason},</if>
<if test="controlCategory != null">#{controlCategory},</if>
<if test="controlReason != null">#{controlReason},</if>
<if test="controlReasonType != null">#{controlReasonType},</if>
<if test="controlStation != null">#{controlStation},</if>
<if test="controlPile != null">#{controlPile},</if>
<if test="controlStrategy != null">#{controlStrategy},</if>
<if test="controlType != null">#{controlType},</if>
<if test="controlVehicleType != null">#{controlVehicleType},</if>
<if test="creatorUserId != null">#{creatorUserId},</if>
<if test="lastModificationTime != null">#{lastModificationTime},</if>
<if test="lastModifierUserId != null">#{lastModifierUserId},</if>
<if test="isDeleted != null">#{isDeleted},</if>
<if test="deleterUserId != null">#{deleterUserId},</if>
<if test="deletionTime != null">#{deletionTime},</if>
now()
</trim>
</insert>
<update id="updateMiddleDatabaseDevice" parameterType="MdEvent">
update device set dev_status = #{deviceState} where dev_no = #{iotDeviceId} update device set dev_status = #{deviceState} where dev_no = #{iotDeviceId}
</update> </update>
<update id="updateMiddleDatabaseEvent" parameterType="MdEvent">
update event
<trim prefix="SET" suffixOverrides=",">
<if test="fusionId != null">fusionId = #{fusionId},</if>
<if test="eventName != null">event_name = #{eventName},</if>
<if test="eventTypeCode != null">event_type_code = #{eventTypeCode},</if>
<if test="eventDesc != null">event_desc = #{eventDesc},</if>
<if test="occurTime != null">occur_time = #{occurTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="stakeNumber != null and stakeNumber != ''">stake_number = #{stakeNumber},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="lane != null">lane = #{lane},</if>
<if test="direction != null and direction != ''">direction = #{direction},</if>
<if test="location != null">location = #{location},</if>
<if test="eventSourceCode != null">event_source_code = #{eventSourceCode},</if>
<if test="eventSource != null">event_source = #{eventSource},</if>
<if test="eventStatus != null">event_status = #{eventStatus},</if>
<if test="eventLevel != null">event_level = #{eventLevel},</if>
<if test="sectionId != null">section_id = #{sectionId},</if>
<if test="eventTypeCode2 != null">event_type_code2 = #{eventTypeCode2},</if>
<if test="eventCause != null">event_cause = #{eventCause},</if>
<if test="accidentWeather != null">accident_weather = #{accidentWeather},</if>
<if test="accidentQueue != null">accident_queue = #{accidentQueue},</if>
<if test="congestionPile != null">congestion_pile = #{congestionPile},</if>
<if test="congestionReason != null">congestion_reason = #{congestionReason},</if>
<if test="controlCategory != null">control_category = #{controlCategory},</if>
<if test="controlReason != null">control_reason = #{controlReason},</if>
<if test="controlReasonType != null">control_reason_type = #{controlReasonType},</if>
<if test="controlStation != null">control_station = #{controlStation},</if>
<if test="controlPile != null">control_pile = #{controlPile},</if>
<if test="controlStrategy != null">control_strategy = #{controlStrategy},</if>
<if test="controlType != null">control_type = #{controlType},</if>
<if test="controlVehicleType != null">control_vehicle_type = #{controlVehicleType},</if>
LastModificationTime = now(),
<if test="lastModifierUserId != null">LastModifierUserId = #{lastModifierUserId},</if>
<if test="isDeleted != null">IsDeleted = #{isDeleted},</if>
<if test="deleterUserId != null">DeleterUserId = #{deleterUserId},</if>
<if test="deletionTime != null">DeletionTime = #{deletionTime},</if>
</trim>
where id = #{id}
</update>
</mapper> </mapper>

Loading…
Cancel
Save