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

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;
import java.util.List;

import org.quartz.JobKey;
import org.quartz.Scheduler;
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.greenplum.utils.SomeUtils;
import com.huazheng.project.hana.mapper.SapMapper;
import com.huazheng.project.hana.model.Afru;
import com.huazheng.project.hana.model.Afvc;
import com.huazheng.project.hana.model.Aufm;
import com.huazheng.project.hana.model.Knkk;
import com.huazheng.project.hana.model.Knvp;
import com.huazheng.project.hana.model.Likp;
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.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.Vbep;
import com.huazheng.project.hana.model.Zsd06;
import com.huazheng.project.mssql.mapper.CrmMapper;
import com.huazheng.project.mssql.model.SalesContractProcessMX;
import com.huazheng.project.mssql.model.SampleApplicationProcess;
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 cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.NumberUtil;
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 Scheduler quartzScheduler;
	
	@Autowired
	private RedisTemplate<String, String> redis1Template;

	@Autowired
	private SapMapper sapMapper;
	@Autowired
	private GPMapper gpMapper;
	@Autowired
	private HzcrmMapper hzcrmMapper;
//	@Autowired
//	private UltimusDBMapper ultimusDBMapper;
	@Autowired
	private Cinderellaw2Mapper cinderellaw2Mapper;
	@Autowired
	private CrmMapper crmMapper;
	
	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";
		}
	}
	
	public void checkJob2() {
		selectTKeHuCheck(); // 6
		selectTKeHuXiaoShouZZCheck(); // 7
		selectTKeHuXiaoShouZZYeWuYCheck(); // 8
		selectTWuLiaoDBCheck(); // 9
	}
	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 checkJob4() {
		selectKnkkCheck(); // 19
		selectMskaCheck(); // 26
		selectS066Check(); // 28
		selectS067Check(); // 29
		selectT001wCheck(); // 30
		selectT023tCheck(); // 31
		selectTvkbtCheck(); //
		selectAfvcCheck();
		selectTspatCheck();
		selectKnvpCheck();
	}
	
	// 计数器复位删除1
	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已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:check: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";
				} 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);
					}
				}

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

			List<Knkk> slist = sapMapper.selectKnkkCheckByUpdate(build); // 从源库中按更新时间查询
			if (slist.size() == 0) { // rowid已完成，则转为由更新时间字段开始同步
				redis1Template.opsForValue().set("huazheng:checkUpdate:Knkk:rowids", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			
			slist.forEach(source -> { // 遍历源库中的数据，去目标库中查询数据
				Knkk target = gpMapper.selectKnkk(source);
				String operator = "none";
				Long srowids = source.getRowids();
				if (target != null) {
					source.setRowids(null);
					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); // 更新数据到数仓中
								operator = "update";
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				
				redis1Template.opsForValue().set("huazheng:checkUpdate:Knkk:rowids", srowids.toString());
				if (!operator.equals("none")) {
					log.info(String.format("selectKnkkCheckUpdate --> rowids:%s, operator:%s", srowids.toString(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkUpdateError:Knkk:rowids", 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 selectKnvpCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Knvp:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Knvp:rowNum");
			Knvp build = Knvp.builder().rowNum(rowNum).build();
			List<Knvp> list = gpMapper.selectKnvpCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				redis1Template.opsForValue().set("huazheng:check:Knvp:rowNum", "0"); // 计数器复位
				ThreadUtil.sleep(1000); // 没有数据了，休眠一下
			}
			list.forEach(target -> { // 遍历要检查的数据
				Knvp source = sapMapper.selectKnvpById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteKnvp(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.updateKnvp(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Knvp:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectKnvpCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Knvp: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 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 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 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 checkJob8() {
		selectPersonCompCheck();
	}
	//独立的
//	public 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 selectMsegCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Mseg:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Mseg:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Mseg:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectMsegMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Mseg:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Mseg:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectMsegCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Mseg build = Mseg.builder().rowNum(rowNum).build();
			List<Mseg> list = gpMapper.selectMsegCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectMsegCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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));
		}
	}
	public void selectMkpfCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Mkpf:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Mkpf:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Mkpf:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectMkpfMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Mkpf:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Mkpf:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectMkpfCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Mkpf build = Mkpf.builder().rowNum(rowNum).build();
			List<Mkpf> list = gpMapper.selectMkpfCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectMkpfCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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));
		}
	}
	public void selectAufmCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Aufm:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Aufm:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Aufm:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectAufmMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Aufm:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Aufm:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectAufmCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Aufm build = Aufm.builder().rowNum(rowNum).build();
			List<Aufm> list = gpMapper.selectAufmCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectAufmCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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));
		}
	}
	public void selectAfruCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Afru:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Afru:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Afru:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectAfruMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Afru:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Afru:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectAfruCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Afru build = Afru.builder().rowNum(rowNum).build();
			List<Afru> list = gpMapper.selectAfruCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectAfruCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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));
		}
	}
	
	public void selectSampleApplicationProcessCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SampleApplicationProcess:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SampleApplicationProcess:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:SampleApplicationProcess:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectSampleApplicationProcessMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:SampleApplicationProcess:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:SampleApplicationProcess:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectSampleApplicationProcessCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			SampleApplicationProcess build = SampleApplicationProcess.builder().rowNum(rowNum).build();
			List<SampleApplicationProcess> list = gpMapper.selectSampleApplicationProcessCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectSampleApplicationProcessCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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);
						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));
		}
	}
	
	public void selectVbakCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbak:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbak:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Vbak:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectVbakMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Vbak:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Vbak:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectVbakCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Vbak build = Vbak.builder().rowNum(rowNum).build();
			List<Vbak> list = gpMapper.selectVbakCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectVbakCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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);
						while (true) {
							try {
								String erdat = source.getErdat();
								String erzet = source.getErzet();
								if ("00000000".equals(erdat)) {
									source.setErdat2erzet(null);
								} else {
									Date date = DateUtil.parse(erdat+erzet, "yyyyMMddHHmmss");
									source.setErdat2erzet(date);
								}
								source.setAudat1(SomeUtils.caDate(source.getAudat()));
								gpMapper.updateVbak(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Vbak:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbakCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbak:rowNum", getErrorInfoFromException(e));
		}
	}
	
	public void selectVbapCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbap:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbap:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Vbap:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectVbapMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Vbap:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Vbap:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectVbapCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Vbap build = Vbap.builder().rowNum(rowNum).build();
			List<Vbap> list = gpMapper.selectVbapCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectVbapCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			list.forEach(target -> { // 遍历要检查的数据
				Vbap source = sapMapper.selectVbapById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbap(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.updateVbap(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Vbap:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbapCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbap:rowNum", getErrorInfoFromException(e));
		}
	}
	
	public void selectSampleApplicationProcessMingXiCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SampleApplicationProcessMingXi:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SampleApplicationProcessMingXi:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:SampleApplicationProcessMingXi:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectSampleApplicationProcessMingXiMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:SampleApplicationProcessMingXi:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:SampleApplicationProcessMingXi:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectSampleApplicationProcessMingXiCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			SampleApplicationProcessMingXi build = SampleApplicationProcessMingXi.builder().rowNum(rowNum).build();
			List<SampleApplicationProcessMingXi> list = gpMapper.selectSampleApplicationProcessMingXiCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectSampleApplicationProcessMingXiCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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);
						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));
		}
	}
	
	public void selectSalesContractProcessMXCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SalesContractProcessMX:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SalesContractProcessMX:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:SalesContractProcessMX:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectSalesContractProcessMXMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:SalesContractProcessMX:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:SalesContractProcessMX:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectSalesContractProcessMXCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			SalesContractProcessMX build = SalesContractProcessMX.builder().rowNum(rowNum).build();
			List<SalesContractProcessMX> list = gpMapper.selectSalesContractProcessMXCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectSalesContractProcessMXCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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);
						while (true) {
							try {
								Object chengben = source.getChengben();
								if (chengben != null && chengben.toString().equals("")) {
									source.setChengben(null);
								}
								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));
		}
	}
	
	public void selectSysSAPreturnNoCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SysSAPreturnNo:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SysSAPreturnNo:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:SysSAPreturnNo:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectSysSAPreturnNoMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:SysSAPreturnNo:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:SysSAPreturnNo:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectSysSAPreturnNoCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			SysSAPreturnNo build = SysSAPreturnNo.builder().rowNum(rowNum).build();
			List<SysSAPreturnNo> list = gpMapper.selectSysSAPreturnNoCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectSysSAPreturnNoCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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));
		}
	}
	
	public void selectSampleClosingProcessCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SampleClosingProcess:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SampleClosingProcess:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:SampleClosingProcess:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectSampleClosingProcessMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:SampleClosingProcess:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:SampleClosingProcess:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectSampleClosingProcessCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			SampleClosingProcess build = SampleClosingProcess.builder().rowNum(rowNum).build();
			List<SampleClosingProcess> list = gpMapper.selectSampleClosingProcessCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectSampleClosingProcessCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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);
						while (true) {
							try {
								if (NumberUtil.isNumber(source.getYangPinSQSLH())) { 
									int yangPinSQSLHi = Integer.parseInt(source.getYangPinSQSLH());
									source.setYangPinSQSLHi(yangPinSQSLHi); 
									}
								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));
		}
	}
	
	public void selectSampleClosingProcessMingXiCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:SampleClosingProcessMingXi:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:SampleClosingProcessMingXi:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:SampleClosingProcessMingXi:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectSampleClosingProcessMingXiMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:SampleClosingProcessMingXi:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:SampleClosingProcessMingXi:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectSampleClosingProcessMingXiCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			SampleClosingProcessMingXi build = SampleClosingProcessMingXi.builder().rowNum(rowNum).build();
			List<SampleClosingProcessMingXi> list = gpMapper.selectSampleClosingProcessMingXiCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectSampleClosingProcessMingXiCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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 selectZsd06Check() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Zsd06:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Zsd06:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Zsd06:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectZsd06MaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Zsd06:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Zsd06:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectZsd06Check_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Zsd06 build = Zsd06.builder().rowNum(rowNum).build();
			List<Zsd06> list = gpMapper.selectZsd06Check(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectZsd06Check_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			list.forEach(target -> { // 遍历要检查的数据
				Zsd06 source = sapMapper.selectZsd06ById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteZsd06(target); // 删除数仓中的数据
					operator = "delete";
				} else { // 源库中有数据
					String shash = SecureUtil.md5(JSONUtil.toJsonStr(source)); // 源库中数据的hash结果
					String thash = target.getHashResult(); // 数仓中数据的hash结果
					if (!shash.equals(thash)) { // 如果hash结果不一致
						source.setHashResult(shash);
						while (true) {
							try {
								if (source.getDatum() != null) {
									String erdat2 = new StringBuffer(source.getDatum()).insert(4, "-").insert(7, "-").toString();
									Date date = DateUtil.parse(erdat2);
									source.setDatum1(date);
								}
								
								String crtdatum = source.getCrt_datum();
								String crttime = source.getCrt_time(); 
								if ("00000000".equals(crtdatum)) {
									source.setCrt_datum1(null);
								} else {
									Date date = DateUtil.parse(crtdatum+crttime, "yyyyMMddHHmmss");
									source.setCrt_datum1(date);
								}
								
								String chadatum = source.getCha_datum();
								String chatime = source.getCha_time(); 
								if ("00000000".equals(chadatum)) {
									source.setCha_datum1(null);
								} else {
									Date date = DateUtil.parse(chadatum+chatime, "yyyyMMddHHmmss");
									source.setCha_datum1(date);
								}
								gpMapper.updateZsd06(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Zsd06:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectZsd06Check --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Zsd06:rowNum", getErrorInfoFromException(e));
		}
	}
	
	
	public void selectVbepCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Vbep:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Vbep:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Vbep:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectVbepMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Vbep:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Vbep:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectVbepCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Vbep build = Vbep.builder().rowNum(rowNum).build();
			List<Vbep> list = gpMapper.selectVbepCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectVbepCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			list.forEach(target -> { // 遍历要检查的数据
				Vbep source = sapMapper.selectVbepById(target); // 根据主键查询源库中的数据
				String operator = "none";
				if (source == null) { // 如果源库中没有数据
					gpMapper.deleteVbep(target); // 删除数仓中的数据
					operator = "delete";
				} else { // 源库中有数据
					String shash = SecureUtil.md5(JSONUtil.toJsonStr(source)); // 源库中数据的hash结果
					String thash = target.getHashResult(); // 数仓中数据的hash结果
					if (!shash.equals(thash)) { // 如果hash结果不一致
						source.setHashResult(shash);
						// ===============================
						if (source.getEdatu() != null) {
							String erdat2 = new StringBuffer(source.getEdatu()).insert(4, "-").insert(7, "-").toString();
							Date date = DateUtil.parse(erdat2);
							source.setEdatu1(date);
						}
						// ===============================
						while (true) {
							try {
								gpMapper.updateVbep(source); // 更新数据到数仓中
								break;
							} catch (RuntimeException e) {
								log.error(e.getMessage());ThreadUtil.safeSleep(500);
							}
						}
						ThreadUtil.safeSleep(500);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Vbep:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectVbepCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Vbep:rowNum", getErrorInfoFromException(e));
		}
	}
	
	public void selectLikpCheck() {
		try {
			ValueOperations<String, String> opsForValue = redis1Template.opsForValue();
			opsForValue.setIfAbsent("huazheng:check:Likp:rowNum", "0");
			String rowNum = opsForValue.get("huazheng:check:Likp:rowNum");
			// 一次性任务的终止位
			if (redis1Template.hasKey("huazheng:check:Likp:stopNum") == false) {
				// 查询最大计数器
				String maxRowNum = gpMapper.selectLikpMaxRowNum().toString();
				opsForValue.setIfAbsent("huazheng:check:Likp:stopNum", maxRowNum);
			}
			Long stopNum = Long.parseLong(opsForValue.get("huazheng:check:Likp:stopNum"));
			if (stopNum < Long.parseLong(rowNum)) {
				JobKey jobKey = JobKey.jobKey("selectLikpCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			Likp build = Likp.builder().rowNum(rowNum).build();
			List<Likp> list = gpMapper.selectLikpCheck(build); // 从数仓中查询一组数据
			if (list.size() == 0) {
				JobKey jobKey = JobKey.jobKey("selectLikpCheck_once", "DEFAULT"); // 删除任务
				quartzScheduler.deleteJob(jobKey);
				return;
			}
			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);
						// ===============================
						String wadat_ist = source.getWadat_ist();
						String lfuhr = source.getLfuhr();
						if ("00000000".equals(wadat_ist)) {
							source.setWadat_ist2lfuhr(null);
						} else {
							Date date = DateUtil.parse(wadat_ist + lfuhr, "yyyyMMddHHmmss");
							source.setWadat_ist2lfuhr(date);
						}
						source.setErdat1(SomeUtils.caDate(source.getErdat())); // 日期00000000格式转换,已处理异常
						source.setWadat_ist1(SomeUtils.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);
					}
				}
				redis1Template.opsForValue().set("huazheng:check:Likp:rowNum", target.getRowNum());
				if (!operator.equals("none")) {
					log.info(String.format("selectLikpCheck --> rowNum:%s, operator:%s", target.getRowNum(), operator));
				}
			});
		} catch (Exception e) {
			redis1Template.opsForValue().set("huazheng:checkError:Likp:rowNum", getErrorInfoFromException(e));
		}
	}
	
}
