| package com.fzzy.async.fzzy40.impl; | 
|   | 
| import com.fzzy.api.Constant; | 
| import com.fzzy.api.entity.*; | 
| import com.fzzy.api.service.ApiCommonService; | 
| import com.fzzy.api.utils.ContextUtil; | 
| import com.fzzy.api.view.repository.Api1304Rep; | 
| import com.fzzy.api.view.repository.Api1305Rep; | 
| import com.fzzy.api.view.repository.ApiLogRep; | 
| import com.fzzy.async.fzzy40.entity.Fz40AreationData; | 
| import com.fzzy.async.fzzy40.entity.Fz40Gas; | 
| import com.fzzy.async.fzzy40.repository.Fzzy40Sync1304Rep; | 
| import com.fzzy.async.fzzy40.repository.Fzzy40Sync1305Rep; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.BeanUtils; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import java.util.Date; | 
| import java.util.List; | 
|   | 
| /** | 
|  * 通风数据同步 | 
|  * | 
|  * @author chen | 
|  * @date 2022-09-08 09:51 | 
|  */ | 
| @Slf4j | 
| @Component | 
| public class Fzzy40Sync1305 { | 
|   | 
|     @Autowired | 
|     private Fzzy40Sync1305Rep fzzySync1305Rep; | 
|     @Autowired | 
|     private ApiCommonService commonService; | 
|     @Autowired | 
|     private Api1305Rep api1305Rep; | 
|   | 
|     @Autowired | 
|     private ApiLogRep apiLogRep; | 
|   | 
|     /** | 
|      * 同步并封装保存气通风数据 | 
|      * | 
|      * @param deptId 系统对应库区编码 | 
|      * @param start  起始时间 | 
|      * @param end    截止时间 | 
|      */ | 
|     public void syncData(String kqdm, String deptId, Date start, Date end) { | 
|         log.info("-------------1305接口数据开始同步------------------"); | 
|         //同步数据,只记录失败的信息 | 
|         ApiLog apiLog = new ApiLog(); | 
|         apiLog.setType(ApiLog.TYPE_SYNC); | 
|         apiLog.setKqdm(deptId); | 
|         apiLog.setUploadTime(new Date()); | 
|         apiLog.setInteId(Constant.API_CODE_1305); | 
|         apiLog.setStatus(99); | 
|         apiLog.setId(ContextUtil.getUUID()); | 
|         try { | 
|             List<Fz40AreationData> list = fzzySync1305Rep.findByReceiveDate(start, end); | 
|             if (null == list || list.isEmpty()) { | 
|                 return; | 
|             } | 
|   | 
|             Api1305 api1305; | 
|             Api1105 api1105; | 
|             List<Api1305> api1305List; | 
|             for (Fz40AreationData fzAreationData : list) { | 
|                 //获取货位信息 | 
|                 api1105 = commonService.getApi1105Cache(fzAreationData.getDepotId()); | 
|                 if (null == api1105) { | 
|                     continue; | 
|                 } | 
|   | 
|                 api1305 = new Api1305(); | 
|   | 
|                 BeanUtils.copyProperties(fzAreationData, api1305); | 
|   | 
|                 api1305.setTfzydh(api1105.getHwdm() + fzAreationData.getId()); | 
|                 api1305.setTfrq(fzAreationData.getStartTime()); | 
|                 api1305.setCfdm(api1105.getHwdm().substring(0,25)); | 
|                 api1305.setTfmd(fzAreationData.getObjective()); | 
|                 api1305.setTflx(fzAreationData.getType()); | 
|                 api1305.setFdxs(fzAreationData.getWindNetType()); | 
|                 api1305.setFdxs(fzAreationData.getWindNetType()); | 
|                 api1305.setSffs(fzAreationData.getAirSupplyMode()); | 
|                 api1305.setZhdl(fzAreationData.getTotalEs()); | 
|                 api1305.setZyqpjlw(fzAreationData.getBeforeTempAvg()); | 
|                 api1305.setJshpjlw(fzAreationData.getAfterTempAvg()); | 
|                 api1305.setZyhpjsf(fzAreationData.getBeforPerWetAvg()); | 
|                 api1305.setZyhpjsf(fzAreationData.getAfterPerWetAvg()); | 
|                 api1305.setTfzyfzr(fzAreationData.getChargeUser()); | 
|                 api1305.setTfzyry(fzAreationData.getOperators()); | 
|                 api1305.setTfsc(fzAreationData.getLongTime()); | 
|                 api1305.setZhgxsj(new Date()); | 
|   | 
|                 api1305.setKqdm(kqdm); | 
|                 api1305.setHwdm(api1105.getHwdm()); | 
|                 api1305.setBizId(fzAreationData.getId()); | 
|                 api1305List = api1305Rep.getDataById(api1305.getTfzydh()); | 
|                 if (null == api1305List || api1305List.isEmpty()) { | 
|                     api1305.setCzbz(Constant.CZBZ_I); | 
|                 } else { | 
|                     api1305.setCzbz(api1305List.get(0).getCzbz()); | 
|                 } | 
|                 api1305Rep.save(api1305); | 
|             } | 
|         } catch (Exception e) { | 
|             log.error("---同步失败----{}", e); | 
|             apiLog.setResult("同步失败:" + e.getMessage()); | 
|             apiLogRep.save(apiLog); | 
|         } | 
|     } | 
|   | 
|   | 
| } |