package com.huazheng.project.greenplum.service.impl;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import com.huazheng.project.greenplum.mapper.GPMapper;
import com.huazheng.project.hana.mapper.SapMapper;
import com.huazheng.project.hana.model.Afko;
import com.huazheng.project.hana.model.Afpo;
import com.huazheng.project.hana.model.Afru;
import com.huazheng.project.hana.model.Afvc;
import com.huazheng.project.hana.model.Aufk;
import com.huazheng.project.hana.model.Aufm;
import com.huazheng.project.hana.model.Ausp;
import com.huazheng.project.hana.model.Bsad;
import com.huazheng.project.hana.model.Bsid;
//import com.huazheng.project.hana.model.Bsid2Bsad;
import com.huazheng.project.hana.model.Kna1;
import com.huazheng.project.hana.model.Knkk;
import com.huazheng.project.hana.model.Knvv;
import com.huazheng.project.hana.model.Konv;
import com.huazheng.project.hana.model.Likp;
import com.huazheng.project.hana.model.Lips;
import com.huazheng.project.hana.model.Makt;
import com.huazheng.project.hana.model.Mara;
import com.huazheng.project.hana.model.Mkpf;
import com.huazheng.project.hana.model.Mseg;
import com.huazheng.project.hana.model.Mska;
import com.huazheng.project.hana.model.Pa0002;
import com.huazheng.project.hana.model.S066;
import com.huazheng.project.hana.model.S067;
import com.huazheng.project.hana.model.T001w;
import com.huazheng.project.hana.model.T023t;
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.VbapAdv;
import com.huazheng.project.hana.model.Vbep;
import com.huazheng.project.hana.model.Vbpa;
import com.huazheng.project.hana.model.Vbrk;
import com.huazheng.project.hana.model.Vbrp;
import com.huazheng.project.hana.model.Vbuk;
import com.huazheng.project.hana.model.Zmdpc;
import com.huazheng.project.hana.model.Zpoedit;
import com.huazheng.project.hana.model.Zsd06;
import com.huazheng.project.hana.model.Zsdfhzl;
import com.huazheng.project.mssql.mapper.CrmMapper;
import com.huazheng.project.mssql.model.SalesContractProcess;
import com.huazheng.project.mssql.model.SalesContractProcessMX;
import com.huazheng.project.mssql.model.SalesForecastProcess;
import com.huazheng.project.mssql.model.SalesForecastProcessMX;
import com.huazheng.project.mssql.model.SampleApplicationProcess;
import com.huazheng.project.mssql.model.SampleApplicationProcessMingXi;
import com.huazheng.project.mssql.model.SampleClosingProcess;
import com.huazheng.project.mssql.model.SampleClosingProcessMingXi;
import com.huazheng.project.mssql2.mapper.HzcrmMapper;
import com.huazheng.project.mssql2.model.SysSAPreturnNo;
import com.huazheng.project.mssql2.model.TKeHu;
import com.huazheng.project.mssql2.model.TKeHuXiaoShouZZ;
import com.huazheng.project.mssql2.model.TKeHuXiaoShouZZYeWuY;
import com.huazheng.project.mssql2.model.TWuLiaoDB;
import com.huazheng.project.mssql3.mapper.Cinderellaw2Mapper;
import com.huazheng.project.mssql3.model.PersonComp;
import com.huazheng.project.mssql4.mapper.UltimusDBMapper;
import com.huazheng.project.mssql4.model.Tasks;
import com.huazheng.project.mysql.mapper.TmsMapper;
import com.huazheng.project.mysql.model.Handover;
import com.huazheng.project.mysql.model.HandoverTask;
import com.huazheng.project.mysql.model.TransformHistoryNode;
import com.huazheng.project.mysql.model.TransformNewNode;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.log4j.Log4j2;

@Log4j2
@Service
public class DeleteUpdateJobServiceImpl {

	@Autowired
	private RedisTemplate<String, String> redis1Template;

	@Autowired
	private SapMapper sapMapper;

	@Autowired
	private CrmMapper crmMapper;

	@Autowired
	private GPMapper gpMapper;

	@Autowired
	private TmsMapper tmsMapper;

	@Autowired
	private HzcrmMapper hzcrmMapper;
	
	@Autowired
	private UltimusDBMapper ultimusDBMapper;
	
	@Autowired
	private Cinderellaw2Mapper cinderellaw2Mapper;
	
	private ExecutorService service = Executors.newFixedThreadPool(15);

	public String getErrorInfoFromException(Exception e) {
		try {
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			e.printStackTrace(pw);
			return "\r\n" + sw.toString() + "\r\n";
		} catch (Exception e2) {
			return "bad getErrorInfoFromException";
		}
	}
	private Date caDate(String datestr) {
		try {
			if (datestr == null || datestr.equals("00000000") || StrUtil.isBlank(datestr)) {
				return null;
			} else {
				Date date = DateUtil.parse(datestr, "yyyyMMdd");
				return date;
			}
		} catch (Exception e) {
			return null;
		}
	}
	
