change - ems计量设备、建筑对应关系优化

master
yinq 8 months ago
parent 3bff627053
commit 5e7340b2db

@ -1,84 +0,0 @@
package com.hw.ems.base.mapper;
import java.util.List;
import com.hw.ems.base.domain.BaseMonitorInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
*
* @author YinQ
* @date 2023-04-06
*/
@Mapper
public interface BaseMonitorInfoMapper
{
/**
*
*
* @param objid
* @return
*/
public BaseMonitorInfo selectBaseMonitorInfoByObjid(Long objid);
/**
*
*
* @param baseMonitorInfo
* @return
*/
public List<BaseMonitorInfo> selectBaseMonitorInfoList(BaseMonitorInfo baseMonitorInfo);
/**
*
*
* @param baseMonitorInfo
* @return
*/
public int insertBaseMonitorInfo(BaseMonitorInfo baseMonitorInfo);
/**
*
*
* @param baseMonitorInfo
* @return
*/
public int updateBaseMonitorInfo(BaseMonitorInfo baseMonitorInfo);
/**
*
*
* @param objid
* @return
*/
public int deleteBaseMonitorInfoByObjid(Long objid);
/**
*
*
* @param objids
* @return
*/
public int deleteBaseMonitorInfoByObjids(String[] objids);
/**
* MonitorId
* @param baseMonitor
* @return
*/
public List<BaseMonitorInfo> checkMonitorIdLegal(BaseMonitorInfo baseMonitor);
List<BaseMonitorInfo> selectChildrenMonitorById(String monitorId);
BaseMonitorInfo selectBaseMonitorInfoByMonitorId(String monitorId);
void updateMonitorChildren(@Param("monitor") List<BaseMonitorInfo> children);
List<BaseMonitorInfo> selectMonitorList(BaseMonitorInfo baseMonitorInfo);
List<BaseMonitorInfo> monitorLedgerList(BaseMonitorInfo baseMonitorInfo);
}

