新增威伟电表修正定时任务

master
FCD 1 day ago
parent 2948e25e84
commit b170e910a5

@ -8,6 +8,8 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
/** auth YangWl
*
*/
@ -26,4 +28,7 @@ public interface RemoteEnergyService {
@PostMapping(value = "/record/dnbInstant/getNhEnergyDetail")
public R SyncNhEnergyDetail();
@PostMapping(value = "/record/dnbInstant/fixWwEnergyData",headers = {"poolName=ds_1000"})
public R syncFixWwEnergyData(@RequestBody Map<String ,String> map);
}

@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class RemoteEnergyFallbackFactory implements FallbackFactory<RemoteEnergyService> {
private static final Logger log = LoggerFactory.getLogger(RemoteEnergyFallbackFactory.class);
@ -36,6 +38,11 @@ public class RemoteEnergyFallbackFactory implements FallbackFactory<RemoteEnergy
public R SyncNhEnergyDetail() {
return R.fail("同步电表实时数据失败:" + throwable.getMessage());
}
@Override
public R syncFixWwEnergyData(Map<String ,String> map) {
return R.fail("修正威伟电表数据失败:" + throwable.getMessage());
}
};
}
}

@ -200,6 +200,8 @@ public class BaseMonitorInfo extends BaseEntity {
private Boolean flag;
private String electricityMeterType;
public String getPhysicalCode() {
return physicalCode;
}
@ -481,6 +483,14 @@ public class BaseMonitorInfo extends BaseEntity {
this.connCode = connCode;
}
public String getElectricityMeterType() {
return electricityMeterType;
}
public void setElectricityMeterType(String electricityMeterType) {
this.electricityMeterType = electricityMeterType;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* Controller
@ -209,5 +210,28 @@ public class RecordDnbInstantController extends BaseController {
return AjaxResult.success();
}
/**
*
* **/
@PostMapping("/testGetNhEnergyDetail")
@ResponseBody
public void testGetNhEnergyDetail( HttpServletResponse response ,@RequestBody Map<String,String> params) {
List<RecordDnbInstant> list = recordDnbInstantService.testGetNhEnergyDetail(params);
ExcelUtil<RecordDnbInstant> util = new ExcelUtil<RecordDnbInstant>(RecordDnbInstant.class);
util.exportExcel(response, list, "导出");
}
/**
*
* **/
@PostMapping("/fixWwEnergyData")
@ResponseBody
public AjaxResult fixWwEnergyData(@RequestBody Map<String,String> params ) {
recordDnbInstantService.fixWwEnergyData(params);
return AjaxResult.success();
}
}

@ -32,7 +32,6 @@ public class RecordDnbInstant extends BaseEntity {
/**
*
*/
@Excel(name = "计量设备名称")
private String monitorName;
/**
@ -51,37 +50,31 @@ public class RecordDnbInstant extends BaseEntity {
/**
* A
*/
@Excel(name = "A项电压")
private BigDecimal vA;
/**
* B
*/
@Excel(name = "B项电压")
private BigDecimal vB;
/**
* C
*/
@Excel(name = "C项电压")
private BigDecimal vC;
/**
* A
*/
@Excel(name = "A项电流")
private BigDecimal iA;
/**
* B
*/
@Excel(name = "B项电流")
private BigDecimal iB;
/**
* C
*/
@Excel(name = "C项电流")
private BigDecimal iC;
/**
@ -92,7 +85,6 @@ public class RecordDnbInstant extends BaseEntity {
/**
*
*/
@Excel(name = "功率因数")
private BigDecimal glys;
/**
@ -104,25 +96,21 @@ public class RecordDnbInstant extends BaseEntity {
/**
*
*/
@Excel(name = "有功功率")
private BigDecimal activePower;
/**
*
*/
@Excel(name = "无功功率")
private BigDecimal reactivePower;
/**
*
*/
@Excel(name = "电耗量")
private BigDecimal consumption;
/**
*
*/
@Excel(name = "采集方式")
private Long collectType;
/**

@ -4,6 +4,7 @@ package com.op.energy.record.service;
import com.op.energy.record.domain.RecordDnbInstant;
import java.util.List;
import java.util.Map;
/**
* Service
@ -89,4 +90,8 @@ public interface IRecordDnbInstantService {
void getNhEnergyDetail();
void getNhEnergy();
List<RecordDnbInstant> testGetNhEnergyDetail(Map<String,String> params);
void fixWwEnergyData(Map<String,String> params);
}

@ -454,4 +454,46 @@ public class RecordDnbInstantServiceImpl implements IRecordDnbInstantService {
return defaultValue;
}
}
@Override
public List<RecordDnbInstant> testGetNhEnergyDetail(Map<String,String> params) {
List<RecordDnbInstant> list = new ArrayList<>();
/**
* /
* **/
AjaxResult electricQuantityRes= remoteOpenService.getElectricQuantity(params);
if(electricQuantityRes.isSuccess()){
JSONObject resData = JSONObject.parseObject(JSON.toJSONString(electricQuantityRes.get(AjaxResult.DATA_TAG)));
JSONArray array = JSONArray.parseArray(resData.get("Data").toString());
for (int i = 0; i < array.size(); i++) {
RecordDnbInstant instant = new RecordDnbInstant();
instant.setMonitorId(array.getJSONObject(i).getString("Address"));
instant.setZxyg(getSafeBigDecimal(array.getJSONObject(i), "ZYGDNSZ"));
instant.setCollectTime(DateUtils.dateTime("yyyy-MM-dd HH:mm", array.getJSONObject(i).getString("ReadingDate")));
list.add(instant);
}
}
return list;
}
@Override
@DS("#header.poolName")
public void fixWwEnergyData(Map<String,String> params) {
//获取威伟电表
BaseMonitorInfo query = new BaseMonitorInfo();
query.setElectricityMeterType("2");
List<BaseMonitorInfo> list = baseMonitorInfoMapper.selectBaseMonitorInfoList(query);
for (BaseMonitorInfo info : list) {
params.put("monitorId", info.getMonitorId());
reportPointDnbMapper.fixWwEnergyData(params);
}
}
}

