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";
|
}
|
}
|
|
}
|