update - 能源整点数据

master
yinq 7 months ago
parent af49b3dead
commit 9779dd80f3

@ -107,14 +107,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) {
throw new ServiceException("计量设备编号重复:" + baseMonitorInfo.getMonitorId());
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);
@ -124,8 +129,8 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
updateMonitorChildren(baseMonitorInfo.getMonitorId(), newAncestors, oldAncestors);
}
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(), baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(), baseMonitorInfo.getSubentryId());
this.insertOrUpdateBaseTypeRelation(baseMonitorInfo.getMonitorId(),baseMonitorInfo.getBuildId(),
baseMonitorInfo.getBusinessId(),baseMonitorInfo.getSubentryId());
} catch (Exception e) {
e.printStackTrace();
}
@ -134,6 +139,33 @@ public class BaseMonitorInfo1ServiceImpl implements IBaseMonitorInfo1Service {
return baseMonitorInfoMapper.updateBaseMonitorInfo(baseMonitorInfo);
}
/**
*
*/
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);
}
}
/**
*
*

@ -121,7 +121,7 @@
<select id="energyConsumptionReportByTime" resultType="java.util.Map">
select ert.pointTime, sum(isnull(ert.expend,0)) expend
from (
select left(rpd.begin_time, #{timeSub}) pointTime, rpd.expend
select left(CONVERT(VARCHAR(17), rpd.begin_time, 120), #{timeSub}) pointTime, rpd.expend
from report_point_dnb rpd
left join base_monitor_info m on m.monitor_id = rpd.monitor_id
<where>
@ -138,7 +138,7 @@
and rpd.begin_time between #{startTime} and #{endTime}
</if>
<if test="startDay != null and startDay != '' and endDay != null and endDay != ''">
and left(rpd.begin_time, 10) between #{startDay} and #{endDay}
and left(CONVERT(VARCHAR(17), rpd.begin_time, 120), 10) between #{startDay} and #{endDay}
</if>
</where>
) ert
@ -149,7 +149,7 @@
<select id="energyConsumptionAnalysisDetails" resultType="java.util.Map">
select ert.monitor_id, ert.monitor_name, ert.pointTime, sum(isnull(ert.expend,0)) expend
from (
select rpd.monitor_id, m.monitor_name, left(rpd.begin_time, 10) pointTime, rpd.expend
select rpd.monitor_id, m.monitor_name, left(CONVERT(VARCHAR(17), rpd.begin_time, 120), 10) pointTime, rpd.expend
from report_point_dnb rpd
left join base_monitor_info m on m.monitor_id = rpd.monitor_id
<where>
@ -167,7 +167,7 @@
<!-- and rpd.begin_time between #{params.beginCollectTime} and #{params.endCollectTime}-->
<!-- </if>-->
<if test="startDay != null and startDay != '' and endDay != null and endDay != ''">
and left(rpd.begin_time, 10) between #{startDay} and #{endDay}
and left(CONVERT(VARCHAR(17), rpd.begin_time, 120), 10) between #{startDay} and #{endDay}
</if>
</where>
) ert
@ -178,21 +178,21 @@
<select id="datePointDnbList" parameterType="ReportPointDnb" resultMap="ReportPointDnbDTOResult">
select ert.monitor_id,
ert.monitor_name,
CASE
CAST( CASE
WHEN #{params.timeSub} = 10 THEN ert.pointTime
WHEN #{params.timeSub} = 7 THEN concat(ert.pointTime, '-01')
WHEN #{params.timeSub} = 4 THEN concat(ert.pointTime, '-01-01')
END AS begin_time,
CASE
END AS datetime) AS begin_time,
CAST( CASE
WHEN #{params.timeSub} = 10 THEN ert.pointTime
WHEN #{params.timeSub} = 7 THEN LAST_DAY(concat(ert.pointTime, '-01'))
WHEN #{params.timeSub} = 4 THEN LAST_DAY(concat(ert.pointTime, '-12-01'))
END AS end_time,
WHEN #{params.timeSub} = 7 THEN EOMONTH(CONVERT(DATE, CONCAT(ert.pointTime, '-01')))
WHEN #{params.timeSub} = 4 THEN EOMONTH(CONVERT(DATE, CONCAT(ert.pointTime, '-12-01')))
END AS datetime) AS end_time,
sum(isnull(ert.expend,0)) expend,
max(ert.meter_value) meter_value,
max(ert.monitor_addr) address
from (
select rpd.monitor_id, m.monitor_name, left(rpd.begin_time, #{params.timeSub}) pointTime, rpd.expend,
select rpd.monitor_id, m.monitor_name, left(CONVERT(VARCHAR(17), rpd.begin_time, 120), #{params.timeSub}) pointTime, rpd.expend,
rpd.meter_value,m.monitor_addr
from report_point_dnb rpd
left join base_monitor_info m on m.monitor_id = rpd.monitor_id
@ -243,7 +243,7 @@
left join base_public_user bpu on bmp.public_share_id = bpu.id
<where>
<if test="beginCollectTime != null and beginCollectTime != '' and endCollectTime != null and endCollectTime != ''">
and left(rpd.begin_time,10) between #{beginCollectTime} and #{endCollectTime}
and left(CONVERT(VARCHAR(17), rpd.begin_time, 120)e,10) between #{beginCollectTime} and #{endCollectTime}
</if>
<if test="monitorIdList != null and monitorIdList.size > 0">
and rpd.monitor_id IN

Loading…
Cancel
Save