Administrator 2 years ago
parent
commit
893813fd01

+ 81 - 71
boman-web-core/src/main/java/com/boman/web/core/service/TaskService.java

@@ -780,7 +780,7 @@ public class TaskService {
 
 
 
 
     //统计镇数据(暂时用)
     //统计镇数据(暂时用)
-    public AjaxResult zhenDate(String startTime,String endTime) {
+    public AjaxResult zhenDate(String startTime, String endTime) {
 
 
         long start2 = System.currentTimeMillis();
         long start2 = System.currentTimeMillis();
 
 
@@ -803,12 +803,12 @@ public class TaskService {
             JSONObject townsResult = new JSONObject(16);
             JSONObject townsResult = new JSONObject(16);
             //查询镇数据
             //查询镇数据
             //户籍人员数据
             //户籍人员数据
-            int hjz = accountingDataService.tongjiHjZ(startTime,endTime,townsDept.getAreaId());
+            int hjz = accountingDataService.tongjiHjZ(startTime, endTime, townsDept.getAreaId());
             //常住人员数据
             //常住人员数据
-            int czz = accountingDataService.tongjiCzZ(startTime,endTime,townsDept.getAreaId());
-            townsResult.put("name",townsDept.getDeptName());
-            townsResult.put("hjz",hjz);
-            townsResult.put("czz",czz);
+            int czz = accountingDataService.tongjiCzZ(startTime, endTime, townsDept.getAreaId());
+            townsResult.put("name", townsDept.getDeptName());
+            townsResult.put("hjz", hjz);
+            townsResult.put("czz", czz);
             towsDataList.add(townsResult);
             towsDataList.add(townsResult);
         }
         }
         long end2 = System.currentTimeMillis();
         long end2 = System.currentTimeMillis();
@@ -817,7 +817,7 @@ public class TaskService {
     }
     }
 
 
     //统计镇,村数据(暂时用)
     //统计镇,村数据(暂时用)
-    public AjaxResult cunDate(String startTime,String endTime) {
+    public AjaxResult cunDate(String startTime, String endTime) {
 
 
         long start2 = System.currentTimeMillis();
         long start2 = System.currentTimeMillis();
 
 
@@ -840,12 +840,12 @@ public class TaskService {
             JSONObject townsResult = new JSONObject(16);
             JSONObject townsResult = new JSONObject(16);
             //查询镇数据
             //查询镇数据
             //户籍人员数据
             //户籍人员数据
-            int hjz = accountingDataService.tongjiHjZ(startTime,endTime,townsDept.getAreaId());
+            int hjz = accountingDataService.tongjiHjZ(startTime, endTime, townsDept.getAreaId());
             //常住人员数据
             //常住人员数据
-            int czz = accountingDataService.tongjiCzZ(startTime,endTime,townsDept.getAreaId());
-            townsResult.put("name",townsDept.getDeptName());
-            townsResult.put("hjz",hjz);
-            townsResult.put("czz",czz);
+            int czz = accountingDataService.tongjiCzZ(startTime, endTime, townsDept.getAreaId());
+            townsResult.put("name", townsDept.getDeptName());
+            townsResult.put("hjz", hjz);
+            townsResult.put("czz", czz);
             //获取镇下面的村数据
             //获取镇下面的村数据
             List<SysDept> cunDepts = new ArrayList<>(16);
             List<SysDept> cunDepts = new ArrayList<>(16);
 
 
@@ -863,15 +863,15 @@ public class TaskService {
                 JSONObject cunResult = new JSONObject(16);
                 JSONObject cunResult = new JSONObject(16);
                 //查询村数据
                 //查询村数据
                 //户籍人员数据
                 //户籍人员数据
-                int hjc = accountingDataMapper.tongjiHjC(startTime,endTime,cunDept.getAreaId());
+                int hjc = accountingDataMapper.tongjiHjC(startTime, endTime, cunDept.getAreaId());
                 //常住人员数据
                 //常住人员数据
-                int czc = accountingDataMapper.tongjiCzC(startTime,endTime,cunDept.getAreaId());
-                cunResult.put("name",cunDept.getDeptName());
-                cunResult.put("hjc",hjc);
-                cunResult.put("czc",czc);
+                int czc = accountingDataMapper.tongjiCzC(startTime, endTime, cunDept.getAreaId());
+                cunResult.put("name", cunDept.getDeptName());
+                cunResult.put("hjc", hjc);
+                cunResult.put("czc", czc);
                 cunDataList.add(cunResult);
                 cunDataList.add(cunResult);
             }
             }
-            townsResult.put("cunDataList",cunDataList);
+            townsResult.put("cunDataList", cunDataList);
             towsDataList.add(townsResult);
             towsDataList.add(townsResult);
         }
         }
         long end2 = System.currentTimeMillis();
         long end2 = System.currentTimeMillis();
@@ -1068,43 +1068,43 @@ public class TaskService {
             }
             }
             int result = mapper.selectById(accountingData);
             int result = mapper.selectById(accountingData);
             if (result == 0) {
             if (result == 0) {
-                if(accountingData.getCjssxq().contains("梅城镇")){
+                if (accountingData.getCjssxq().contains("梅城镇")) {
                     accountingData.setCjqxqh("340882100000");
                     accountingData.setCjqxqh("340882100000");
-                }else if(accountingData.getCjssxq().contains("源潭镇")){
+                } else if (accountingData.getCjssxq().contains("源潭镇")) {
                     accountingData.setCjqxqh("340882101000");
                     accountingData.setCjqxqh("340882101000");
-                }else if(accountingData.getCjssxq().contains("黄铺镇")){
+                } else if (accountingData.getCjssxq().contains("黄铺镇")) {
                     accountingData.setCjqxqh("340882104000");
                     accountingData.setCjqxqh("340882104000");
-                }else if(accountingData.getCjssxq().contains("王河镇")){
+                } else if (accountingData.getCjssxq().contains("王河镇")) {
                     accountingData.setCjqxqh("340882103000");
                     accountingData.setCjqxqh("340882103000");
-                }else if(accountingData.getCjssxq().contains("余井镇")){
+                } else if (accountingData.getCjssxq().contains("余井镇")) {
                     accountingData.setCjqxqh("340882102000");
                     accountingData.setCjqxqh("340882102000");
-                }else if(accountingData.getCjssxq().contains("官庄镇")){
+                } else if (accountingData.getCjssxq().contains("官庄镇")) {
                     accountingData.setCjqxqh("340882107000");
                     accountingData.setCjqxqh("340882107000");
-                }else if(accountingData.getCjssxq().contains("槎水镇")){
+                } else if (accountingData.getCjssxq().contains("槎水镇")) {
                     accountingData.setCjqxqh("340882105000");
                     accountingData.setCjqxqh("340882105000");
-                }else if(accountingData.getCjssxq().contains("水吼镇")){
+                } else if (accountingData.getCjssxq().contains("水吼镇")) {
                     accountingData.setCjqxqh("340882106000");
                     accountingData.setCjqxqh("340882106000");
-                }else if(accountingData.getCjssxq().contains("塔畈乡")){
+                } else if (accountingData.getCjssxq().contains("塔畈乡")) {
                     accountingData.setCjqxqh("340882200000");
                     accountingData.setCjqxqh("340882200000");
-                }else if(accountingData.getCjssxq().contains("油坝乡")){
+                } else if (accountingData.getCjssxq().contains("油坝乡")) {
                     accountingData.setCjqxqh("340882201000");
                     accountingData.setCjqxqh("340882201000");
-                }else if(accountingData.getCjssxq().contains("黄泥镇")){
+                } else if (accountingData.getCjssxq().contains("黄泥镇")) {
                     accountingData.setCjqxqh("340882108000");
                     accountingData.setCjqxqh("340882108000");
-                }else if(accountingData.getCjssxq().contains("天柱山镇")){
+                } else if (accountingData.getCjssxq().contains("天柱山镇")) {
                     accountingData.setCjqxqh("340882110000");
                     accountingData.setCjqxqh("340882110000");
-                }else if(accountingData.getCjssxq().contains("龙潭乡")){
+                } else if (accountingData.getCjssxq().contains("龙潭乡")) {
                     accountingData.setCjqxqh("340882202000");
                     accountingData.setCjqxqh("340882202000");
-                }else if(accountingData.getCjssxq().contains("黄柏镇")){
+                } else if (accountingData.getCjssxq().contains("黄柏镇")) {
                     accountingData.setCjqxqh("340882109000");
                     accountingData.setCjqxqh("340882109000");
-                }else if(accountingData.getCjssxq().contains("痘姆乡")){
+                } else if (accountingData.getCjssxq().contains("痘姆乡")) {
                     accountingData.setCjqxqh("340882203000");
                     accountingData.setCjqxqh("340882203000");
-                }else if(accountingData.getCjssxq().contains("五庙乡")){
+                } else if (accountingData.getCjssxq().contains("五庙乡")) {
                     accountingData.setCjqxqh("340882204000");
                     accountingData.setCjqxqh("340882204000");
-                }else if(accountingData.getCjssxq().contains("开发区")){
+                } else if (accountingData.getCjssxq().contains("开发区")) {
                     accountingData.setCjqxqh("340882400000");
                     accountingData.setCjqxqh("340882400000");
-                }else if(accountingData.getCjssxq().contains("lis")){
+                } else if (accountingData.getCjssxq().contains("lis")) {
                     accountingData.setCjqxqh("123456789");
                     accountingData.setCjqxqh("123456789");
-                }else{
+                } else {
                     accountingData.setCjqxqh("340882000000");
                     accountingData.setCjqxqh("340882000000");
                 }
                 }
                 accountingData.setId(IdUtils.simpleUUID());
                 accountingData.setId(IdUtils.simpleUUID());
@@ -1133,18 +1133,18 @@ public class TaskService {
 
 
             //String startTime = redisService.getCacheObject("toQianShanStartTime");
             //String startTime = redisService.getCacheObject("toQianShanStartTime");
             //if (StringUtils.isEmpty(startTime)) {
             //if (StringUtils.isEmpty(startTime)) {
-                //startTime = "2022-05-14 00:00:00";
+            //startTime = "2022-05-14 00:00:00";
             //}
             //}
 
 
             //数据库查询最新数据
             //数据库查询最新数据
             ToQianshanPersonner toQianshanPersonner = toQianshanPersonnerService.getNewInfo();
             ToQianshanPersonner toQianshanPersonner = toQianshanPersonnerService.getNewInfo();
             String startTime = "2022-05-1 00:00:00";
             String startTime = "2022-05-1 00:00:00";
-            if(toQianshanPersonner != null){
+            if (toQianshanPersonner != null) {
                 startTime = toQianshanPersonner.getHiDate();
                 startTime = toQianshanPersonner.getHiDate();
             }
             }
 
 
             SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date date =df.parse(startTime);
+            Date date = df.parse(startTime);
             date.setTime(date.getTime() + 1000);
             date.setTime(date.getTime() + 1000);
             startTime = df.format(date);
             startTime = df.format(date);
 
 
@@ -1183,7 +1183,7 @@ public class TaskService {
 
 
     public String test() {
     public String test() {
         Long gjzwfwpt_rtime = new Date().getTime();
         Long gjzwfwpt_rtime = new Date().getTime();
-        System.out.println("时间戳------"+gjzwfwpt_rtime);
+        System.out.println("时间戳------" + gjzwfwpt_rtime);
         String gjzwfwpt_rid = "TE3400003400000001@f6eae674bdc840d2b0474dd3d736faf1";
         String gjzwfwpt_rid = "TE3400003400000001@f6eae674bdc840d2b0474dd3d736faf1";
         String gjzwfwpt_sid = "s_X01201000200000000_4817";
         String gjzwfwpt_sid = "s_X01201000200000000_4817";
 
 
@@ -1191,87 +1191,97 @@ public class TaskService {
         sb.append(gjzwfwpt_sid).append(gjzwfwpt_rid).append(String.valueOf(gjzwfwpt_rtime));
         sb.append(gjzwfwpt_sid).append(gjzwfwpt_rid).append(String.valueOf(gjzwfwpt_rtime));
 
 
         // System.out.println(sign(sid+rid+rtime,"90f27130802db6f63edb783831bf5aff"));
         // System.out.println(sign(sid+rid+rtime,"90f27130802db6f63edb783831bf5aff"));
-        System.out.println("加密------"+AESUtil.sign(sb.toString(),"e72f935d839db74e407ca9fa13cc78b7"));
+        System.out.println("加密------" + AESUtil.sign(sb.toString(), "e72f935d839db74e407ca9fa13cc78b7"));
 
 
-        String gjzwfwpt_sign = AESUtil.sign(sb.toString(),"e72f935d839db74e407ca9fa13cc78b7");
+        String gjzwfwpt_sign = AESUtil.sign(sb.toString(), "e72f935d839db74e407ca9fa13cc78b7");
 
 
         JSONObject paramMap = new JSONObject();
         JSONObject paramMap = new JSONObject();
-        paramMap.put("gjzwfwpt_rid",gjzwfwpt_rid);
-        paramMap.put("gjzwfwpt_sid",gjzwfwpt_sid);
-        paramMap.put("gjzwfwpt_rtime",String.valueOf(gjzwfwpt_rtime));
-        paramMap.put("gjzwfwpt_sign",gjzwfwpt_sign);
+        paramMap.put("gjzwfwpt_rid", gjzwfwpt_rid);
+        paramMap.put("gjzwfwpt_sid", gjzwfwpt_sid);
+        paramMap.put("gjzwfwpt_rtime", String.valueOf(gjzwfwpt_rtime));
+        paramMap.put("gjzwfwpt_sign", gjzwfwpt_sign);
         String http = "http://59.255.22.70:8443/authz/authSystem/getAppSecret";
         String http = "http://59.255.22.70:8443/authz/authSystem/getAppSecret";
         BufferedReader in = null;
         BufferedReader in = null;
         String response = "";
         String response = "";
         try {
         try {
-            String data = HttpClientUtils.send(http, paramMap,"utf-8");
-            System.out.println("/authSystem/getAppSecret返回值------"+data);
+            String data = HttpClientUtils.send(http, paramMap, "utf-8");
+            System.out.println("/authSystem/getAppSecret返回值------" + data);
             JSONObject jsonObject = JSONObject.parseObject(data);
             JSONObject jsonObject = JSONObject.parseObject(data);
-            Map<String,Object> map = (Map<String, Object>) jsonObject.get("data");
-            System.out.println("secret------"+(String) map.get("secret"));
+            Map<String, Object> map = (Map<String, Object>) jsonObject.get("data");
+            System.out.println("secret------" + (String) map.get("secret"));
             //秘钥 24小时有效
             //秘钥 24小时有效
             String appsecret = AESUtil.AESDncode("e72f935d839db74e407ca9fa13cc78b7", (String) map.get("secret"));
             String appsecret = AESUtil.AESDncode("e72f935d839db74e407ca9fa13cc78b7", (String) map.get("secret"));
-            System.out.println("解密------"+appsecret);
+            System.out.println("解密------" + appsecret);
             //根据秘钥获得最终签名
             //根据秘钥获得最终签名
-             gjzwfwpt_sign = AESUtil.sign(sb.toString(),appsecret);
+            gjzwfwpt_sign = AESUtil.sign(sb.toString(), appsecret);
 
 
             //请求url
             //请求url
             URL postUrl = new URL("http://59.255.22.70:8443/gateway/wsproxy");
             URL postUrl = new URL("http://59.255.22.70:8443/gateway/wsproxy");
             //请求参数map
             //请求参数map
-            Map<String,String>  postParams = new HashMap<String,String>();
+            Map<String, String> postParams = new HashMap<String, String>();
             //组装参数
             //组装参数
             //公共请求参数
             //公共请求参数
             postParams.put("access_key", "TE3400003400000001@f6eae674bdc840d2b0474dd3d736faf1");
             postParams.put("access_key", "TE3400003400000001@f6eae674bdc840d2b0474dd3d736faf1");
-            postParams.put("format","json");
-            postParams.put("request_id","");
+            postParams.put("format", "json");
+            postParams.put("request_id", "");
             postParams.put("sign", gjzwfwpt_sign);
             postParams.put("sign", gjzwfwpt_sign);
-            postParams.put("timestamp",String.valueOf(gjzwfwpt_rtime));
-            postParams.put("version","1.0");
+            postParams.put("timestamp", String.valueOf(gjzwfwpt_rtime));
+            postParams.put("version", "1.0");
             //请求查询条件参数
             //请求查询条件参数
-            Map<String,String> params = new HashMap<String, String>();
+            Map<String, String> params = new HashMap<String, String>();
             params.put("cert_num_man", "340826199601121171");
             params.put("cert_num_man", "340826199601121171");
             params.put("name_man", "叶飞翔");
             params.put("name_man", "叶飞翔");
             StringBuilder biz_content = new StringBuilder("{");
             StringBuilder biz_content = new StringBuilder("{");
-            for(String key : params.keySet()){
+            for (String key : params.keySet()) {
                 String value = params.get(key);
                 String value = params.get(key);
-                biz_content.append("\""+key+"\""+":"+"\""+value+"\",");
+                biz_content.append("\"" + key + "\"" + ":" + "\"" + value + "\",");
             }
             }
             biz_content.deleteCharAt(biz_content.length() - 1);
             biz_content.deleteCharAt(biz_content.length() - 1);
             biz_content.append("}");
             biz_content.append("}");
             postParams.put("biz_content", biz_content.toString());
             postParams.put("biz_content", biz_content.toString());
             StringBuilder postData = new StringBuilder();
             StringBuilder postData = new StringBuilder();
-            for (Map.Entry<String,String> param : postParams.entrySet()) {
-                if (postData.length() != 0){
+            for (Map.Entry<String, String> param : postParams.entrySet()) {
+                if (postData.length() != 0) {
                     postData.append('&');
                     postData.append('&');
                 }
                 }
                 postData.append(param.getKey());
                 postData.append(param.getKey());
                 postData.append("=");
                 postData.append("=");
                 postData.append(param.getValue());
                 postData.append(param.getValue());
             }
             }
-            System.out.println("http://59.255.22.70:8443/gateway/wsproxy参数"+postData.toString());
+            System.out.println("http://59.255.22.70:8443/gateway/wsproxy参数" + postData.toString());
             byte[] postDataBytes = postData.toString().getBytes(StandardCharsets.UTF_8);
             byte[] postDataBytes = postData.toString().getBytes(StandardCharsets.UTF_8);
-            HttpURLConnection conn = (HttpURLConnection)postUrl.openConnection();
+            HttpURLConnection conn = (HttpURLConnection) postUrl.openConnection();
             conn.setDoOutput(true);
             conn.setDoOutput(true);
             conn.setDoInput(true);
             conn.setDoInput(true);
             conn.setRequestMethod("POST");
             conn.setRequestMethod("POST");
             conn.setRequestProperty("connection", "Keep-Alive");
             conn.setRequestProperty("connection", "Keep-Alive");
             conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
             conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
-            conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
-            conn.setRequestProperty("Content-Length",String.valueOf(postDataBytes.length));
+            conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+            conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
             conn.connect();
             conn.connect();
             OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "utf-8");
             OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "utf-8");
             out.write(postData.toString());
             out.write(postData.toString());
             // flush输出流的缓冲
             // flush输出流的缓冲
             out.flush();
             out.flush();
             // 定义BufferedReader输入流来读取URL的响应
             // 定义BufferedReader输入流来读取URL的响应
-             in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
+            int responseCode = conn.getResponseCode();
+            System.out.println("状态码:" + responseCode);
+            InputStreamReader raw = null;
+            if (responseCode == 200) {
+                InputStream is = conn.getInputStream();
+                raw = new InputStreamReader(is, StandardCharsets.UTF_8);
+            } else {
+                InputStream errorStream = conn.getErrorStream();
+                raw = new InputStreamReader(errorStream, StandardCharsets.UTF_8);
+            }
+            in = new BufferedReader(raw);
             StringBuilder sb1 = new StringBuilder();
             StringBuilder sb1 = new StringBuilder();
-            for (int c; (c = in.read()) >= 0;){
-                sb1.append((char)c);
+            for (int c; (c = in.read()) >= 0; ) {
+                sb1.append((char) c);
             }
             }
             //获取查询结果,结果示例见第5条,
             //获取查询结果,结果示例见第5条,
             response = sb1.toString();
             response = sb1.toString();
-            System.out.println("结果------"+response);
+            System.out.println("结果------" + response);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             return null;
             return null;