From 029de836702607a95ccb0a69a74efcea52ddc451 Mon Sep 17 00:00:00 2001 From: czt <czt18638530771@163.com> Date: 星期四, 25 九月 2025 19:35:38 +0800 Subject: [PATCH] 上海对农数据接口调整2 --- src/main/java/com/fzzy/async/fzzy61/impl/Fzzy61Sync1304.java | 141 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 141 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/fzzy/async/fzzy61/impl/Fzzy61Sync1304.java b/src/main/java/com/fzzy/async/fzzy61/impl/Fzzy61Sync1304.java new file mode 100644 index 0000000..00867ae --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy61/impl/Fzzy61Sync1304.java @@ -0,0 +1,141 @@ +package com.fzzy.async.fzzy61.impl; + +import com.fzzy.api.Constant; +import com.fzzy.api.entity.Api1105; +import com.fzzy.api.entity.Api1304; +import com.fzzy.api.entity.ApiLog; +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.ApiLogRep; +import com.fzzy.async.fzzy61.entity.Fz61Gas; +import com.fzzy.async.fzzy61.repository.Fzzy61Sync1304Rep; +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 chen + * @date 2022-09-08 09:51 + */ +@Slf4j +@Component +public class Fzzy61Sync1304 { + + @Autowired + private Fzzy61Sync1304Rep fzzySync1304Rep; + @Autowired + private ApiCommonService commonService; + @Autowired + private Api1304Rep api1304Rep; + + @Autowired + private ApiLogRep apiLogRep; + + /** + * 鍚屾骞跺皝瑁呬繚瀛樻皵浣撴娴嬫暟鎹� + * + * @param deptId 绯荤粺瀵瑰簲搴撳尯缂栫爜 + * @param start 璧峰鏃堕棿 + * @param end 鎴鏃堕棿 + */ + public void syncData(String kqdm, String deptId, Date start, Date end) { + log.info("-------------1304姘斾綋妫�娴嬫暟鎹帴鍙f暟鎹紑濮嬪悓姝�------------------"); + //鍚屾鏁版嵁锛屽彧璁板綍澶辫触鐨勪俊鎭� + ApiLog apiLog = new ApiLog(); + apiLog.setType(ApiLog.TYPE_SYNC); + apiLog.setKqdm(deptId); + apiLog.setUploadTime(new Date()); + apiLog.setInteId(Constant.API_CODE_1304); + apiLog.setStatus(99); + apiLog.setId(ContextUtil.getUUID()); + try { + List<Fz61Gas> list = fzzySync1304Rep.findByReceiveDate(start, end); + if (null == list || list.isEmpty()) { + return; + } + + Api1304 api1304; + Api1105 api1105; + List<Api1304> api1304List; + for (Fz61Gas fz61Gas : list) { + //鑾峰彇璐т綅淇℃伅 + api1105 = commonService.getApi1105Cache(fz61Gas.getDepotId()); + if (null == api1105) { + continue; + } + + api1304 = new Api1304(); + api1304.setQtndjcdh(api1105.getHwdm() + fz61Gas.getBatchId()); + api1304.setJcsj(fz61Gas.getReceiveDate()); + api1304.setHwdm(api1105.getHwdm()); + api1304.setZylx("5"); + + api1304 = updateGasInfo(api1304, fz61Gas.getPoints()); + + api1304.setZhgxsj(new Date()); + + api1304.setBizId(fz61Gas.getBatchId()); + api1304.setKqdm(api1105.getKqdm()); + api1304.setSyncTime(new Date()); + api1304List = api1304Rep.getDataByQtndjcdh(api1304.getQtndjcdh()); + if (null == api1304List || api1304List.isEmpty()) { + api1304.setCzbz(Constant.CZBZ_I); + } else { + api1304.setCzbz(api1304List.get(0).getCzbz()); + } + api1304Rep.save(api1304); + } + } catch (Exception e) { + log.error("---1304姘斾綋妫�娴嬫暟鎹悓姝ュけ璐�----{}", e.toString()); + apiLog.setResult("鍚屾澶辫触锛�" + e.getMessage()); + apiLogRep.save(apiLog); + } + } + + /** + * 鑾峰彇瀵瑰簲姘斾綋娴撳害闆嗗悎锛歱assCode,co2,o2,ph3,n2;passCode,co2,o2,ph3,n2; + * + * @param points + * @return + */ + private Api1304 updateGasInfo(Api1304 api1304, String points) { + String[] attr = points.split(";"); + + String[] arrt2; + String o2 = "", co2 = "", ph3 = "", n2 = ""; + for (String temp : attr) { + arrt2 = temp.split(","); + o2 += "," + arrt2[2]; + co2 += "," + arrt2[1]; + ph3 += "," + arrt2[3]; + n2 += "," + arrt2[4]; + } + + if(o2.length() > 0){ + o2 = o2.substring(1); + } + if(co2.length() > 0){ + co2 = co2.substring(1); + } + if(ph3.length() > 0){ + ph3 = ph3.substring(1); + } + if(n2.length() > 0){ + n2 = n2.substring(1); + } + co2 += "|ppm"; + ph3 += "|ppm"; + api1304.setYqhlzjh(o2); + api1304.setEyhthlzjh(co2); + api1304.setLhqndzjh(ph3); + api1304.setDqndzjh(n2); + return api1304; + } + +} -- Gitblit v1.9.3