|
@@ -1,12 +1,6 @@
|
|
|
package com.fjhx.rocketmq.consumer;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.quake.quake_qinxin.core.util.*;
|
|
|
-import com.quake.quake_qinxin.model.ESPContent;
|
|
|
-import com.quake.quake_qinxin.model.ESPList;
|
|
|
-import com.quake.quake_qinxin.model.SqlServerParam;
|
|
|
-import com.quake.quake_qinxin.service.IRocketmqMessageService;
|
|
|
-import net.sf.json.JSONArray;
|
|
|
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
|
|
|
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
|
|
|
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
|
|
@@ -27,9 +21,6 @@ import java.util.List;
|
|
|
@Component
|
|
|
public class ConsumerServiceERP {
|
|
|
|
|
|
- @Autowired
|
|
|
- private IRocketmqMessageService service;
|
|
|
-
|
|
|
private DefaultMQPushConsumer consumer;
|
|
|
|
|
|
private String consumerGroup = "rocketmq_test_group_official_erp";
|
|
@@ -54,63 +45,6 @@ public class ConsumerServiceERP {
|
|
|
System.out.println("消费erp数据" + str);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(str);
|
|
|
String whodoesp = jsonObject.get("whodoesp").toString();
|
|
|
- String receiveGroup = jsonObject.get("receiveGroup").toString();
|
|
|
- JSONArray contentArray = JSONArray.fromObject(jsonObject.get("content"));
|
|
|
- JSONArray listArray = JSONArray.fromObject(jsonObject.get("doList"));
|
|
|
- ESPContent content = new ESPContent();
|
|
|
- String uuid = UUIDUtil.getNum19();
|
|
|
- for (int i = 0; i < listArray.size(); i++) {
|
|
|
- List<List<ESPContent>> lists = StringUtil.groupList(contentArray);
|
|
|
- System.out.println(lists);
|
|
|
- ESPList espList = JSON.parseObject(listArray.get(i).toString(), ESPList.class);
|
|
|
- for(List<ESPContent> espContents:lists){
|
|
|
- System.out.println(getType(espContents));
|
|
|
- try {
|
|
|
- WebsocketUtil.webSocketSendMessageByUsername(espList.getEspId(),StringUtil.toErsStr(whodoesp+"&"+uuid,espList, content, "start+"+receiveGroup));
|
|
|
-
|
|
|
- }catch (Exception e){
|
|
|
- System.out.println("websocket服务出现错误");
|
|
|
- EmailUtil.sendEmail("1164636026@qq.com","websocket服务出现错误,异常信息为:"+e);
|
|
|
- EmailUtil.sendEmail("504178754@qq.com","websocket服务出现错误,异常信息为:"+e);
|
|
|
- }
|
|
|
- for (int j = 0; j < espContents.size(); j++) {
|
|
|
- net.sf.json.JSONObject sfObject = net.sf.json.JSONObject.fromObject(espContents.get(j));
|
|
|
- ESPContent espContent = (ESPContent) net.sf.json.JSONObject.toBean(sfObject, ESPContent.class);
|
|
|
- String param = StringUtil.toErsStr(whodoesp+"&"+uuid,espList, espContent, "");
|
|
|
- String result = WebsocketUtil.webSocketSendMessageByUsername(espList.getEspId(),param);
|
|
|
-
|
|
|
- System.out.println("websocket监听发送成功与否:"+result+param);
|
|
|
- SqlServerParam p = SqlServerUtil.sqlServerParamStart(espContent,whodoesp,espList,uuid);
|
|
|
- try {
|
|
|
- SqlServerUtil.sqlServerSaveLog(JSON.toJSONString(p));
|
|
|
- }catch (Exception e){
|
|
|
- System.out.println("sqlServer服务出现错误");
|
|
|
- EmailUtil.sendEmail("1164636026@qq.com","sqlServer服务出现错误,异常信息为:"+e);
|
|
|
- EmailUtil.sendEmail("504178754@qq.com","sqlServer服务出现错误,异常信息为:"+e);
|
|
|
- }
|
|
|
- Thread.sleep(150);
|
|
|
- }
|
|
|
- WebsocketUtil.webSocketSendMessageByUsername(espList.getEspId(), StringUtil.toErsStr(whodoesp+"&"+uuid,espList, content, "end"));
|
|
|
-
|
|
|
- Thread.sleep(200);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -120,20 +54,4 @@ public class ConsumerServiceERP {
|
|
|
});
|
|
|
consumer.start();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 获取数据类型
|
|
|
- * @param object
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static String getType(Object object){
|
|
|
- String typeName=object.getClass().getName();
|
|
|
- int length= typeName.lastIndexOf(".");
|
|
|
- String type =typeName.substring(length+1);
|
|
|
- return type;
|
|
|
- }
|
|
|
- public static void main(String[] args) {
|
|
|
- int a = 0;
|
|
|
- System.out.println(getType(a));
|
|
|
- }
|
|
|
}
|