1、com.huazheng.project.greenplum.service.impl.JobServiceImpl.selectSysSAPreturnNoNew()
2、sapNo需要补0
<select id="selectSysSAPreturnNoNew" parameterType="SysSAPreturnNo" resultType="SysSAPreturnNo">
select top 20 a.* from (
	select id as rowids,
		id,processName,shiLiH,sapNo,chuangJianSJ
	from Sys_SAPreturnNo
) a where a.rowids &gt; #{rowids}
</select>

select * from SysSAPreturnNo where sapno = '10059162';
select * from SysSAPreturnNo where sapno = '0010059162';

com.huazheng.project.greenplum.service.impl.CheckUpdateServiceImpl.selectVbapCheckUpdate()
SalesContractProcess salesContractProcess = gpMapper.selectVbapAdv4SalesContractProcess(source); // vbap-SysSAPreturnNo-SalesContractProcess
if (salesContractProcess != null) {
	salesContractProcess.setVbap(source);
	gpMapper.updateVbapAdv4SalesContractProcess(salesContractProcess); // vbap-SysSAPreturnNo-SalesContractProcess
}

gpMapper.selectVbapAdv4SalesContractProcess(source)
select b.* from SysSAPreturnNo a
left join SalesContractProcess b on a.processName = b.SYSPROCESSNAME and a.shiLiH = SYSINCIDENT
where b.id is not null and a.sapno = #{vbeln}
limit 1
#{vbeln}这个参数是vbap的vbeln，是有前面两个0的

select * from SysSAPreturnNo where sapno = '0010059162';

select a.sapno,b.* from SysSAPreturnNo a
left join SalesContractProcess b on a.processName = b.SYSPROCESSNAME and a.shiLiH = SYSINCIDENT
where b.id is not null and a.sapno = '10059162'
limit 1

select a.sapno,b.* from SysSAPreturnNo a
left join SalesContractProcess b on a.processName = b.SYSPROCESSNAME and a.shiLiH = SYSINCIDENT
where b.id is not null and a.sapno = '0010059162'
limit 1
-----------------------


处理方案
1、sapNo需要补0
HzcrmMapper_mssql2.xml
selectSysSAPreturnNoNew 拉数据用的com.huazheng.project.greenplum.service.impl.JobServiceImpl.selectSysSAPreturnNoNew()
selectSysSAPreturnNoById 删除时候 com.huazheng.project.greenplum.service.impl.CheckDeleteServiceImpl.selectSysSAPreturnNoCheckByDelete()
cascadeSysSAPreturnNoByVbap 和vbap级联更新的时候com.huazheng.project.greenplum.service.impl.CheckUpdateServiceImpl.selectVbapCheckUpdate()
('00'+sapNo) as sapNo

2、数仓SysSAPreturnNo表里面的sapNo字段的现有的数据补0
--update SysSAPreturnNo set sapno = '00'||sapno where "length"(sapno) = 8;

3、调试vbap的更新，代码块
调整vbap的update计数器 
set huazheng:checkUpdate:Vbap:rowids 0
update vbap set hashresult = null;

com.huazheng.project.greenplum.service.impl.CheckUpdateServiceImpl.selectVbapCheckUpdate()
SalesContractProcess salesContractProcess = gpMapper.selectVbapAdv4SalesContractProcess(source); // vbap-SysSAPreturnNo-SalesContractProcess
if (salesContractProcess != null) {
	salesContractProcess.setVbap(source);
	gpMapper.updateVbapAdv4SalesContractProcess(salesContractProcess); // vbap-SysSAPreturnNo-SalesContractProcess
}

select b.* from SysSAPreturnNo a
left join SalesContractProcess b on a.processName = b.SYSPROCESSNAME and a.shiLiH = SYSINCIDENT
where b.id is not null and a.sapno = #{vbeln}这个是vbap的vbeln是带0的
limit 1

就会进入updateVbapAdv4SalesContractProcess
update VbapAdv set
	scp_id = #{id}, scp_xiaoShouDDBH = #{xiaoShouDDBH}, scp_xuFangGSID = #{xuFangGSID}, 
	scp_xuFangGS = #{xuFangGS}, scp_gongFangGSt = #{gongFangGSt}, scp_xiaoShouBMt = #{xiaoShouBMt}, 
	scp_shouHuoGSID = #{shouHuoGSID}, scp_shouHuoGS = #{shouHuoGS}, scp_fuKuanTJt = #{fuKuanTJt}, 
	scp_caiGouDDBH = #{caiGouDDBH}, scp_dangQianXYED = #{dangQianXYED}, scp_yvQiK = #{yvQiK}, 
	scp_dengJi = #{dengJi}, scp_biZhongt = #{biZhongt}, scp_yongJin = #{yongJin}, 
	scp_zongHeMLL = #{zongHeMLL}, scp_sysProcessname = #{sysProcessname}, scp_sysIncident = #{sysIncident},
	scp_ziShiYBv = #{ziShiYBv}
where vbeln = #{vbap.vbeln} and posnr = #{vbap.posnr} and mandt = #{vbap.mandt} and erdat1 = #{vbap.erdat1}



问题的解释
1、宽表在更新字段时候，比如更新宽表中SysSAPreturnNo表的字段，首先表关联逻辑没有问题
2、造成宽表字段没有更新到值是因为源库中SysSAPreturnNo.sapno存储的时候缺少00，vbap的vbel是10位的是有前置00的
3、在更新vbap宽表的时候需要根据关联条件vbap.vbeln=SysSAPreturnNo.sapno去查询数据
4、但是由于vbap.vbeln、SysSAPreturnNo.sapno两个字段的值的位数同步，导致查不到数据，所以没有更新到宽表中SysSAPreturnNo表的字段

我们现在的处理手段
1、在查询源库SysSAPreturnNo表的时候进行补0，然后再写到数仓中的SysSAPreturnNo表中
2、写好之后调试vbap的更新流程，发现vbap.vbeln=SysSAPreturnNo.sapno关联的时候已经没有问题了，可以查到数据了，从而宽表的SysSAPreturnNo表的字段就被更新上了



vbap更新流程
1、先从源库中取20个数据（计数器）
2、对比数仓的数据，计算源库数据的hash值，对比数仓中的数据的hash值
3、如果一致，就不用更新了
4、不一致，开始更新
4.1、更新vbap表
4.2、更新vbap宽表
4.3、级联更新（数据同步类型.xlsx）更新的是被vbap级联到的表
4.4、更新计算字段
4.5、更新宽表中的附属表字段
4.6、结束








