From 757ee5dc2ca4185d3c60db1e8c35d2e96e15c50c Mon Sep 17 00:00:00 2001 From: CZT <czt18638530771@163.com> Date: 星期四, 14 十二月 2023 17:35:46 +0800 Subject: [PATCH] 上海省平台共享接口-监控信息更新 --- /dev/null | 23 -- src/main/java/com/fzzy/push/sh2023/dto/SH2023ShareApi1311.java | 129 ++++++++++++++++ src/main/java/com/fzzy/push/sh2023/SH2023HttpClientUtil.java | 72 ++++++++ src/main/java/com/fzzy/otherview/sh2023/pr/SHApi1311PR.java | 74 +++++++++ src/main/java/com/fzzy/push/sh2023/dto/SH2023PullRespDto.java | 37 ++++ src/main/java/com/fzzy/push/sh2023/dto/SH2023PullReqDto.java | 25 +++ src/main/java/com/fzzy/otherview/sh2023/ShApi1311.view.xml | 31 ++- src/main/java/com/fzzy/push/sh2023/SH2023ApiRemoteService.java | 64 +++++++ 8 files changed, 409 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/fzzy/otherview/sh2023/ShApi1311.view.xml b/src/main/java/com/fzzy/otherview/sh2023/ShApi1311.view.xml index e772385..ab8dd56 100644 --- a/src/main/java/com/fzzy/otherview/sh2023/ShApi1311.view.xml +++ b/src/main/java/com/fzzy/otherview/sh2023/ShApi1311.view.xml @@ -432,6 +432,18 @@ <Property name="exClassName">toolbar-button-push</Property> <Property name="width">100</Property> </ToolBarButton> + <ToolBarButton> + <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> + <Property name="iconClass">fa fa-hand-o-up</Property> + <Property name="exClassName">toolbar-button-push</Property> + <Property name="width">100</Property> + </ToolBarButton> <Fill/> <ToolBarButton> <Property name="caption">涓婁紶璁板綍</Property> @@ -560,16 +572,6 @@ <Editor/> </AutoFormElement> <AutoFormElement> - <Property name="name">tdmc</Property> - <Property name="property">tdmc</Property> - <Editor/> - </AutoFormElement> - <AutoFormElement> - <Property name="name">jksbbm</Property> - <Property name="property">jksbbm</Property> - <Editor/> - </AutoFormElement> - <AutoFormElement> <Property name="name">jksbmc</Property> <Property name="property">jksbmc</Property> <Editor/> @@ -587,11 +589,6 @@ <AutoFormElement> <Property name="name">jkxh</Property> <Property name="property">jkxh</Property> - <Editor/> - </AutoFormElement> - <AutoFormElement> - <Property name="name">jkxlh</Property> - <Property name="property">jkxlh</Property> <Editor/> </AutoFormElement> <AutoFormElement> @@ -699,6 +696,10 @@ <Property name="service">sHApi1311PR#pushData</Property> <Property name="confirmMessage">纭畾瑕佷笂鎶ヤ箞锛�</Property> </AjaxAction> + <AjaxAction id="ajaxPull"> + <Property name="service">sHApi1311PR#pullData</Property> + <Property name="confirmMessage">纭畾瑕佹媺鍙栨暟鎹悧锛�</Property> + </AjaxAction> <AjaxAction id="ajaxDel"> <Property name="service">sHApi1311PR#delData</Property> <Property name="confirmMessage">褰撳墠鏁版嵁鍒犻櫎鍚庢棤娉曟仮澶嶏紝璇风‘璁よ鍒犻櫎涔堬紵</Property> diff --git a/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2104.java b/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2104.java deleted file mode 100644 index 55d1ef0..0000000 --- a/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2104.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.fzzy.otherview.sh2023.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * 涓婃捣甯傛帴鍙�-2104 甯傚偍椹宠繍鍗� - * - * @author czt - * @date 2023/8/17 - */ -@Data -@EqualsAndHashCode(callSuper = false) -public class ShApi2104 implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - -} diff --git a/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2203.java b/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2203.java deleted file mode 100644 index 6c5ca81..0000000 --- a/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2203.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.fzzy.otherview.sh2023.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * 涓婃捣甯傛帴鍙�-2203 浜ゆ槗涓績鍚堝悓 - * - * @author czt - * @date 2023/8/17 - */ -@Data -@EqualsAndHashCode(callSuper = false) -public class ShApi2203 implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - -} diff --git a/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2204.java b/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2204.java deleted file mode 100644 index ea83731..0000000 --- a/src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2204.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.fzzy.otherview.sh2023.dto; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; - -/** - * 涓婃捣甯傛帴鍙�-2204 瀹氬寲姘存楠� - * - * @author czt - * @date 2023/8/17 - */ -@Data -@EqualsAndHashCode(callSuper = false) -public class ShApi2204 implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - -} diff --git a/src/main/java/com/fzzy/otherview/sh2023/pr/SHApi1311PR.java b/src/main/java/com/fzzy/otherview/sh2023/pr/SHApi1311PR.java index f3fc1c0..78c74cb 100644 --- a/src/main/java/com/fzzy/otherview/sh2023/pr/SHApi1311PR.java +++ b/src/main/java/com/fzzy/otherview/sh2023/pr/SHApi1311PR.java @@ -19,8 +19,10 @@ import com.fzzy.push.sh2023.SH2023Constant; import com.fzzy.push.sh2023.dto.SH2023Api1311; import com.fzzy.push.sh2023.dto.SH2023Api2101; +import com.fzzy.push.sh2023.dto.SH2023ShareApi1311; 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; @@ -172,7 +174,7 @@ } //灏佽鍙傛暟 - ApiParam param = new ApiParam(apiConf, "21", SH2023Constant.SH_2023_API_CODE_1311); + ApiParam param = new ApiParam(apiConf, "13", SH2023Constant.SH_2023_API_CODE_1311); //鑾峰彇瀹炵幇鎺ュ彛 ApiRemoteService apiService = apiPushManager.getApiRemoteService(param.getPushProtocol()); @@ -201,4 +203,74 @@ return result; } + /** + * 鍏变韩鎷夊彇鏁版嵁 + * sHApi1311PR#pullData + * + * @return + */ + @Expose + public String pullData() { + + + //鑾峰彇閰嶇疆淇℃伅 + List<ApiConfs> apiConfs = apiCommonService.listCacheConf(); + if (null == apiConfs || apiConfs.isEmpty()) { + return "绯荤粺娌℃湁鑾峰彇鍒板簱鍖洪厤缃俊鎭紝鎵ц澶辫触"; + } + + ApiRemoteService apiService; + ApiParam param; + ResponseDto responseDto; + ApiInfoData infoData; + String result = ""; + List<SH2023ShareApi1311> list; + SH2023Api1311 sh2023Api1311; + List<ApiInfoData> apiInfoDataList; + for (ApiConfs apiConf : apiConfs) { + apiService = apiPushManager.getApiRemoteService(apiConf.getPushProtocol()); + if (null == apiService) { + continue; + } + //灏佽鍙傛暟 + param = new ApiParam(apiConf, "13", SH2023Constant.SH_2023_API_CODE_1311); + responseDto = apiService.pullData(param, apiConf); + + if (responseDto.getSuccess() == 0) { + list = JSONObject.parseArray(responseDto.getData(), SH2023ShareApi1311.class); + if(null != list && list.size() > 0){ + for (SH2023ShareApi1311 shareData : list) { + + apiInfoDataList = apiInfoDataRep.getDataByDataId(shareData.getSxtbh()); + if(null == apiInfoDataList || apiInfoDataList.isEmpty()){ + sh2023Api1311 = new SH2023Api1311(); + sh2023Api1311.setSpjksbid(shareData.getSxtbh()); + sh2023Api1311.setCzbz(Constant.CZBZ_I); + }else { + sh2023Api1311 = JSONObject.parseObject(apiInfoDataList.get(0).getData(), SH2023Api1311.class); + sh2023Api1311.setCzbz(apiInfoDataList.get(0).getCzbz()); + } + if(StringUtils.isNotEmpty(shareData.getHwdm())){ + sh2023Api1311.setHwdm(shareData.getHwdm()); + } + sh2023Api1311.setJksbmc(shareData.getTdmc()); + infoData = new ApiInfoData(); + infoData.setId(sh2023Api1311.getSpjksbid()); + infoData.setKqdm(apiConf.getKqdm()); + infoData.setInteType("13"); + infoData.setInteId(SH2023Constant.SH_2023_API_CODE_1311); + infoData.setUpdateTime(new Date()); + infoData.setDataId(sh2023Api1311.getSpjksbid()); + infoData.setData(JSON.toJSONString(sh2023Api1311)); + infoData.setCzbz(sh2023Api1311.getCzbz()); + apiInfoDataRep.save(infoData); + } + } + } + result += responseDto.toString(); + return result; + } + return null; + } + } diff --git a/src/main/java/com/fzzy/push/sh2023/SH2023ApiRemoteService.java b/src/main/java/com/fzzy/push/sh2023/SH2023ApiRemoteService.java index b6ee00b..6d59bdd 100644 --- a/src/main/java/com/fzzy/push/sh2023/SH2023ApiRemoteService.java +++ b/src/main/java/com/fzzy/push/sh2023/SH2023ApiRemoteService.java @@ -162,6 +162,64 @@ } } + @Override + public ResponseDto pullData(ApiParam param, ApiConfs conf) { + String inteId = param.getInteId(); + String kqdm = param.getKqdm(); + + try { + if (null == conf) { + conf = apiCommonService.getConf(kqdm); + } + + //娣诲姞鏃ュ織 + ApiLog apiLog = new ApiLog(); + apiLog.setId(ContextUtil.getUUID()); + apiLog.setInteId(inteId); + + if (StringUtils.isEmpty(inteId)) { + ResponseDto responseDto = new ResponseDto(99, "娌℃湁鑾峰彇鍒版帴鍙�"); + apiLog.setStatus(99); + apiLog.setResult("娌℃湁鑾峰彇鍒版帴鍙�"); + apiLogRep.save(apiLog); + return responseDto; + } + + if (conf == null) { + ResponseDto responseDto = new ResponseDto(99, "娌℃湁鑾峰彇鍒颁笂浼犻厤缃�"); + apiLog.setStatus(99); + apiLog.setResult("娌℃湁鑾峰彇鍒颁笂浼犻厤缃�"); + apiLogRep.save(apiLog); + return responseDto; + } + + //鏌ヨ搴撳尯淇℃伅琛屾斂鍖哄垝鐮� + List<Api1102> api1102List = api1102Rep.findPushData(kqdm); + //灏佽鏁版嵁 + SH2023PullReqDto reqData = new SH2023PullReqDto();; + + reqData.setName(conf.getUserName()); + reqData.setPwd(conf.getAppCode()); + + log.info("鎷夊彇鍏变韩鏁版嵁璇锋眰淇℃伅=" + JSON.toJSONString(reqData)); + + String url = conf.getApiUrl().replace("UPLOAD", "Shared"); + SH2023PullRespDto responseDto = SH2023HttpClientUtil.postPullData(url + inteId, JSON.toJSONString(reqData)); + + apiLog.setStatus(responseDto.getRetcode() == 200 ? 0 : responseDto.getRetcode()); + apiLog.setResult(responseDto.getRetMsg()); + apiLogRep.save(apiLog); + ResponseDto resd = new ResponseDto(); + resd.setSuccess(responseDto.getRetcode() == 200 ? 0 : responseDto.getRetcode()); + resd.setMsg(responseDto.getRetMsg()); + resd.setData(responseDto.getData()); + return resd; + } catch (Exception e) { + log.error(e.getMessage(), e); + return new ResponseDto(99, e.getMessage()); + } + } + /** * 杞负JSON * @@ -1227,12 +1285,6 @@ } } return object; - } - - @Override - public ResponseDto pullData(ApiParam param, ApiConfs conf) { - //璇ュ崗璁棤姝ゅ疄鐜� - return null; } } \ No newline at end of file diff --git a/src/main/java/com/fzzy/push/sh2023/SH2023HttpClientUtil.java b/src/main/java/com/fzzy/push/sh2023/SH2023HttpClientUtil.java index 9f5ddf9..bbaef44 100644 --- a/src/main/java/com/fzzy/push/sh2023/SH2023HttpClientUtil.java +++ b/src/main/java/com/fzzy/push/sh2023/SH2023HttpClientUtil.java @@ -2,7 +2,7 @@ import com.alibaba.fastjson.JSON; import com.fzzy.api.entity.ApiConfs; -import com.fzzy.push.sh2023.dto.SH2023ReqDto; +import com.fzzy.push.sh2023.dto.SH2023PullRespDto; import com.fzzy.push.sh2023.dto.SH2023RespDto; import lombok.extern.slf4j.Slf4j; import java.io.BufferedReader; @@ -87,4 +87,74 @@ connection = null; } } + + /** + * 鎷夊彇鏁版嵁 + * @param url + * @param reqData + * @return + * @throws Exception + */ + @SuppressWarnings("resource") + public static SH2023PullRespDto postPullData(String url, String reqData) throws Exception { + log.info("---------鎺ュ彛璇锋眰鍦板潃锛�" +url+ "----------鍙傛暟锛�" + reqData +"---------"); + BufferedReader in = null; + URL urls = new URL(url); + HttpURLConnection connection = null; + OutputStream outputStream = null; + String rs = ""; + SH2023PullRespDto responseDto; + try { + + 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"); + + outputStream = connection.getOutputStream(); + + outputStream.write(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 SH2023PullRespDto(99,e.getMessage(),null,null,null); + } + log.info("---------鎺ュ彛杩斿洖锛�" + rs +"---------"); + responseDto = JSON.parseObject(rs,SH2023PullRespDto.class); + if(responseDto == null ) return new SH2023PullRespDto(99,"鎺ュ彛璇锋眰鍙戠敓鏈煡閿欒",null,null,null); + return responseDto; + } finally { + try { + outputStream.close(); + if (in != null){ + in.close(); + } + } catch (Exception e) { + } + outputStream = null; + if (connection != null) + connection.disconnect(); + connection = null; + } + } } \ No newline at end of file diff --git a/src/main/java/com/fzzy/push/sh2023/dto/SH2023PullReqDto.java b/src/main/java/com/fzzy/push/sh2023/dto/SH2023PullReqDto.java new file mode 100644 index 0000000..00e90ec --- /dev/null +++ b/src/main/java/com/fzzy/push/sh2023/dto/SH2023PullReqDto.java @@ -0,0 +1,25 @@ +package com.fzzy.push.sh2023.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 涓婃捣2023鐗堢渷骞冲彴-鍏变韩鏁版嵁灏佽 + * @author czt + * @date 2023/08/17 + */ +@Data +public class SH2023PullReqDto implements Serializable { + + /** + * + */ + private String name; + + /** + * + */ + private String pwd; + +} diff --git a/src/main/java/com/fzzy/push/sh2023/dto/SH2023PullRespDto.java b/src/main/java/com/fzzy/push/sh2023/dto/SH2023PullRespDto.java new file mode 100644 index 0000000..f112ebe --- /dev/null +++ b/src/main/java/com/fzzy/push/sh2023/dto/SH2023PullRespDto.java @@ -0,0 +1,37 @@ +package com.fzzy.push.sh2023.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 涓婃姤鍙嶉 + * @author czt + * @date 2023/08/17 + */ +@Data +public class SH2023PullRespDto<T> implements Serializable { + /** + * + */ + private static final long serialVersionUID = -6714158228489303453L; + + + private int retcode ; + + private String retMsg; + private String nextpointer; + private String isTransmitComplete; + private String data; + + public SH2023PullRespDto() { + } + + public SH2023PullRespDto(int retcode, String retMsg, String nextpointer, String isTransmitComplete, String data) { + this.retcode = retcode; + this.retMsg = retMsg; + this.nextpointer = nextpointer; + this.isTransmitComplete = isTransmitComplete; + this.data = data; + } +} diff --git a/src/main/java/com/fzzy/push/sh2023/dto/SH2023ShareApi1311.java b/src/main/java/com/fzzy/push/sh2023/dto/SH2023ShareApi1311.java new file mode 100644 index 0000000..8c09fb3 --- /dev/null +++ b/src/main/java/com/fzzy/push/sh2023/dto/SH2023ShareApi1311.java @@ -0,0 +1,129 @@ +package com.fzzy.push.sh2023.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import com.bstek.dorado.annotation.PropertyDef; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * 瑙嗛鐩戞帶 + * + * @Author:YAN + */ +@Data +@EqualsAndHashCode(callSuper = false) +public class SH2023ShareApi1311 implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + @PropertyDef(label = "鐩戞帶缂栧彿") + private String sxtbh; + @PropertyDef(label = "鐩戞帶缂栧彿") + private String tdmc; + @PropertyDef(label = "鐩戞帶缂栧彿") + private String jkxlh; + @PropertyDef(label = "鐩戞帶缂栧彿") + private String jksbbm; + + @PropertyDef(label = "瑙嗛鐩戞帶璁惧id") + private String spjksbid; + + @PropertyDef(label = "閫氶亾缂栧彿") + private Integer tdbh; + + @PropertyDef(label = "鐩戞帶璁惧鍚嶇О") + private String jksbmc; + + @PropertyDef(label = "搴撳尯浠g爜") + private String kqdm; + + /** + * 1 娴峰悍, 2 澶у崕, 3 瀹囪 + * 4 澶╁湴浼熶笟,5 鍗庝负,9 鍏朵粬 + */ + @PropertyDef(label = "鐩戞帶鍘傚晢") + private String jkcs; + + @PropertyDef(label = "鐩戞帶鍨嬪彿") + private String jkxh; + + /** + * 1:浠撳唴锛�2:涓氬姟锛� + * 3:瀹夐槻 + */ + @PropertyDef(label = "瑙嗛鐩戞帶绫诲瀷") + private String spjklx; + + /** + * 1:DVR 2:NVR + */ + @PropertyDef(label = "璁惧绫诲瀷") + private String sblxbm; + + @PropertyDef(label = "瀹夎浣嶇疆") + private String azwz; + + /** + * 绮簱澶ч棬锛�01锛夛紝鎵︽牱鏈猴紙02锛夛紝鍖栭獙瀹わ紙03锛夛紝缁撶畻瀹わ紙04锛夛紝 + * 鍦扮鎴匡紙05锛夛紝搴撳尯涓诲共閬擄紙06锛夛紝浠撻棿鐩戞帶锛�07锛夛紝浠撳唴锛�08锛夛紝 + * 鑽搧搴擄紙09锛夛紝鍣ㄦ潗搴擄紙10锛夛紝鍒堕珮鐐癸紙11锛夛紝鍛ㄧ晫锛�12锛夛紝鍏朵粬锛�99锛� + */ + @PropertyDef(label = "瀹夎浣嶇疆绫诲瀷") + private String azwzlx; + + @PropertyDef(label = "鐓у皠鍖哄煙") + private String zsqy; + + /** + * Y/N + */ + @PropertyDef(label = "鏄惁瀹夎琛ュ厜鐏�") + private String sfazbgd; + + @PropertyDef(label = "寤掗棿浠g爜") + private String ajdm; + + @PropertyDef(label = "璐т綅浠g爜") + private String hwdm; + + /** + * 1 :鏋満 2 :鐞冩満 + */ + @PropertyDef(label = "鐩戞帶绫诲瀷缂栫爜") + private String jkjlxbm; + + @PropertyDef(label = "鐩戞帶棰勭疆浣嶆暟閲�") + private Integer jktyzw; + + @PropertyDef(label = "璁惧IP鍦板潃") + private String sbipdz; + + @PropertyDef(label = "璁惧绔彛鍙�") + private Integer sbdkh; + + @PropertyDef(label = "璁惧鐧诲綍鍚嶇О") + private String sbdlmc; + + @PropertyDef(label = "璁惧鐧诲綍瀵嗙爜") + private String sbdlmm; + + @PropertyDef(label = "澶囨敞") + private String bz; + + @PropertyDef(label = "鏍囧織浣�") + private String bjw; + + @PropertyDef(label = "鎿嶄綔鏍囧織") + private String czbz; + + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @PropertyDef(label = "鏈�鍚庢洿鏂版椂闂�") + private Date zhgxsj; + +} -- Gitblit v1.9.3