@ -81,6 +81,7 @@
<if test="roomCode != null ">and room_code = #{roomCode}</if>
<if test="addressCode != null ">and address_code = #{addressCode}</if>
<if test="connCode != null ">and conn_code = #{connCode}</if>
<if test="electricityMeterType != null ">and electricity_meter_type = #{electricityMeterType}</if>
</where>
</select>

@ -506,4 +506,67 @@
order by ert.pointTime asc
</select>
<select id="fixWwEnergyData" resultType="Integer" parameterType="java.util.Map" >
UPDATE a
SET expend = b.expend
FROM report_point_dnb a
INNER JOIN (
SELECT objId, expend
FROM (
SELECT
objId,
meter_value - ISNULL( LAG ( meter_value, 1 ) OVER ( PARTITION BY monitor_id ORDER BY record_time ), 0 ) AS expend,
ROW_NUMBER ( ) OVER ( ORDER BY record_time ) AS row_num
FROM report_point_dnb
WHERE DATEPART( MINUTE, record_time ) = 0
AND DATEPART( SECOND, record_time ) = 0
<if test="params.beginDate != null and params.beginDate != ''">
AND CONVERT ( VARCHAR, record_time, 23 ) >= #{params.beginDate}
AND CONVERT ( VARCHAR, record_time, 23 ) <![CDATA[ <= ]]> #{params.endDate}
</if>
<if test="params.beginDate == null || params.beginDate == ''">
AND CONVERT ( VARCHAR, record_time, 23 ) >= CONVERT(varchar, DATEADD(day, -2, GETDATE()), 23)
</if>
AND monitor_id = #{params.monitorId}
) n
WHERE row_num != 1
) b ON a.objid = b.objId
WHERE a.objid IN (
SELECT objId
FROM report_point_dnb
WHERE monitor_id = #{params.monitorId}
<if test="params.beginDate != null and params.beginDate != ''">
AND CONVERT ( VARCHAR, record_time, 23 ) >= #{params.beginDate}
AND CONVERT ( VARCHAR, record_time, 23 ) <![CDATA[ <= ]]> #{params.endDate}
</if>
<if test="params.beginDate == null || params.beginDate == ''">
AND CONVERT ( VARCHAR, record_time, 23 ) >= CONVERT(varchar, DATEADD(day, -2, GETDATE()), 23)
</if>
)
</select>
<insert id="batchInsertReportPointDnb" parameterType="java.util.List">
INSERT INTO report_point_dnb
(
monitor_id, monitor_name, begin_time, end_time,
record_time, expend, meter_value, collect_type
)
SELECT
t.monitorId, t.monitorName, t.beginTime, t.endTime,
t.recordTime, t.expend, t.meterValue, t.collectType
FROM (
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.monitorId,jdbcType=VARCHAR} AS monitorId,
#{item.monitorName,jdbcType=VARCHAR} AS monitorName,
#{item.beginTime,jdbcType=TIMESTAMP} AS beginTime,
#{item.endTime,jdbcType=TIMESTAMP} AS endTime,
GETDATE() AS recordTime,
#{item.expend,jdbcType=DECIMAL} AS expend,
#{item.meterValue,jdbcType=DECIMAL} AS meterValue,
'1' AS collectType
</foreach>
) t
</insert>
</mapper>

@ -11,7 +11,9 @@ import org.springframework.stereotype.Component;
import com.op.common.core.utils.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@ -291,5 +293,23 @@ public class RyTask {
logger.info("+++留样复检任务提醒++syncSendSampleCheckRemind+++++");
remoteQualityService.syncSendSampleCheckRemind();
}
/**********修正威伟电表数据(有参)*********/
public void syncFixWwEnergyData(String beginDate,String endDate){
logger.info("+++修正威伟电表数据(有参)++syncFixWwEnergyData+++++");
Map<String ,String> map = new HashMap<>();
map.put("beginDate",beginDate);
map.put("endDate",endDate);
remoteEnergyService.syncFixWwEnergyData(map);
}
/** 修正威伟电表数据(无参) **/
public void syncFixWwEnergyData(){
logger.info("+++修正威伟电表数据(无参)++syncFixWwEnergyData+++++");
Map<String ,String> map = new HashMap<>();
map.put("beginDate","");
map.put("endDate","");
remoteEnergyService.syncFixWwEnergyData(map);
}
}

Loading…
Cancel
Save