You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.4 KiB
68 lines
2.4 KiB
|
9 months ago
|
package com.hxjt.dataupload.jobhandler.doubleprevent;
|
||
|
|
|
||
|
|
import com.alibaba.fastjson.JSONObject;
|
||
|
|
import com.hxjt.dataupload.model.entity.doubleprevent.Fxfxdx;
|
||
|
|
import com.hxjt.dataupload.model.entity.doubleprevent.Fxfxdy;
|
||
|
|
import com.hxjt.dataupload.model.entity.doubleprevent.Fxsj;
|
||
|
|
import com.hxjt.dataupload.service.FxfxdxService;
|
||
|
|
import com.hxjt.dataupload.utils.HttpUtils;
|
||
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
||
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||
|
|
import org.apache.http.protocol.HTTP;
|
||
|
|
import org.slf4j.Logger;
|
||
|
|
import org.slf4j.LoggerFactory;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
import java.io.IOException;
|
||
|
|
import java.util.ArrayList;
|
||
|
|
|
||
|
|
|
||
|
|
@Component
|
||
|
|
public class FxsjJobHandler {
|
||
|
|
|
||
|
|
private Logger log = LoggerFactory.getLogger(FxsjJobHandler.class);
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
FxfxdxService fxfxdxService;
|
||
|
|
|
||
|
|
@XxlJob(value = "FxsjJobHandler", init = "init", destroy = "destroy")
|
||
|
|
public void execute(String param) {
|
||
|
|
|
||
|
|
ArrayList<Fxsj> fxsjs = fxfxdxService.getFxsjs();
|
||
|
|
|
||
|
|
for (int i = 0; i < fxsjs.size(); i++) {
|
||
|
|
|
||
|
|
String company = fxsjs.get(i).getQiyemingcheng();
|
||
|
|
String url = "https://www.ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/fengxianshijianxinxi/v1/fengxianshijianxinxi";
|
||
|
|
switch (company) {
|
||
|
|
case "山东恒信高科能源有限公司":
|
||
|
|
case "恒信中碳氢能源科技(山东)有限公司":
|
||
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(fxsjs.get(i));
|
||
|
|
String post = null;
|
||
|
|
try {
|
||
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "GGUIPRh5bemgUmX8bvyn76E2ACA7DEE82AB4");
|
||
|
|
//System.out.println("post:"+post.toString());
|
||
|
|
XxlJobHelper.log("执行日志:"+company+post.toString());
|
||
|
|
} catch (IOException e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
XxlJobHelper.handleFail("任务执行失败"+e.getMessage());
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
//System.out.println("post:"+post1.toString());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private void init() {
|
||
|
|
log.info("init 方法调用成功");
|
||
|
|
}
|
||
|
|
|
||
|
|
private void destroy() {
|
||
|
|
log.info("destroy 方法调用成功");
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|