提交 26c86407 作者: think

表zsd06一次性任务,将crt_datum1,cha_datum1字段的内容进行修改

上级 38ed6c6a
......@@ -403,6 +403,8 @@ public interface GPMapper {
@CacheEvict(key = "'selectZsd06'+':'+#p0.vbeln+','+#p0.posnr+','+#p0.mandt")
public void deleteZsd06(Zsd06 item);
public List<Zsd06> selectZsd06Check(Zsd06 build);
public Long selectZsd06MaxRowNum();
@Cacheable(key = "#root.method.name+':'+#p0.vbeln+','+#p0.posnr+','+#p0.mandt", unless="#result == null")
public Zsdfhzl selectZsdfhzl(Zsdfhzl zsdfhzl); // 查询替代删除
......
......@@ -423,8 +423,25 @@ public class CheckUpdateServiceImpl {
Date date = DateUtil.parse(erdat2);
source.setDatum1(date);
}
source.setCrt_datum1(SomeUtils.caDate(source.getCrt_datum()));
source.setCha_datum1(SomeUtils.caDate(source.getCha_datum()));
// source.setCrt_datum1(SomeUtils.caDate(source.getCrt_datum()));
// source.setCha_datum1(SomeUtils.caDate(source.getCha_datum()));
String crtdatum = source.getCrt_datum();
String crttime = source.getCrt_time();
if ("00000000".equals(crtdatum)) {
source.setCrt_datum1(null);
} else {
Date date = DateUtil.parse(crtdatum+crttime, "yyyyMMddHHmmss");
source.setCrt_datum1(date);
}
String chadatum = source.getCha_datum();
String chatime = source.getCha_time();
if ("00000000".equals(chadatum)) {
source.setCha_datum1(null);
} else {
Date date = DateUtil.parse(chadatum+chatime, "yyyyMMddHHmmss");
source.setCha_datum1(date);
}
// ===============================
while (true) {
try {
......
......@@ -31,6 +31,7 @@ import com.huazheng.project.hana.model.Tspat;
import com.huazheng.project.hana.model.Tvkbt;
import com.huazheng.project.hana.model.Vbak;
import com.huazheng.project.hana.model.Vbap;
import com.huazheng.project.hana.model.Zsd06;
import com.huazheng.project.mssql.mapper.CrmMapper;
import com.huazheng.project.mssql.model.SalesContractProcessMX;
import com.huazheng.project.mssql.model.SampleApplicationProcess;
......@@ -1578,4 +1579,77 @@ public class DeleteUpdateJobServiceImpl {
}
}
public void selectZsd06Check() {
try {
ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
opsForValue.setIfAbsent("huazheng:check:Zsd06:rowNum", "0");
String rowNum = opsForValue.get("huazheng:check:Zsd06:rowNum");
// 一次性任务的终止位
if (redis1Template.hasKey("huazheng:check:Zsd06:stopNum") == false) {
// 查询最大计数器
String maxRowNum = gpMapper.selectZsd06MaxRowNum().toString();
opsForValue.setIfAbsent("huazheng:check:Zsd06:stopNum", maxRowNum);
}
Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Zsd06:stopNum"));
if (stopNum < Long.parseLong(rowNum)) {
JobKey jobKey = JobKey.jobKey("selectZsd06Check_once", "DEFAULT"); // 删除任务
quartzScheduler.deleteJob(jobKey);
return;
}
Zsd06 build = Zsd06.builder().rowNum(rowNum).build();
List<Zsd06> list = gpMapper.selectZsd06Check(build); // 从数仓中查询一组数据
if (list.size() == 0) {
JobKey jobKey = JobKey.jobKey("selectZsd06Check_once", "DEFAULT"); // 删除任务
quartzScheduler.deleteJob(jobKey);
return;
}
list.forEach(target -> { // 遍历要检查的数据
Zsd06 source = sapMapper.selectZsd06ById(target); // 根据主键查询源库中的数据
String operator = "none";
if (source == null) { // 如果源库中没有数据
gpMapper.deleteZsd06(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);
while (true) {
try {
String crtdatum = source.getCrt_datum();
String crttime = source.getCrt_time();
if ("00000000".equals(crtdatum)) {
source.setCrt_datum1(null);
} else {
Date date = DateUtil.parse(crtdatum+crttime, "yyyyMMddHHmmss");
source.setCrt_datum1(date);
}
String chadatum = source.getCha_datum();
String chatime = source.getCha_time();
if ("00000000".equals(chadatum)) {
source.setCha_datum1(null);
} else {
Date date = DateUtil.parse(chadatum+chatime, "yyyyMMddHHmmss");
source.setCha_datum1(date);
}
gpMapper.updateZsd06(source); // 更新数据到数仓中
break;
} catch (RuntimeException e) {
log.error(e.getMessage());ThreadUtil.safeSleep(500);
}
}
ThreadUtil.safeSleep(500);
}
}
redis1Template.opsForValue().set("huazheng:check:Zsd06:rowNum", target.getRowNum());
if (!operator.equals("none")) {
log.info(String.format("selectZsd06Check --> rowNum:%s, operator:%s", target.getRowNum(), operator));
}
});
} catch (Exception e) {
redis1Template.opsForValue().set("huazheng:checkError:Zsd06:rowNum", getErrorInfoFromException(e));
}
}
}
......@@ -900,8 +900,26 @@ public class GPServiceImpl {
redis1Template.opsForHash().put("huazheng:Zsd06:error", "processZsd061", getErrorInfoFromException(e));
log.error(e.getMessage());
}
data.setCrt_datum1(caDate(data.getCrt_datum()));
data.setCha_datum1(caDate(data.getCha_datum()));
// data.setCrt_datum1(caDate(data.getCrt_datum()));
// data.setCha_datum1(caDate(data.getCha_datum()));
String crtdatum = data.getCrt_datum();
String crttime = data.getCrt_time();
if ("00000000".equals(crtdatum)) {
data.setCrt_datum1(null);
} else {
Date date = DateUtil.parse(crtdatum+crttime, "yyyyMMddHHmmss");
data.setCrt_datum1(date);
}
String chadatum = data.getCha_datum();
String chatime = data.getCha_time();
if ("00000000".equals(chadatum)) {
data.setCha_datum1(null);
} else {
Date date = DateUtil.parse(chadatum+chatime, "yyyyMMddHHmmss");
data.setCha_datum1(date);
}
}
out.collect(data);
} catch (Exception e) {
......
......@@ -1332,6 +1332,11 @@
<select id="selectZsd06Check" parameterType="com.huazheng.project.hana.model.Zsd06" resultType="com.huazheng.project.hana.model.Zsd06">
select * from Zsd06 where rownum &gt; #{rowNum} order by rownum limit 20
</select>
<select id="selectZsd06MaxRowNum" resultType="long">
select max(rowNum) from Zsd06
</select>
<select id="selectZsdfhzl" parameterType="com.huazheng.project.hana.model.Zsdfhzl" resultType="com.huazheng.project.hana.model.Zsdfhzl">
select * from Zsdfhzl
......
......@@ -1576,6 +1576,16 @@
</property>
<property name="cronExpression" value="* * * * * ?" />
</bean>
<bean class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<bean parent="methodJobDetail">
<property name="name" value="selectZsd06Check_once"/>
<property name="targetObject" ref="deleteUpdateJobServiceImpl" />
<property name="targetMethod" value="selectZsd06Check" />
</bean>
</property>
<property name="cronExpression" value="* * * * * ?" />
</bean>
</list>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论