张涛 2 anni fa
parent
commit
023cae6bf8

+ 7
- 0
pom.xml Vedi File

@@ -43,6 +43,13 @@
43 43
             <scope>test</scope>
44 44
         </dependency>
45 45
 
46
+        <!--fastjson start-->
47
+        <dependency>
48
+            <groupId>com.alibaba</groupId>
49
+            <artifactId>fastjson</artifactId>
50
+            <version>1.2.56</version>
51
+        </dependency>
52
+        <!--fastjson end-->
46 53
 
47 54
         <!--oss start-->
48 55
         <dependency>

+ 87
- 0
src/main/java/com/example/civilizedcity/common/HttpUtils.java Vedi File

@@ -0,0 +1,87 @@
1
+//package com.example.civilizedcity.common;
2
+//
3
+//import org.springframework.http.*;
4
+//import org.springframework.stereotype.Component;
5
+//import org.springframework.web.client.RestTemplate;
6
+//
7
+//import java.io.UnsupportedEncodingException;
8
+//import java.net.URLDecoder;
9
+//import java.util.*;
10
+//
11
+//@Component
12
+//public class HttpUtils {
13
+//    public String get(String url) throws Exception {
14
+//        RestTemplate restTemplate = new RestTemplate();
15
+//        HttpHeaders headers = new HttpHeaders();
16
+//        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
17
+//        HttpEntity<String> entity = new HttpEntity<String>(headers);
18
+//
19
+//        Map<String, Object> urlAndParams = parseURL(url);
20
+//        String formatURL = (String) urlAndParams.get("url");
21
+//        Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
22
+//
23
+//        ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.GET, entity, String.class, params);
24
+//        return resp.getBody();
25
+//    }
26
+//
27
+//    public String post(String url, Map<String, String> header, String body) throws Exception {
28
+//        RestTemplate restTemplate = new RestTemplate();
29
+//        HttpHeaders headers = new HttpHeaders();
30
+//        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
31
+//        headers.setContentType(type);
32
+//        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
33
+//        headers.setAll(header);
34
+//        HttpEntity<String> entity = new HttpEntity<String>(body, headers);
35
+//
36
+//        Map<String, Object> urlAndParams = parseURL(url);
37
+//        String formatURL = (String) urlAndParams.get("url");
38
+//        Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
39
+//
40
+//        ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.POST, entity, String.class, params);
41
+//        return resp.getBody();
42
+//    }
43
+//
44
+//    // RestTemplate 不能正常的处理 querystring, 必须按照约定的方式处理
45
+//    private Map<String, Object> parseURL(String url) {
46
+//        Map<String, Object> res = new HashMap<>();
47
+//
48
+//        String[] parts = url.split("\\?");
49
+//        String baseURL = parts[0];
50
+//
51
+//        if (parts.length < 2) {
52
+//            res.put("url", baseURL);
53
+//            res.put("params", new HashMap<>());
54
+//            return res;
55
+//        }
56
+//
57
+//
58
+//        String[] fields = parts[1].split("&");
59
+//        Map<String, String> params = new HashMap<>();
60
+//        List<String> searchList = new ArrayList<>();
61
+//        for (String field : fields) {
62
+//            String[] pairs = field.split("=");
63
+//            if (2 != pairs.length) {
64
+//                continue;
65
+//            }
66
+//
67
+//            try {
68
+//                String key = URLDecoder.decode(pairs[0].trim(), "UTF-8");
69
+//                String val = URLDecoder.decode(pairs[1].trim(), "UTF-8");
70
+//
71
+//                // 转化为 "foo={foo}" 这种字符串
72
+//                searchList.add(String.format("%s={%s}", key, key));
73
+//                // 把 foo 对应的值存储起来
74
+//                params.put(key, val);
75
+//            } catch (UnsupportedEncodingException e) {
76
+//                e.printStackTrace();
77
+//            }
78
+//        }
79
+//
80
+//        // url 格式类似 http://foo.org/bar?name={name}
81
+//        String formatURL = baseURL + "?" + String.join("&", searchList);
82
+//        res.put("url", formatURL);
83
+//        res.put("params", params);
84
+//
85
+//        return res;
86
+//    }
87
+//}

