This commit is contained in:
yangjun 2025-09-22 11:12:41 +08:00
commit c240fb246a
12 changed files with 227 additions and 19 deletions

View File

@ -0,0 +1,50 @@
package org.jeecg.modules.heating.job;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.heating.entity.HeatanalysisHistory;
import org.jeecg.modules.heating.service.HeatanalysisHistoryService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* 同步乡镇历史数据 定时每2分钟
* @author: jeecg-boot
*/
@Slf4j
public class HeatingSyncXzHistoryJob implements Job {
@Autowired
private HeatanalysisHistoryService service;
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
log.info(String.format("同步乡镇历史数据 HeatingSyncXzHistoryJob ! 时间:" + DateUtils.getTimestamp()));
SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
HeatanalysisHistory entity = new HeatanalysisHistory();
entity.setRegionType("乡镇");
Calendar c = Calendar.getInstance();
entity.setEDate(c.getTime());
String eDateStr = timeFormat.format(c.getTime());
String suffix = eDateStr.substring(2, 4)+eDateStr.substring(5, 7);
String tableName = "bl_heatanalysis_"+suffix;
entity.setTableName(tableName);
c.add(Calendar.MINUTE,-5);
entity.setSDate(c.getTime());
List<HeatanalysisHistory> list = service.findSyncXzHistoryList(entity);
for (HeatanalysisHistory heat : list)
{
log.info(String.format("code:"+heat.getCode()+" sim:" + heat.getSim()));
service.syncXzHistory(heat);
}
}
}

View File

@ -0,0 +1,38 @@
package org.jeecg.modules.heating.job;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.heating.entity.Heatanalysis;
import org.jeecg.modules.heating.service.HeatanalysisService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* 同步乡镇数据 定时每2分钟
* @author: jeecg-boot
*/
@Slf4j
public class HeatingSyncXzJob implements Job {
@Autowired
private HeatanalysisService service;
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
log.info(String.format("同步乡镇数据 HeatingSyncXzJob ! 时间:" + DateUtils.getTimestamp()));
Heatanalysis entity = new Heatanalysis();
entity.setRegionType("乡镇");
List<Heatanalysis> list = service.findList(entity);
for (Heatanalysis heat : list)
{
log.info(String.format("code:"+heat.getCode()+" sim:" + heat.getSim()));
service.syncXz(heat);
}
}
}

View File

@ -12,4 +12,6 @@ public interface HeatanalysisHistoryMapper extends BaseMapper<HeatanalysisHistor
Page<HeatanalysisHistory> findJxPage(Page<HeatanalysisHistory> page, @Param("params") HeatanalysisHistory heatanalysisHistory);
List<HeatanalysisHistory> findHistoryList(HeatanalysisHistory heatanalysisHistory);
List<HeatanalysisHistory> getJxHistoryList(HeatanalysisHistory heatanalysisHistory);
void syncXzHistory(HeatanalysisHistory heatanalysisHistory);
}

View File

@ -31,4 +31,6 @@ public interface HeatanalysisMapper extends BaseMapper<Heatanalysis> {
Page<Heatanalysis> yunweiPage(Page<Heatanalysis> page, @Param("params") Heatanalysis heatanalysis);
List<Heatanalysis> getStaticNowList(@Param("params") HomeApiEntity dto);
void syncXz(Heatanalysis heatanalysis);
}

View File

@ -402,4 +402,50 @@
ORDER BY view001 asc ,view002 asc,view004 asc, view032 ASC
</select>
<insert id="syncXzHistory">
CALL P_Q_D_HEATANALYSIS_SYNC_HISTORY(
#{id},
#{view001},
#{view002},
#{view004},
#{datatime},
#{caveat},
#{view005},
#{view006},
#{view007},
#{view008},
#{view009},
#{view010},
#{view011},
#{view012},
#{view001Name},
#{view002Name},
#{view004Name},
#{sim},
#{delFlag},
#{code},
#{reportType},
#{isExtract},
#{regionType},
#{fromFlow},
#{view031},
#{view032},
#{view033},
#{view034},
#{view035},
#{view036},
#{view037},
#{view038},
#{view039},
#{view040},
#{view041},
#{view042},
#{view043},
#{view044},
#{view045},
#{view046},
#{view047}
)
</insert>
</mapper>

View File

