新增能耗数据同步
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
package com.lideeyunji.core.framework.config.job;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.lideeyunji.core.framework.entity.GrNhEntity;
|
||||
import com.lideeyunji.core.framework.service.IGrNhService;
|
||||
import com.lideeyunji.core.framework.service.ILideeYunJiService;
|
||||
import com.lideeyunji.tool.framework.common.util.http.HttpUtils;
|
||||
import com.lideeyunji.tool.framework.quartz.core.handler.JobHandler;
|
||||
@@ -15,6 +17,8 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -29,7 +33,7 @@ public class anyToGrBiNh implements JobHandler {
|
||||
private lideeYunjiRedisUtils redisUtil;
|
||||
|
||||
@Autowired
|
||||
private ILideeYunJiService lideeYunJiService;
|
||||
private IGrNhService grNhService;
|
||||
|
||||
@Override
|
||||
@TenantIgnore
|
||||
@@ -81,6 +85,50 @@ public class anyToGrBiNh implements JobHandler {
|
||||
String getResult = HttpUtils.doGet("http://111.39.171.64:8090/SubstationWEBV2/main/Compare/overview?fCoaccountno=1", headers);
|
||||
System.out.println("GET Response:\n" + getResult);
|
||||
|
||||
JSONObject jsonObject = new JSONObject(getResult);
|
||||
System.out.println(jsonObject.get("data"));
|
||||
GrNhEntity grNhEntity = new GrNhEntity();
|
||||
if (jsonObject.get("code").toString().equals("200")){
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
grNhEntity.setEleDayCurrent(data.getJSONObject("eleDayCompare").getFloat("currentValue")); //电-当日
|
||||
grNhEntity.setEleDayBefore(data.getJSONObject("eleDayCompare").getFloat("beforeValue"));//电-昨日
|
||||
grNhEntity.setEleMonthCurrent(data.getJSONObject("eleMonthCompare").getFloat("currentValue"));//电-当月
|
||||
grNhEntity.setEleMonthBefore(data.getJSONObject("eleMonthCompare").getFloat("beforeValue"));//电-上月
|
||||
grNhEntity.setEleYearCurrent(data.getJSONObject("eleYearCompare").getFloat("currentValue"));//电-昨年
|
||||
grNhEntity.setEleYearBefore(data.getJSONObject("eleYearCompare").getFloat("beforeValue"));////电-上年
|
||||
|
||||
|
||||
grNhEntity.setWaterDayCurrent(data.getJSONObject("waterDayCompare").getFloat("currentValue")); //水-当日
|
||||
grNhEntity.setWaterDayBefore(data.getJSONObject("waterDayCompare").getFloat("beforeValue"));//水-昨日
|
||||
grNhEntity.setWaterMonthCurrent(data.getJSONObject("waterMonthCompare").getFloat("currentValue"));//水-当月
|
||||
grNhEntity.setWaterMonthBefore(data.getJSONObject("waterMonthCompare").getFloat("beforeValue"));//水-上月
|
||||
grNhEntity.setWaterYearCurrent(data.getJSONObject("waterYearCompare").getFloat("currentValue"));//水-昨年
|
||||
grNhEntity.setWaterYearBefore(data.getJSONObject("waterYearCompare").getFloat("beforeValue"));////水-上年
|
||||
|
||||
|
||||
grNhEntity.setGasDayCurrent(data.getJSONObject("gasDayCompare").getFloat("currentValue")); //气-当日
|
||||
grNhEntity.setGasDayBefore(data.getJSONObject("gasDayCompare").getFloat("beforeValue"));//气-昨日
|
||||
grNhEntity.setGasMonthCurrent(data.getJSONObject("gasMonthCompare").getFloat("currentValue"));//气-当月
|
||||
grNhEntity.setGasMonthBefore(data.getJSONObject("gasMonthCompare").getFloat("beforeValue"));//气-上月
|
||||
grNhEntity.setGasYearCurrent(data.getJSONObject("gasYearCompare").getFloat("currentValue"));//气-昨年
|
||||
grNhEntity.setGasYearBefore(data.getJSONObject("gasYearCompare").getFloat("beforeValue"));////气-上年
|
||||
|
||||
|
||||
grNhEntity.setStcDayCurrent(data.getJSONObject("stcDayCompare").getFloat("currentValue")); //标准煤-当日
|
||||
grNhEntity.setStcDayBefore(data.getJSONObject("stcDayCompare").getFloat("beforeValue"));//标准煤-昨日
|
||||
grNhEntity.setStcMonthCurrent(data.getJSONObject("stcMonthCompare").getFloat("currentValue"));//标准煤-当月
|
||||
grNhEntity.setStcMonthBefore(data.getJSONObject("stcMonthCompare").getFloat("beforeValue"));//标准煤-上月
|
||||
grNhEntity.setStcYearCurrent(data.getJSONObject("stcYearCompare").getFloat("currentValue"));//标准煤-昨年
|
||||
grNhEntity.setStcYearBefore(data.getJSONObject("stcYearCompare").getFloat("beforeValue"));//标准煤-上年
|
||||
|
||||
grNhService.saveNH(grNhEntity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// grNhService.query().eq("add_time",1);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.lideeyunji.core.framework.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 能耗数据
|
||||
*
|
||||
* @author 裕恒 282636116@qq.com
|
||||
* @since 1.0.0 2026-03-13
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("erp_bi_data.gr_nh")
|
||||
public class GrNhEntity {
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 电(当日)
|
||||
*/
|
||||
private Float eleDayCurrent;
|
||||
|
||||
/**
|
||||
* 电(昨日)
|
||||
*/
|
||||
private Float eleDayBefore;
|
||||
|
||||
/**
|
||||
* 电(当月)
|
||||
*/
|
||||
private Float eleMonthCurrent;
|
||||
|
||||
/**
|
||||
* 电(上月)
|
||||
*/
|
||||
private Float eleMonthBefore;
|
||||
|
||||
/**
|
||||
* 电(当年)
|
||||
*/
|
||||
private Float eleYearCurrent;
|
||||
|
||||
/**
|
||||
* 电(上年)
|
||||
*/
|
||||
private Float eleYearBefore;
|
||||
|
||||
/**
|
||||
* 水(当日)
|
||||
*/
|
||||
private Float waterDayCurrent;
|
||||
|
||||
/**
|
||||
* 水(昨日)
|
||||
*/
|
||||
private Float waterDayBefore;
|
||||
|
||||
/**
|
||||
* 水(当月)
|
||||
*/
|
||||
private Float waterMonthCurrent;
|
||||
|
||||
/**
|
||||
* 水(上月)
|
||||
*/
|
||||
private Float waterMonthBefore;
|
||||
|
||||
/**
|
||||
* 水(当年)
|
||||
*/
|
||||
private Float waterYearCurrent;
|
||||
|
||||
/**
|
||||
* 水(上年)
|
||||
*/
|
||||
private Float waterYearBefore;
|
||||
|
||||
/**
|
||||
* 气(当日)
|
||||
*/
|
||||
private Float gasDayCurrent;
|
||||
|
||||
/**
|
||||
* 气(昨日)
|
||||
*/
|
||||
private Float gasDayBefore;
|
||||
|
||||
/**
|
||||
* 气(当月)
|
||||
*/
|
||||
private Float gasMonthCurrent;
|
||||
|
||||
/**
|
||||
* 气(上月)
|
||||
*/
|
||||
private Float gasMonthBefore;
|
||||
|
||||
/**
|
||||
* 气(当年)
|
||||
*/
|
||||
private Float gasYearCurrent;
|
||||
|
||||
/**
|
||||
* 气(上年)
|
||||
*/
|
||||
private Float gasYearBefore;
|
||||
|
||||
/**
|
||||
* 标准煤
|
||||
(当日)
|
||||
*/
|
||||
private Float stcDayCurrent;
|
||||
|
||||
/**
|
||||
* 标准煤
|
||||
(昨日)
|
||||
*/
|
||||
private Float stcDayBefore;
|
||||
|
||||
/**
|
||||
* 标准煤
|
||||
(当月)
|
||||
*/
|
||||
private Float stcMonthCurrent;
|
||||
|
||||
/**
|
||||
* 标准煤
|
||||
(上月)
|
||||
*/
|
||||
private Float stcMonthBefore;
|
||||
|
||||
/**
|
||||
* 标准煤
|
||||
(当年)
|
||||
*/
|
||||
private Float stcYearCurrent;
|
||||
|
||||
/**
|
||||
* 标准煤(上年)
|
||||
*/
|
||||
private Float stcYearBefore;
|
||||
|
||||
/**
|
||||
* 添加日期
|
||||
*/
|
||||
private Date addTime=new Date();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.lideeyunji.core.framework.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.lideeyunji.core.framework.entity.GrNhEntity;
|
||||
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 能耗数据
|
||||
*
|
||||
* @author 裕恒 282636116@qq.com
|
||||
* @since 1.0.0 2026-03-13
|
||||
*/
|
||||
@DS(lideeYunJiBaseConstant.DS_ERP_BI_DATA)
|
||||
public interface GrNhMapper extends BaseMapper<GrNhEntity> {
|
||||
@DS(value = "#dataSourceType")
|
||||
default int save(@Param("dataSourceType") String dataSourceType, GrNhEntity grNhEntity) {
|
||||
return this.insert(grNhEntity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.lideeyunji.core.framework.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.lideeyunji.core.framework.entity.GrNhEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 能耗数据
|
||||
*
|
||||
* @author 裕恒 282636116@qq.com
|
||||
* @since 1.0.0 2026-03-13
|
||||
*/
|
||||
public interface IGrNhService extends IService<GrNhEntity> {
|
||||
|
||||
Integer saveNH(GrNhEntity grNhEntity) ;
|
||||
|
||||
void delete(List<Long> idList);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.lideeyunji.core.framework.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.lideeyunji.core.framework.entity.GrNhEntity;
|
||||
import com.lideeyunji.core.framework.mapper.GrNhMapper;
|
||||
import com.lideeyunji.core.framework.service.IGrNhService;
|
||||
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 能耗数据
|
||||
*
|
||||
* @author 裕恒 282636116@qq.com
|
||||
* @since 1.0.0 2026-03-13
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class GrNhServiceImpl extends ServiceImpl<GrNhMapper, GrNhEntity> implements IGrNhService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(List<Long> idList) {
|
||||
removeByIds(idList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//新增
|
||||
@Override
|
||||
@DSTransactional
|
||||
public Integer saveNH(GrNhEntity grNhEntity) {
|
||||
int re = this.baseMapper.save(lideeYunJiBaseConstant.DS_ERP_BI_DATA, grNhEntity);
|
||||
return re;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user