提交 5703a8cb 作者: think

vbep任务

上级 4d947ced
...@@ -342,6 +342,7 @@ public interface GPMapper { ...@@ -342,6 +342,7 @@ public interface GPMapper {
@CacheEvict(key = "'selectVbep'+':'+#p0.vbeln+','+#p0.posnr+','+#p0.etenr+','+#p0.mandt") @CacheEvict(key = "'selectVbep'+':'+#p0.vbeln+','+#p0.posnr+','+#p0.etenr+','+#p0.mandt")
public void deleteVbep(Vbep vbep); public void deleteVbep(Vbep vbep);
public List<Vbep> selectVbepCheck(Vbep build); public List<Vbep> selectVbepCheck(Vbep build);
public Long selectVbepMaxRowNum();
@Cacheable(key = "#root.method.name+':'+#p0.vbeln+','+#p0.posnr+','+#p0.mandt+','+#p0.parvw", unless="#result == null") @Cacheable(key = "#root.method.name+':'+#p0.vbeln+','+#p0.posnr+','+#p0.mandt+','+#p0.parvw", unless="#result == null")
public Vbpa selectVbpa(Vbpa vbpa); // 查询替代删除 public Vbpa selectVbpa(Vbpa vbpa); // 查询替代删除
......
...@@ -31,6 +31,7 @@ import com.huazheng.project.hana.model.Tspat; ...@@ -31,6 +31,7 @@ import com.huazheng.project.hana.model.Tspat;
import com.huazheng.project.hana.model.Tvkbt; import com.huazheng.project.hana.model.Tvkbt;
import com.huazheng.project.hana.model.Vbak; import com.huazheng.project.hana.model.Vbak;
import com.huazheng.project.hana.model.Vbap; import com.huazheng.project.hana.model.Vbap;
import com.huazheng.project.hana.model.Vbep;
import com.huazheng.project.hana.model.Zsd06; import com.huazheng.project.hana.model.Zsd06;
import com.huazheng.project.mssql.mapper.CrmMapper; import com.huazheng.project.mssql.mapper.CrmMapper;
import com.huazheng.project.mssql.model.SalesContractProcessMX; import com.huazheng.project.mssql.model.SalesContractProcessMX;
...@@ -1658,4 +1659,68 @@ public class DeleteUpdateJobServiceImpl { ...@@ -1658,4 +1659,68 @@ public class DeleteUpdateJobServiceImpl {
} }
} }
public void selectVbepCheck() {
try {
ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
opsForValue.setIfAbsent("huazheng:check:Vbep:rowNum", "0");
String rowNum = opsForValue.get("huazheng:check:Vbep:rowNum");
// 一次性任务的终止位
if (redis1Template.hasKey("huazheng:check:Vbep:stopNum") == false) {
// 查询最大计数器
String maxRowNum = gpMapper.selectVbepMaxRowNum().toString();
opsForValue.setIfAbsent("huazheng:check:Vbep:stopNum", maxRowNum);
}
Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Vbep:stopNum"));
if (stopNum < Long.parseLong(rowNum)) {
JobKey jobKey = JobKey.jobKey("selectVbepCheck_once", "DEFAULT"); // 删除任务
quartzScheduler.deleteJob(jobKey);
return;
}
Vbep build = Vbep.builder().rowNum(rowNum).build();
List<Vbep> list = gpMapper.selectVbepCheck(build); // 从数仓中查询一组数据
if (list.size() == 0) {
JobKey jobKey = JobKey.jobKey("selectVbepCheck_once", "DEFAULT"); // 删除任务
quartzScheduler.deleteJob(jobKey);
return;
}
list.forEach(target -> { // 遍历要检查的数据
Vbep source = sapMapper.selectVbepById(target); // 根据主键查询源库中的数据
String operator = "none";
if (source == null) { // 如果源库中没有数据
gpMapper.deleteVbep(target); // 删除数仓中的数据
operator = "delete";
} else { // 源库中有数据
String shash = SecureUtil.md5(JSONUtil.toJsonStr(source)); // 源库中数据的hash结果
String thash = target.getHashResult(); // 数仓中数据的hash结果
if (!shash.equals(thash)) { // 如果hash结果不一致
source.setHashResult(shash);
// ===============================
if (source.getEdatu() != null) {
String erdat2 = new StringBuffer(source.getEdatu()).insert(4, "-").insert(7, "-").toString();
Date date = DateUtil.parse(erdat2);
source.setEdatu1(date);
}
// ===============================
while (true) {
try {
gpMapper.updateVbep(source); // 更新数据到数仓中
break;
} catch (RuntimeException e) {
log.error(e.getMessage());ThreadUtil.safeSleep(500);
}
}
ThreadUtil.safeSleep(500);
}
}
redis1Template.opsForValue().set("huazheng:check:Vbep:rowNum", target.getRowNum());
if (!operator.equals("none")) {
log.info(String.format("selectVbepCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
}
});
} catch (Exception e) {
redis1Template.opsForValue().set("huazheng:checkError:Vbep:rowNum", getErrorInfoFromException(e));
}
}
} }
...@@ -1194,6 +1194,10 @@ ...@@ -1194,6 +1194,10 @@
<select id="selectVbepCheck" parameterType="com.huazheng.project.hana.model.Vbep" resultType="com.huazheng.project.hana.model.Vbep"> <select id="selectVbepCheck" parameterType="com.huazheng.project.hana.model.Vbep" resultType="com.huazheng.project.hana.model.Vbep">
select * from Vbep where rownum &gt; #{rowNum} order by rownum limit 20 select * from Vbep where rownum &gt; #{rowNum} order by rownum limit 20
</select> </select>
<select id="selectVbepMaxRowNum" resultType="long">
select max(rowNum) from Zsd06
</select>
<select id="selectVbpa" parameterType="com.huazheng.project.hana.model.Vbpa" resultType="com.huazheng.project.hana.model.Vbpa"> <select id="selectVbpa" parameterType="com.huazheng.project.hana.model.Vbpa" resultType="com.huazheng.project.hana.model.Vbpa">
select * from Vbpa select * from Vbpa
......
...@@ -1635,6 +1635,16 @@ ...@@ -1635,6 +1635,16 @@
</property> </property>
<property name="cronExpression" value="* * * * * ?" /> <property name="cronExpression" value="* * * * * ?" />
</bean> </bean>
<bean class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<bean parent="methodJobDetail">
<property name="name" value="selectVbepCheck_once"/>
<property name="targetObject" ref="deleteUpdateJobServiceImpl" />
<property name="targetMethod" value="selectVbepCheck" />
</bean>
</property>
<property name="cronExpression" value="* * * * * ?" />
</bean>
</list> </list>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论