@ -241,6 +241,7 @@
a.view046 AS "view046",
a.view047 AS "view047",
a.sim AS "sim",
a.code AS "code",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
@ -289,6 +290,9 @@
<if test="caveat != null">
AND a.caveat = #{caveat}
</if>
<if test="regionType != null and regionType != ''">
AND a.region_type = #{regionType}
</if>
</where>
ORDER BY a.view001 asc ,a.view002 asc,a.view004 asc,A.DATATIME DESC
</select>
@ -656,5 +660,49 @@
ORDER BY view001 asc ,view002 asc,view004 asc
</select>
<insert id="syncXz">
CALL P_Q_D_HEATANALYSIS_SYNC(
#{view001},
#{view002},
#{view004},
#{datatime},
#{caveat},
#{view005},
#{view006},
#{view007},
#{view008},
#{view009},
#{view010},
#{view011},
#{view012},
#{view001Name},
#{view002Name},
#{view004Name},
#{sim},
#{delFlag},
#{code},
#{reportType},
#{isExtract},
#{regionType},
#{fromFlow},
#{view031},
#{view032},
#{view033},
#{view034},
#{view035},
#{view036},
#{view037},
#{view038},
#{view039},
#{view040},
#{view041},
#{view042},
#{view043},
#{view044},
#{view045},
#{view046},
#{view047}
)
</insert>
</mapper>

View File

@ -13,4 +13,6 @@ public interface HeatanalysisHistoryService extends JeecgService<HeatanalysisHis
Result<?> findHistoryList(HeatanalysisHistory heatanalysisHistory);
Result<?> getHistoryList(HeatanalysisHistory heatanalysisHistory);
Result<?> getJxHistoryList(HeatanalysisHistory heatanalysisHistory);
List<HeatanalysisHistory> findSyncXzHistoryList(HeatanalysisHistory heatanalysisHistory);
void syncXzHistory(HeatanalysisHistory heatanalysisHistory);
}

View File

@ -18,6 +18,7 @@ public interface HeatanalysisService extends JeecgService<Heatanalysis> {
List<Heatanalysis> findStaticList(Heatanalysis heatanalysis);
List<Heatanalysis> findSimulateList(Heatanalysis heatanalysis);
void exeProc(Heatanalysis heatanalysis);
List<Heatanalysis> lowest(Heatanalysis heatanalysis);
IPage<Heatanalysis> findOnePage(Page<Heatanalysis> page, Heatanalysis heatanalysis);
@ -32,4 +33,6 @@ public interface HeatanalysisService extends JeecgService<Heatanalysis> {
IPage<Heatanalysis> yunweiPage(Page<Heatanalysis> page,Heatanalysis heatanalysis);
List<Heatanalysis> getStaticNowList(HomeApiEntity dto);
void syncXz(Heatanalysis heatanalysis);
}

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.heating.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
@ -191,4 +192,14 @@ public class HeatanalysisHistoryServiceImpl extends JeecgServiceImpl<Heatanalysi
return Result.ok(map);
}
public List<HeatanalysisHistory> findSyncXzHistoryList(HeatanalysisHistory heatanalysisHistory){
return baseMapper.getJxHistoryList(heatanalysisHistory);
}
@Override
@DS("multi-datasource1")
public void syncXzHistory(HeatanalysisHistory heatanalysisHistory){
baseMapper.syncXzHistory(heatanalysisHistory);
}
}

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.heating.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.system.base.service.impl.JeecgServiceImpl;
@ -107,4 +108,9 @@ public class HeatanalysisServiceImpl extends JeecgServiceImpl<HeatanalysisMapper
return baseMapper.getStaticNowList(dto);
}
@Override
@DS("multi-datasource1")
public void syncXz(Heatanalysis heatanalysis){
baseMapper.syncXz(heatanalysis);
}
}

View File

@ -154,20 +154,20 @@ spring:
slow-sql-millis: 5000
datasource:
master:
url: jdbc:mysql://192.168.2.199:3306/heating?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: nu_sys
password: nu_sys
driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/heating?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
# username: root
# password: root
# url: jdbc:mysql://192.168.2.199:3306/heating?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
# username: nu_sys
# password: nu_sys
# driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/heating?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
#url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
#username: root
#password: root
#driver-class-name: com.mysql.cj.jdbc.Driver
multi-datasource1:
url: jdbc:mysql://115.175.20.152:40521/heating?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: Root@123..
driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置
redis:
database: 0

View File

@ -146,16 +146,16 @@ spring:
slow-sql-millis: 5000
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://localhost:3306/heating?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
#url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
#username: root
#password: root
#driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
multi-datasource1:
url: jdbc:mysql://115.175.20.152:40521/heating?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: Root@123..
driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置
redis:
database: 0