|
@@ -0,0 +1,361 @@
|
|
|
|
+package com.example.demo.controller;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.example.common.HttpRequest;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
|
+import org.apache.http.HttpStatus;
|
|
|
|
+import org.apache.http.client.HttpClient;
|
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
|
+import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
|
+import org.apache.http.message.BasicHeader;
|
|
|
|
+import org.apache.http.protocol.HTTP;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+
|
|
|
|
+import java.io.BufferedInputStream;
|
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
|
+import java.io.BufferedReader;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileInputStream;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.io.InputStreamReader;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+@Slf4j
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping("/cms/zzxd/th")
|
|
|
|
+public class ZzxdControllerth {
|
|
|
|
+
|
|
|
|
+ @Value("${system.http.url12345}")
|
|
|
|
+ private String url12345;
|
|
|
|
+
|
|
|
|
+ private final String CHANNELADDORDER = "/12345_inter/handlerProcessNew/channelAddOrderNew";// 自助下单 --8.1新增渠道工单
|
|
|
|
+ private final String CHANNELEDITORDER = "/12345_inter/handlerProcess/channelEditOrder";// 8.2修改渠道工单
|
|
|
|
+ private final String LISTMYAPPEAL = "/12345_inter/handlerProcessNew/listMyAppealNew";// 进度查询--8.3我的诉求查询接口
|
|
|
|
+ private final String SINGLEQUERYORDER = "/12345_inter/handlerProcess/singleQueryOrder";// 工单查询---8.4单个工单查询接口
|
|
|
|
+ private final String SUBMITAPPRAISE = "/12345_inter/handlerProcess/submitAppraise";// 提交评价---8.5提交评价接口
|
|
|
|
+ private final String QUERYPUBLICORDE = "/12345_inter/handlerProcess/queryPublicOrde";// 案例公开---8.6查询案例公开
|
|
|
|
+ private final String GETORDERCOUNT = "/12345_inter/handlerProcess/getOrderCount";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Value("${system.http.appid}")
|
|
|
|
+ private String appid;
|
|
|
|
+
|
|
|
|
+ @Value("${system.http.account}")
|
|
|
|
+ private String account;
|
|
|
|
+
|
|
|
|
+ @Value("${system.http.password}")
|
|
|
|
+ private String password;
|
|
|
|
+
|
|
|
|
+ private String getSignature(String timestamp) {
|
|
|
|
+ // 字典序排序
|
|
|
|
+ String[] arr = { account, timestamp, password };
|
|
|
|
+ Arrays.sort(arr);
|
|
|
|
+ // 按排序后的前后顺序连成串
|
|
|
|
+ StringBuffer buf = new StringBuffer();
|
|
|
|
+ buf.append(arr[0]).append(arr[1]).append(arr[2]);
|
|
|
|
+ String befStr = buf.toString();
|
|
|
|
+ // SHA1加密
|
|
|
|
+ String signature = DigestUtils.shaHex(befStr.getBytes());
|
|
|
|
+ return signature;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// /**
|
|
|
|
+// * 内网(新增12345渠道工单)
|
|
|
|
+// */
|
|
|
|
+ @PostMapping(value = "/save12345")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JSONObject channelAddOrderNew(@RequestBody String requestBody, HttpServletRequest request) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(requestBody);
|
|
|
|
+
|
|
|
|
+ HttpRequest http = new HttpRequest() {
|
|
|
|
+ @Override
|
|
|
|
+ public void complete(Response response) {
|
|
|
|
+
|
|
|
|
+ if (response.state != 200) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ jsonObject.put("message", response.content);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ String channelAddOrder1 = url12345 + CHANNELADDORDER;
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ long times = System.currentTimeMillis();
|
|
|
|
+ String timestamp = String.valueOf(times);
|
|
|
|
+ String mySignature = this.getSignature(timestamp);
|
|
|
|
+
|
|
|
|
+ params.put("signature", mySignature);// 加密校验串
|
|
|
|
+ params.put("timestamp", timestamp);// 时间戳
|
|
|
|
+ params.put("appid", appid);// 吉林省政务服务热线分配给第三方系统的appid
|
|
|
|
+ params.put("orderType", jsonObject.getString("orderType"));// 工单类型
|
|
|
|
+ params.put("requestTopic", jsonObject.getString("requestTopic"));// 诉求标题
|
|
|
|
+ params.put("requestContent", jsonObject.getString("requestContent"));// 诉求内容
|
|
|
|
+ params.put("contactName", jsonObject.getString("contactName"));// 联系人姓名
|
|
|
|
+ params.put("contactTel", jsonObject.getString("contactTel"));// 联系人电话
|
|
|
|
+ params.put("certType", jsonObject.getString("certType"));// 证件类型(1身份证)
|
|
|
|
+ params.put("certCode", jsonObject.getString("certCode"));// 证件号码
|
|
|
|
+ params.put("contactAddress", jsonObject.getString("contactAddress"));// 联系地址
|
|
|
|
+ params.put("requestArea", jsonObject.getString("requestArea"));// 事发地址
|
|
|
|
+ params.put("requestFrom", jsonObject.getString("requestFrom"));// 来源渠道(12345网站)
|
|
|
|
+ params.put("pubIntent", jsonObject.getString("pubIntent"));// 公开意向(y—公开 n—不公开)
|
|
|
|
+ params.put("userId", jsonObject.getString("userId"));//统一身份认证用户唯一标识
|
|
|
|
+ params.put("taskName", jsonObject.getString("requestTopic"));//事项名称
|
|
|
|
+
|
|
|
|
+ if (jsonObject.getString("type") != null &&jsonObject.getString("type").equals("1")) {
|
|
|
|
+ List<Map<String, String>> info = new ArrayList<Map<String, String>>();
|
|
|
|
+ Map<String, String> m = new HashMap<String, String>();
|
|
|
|
+ m.put("fileName", jsonObject.getString("fileName"));//
|
|
|
|
+ m.put("fileBytes", jsonObject.getString("fileBytes"));// 附件数据流,需要转成Base64编码格式
|
|
|
|
+// m.put("fileUrl", jsonObject.getString("fileUrl"));// 文件url
|
|
|
|
+ info.add(m);
|
|
|
|
+ params.put("fileDatas", info);//
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.getString("type") != null && jsonObject.getString("type").equals("2")) {
|
|
|
|
+ List<Map<String, String>> info = new ArrayList<Map<String, String>>();
|
|
|
|
+ Map<String, String> m = new HashMap<String, String>();
|
|
|
|
+ m.put("fileName", jsonObject.getString("fileName"));
|
|
|
|
+// m.put("fileBytes", jsonObject.getString("fileBytes"));// 附件数据流,需要转成Base64编码格式
|
|
|
|
+ m.put("fileUrl", jsonObject.getString("fileUrl"));// 文件url
|
|
|
|
+ info.add(m);
|
|
|
|
+ params.put("fileDatas", info);//
|
|
|
|
+ }
|
|
|
|
+ JSONObject paramsjson = JSONObject.parseObject(JSONObject.toJSONString(params));
|
|
|
|
+ log.info("新增12345渠道工单----参数:" + paramsjson);
|
|
|
|
+ String result_12345 = post(paramsjson, channelAddOrder1);// 注册
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result_12345);
|
|
|
|
+ log.info("新增12345渠道工单----返回值:" + resultJson);
|
|
|
|
+ return resultJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// /**
|
|
|
|
+// * 内网(12345渠道工单进度查询)
|
|
|
|
+// */
|
|
|
|
+ @PostMapping(value = "/selectScheduleQuery12345")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JSONObject selectScheduleQuery12345(@RequestBody String requestBody, HttpServletRequest request) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(requestBody);
|
|
|
|
+
|
|
|
|
+ String MyQueryOrder1 = url12345 + LISTMYAPPEAL;
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ long times = System.currentTimeMillis();
|
|
|
|
+ String timestamp = String.valueOf(times);
|
|
|
|
+ String mySignature = this.getSignature(timestamp);
|
|
|
|
+ params.put("signature", mySignature);// 加密校验串
|
|
|
|
+ params.put("timestamp", timestamp);// 时间戳
|
|
|
|
+ params.put("appid", appid);// 吉林省政务服务热线分配给第三方系统的appid
|
|
|
|
+ params.put("proWoCode", jsonObject.getString("proWoCode"));// 工单编号
|
|
|
|
+ params.put("telNum", jsonObject.getString("telNum"));// 电话号码
|
|
|
|
+ params.put("startNum", jsonObject.getString("startNum"));// 开始条数
|
|
|
|
+ params.put("endNum", jsonObject.getString("endNum"));// 结束条数
|
|
|
|
+
|
|
|
|
+ JSONObject paramsjson = JSONObject.parseObject(JSONObject.toJSONString(params));
|
|
|
|
+ log.info("渠道工单进度查询----参数:" + paramsjson);
|
|
|
|
+ String result_12345 = post(paramsjson, MyQueryOrder1);// 注册
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result_12345);
|
|
|
|
+ log.info("渠道工单进度查询----返回值:" + resultJson);
|
|
|
|
+ return resultJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// /**
|
|
|
|
+// * 内网(12345案例公开查询)
|
|
|
|
+// */
|
|
|
|
+ @PostMapping(value = "/selectAlgk12345")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JSONObject selectAlgk12345(@RequestBody String requestBody, HttpServletRequest request) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(requestBody);
|
|
|
|
+
|
|
|
|
+ String queryPublicOrde1 = url12345 + QUERYPUBLICORDE;
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ long times = System.currentTimeMillis();
|
|
|
|
+ String timestamp = String.valueOf(times);
|
|
|
|
+ String mySignature = this.getSignature(timestamp);
|
|
|
|
+ params.put("signature", mySignature);// 加密校验串
|
|
|
|
+ params.put("timestamp", timestamp);// 时间戳
|
|
|
|
+ params.put("appid", appid);// 吉林省政务服务热线分配给第三方系统的appid
|
|
|
|
+ params.put("proWoCode", jsonObject.getString("proWoCode"));// 工单编号
|
|
|
|
+ params.put("startNum", jsonObject.getString("startNum"));// 开始条数
|
|
|
|
+ params.put("endNum", jsonObject.getString("endNum"));// 结束条数
|
|
|
|
+
|
|
|
|
+ JSONObject paramsjson = JSONObject.parseObject(JSONObject.toJSONString(params));
|
|
|
|
+ log.info("12345案例公开查询---参数:" + paramsjson);
|
|
|
|
+ String result_12345 = post(paramsjson, queryPublicOrde1);// 注册
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result_12345);
|
|
|
|
+ log.info("12345案例公开查询---返回值:" + resultJson);
|
|
|
|
+ return resultJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// /**
|
|
|
|
+// * 内网(12345单个工单查询)
|
|
|
|
+// */
|
|
|
|
+ @PostMapping(value = "/singleQueryOrder12345")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JSONObject singleQueryOrder12345(@RequestBody String requestBody, HttpServletRequest request) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(requestBody);
|
|
|
|
+
|
|
|
|
+ String singleQueryOrder1 = url12345 + SINGLEQUERYORDER;
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ long times = System.currentTimeMillis();
|
|
|
|
+ String timestamp = String.valueOf(times);
|
|
|
|
+ String mySignature = this.getSignature(timestamp);
|
|
|
|
+ params.put("signature", mySignature);// 加密校验串
|
|
|
|
+ params.put("timestamp", timestamp);// 时间戳
|
|
|
|
+ params.put("appid", appid);// 吉林省政务服务热线分配给第三方系统的appid
|
|
|
|
+ params.put("proWoCode", jsonObject.getString("proWoCode"));// 工单编号
|
|
|
|
+ params.put("telNum",jsonObject.getString("telNum"));//电话号码
|
|
|
|
+
|
|
|
|
+ JSONObject paramsjson = JSONObject.parseObject(JSONObject.toJSONString(params));
|
|
|
|
+ log.info("12345单个工单查询---参数:" + paramsjson);
|
|
|
|
+ String result_12345 = post(paramsjson, singleQueryOrder1);// 注册
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result_12345);
|
|
|
|
+// log.info("12345单个工单查询---返回值:" + resultJson);
|
|
|
|
+// String filePath = resultJson.get("filePath").toString();
|
|
|
|
+// log.info("12345单个工单查询---filePath:" + url12345 + filePath);
|
|
|
|
+
|
|
|
|
+ return resultJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public HttpServletResponse download(String path, HttpServletResponse response) {
|
|
|
|
+ try {
|
|
|
|
+ // path是指欲下载的文件的路径。
|
|
|
|
+ File file = new File(path);
|
|
|
|
+ // 取得文件名。
|
|
|
|
+ String filename = file.getName();
|
|
|
|
+ // 取得文件的后缀名。
|
|
|
|
+ String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase();
|
|
|
|
+ // 以流的形式下载文件。
|
|
|
|
+ InputStream fis = new BufferedInputStream(new FileInputStream(path));
|
|
|
|
+ byte[] buffer = new byte[fis.available()];
|
|
|
|
+ fis.read(buffer);
|
|
|
|
+ fis.close();
|
|
|
|
+ // 清空response
|
|
|
|
+ response.reset();
|
|
|
|
+ // 设置response的Header
|
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes()));
|
|
|
|
+ response.addHeader("Content-Length", "" + file.length());
|
|
|
|
+ OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
|
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
|
+ toClient.write(buffer);
|
|
|
|
+ toClient.flush();
|
|
|
|
+ toClient.close();
|
|
|
|
+ } catch (IOException ex) {
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// /**
|
|
|
|
+// * 内网(12345提交评价接口)
|
|
|
|
+// */
|
|
|
|
+ @PostMapping(value = "/submitAppraise12345")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JSONObject submitAppraise12345(@RequestBody String requestBody, HttpServletRequest request) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(requestBody);
|
|
|
|
+
|
|
|
|
+ String submitAppraise1 = url12345 + SUBMITAPPRAISE;
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ long times = System.currentTimeMillis();
|
|
|
|
+ String timestamp = String.valueOf(times);
|
|
|
|
+ String mySignature = this.getSignature(timestamp);
|
|
|
|
+ params.put("signature", mySignature);// 加密校验串
|
|
|
|
+ params.put("timestamp", timestamp);// 时间戳
|
|
|
|
+ params.put("appid", appid);// 吉林省政务服务热线分配给第三方系统的appid
|
|
|
|
+ params.put("proWoCode", jsonObject.getString("proWoCode"));// 工单编号
|
|
|
|
+ params.put("appraisesatisfy", jsonObject.getString("appraisesatisfy"));// 评价满意度
|
|
|
|
+ params.put("appraiseTime", jsonObject.getString("appraiseTime"));// 评价时间
|
|
|
|
+ JSONObject paramsjson = JSONObject.parseObject(JSONObject.toJSONString(params));
|
|
|
|
+ log.info("12345提交评价接口---参数:" + paramsjson);
|
|
|
|
+ String result_12345 = post(paramsjson, submitAppraise1);// 注册
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result_12345);
|
|
|
|
+ log.info("12345提交评价接口---返回值:" + resultJson);
|
|
|
|
+ return resultJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// /**
|
|
|
|
+// * 12345内网
|
|
|
|
+// */
|
|
|
|
+ public static String post(JSONObject json, String url) {
|
|
|
|
+
|
|
|
|
+ HttpClient client = new DefaultHttpClient();
|
|
|
|
+ HttpPost post = new HttpPost(url);
|
|
|
|
+ post.setHeader("Content-Type", "application/json");
|
|
|
|
+ post.addHeader("Authorization", "Basic YWRtaW46");
|
|
|
|
+ String result = "";
|
|
|
|
+ try {
|
|
|
|
+ StringEntity s = new StringEntity(json.toString(), "utf-8");
|
|
|
|
+ s.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
|
|
|
+ post.setEntity(s);
|
|
|
|
+ // 发送请求
|
|
|
|
+ HttpResponse httpResponse = client.execute(post);
|
|
|
|
+ // 获取响应输入流
|
|
|
|
+ InputStream inStream = httpResponse.getEntity().getContent();
|
|
|
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "utf-8"));
|
|
|
|
+ StringBuilder strber = new StringBuilder();
|
|
|
|
+ String line = null;
|
|
|
|
+ while ((line = reader.readLine()) != null)
|
|
|
|
+ strber.append(line + "\n");
|
|
|
|
+ inStream.close();
|
|
|
|
+ result = strber.toString();
|
|
|
|
+ if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
|
|
|
+ log.info(url + "请求服务器成功");
|
|
|
|
+ } else {
|
|
|
|
+ log.info(url + "请求服务端失败");
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.info(url + "请求异常" + e.getMessage());
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 8.13查询下单量和公开量
|
|
|
|
+ * @param requestBody
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @PostMapping(value = "/getOrderCount")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public JSONObject getOrderCount(@RequestBody String requestBody, HttpServletRequest request) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(requestBody);
|
|
|
|
+ String submitAppraise1 = url12345 + GETORDERCOUNT;
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ long times = System.currentTimeMillis();
|
|
|
|
+ String timestamp = String.valueOf(times);
|
|
|
|
+ String mySignature = this.getSignature(timestamp);
|
|
|
|
+ params.put("signature", mySignature);// 加密校验串
|
|
|
|
+ params.put("timestamp", timestamp);// 时间戳
|
|
|
|
+ params.put("appid", appid);// 吉林省政务服务热线分配给第三方系统的appid
|
|
|
|
+ params.put("callType", "1");// 评价满意度
|
|
|
|
+ JSONObject paramsjson = JSONObject.parseObject(JSONObject.toJSONString(params));
|
|
|
|
+ log.info("下单量和公开量---参数:" + paramsjson);
|
|
|
|
+ String result_12345 = post(paramsjson, submitAppraise1);// 注册
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result_12345);
|
|
|
|
+ log.info("下单量和公开量---返回值:" + resultJson);
|
|
|
|
+ return resultJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/test")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public String test() {
|
|
|
|
+ log.info("===========测试");
|
|
|
|
+ return "test";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|