	public void checkJob1() {
		selectSalesContractProcessCheck();// 1
		selectSalesContractProcessMXCheck(); // 2
		selectSalesForecastProcessCheck(); // 3
		selectSalesForecastProcessMXCheck(); // 4
		selectSampleApplicationProcessCheck();
		selectSampleApplicationProcessMingXiCheck();
		selectSampleClosingProcessCheck();
		selectSampleClosingProcessMingXiCheck();
	}
	private void selectSalesContractProcessCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SalesContractProcess:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SalesContractProcess:rowNum");
			SalesContractProcess build = SalesContractProcess.builder().rowNum(rowNum).build();
			List<SalesContractProcess> list = gpMapper.selectSalesContractProcessCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SalesContractProcess:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SalesContractProcess source = crmMapper.selectSalesContractProcessById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSalesContractProcess(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 {
								gpMapper.updateSalesContractProcess(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SalesContractProcess:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSalesContractProcessCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SalesContractProcess:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectSalesContractProcessMXCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SalesContractProcessMX:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SalesContractProcessMX:rowNum");
			SalesContractProcessMX build = SalesContractProcessMX.builder().rowNum(rowNum).build();
			List<SalesContractProcessMX> list = gpMapper.selectSalesContractProcessMXCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SalesContractProcessMX:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SalesContractProcessMX source = crmMapper.selectSalesContractProcessMXById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSalesContractProcessMX(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);
						// ===============================
						Object chengben = source.getChengben();
						if (chengben != null && chengben.toString().equals("")) {
							source.setChengben(null);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateSalesContractProcessMX(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SalesContractProcessMX:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSalesContractProcessMXCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SalesContractProcessMX:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectSalesForecastProcessCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SalesForecastProcess:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SalesForecastProcess:rowNum");
			SalesForecastProcess build = SalesForecastProcess.builder().rowNum(rowNum).build();
			List<SalesForecastProcess> list = gpMapper.selectSalesForecastProcessCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SalesForecastProcess:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SalesForecastProcess source = crmMapper.selectSalesForecastProcessById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSalesForecastProcess(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);
						// ===============================
						String kaiShiSJs = source.getKaiShiSJs(); // 时间数据纠错
						if (kaiShiSJs == null || kaiShiSJs.equals("00000000") || StrUtil.isBlank(kaiShiSJs)) {
							source.setKaiShiSJ(null);
						} else {
							if (kaiShiSJs.indexOf("--") == -1) {
								Date date = DateUtil.parse(kaiShiSJs);
								source.setKaiShiSJ(date);
							}
						}
						String jieShuSJs = source.getJieShuSJs(); // 时间数据纠错
						if (jieShuSJs == null || jieShuSJs.equals("00000000") || StrUtil.isBlank(jieShuSJs)) {
							source.setJieShuSJ(null);
						} else {
							Date date = DateUtil.parse(jieShuSJs);
							source.setJieShuSJ(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateSalesForecastProcess(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SalesForecastProcess:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSalesForecastProcessCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SalesForecastProcess:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectSalesForecastProcessMXCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SalesForecastProcessMX:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SalesForecastProcessMX:rowNum");
			SalesForecastProcessMX build = SalesForecastProcessMX.builder().rowNum(rowNum).build();
			List<SalesForecastProcessMX> list = gpMapper.selectSalesForecastProcessMXCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SalesForecastProcessMX:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SalesForecastProcessMX source = crmMapper.selectSalesForecastProcessMXById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSalesForecastProcessMX(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.getJiHuaJDL() != null) {
							source.setJiHuaJDL(ReUtil.getFirstNumber(source.getJiHuaJDL()) + "");
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateSalesForecastProcessMX(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SalesForecastProcessMX:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSalesForecastProcessMXCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SalesForecastProcessMX:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectSampleApplicationProcessCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SampleApplicationProcess:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SampleApplicationProcess:rowNum");
			SampleApplicationProcess build = SampleApplicationProcess.builder().rowNum(rowNum).build();
			List<SampleApplicationProcess> list = gpMapper.selectSampleApplicationProcessCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SampleApplicationProcess:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SampleApplicationProcess source = crmMapper.selectSampleApplicationProcessById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSampleApplicationProcess(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);
						// ===============================
						String pcbcs = source.getPCBCS();
						String chanPinYY = source.getChanPinYY();
						if (StrUtil.isBlank(pcbcs) || StrUtil.isBlank(chanPinYY)) {
							source.setPCBCS2chanPinYY(null);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateSampleApplicationProcess(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SampleApplicationProcess:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSampleApplicationProcessCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SampleApplicationProcess:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectSampleApplicationProcessMingXiCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SampleApplicationProcessMingXi:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SampleApplicationProcessMingXi:rowNum");
			SampleApplicationProcessMingXi build = SampleApplicationProcessMingXi.builder().rowNum(rowNum).build();
			List<SampleApplicationProcessMingXi> list = gpMapper.selectSampleApplicationProcessMingXiCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SampleApplicationProcessMingXi:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SampleApplicationProcessMingXi source = crmMapper.selectSampleApplicationProcessMingXiById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSampleApplicationProcessMingXi(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);
						// ===============================
						String hangXiangMH = source.getHangXiangMH();
						if (StrUtil.isBlank(hangXiangMH)) {
							source.setHangxiangmh1(null);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateSampleApplicationProcessMingXi(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SampleApplicationProcessMingXi:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSampleApplicationProcessMingXiCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SampleApplicationProcessMingXi:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectSampleClosingProcessCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SampleClosingProcess:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SampleClosingProcess:rowNum");
			SampleClosingProcess build = SampleClosingProcess.builder().rowNum(rowNum).build();
			List<SampleClosingProcess> list = gpMapper.selectSampleClosingProcessCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SampleClosingProcess:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SampleClosingProcess source = crmMapper.selectSampleClosingProcessById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSampleClosingProcess(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 (NumberUtil.isNumber(source.getYangPinSQSLH())) {
							int yangPinSQSLHi = Integer.parseInt(source.getYangPinSQSLH());
							source.setYangPinSQSLHi(yangPinSQSLHi);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateSampleClosingProcess(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SampleClosingProcess:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSampleClosingProcessCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SampleClosingProcess:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectSampleClosingProcessMingXiCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SampleClosingProcessMingXi:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SampleClosingProcessMingXi:rowNum");
			SampleClosingProcessMingXi build = SampleClosingProcessMingXi.builder().rowNum(rowNum).build();
			List<SampleClosingProcessMingXi> list = gpMapper.selectSampleClosingProcessMingXiCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SampleClosingProcessMingXi:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SampleClosingProcessMingXi source = crmMapper.selectSampleClosingProcessMingXiById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSampleClosingProcessMingXi(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 {
								gpMapper.updateSampleClosingProcessMingXi(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SampleClosingProcessMingXi:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSampleClosingProcessMingXiCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SampleClosingProcessMingXi:rowNum", getErrorInfoFromException(e));
		}
	}
	
	public void checkJob2() {
		selectSysSAPreturnNoCheck(); // 5
		selectTKeHuCheck(); // 6
		selectTKeHuXiaoShouZZCheck(); // 7
		selectTKeHuXiaoShouZZYeWuYCheck(); // 8
		selectTWuLiaoDBCheck(); // 9
	}
	private void selectSysSAPreturnNoCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SysSAPreturnNo:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SysSAPreturnNo:rowNum");
			SysSAPreturnNo build = SysSAPreturnNo.builder().rowNum(rowNum).build();
			List<SysSAPreturnNo> list = gpMapper.selectSysSAPreturnNoCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:SysSAPreturnNo:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				SysSAPreturnNo source = hzcrmMapper.selectSysSAPreturnNoById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteSysSAPreturnNo(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 {
								gpMapper.updateSysSAPreturnNo(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:SysSAPreturnNo:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectSysSAPreturnNoCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:SysSAPreturnNo:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectTKeHuCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:TKeHu:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:TKeHu:rowNum");
			TKeHu build = TKeHu.builder().rowNum(rowNum).build();
			List<TKeHu> list = gpMapper.selectTKeHuCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:TKeHu:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				TKeHu source = hzcrmMapper.selectTKeHuById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTKeHu(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 {
								gpMapper.updateTKeHu(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:TKeHu:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTKeHuCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:TKeHu:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectTKeHuXiaoShouZZCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:TKeHuXiaoShouZZ:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:TKeHuXiaoShouZZ:rowNum");
			TKeHuXiaoShouZZ build = TKeHuXiaoShouZZ.builder().rowNum(rowNum).build();
			List<TKeHuXiaoShouZZ> list = gpMapper.selectTKeHuXiaoShouZZCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:TKeHuXiaoShouZZ:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				TKeHuXiaoShouZZ source = hzcrmMapper.selectTKeHuXiaoShouZZById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTKeHuXiaoShouZZ(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 {
								gpMapper.updateTKeHuXiaoShouZZ(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:TKeHuXiaoShouZZ:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTKeHuXiaoShouZZCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:TKeHuXiaoShouZZ:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectTKeHuXiaoShouZZYeWuYCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:TKeHuXiaoShouZZYeWuY:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:TKeHuXiaoShouZZYeWuY:rowNum");
			TKeHuXiaoShouZZYeWuY build = TKeHuXiaoShouZZYeWuY.builder().rowNum(rowNum).build();
			List<TKeHuXiaoShouZZYeWuY> list = gpMapper.selectTKeHuXiaoShouZZYeWuYCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:TKeHuXiaoShouZZYeWuY:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				TKeHuXiaoShouZZYeWuY source = hzcrmMapper.selectTKeHuXiaoShouZZYeWuYById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTKeHuXiaoShouZZYeWuY(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 {
								gpMapper.updateTKeHuXiaoShouZZYeWuY(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:TKeHuXiaoShouZZYeWuY:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTKeHuXiaoShouZZYeWuYCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:TKeHuXiaoShouZZYeWuY:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectTWuLiaoDBCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:TWuLiaoDB:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:TWuLiaoDB:rowNum");
			TWuLiaoDB build = TWuLiaoDB.builder().rowNum(rowNum).build();
			List<TWuLiaoDB> list = gpMapper.selectTWuLiaoDBCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:TWuLiaoDB:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				TWuLiaoDB source = hzcrmMapper.selectTWuLiaoDBById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTWuLiaoDB(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 {
								gpMapper.updateTWuLiaoDB(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:TWuLiaoDB:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTWuLiaoDBCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:TWuLiaoDB:rowNum", getErrorInfoFromException(e));
		}
	}
	
	public void checkJob3() {
		selectHandoverCheck(); // 10
		selectHandoverTaskCheck(); // 11
		selectTransformHistoryNodeCheck(); // 12
		selectTransformNewNodeCheck(); // 13
	}
	private void selectHandoverCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Handover:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Handover:rowNum");
			Handover build = Handover.builder().rowNum(rowNum).build();
			List<Handover> list = gpMapper.selectHandoverCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Handover:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Handover source = tmsMapper.selectHandoverById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteHandover(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 {
								gpMapper.updateHandover(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Handover:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectHandoverCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Handover:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectHandoverTaskCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:HandoverTask:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:HandoverTask:rowNum");
			HandoverTask build = HandoverTask.builder().rowNum(rowNum).build();
			List<HandoverTask> list = gpMapper.selectHandoverTaskCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:HandoverTask:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				HandoverTask source = tmsMapper.selectHandoverTaskById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteHandoverTask(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 {
								gpMapper.updateHandoverTask(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:HandoverTask:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectHandoverTaskCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:HandoverTask:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectTransformHistoryNodeCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:TransformHistoryNode:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:TransformHistoryNode:rowNum");
			TransformHistoryNode build = TransformHistoryNode.builder().rowNum(rowNum).build();
			List<TransformHistoryNode> list = gpMapper.selectTransformHistoryNodeCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:TransformHistoryNode:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				TransformHistoryNode source = tmsMapper.selectTransformHistoryNodeById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTransformHistoryNode(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 {
								gpMapper.updateTransformHistoryNode(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:TransformHistoryNode:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTransformHistoryNodeCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:TransformHistoryNode:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectTransformNewNodeCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:TransformNewNode:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:TransformNewNode:rowNum");
			TransformNewNode build = TransformNewNode.builder().rowNum(rowNum).build();
			List<TransformNewNode> list = gpMapper.selectTransformNewNodeCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:TransformNewNode:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				TransformNewNode source = tmsMapper.selectTransformNewNodeById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTransformNewNode(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 {
								gpMapper.updateTransformNewNode(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:TransformNewNode:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTransformNewNodeCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:TransformNewNode:rowNum", getErrorInfoFromException(e));
		}
	}
	
	public void checkJob4() {
		selectAfkoCheck(); // 14
		selectAfpoCheck(); // 15
		selectAufkCheck(); // 16
//		selectAufmCheck(); // 17
		selectKna1Check(); // 18
		selectKnkkCheck(); // 19
		selectKnvvCheck(); // 20
//		selectKonvCheck(); // 21
		selectLipsCheck(); // 23
		selectMaktCheck(); // 24
		selectMaraCheck(); // 25
		selectMskaCheck(); // 26
		selectPa0002Check(); // 27
		selectS066Check(); // 28
		selectS067Check(); // 29
		selectT001wCheck(); // 30
		selectT023tCheck(); // 31
		selectVbepCheck(); // 33
		selectVbpaCheck(); // 34
		selectVbrkCheck(); // 35
		selectVbrpCheck(); // 36
		selectVbukCheck(); // 37
		selectZmdpcCheck(); // 38
		selectZsd06Check(); // 39
		selectZsdfhzlCheck(); // 40
		selectTvkbtCheck(); //
		selectAfvcCheck();
		selectMkpfCheck();
		selectMsegCheck();
		selectAfruCheck();
		selectTspatCheck();
		selectZpoeditCheck();
		selectAuspCheck();
	}
	private void selectAfkoCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Afko:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Afko:rowNum");
			Afko build = Afko.builder().rowNum(rowNum).build();
			List<Afko> list = gpMapper.selectAfkoCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Afko:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Afko source = sapMapper.selectAfkoById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteAfko(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.getGltrp() != null) {
							String erdat2 = new StringBuffer(source.getGltrp()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setGltrp1(date);
						}
						if (source.getGstrp() != null) {
							String erdat2 = new StringBuffer(source.getGstrp()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setGstrp1(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateAfko(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Afko:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectAfkoCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Afko:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectAfpoCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Afpo:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Afpo:rowNum");
			Afpo build = Afpo.builder().rowNum(rowNum).build();
			List<Afpo> list = gpMapper.selectAfpoCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Afpo:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Afpo source = sapMapper.selectAfpoById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteAfpo(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 {
								gpMapper.updateAfpo(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Afpo:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectAfpoCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Afpo:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectAufkCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Aufk:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Aufk:rowNum");
			Aufk build = Aufk.builder().rowNum(rowNum).build();
			List<Aufk> list = gpMapper.selectAufkCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Aufk:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Aufk source = sapMapper.selectAufkById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteAufk(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.getErdat() != null && source.getErfzeit() != null) {
							String erdat2 = new StringBuffer(source.getErdat()).insert(4, "-").insert(7, "-").toString();
							String erzet2 = new StringBuffer(source.getErfzeit()).insert(2, ":").insert(5, ":").toString();
							String dateStr = erdat2 + " " + erzet2;
							Date date = DateUtil.parse(dateStr);
							source.setErdat1(date);
							source.setErdat2(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateAufk(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Aufk:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectAufkCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Aufk:rowNum", getErrorInfoFromException(e));
		}
	}
	// 数据量过大不再执行任务
	private void selectAufmCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Aufm:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Aufm:rowNum");
			Aufm build = Aufm.builder().rowNum(rowNum).build();
			List<Aufm> list = gpMapper.selectAufmCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Aufm:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Aufm source = sapMapper.selectAufmById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteAufm(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.getBldat() != null) {
							String erdat2 = new StringBuffer(source.getBldat()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setBldat1(date);
						}
						if (source.getBudat() != null) {
							String erdat2 = new StringBuffer(source.getBudat()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setBudat1(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateAufm(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Aufm:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectAufmCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Aufm:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectKna1Check() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Kna1:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Kna1:rowNum");
			Kna1 build = Kna1.builder().rowNum(rowNum).build();
			List<Kna1> list = gpMapper.selectKna1Check(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Kna1:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Kna1 source = sapMapper.selectKna1ById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteKna1(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 {
								gpMapper.updateKna1(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Kna1:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectKna1Check --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Kna1:rowNum", getErrorInfoFromException(e));
		}
	}
	// 计数器复位删除
	private void selectKnkkCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Knkk:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Knkk:rowNum");
			Knkk build = Knkk.builder().rowNum(rowNum).build();

			List<Knkk> list = gpMapper.selectKnkkCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				// 按更新时间查询，查询大于今天的数据，此时就不需要重置计数器了
				String aedat = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"); // 昨天的日期
				build = Knkk.builder().rowNum(rowNum).aedat(aedat).build();
				// 查询出列表20个，下面的代码运行后会复位一个阶段的rowNum，如此往复list.size()就不会为0了
				list = gpMapper.selectKnkkCheckByUpdate(build);
				// 是否为list.size() == 0的时候的更新时间查询的列表
				opsForValue.set("huazheng:check:Knkk:isUpdateList", "true");
			} else {
				redis1Template.delete("huazheng:check:Knkk:isUpdateList");
			}

			list.forEach(target -> { // 遍历要检查的数据
				Knkk source = sapMapper.selectKnkkById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteKnkk(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 {
								gpMapper.updateKnkk(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}

				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Knkk:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Knkk:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}

				if (!operator.equals("none")) {
					log.info(String.format("selectKnkkCheck --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Knkk:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectKnkkCheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Knkk:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Knkk:rowNum");
			Knkk build = Knkk.builder().rowNum(rowNum).build();

			List<Knkk> list = gpMapper.selectKnkkCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:checkDelete:Knkk:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}

			list.forEach(target -> { // 遍历要检查的数据
				Knkk source = sapMapper.selectKnkkById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteKnkk(target); // 删除数仓中的数据
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Knkk:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectKnkkCheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Knkk:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectKnvvCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Knvv:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Knvv:rowNum");
			Knvv build = Knvv.builder().rowNum(rowNum).build();
			List<Knvv> list = gpMapper.selectKnvvCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Knvv:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Knvv source = sapMapper.selectKnvvById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteKnvv(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 {
								gpMapper.updateKnvv(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Knvv:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectKnvvCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Knvv:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectAfvcCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Afvc:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Afvc:rowNum");
			Afvc build = Afvc.builder().rowNum(rowNum).build();
			List<Afvc> list = gpMapper.selectAfvcCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Afvc:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Afvc source = sapMapper.selectAfvcById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteAfvc(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 {
								gpMapper.updateAfvc(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Afvc:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectAfvcCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Afvc:rowNum", getErrorInfoFromException(e));
		}
	}
	
	private void selectMkpfCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Mkpf:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Mkpf:rowNum");
			Mkpf build = Mkpf.builder().rowNum(rowNum).build();
			List<Mkpf> list = gpMapper.selectMkpfCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Mkpf:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Mkpf source = sapMapper.selectMkpfById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteMkpf(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 {
								gpMapper.updateMkpf(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Mkpf:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectMkpfCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Mkpf:rowNum", getErrorInfoFromException(e));
		}
	}
	
	private void selectMsegCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Mseg:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Mseg:rowNum");
			Mseg build = Mseg.builder().rowNum(rowNum).build();
			List<Mseg> list = gpMapper.selectMsegCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Mseg:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Mseg source = sapMapper.selectMsegById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteMseg(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 {
								gpMapper.updateMseg(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Mseg:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectMsegCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Mseg:rowNum", getErrorInfoFromException(e));
		}
	}
	
	private void selectAfruCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Afru:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Afru:rowNum");
			Afru build = Afru.builder().rowNum(rowNum).build();
			List<Afru> list = gpMapper.selectAfruCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Afru:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Afru source = sapMapper.selectAfruById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteAfru(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 {
								gpMapper.updateAfru(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Afru:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectAfruCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Afru:rowNum", getErrorInfoFromException(e));
		}
	}
	
	private void selectAuspCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Ausp:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Ausp:rowNum");
			Ausp build = Ausp.builder().rowNum(rowNum).build();
			List<Ausp> list = gpMapper.selectAuspCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Ausp:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Ausp source = sapMapper.selectAuspById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteAusp(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 {
								gpMapper.updateAusp(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Ausp:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectAuspCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Ausp:rowNum", getErrorInfoFromException(e));
		}
	}
	
	private void selectTspatCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Tspat:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Tspat:rowNum");
			Tspat build = Tspat.builder().rowNum(rowNum).build();
			List<Tspat> list = gpMapper.selectTspatCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Tspat:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Tspat source = sapMapper.selectTspatById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTspat(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 {
								gpMapper.updateTspat(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Tspat:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTspatCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Tspat:rowNum", getErrorInfoFromException(e));
		}
	}
	
	private void selectZpoeditCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Zpoedit:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Zpoedit:rowNum");
			Zpoedit build = Zpoedit.builder().rowNum(rowNum).build();
			List<Zpoedit> list = gpMapper.selectZpoeditCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Zpoedit:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Zpoedit source = sapMapper.selectZpoeditById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteZpoedit(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 {
								gpMapper.updateZpoedit(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Zpoedit:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectZpoeditCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Zpoedit:rowNum", getErrorInfoFromException(e));
		}
	}
	
	// 数据量过大不再执行任务
	private void selectKonvCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Konv:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Konv:rowNum");
			Konv build = Konv.builder().rowNum(rowNum).build();
			List<Konv> list = gpMapper.selectKonvCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Konv:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Konv source = sapMapper.selectKonvById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteKonv(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 {
								gpMapper.updateKonv(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Konv:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectKonvCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Konv:rowNum", getErrorInfoFromException(e));
		}
	}
	// 计数器复位删除
	private void selectLikpCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Likp:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Likp:rowNum");
			Likp build = Likp.builder().rowNum(rowNum).build();

			List<Likp> list = gpMapper.selectLikpCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				// 按更新时间查询，查询大于今天的数据，此时就不需要重置计数器了
				String aedat = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"); // 昨天的日期
				build = Likp.builder().rowNum(rowNum).aedat(aedat).build();
				// 查询出列表20个，下面的代码运行后会复位一个阶段的rowNum，如此往复list.size()就不会为0了
				list = gpMapper.selectLikpCheckByUpdate(build);
				// 是否为list.size() == 0的时候的更新时间查询的列表
				opsForValue.set("huazheng:check:Likp:isUpdateList", "true");
			} else {
				redis1Template.delete("huazheng:check:Likp:isUpdateList");
			}

			list.forEach(target -> { // 遍历要检查的数据
				Likp source = sapMapper.selectLikpById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteLikp(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);
						// ===============================
						source.setErdat1(caDate(source.getErdat())); // 日期00000000格式转换,已处理异常
						source.setWadat_ist1(caDate(source.getWadat_ist())); // 日期00000000格式转换,已处理异常
						// ===============================
						while (true) {
							try {
								gpMapper.updateLikp(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}

				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Likp:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Likp:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}

				if (!operator.equals("none")) {
					log.info(String.format("selectLikpCheck --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Likp:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectLikpCheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Likp:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Likp:rowNum");
			Likp build = Likp.builder().rowNum(rowNum).build();

			List<Likp> list = gpMapper.selectLikpCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:checkDelete:Likp:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}

			list.forEach(target -> { // 遍历要检查的数据
				Likp source = sapMapper.selectLikpById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteLikp(target); // 删除数仓中的数据
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Likp:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectLikpCheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Likp:rowNum", getErrorInfoFromException(e));
		}
	}
	// 计数器复位删除
	private void selectLipsCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Lips:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Lips:rowNum");
			Lips build = Lips.builder().rowNum(rowNum).build();

			List<Lips> list = gpMapper.selectLipsCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				// 按更新时间查询，查询大于今天的数据，此时就不需要重置计数器了
				String aedat = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"); // 昨天的日期
				build = Lips.builder().rowNum(rowNum).aedat(aedat).build();
				// 查询出列表20个，下面的代码运行后会复位一个阶段的rowNum，如此往复list.size()就不会为0了
				list = gpMapper.selectLipsCheckByUpdate(build);
				// 是否为list.size() == 0的时候的更新时间查询的列表
				opsForValue.set("huazheng:check:Lips:isUpdateList", "true");
			} else {
				redis1Template.delete("huazheng:check:Lips:isUpdateList");
			}

			list.forEach(target -> { // 遍历要检查的数据
				Lips source = sapMapper.selectLipsById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteLips(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.getErdat() != null && source.getErzet() != null) {
							String erdat2 = new StringBuffer(source.getErdat()).insert(4, "-").insert(7, "-").toString();
							String erzet2 = new StringBuffer(source.getErzet()).insert(2, ":").insert(5, ":").toString();
							String dateStr = erdat2 + " " + erzet2;
							Date date = DateUtil.parse(dateStr);
							source.setErdat1(date);
							source.setErdat2(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateLips(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}

				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Lips:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Lips:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}

				if (!operator.equals("none")) {
					log.info(String.format("selectLipsCheck --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Lips:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectLipsCheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Lips:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Lips:rowNum");
			Lips build = Lips.builder().rowNum(rowNum).build();

			List<Lips> list = gpMapper.selectLipsCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
			}

			list.forEach(target -> { // 遍历要检查的数据
				Lips source = sapMapper.selectLipsById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteLips(target); // 删除数仓中的数据
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Lips:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectLipsCheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Lips:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectMaktCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Makt:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Makt:rowNum");
			Makt build = Makt.builder().rowNum(rowNum).build();
			List<Makt> list = gpMapper.selectMaktCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Makt:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Makt source = sapMapper.selectMaktById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteMakt(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);
						// ===============================
						String maktx = source.getMaktx();
						if (maktx != null && !maktx.equals("")) {
							String[] split = maktx.split("-");
							for (int i = split.length - 1; i >= 0; i--) {
								String string = split[i];
								if (string.indexOf("*") != -1) {
									source.setMaktxSize(string.split("\\*")[0]); // 分割出尺寸数据
									break;
								}
							}
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateMakt(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Makt:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectMaktCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Makt:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectMaraCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Mara:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Mara:rowNum");
			Mara build = Mara.builder().rowNum(rowNum).build();
			List<Mara> list = gpMapper.selectMaraCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Mara:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Mara source = sapMapper.selectMaraById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteMara(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.getErsda() != null) {
							String erdat2 = new StringBuffer(source.getErsda()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setErsda1(date);
						}
						if (source.getLaeda() != null) {
							String erdat2 = new StringBuffer(source.getLaeda()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setLaeda1(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateMara(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Mara:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectMaraCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Mara:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectMskaCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Mska:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Mska:rowNum");
			Mska build = Mska.builder().rowNum(rowNum).build();
			List<Mska> list = gpMapper.selectMskaCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Mska:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Mska source = sapMapper.selectMskaById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteMska(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 {
								gpMapper.updateMska(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Mska:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectMskaCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Mska:rowNum", getErrorInfoFromException(e));
		}
	}
	// 计数器复位删除
	private void selectPa0002Check() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Pa0002:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Pa0002:rowNum");
			Pa0002 build = Pa0002.builder().rowNum(rowNum).build();

			List<Pa0002> list = gpMapper.selectPa0002Check(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				// 按更新时间查询，查询大于今天的数据，此时就不需要重置计数器了
				String aedtm = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"); // 昨天的日期
				build = Pa0002.builder().rowNum(rowNum).aedtm(aedtm).build();
				// 查询出列表20个，下面的代码运行后会复位一个阶段的rowNum，如此往复list.size()就不会为0了
				list = gpMapper.selectPa0002CheckByUpdate(build);
				// 是否为list.size() == 0的时候的更新时间查询的列表
				opsForValue.set("huazheng:check:Pa0002:isUpdateList", "true");
			} else {
				redis1Template.delete("huazheng:check:Pa0002:isUpdateList");
			}

			list.forEach(target -> { // 遍历要检查的数据
				Pa0002 source = sapMapper.selectPa0002ById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deletePa0002(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.getEndda() != null) {
							String erdat2 = new StringBuffer(source.getEndda()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setEndda1(date);
						}
						source.setYeWuYMC(source.getNachn() + source.getVorna());
						// ===============================
						while (true) {
							try {
								gpMapper.updatePa0002(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Vbrk:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Pa0002:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}

				if (!operator.equals("none")) {
					log.info(String.format("selectPa0002Check --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Pa0002:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectPa0002CheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Pa0002:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Pa0002:rowNum");
			Pa0002 build = Pa0002.builder().rowNum(rowNum).build();

			List<Pa0002> list = gpMapper.selectPa0002Check(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:checkDelete:Pa0002:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}

			list.forEach(target -> { // 遍历要检查的数据
				Pa0002 source = sapMapper.selectPa0002ById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deletePa0002(target); // 删除数仓中的数据
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Pa0002:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectPa0002CheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Pa0002:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectS066Check() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:S066:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:S066:rowNum");
			S066 build = S066.builder().rowNum(rowNum).build();
			List<S066> list = gpMapper.selectS066Check(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:S066:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				S066 source = sapMapper.selectS066ById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteS066(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);
						// ===============================
						String sptags = source.getSptags(); // 日期转义
						if (sptags == null || sptags.equals("00000000") || StrUtil.isBlank(sptags)) {
							Date date = DateUtil.parse("1970-01-01 00:00:00").toJdkDate();
							source.setSptag(date);
						} else {
							String erdat2 = new StringBuffer(sptags).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setSptag(date);
						}
						if (source.getSpwocs() == null) {
							source.setSpwocs("000000");
						}
						if (source.getSpbups() == null) {
							source.setSpbups("000000");
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateS066(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:S066:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectS066Check --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:S066:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectS067Check() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:S067:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:S067:rowNum");
			S067 build = S067.builder().rowNum(rowNum).build();
			List<S067> list = gpMapper.selectS067Check(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:S067:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				S067 source = sapMapper.selectS067ById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteS067(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);
						// ===============================
						String sptags = source.getSptags(); // 日期转义
						if (sptags == null || sptags.equals("00000000") || StrUtil.isBlank(sptags)) {
							Date date = DateUtil.parse("1970-01-01 00:00:00").toJdkDate();
							source.setSptag(date);
						} else {
							String erdat2 = new StringBuffer(sptags).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setSptag(date);
						}
						if (source.getSpwocs() == null) {
							source.setSpwocs("000000");
						}
						if (source.getSpbups() == null) {
							source.setSpbups("000000");
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateS067(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:S067:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectS067Check --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:S067:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectT001wCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:T001w:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:T001w:rowNum");
			T001w build = T001w.builder().rowNum(rowNum).build();
			List<T001w> list = gpMapper.selectT001wCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:T001w:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				T001w source = sapMapper.selectT001wById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteT001w(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 {
								gpMapper.updateT001w(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:T001w:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectT001wCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:T001w:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectT023tCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:T023t:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:T023t:rowNum");
			T023t build = T023t.builder().rowNum(rowNum).build();
			List<T023t> list = gpMapper.selectT023tCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:T023t:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				T023t source = sapMapper.selectT023tById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteT023t(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 {
								gpMapper.updateT023t(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:T023t:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectT023tCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:T023t:rowNum", getErrorInfoFromException(e));
		}
	}
	// 计数器复位删除
	private void selectVbakCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbak:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbak:rowNum");
			Vbak build = Vbak.builder().rowNum(rowNum).build();

			List<Vbak> list = gpMapper.selectVbakCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				// 按更新时间查询，查询大于今天的数据，此时就不需要重置计数器了
				String aedat = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"); // 昨天的日期
				build = Vbak.builder().rowNum(rowNum).aedat(aedat).build();
				// 查询出列表20个，下面的代码运行后会复位一个阶段的rowNum，如此往复list.size()就不会为0了
				list = gpMapper.selectVbakCheckByUpdate(build);
				// 是否为list.size() == 0的时候的更新时间查询的列表
				opsForValue.set("huazheng:check:Vbak:isUpdateList", "true");
			} else {
				redis1Template.delete("huazheng:check:Vbak:isUpdateList");
			}

			list.forEach(target -> { // 遍历要检查的数据
				Vbak source = sapMapper.selectVbakById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbak(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);
						// ===============================
						source.setAudat1(caDate(source.getAudat())); // 日期00000000格式转换,已处理异常
						// ===============================
						while (true) {
							try {
								gpMapper.updateVbak(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}

				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Vbak:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Vbak:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}

				if (!operator.equals("none")) {
					log.info(String.format("selectVbakCheck --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbak:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectVbakCheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Vbak:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Vbak:rowNum");
			Vbak build = Vbak.builder().rowNum(rowNum).build();

			List<Vbak> list = gpMapper.selectVbakCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:checkDelete:Vbak:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Vbak source = sapMapper.selectVbakById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbak(target); // 删除数仓中的数据
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Vbak:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbakCheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbak:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectVbepCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbep:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbep:rowNum");
			Vbep build = Vbep.builder().rowNum(rowNum).build();
			List<Vbep> list = gpMapper.selectVbepCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Vbep:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			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));
		}
	}
	private void selectVbpaCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbpa:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbpa:rowNum");
			Vbpa build = Vbpa.builder().rowNum(rowNum).build();
			List<Vbpa> list = gpMapper.selectVbpaCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Vbpa:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Vbpa source = sapMapper.selectVbpaById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbpa(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 {
								gpMapper.updateVbpa(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Vbpa:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbpaCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbpa:rowNum", getErrorInfoFromException(e));
		}
	}
	// 计数器复位删除
	private void selectVbrkCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbrk:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbrk:rowNum");
			Vbrk build = Vbrk.builder().rowNum(rowNum).build();

			List<Vbrk> list = gpMapper.selectVbrkCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				// 按更新时间查询，查询大于今天的数据，此时就不需要重置计数器了
				String aedat = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"); // 昨天的日期
				build = Vbrk.builder().rowNum(rowNum).aedat(aedat).build();
				// 查询出列表20个，下面的代码运行后会复位一个阶段的rowNum，如此往复list.size()就不会为0了
				list = gpMapper.selectVbrkCheckByUpdate(build);
				// 是否为list.size() == 0的时候的更新时间查询的列表
				opsForValue.set("huazheng:check:Vbrk:isUpdateList", "true");
			} else {
				redis1Template.delete("huazheng:check:Vbrk:isUpdateList");
			}

			list.forEach(target -> { // 遍历要检查的数据
				Vbrk source = sapMapper.selectVbrkById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbrk(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.getFkdat() != null) {
							String erdat2 = new StringBuffer(source.getFkdat()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setFkdat1(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateVbrk(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}

				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Vbrk:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Vbrk:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}

				if (!operator.equals("none")) {
					log.info(String.format("selectVbrkCheck --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbrk:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectVbrkCheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Vbrk:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Vbrk:rowNum");
			Vbrk build = Vbrk.builder().rowNum(rowNum).build();

			List<Vbrk> list = gpMapper.selectVbrkCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:checkDelete:Vbrk:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}

			list.forEach(target -> { // 遍历要检查的数据
				Vbrk source = sapMapper.selectVbrkById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbrk(target); // 删除数仓中的数据
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Vbrk:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbrkCheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbrk:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectVbrpCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbrp:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbrp:rowNum");
			Vbrp build = Vbrp.builder().rowNum(rowNum).build();
			List<Vbrp> list = gpMapper.selectVbrpCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Vbrp:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Vbrp source = sapMapper.selectVbrpById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbrp(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 {
								gpMapper.updateVbrp(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Vbrp:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbrpCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbrp:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectVbukCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbuk:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbuk:rowNum");
			Vbuk build = Vbuk.builder().rowNum(rowNum).build();
			List<Vbuk> list = gpMapper.selectVbukCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Vbuk:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Vbuk source = sapMapper.selectVbukById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbuk(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 {
								gpMapper.updateVbuk(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Vbuk:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbukCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbuk:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectZmdpcCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Zmdpc:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Zmdpc:rowNum");
			Zmdpc build = Zmdpc.builder().rowNum(rowNum).build();
			List<Zmdpc> list = gpMapper.selectZmdpcCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Zmdpc:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Zmdpc source = sapMapper.selectZmdpcById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteZmdpc(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 {
								gpMapper.updateZmdpc(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Zmdpc:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectZmdpcCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Zmdpc:rowNum", getErrorInfoFromException(e));
		}
	}
	// 计数器复位删除
	private void selectZsd06Check() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Zsd06:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Zsd06:rowNum");
			Zsd06 build = Zsd06.builder().rowNum(rowNum).build();

			List<Zsd06> list = gpMapper.selectZsd06Check(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				// 按更新时间查询，查询大于今天的数据，此时就不需要重置计数器了
				String cha_datum = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"); // 昨天的日期
				build = Zsd06.builder().rowNum(rowNum).cha_datum(cha_datum).build();
				// 查询出列表20个，下面的代码运行后会复位一个阶段的rowNum，如此往复list.size()就不会为0了
				list = gpMapper.selectZsd06CheckByUpdate(build);
				// 是否为list.size() == 0的时候的更新时间查询的列表
				opsForValue.set("huazheng:check:Zsd06:isUpdateList", "true");
			} else {
				redis1Template.delete("huazheng:check:Zsd06:isUpdateList");
			}

			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);
						// ===============================
						if (source.getDatum() != null) {
							String erdat2 = new StringBuffer(source.getDatum()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setDatum1(date);
						}
						source.setCrt_datum1(caDate(source.getCrt_datum()));
						source.setCha_datum1(caDate(source.getCha_datum()));
						// ===============================
						while (true) {
							try {
								gpMapper.updateZsd06(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Zsd06:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Zsd06:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}

				if (!operator.equals("none")) {
					log.info(String.format("selectZsd06Check --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Zsd06:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectZsd06CheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Zsd06:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Zsd06:rowNum");
			Zsd06 build = Zsd06.builder().rowNum(rowNum).build();

			List<Zsd06> list = gpMapper.selectZsd06Check(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:checkDelete:Zsd06:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}

			list.forEach(target -> { // 遍历要检查的数据
				Zsd06 source = sapMapper.selectZsd06ById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteZsd06(target); // 删除数仓中的数据
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Zsd06:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectZsd06CheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Zsd06:rowNum", getErrorInfoFromException(e));
		}
	}
	// 计数器复位删除
	private void selectZsdfhzlCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Zsdfhzl:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Zsdfhzl:rowNum");
			Zsdfhzl build = Zsdfhzl.builder().rowNum(rowNum).build();

			List<Zsdfhzl> list = gpMapper.selectZsdfhzlCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				// 按更新时间查询，查询大于今天的数据，此时就不需要重置计数器了
				String cha_datum = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"); // 昨天的日期
				build = Zsdfhzl.builder().rowNum(rowNum).cha_datum(cha_datum).build();
				// 查询出列表20个，下面的代码运行后会复位一个阶段的rowNum，如此往复list.size()就不会为0了
				list = gpMapper.selectZsdfhzlCheckByUpdate(build);
				// 是否为list.size() == 0的时候的更新时间查询的列表
				opsForValue.set("huazheng:check:Zsdfhzl:isUpdateList", "true");
			} else {
				redis1Template.delete("huazheng:check:Zsdfhzl:isUpdateList");
			}

			list.forEach(target -> { // 遍历要检查的数据
				Zsdfhzl source = sapMapper.selectZsdfhzlById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteZsdfhzl(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.getCdate() != null && source.getCtime() != null) {
							String erdat2 = new StringBuffer(source.getCdate()).insert(4, "-").insert(7, "-").toString();
							String erzet2 = new StringBuffer(source.getCtime()).insert(2, ":").insert(5, ":").toString();
							String dateStr = erdat2 + " " + erzet2;
							Date date = DateUtil.parse(dateStr);
							source.setCdate1(date);
						}
						if (source.getFh_date() != null && source.getFh_date().indexOf("--") == -1) {
							String erdat2 = new StringBuffer(source.getFh_date()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setFh_date1(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateZsdfhzl(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Zsdfhzl:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Zsdfhzl:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}

				if (!operator.equals("none")) {
					log.info(String.format("selectZsdfhzlCheck --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Zsdfhzl:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectZsdfhzlCheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Zsdfhzl:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Zsdfhzl:rowNum");
			Zsdfhzl build = Zsdfhzl.builder().rowNum(rowNum).build();

			List<Zsdfhzl> list = gpMapper.selectZsdfhzlCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:checkDelete:Zsdfhzl:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}

			list.forEach(target -> { // 遍历要检查的数据
				Zsdfhzl source = sapMapper.selectZsdfhzlById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteZsdfhzl(target); // 删除数仓中的数据
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Zsdfhzl:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectZsdfhzlCheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Zsdfhzl:rowNum", getErrorInfoFromException(e));
		}
	}
	
	private void selectTvkbtCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Tvkbt:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Tvkbt:rowNum");
			Tvkbt build = Tvkbt.builder().rowNum(rowNum).build();
			List<Tvkbt> list = gpMapper.selectTvkbtCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Tvkbt:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Tvkbt source = sapMapper.selectTvkbtById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTvkbt(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 {
								gpMapper.updateTvkbt(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Tvkbt:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTvkbtCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Tvkbt:rowNum", getErrorInfoFromException(e));
		}
	}

	public void checkJob5() {
		selectVbapCheck(); // 44
	}
	// 计数器复位删除
	private void selectVbapCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbap:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbap:rowNum");
			Vbap build = Vbap.builder().rowNum(rowNum).build();

			List<Vbap> list = gpMapper.selectVbapCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:check:Vbap:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			} else {
				redis1Template.delete("huazheng:check:Vbap:isUpdateList");
			}
			list.forEach(target -> { // 遍历要检查的数据
				Vbap source = sapMapper.selectVbapById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbap(target); // 删除数仓中的数据
					gpMapper.deleteVbapAdv(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.getErdat() != null && source.getErzet() != null) {
							String erdat2 = new StringBuffer(source.getErdat()).insert(4, "-").insert(7, "-").toString();
							String erzet2 = new StringBuffer(source.getErzet()).insert(2, ":").insert(5, ":").toString();
							String dateStr = erdat2 + " " + erzet2;
							Date date = DateUtil.parse(dateStr);
							source.setErdat1(date);
							source.setErdat2(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateVbap(source); // 更新数据到数仓中
								gpMapper.updateVbapAdv(source);
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
						try {
							Future<VbapAdv> vbapAdvSubmit = service.submit(() -> {
								return gpMapper.selectVbapAdv(source);
							});
							
							Future<BigDecimal> ccslSubmit = service.submit(() -> {
								return gpMapper.caLips4ccsl(source);
							});
							Future<BigDecimal> jhslSubmit = service.submit(() -> {
								return gpMapper.caVbep4jhsl(source);
							});
							Future<BigDecimal> rkslSubmit = service.submit(() -> {
								return gpMapper.caAfpo4rksl(source);
							});
							Future<BigDecimal> pcslSubmit = service.submit(() -> {
								return gpMapper.caAfpo4pcsl(source);
							});
							Future<BigDecimal> kpslSubmit = service.submit(() -> {
								return gpMapper.caVbrp4kpsl(source);
							});
							Future<Date> jhsjSubmit = service.submit(() -> {
								return gpMapper.caVbep4jhsj(source);
							});
							Future<Date> kpsjSubmit = service.submit(() -> {
								return gpMapper.caVbrk4kpsj(source);
							});
							Future<Date> rksjSubmit = service.submit(() -> {
								return gpMapper.caAufm4rksj(source);
							});
							Future<Date> ccsjSubmit = service.submit(() -> {
								return gpMapper.caHandover4ccsj(source);
							});
							Future<Date> wlsjSubmit = service.submit(() -> {
								return gpMapper.caHandover4wlsj(source);
							});
							
							VbapAdv vbapAdv = vbapAdvSubmit.get();
							vbapAdv.setCcsl(ccslSubmit.get());
							vbapAdv.setJhsl(jhslSubmit.get());
							vbapAdv.setRksl(rkslSubmit.get());
							vbapAdv.setPcsl(pcslSubmit.get());
							vbapAdv.setKpsl(kpslSubmit.get());
							vbapAdv.setJhsj(jhsjSubmit.get());
							vbapAdv.setKpsj(kpsjSubmit.get());
							vbapAdv.setRksj(rksjSubmit.get());
							vbapAdv.setCcsj(ccsjSubmit.get());
							vbapAdv.setWlsj(wlsjSubmit.get());
							vbapAdv.setHtsl(source.getKwmeng());
							vbapAdv.setPssj(source.getErdat1());
							vbapAdv.setPcsj(source.getErdat1());
							gpMapper.updatevbapAdv4CaAll(vbapAdv);
							
//							Future<String> s1 = service.submit(() -> {
								Aufk aufk = gpMapper.selectVbapAdv4Aufk(source); // vbap-aufk
								if (aufk != null) {
									aufk.setVbap(source);
									gpMapper.updateVbapAdv4Aufk(aufk); // vbap-aufk
								}
//								return "ok";
//							});
//							Future<String> s2 = service.submit(() -> {
								SysSAPreturnNo sysSAPreturnNo = gpMapper.selectVbapAdv4SysSAPreturnNo(source); // vbap-SysSAPreturnNo
								if (sysSAPreturnNo != null) {
									sysSAPreturnNo.setVbap(source);
									gpMapper.updateVbapAdv4SysSAPreturnNo(sysSAPreturnNo); // vbap-SysSAPreturnNo
								}
//								return "ok";
//							});
//							Future<String> s3 = service.submit(() -> {
								SalesContractProcess salesContractProcess = gpMapper.selectVbapAdv4SalesContractProcess(source); // vbap-SysSAPreturnNo-SalesContractProcess
								if (salesContractProcess != null) {
									salesContractProcess.setVbap(source);
									gpMapper.updateVbapAdv4SalesContractProcess(salesContractProcess); // vbap-SysSAPreturnNo-SalesContractProcess
								}
//								return "ok";
//							});
//							Future<String> s4 = service.submit(() -> {
								Mara mara = gpMapper.selectVbapAdv4Mara(source); // vbap-Mara
								if (mara != null) {
									mara.setVbap(source);
									gpMapper.updateVbapAdv4Mara(mara); // vbap-Mara
								}
//								return "ok";
//							});
//							Future<String> s5 = service.submit(() -> {
								Makt makt = gpMapper.selectVbapAdv4Makt(source); // vbap-Makt
								if (makt != null) {
									makt.setVbap(source);
									gpMapper.updateVbapAdv4Makt(makt); // vbap-Makt
								}
//								return "ok";
//							});
//							Future<String> s6 = service.submit(() -> {
								Zsd06 zsd06 = gpMapper.selectVbapAdv4Zsd06(source); // vbap-Zsd06
								if (zsd06 != null) {
									zsd06.setVbap(source);
									gpMapper.updateVbapAdv4Zsd06(zsd06); // vbap-Zsd06
								}
//								return "ok";
//							});
//							Future<String> s7 = service.submit(() -> {
								Vbak vbak = gpMapper.selectVbapAdv4Vbak(source); // vbap-Vbak
								if (vbak != null) {
									vbak.setVbap(source);
									gpMapper.updateVbapAdv4Vbak(vbak); // vbap-Vbak
								}
//								return "ok";
//							});
//							Future<String> s8 = service.submit(() -> {
								Likp likp = gpMapper.selectVbapAdv4Likp(source); // vbap-lips-Likp
								if (likp != null) {
									likp.setVbap(source);
									gpMapper.updateVbapAdv4Likp(likp); // vbap-lips-Likp
								}
//								return "ok";
//							});
//							Future<String> s9 = service.submit(() -> {
								Handover handover = gpMapper.selectVbapAdv4Handover(source); // vbap-lips-Likp-Handover
								if (handover != null) {
									handover.setVbap(source);
									gpMapper.updateVbapAdv4Handover(handover); // vbap-lips-Likp-Handover
								}
//								return "ok";
//							});
//							Future<String> s10 = service.submit(() -> {
								Zmdpc zmdpc = gpMapper.selectVbapAdv4Zmdpc(source); // vbap-Zmdpc
								if (zmdpc != null) {
									zmdpc.setVbap(source);
									gpMapper.updateVbapAdv4Zmdpc(zmdpc); // vbap-Zmdpc
								}
//								return "ok";
//							});
//							Future<String> s11 = service.submit(() -> {
								T023t t023t = gpMapper.selectVbapAdv4T023t(source); // vbap-mara-T023t
								if (t023t != null) {
									t023t.setVbap(source);
									gpMapper.updateVbapAdv4T023t(t023t); // vbap-mara-T023t
								}
//								return "ok";
//							});
//							Future<String> s12 = service.submit(() -> {
								Kna1 kna1 = gpMapper.selectVbapAdv4Kna1(source); // vbap-vbak-Kna1
								if (kna1 != null) {
									kna1.setVbap(source);
									gpMapper.updateVbapAdv4Kna1(kna1); // vbap-vbak-Kna1
								}
//								return "ok";
//							});
//							log.info("=========== vbap ===== ca" + source.getVbeln());
//							s1.get();log.info("=========== vbap ===== cas1" + source.getVbeln());
//							s2.get();log.info("=========== vbap ===== cas2" + source.getVbeln());
//							s3.get();log.info("=========== vbap ===== cas3" + source.getVbeln());
//							s4.get();log.info("=========== vbap ===== cas4" + source.getVbeln());
//							s5.get();log.info("=========== vbap ===== cas5" + source.getVbeln());
//							s6.get();log.info("=========== vbap ===== cas6" + source.getVbeln());
//							s7.get();log.info("=========== vbap ===== cas7" + source.getVbeln());
//							s8.get();log.info("=========== vbap ===== cas8" + source.getVbeln());
//							s9.get();log.info("=========== vbap ===== cas9" + source.getVbeln());
//							s10.get();log.info("=========== vbap ===== cas10" + source.getVbeln());
//							s11.get();log.info("=========== vbap ===== cas11" + source.getVbeln());
//							s12.get();log.info("=========== vbap ===== cas12" + source.getVbeln());
							
						} catch (Exception e) {
							redis1Template.opsForValue().set("huazheng:checkError:Vbap:rowNum", getErrorInfoFromException(e));
						}
					}
				}
				String mode = null;
				String isUpdateList = opsForValue.get("huazheng:check:Vbap:isUpdateList");
				if (isUpdateList == null) { // 非更新模式下的列表才更新计数器
					redis1Template.opsForValue().set("huazheng:check:Vbap:rowNum", target.getRowNum());
					mode = "计数器模式";
				} else {
					mode = "更新时间模式";
				}
				if (!operator.equals("none")) {
					log.info(String.format("selectVbapCheck --> rowNum:%s, operator:%s, %s", target.getRowNum(), operator, mode));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbap:rowNum", getErrorInfoFromException(e));
		}
	}
	
	// 有更新时间的表的删除计数器需要拆分出来，避免数据不能删除
	// 把这些方法的删除部分从原方法种剥离出来
	public void checkJob6() {
		selectKnkkCheckDelete();
		selectLikpCheckDelete();
		selectLipsCheckDelete();
		selectPa0002CheckDelete();
		selectVbakCheckDelete();
		selectVbrkCheckDelete();
		selectZsd06CheckDelete();
		selectZsdfhzlCheckDelete();
		selectVbapCheckDelete();
	}
	private void selectVbapCheckDelete() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:checkDelete:Vbap:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:checkDelete:Vbap:rowNum");
			Vbap build = Vbap.builder().rowNum(rowNum).build();

			List<Vbap> list = gpMapper.selectVbapCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:checkDelete:Vbap:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}

			list.forEach(target -> { // 遍历要检查的数据
				Vbap source = sapMapper.selectVbapById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbap(target); // 删除数仓中的数据
					gpMapper.deleteVbapAdv(target);
					operator = "delete";
				}
				redis1Template.opsForValue().set("huazheng:checkDelete:Vbap:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbapCheckDelete --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbap:rowNum", getErrorInfoFromException(e));
		}
	}
	
	public void checkJob7() {
		selectBsadCheck(); // 41 Bsid2Bsad 43
		selectBsidCheck(); // 42 Bsid2Bsad 43
	}
	private void selectBsadCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Bsad:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Bsad:rowNum");
			Bsad build = Bsad.builder().rowNum(rowNum).build();
			List<Bsad> list = gpMapper.selectBsadCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Bsad:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Bsad source = sapMapper.selectBsadById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteBsad(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 (StrUtil.isBlank(source.getUmsks())) {
							source.setUmskz(""); // 属于主键组，不能为空
						}
						String augdts = source.getAugdts(); // 日期转义
						if (augdts == null || augdts.equals("00000000") || StrUtil.isBlank(augdts)) {
							Date date = DateUtil.parse("1970-01-01 00:00:00");
							source.setAugdt(date);
						} else {
							String erdat2 = new StringBuffer(augdts).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setAugdt(date);
						}
						String zfbdts = source.getZfbdts(); // 转义日期
						if (zfbdts == null || zfbdts.equals("00000000") || StrUtil.isBlank(zfbdts)) {
							Date date = DateUtil.parse("1970-01-01 00:00:00");
							source.setZfbdt(date);
						} else {
							String erdat2 = new StringBuffer(zfbdts).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setZfbdt(date);
						}
						String budats = source.getBudats(); // 转义日期
						if (budats == null || budats.equals("00000000") || StrUtil.isBlank(budats)) {
							Date date = DateUtil.parse("1970-01-01 00:00:00");
							source.setBudat(date);
							source.setBudatc("1970-01");
							source.setDqsjc(null); // 到期时间不用计算
						} else {
							String erdat2 = new StringBuffer(budats).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setBudat(date);
							source.setBudatc(DateUtil.format(date, "yyyy-MM"));
							
							int budatDay = Integer.parseInt(DateUtil.format(source.getBudat(), "dd")); // 过账日期
							if (budatDay > 26) { // budat(过账日期) > 26号 ：zfbdt(基准日期)+2个月
								source.setDqsjc(DateUtil.offset(source.getZfbdt(), DateField.MONTH, 2)); // 到期时间
								// 根据过账日期判断日是否>26，大于的话，就在过账日期的基础上加一个月，小于等于的话就是不变
								source.setBudatd(DateUtil.format(DateUtil.offset(source.getBudat(), DateField.MONTH, 1), "yyyy-MM"));
							} else if (budatDay <= 26) { // budat(过账日期) <= 26号 ：zfbdt(基准日期)+1个月
								source.setDqsjc(DateUtil.offset(source.getZfbdt(), DateField.MONTH, 1)); // 到期时间
								// 根据过账日期判断日是否>26，大于的话，就在过账日期的基础上加一个月，小于等于的话就是不变
								source.setBudatd(DateUtil.format(source.getBudat(), "yyyy-MM"));
							}
							
							if ("Z001".equals(source.getZterm())) {
								source.setDqsjc(source.getZfbdt()); // 现款，到期时间=基准日期
							}
							
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateBsad(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Bsad:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectBsadCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Bsad:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectBsidCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Bsid:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Bsid:rowNum");
			Bsid build = Bsid.builder().rowNum(rowNum).build();
			List<Bsid> list = gpMapper.selectBsidCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Bsid:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Bsid source = sapMapper.selectBsidById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteBsid(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 (StrUtil.isBlank(source.getUmsks())) {
							source.setUmskz(""); // 属于主键组，不能为空
						}
						String augdts = source.getAugdts(); // 日期转义
						if (augdts == null || augdts.equals("00000000") || StrUtil.isBlank(augdts)) {
							Date date = DateUtil.parse("1970-01-01 00:00:00");
							source.setAugdt(date);
						} else {
							String erdat2 = new StringBuffer(augdts).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setAugdt(date);
						}
						String zfbdts = source.getZfbdts(); // 转义日期
						if (zfbdts == null || zfbdts.equals("00000000") || StrUtil.isBlank(zfbdts)) {
							Date date = DateUtil.parse("1970-01-01 00:00:00");
							source.setZfbdt(date);
						} else {
							String erdat2 = new StringBuffer(zfbdts).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setZfbdt(date);
						}
						String budats = source.getBudats(); // 转义日期
						if (budats == null || budats.equals("00000000") || StrUtil.isBlank(budats)) {
							Date date = DateUtil.parse("1970-01-01 00:00:00");
							source.setBudat(date);
							source.setBudatc("1970-01");
							source.setDqsjc(null); // 到期时间不用计算
						} else {
							String erdat2 = new StringBuffer(budats).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setBudat(date);
							source.setBudatc(DateUtil.format(date, "yyyy-MM"));
							
							int budatDay = Integer.parseInt(DateUtil.format(source.getBudat(), "dd")); // 过账日期
							if (budatDay > 26) { // budat(过账日期) > 26号 ：zfbdt(基准日期)+2个月
								source.setDqsjc(DateUtil.offset(source.getZfbdt(), DateField.MONTH, 2)); // 到期时间
								// 根据过账日期判断日是否>26，大于的话，就在过账日期的基础上加一个月，小于等于的话就是不变
								source.setBudatd(DateUtil.format(DateUtil.offset(source.getBudat(), DateField.MONTH, 1), "yyyy-MM"));
							} else if (budatDay <= 26) { // budat(过账日期) <= 26号 ：zfbdt(基准日期)+1个月
								source.setDqsjc(DateUtil.offset(source.getZfbdt(), DateField.MONTH, 1)); // 到期时间
								// 根据过账日期判断日是否>26，大于的话，就在过账日期的基础上加一个月，小于等于的话就是不变
								source.setBudatd(DateUtil.format(source.getBudat(), "yyyy-MM"));
							}
							
							if ("Z001".equals(source.getZterm())) {
								source.setDqsjc(source.getZfbdt()); // 现款，到期时间=基准日期
							}
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateBsid(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Bsid:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectBsidCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Bsid:rowNum", getErrorInfoFromException(e));
		}
	}
	
	public void checkJob8() {
		selectTasksCheck();
		selectPersonCompCheck();
	}
	private void selectTasksCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Tasks:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Tasks:rowNum");
			Tasks build = Tasks.builder().rowNum(rowNum).build();
			List<Tasks> list = gpMapper.selectTasksCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Tasks:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Tasks source = ultimusDBMapper.selectTasksById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteTasks(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 {
								gpMapper.updateTasks(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Tasks:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectTasksCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Tasks:rowNum", getErrorInfoFromException(e));
		}
	}
	private void selectPersonCompCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:PersonComp:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:PersonComp:rowNum");
			PersonComp build = PersonComp.builder().rowNum(rowNum).build();
			List<PersonComp> list = gpMapper.selectPersonCompCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:PersonComp:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				PersonComp source = cinderellaw2Mapper.selectPersonCompById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deletePersonComp(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 {
								gpMapper.updatePersonComp(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:PersonComp:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectPersonCompCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:PersonComp:rowNum", getErrorInfoFromException(e));
		}
	}
	
	// 执行紧急任务
	public void checkBusy() {
		selectLikpCheck(); // 22
		selectVbakCheck(); // 32
	}
	
}
