ws183
2025-04-28 b306d1106b915bb13fd7a02217ae9c65de2fd03d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.ld.igds.protocol.grainplug;
 
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
 
/**
 * 本地插件--粮情接收入口
 *
 * @author chen
 */
@Slf4j
@Controller
@RequestMapping("grain")
public class GrainPlugServer {
 
 
   @Autowired
   private GrainPlugAnalysis grainPlugAnalysis;
 
    @ResponseBody
    @RequestMapping("/v1")
    public String grainReceive(@RequestBody JSONObject request){
 
        log.info("粮情插件----->>>平台:报文信息={}", request);
 
        try{
 
            //异步处理,子线程解析事件
            final ExecutorService exec = Executors.newFixedThreadPool(1);
            Callable<String> call = new Callable<String>() {
                public String call(){
 
                    //解析粮情数据
                    return grainPlugAnalysis.analysisGrain(request);
                }
            };
            exec.submit(call);
            exec.shutdown();
            return "SUCCESS";
 
        }catch (Exception e){
 
            log.error("----粮情数据解析失败,原因={}-----", e.getLocalizedMessage());
            return "SUCCESS";
        }
    }
 
}