diff --git a/zc-business/src/main/java/com/zc/business/domain/DcDevice.java b/zc-business/src/main/java/com/zc/business/domain/DcDevice.java index 54e75d83..1b1faa72 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcDevice.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcDevice.java @@ -53,6 +53,8 @@ public class DcDevice { private String otherConfig; @ApiModelProperty("备注") private String remark; + @ApiModelProperty("设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等") + private String facilitiesType; @ApiModelProperty("创建时间") private Date createTime; @ApiModelProperty("修改时间") @@ -61,4 +63,7 @@ public class DcDevice { private String longitude; @TableField(exist = false) private String latitude; + //设备厂商 + @TableField(exist = false) + private String manufacturer; } diff --git a/zc-business/src/main/java/com/zc/business/domain/MdDevice.java b/zc-business/src/main/java/com/zc/business/domain/MdDevice.java new file mode 100644 index 00000000..f10d8964 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/MdDevice.java @@ -0,0 +1,311 @@ +package com.zc.business.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.utils.StringUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 中间库 设备对象 device + * + * @author ruoyi + * @date 2024-02-21 + */ +public class MdDevice +{ + + /** 主键 */ + private Long id; + + /** 设备id */ + @Excel(name = "设备id") + private String devNo; + + /** 设备名称 */ + @Excel(name = "设备名称") + private String devName; + + /** 所在桩号 */ + @Excel(name = "所在桩号") + private String stakeNum; + + /** 方向1-上行,2-中,3-下行 */ + @Excel(name = "方向1-上行,2-中,3-下行") + private String direction; + + /** 设备类型 + 1 摄像机 + 2 可变信息标志 + 3 气象监测器 + 4 出口诱导灯 + 5 路段语音广播 + 6 护栏碰撞 + 7 毫米波雷达 + 8 合流区预警 + 9 智慧锥桶 + 10 激光疲劳唤醒 + 11 一类交通量调查站 + 12 行车诱导 + 13 智能设备箱 + 14 光线在线监测 + */ + @Excel(name = "设备类型") + private String typeCode; + + /** 设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等 */ + @Excel(name = "设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等 ") + private String facilitiesType; + + /** 设备状态:0-异常,1-正常 */ + @Excel(name = "设备状态:0-异常,1-正常") + private String devStatus; + + /** 所属机构id */ + @Excel(name = "所属机构id") + private String opmaManagerId; + + /** 所属机构名称 */ + @Excel(name = "所属机构名称") + private String opmaManagerName; + + /** 所属厂商 */ + @Excel(name = "所属厂商") + private String supplierName; + + /** 所属路段 */ + @Excel(name = "所属路段") + private String sectionId; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date creationTime; + + /** 创建人 */ + @Excel(name = "创建人") + private Long creatorUserId; + + /** 最后修改时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "最后修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date lastModificationTime; + + /** 最后修改人 */ + @Excel(name = "最后修改人") + private Long lastModifierUserId; + + /** 是否删除 */ + @Excel(name = "是否删除") + private Integer isDeleted; + + /** 删除人 */ + @Excel(name = "删除人") + private Long deleterUserId; + + /** 删除时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "删除时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date deletionTime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public String getDevNo() { + return devNo; + } + + public void setDevNo(String devNo) { + this.devNo = devNo; + } + + public String getDevName() { + return devName; + } + + public void setDevName(String devName) { + this.devName = devName; + } + + public String getStakeNum() { + return stakeNum; + } + + public void setStakeNum(String stakeNum) { + this.stakeNum = stakeNum; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getTypeCode() { + return typeCode; + } + + public void setTypeCode(String typeCode) { + this.typeCode = typeCode; + } + + public String getFacilitiesType() { + return facilitiesType; + } + + public void setFacilitiesType(String facilitiesType) { + this.facilitiesType = facilitiesType; + } + + public String getDevStatus() { + return devStatus; + } + + public void setDevStatus(String devStatus) { + this.devStatus = devStatus; + } + + public String getOpmaManagerId() { + return opmaManagerId; + } + + public void setOpmaManagerId(String opmaManagerId) { + this.opmaManagerId = opmaManagerId; + } + + public String getOpmaManagerName() { + return opmaManagerName; + } + + public void setOpmaManagerName(String opmaManagerName) { + this.opmaManagerName = opmaManagerName; + } + + public String getSupplierName() { + return supplierName; + } + + public void setSupplierName(String supplierName) { + this.supplierName = supplierName; + } + + public String getSectionId() { + return sectionId; + } + + public void setSectionId(String sectionId) { + this.sectionId = sectionId; + } + + public Date getCreationTime() { + return creationTime; + } + + public void setCreationTime(Date creationTime) { + this.creationTime = creationTime; + } + + public Long getCreatorUserId() { + return creatorUserId; + } + + public void setCreatorUserId(Long creatorUserId) { + this.creatorUserId = creatorUserId; + } + + public Date getLastModificationTime() { + return lastModificationTime; + } + + public void setLastModificationTime(Date lastModificationTime) { + this.lastModificationTime = lastModificationTime; + } + + public Long getLastModifierUserId() { + return lastModifierUserId; + } + + public void setLastModifierUserId(Long lastModifierUserId) { + this.lastModifierUserId = lastModifierUserId; + } + + public Integer getIsDeleted() { + return isDeleted; + } + + public void setIsDeleted(Integer isDeleted) { + this.isDeleted = isDeleted; + } + + public Long getDeleterUserId() { + return deleterUserId; + } + + public void setDeleterUserId(Long deleterUserId) { + this.deleterUserId = deleterUserId; + } + + public Date getDeletionTime() { + return deletionTime; + } + + public void setDeletionTime(Date deletionTime) { + this.deletionTime = deletionTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("id", id) + .append("devNo", devNo) + .append("devName", devName) + .append("stakeNum", stakeNum) + .append("direction", direction) + .append("typeCode", typeCode) + .append("facilitiesType", facilitiesType) + .append("devStatus", devStatus) + .append("opmaManagerId", opmaManagerId) + .append("opmaManagerName", opmaManagerName) + .append("supplierName", supplierName) + .append("sectionId", sectionId) + .append("creationTime", creationTime) + .append("creatorUserId", creatorUserId) + .append("lastModificationTime", lastModificationTime) + .append("lastModifierUserId", lastModifierUserId) + .append("isDeleted", isDeleted) + .append("deleterUserId", deleterUserId) + .append("deletionTime", deletionTime) + .toString(); + } + + public MdDevice(){} + + public MdDevice(DcDevice dcDevice){ + this.id = dcDevice.getId(); + this.devNo = dcDevice.getIotDeviceId(); + this.devName = dcDevice.getDeviceName(); + this.stakeNum = dcDevice.getStakeMark(); + this.direction = dcDevice.getDirection(); + this.typeCode = dcDevice.getDeviceType().toString(); + if (StringUtils.isNotEmpty(dcDevice.getFacilitiesType())){ + this.facilitiesType = dcDevice.getFacilitiesType(); + } + this.devStatus = dcDevice.getDeviceState(); + if (dcDevice.getGroupId() > 0){ + this.opmaManagerId = dcDevice.getGroupId().toString(); + } + this.supplierName = dcDevice.getManufacturer(); + } +} 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 864a86cd..028a80a3 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,10 +3,7 @@ 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; -import com.zc.business.domain.MdEvent; +import com.zc.business.domain.*; import java.util.List; @@ -27,6 +24,31 @@ public interface MiddleDatabaseMapper */ Boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData); + /** + * 新增中间库设备 + * + * @param mdDevice 设备 + * @return 结果 + */ + boolean insertMiddleDatabaseDeviceInfo(MdDevice mdDevice); + + /** + * 修改中间库设备 + * + * @param mdDevice 设备 + * @return 结果 + */ + boolean updateMiddleDatabaseDeviceInfo(MdDevice mdDevice); + + /** + * 删除中间库设备 + * 假删 + * + * @param ids 设备ids + * @return 结果 + */ + boolean deleteMiddleDatabaseDeviceInfoByIds(List ids); + /** * 更新中间库设备 * 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 1d669667..c6a30df9 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 @@ -2,10 +2,7 @@ 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; -import com.zc.business.domain.MdDeviceData; -import com.zc.business.domain.MdEvent; +import com.zc.business.domain.*; import java.util.List; @@ -35,7 +32,32 @@ public interface IMiddleDatabaseService boolean updateMiddleDatabaseDeviceByList(List listDevice); /** - * 更新中间库设备 + * 添加中间库设备 + * + * @param mdDevice 设备 + * @return 结果 + */ + boolean insertMiddleDatabaseDeviceInfo(MdDevice mdDevice); + + /** + * 修改中间库设备 + * + * @param mdDevice 设备 + * @return 结果 + */ + boolean updateMiddleDatabaseDeviceInfo(MdDevice mdDevice); + + /** + * 批量删除中间库设备 + * 假删 + * + * @param ids ids + * @return 结果 + */ + boolean deleteMiddleDatabaseDeviceInfoByIds(List ids); + + /** + * 更新中间库设备状态 * * @param device 设备 * @return 结果 diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java index 6d14e74b..1f4c0cce 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java @@ -10,10 +10,12 @@ import com.zc.business.constant.RedisKeyConstants; import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcProduct; import com.zc.business.domain.DcStakeMark; +import com.zc.business.domain.MdDevice; import com.zc.business.mapper.DcDeviceMapper; import com.zc.business.service.IDcDeviceService; import com.zc.business.service.IDcProductService; import com.zc.business.service.IDcStakeMarkService; +import com.zc.business.service.IMiddleDatabaseService; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -37,6 +39,8 @@ public class DcDeviceServiceImpl extends ServiceImpl i private IDcStakeMarkService dcStakeMarkService; @Resource private DcDeviceMapper dcDeviceMapper; + @Resource + private IMiddleDatabaseService middleDataBaseService; @Resource private RedisCache redisCache; @@ -211,6 +215,8 @@ public class DcDeviceServiceImpl extends ServiceImpl i if (Objects.isNull(dcProduct)) { throw new ServiceException("所属产品[" + productId + "]不存在", HttpStatus.BAD_REQUEST); } + //设备厂商 + dcDevice.setManufacturer(dcProduct.getManufacturer()); } dcDevice.setCreateTime(new Date()); @@ -219,6 +225,11 @@ public class DcDeviceServiceImpl extends ServiceImpl i if (save(dcDevice)) { // 更新缓存 updateRedisCache(); + + //中间库添加设备 + MdDevice mdDevice = new MdDevice(dcDevice); + middleDataBaseService.insertMiddleDatabaseDeviceInfo(mdDevice); + return true; } @@ -243,11 +254,27 @@ public class DcDeviceServiceImpl extends ServiceImpl i throw new ServiceException("设备ID[" + id + "]不存在", HttpStatus.BAD_REQUEST); } + Long productId = dcDevice.getProductId(); + if (Objects.nonNull(productId)) { + DcProduct dcProduct = dcProdurtService.getById(productId); + // 产品不存在 + if (Objects.isNull(dcProduct)) { + throw new ServiceException("所属产品[" + productId + "]不存在", HttpStatus.BAD_REQUEST); + } + //设备厂商 + dcDevice.setManufacturer(dcProduct.getManufacturer()); + } + dcDevice.setUpdateTime(new Date()); if (updateById(dcDevice)) { // 更新缓存 updateRedisCache(); + + //中间库修改设备 + MdDevice mdDevice = new MdDevice(dcDevice); + middleDataBaseService.updateMiddleDatabaseDeviceInfo(mdDevice); + return true; } @@ -275,6 +302,9 @@ public class DcDeviceServiceImpl extends ServiceImpl i if (removeByIds(ids)) { // 更新缓存 updateRedisCache(); + + //中间库 假删设备 + middleDataBaseService.deleteMiddleDatabaseDeviceInfoByIds(ids); return true; } 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 0ea93378..88e733f8 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 @@ -6,6 +6,7 @@ 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.MdDevice; import com.zc.business.domain.MdDeviceData; import com.zc.business.domain.MdEvent; import com.zc.business.mapper.MiddleDatabaseMapper; @@ -39,7 +40,6 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService { * @param mdDeviceData 气象检测器数据 * @return 结果 */ -// @DataSource(value = DataSourceType.SLAVE)//切换数据源 @Override public boolean insertMiddleDatabaseDeviceData(MdDeviceData mdDeviceData) { @@ -53,7 +53,6 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService { * @param listDevice 设备列表 * @return 结果 */ -// @DataSource(value = DataSourceType.SLAVE)//切换数据源 @Override public boolean updateMiddleDatabaseDeviceByList(List listDevice) { @@ -63,6 +62,42 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService { return true; } + /** + * 新增中间库设备 + * + * @param mdDevice 设备 + * @return 结果 + */ + @Override + public boolean insertMiddleDatabaseDeviceInfo(MdDevice mdDevice) + { + return middleDatabaseMapper.insertMiddleDatabaseDeviceInfo(mdDevice); + } + + /** + * 修改中间库设备 + * + * @param mdDevice 设备 + * @return 结果 + */ + @Override + public boolean updateMiddleDatabaseDeviceInfo(MdDevice mdDevice) + { + return middleDatabaseMapper.updateMiddleDatabaseDeviceInfo(mdDevice); + } + + /** + * 批量删除中间库设备 + * 假删 + * + * @param ids 设备ids + * @return 结果 + */ + @Override + public boolean deleteMiddleDatabaseDeviceInfoByIds(List ids) + { + return middleDatabaseMapper.deleteMiddleDatabaseDeviceInfoByIds(ids); + } /** * 更新中间库设备 @@ -70,7 +105,6 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService { * @param device 设备 * @return 结果 */ -// @DataSource(value = DataSourceType.SLAVE)//切换数据源 @Override public boolean updateMiddleDatabaseDevice(DcDevice device) { @@ -85,10 +119,10 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService { */ @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); } @@ -98,7 +132,6 @@ public class MiddleDatabaseServiceImpl implements IMiddleDatabaseService { * @param mdEvent 事件 * @return 结果 */ -// @DataSource(value = DataSourceType.SLAVE)//切换数据源 @Override public boolean updateMiddleDatabaseEvent(MdEvent mdEvent){ LoginUser loginUser = SecurityUtils.getLoginUser(); diff --git a/zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml b/zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml index f26ca694..a6f3a0cd 100644 --- a/zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml +++ b/zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml @@ -117,7 +117,84 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + insert into device + + id, + dev_no, + dev_name, + stake_num, + direction, + type_code, + facilities_type, + dev_status, + opma_manager_id, + opma_manager_name, + supplier_name, + section_id, + CreationTime, + CreatorUserId, + LastModificationTime, + LastModifierUserId, + IsDeleted, + DeleterUserId, + DeletionTime, + + + #{id}, + #{devNo}, + #{devName}, + #{stakeNum}, + #{direction}, + #{typeCode}, + #{facilitiesType}, + #{devStatus}, + #{opmaManagerId}, + #{opmaManagerName}, + #{supplierName}, + #{sectionId}, + now(), + #{creatorUserId}, + #{lastModificationTime}, + #{lastModifierUserId}, + #{isDeleted}, + #{deleterUserId}, + #{deletionTime}, + + + + + update device + + dev_no = #{devNo} + dev_name = #{devName} + stake_num = #{stakeNum} + direction = #{direction} + type_code = #{typeCode} + facilities_type = #{facilitiesType} + dev_status = #{devStatus} + opma_manager_id = #{opmaManagerId} + opma_manager_name = #{opmaManagerName} + supplier_name = #{supplierName} + section_id = #{sectionId} + LastModificationTime = now(), + LastModifierUserId = #{lastModifierUserId} + IsDeleted = #{isDeleted} + DeleterUserId = #{deleterUserId} + DeletionTime = #{deletionTime} + + where id = #{id} + + + + update device set IsDeleted = '1',DeletionTime = now() + where id in + + #{id} + + + + update device set dev_status = #{deviceState} where dev_no = #{iotDeviceId} @@ -164,4 +241,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + +