|  |  |  | 
|---|
|  |  |  | package com.fzzy.async.fzzy40.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.fzzy.api.Constant; | 
|---|
|  |  |  | import com.fzzy.api.entity.Api1102; | 
|---|
|  |  |  | import com.fzzy.api.entity.Api1105; | 
|---|
|  |  |  | import com.fzzy.api.entity.Api1204; | 
|---|
|  |  |  | import com.fzzy.api.entity.ApiLog; | 
|---|
|  |  |  | import com.fzzy.api.service.ApiCommonService; | 
|---|
|  |  |  | import com.fzzy.api.utils.ContextUtil; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.*; | 
|---|
|  |  |  | import com.fzzy.async.fzzy30.repository.FzzySync1202Rep; | 
|---|
|  |  |  | import com.fzzy.async.fzzy35.repository.Fzzy35Sync1202Rep; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.entity.Fz40InoutRecord; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.entity.Fz40InoutSettle; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.entity.Fz40InoutNoticeIn; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.entity.Fz40InoutRecord; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.entity.Fz40InoutSettle; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.repository.Fzzy40Sync1107Rep; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.repository.Fzzy40Sync1202Rep; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.repository.Fzzy40Sync1204Rep; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.repository.Fzzy40SyncNoticeInRep; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private final static String INOUT_TYPE_IN = "IN"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Fzzy40Sync1202Rep fzzy40Sync1202Rep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Fzzy40Sync1204Rep fzzy40Sync1204Rep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Fzzy40SyncNoticeInRep fzzySyncNoticeInRep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiLogRep apiLogRep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Api1102Rep api1102Rep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Api1204Rep api1204Rep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | apiLog.setId(ContextUtil.getUUID()); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //获取粮食入库结算信息 | 
|---|
|  |  |  | List<Fz40InoutSettle> list = fzzy40Sync1204Rep.listInoutSettle(INOUT_TYPE_IN, start, end); | 
|---|
|  |  |  | List<Fz40InoutSettle> list = fzzy40Sync1204Rep.listInoutSettle(deptId, INOUT_TYPE_IN, start, end); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == list || list.isEmpty()) { | 
|---|
|  |  |  | log.info("-------------没有获取到粮食入库结算信息------------------"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //根据库区代码获取库区信息 | 
|---|
|  |  |  | Api1102 api1102 = api1102Rep.findById(kqdm).get(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Api1204 apiData; | 
|---|
|  |  |  | Api1105 api1105; | 
|---|
|  |  |  | List<Fz40InoutRecord> fz40InoutRecords; | 
|---|
|  |  |  | Fz40InoutRecord fz40InoutRecord; | 
|---|
|  |  |  | List<Api1204> api1204List; | 
|---|
|  |  |  | for (Fz40InoutSettle sysData : list) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取粮食入库信息 | 
|---|
|  |  |  | fz40InoutRecords = fzzy40Sync1202Rep.listInoutRecordById(sysData.getId()); | 
|---|
|  |  |  | if (null == fz40InoutRecords || fz40InoutRecords.isEmpty()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | fz40InoutRecord = fz40InoutRecords.get(0); | 
|---|
|  |  |  | if (!deptId.equals(fz40InoutRecord.getDeptId())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取货位信息 | 
|---|
|  |  |  | api1105 = commonService.getApi1105Cache(fz40InoutRecord.getDepotId()); | 
|---|
|  |  |  | if (null == api1105) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | apiData = new Api1204(); | 
|---|
|  |  |  | //入库结算单号:库区代码 + yyMMdd + 4为顺序号 | 
|---|
|  |  |  | apiData.setRkjsdh(kqdm + sysData.getId().substring(2)); | 
|---|
|  |  |  | //入库结算单号:库区代码 + yyyyMMdd + 4为顺序号 | 
|---|
|  |  |  | apiData.setRkjsdh(kqdm + sysData.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //货位代码 | 
|---|
|  |  |  | apiData.setHwdm(api1105.getHwdm()); | 
|---|
|  |  |  | //合同号 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(sysData.getContractId())){ | 
|---|
|  |  |  | apiData.setHth(api1102.getDwdm() + sysData.getContractId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(sysData.getDepotId())){ | 
|---|
|  |  |  | api1105 = commonService.getApi1105Cache(sysData.getDepotId()); | 
|---|
|  |  |  | //货位代码 | 
|---|
|  |  |  | apiData.setHwdm(api1105.getHwdm()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //结算重量、结算单价、结算金额、结算时间 | 
|---|
|  |  |  | apiData.setJssl(sysData.getSettleWeight()); | 
|---|
|  |  |  | 
|---|
|  |  |  | apiData.setFkdw(sysData.getPayUnit()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //操作标志及最后更新时间 | 
|---|
|  |  |  | apiData.setCzbz(Constant.CZBZ_I); | 
|---|
|  |  |  | apiData.setZhgxsj(sysData.getUpdateTime()); | 
|---|
|  |  |  | apiData.setZhgxsj(new Date()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //业务id、库区编码、同步时间 | 
|---|
|  |  |  | apiData.setBizId(sysData.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | apiData.setSyncTime(new Date()); | 
|---|
|  |  |  | log.info("1204---同步数据:{}", apiData.toString()); | 
|---|
|  |  |  | //保存数据 | 
|---|
|  |  |  | api1204List = api1204Rep.getDataById(apiData.getRkjsdh()); | 
|---|
|  |  |  | if (null == api1204List || api1204List.isEmpty()) { | 
|---|
|  |  |  | apiData.setCzbz(Constant.CZBZ_I); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | apiData.setCzbz(api1204List.get(0).getCzbz()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | api1204Rep.save(apiData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|