@ -96,7 +96,6 @@ public interface IBaseMonitorInfoService {
* @return
*/
ArrayList<BaseTypeRelation> selectTypeSubset(Long type);
List<BaseMonitorInfo> monitorLedgerList(BaseMonitorInfo baseMonitorInfo);
List<BaseMonitorInfo> selectMonitor(Long publicShareId);

@ -11,7 +11,7 @@ import com.hw.ems.base.domain.BaseDnbThreshold;
import com.hw.ems.base.domain.BaseMonitorInfo;
import com.hw.ems.base.domain.vo.TreeSelect;
import com.hw.ems.base.mapper.BaseDnbThresholdMapper;
import com.hw.ems.base.mapper.BaseMonitorInfoMapper;
import com.hw.ems.base.mapper.BaseMonitorInfo1Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.ems.base.service.IBaseDnbThresholdService;
@ -27,7 +27,7 @@ public class BaseDnbThresholdServiceImpl implements IBaseDnbThresholdService {
@Autowired
private BaseDnbThresholdMapper baseDnbThresholdMapper;
@Autowired
private BaseMonitorInfoMapper baseMonitorInfoMapper;
private BaseMonitorInfo1Mapper baseMonitorInfoMapper;
/**
*
@ -113,7 +113,7 @@ public class BaseDnbThresholdServiceImpl implements IBaseDnbThresholdService {
//@DataScope(deptAlias = "d")
//@DS("#header.poolName")
public List<BaseMonitorInfo> selectMonitorList(BaseMonitorInfo baseMonitorInfo) {
return baseMonitorInfoMapper.selectMonitorList(baseMonitorInfo);
return baseMonitorInfoMapper.selectBaseMonitorInfoList(baseMonitorInfo);
}
//@Override

@ -94,46 +94,23 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
if (baseMonitorInfos.size() != 0) {
throw new ServiceException("计量设备编号重复:" + baseMonitorInfo.getMonitorId());
}
//todo 新增父级为空判断,父级为空时会导致创建子表与创建计量设备与类型的对应对象失效
try {
BaseMonitorInfo monitor = baseMonitorInfoMapper.selectBaseMonitorInfoByObjid(baseMonitorInfo.getParentId());
if (baseMonitorInfo.getParentId()==0){
baseMonitorInfo.setAncestors(baseMonitorInfo.getMonitorId());
}
else {
if (monitor != null) {
baseMonitorInfo.setAncestors(monitor.getAncestors() + "," + baseMonitorInfo.getMonitorId());
String[] split = baseMonitorInfo.getAncestors().split(",");
monitor.setAncestors(monitor.getAncestors() + "," + monitor.getMonitorId());
String[] split = monitor.getAncestors().split(",");
monitor.setGrade(split.length);
}
}
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(), baseMonitorInfo.getSubentryId());
List<BaseMonitorInfo> subsetList = this.selectMonitorSubsetList(new BaseMonitorInfo());
// 添加线损对象
this.insertLineLossList(subsetList);
// List<BaseMonitorInfo> subsetList = this.selectMonitorSubsetList(new BaseMonitorInfo());
//添加线损对象
// this.insertLineLossList(subsetList);
} catch (Exception e) {
System.out.println("新增计量设备信息异常:" + e.getMessage());
}
baseMonitorInfo.setCreateTime(DateUtils.getNowDate());
baseMonitorInfo.setCreateBy(SecurityUtils.getUsername());
//修改父级等级
// baseMonitorInfoMapper.updateBaseMonitorInfo(monitor);
int result = baseMonitorInfoMapper.insertBaseMonitorInfo(baseMonitorInfo);
//创建TDEngine子表
this.createEmsTbale(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(), baseMonitorInfo.getMonitorName(), baseMonitorInfo.getObjid());
return result;
} catch (Exception e) {
System.out.println("新增计量设备信息异常1111:" + e.getMessage());
//捕获异常时回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return 0;
return baseMonitorInfoMapper.insertBaseMonitorInfo(baseMonitorInfo);
}
/**
@ -221,14 +198,19 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
@Override
//@DS("#header.poolName")
public int updateBaseMonitorInfo(BaseMonitorInfo baseMonitorInfo) {
// 异常处理:若设备停用则更新所有父级
if (StringUtils.isNotNull(baseMonitorInfo.getMonitorStatus()) && baseMonitorInfo.getMonitorStatus().equals(1L)){
this.updateAllBaseMonitorInfo();
}
List<BaseMonitorInfo> baseMonitorInfos = baseMonitorInfoMapper.checkMonitorIdLegal(baseMonitorInfo);
if (baseMonitorInfos.size() > 1) {
if (baseMonitorInfos.size() > 1){
throw new ServiceException("计量设备编号重复:" + baseMonitorInfo.getMonitorId());
}
try {
BaseMonitorInfo newParenMonitorInfo = baseMonitorInfoMapper.selectBaseMonitorInfoByObjid(baseMonitorInfo.getParentId());
BaseMonitorInfo oldDeptMonitorInfo = selectBaseMonitorInfoByObjid(baseMonitorInfo.getObjid());
if (StringUtils.isNotNull(newParenMonitorInfo) && StringUtils.isNotNull(oldDeptMonitorInfo)) {
if (StringUtils.isNotNull(newParenMonitorInfo) && StringUtils.isNotNull(oldDeptMonitorInfo))
{
String newAncestors = newParenMonitorInfo.getAncestors() + "," + oldDeptMonitorInfo.getMonitorId();
String oldAncestors = oldDeptMonitorInfo.getAncestors();
baseMonitorInfo.setAncestors(newAncestors);
@ -238,18 +220,14 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
updateMonitorChildren(baseMonitorInfo.getMonitorId(), newAncestors, oldAncestors);
}
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(), baseMonitorInfo.getSubentryId());
baseMonitorInfo.setUpdateTime(DateUtils.getNowDate());
baseMonitorInfo.setUpdateBy(SecurityUtils.getUsername());
int result = baseMonitorInfoMapper.updateBaseMonitorInfo(baseMonitorInfo);
this.updateTdEngineTable(baseMonitorInfo, oldDeptMonitorInfo);
return result;
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(),baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(),baseMonitorInfo.getSubentryId());
} catch (Exception e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return 0;
baseMonitorInfo.setUpdateTime(DateUtils.getNowDate());
baseMonitorInfo.setUpdateBy(SecurityUtils.getUsername());
return baseMonitorInfoMapper.updateBaseMonitorInfo(baseMonitorInfo);
}
/**
@ -270,6 +248,31 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
}
/**
*
*/
private void updateAllBaseMonitorInfo() {
List<BaseMonitorInfo> monitorInfoList = this.selectBaseMonitorInfoList(new BaseMonitorInfo());
for (BaseMonitorInfo baseMonitorInfo : monitorInfoList) {
BaseMonitorInfo newParenMonitorInfo = baseMonitorInfoMapper.selectBaseMonitorInfoByObjid(baseMonitorInfo.getParentId());
BaseMonitorInfo oldDeptMonitorInfo = selectBaseMonitorInfoByObjid(baseMonitorInfo.getObjid());
if (StringUtils.isNotNull(newParenMonitorInfo) && StringUtils.isNotNull(oldDeptMonitorInfo)) {
String newAncestors = newParenMonitorInfo.getAncestors() + "," + oldDeptMonitorInfo.getMonitorId();
String oldAncestors = oldDeptMonitorInfo.getAncestors();
baseMonitorInfo.setAncestors(newAncestors);
String[] split = baseMonitorInfo.getAncestors().split(",");
baseMonitorInfo.setGrade(split.length);
updateMonitorChildren(baseMonitorInfo.getMonitorId(), newAncestors, oldAncestors);
}
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(), baseMonitorInfo.getSubentryId());
baseMonitorInfo.setUpdateTime(DateUtils.getNowDate());
baseMonitorInfo.setUpdateBy(SecurityUtils.getUsername());
baseMonitorInfoMapper.updateBaseMonitorInfo(baseMonitorInfo);
}
}
/**
* @param: baseMonitorInfo

@ -26,7 +26,7 @@ import java.util.stream.Collectors;
@Service
public class BaseMonitorInfoServiceImpl implements IBaseMonitorInfoService {
@Autowired
private BaseMonitorInfoMapper baseMonitorInfoMapper;
private BaseMonitorInfo1Mapper baseMonitorInfoMapper;
@Autowired
private BaseBusinessTypeMapper baseBusinessTypeMapper;
@ -208,7 +208,7 @@ public class BaseMonitorInfoServiceImpl implements IBaseMonitorInfoService {
@Override
//@DS("#header.poolName")
public int deleteBaseMonitorInfoByObjids(String objids) {
return baseMonitorInfoMapper.deleteBaseMonitorInfoByObjids(Convert.toStrArray(objids));
return baseMonitorInfoMapper.deleteBaseMonitorInfoByObjids(Convert.toLongArray(objids));
}
/**
@ -490,12 +490,6 @@ public class BaseMonitorInfoServiceImpl implements IBaseMonitorInfoService {
return typeRelations;
}
@Override
//@DS("#header.poolName")
public List<BaseMonitorInfo> monitorLedgerList(BaseMonitorInfo baseMonitorInfo) {
return baseMonitorInfoMapper.monitorLedgerList(baseMonitorInfo);
}
@Override
//@DS("#header.poolName")
public List<BaseMonitorInfo> selectMonitor(Long publicShareId) {

@ -10,7 +10,7 @@ import com.hw.ems.base.domain.BaseMonitorInfo;
import com.hw.ems.base.domain.BaseTypeRelation;
import com.hw.ems.base.mapper.BaseLineLossMapper;
import com.hw.ems.base.mapper.BaseLineMonitorMapper;
import com.hw.ems.base.mapper.BaseMonitorInfoMapper;
import com.hw.ems.base.mapper.BaseMonitorInfo1Mapper;
import com.hw.ems.base.mapper.BaseTypeRelationMapper;
import com.hw.ems.base.service.IBaseMonitorInfoService;
import com.hw.ems.report.domain.ExportReport;
@ -55,7 +55,7 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
private BaseLineLossMapper baseLineLossMapper;
@Autowired
private BaseMonitorInfoMapper baseMonitorInfoMapper;
private BaseMonitorInfo1Mapper baseMonitorInfoMapper;
@Autowired
private BaseTypeRelationMapper baseTypeRelationMapper;

@ -2,7 +2,7 @@ package com.hw.ems.report.service.impl;
import com.hw.common.core.text.Convert;
import com.hw.common.core.utils.DateUtils;
import com.hw.ems.base.mapper.BaseMonitorInfoMapper;
import com.hw.ems.base.mapper.BaseMonitorInfo1Mapper;
import com.hw.ems.report.domain.ReportPointDnb;
import com.hw.ems.report.domain.ReportPointDnbDTO;
import com.hw.ems.report.mapper.ReportPointDnbMapper;
@ -27,7 +27,7 @@ public class ReportPointDnbServiceImpl implements IReportPointDnbService {
private ReportPointDnbMapper reportPointDnbMapper;
@Autowired
private BaseMonitorInfoMapper monitorInfoMapper;
private BaseMonitorInfo1Mapper monitorInfoMapper;
/**
*

@ -37,7 +37,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="roomCode" column="room_code" />
<result property="roomName" column="room_name" />
<result property="physicalCode" column="physical_code" />
<result property="feeType" column="fee_type" />
<result property="relationId" column="relation_id" />
<result property="submitFlag" column="submit_flag" />
</resultMap>
@ -45,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectBaseMonitorInfoVo">
select objid, parent_id, monitor_id, monitor_name, monitor_addr, monitor_type, monitor_status,
collect_device_id, ancestors, grade, build_id, subentry_id, business_id, meter_type_id,
meter_id, correct_value, pt, ct, is_ammeter, is_key_monitor, is_circuit, dept_id, user_id,fee_type,
meter_id, correct_value, pt, ct, is_ammeter, is_key_monitor, is_circuit, dept_id, user_id,
create_by, create_time, update_by, update_time, public_share_type,monitor_hierarchy,room_code,room_name,physical_code from base_monitor_info
</sql>
@ -65,7 +64,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="subentryId != null and subentryId != ''"> and subentry_id = #{subentryId}</if>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="meterTypeId != null and meterTypeId != ''"> and meter_type_id = #{meterTypeId}</if>
<if test="feeType != null and feeType != ''"> and fee_type = #{feeType}</if>
<if test="meterId != null and meterId != ''"> and meter_id = #{meterId}</if>
<if test="correctValue != null "> and correct_value = #{correctValue}</if>
<if test="pt != null "> and pt = #{pt}</if>
@ -129,7 +127,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bmi.room_code,
bmi.room_name,
bmi.physical_code,
bmi.fee_type,
bt.relation_id
from base_monitor_info bmi
left join (SELECT monitor_id, relation_id
@ -185,7 +182,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roomCode != null">room_code,</if>
<if test="roomName != null">room_name,</if>
<if test="physicalCode != null">physical_code,</if>
<if test="feeType != null">fee_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
@ -219,7 +215,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roomCode != null">#{roomCode},</if>
<if test="roomName != null">#{roomName},</if>
<if test="physicalCode != null">#{physicalCode},</if>
<if test="feeType != null">#{feeType},</if>
</trim>
</insert>
@ -256,8 +251,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roomCode != null">room_code = #{roomCode},</if>
<if test="roomName != null">room_name = #{roomName},</if>
<if test="physicalCode != null">physical_code = #{physicalCode},</if>
<if test="feeType != null">fee_type = #{feeType},</if>
<if test="submitFlag != null">submit_flag = #{submitFlag},</if>
monitor_hierarchy = #{monitorHierarchy},
</trim>
where objid = #{objid}

@ -1,260 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.ems.base.mapper.BaseMonitorInfoMapper">
<resultMap type="BaseMonitorInfo" id="BaseMonitorInfoResult">
<result property="objid" column="objid" />
<result property="parentId" column="parent_id" />
<result property="monitorId" column="monitor_id" />
<result property="monitorName" column="monitor_name" />
<result property="monitorAddr" column="monitor_addr" />
<result property="monitorType" column="monitor_type" />
<result property="monitorStatus" column="monitor_status" />
<result property="collectDeviceId" column="collect_device_id" />
<result property="ancestors" column="ancestors" />
<result property="grade" column="grade" />
<result property="buildId" column="build_id" />
<result property="subentryId" column="subentry_id" />
<result property="businessId" column="business_id" />
<result property="meterTypeId" column="meter_type_id" />
<result property="meterId" column="meter_id" />
<result property="correctValue" column="correct_value" />
<result property="pt" column="pt" />
<result property="ct" column="ct" />
<result property="isAmmeter" column="is_ammeter" />
<result property="isKeyMonitor" column="is_key_monitor" />
<result property="isCircuit" column="is_circuit" />
<result property="deptId" column="dept_id" />
<result property="userId" column="user_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="parentName" column="parent_name" />
</resultMap>
<sql id="selectBaseMonitorInfoVo">
select objid, parent_id, monitor_id, monitor_name, monitor_addr, monitor_type,
monitor_status, collect_device_id, ancestors, grade, build_id, subentry_id,
business_id, meter_type_id, meter_id, correct_value, pt, ct, is_ammeter,
is_key_monitor, is_circuit, dept_id, user_id, create_by, create_time, update_by, update_time from base_monitor_info
</sql>
<select id="selectBaseMonitorInfoList" parameterType="BaseMonitorInfo" resultMap="BaseMonitorInfoResult">
<include refid="selectBaseMonitorInfoVo"/>
<where>
<if test="monitorName != null and monitorName != ''"> and monitor_name like concat('%', #{monitorName}, '%')</if>
<if test="monitorAddr != null and monitorAddr != ''"> and monitor_addr = #{monitorAddr}</if>
<if test="monitorId != null and monitorId != ''"> and monitor_id = #{monitorId}</if>
<if test="parentId != null and parentId != ''"> and parent_id = #{parentId}</if>
<if test="monitorType != null "> and monitor_type = #{monitorType}</if>
<if test="monitorStatus != null "> and monitor_status = #{monitorStatus}</if>
<if test="collectDeviceId != null and collectDeviceId != ''"> and collect_device_id = #{collectDeviceId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="grade != null "> and grade = #{grade}</if>
<if test="buildId != null and buildId != ''"> and build_id = #{buildId}</if>
<if test="subentryId != null and subentryId != ''"> and subentry_id = #{subentryId}</if>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="meterTypeId != null and meterTypeId != ''"> and meter_type_id = #{meterTypeId}</if>
<if test="publicShareType != null "> and public_share_type = #{publicShareType}</if>
<if test="meterId != null and meterId != ''"> and meter_id = #{meterId}</if>
<if test="correctValue != null "> and correct_value = #{correctValue}</if>
<if test="pt != null "> and pt = #{pt}</if>
<if test="ct != null "> and ct = #{ct}</if>
<if test="isAmmeter != null and isAmmeter != ''"> and is_ammeter = #{isAmmeter}</if>
<if test="isCircuit != null "> and is_circuit = #{isCircuit}</if>
</where>
order by parent_id,monitor_name
</select>
<select id="selectBaseMonitorInfoByObjid" parameterType="Long" resultMap="BaseMonitorInfoResult">
select t.objid, t.parent_id, t.monitor_id, t.monitor_name, t.monitor_addr, t.monitor_type, t.monitor_status, t.collect_device_id, t.ancestors, t.grade, t.build_id, t.subentry_id, t.business_id, t.meter_type_id, t.meter_id, t.correct_value, t.pt, t.ct, t.is_ammeter, t.is_key_monitor, t.is_circuit, t.dept_id, t.user_id, t.create_by, t.create_time, t.update_by, t.update_time, p.monitor_name as parent_name
from base_monitor_info t
left join base_monitor_info p on p.objid = t.parent_id
where t.objid = #{objid}
</select>
<select id="checkMonitorIdLegal" parameterType="BaseMonitorInfo" resultMap="BaseMonitorInfoResult">
select t.objid, t.parent_id, t.monitor_id, t.monitor_name, t.monitor_addr, t.monitor_type
from base_monitor_info t
<where>
<if test="monitorId != null and monitorId != ''"> and t.monitor_id like concat('%', #{monitorId}, '%')</if>
</where>
</select>
<select id="selectChildrenMonitorById" parameterType="String" resultMap="BaseMonitorInfoResult">
select * from base_monitor_info where find_in_set(#{monitorId}, ancestors)
</select>
<select id="selectBaseMonitorInfoByMonitorId" parameterType="String" resultMap="BaseMonitorInfoResult">
select * from base_monitor_info where monitor_id = #{monitorId}
</select>
<update id="updateMonitorChildren" parameterType="java.util.List">
update base_monitor_info set ancestors =
<foreach collection="monitor" item="item" index="index"
separator=" " open="case monitor_id" close="end">
when #{item.monitorId} then #{item.ancestors}
</foreach>
where monitor_id in
<foreach collection="monitor" item="item" index="index"
separator="," open="(" close=")">
#{item.monitorId}
</foreach>
</update>
<insert id="insertBaseMonitorInfo" parameterType="BaseMonitorInfo" useGeneratedKeys="true" keyProperty="objid">
insert into base_monitor_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="monitorId != null">monitor_id,</if>
<if test="monitorName != null">monitor_name,</if>
<if test="monitorAddr != null">monitor_addr,</if>
<if test="monitorType != null">monitor_type,</if>
<if test="monitorStatus != null">monitor_status,</if>
<if test="collectDeviceId != null">collect_device_id,</if>
<if test="ancestors != null">ancestors,</if>
<if test="grade != null">grade,</if>
<if test="buildId != null">build_id,</if>
<if test="subentryId != null">subentry_id,</if>
<if test="businessId != null">business_id,</if>
<if test="meterTypeId != null">meter_type_id,</if>
<if test="meterId != null">meter_id,</if>
<if test="correctValue != null">correct_value,</if>
<if test="pt != null">pt,</if>
<if test="ct != null">ct,</if>
<if test="isAmmeter != null">is_ammeter,</if>
<if test="isKeyMonitor != null">is_key_monitor,</if>
<if test="isCircuit != null">is_circuit,</if>
<if test="deptId != null">dept_id,</if>
<if test="userId != null">user_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="monitorId != null">#{monitorId},</if>
<if test="monitorName != null">#{monitorName},</if>
<if test="monitorAddr != null">#{monitorAddr},</if>
<if test="monitorType != null">#{monitorType},</if>
<if test="monitorStatus != null">#{monitorStatus},</if>
<if test="collectDeviceId != null">#{collectDeviceId},</if>
<if test="ancestors != null">#{ancestors},</if>
<if test="grade != null">#{grade},</if>
<if test="buildId != null">#{buildId},</if>
<if test="subentryId != null">#{subentryId},</if>
<if test="businessId != null">#{businessId},</if>
<if test="meterTypeId != null">#{meterTypeId},</if>
<if test="meterId != null">#{meterId},</if>
<if test="correctValue != null">#{correctValue},</if>
<if test="pt != null">#{pt},</if>
<if test="ct != null">#{ct},</if>
<if test="isAmmeter != null">#{isAmmeter},</if>
<if test="isKeyMonitor != null">#{isKeyMonitor},</if>
<if test="isCircuit != null">#{isCircuit},</if>
<if test="deptId != null">#{deptId},</if>
<if test="userId != null">#{userId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateBaseMonitorInfo" parameterType="BaseMonitorInfo">
update base_monitor_info
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="monitorId != null">monitor_id = #{monitorId},</if>
<if test="monitorName != null">monitor_name = #{monitorName},</if>
<if test="monitorAddr != null">monitor_addr = #{monitorAddr},</if>
<if test="monitorType != null">monitor_type = #{monitorType},</if>
<if test="monitorStatus != null">monitor_status = #{monitorStatus},</if>
<if test="collectDeviceId != null">collect_device_id = #{collectDeviceId},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="grade != null">grade = #{grade},</if>
<if test="buildId != null">build_id = #{buildId},</if>
<if test="subentryId != null">subentry_id = #{subentryId},</if>
<if test="businessId != null">business_id = #{businessId},</if>
<if test="meterTypeId != null">meter_type_id = #{meterTypeId},</if>
<if test="meterId != null">meter_id = #{meterId},</if>
<if test="correctValue != null">correct_value = #{correctValue},</if>
<if test="pt != null">pt = #{pt},</if>
<if test="ct != null">ct = #{ct},</if>
<if test="isAmmeter != null">is_ammeter = #{isAmmeter},</if>
<if test="isKeyMonitor != null">is_key_monitor = #{isKeyMonitor},</if>
<if test="isCircuit != null">is_circuit = #{isCircuit},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where objid = #{objid}
</update>
<delete id="deleteBaseMonitorInfoByObjid" parameterType="Long">
delete from base_monitor_info where objid = #{objid}
</delete>
<delete id="deleteBaseMonitorInfoByObjids" parameterType="String">
delete from base_monitor_info where objid in
<foreach item="objid" collection="array" open="(" separator="," close=")">
#{objid}
</foreach>
</delete>
<select id="selectMonitorList" resultType="BaseMonitorInfo">
select objid,
parent_id parentId,
monitor_id monitorId,
monitor_name monitorName
from base_monitor_info
where 1=1
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
<if test="monitorName != null and monitorName != ''">
AND monitor_name like concat('%', #{monitorName}, '%')
</if>
<if test="monitorType != null and monitorType != ''">
and monitor_type = #{monitorType}
</if>
<!-- 数据范围过滤
${params.dataScope}-->
order by parent_id<!--, d.order_num-->
</select>
<select id="monitorLedgerList" parameterType="BaseMonitorInfo" resultMap="BaseMonitorInfoResult">
select objid,is_key_monitor parent_id, monitor_id, monitor_name, monitor_addr, monitor_type,
monitor_status, collect_device_id, ancestors, grade, build_id, subentry_id,
business_id, meter_type_id, meter_id, correct_value, pt, ct, is_ammeter,
is_key_monitor, is_circuit, dept_id, user_id, create_by, create_time, update_by, update_time from base_monitor_info
<where>
<if test="monitorName != null and monitorName != ''"> and monitor_name like concat('%', #{monitorName}, '%')</if>
<if test="monitorAddr != null and monitorAddr != ''"> and monitor_addr = #{monitorAddr}</if>
<if test="monitorId != null and monitorId != ''"> and monitor_id = #{monitorId}</if>
<if test="parentId != null and parentId != ''"> and parent_id = #{parentId}</if>
<if test="monitorType != null "> and monitor_type = #{monitorType}</if>
<if test="monitorStatus != null "> and monitor_status = #{monitorStatus}</if>
<if test="collectDeviceId != null and collectDeviceId != ''"> and collect_device_id = #{collectDeviceId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="grade != null "> and grade = #{grade}</if>
<if test="buildId != null and buildId != ''"> and build_id = #{buildId}</if>
<if test="subentryId != null and subentryId != ''"> and subentry_id = #{subentryId}</if>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="meterTypeId != null and meterTypeId != ''"> and meter_type_id = #{meterTypeId}</if>
<if test="meterId != null and meterId != ''"> and meter_id = #{meterId}</if>
<if test="correctValue != null "> and correct_value = #{correctValue}</if>
<if test="pt != null "> and pt = #{pt}</if>
<if test="ct != null "> and ct = #{ct}</if>
<if test="isAmmeter != null and isAmmeter != ''"> and is_ammeter = #{isAmmeter}</if>
<if test="isCircuit != null "> and is_circuit = #{isCircuit}</if>
</where>
order by parent_id,monitor_name
</select>
</mapper>

@ -35,15 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.monitor_name,
case
when base_type_relation.type = 0 then bi.build_name
when base_type_relation.type = 1 then bt.business_name
when base_type_relation.type = 2 then st.subentry_name
end unit_name,
base_type_relation.rate, base_type_relation.formula_mode
from base_type_relation
left join base_monitor_info m on m.monitor_id = base_type_relation.monitor_id
left join base_build_info bi on base_type_relation.relation_id = bi.objid
left join base_business_type bt on base_type_relation.relation_id = bt.objid
left join base_subentry_type st on base_type_relation.relation_id = st.objid
</sql>
<select id="selectBaseTypeRelationList" parameterType="BaseTypeRelation" resultMap="BaseTypeRelationResult">
@ -77,15 +73,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
m.monitor_name,
case
when btr.type = 0 then bi.build_name
when btr.type = 1 then bt.business_name
when btr.type = 2 then st.subentry_name end unit_name,
end unit_name,
btr.rate,
btr.formula_mode
from base_type_relation btr
left join base_monitor_info m on m.monitor_id = btr.monitor_id
left join base_build_info bi on btr.relation_id = bi.objid and bi.parent_id = 1
left join base_business_type bt on btr.relation_id = bt.objid and bt.parent_id = 1
left join base_subentry_type st on btr.relation_id = st.objid and st.parent_id = 1
) btr
<where>
btr.unit_name is not null

Loading…
Cancel
Save