| package com.fzzy.async.fzzy61.impl; | 
|   | 
| import com.alibaba.fastjson.JSON; | 
| import com.fzzy.api.Constant; | 
| import com.fzzy.api.entity.Api1102; | 
| import com.fzzy.api.entity.Api1105; | 
| import com.fzzy.api.entity.ApiInfoData; | 
| import com.fzzy.api.entity.ApiLog; | 
| import com.fzzy.api.service.ApiCommonService; | 
| import com.fzzy.api.utils.ContextUtil; | 
| import com.fzzy.api.view.repository.Api1102Rep; | 
| import com.fzzy.api.view.repository.ApiInfoDataRep; | 
| import com.fzzy.api.view.repository.ApiLogRep; | 
| import com.fzzy.async.fzzy61.entity.Fz61InoutStockChange; | 
| import com.fzzy.async.fzzy61.repository.Fzzy61Sync1207Rep; | 
| import com.fzzy.push.sh2023.SH2023Constant; | 
| import com.fzzy.push.sh2023.dto.SH2023Api2102; | 
| import com.fzzy.push.sh2023.dto.ShAreaBjw; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import java.util.Date; | 
| import java.util.List; | 
|   | 
| /** | 
|  * 倒仓倒入 | 
|  * | 
|  * @author czt | 
|  */ | 
| @Slf4j | 
| @Component | 
| public class Fzzy61Sync2102 { | 
|   | 
|     @Autowired | 
|     private Fzzy61Sync1207Rep fzzySync1207Rep; | 
|     @Autowired | 
|     private ApiCommonService commonService; | 
|     @Autowired | 
|     private Api1102Rep api1102Rep; | 
|     @Autowired | 
|     private ApiInfoDataRep apiInfoDataRep; | 
|     @Autowired | 
|     private ApiLogRep apiLogRep; | 
|   | 
|     /** | 
|      * 倒仓倒入信息同步 | 
|      * | 
|      * @param kqdm | 
|      * @param deptId | 
|      * @param start | 
|      * @param end | 
|      */ | 
|     public void syncData(String kqdm, String deptId, Date start, Date end) { | 
|         log.info("-------------2101接口数据开始同步------------------"); | 
|   | 
|         //同步数据,只记录失败的信息 | 
|         ApiLog apiLog = new ApiLog(); | 
|         apiLog.setType(ApiLog.TYPE_SYNC); | 
|         apiLog.setKqdm(deptId); | 
|         apiLog.setUploadTime(new Date()); | 
|         apiLog.setInteId(SH2023Constant.SH_2023_API_CODE_2101); | 
|         apiLog.setStatus(99); | 
|         apiLog.setId(ContextUtil.getUUID()); | 
|         try { | 
|             List<Fz61InoutStockChange> list = fzzySync1207Rep.listStockChange(deptId, start, end); | 
|             if (null == list || list.isEmpty()) { | 
|                 log.info("-------------没有获取到倒仓倒入信息------------------"); | 
|                 return; | 
|             } | 
|   | 
|             SH2023Api2102 apiData; | 
|             Api1105 api1105; | 
|             List<ApiInfoData> apiInfoDataList; | 
|             List<Api1102> api1102List = api1102Rep.findPushData(kqdm); | 
|             String bjw = ""; | 
|             if (null != api1102List && api1102List.size() > 0) { | 
|                 bjw = ShAreaBjw.getBjw(api1102List.get(0).getXzqhdm()); | 
|             } | 
|             Api1105 api1105In; | 
|             Api1105 api1105Out; | 
|             for (Fz61InoutStockChange sysData : list) { | 
|                 //获取货位信息 | 
|                 api1105Out = commonService.getApi1105Cache(sysData.getDepotIdOut()); | 
|                 if (null == api1105Out) { | 
|                     continue; | 
|                 } | 
|                 //获取货位信息 | 
|                 api1105In = commonService.getApi1105Cache(sysData.getDepotIdIn()); | 
|                 if (null == api1105In) { | 
|                     continue; | 
|                 } | 
|                 apiData = new SH2023Api2102(); | 
|                 apiData.setDrdh(kqdm + sysData.getId()); | 
|                 apiData.setDrdw(kqdm); | 
|                 apiData.setDrhwdm(api1105In.getHwdm()); | 
|                 apiData.setDrhwsl(sysData.getNumber()); | 
|                 apiData.setDcrq(sysData.getChangeDate()); | 
|                 apiData.setZhgxsj(sysData.getUpdateTime()); | 
|                 apiData.setBjw(bjw); | 
|   | 
|   | 
|                 //持久化保存,单独存入非国标接口表 | 
|                 ApiInfoData infoData = new ApiInfoData(); | 
|                 infoData.setId(ContextUtil.getUUID()); | 
|                 infoData.setKqdm(kqdm); | 
|                 infoData.setInteType(Constant.API_CATEGORY_12); | 
|                 infoData.setInteId(SH2023Constant.SH_2023_API_CODE_2102); | 
|                 infoData.setUpdateTime(new Date()); | 
|                 infoData.setDataId(apiData.getDrdh()); | 
|                 infoData.setRemarks("倒仓倒入"); | 
|   | 
|                 //设置操作标志 | 
|                 apiInfoDataList = apiInfoDataRep.getDataByInteAndData(SH2023Constant.SH_2023_API_CODE_2101, infoData.getDataId(), kqdm); | 
|                 if (null == apiInfoDataList || apiInfoDataList.isEmpty()) { | 
|                     infoData.setCzbz(Constant.CZBZ_I); | 
|                     apiData.setCzbz(Constant.CZBZ_I); | 
|                 } else { | 
|                     infoData.setCzbz(apiInfoDataList.get(0).getCzbz()); | 
|                     apiData.setCzbz(apiInfoDataList.get(0).getCzbz()); | 
|                 } | 
|   | 
|                 infoData.setData(JSON.toJSONString(apiData)); | 
|                 apiInfoDataRep.save(infoData); | 
|   | 
|                 log.info("2102---倒仓倒入-同步数据:{}", apiData); | 
|   | 
|             } | 
|   | 
|         } catch (Exception e) { | 
|             log.error("---倒仓倒入同步执行失败----{}", e.toString()); | 
|             apiLog.setResult("倒仓倒入失败:" + e.getMessage()); | 
|             apiLogRep.save(apiLog); | 
|         } | 
|     } | 
| } |