+ 65
- 0
src/main/java/com/example/civilizedcity/common/SMSUtils.java Vedi File

@@ -0,0 +1,65 @@
1
+//package com.example.civilizedcity.common;
2
+//
3
+//import com.alibaba.fastjson.JSONObject;
4
+//import lombok.Data;
5
+//import lombok.experimental.Accessors;
6
+//import lombok.extern.slf4j.Slf4j;
7
+//import org.springframework.beans.factory.InitializingBean;
8
+//import org.springframework.beans.factory.annotation.Autowired;
9
+//import org.springframework.beans.factory.annotation.Value;
10
+//import org.springframework.scheduling.annotation.EnableAsync;
11
+//import org.springframework.scheduling.annotation.EnableScheduling;
12
+//import org.springframework.stereotype.Component;
13
+//
14
+//import java.util.HashMap;
15
+//import java.util.Map;
16
+//
17
+//@Slf4j
18
+//@Component
19
+//@EnableScheduling //开启定时任务
20
+//@EnableAsync  //开启多线程
21
+//public class SMSUtils implements InitializingBean {
22
+//    @Autowired
23
+//    HttpUtils httpUtils;
24
+//    @Value("${yz.sms.api}")
25
+//    String smsAPI;
26
+//
27
+//    @Value("${yz.sms.appid}")
28
+//    String appid;
29
+//
30
+//    //    @Async
31
+////    @Scheduled(cron = "0 30 8 * * ?") //时隔多少秒
32
+//    public void SendMessage(Message message) throws Exception {
33
+//        long nowMills = System.currentTimeMillis();
34
+//        String timestamp = String.valueOf(nowMills);
35
+//        String secret = appid + timestamp;
36
+//
37
+//        Map<String, String> header = new HashMap<>();
38
+//        header.put("x-appid", appid);
39
+//        header.put("x-timestamp", timestamp);
40
+//        header.put("x-sign", EncryptUtils.md5(appid + secret, timestamp));
41
+//
42
+//        Map<String, String> body = new HashMap<>();
43
+//        body.put("PhoneNumbers", message.getTel());
44
+//        body.put("SignName", message.getSign());
45
+//        body.put("TemplateCode", message.getCode());
46
+//        body.put("TemplateParam", message.getContent());
47
+//
48
+//        httpUtils.post(smsAPI, header, JSONObject.toJSONString(body, false));
49
+//
50
+//    }
51
+//
52
+//    @Override
53
+//    public void afterPropertiesSet() throws Exception {
54
+//    }
55
+//
56
+//    @Data
57
+//    @Accessors(chain = true)
58
+//    public static class Message {
59
+//        String code;
60
+//        String tel;
61
+//        String sign;
62
+//        String content;
63
+//    }
64
+//
65
+//}

+ 5
- 1
src/main/java/com/example/civilizedcity/service/impl/TaFeedbackServiceImpl.java Vedi File

@@ -5,9 +5,9 @@ import com.example.civilizedcity.common.Constants;
5 5
 import com.example.civilizedcity.common.StringUtils;
6 6
 import com.example.civilizedcity.entity.*;
7 7
 import com.example.civilizedcity.mapper.*;
8
+import com.example.civilizedcity.service.TaFeedbackService;
8 9
 import org.springframework.beans.factory.annotation.Autowired;
9 10
 import org.springframework.stereotype.Service;
10
-import com.example.civilizedcity.service.TaFeedbackService;
11 11
 import org.springframework.transaction.annotation.Transactional;
12 12
 
13 13
 import java.time.LocalDateTime;
@@ -139,6 +139,10 @@ public class TaFeedbackServiceImpl extends BaseServiceImpl<TaFeedbackMapper, TaF
139 139
             processStatus = Constants.APPLY_REJECT;
140 140
         }
141 141
 
142
+        if (processList.size() == 0) {
143
+            processList = null;
144
+        }
145
+
142 146
         return baseMapper.getPageBy(pg, personId, processList, processStatus);
143 147
     }
144 148
 }