From 8bb6004ed19b69fff5b0ca70303c616bc71546e6 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期一, 13 十月 2025 15:46:45 +0800
Subject: [PATCH] 武汉黄陂军粮-质检报告共享接口同步及推送2
---
src/main/java/com/fzzy/otherview/whhpjl/WhjlShareApi20132.view.xml | 126 ++++++++++++++-
src/main/java/com/fzzy/push/whhpjl/WhjlApiRemoteService.java | 8 +
src/main/java/com/fzzy/api/view/repository/ApiInfoDataRep.java | 10 +
src/main/java/com/fzzy/push/whhpjl/dto/WhjlPullReqDto.java | 10 +
src/main/java/com/fzzy/otherview/whhpjl/dto/WhjlShareApi2013.java | 2
src/main/java/com/fzzy/api/timer/ApiWhjlScheduled.java | 14 +
src/main/java/com/fzzy/otherview/whhpjl/pr/WhjlShareApi2013PR2.java | 163 ++++++++++++-------
src/main/java/com/fzzy/push/whhpjl/Whjl2023HttpClientUtil.java | 144 ++++++++++++++---
src/main/java/com/fzzy/async/whhpjl/impl/Fz40ToWhjlSync1212.java | 3
9 files changed, 375 insertions(+), 105 deletions(-)
diff --git a/src/main/java/com/fzzy/api/timer/ApiWhjlScheduled.java b/src/main/java/com/fzzy/api/timer/ApiWhjlScheduled.java
index d79a5b7..64b1d7f 100644
--- a/src/main/java/com/fzzy/api/timer/ApiWhjlScheduled.java
+++ b/src/main/java/com/fzzy/api/timer/ApiWhjlScheduled.java
@@ -1,10 +1,14 @@
package com.fzzy.api.timer;
+import com.fzzy.api.data.ApiParam;
import com.fzzy.otherview.whhpjl.pr.WhjlShareApi2013PR2;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+
+import java.util.Date;
/**
* @Description 姝︽眽鍐涚伯鐪佸钩鍙�
@@ -26,10 +30,16 @@
log.info("------->>>>>>>>>>姝︽眽榛勯檪鍐涚伯锛岀郴缁熷畾鏃剁粺璁″叡浜帴鍙g渷璐ㄦ鎶ュ憡");
+ Date endTime = new Date();
+ Date startTime = DateUtils.addDays(endTime, -1);
+ ApiParam param1 = new ApiParam();
+ param1.setStart(startTime);
+ param1.setEnd(endTime);
//鑾峰彇鍏变韩鏁版嵁
- whjlShareApi2013PR2.pullData(null);
+ whjlShareApi2013PR2.pullData(param1);
+
//鍚屾鑷冲簱鍖烘暟鎹簱
- whjlShareApi2013PR2.sysDataToDept();
+ whjlShareApi2013PR2.sysDataToDept(param1);
}
}
diff --git a/src/main/java/com/fzzy/api/view/repository/ApiInfoDataRep.java b/src/main/java/com/fzzy/api/view/repository/ApiInfoDataRep.java
index 448b740..de37f4c 100644
--- a/src/main/java/com/fzzy/api/view/repository/ApiInfoDataRep.java
+++ b/src/main/java/com/fzzy/api/view/repository/ApiInfoDataRep.java
@@ -8,6 +8,7 @@
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
+import java.util.Date;
import java.util.List;
public interface ApiInfoDataRep extends JpaRepository<ApiInfoData, String>, JpaSpecificationExecutor<ApiInfoData> {
@@ -32,6 +33,15 @@
List<ApiInfoData> getDataByInteId(@Param("inteId") String inteId);
/**
+ * 鏍规嵁鎺ュ彛缂栫爜鏌ヨ鏁版嵁
+ *
+ * @param inteId
+ * @return
+ */
+ @Query("from ApiInfoData where inteId=:inteId and updateTime >=:start and updateTime <:end order by updateTime")
+ List<ApiInfoData> getDataByInteId(@Param("inteId") String inteId, @Param("start") Date start, @Param("end") Date end);
+
+ /**
* 鏍规嵁琛ㄥ崟涓婚敭鏇存柊鎿嶄綔鏍囧織鐘舵��
*
* @param id 涓婚敭ID
diff --git a/src/main/java/com/fzzy/async/whhpjl/impl/Fz40ToWhjlSync1212.java b/src/main/java/com/fzzy/async/whhpjl/impl/Fz40ToWhjlSync1212.java
index 23355e5..a9f2e2b 100644
--- a/src/main/java/com/fzzy/async/whhpjl/impl/Fz40ToWhjlSync1212.java
+++ b/src/main/java/com/fzzy/async/whhpjl/impl/Fz40ToWhjlSync1212.java
@@ -137,6 +137,7 @@
apiData.setLspzmc(lspz.get(0).getName());//鍝佺鍚嶇О
}
if (sysData.getFoodVariety().startsWith("2")){
+ apiData.setLspzmc("闈㈢矇");//鍝佺鍚嶇О
apiData.setKctzbh("1234567891234567002");//搴撳瓨鍙拌处ID
apiData.setKctzcppcid("12312332132145002");//搴撳瓨鍙拌处鎵规ID
apiData.setJldwbm("12");//璁¢噺鍗曚綅缂栫爜
@@ -150,6 +151,7 @@
apiData.setCpmc("绮捐嚧灏忛害绮�");//浜у搧缂栧彿
}
if (sysData.getFoodVariety().startsWith("1")){
+ apiData.setLspzmc("澶х背");//鍝佺鍚嶇О
apiData.setKctzbh("1234567891234567001");//搴撳瓨鍙拌处ID
apiData.setKctzcppcid("12312332132145001");//搴撳瓨鍙拌处鎵规ID
apiData.setJldwbm("12");//璁¢噺鍗曚綅缂栫爜
@@ -163,6 +165,7 @@
}
if (sysData.getFoodVariety().startsWith("3")){
+ apiData.setLspzmc("椋熺敤娌�");//鍝佺鍚嶇О
apiData.setKctzbh("1234567891234567003");//搴撳瓨鍙拌处ID
apiData.setKctzcppcid("12312332132145003");//搴撳瓨鍙拌处鎵规ID
apiData.setJldwbm("13");//璁¢噺鍗曚綅缂栫爜
diff --git a/src/main/java/com/fzzy/otherview/whhpjl/WhjlShareApi20132.view.xml b/src/main/java/com/fzzy/otherview/whhpjl/WhjlShareApi20132.view.xml
index 3908cb3..0fda86e 100644
--- a/src/main/java/com/fzzy/otherview/whhpjl/WhjlShareApi20132.view.xml
+++ b/src/main/java/com/fzzy/otherview/whhpjl/WhjlShareApi20132.view.xml
@@ -526,12 +526,27 @@
<Property name="label">妫�楠岀粨璁�</Property>
</PropertyDef>
</DataType>
+ <DataType name="dtTest">
+ <Property name="creationType">com.fzzy.api.data.ApiParam</Property>
+ <PropertyDef name="start">
+ <Property name="dataType">DateTime</Property>
+ <Property name="label">寮�濮嬫椂闂�</Property>
+ </PropertyDef>
+ <PropertyDef name="end">
+ <Property name="dataType">DateTime</Property>
+ <Property name="label">鎴鏃堕棿</Property>
+ </PropertyDef>
+ </DataType>
</Model>
<View layout="regionPadding:10">
<Property name="packages">font-awesome,css-common</Property>
<DataSet id="dsMain">
<Property name="dataType">[dtMain]</Property>
<Property name="dataProvider">whjlShareApi2013PR2#listData</Property>
+ </DataSet>
+ <DataSet id="dsTest">
+ <ClientEvent name="onReady">self.insert({});</ClientEvent>
+ <Property name="dataType">dtTest</Property>
</DataSet>
<Container layout="regionPadding:10" layoutConstraint="top">
<Property name="exClassName">bg-color</Property>
@@ -582,13 +597,8 @@
<Property name="exClassName">btn-flush</Property>
</Button>
<Button layoutConstraint="left">
- <ClientEvent name="onClick">var select = view.get("#dgMain").get("selection");
- view.get("#ajaxPull").set("parameter",select).execute(function(result){
- view.get("#dsMain").flushAsync();
- $notify(result);
- });
- </ClientEvent>
- <Property name="caption">鎵嬪姩鏇存柊</Property>
+ <ClientEvent name="onClick">view.get("#testWarn").show()</ClientEvent>
+ <Property name="caption">鎵嬪姩鎷夊彇</Property>
<Property name="iconClass">fa fa-hand-o-up</Property>
<Property name="exClassName">btn-default</Property>
</Button>
@@ -601,12 +611,7 @@
<Property name="exClassName">btn-flush</Property>
</Button>
<Button layoutConstraint="left">
- <ClientEvent name="onClick">
-var select = view.get("#dgMain").get("selection");
- view.get("#ajaxsysDataToDept").execute(function(result){
- view.get("#dsMain").flushAsync();
- $notify(result);
- });</ClientEvent>
+ <ClientEvent name="onClick">view.get("#testWarn2").show()</ClientEvent>
<Property name="caption">鍚屾鑷冲簱鍖�</Property>
<Property name="iconClass">fa fa-hand-o-up</Property>
<Property name="exClassName">btn-default</Property>
@@ -1320,6 +1325,101 @@
</Children>
<Tools/>
</Dialog>
+ <Dialog id="testWarn" layout="padding:10;regionPadding:10">
+ <Property name="width">40%</Property>
+ <Property name="iconClass">fa fa-flag-o</Property>
+ <Property name="closeable">false</Property>
+ <Property name="caption">璧锋鏃堕棿</Property>
+ <Buttons>
+ <Button id="btnOk">
+ <ClientEvent name="onClick">
+ var data = view.get("#dsTest.data");
+ view.get("#ajaxPull").set("parameter",data).execute(function(result){
+ self.get("parent").hide();
+ view.get("#dsMain").flushAsync();
+ $notify(result);
+ });
</ClientEvent>
+ <Property name="caption">纭畾鎷夊彇</Property>
+ <Property name="iconClass">fa fa-check</Property>
+ </Button>
+ <Button>
+ <ClientEvent name="onClick">self.get("parent").hide();</ClientEvent>
+ <Property name="caption">鍙栨秷</Property>
+ <Property name="iconClass">fa fa-times-circle</Property>
+ <Property name="width">90</Property>
+ </Button>
+ </Buttons>
+ <Children>
+ <AutoForm>
+ <Property name="dataSet">dsTest</Property>
+ <Property name="cols">*</Property>
+ <Property name="labelWidth">110</Property>
+ <Property name="labelAlign">right</Property>
+ <Property name="labelSeparator">锛�</Property>
+ <AutoFormElement>
+ <Property name="name">start</Property>
+ <Property name="property">start</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">end</Property>
+ <Property name="property">end</Property>
+ <Editor/>
+ </AutoFormElement>
+ <Label layoutConstraint="colSpan:2">
+ <Property name="text">璇存槑锛氬繀椤诲~鍐欒捣姝㈡椂闂达紒</Property>
+ </Label>
+ </AutoForm>
+ </Children>
+ <Tools/>
+ </Dialog>
+ <Dialog id="testWarn2" layout="padding:10;regionPadding:10">
+ <Property name="width">40%</Property>
+ <Property name="iconClass">fa fa-flag-o</Property>
+ <Property name="closeable">false</Property>
+ <Property name="caption">璧锋鏃堕棿</Property>
+ <Buttons>
+ <Button id="btnOk2">
+ <ClientEvent name="onClick">
+ var data = view.get("#dsTest.data");
+ view.get("#ajaxsysDataToDept").set("parameter",data).execute(function(result){
+ self.get("parent").hide();
+ $notify(result);
+ });
</ClientEvent>
+ <Property name="caption">纭畾鎺ㄩ��</Property>
+ <Property name="iconClass">fa fa-check</Property>
+ </Button>
+ <Button>
+ <ClientEvent name="onClick">self.get("parent").hide();</ClientEvent>
+ <Property name="caption">鍙栨秷</Property>
+ <Property name="iconClass">fa fa-times-circle</Property>
+ <Property name="width">90</Property>
+ </Button>
+ </Buttons>
+ <Children>
+ <AutoForm>
+ <Property name="dataSet">dsTest</Property>
+ <Property name="cols">*</Property>
+ <Property name="labelWidth">110</Property>
+ <Property name="labelAlign">right</Property>
+ <Property name="labelSeparator">锛�</Property>
+ <AutoFormElement>
+ <Property name="name">start</Property>
+ <Property name="property">start</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">end</Property>
+ <Property name="property">end</Property>
+ <Editor/>
+ </AutoFormElement>
+ <Label layoutConstraint="colSpan:2">
+ <Property name="text">璇存槑锛氬繀椤诲~鍐欒捣姝㈡椂闂达紒</Property>
+ </Label>
+ </AutoForm>
+ </Children>
+ <Tools/>
+ </Dialog>
<ListDropDown id="listDropYN">
<Property name="items">鏄�,鍚�</Property>
</ListDropDown>
diff --git a/src/main/java/com/fzzy/otherview/whhpjl/dto/WhjlShareApi2013.java b/src/main/java/com/fzzy/otherview/whhpjl/dto/WhjlShareApi2013.java
index b2395a2..12267c9 100644
--- a/src/main/java/com/fzzy/otherview/whhpjl/dto/WhjlShareApi2013.java
+++ b/src/main/java/com/fzzy/otherview/whhpjl/dto/WhjlShareApi2013.java
@@ -18,6 +18,8 @@
public class WhjlShareApi2013 implements Serializable {
private static final long serialVersionUID = 1L;
+ public static String SORT_PROP = "qlyOrgReportId";
+
private String qlyOrgReportId; //璐ㄦ鎶ュ憡id
private String orderId; //璁㈠崟琛↖D
private String sampleId; //鏍峰搧琛↖D
diff --git a/src/main/java/com/fzzy/otherview/whhpjl/pr/WhjlShareApi2013PR2.java b/src/main/java/com/fzzy/otherview/whhpjl/pr/WhjlShareApi2013PR2.java
index ba380e3..b1da9f3 100644
--- a/src/main/java/com/fzzy/otherview/whhpjl/pr/WhjlShareApi2013PR2.java
+++ b/src/main/java/com/fzzy/otherview/whhpjl/pr/WhjlShareApi2013PR2.java
@@ -5,9 +5,11 @@
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
+import com.bstek.dorado.data.provider.Page;
import com.fzzy.api.Constant;
import com.fzzy.api.data.ApiParam;
import com.fzzy.api.dto.ResponseDto;
+import com.fzzy.api.entity.Api1202;
import com.fzzy.api.entity.ApiConfs;
import com.fzzy.api.entity.ApiInfoData;
import com.fzzy.api.service.ApiCommonService;
@@ -21,12 +23,22 @@
import com.fzzy.data.ConfigData;
import com.fzzy.otherview.whhpjl.WhjlConstant;
import com.fzzy.otherview.whhpjl.dto.*;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -36,6 +48,8 @@
*
* @author czt
*/
+
+@Slf4j
@Component
public class WhjlShareApi2013PR2 {
@Autowired
@@ -73,6 +87,23 @@
@DataProvider
public List<WhjlShareApi2013> listData() {
List<ApiInfoData> result = apiInfoDataRep.getDataByInteId(WhjlConstant.API_CODE_2013);
+ if (null == result || result.isEmpty()) {
+ return null;
+ }
+ List<WhjlShareApi2013> list = new ArrayList<>();
+ WhjlShareApi2013 whjlShareApiData;
+ for (ApiInfoData infoData : result) {
+ whjlShareApiData = JSONObject.parseObject(infoData.getData(), WhjlShareApi2013.class);
+ whjlShareApiData.setKqdm(infoData.getKqdm());
+ whjlShareApiData.setCzbz(infoData.getCzbz());
+ whjlShareApiData.setUpdateTime(infoData.getUpdateTime());
+ list.add(whjlShareApiData);
+ }
+ return list;
+ }
+
+ public List<WhjlShareApi2013> listDataByTime(Date start, Date end) {
+ List<ApiInfoData> result = apiInfoDataRep.getDataByInteId(WhjlConstant.API_CODE_2013, start, end);
if (null == result || result.isEmpty()) {
return null;
}
@@ -168,15 +199,16 @@
apiInfoDataRep.deleteById(data.getQlyOrgReportId());
return null;
}
+
/**
* 鏇存柊鏁版嵁
* whjlShareApi2013PR2#pullData
*
- * @param items
+ * @param
* @return
*/
@Expose
- public String pullData(List<WhjlShareApi2013> items) {
+ public String pullData(ApiParam param1) {
//鑾峰彇閰嶇疆淇℃伅
@@ -198,14 +230,19 @@
}
//灏佽鍙傛暟
param = new ApiParam(apiConf, WhjlConstant.API_CATEGORY_20, WhjlConstant.API_CODE_2013);
+
+ //璁剧疆璧峰鏃堕棿
+ param.setStart(param1.getStart());
+ param.setEnd(param1.getEnd());
+
responseDto = apiService.pullData(param, apiConf);
- if(null == responseDto){
+ if (null == responseDto) {
return "鏇存柊澶辫触锛�";
}
if (responseDto.getSuccess() == 0) {
list = JSONObject.parseArray(responseDto.getData(), WhjlShareApi2013.class);
- if(null != list && list.size() > 0){
+ if (null != list && list.size() > 0) {
for (WhjlShareApi2013 shareData : list) {
//淇濆瓨鏂囦欢
//璺緞
@@ -213,10 +250,10 @@
//鏂囦欢id
- if(StringUtils.isNotEmpty(shareData.getReportFile())){
+ if (StringUtils.isNotEmpty(shareData.getReportFile())) {
String fileId = ContextUtil.getTimeId(1000);
- String fileName = "闄勪欢"+ ".pdf";
- Base64Util.saveBase64ToFile(shareData.getReportFile(),basePath + fileId + ".pdf");
+ String fileName = "闄勪欢" + ".pdf";
+ Base64Util.base64StringToPDF(shareData.getReportFile(), basePath, fileId + ".pdf");
shareData.setFileId(fileId);
shareData.setFileName(fileName);
@@ -253,75 +290,81 @@
* whjlShareApi2013PR#sysDataToDept
*/
@Expose
- public void sysDataToDept(){
+ public void sysDataToDept(ApiParam param1) {
//鑾峰彇鎵�鏈夋暟鎹�
- List<WhjlShareApi2013> list = listData();
- if(null == list || list.isEmpty()){
+ List<WhjlShareApi2013> list = listDataByTime(param1.getStart(), param1.getEnd());
+ if (null == list || list.isEmpty()) {
return;
}
Fz40WhjlMQuality fz40WhjlMQuality = null;
for (WhjlShareApi2013 whjlShareApi2013 : list) {
- fz40WhjlMQuality = new Fz40WhjlMQuality();
- fz40WhjlMQuality.setProvReserve(Constant.YN_Y);
- fz40WhjlMQuality.setId(whjlShareApi2013.getQlyOrgReportId());
- String basePath = configData.getImgPath() + "COMMON/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
+ try {
- if(StringUtils.isNotEmpty(whjlShareApi2013.getReportFile())){
+ fz40WhjlMQuality = new Fz40WhjlMQuality();
+ fz40WhjlMQuality.setProvReserve(Constant.YN_Y);
+ fz40WhjlMQuality.setId(whjlShareApi2013.getQlyOrgReportId());
+ String basePath = configData.getImgPath() + "COMMON/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/";
- String fileId = ContextUtil.getTimeId(1000) + ".pdf";
- String fileName = "闄勪欢"+ ".pdf";
- Base64Util.base64StringToPDF(whjlShareApi2013.getReportFile(),basePath , fileId );
+ if (StringUtils.isNotEmpty(whjlShareApi2013.getReportFile())) {
+
+ String fileId = ContextUtil.getTimeId(1000) + ".pdf";
+ String fileName = "闄勪欢" + ".pdf";
+ Base64Util.base64StringToPDF(whjlShareApi2013.getReportFile(), basePath, fileId);
- whjlShareApi2013.setFileId(fileId);
- whjlShareApi2013.setFileName(fileName);
- whjlShareApi2013.setFileTime(new Date());
- whjlShareApi2013.setReportFile(null);
- }
- BeanUtils.copyProperties(whjlShareApi2013, fz40WhjlMQuality);
- fz40WhjlMQuality.setCompanyId(configData.getCompanyId());
- fz40WhjlMQuality.setDeptId(DEPT_ID);
- fz40ToWhjlSync2013Rep.save(fz40WhjlMQuality);
- if(whjlShareApi2013.getOrgReportNoodlesList() != null){
- List<ShareApi2013Xmf> orgReportNoodlesList = whjlShareApi2013.getOrgReportNoodlesList();
- for (ShareApi2013Xmf shareApi2013Xmf : orgReportNoodlesList) {
- Fz40WhjlCheckItemXmf fz40WhjlCheckItemXmf = new Fz40WhjlCheckItemXmf();
- BeanUtils.copyProperties(shareApi2013Xmf,fz40WhjlCheckItemXmf);
- if(StringUtils.isEmpty(fz40WhjlCheckItemXmf.getQlyOrgReportNoodlesId())) continue;
- fz40ToWhjlSync2013XmfRep.save(fz40WhjlCheckItemXmf);
+ whjlShareApi2013.setFileId(fileId);
+ whjlShareApi2013.setFileName(fileName);
+ whjlShareApi2013.setFileTime(new Date());
+ whjlShareApi2013.setReportFile(null);
+ log.info("瀛樺叆闄勪欢淇℃伅={}", fileName);
}
- }
- if(whjlShareApi2013.getOrgReportSoybeanList() != null){
- List<ShareApi2013Dd> orgReportSoybeanList = whjlShareApi2013.getOrgReportSoybeanList();
- for (ShareApi2013Dd shareApi2013Dd : orgReportSoybeanList) {
- Fz40WhjlCheckItemDd fz40WhjlCheckItemDd = new Fz40WhjlCheckItemDd();
- BeanUtils.copyProperties(shareApi2013Dd,fz40WhjlCheckItemDd);
- if(StringUtils.isEmpty(fz40WhjlCheckItemDd.getQlyOrgReportSoybeanId())) continue;
-
- fz40ToWhjlSync2013DdRep.save(fz40WhjlCheckItemDd);
+ BeanUtils.copyProperties(whjlShareApi2013, fz40WhjlMQuality);
+ fz40WhjlMQuality.setCompanyId(configData.getCompanyId());
+ fz40WhjlMQuality.setDeptId(DEPT_ID);
+ fz40ToWhjlSync2013Rep.save(fz40WhjlMQuality);
+ if (whjlShareApi2013.getOrgReportNoodlesList() != null) {
+ List<ShareApi2013Xmf> orgReportNoodlesList = whjlShareApi2013.getOrgReportNoodlesList();
+ for (ShareApi2013Xmf shareApi2013Xmf : orgReportNoodlesList) {
+ Fz40WhjlCheckItemXmf fz40WhjlCheckItemXmf = new Fz40WhjlCheckItemXmf();
+ BeanUtils.copyProperties(shareApi2013Xmf, fz40WhjlCheckItemXmf);
+ if (StringUtils.isEmpty(fz40WhjlCheckItemXmf.getQlyOrgReportNoodlesId())) continue;
+ fz40ToWhjlSync2013XmfRep.save(fz40WhjlCheckItemXmf);
+ }
}
- }
- if(whjlShareApi2013.getOrgReportRiceList() != null){
- List<ShareApi2013Dm> orgReportRiceList = whjlShareApi2013.getOrgReportRiceList();
- for (ShareApi2013Dm shareApi2013Dm : orgReportRiceList) {
- Fz40WhjlCheckItemDm fz40WhjlCheckItemDm = new Fz40WhjlCheckItemDm();
- BeanUtils.copyProperties(shareApi2013Dm,fz40WhjlCheckItemDm);
- if(StringUtils.isEmpty(fz40WhjlCheckItemDm.getQlyOrgReportRiceId())) continue;
+ if (whjlShareApi2013.getOrgReportSoybeanList() != null) {
+ List<ShareApi2013Dd> orgReportSoybeanList = whjlShareApi2013.getOrgReportSoybeanList();
+ for (ShareApi2013Dd shareApi2013Dd : orgReportSoybeanList) {
+ Fz40WhjlCheckItemDd fz40WhjlCheckItemDd = new Fz40WhjlCheckItemDd();
+ BeanUtils.copyProperties(shareApi2013Dd, fz40WhjlCheckItemDd);
+ if (StringUtils.isEmpty(fz40WhjlCheckItemDd.getQlyOrgReportSoybeanId())) continue;
- fz40ToWhjlSync2013DmRep.save(fz40WhjlCheckItemDm);
+ fz40ToWhjlSync2013DdRep.save(fz40WhjlCheckItemDd);
+ }
}
- }
- if(whjlShareApi2013.getOrgReportOilList() != null){
- List<ShareApi2013Syy> orgReportOilList = whjlShareApi2013.getOrgReportOilList();
- for (ShareApi2013Syy shareApi2013Syy : orgReportOilList) {
- Fz40WhjlCheckItemSyy fz40WhjlCheckItemSyy = new Fz40WhjlCheckItemSyy();
- BeanUtils.copyProperties(shareApi2013Syy,fz40WhjlCheckItemSyy);
- if(StringUtils.isEmpty(fz40WhjlCheckItemSyy.getQlyOrgReportOilId())) continue;
+ if (whjlShareApi2013.getOrgReportRiceList() != null) {
+ List<ShareApi2013Dm> orgReportRiceList = whjlShareApi2013.getOrgReportRiceList();
+ for (ShareApi2013Dm shareApi2013Dm : orgReportRiceList) {
+ Fz40WhjlCheckItemDm fz40WhjlCheckItemDm = new Fz40WhjlCheckItemDm();
+ BeanUtils.copyProperties(shareApi2013Dm, fz40WhjlCheckItemDm);
+ if (StringUtils.isEmpty(fz40WhjlCheckItemDm.getQlyOrgReportRiceId())) continue;
- fz40ToWhjlSync2013SyyRep.save(fz40WhjlCheckItemSyy);
+ fz40ToWhjlSync2013DmRep.save(fz40WhjlCheckItemDm);
+ }
}
- }
+ if (whjlShareApi2013.getOrgReportOilList() != null) {
+ List<ShareApi2013Syy> orgReportOilList = whjlShareApi2013.getOrgReportOilList();
+ for (ShareApi2013Syy shareApi2013Syy : orgReportOilList) {
+ Fz40WhjlCheckItemSyy fz40WhjlCheckItemSyy = new Fz40WhjlCheckItemSyy();
+ BeanUtils.copyProperties(shareApi2013Syy, fz40WhjlCheckItemSyy);
+ if (StringUtils.isEmpty(fz40WhjlCheckItemSyy.getQlyOrgReportOilId())) continue;
+ fz40ToWhjlSync2013SyyRep.save(fz40WhjlCheckItemSyy);
+ }
+ }
+ } catch (Exception e) {
+ log.error("鍚屾鏁版嵁澶辫触锛�", e);
+ continue;
+ }
}
}
}
diff --git a/src/main/java/com/fzzy/push/whhpjl/Whjl2023HttpClientUtil.java b/src/main/java/com/fzzy/push/whhpjl/Whjl2023HttpClientUtil.java
index 404a853..3b14e06 100644
--- a/src/main/java/com/fzzy/push/whhpjl/Whjl2023HttpClientUtil.java
+++ b/src/main/java/com/fzzy/push/whhpjl/Whjl2023HttpClientUtil.java
@@ -6,9 +6,11 @@
import com.fzzy.push.whhpjl.dto.WhjlReqDto;
import com.fzzy.push.whhpjl.dto.WhjlRespDto;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
/**
* 姝︽眽鍐涚伯鐪佸钩鍙�-涓婁紶鏁版嵁鏈嶅姟绫�
@@ -20,59 +22,141 @@
@Component
public class Whjl2023HttpClientUtil {
- @Autowired
- private RestTemplate restTemplate;
-
-
/**
* 鏁版嵁涓婃姤post璇锋眰
+ *
* @param url
* @param reqData
* @return
*/
- public WhjlRespDto postPushData(String url, WhjlReqDto reqData) {
+ public WhjlRespDto postPushData(String url, WhjlReqDto reqData) throws Exception {
log.info("---------鎺ュ彛璇锋眰鍦板潃锛�" + url + "----------鍙傛暟锛�" + JSON.toJSONString(reqData) + "---------");
+ BufferedReader in = null;
+ URL urls = new URL(url);
+ HttpURLConnection connection = null;
+ OutputStream outputStream = null;
String rs = "";
WhjlRespDto responseDto;
-
try {
- rs = restTemplate.postForObject(url, reqData, String.class);
+ connection = (HttpURLConnection) urls.openConnection();
+ connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
+ connection.setRequestProperty("Accept", "*/*");
+ connection.setRequestProperty("Range", "bytes=" + "");
+ connection.setConnectTimeout(20000);
+ connection.setReadTimeout(30000);
+ connection.setRequestMethod("POST");
- } catch (Exception e) {
- System.out.println("鍙戠敓寮傚父");
- log.error(e.getMessage(), e);
- rs = null;
- return new WhjlRespDto(99, e.getMessage());
+ outputStream = connection.getOutputStream();
+
+ outputStream.write(JSON.toJSONString(reqData).getBytes("UTF-8"));
+ try {
+ connection.connect();
+ if (connection.getResponseCode() == 200) {
+ in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+ String line = "";
+ while ((line = in.readLine()) != null) {
+ rs += line;
+ }
+ }else{
+ log.error("http鐘舵�侊細" + connection.getResponseCode());
+ log.error("http娑堟伅锛�" + connection.getResponseMessage());
+ }
+
+ } catch (Exception e) {
+ System.out.println("鍙戠敓寮傚父");
+ log.error(e.getMessage(), e);
+ rs = null;
+ return new WhjlRespDto(99, e.getMessage());
+ }
+ log.info("---------鎺ュ彛杩斿洖锛�" + rs + "---------");
+ responseDto = JSON.parseObject(rs, WhjlRespDto.class);
+ if (responseDto == null) return new WhjlRespDto(99, "鎺ュ彛璇锋眰鍙戠敓鏈煡閿欒");
+ return responseDto;
+ } finally {
+ try {
+ outputStream.close();
+ if (in != null) {
+ in.close();
+ }
+ } catch (Exception e) {
+ }
+ outputStream = null;
+ if (connection != null)
+ connection.disconnect();
+ connection = null;
}
- log.info("---------鎺ュ彛杩斿洖锛�" + rs + "---------");
- responseDto = JSON.parseObject(rs, WhjlRespDto.class);
- if (responseDto == null) return new WhjlRespDto(99, "鎺ュ彛璇锋眰鍙戠敓鏈煡閿欒");
- return responseDto;
}
/**
* 鏁版嵁涓婃姤post璇锋眰
+ *
* @param url
* @param reqData
* @return
*/
- public WhjlPullRespDto postPullData(String url, WhjlPullReqDto reqData) {
+ public WhjlPullRespDto postPullData(String url, WhjlPullReqDto reqData) throws Exception {
log.info("---------鎺ュ彛璇锋眰鍦板潃锛�" + url + "----------鍙傛暟锛�" + JSON.toJSONString(reqData) + "---------");
+ BufferedReader in = null;
+ URL urls = new URL(url);
+ HttpURLConnection connection = null;
+ OutputStream outputStream = null;
String rs = "";
WhjlPullRespDto responseDto;
-
try {
- rs = restTemplate.postForObject(url, reqData, String.class);
+ connection = (HttpURLConnection) urls.openConnection();
+ connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
+ connection.setRequestProperty("Accept", "*/*");
+ connection.setRequestProperty("Range", "bytes=" + "");
+ connection.setConnectTimeout(20000);
+ connection.setReadTimeout(30000);
+ connection.setRequestMethod("POST");
- } catch (Exception e) {
- System.out.println("鍙戠敓寮傚父");
- log.error(e.getMessage(), e);
- rs = null;
- return new WhjlPullRespDto(99, null);
+ outputStream = connection.getOutputStream();
+
+ outputStream.write(JSON.toJSONString(reqData).getBytes("UTF-8"));
+ try {
+ connection.connect();
+ if (connection.getResponseCode() == 200) {
+ in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
+ String line = "";
+ while ((line = in.readLine()) != null) {
+ rs += line;
+ }
+ } else {
+ log.error("http鐘舵�侊細" + connection.getResponseCode());
+ log.error("http娑堟伅锛�" + connection.getResponseMessage());
+ }
+
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ rs = null;
+ return new WhjlPullRespDto(99, null);
+ }
+ log.info("---------鎺ュ彛杩斿洖锛�" + rs + "---------");
+ responseDto = JSON.parseObject(rs, WhjlPullRespDto.class);
+
+ if (responseDto == null) {
+ return new WhjlPullRespDto(99, "鎺ュ彛璇锋眰鍙戠敓鏈煡閿欒");
+ }
+ return responseDto;
+ } finally {
+ try {
+ outputStream.close();
+ if (in != null) {
+ in.close();
+ }
+ } catch (Exception e) {
+ }
+ outputStream = null;
+ if (connection != null)
+ connection.disconnect();
+ connection = null;
}
- log.info("---------鎺ュ彛杩斿洖锛�" + rs + "---------");
- responseDto = JSON.parseObject(rs, WhjlPullRespDto.class);
- if (responseDto == null) return new WhjlPullRespDto(99, "鎺ュ彛璇锋眰鍙戠敓鏈煡閿欒");
- return responseDto;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/fzzy/push/whhpjl/WhjlApiRemoteService.java b/src/main/java/com/fzzy/push/whhpjl/WhjlApiRemoteService.java
index b3ba95b..c0980f9 100644
--- a/src/main/java/com/fzzy/push/whhpjl/WhjlApiRemoteService.java
+++ b/src/main/java/com/fzzy/push/whhpjl/WhjlApiRemoteService.java
@@ -19,6 +19,7 @@
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateFormatUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -352,6 +353,13 @@
reqData.setUid(conf.getUserName());
//搴旂敤鐮�
reqData.setAppcode(conf.getAppCode());
+ if(null != param.getStart()){
+ reqData.setStarttime(DateFormatUtils.format(param.getStart(), "yyyy-MM-dd HH:mm:ss"));
+ }
+ if(null != param.getEnd()){
+ reqData.setEndtime(DateFormatUtils.format(param.getEnd(), "yyyy-MM-dd HH:mm:ss"));
+ }
+
//鏃堕棿鎴�
reqData.setTimestamp(Long.valueOf(ContextUtil.getCurTimeMillis()));
//韬唤绛惧悕锛屽搴旂敤鐮乢鎺堟潈鐮乢绔欑偣缂栫爜_鎶ユ枃ID_鏃堕棿鎴宠繘琛孧D5绠楁硶绛惧悕
diff --git a/src/main/java/com/fzzy/push/whhpjl/dto/WhjlPullReqDto.java b/src/main/java/com/fzzy/push/whhpjl/dto/WhjlPullReqDto.java
index 40e6f7c..da87d08 100644
--- a/src/main/java/com/fzzy/push/whhpjl/dto/WhjlPullReqDto.java
+++ b/src/main/java/com/fzzy/push/whhpjl/dto/WhjlPullReqDto.java
@@ -36,4 +36,14 @@
* 韬唤绛惧悕
*/
private String accesstoken;
+
+ /**
+ * 寮�濮嬫椂闂�
+ */
+ private String starttime;
+
+ /**
+ * 鎴鏃堕棿
+ */
+ private String endtime;
}
--
Gitblit v1.9.3