CZT
2023-12-14 757ee5dc2ca4185d3c60db1e8c35d2e96e15c50c
上海省平台共享接口-监控信息更新
已删除3个文件
已修改4个文件
已添加3个文件
501 ■■■■ 文件已修改
src/main/java/com/fzzy/otherview/sh2023/ShApi1311.view.xml 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2104.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2203.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2204.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/otherview/sh2023/pr/SHApi1311PR.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/push/sh2023/SH2023ApiRemoteService.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/push/sh2023/SH2023HttpClientUtil.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/push/sh2023/dto/SH2023PullReqDto.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/push/sh2023/dto/SH2023PullRespDto.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/push/sh2023/dto/SH2023ShareApi1311.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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(&quot;#dgMain&quot;).get(&quot;selection&quot;);&#xD;
view.get(&quot;#ajaxPull&quot;).set(&quot;parameter&quot;,select).execute(function(result){&#xD;
    view.get(&quot;#dsMain&quot;).flushAsync();&#xD;
       $notify(result);&#xD;
    });&#xD;
</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>
src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2104.java
ÎļþÒÑɾ³ý
src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2203.java
ÎļþÒÑɾ³ý
src/main/java/com/fzzy/otherview/sh2023/dto/ShApi2204.java
ÎļþÒÑɾ³ý
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;
    }
}
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;
    }
}
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;
        }
    }
}
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;
}
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;
    }
}
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 = "库区代码")
    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 = "廒间代码")
    private String ajdm;
    @PropertyDef(label = "货位代码")
    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;
}