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.
1464 lines
67 KiB
1464 lines
67 KiB
package com.hxjt.dataupload.controller;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.hxjt.dataupload.mapper.ZypSingleQueryMapper;
|
|
import com.hxjt.dataupload.model.entity.tszy.aqcs.Aqcs;
|
|
import com.hxjt.dataupload.model.entity.tszy.upload.*;
|
|
import com.hxjt.dataupload.service.FxfxdxService;
|
|
import com.hxjt.dataupload.task.AsyncTask;
|
|
import com.hxjt.dataupload.utils.FileUploadUtil;
|
|
import com.hxjt.dataupload.utils.HttpUtils;
|
|
import com.hxjt.dataupload.utils.JingWeiDuConverter;
|
|
import com.hxjt.dataupload.utils.JsonData;
|
|
import com.hxjt.dataupload.utils.tszy.*;
|
|
//import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.http.protocol.HTTP;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
import java.nio.file.StandardCopyOption;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.Future;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/**
|
|
* liwenxuan
|
|
*/
|
|
|
|
@RestController
|
|
@RequestMapping("dataupload/api/v1")
|
|
public class UploadController {
|
|
|
|
@Autowired
|
|
private AsyncTask asyncTask;
|
|
|
|
@Autowired
|
|
private FxfxdxService fxfxdxService;
|
|
|
|
@Autowired
|
|
private ZypSingleQueryMapper zypSingleQueryMapper;
|
|
|
|
|
|
|
|
@RequestMapping("list")
|
|
public Object list(){
|
|
|
|
Map<String,String > map = new HashMap<>();
|
|
map.put("1","asdfdsa");
|
|
map.put("2","S6543465");
|
|
|
|
return map;
|
|
|
|
}
|
|
@GetMapping("async")
|
|
public JsonData testAsync(){
|
|
long begin = System.currentTimeMillis();
|
|
/*asyncTask.task1();
|
|
asyncTask.task2();
|
|
asyncTask.task3();*/
|
|
Future<String> task4 = asyncTask.task4();
|
|
Future<String> task5 = asyncTask.task5();
|
|
for(;;){
|
|
if(task4.isDone() && task5.isDone()){
|
|
try {
|
|
String task4Result = task4.get();
|
|
System.out.println(task4Result);
|
|
|
|
String task5Result = task5.get();
|
|
System.out.println(task5Result);
|
|
|
|
|
|
}catch (InterruptedException e){
|
|
e.printStackTrace();
|
|
}catch (ExecutionException e){
|
|
e.printStackTrace();
|
|
}finally {
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
long end = System.currentTimeMillis();
|
|
return JsonData.buildSuccess(end-begin);
|
|
}
|
|
|
|
/*获取用户有权限的启用状态的表单列表树形结构*/
|
|
@RequestMapping(value = "/getOTBILLIDById")
|
|
public JsonData getCustomerFormList(@RequestBody Map<String,String> requestBody) {
|
|
//System.out.println(requestBody.get("id"));
|
|
if(!StringUtils.isBlank(requestBody.get("id"))){
|
|
Map<String,String> result = fxfxdxService.getOTBILLIDById(requestBody.get("id"));
|
|
return JsonData.buildSuccess(result);
|
|
}else{
|
|
return JsonData.buildError("请先输入id");
|
|
}
|
|
}
|
|
|
|
@PostMapping("/uploadPDF")
|
|
public ResponseEntity<String> uploadPdf(
|
|
@RequestParam("file") MultipartFile file,
|
|
@RequestParam("id") String id,
|
|
@RequestParam("ticketNumber") String ticketNumber,
|
|
@RequestParam("zypTypeId") String zypTypeId) {
|
|
//上线
|
|
String uploadDir = "F://dataUpload/zypPdfs/";
|
|
// 1. 验证文件类型和大小
|
|
if (file.isEmpty()) {
|
|
return ResponseEntity.badRequest().body("文件不能为空");
|
|
}
|
|
if (!file.getContentType().equals("application/pdf")) {
|
|
return ResponseEntity.badRequest().body("仅支持PDF格式");
|
|
}
|
|
if (file.getSize() > 10 * 1024 * 1024) { // 限制10MB
|
|
return ResponseEntity.badRequest().body("文件大小超过限制");
|
|
}
|
|
System.out.println(id);
|
|
System.out.println(ticketNumber);
|
|
System.out.println(zypTypeId);
|
|
try {
|
|
// 确保目录存在
|
|
File targetDir = new File(uploadDir);
|
|
if (!targetDir.exists()) {
|
|
targetDir.mkdirs(); // 自动创建多级目录
|
|
}
|
|
|
|
// 生成唯一文件名(可选,避免重复覆盖)
|
|
String fileName = id+ "_" +ticketNumber+".pdf";
|
|
|
|
// 构建目标文件的绝对路径
|
|
File targetFile = new File(targetDir.getAbsolutePath() + File.separator + fileName);
|
|
|
|
// 保存文件到磁盘
|
|
file.transferTo(targetFile);
|
|
|
|
if(zypTypeId.equals("e3dbc4258dae4f21961dbb0e83701929")||zypTypeId.equals("626e96e90760406a98c20f2f1f9d014f")){
|
|
boolean flag = dh(id,targetFile);
|
|
if(flag){
|
|
return ResponseEntity.ok("上传成功");
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
}else if(zypTypeId.equals("4babbbd0f1714289bd0b70222998834c")||zypTypeId.equals("c72815d306314dca864414c7ea4a80c7")){
|
|
boolean flag = sxkj(id,targetFile);
|
|
if(flag){
|
|
return ResponseEntity.ok("上传成功");
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
}else if(zypTypeId.equals("457abb402d9b42ad8b8fd601d24fcece")||zypTypeId.equals("7314a6809e66452e9e5e51dfab9a2b3d")){
|
|
boolean flag = mbcd(id, targetFile);
|
|
if(flag){
|
|
return ResponseEntity.ok("上传成功");
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
}else if(zypTypeId.equals("0dc5370dda5248e69db924de402b6639")||zypTypeId.equals("e05c6ca6921f4900af3d6d85cdd9337c")){
|
|
boolean flag = gczy(id,targetFile);
|
|
if(flag){
|
|
return ResponseEntity.ok("上传成功");
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
}else if(zypTypeId.equals("e7671c99bca845e49aad9baab1084331")||zypTypeId.equals("2ce56e004e114f5a9c4b010392780abe")){
|
|
boolean flag = dzaqzy(id, targetFile);
|
|
if(flag){
|
|
return ResponseEntity.ok("上传成功");
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
}else if(zypTypeId.equals("f0ffe0a4620d4f53a143e647fc467b88")||zypTypeId.equals("797dcd5af1c04d76b8bc0071321aae6b")){
|
|
boolean flag = lsydzy(id, targetFile);
|
|
if(flag){
|
|
return ResponseEntity.ok("上传成功");
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
}else if(zypTypeId.equals("0579b3bc102e46feac2d8bdb617750df")||zypTypeId.equals("02954995e8e14704ac86276dee785983")){
|
|
boolean flag = dtzy(id, targetFile);
|
|
if(flag){
|
|
return ResponseEntity.ok("上传成功");
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
}else if(zypTypeId.equals("35ee7345c96a4d77b206d47076ed6839")||zypTypeId.equals("9b8ee675618f4544b9e4a565df4c8f01")||zypTypeId.equals("96f4c6faafcb405785c23f9c0e431a30")){
|
|
boolean flag = dlzy(id, targetFile);
|
|
if(flag){
|
|
return ResponseEntity.ok("上传成功");
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
}else{
|
|
return ResponseEntity.internalServerError().body("失败");
|
|
}
|
|
|
|
|
|
//return ResponseEntity.ok("上传成功");
|
|
} catch (IOException e) {
|
|
return ResponseEntity.internalServerError().body("文件存储失败:" + e.getMessage());
|
|
}
|
|
}
|
|
|
|
public boolean dh(String id,File file) {
|
|
//附件上传
|
|
FileUploadUtil fileUploadUtil = new FileUploadUtil();
|
|
Map<String, Object> uploadResult = fileUploadUtil.upload(file);
|
|
Object body1 = uploadResult.get("body");
|
|
String body1json = JSON.toJSONString(body1);
|
|
com.alibaba.fastjson2.JSONObject body1JsonObject = JSON.parseObject(body1json);
|
|
String body2Str = (String)body1JsonObject.get("body");
|
|
System.out.println(body2Str);
|
|
com.alibaba.fastjson2.JSONObject body2JsonObject = JSON.parseObject(body2Str);
|
|
JSONArray dataJsonArr = (JSONArray) body2JsonObject.get("data");
|
|
String dataStr = JSON.toJSONString(dataJsonArr);
|
|
System.out.println(dataStr);
|
|
String zuoyepiao = dataStr;
|
|
String jobParam = "全量";
|
|
//附件上传
|
|
|
|
|
|
|
|
int pageSize = 1000;
|
|
int success = 0;
|
|
int fail = 0;
|
|
long total = 0;
|
|
|
|
|
|
int pageNum = 1;
|
|
do {
|
|
List<Dhzy> onePage = new ArrayList<>();
|
|
// 1. 启动分页(必须紧邻查询语句)
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 2. 执行查询(此时SQL已被自动拦截并添加分页逻辑)
|
|
|
|
//附件上传
|
|
if (jobParam.equals("全量")) {
|
|
onePage = zypSingleQueryMapper.getOneDhzysPage("N",id);
|
|
} else {
|
|
onePage = zypSingleQueryMapper.getOneDhzysPage("Y",id);
|
|
}
|
|
//附件上传
|
|
|
|
// 3. 封装分页结果
|
|
PageInfo<Dhzy> pageInfo = new PageInfo<>(onePage);
|
|
//设置总数
|
|
total = pageInfo.getTotal();
|
|
System.out.println("总条数:" + total);
|
|
System.out.println("第" + pageNum + "页");
|
|
System.out.println("本页条数:" + pageInfo.getList().size());
|
|
//处理经纬度
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
pageInfo.getList().get(x).setJingweidu(JingWeiDuConverter.createGeoPoint(pageInfo.getList().get(x).getJingweidu()));
|
|
//附件上传
|
|
pageInfo.getList().get(x).setZuoyepiao(zuoyepiao);
|
|
//附件上传
|
|
}
|
|
//对本页数据进行上传
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
|
|
String qiyebianma = pageInfo.getList().get(x).getQiyebianma();
|
|
String url = "https://ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/donghuozuoyebaobei/v1/donghuozuoyebaobei";
|
|
switch (qiyebianma) {
|
|
case "370910170":
|
|
//恒信高科
|
|
//查询安全措施
|
|
ArrayList<Aqcs> dhAqcsList = fxfxdxService.queryDhAqcsByBianhao(pageInfo.getList().get(x).getBianhao());
|
|
//根据安全措施列表便利处理给当前上传对象赋值相关字段
|
|
for (Aqcs dhAqcs: dhAqcsList) {
|
|
DhAqcsUtil.handle(pageInfo.getList().get(x),dhAqcs);
|
|
}
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(pageInfo.getList().get(x));
|
|
String post = null;
|
|
|
|
//System.out.println(jsonObject);
|
|
|
|
|
|
try {
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "PrBMPrhf0qLDFwj6bnLJ7D1821BA364FFDC5");
|
|
boolean thisFailFlag = false;
|
|
boolean postIsNull = false;
|
|
boolean postNoMsgs = false;
|
|
if(!StringUtils.isBlank(post)){
|
|
JSONObject postJsonObj = JSONObject.parseObject(post);
|
|
if(postJsonObj.get("msg")!=null && postJsonObj.get("code")!=null && postJsonObj.get("status")!=null && !StringUtils.isBlank(postJsonObj.get("msg").toString())&&!StringUtils.isBlank(postJsonObj.get("code").toString())&&!StringUtils.isBlank(postJsonObj.get("status").toString())){
|
|
if(postJsonObj.get("msg").equals("成功")&&postJsonObj.get("code").toString().equals("1000000")&&postJsonObj.get("status").toString().equals("200")){//status
|
|
//成功
|
|
System.out.println("成功"+(x+1)+",");
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println(jsonObject);
|
|
System.out.println("post:" + post.toString());
|
|
|
|
success++;
|
|
}else{
|
|
thisFailFlag = true;
|
|
}
|
|
}else{
|
|
thisFailFlag = true;
|
|
postNoMsgs = true;
|
|
}
|
|
}else{
|
|
postIsNull = true;
|
|
thisFailFlag = true;
|
|
}
|
|
if(thisFailFlag){//异常情况
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println("失败"+(x+1)+",动火作业");
|
|
if(!postIsNull){
|
|
System.out.println("post:" + post.toString());
|
|
//XxlJobHelper.log("执行日志:(恒信高科)" + post.toString());
|
|
}
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
fail++;
|
|
Thread.sleep(120000);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
//XxlJobHelper.log("错误信息:" + e);
|
|
//XxlJobHelper.log("请求体:" + jsonObject);
|
|
try {
|
|
TimeUnit.MINUTES.sleep(2); // 直接指定分钟
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
|
|
}
|
|
break;
|
|
case "370980326":
|
|
//中碳氢能源
|
|
System.out.println(1);
|
|
}
|
|
|
|
|
|
}
|
|
pageNum++;
|
|
|
|
} while (total > (pageNum - 1) * pageSize);
|
|
|
|
|
|
|
|
//附件上传
|
|
if (total > 0) {
|
|
return true;
|
|
//XxlJobHelper.log("执行日志:本次有" + total + "条需要上传,成功上传" + success + "条,失败" + fail + "条");
|
|
} else {
|
|
return false;
|
|
//XxlJobHelper.log("执行日志:本次无新数据需上传");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public boolean sxkj(String id,File file) {
|
|
//附件上传
|
|
FileUploadUtil fileUploadUtil = new FileUploadUtil();
|
|
Map<String, Object> uploadResult = fileUploadUtil.upload(file);
|
|
Object body1 = uploadResult.get("body");
|
|
String body1json = JSON.toJSONString(body1);
|
|
com.alibaba.fastjson2.JSONObject body1JsonObject = JSON.parseObject(body1json);
|
|
String body2Str = (String)body1JsonObject.get("body");
|
|
System.out.println(body2Str);
|
|
com.alibaba.fastjson2.JSONObject body2JsonObject = JSON.parseObject(body2Str);
|
|
JSONArray dataJsonArr = (JSONArray) body2JsonObject.get("data");
|
|
String dataStr = JSON.toJSONString(dataJsonArr);
|
|
System.out.println(dataStr);
|
|
String zuoyepiao = dataStr;
|
|
String jobParam = "全量";
|
|
//附件上传
|
|
|
|
int pageSize = 1000;
|
|
int success = 0;
|
|
int fail = 0;
|
|
long total = 0;
|
|
|
|
|
|
int pageNum = 1;
|
|
do {
|
|
List<Sxkjzy> onePage = new ArrayList<>();
|
|
// 1. 启动分页(必须紧邻查询语句)
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 2. 执行查询(此时SQL已被自动拦截并添加分页逻辑)
|
|
if (jobParam.equals("全量")) {
|
|
onePage = zypSingleQueryMapper.getOneSxkjzysPage("N",id);
|
|
} else {
|
|
onePage = zypSingleQueryMapper.getOneSxkjzysPage("Y",id);
|
|
}
|
|
|
|
// 3. 封装分页结果
|
|
PageInfo<Sxkjzy> pageInfo = new PageInfo<>(onePage);
|
|
//设置总数
|
|
total = pageInfo.getTotal();
|
|
System.out.println("总条数:" + total);
|
|
System.out.println("第" + pageNum + "页");
|
|
System.out.println("本页条数:" + pageInfo.getList().size());
|
|
//处理经纬度
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
pageInfo.getList().get(x).setJingweidu(JingWeiDuConverter.createGeoPoint(pageInfo.getList().get(x).getJingweidu()));
|
|
//附件上传
|
|
pageInfo.getList().get(x).setZuoyepiao(zuoyepiao);
|
|
//附件上传
|
|
}
|
|
//对本页数据进行上传
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
|
|
String qiyebianma = pageInfo.getList().get(x).getQiyebianma();
|
|
String url = "https://ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/shouxiankongjiananqu/v1/shouxiankongjiananqu";
|
|
switch (qiyebianma) {
|
|
case "370910170":
|
|
//恒信高科
|
|
//查询安全措施
|
|
ArrayList<Aqcs> aqcsList = fxfxdxService.queryDhAqcsByBianhao(pageInfo.getList().get(x).getBianhao());
|
|
//根据安全措施列表便利处理给当前上传对象赋值相关字段
|
|
for (Aqcs aqcs: aqcsList) {
|
|
SxkjzyUtil.handle(pageInfo.getList().get(x),aqcs);
|
|
//System.out.println(aqcs);
|
|
}
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(pageInfo.getList().get(x));
|
|
String post = null;
|
|
|
|
//System.out.println(jsonObject);
|
|
|
|
|
|
try {
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "UgedXJ6rjuZ0iPihxQRN1A312DA6ACE3B28F");
|
|
boolean thisFailFlag = false;
|
|
boolean postIsNull = false;
|
|
boolean postNoMsgs = false;
|
|
if(!StringUtils.isBlank(post)){
|
|
JSONObject postJsonObj = JSONObject.parseObject(post);
|
|
if(postJsonObj.get("msg")!=null && postJsonObj.get("code")!=null && postJsonObj.get("status")!=null && !StringUtils.isBlank(postJsonObj.get("msg").toString())&&!StringUtils.isBlank(postJsonObj.get("code").toString())&&!StringUtils.isBlank(postJsonObj.get("status").toString())){
|
|
if(postJsonObj.get("msg").equals("成功")&&postJsonObj.get("code").toString().equals("1000000")&&postJsonObj.get("status").toString().equals("200")){//status
|
|
//成功
|
|
System.out.println("成功"+(x+1)+",");
|
|
|
|
|
|
/*DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println(jsonObject);
|
|
System.out.println("post:" + post.toString());*/
|
|
|
|
success++;
|
|
}else{
|
|
thisFailFlag = true;
|
|
}
|
|
}else{
|
|
thisFailFlag = true;
|
|
postNoMsgs = true;
|
|
}
|
|
}else{
|
|
postIsNull = true;
|
|
thisFailFlag = true;
|
|
}
|
|
if(thisFailFlag){//异常情况
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println("失败"+(x+1)+",受限空间作业");
|
|
if(!postIsNull){
|
|
System.out.println("post:" + post.toString());
|
|
/*XxlJobHelper.log("执行日志:(恒信高科)" + post.toString());*/
|
|
}
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
fail++;
|
|
Thread.sleep(120000);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
/*XxlJobHelper.log("错误信息:" + e);
|
|
XxlJobHelper.log("请求体:" + jsonObject);*/
|
|
try {
|
|
TimeUnit.MINUTES.sleep(2); // 直接指定分钟
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
|
|
}
|
|
break;
|
|
case "370980326":
|
|
//中碳氢能源
|
|
System.out.println(1);
|
|
}
|
|
|
|
|
|
}
|
|
pageNum++;
|
|
|
|
} while (total > (pageNum - 1) * pageSize);
|
|
|
|
|
|
|
|
|
|
//附件上传
|
|
if (total > 0) {
|
|
return true;
|
|
//XxlJobHelper.log("执行日志:本次有" + total + "条需要上传,成功上传" + success + "条,失败" + fail + "条");
|
|
} else {
|
|
return false;
|
|
//XxlJobHelper.log("执行日志:本次无新数据需上传");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean mbcd(String id,File file) {
|
|
//附件上传
|
|
FileUploadUtil fileUploadUtil = new FileUploadUtil();
|
|
Map<String, Object> uploadResult = fileUploadUtil.upload(file);
|
|
Object body1 = uploadResult.get("body");
|
|
String body1json = JSON.toJSONString(body1);
|
|
com.alibaba.fastjson2.JSONObject body1JsonObject = JSON.parseObject(body1json);
|
|
String body2Str = (String)body1JsonObject.get("body");
|
|
System.out.println(body2Str);
|
|
com.alibaba.fastjson2.JSONObject body2JsonObject = JSON.parseObject(body2Str);
|
|
JSONArray dataJsonArr = (JSONArray) body2JsonObject.get("data");
|
|
String dataStr = JSON.toJSONString(dataJsonArr);
|
|
System.out.println(dataStr);
|
|
String zuoyepiao = dataStr;
|
|
String jobParam = "全量";
|
|
//附件上传
|
|
|
|
int pageSize = 1000;
|
|
int success = 0;
|
|
int fail = 0;
|
|
long total = 0;
|
|
|
|
|
|
int pageNum = 1;
|
|
do {
|
|
List<Mbcdzy> onePage = new ArrayList<>();
|
|
// 1. 启动分页(必须紧邻查询语句)
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 2. 执行查询(此时SQL已被自动拦截并添加分页逻辑)
|
|
if (jobParam.equals("全量")) {
|
|
onePage = zypSingleQueryMapper.getOneMbcdzysPage("N",id);
|
|
} else {
|
|
onePage = zypSingleQueryMapper.getOneMbcdzysPage("Y",id);
|
|
}
|
|
|
|
// 3. 封装分页结果
|
|
PageInfo<Mbcdzy> pageInfo = new PageInfo<>(onePage);
|
|
//设置总数
|
|
total = pageInfo.getTotal();
|
|
System.out.println("总条数:" + total);
|
|
System.out.println("第" + pageNum + "页");
|
|
System.out.println("本页条数:" + pageInfo.getList().size());
|
|
//处理经纬度
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
pageInfo.getList().get(x).setJingweidu(JingWeiDuConverter.createGeoPoint(pageInfo.getList().get(x).getJingweidu()));
|
|
//附件上传
|
|
pageInfo.getList().get(x).setZuoyepiao(zuoyepiao);
|
|
//附件上传
|
|
}
|
|
//对本页数据进行上传
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
|
|
String qiyebianma = pageInfo.getList().get(x).getQiyebianma();
|
|
String url = "https://ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/mangbanchouduanquanz/v1/mangbanchouduanquanz";
|
|
switch (qiyebianma) {
|
|
case "370910170":
|
|
//恒信高科
|
|
//查询安全措施
|
|
ArrayList<Aqcs> aqcsList = fxfxdxService.queryDhAqcsByBianhao(pageInfo.getList().get(x).getZuoyepiaobianhao());
|
|
//根据安全措施列表便利处理给当前上传对象赋值相关字段
|
|
for (Aqcs aqcs: aqcsList) {
|
|
MbcdzyUtil.handle(pageInfo.getList().get(x),aqcs);
|
|
//System.out.println(aqcs);
|
|
}
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(pageInfo.getList().get(x));
|
|
String post = null;
|
|
|
|
//System.out.println(jsonObject);
|
|
|
|
|
|
try {
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "v3N8M5tIrV7wroWdO4fmCD2897D9726FD394");
|
|
boolean thisFailFlag = false;
|
|
boolean postIsNull = false;
|
|
boolean postNoMsgs = false;
|
|
if(!StringUtils.isBlank(post)){
|
|
JSONObject postJsonObj = JSONObject.parseObject(post);
|
|
if(postJsonObj.get("msg")!=null && postJsonObj.get("code")!=null && postJsonObj.get("status")!=null && !StringUtils.isBlank(postJsonObj.get("msg").toString())&&!StringUtils.isBlank(postJsonObj.get("code").toString())&&!StringUtils.isBlank(postJsonObj.get("status").toString())){
|
|
if(postJsonObj.get("msg").equals("成功")&&postJsonObj.get("code").toString().equals("1000000")&&postJsonObj.get("status").toString().equals("200")){//status
|
|
//成功
|
|
System.out.println("成功"+(x+1)+",");
|
|
|
|
|
|
/*DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println(jsonObject);
|
|
System.out.println("post:" + post.toString());*/
|
|
|
|
success++;
|
|
}else{
|
|
thisFailFlag = true;
|
|
}
|
|
}else{
|
|
thisFailFlag = true;
|
|
postNoMsgs = true;
|
|
}
|
|
}else{
|
|
postIsNull = true;
|
|
thisFailFlag = true;
|
|
}
|
|
if(thisFailFlag){//异常情况
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println("失败"+(x+1)+",盲板抽堵作业");
|
|
if(!postIsNull){
|
|
System.out.println("post:" + post.toString());
|
|
//XxlJobHelper.log("执行日志:(恒信高科)" + post.toString());
|
|
}
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
fail++;
|
|
Thread.sleep(120000);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
/*XxlJobHelper.log("错误信息:" + e);
|
|
XxlJobHelper.log("请求体:" + jsonObject);*/
|
|
try {
|
|
TimeUnit.MINUTES.sleep(2); // 直接指定分钟
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
|
|
}
|
|
break;
|
|
case "370980326":
|
|
//中碳氢能源
|
|
System.out.println(1);
|
|
}
|
|
|
|
|
|
}
|
|
pageNum++;
|
|
|
|
} while (total > (pageNum - 1) * pageSize);
|
|
|
|
|
|
|
|
|
|
//附件上传
|
|
if (total > 0) {
|
|
return true;
|
|
//XxlJobHelper.log("执行日志:本次有" + total + "条需要上传,成功上传" + success + "条,失败" + fail + "条");
|
|
} else {
|
|
return false;
|
|
//XxlJobHelper.log("执行日志:本次无新数据需上传");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean gczy(String id,File file) {
|
|
//附件上传
|
|
FileUploadUtil fileUploadUtil = new FileUploadUtil();
|
|
Map<String, Object> uploadResult = fileUploadUtil.upload(file);
|
|
Object body1 = uploadResult.get("body");
|
|
String body1json = JSON.toJSONString(body1);
|
|
com.alibaba.fastjson2.JSONObject body1JsonObject = JSON.parseObject(body1json);
|
|
String body2Str = (String)body1JsonObject.get("body");
|
|
System.out.println(body2Str);
|
|
com.alibaba.fastjson2.JSONObject body2JsonObject = JSON.parseObject(body2Str);
|
|
JSONArray dataJsonArr = (JSONArray) body2JsonObject.get("data");
|
|
String dataStr = JSON.toJSONString(dataJsonArr);
|
|
System.out.println(dataStr);
|
|
String zuoyepiao = dataStr;
|
|
String jobParam = "全量";
|
|
//附件上传
|
|
|
|
int pageSize = 1000;
|
|
int success = 0;
|
|
int fail = 0;
|
|
long total = 0;
|
|
/*
|
|
|
|
*/
|
|
|
|
|
|
int pageNum = 1;
|
|
do {
|
|
List<Gczy> onePage = new ArrayList<>();
|
|
// 1. 启动分页(必须紧邻查询语句)
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 2. 执行查询(此时SQL已被自动拦截并添加分页逻辑)
|
|
if (jobParam.equals("全量")) {
|
|
onePage = zypSingleQueryMapper.getOneGczysPage("N",id);
|
|
} else {
|
|
onePage = zypSingleQueryMapper.getOneGczysPage("Y",id);
|
|
}
|
|
|
|
// 3. 封装分页结果
|
|
PageInfo<Gczy> pageInfo = new PageInfo<>(onePage);
|
|
//设置总数
|
|
total = pageInfo.getTotal();
|
|
System.out.println("总条数:" + total);
|
|
System.out.println("第" + pageNum + "页");
|
|
System.out.println("本页条数:" + pageInfo.getList().size());
|
|
//处理经纬度
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
pageInfo.getList().get(x).setJingweidu(JingWeiDuConverter.createGeoPoint(pageInfo.getList().get(x).getJingweidu()));
|
|
//附件上传
|
|
pageInfo.getList().get(x).setZuoyepiao(zuoyepiao);
|
|
//附件上传
|
|
}
|
|
//对本页数据进行上传
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
|
|
String qiyebianma = pageInfo.getList().get(x).getQiyebianma();
|
|
String url = "https://ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/gaochuanquanzuoyebao/v1/gaochuanquanzuoyebao";
|
|
switch (qiyebianma) {
|
|
case "370910170":
|
|
//恒信高科
|
|
//查询安全措施
|
|
ArrayList<Aqcs> aqcsList = fxfxdxService.queryDhAqcsByBianhao(pageInfo.getList().get(x).getBianhao());
|
|
//根据安全措施列表便利处理给当前上传对象赋值相关字段
|
|
for (Aqcs aqcs: aqcsList) {
|
|
GczyUtil.handle(pageInfo.getList().get(x),aqcs);
|
|
//System.out.println(aqcs);
|
|
}
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(pageInfo.getList().get(x));
|
|
String post = null;
|
|
|
|
//System.out.println(jsonObject);
|
|
|
|
|
|
try {
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "zaIDuL6BDCJRpciQpiTZDF739F2837E3D0BF");
|
|
boolean thisFailFlag = false;
|
|
boolean postIsNull = false;
|
|
boolean postNoMsgs = false;
|
|
if(!StringUtils.isBlank(post)){
|
|
JSONObject postJsonObj = JSONObject.parseObject(post);
|
|
if(postJsonObj.get("msg")!=null && postJsonObj.get("code")!=null && postJsonObj.get("status")!=null && !StringUtils.isBlank(postJsonObj.get("msg").toString())&&!StringUtils.isBlank(postJsonObj.get("code").toString())&&!StringUtils.isBlank(postJsonObj.get("status").toString())){
|
|
if(postJsonObj.get("msg").equals("成功")&&postJsonObj.get("code").toString().equals("1000000")&&postJsonObj.get("status").toString().equals("200")){//status
|
|
//成功
|
|
System.out.println("成功"+(x+1)+",");
|
|
|
|
|
|
/*DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println(jsonObject);
|
|
System.out.println("post:" + post.toString());*/
|
|
|
|
success++;
|
|
}else{
|
|
thisFailFlag = true;
|
|
}
|
|
}else{
|
|
thisFailFlag = true;
|
|
postNoMsgs = true;
|
|
}
|
|
}else{
|
|
postIsNull = true;
|
|
thisFailFlag = true;
|
|
}
|
|
if(thisFailFlag){//异常情况
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println("失败"+(x+1)+",高处作业");
|
|
if(!postIsNull){
|
|
System.out.println("post:" + post.toString());
|
|
//XxlJobHelper.log("执行日志:(恒信高科)" + post.toString());
|
|
}
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
fail++;
|
|
Thread.sleep(120000);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
/*XxlJobHelper.log("错误信息:" + e);
|
|
XxlJobHelper.log("请求体:" + jsonObject);*/
|
|
try {
|
|
TimeUnit.MINUTES.sleep(2); // 直接指定分钟
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
|
|
}
|
|
break;
|
|
case "370980326":
|
|
//中碳氢能源
|
|
System.out.println(1);
|
|
}
|
|
|
|
|
|
}
|
|
pageNum++;
|
|
|
|
} while (total > (pageNum - 1) * pageSize);
|
|
|
|
|
|
|
|
|
|
//附件上传
|
|
if (total > 0) {
|
|
return true;
|
|
//XxlJobHelper.log("执行日志:本次有" + total + "条需要上传,成功上传" + success + "条,失败" + fail + "条");
|
|
} else {
|
|
return false;
|
|
//XxlJobHelper.log("执行日志:本次无新数据需上传");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public boolean dzaqzy(String id,File file) {
|
|
//附件上传
|
|
FileUploadUtil fileUploadUtil = new FileUploadUtil();
|
|
Map<String, Object> uploadResult = fileUploadUtil.upload(file);
|
|
Object body1 = uploadResult.get("body");
|
|
String body1json = JSON.toJSONString(body1);
|
|
com.alibaba.fastjson2.JSONObject body1JsonObject = JSON.parseObject(body1json);
|
|
String body2Str = (String)body1JsonObject.get("body");
|
|
System.out.println(body2Str);
|
|
com.alibaba.fastjson2.JSONObject body2JsonObject = JSON.parseObject(body2Str);
|
|
JSONArray dataJsonArr = (JSONArray) body2JsonObject.get("data");
|
|
String dataStr = JSON.toJSONString(dataJsonArr);
|
|
System.out.println(dataStr);
|
|
String zuoyepiao = dataStr;
|
|
String jobParam = "全量";
|
|
//附件上传
|
|
|
|
int pageSize = 1000;
|
|
int success = 0;
|
|
int fail = 0;
|
|
long total = 0;
|
|
/*
|
|
|
|
*/
|
|
|
|
|
|
int pageNum = 1;
|
|
do {
|
|
List<Dzaqzy> onePage = new ArrayList<>();
|
|
// 1. 启动分页(必须紧邻查询语句)
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 2. 执行查询(此时SQL已被自动拦截并添加分页逻辑)
|
|
if (jobParam.equals("全量")) {
|
|
onePage = zypSingleQueryMapper.getOneDzaqzysPage("N",id);
|
|
} else {
|
|
onePage = zypSingleQueryMapper.getOneDzaqzysPage("Y",id);
|
|
}
|
|
|
|
// 3. 封装分页结果
|
|
PageInfo<Dzaqzy> pageInfo = new PageInfo<>(onePage);
|
|
//设置总数
|
|
total = pageInfo.getTotal();
|
|
System.out.println("总条数:" + total);
|
|
System.out.println("第" + pageNum + "页");
|
|
System.out.println("本页条数:" + pageInfo.getList().size());
|
|
//处理经纬度
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
pageInfo.getList().get(x).setJingweidu(JingWeiDuConverter.createGeoPoint(pageInfo.getList().get(x).getJingweidu()));
|
|
//附件上传
|
|
pageInfo.getList().get(x).setZuoyepiao(zuoyepiao);
|
|
//附件上传
|
|
}
|
|
//对本页数据进行上传
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
|
|
String qiyebianma = pageInfo.getList().get(x).getQiyebianma();
|
|
String url = "https://ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/diaozhuanganquanzuoy/v1/diaozhuanganquanzuoy";
|
|
switch (qiyebianma) {
|
|
case "370910170":
|
|
//恒信高科
|
|
//查询安全措施
|
|
ArrayList<Aqcs> aqcsList = fxfxdxService.queryDhAqcsByBianhao(pageInfo.getList().get(x).getBianhao());
|
|
//根据安全措施列表便利处理给当前上传对象赋值相关字段
|
|
for (Aqcs aqcs: aqcsList) {
|
|
DzaqzyUtil.handle(pageInfo.getList().get(x),aqcs);
|
|
//System.out.println(aqcs);
|
|
}
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(pageInfo.getList().get(x));
|
|
String post = null;
|
|
|
|
//System.out.println(jsonObject);
|
|
|
|
|
|
try {
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "TgFxv5xVQwYvJ3pb4hKVD7FCB38C89FCDC7A");
|
|
boolean thisFailFlag = false;
|
|
boolean postIsNull = false;
|
|
boolean postNoMsgs = false;
|
|
if(!StringUtils.isBlank(post)){
|
|
JSONObject postJsonObj = JSONObject.parseObject(post);
|
|
if(postJsonObj.get("msg")!=null && postJsonObj.get("code")!=null && postJsonObj.get("status")!=null && !StringUtils.isBlank(postJsonObj.get("msg").toString())&&!StringUtils.isBlank(postJsonObj.get("code").toString())&&!StringUtils.isBlank(postJsonObj.get("status").toString())){
|
|
if(postJsonObj.get("msg").equals("成功")&&postJsonObj.get("code").toString().equals("1000000")&&postJsonObj.get("status").toString().equals("200")){//status
|
|
//成功
|
|
System.out.println("成功"+(x+1)+",");
|
|
|
|
|
|
/*DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println(jsonObject);
|
|
System.out.println("post:" + post.toString());*/
|
|
|
|
success++;
|
|
}else{
|
|
thisFailFlag = true;
|
|
}
|
|
}else{
|
|
thisFailFlag = true;
|
|
postNoMsgs = true;
|
|
}
|
|
}else{
|
|
postIsNull = true;
|
|
thisFailFlag = true;
|
|
}
|
|
if(thisFailFlag){//异常情况
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println("失败"+(x+1)+",吊装安全作业");
|
|
if(!postIsNull){
|
|
System.out.println("post:" + post.toString());
|
|
//XxlJobHelper.log("执行日志:(恒信高科)" + post.toString());
|
|
}
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
fail++;
|
|
Thread.sleep(120000);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
/*XxlJobHelper.log("错误信息:" + e);
|
|
XxlJobHelper.log("请求体:" + jsonObject);*/
|
|
try {
|
|
TimeUnit.MINUTES.sleep(2); // 直接指定分钟
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
|
|
}
|
|
break;
|
|
case "370980326":
|
|
//中碳氢能源
|
|
System.out.println(1);
|
|
}
|
|
|
|
|
|
}
|
|
pageNum++;
|
|
|
|
} while (total > (pageNum - 1) * pageSize);
|
|
|
|
|
|
|
|
|
|
//附件上传
|
|
if (total > 0) {
|
|
return true;
|
|
//XxlJobHelper.log("执行日志:本次有" + total + "条需要上传,成功上传" + success + "条,失败" + fail + "条");
|
|
} else {
|
|
return false;
|
|
//XxlJobHelper.log("执行日志:本次无新数据需上传");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public boolean lsydzy(String id,File file) {
|
|
//附件上传
|
|
FileUploadUtil fileUploadUtil = new FileUploadUtil();
|
|
Map<String, Object> uploadResult = fileUploadUtil.upload(file);
|
|
Object body1 = uploadResult.get("body");
|
|
String body1json = JSON.toJSONString(body1);
|
|
com.alibaba.fastjson2.JSONObject body1JsonObject = JSON.parseObject(body1json);
|
|
String body2Str = (String)body1JsonObject.get("body");
|
|
System.out.println(body2Str);
|
|
com.alibaba.fastjson2.JSONObject body2JsonObject = JSON.parseObject(body2Str);
|
|
JSONArray dataJsonArr = (JSONArray) body2JsonObject.get("data");
|
|
String dataStr = JSON.toJSONString(dataJsonArr);
|
|
System.out.println(dataStr);
|
|
String zuoyepiao = dataStr;
|
|
String jobParam = "全量";
|
|
//附件上传
|
|
|
|
int pageSize = 1000;
|
|
int success = 0;
|
|
int fail = 0;
|
|
long total = 0;
|
|
|
|
|
|
int pageNum = 1;
|
|
do {
|
|
List<Lsydzy> onePage = new ArrayList<>();
|
|
// 1. 启动分页(必须紧邻查询语句)
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 2. 执行查询(此时SQL已被自动拦截并添加分页逻辑)
|
|
if (jobParam.equals("全量")) {
|
|
onePage = zypSingleQueryMapper.getOneLsydzysPage("N",id);
|
|
} else {
|
|
onePage = zypSingleQueryMapper.getOneLsydzysPage("Y",id);
|
|
}
|
|
|
|
// 3. 封装分页结果
|
|
PageInfo<Lsydzy> pageInfo = new PageInfo<>(onePage);
|
|
//设置总数
|
|
total = pageInfo.getTotal();
|
|
System.out.println("总条数:" + total);
|
|
System.out.println("第" + pageNum + "页");
|
|
System.out.println("本页条数:" + pageInfo.getList().size());
|
|
//处理经纬度
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
pageInfo.getList().get(x).setJingweidu(JingWeiDuConverter.createGeoPoint(pageInfo.getList().get(x).getJingweidu()));
|
|
//附件上传
|
|
pageInfo.getList().get(x).setZuoyepiao(zuoyepiao);
|
|
//附件上传
|
|
}
|
|
//对本页数据进行上传
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
|
|
String shenqingdanwei = pageInfo.getList().get(x).getShenqingdanwei();
|
|
String url = "https://ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/linshiyongdiananquan/v1/linshiyongdiananquan";
|
|
if(shenqingdanwei.equals("山东恒信高科能源有限公司")){
|
|
//恒信高科
|
|
//查询安全措施
|
|
ArrayList<Aqcs> aqcsList = fxfxdxService.queryDhAqcsByBianhao(pageInfo.getList().get(x).getBianhao());
|
|
//根据安全措施列表便利处理给当前上传对象赋值相关字段
|
|
for (Aqcs aqcs: aqcsList) {
|
|
LsydzyUtil.handle(pageInfo.getList().get(x),aqcs);
|
|
//System.out.println(aqcs);
|
|
}
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(pageInfo.getList().get(x));
|
|
String post = null;
|
|
|
|
//System.out.println(jsonObject);
|
|
|
|
|
|
try {
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "C6MC32Ig7bjNMfNiFn9f0349DF6D105F39E0");
|
|
boolean thisFailFlag = false;
|
|
boolean postIsNull = false;
|
|
boolean postNoMsgs = false;
|
|
if(!StringUtils.isBlank(post)){
|
|
JSONObject postJsonObj = JSONObject.parseObject(post);
|
|
if(postJsonObj.get("msg")!=null && postJsonObj.get("code")!=null && postJsonObj.get("status")!=null && !StringUtils.isBlank(postJsonObj.get("msg").toString())&&!StringUtils.isBlank(postJsonObj.get("code").toString())&&!StringUtils.isBlank(postJsonObj.get("status").toString())){
|
|
if(postJsonObj.get("msg").equals("成功")&&postJsonObj.get("code").toString().equals("1000000")&&postJsonObj.get("status").toString().equals("200")){//status
|
|
//成功
|
|
System.out.println("成功"+(x+1)+",");
|
|
|
|
|
|
/*DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println(jsonObject);
|
|
System.out.println("post:" + post.toString());*/
|
|
|
|
success++;
|
|
}else{
|
|
thisFailFlag = true;
|
|
}
|
|
}else{
|
|
thisFailFlag = true;
|
|
postNoMsgs = true;
|
|
}
|
|
}else{
|
|
postIsNull = true;
|
|
thisFailFlag = true;
|
|
}
|
|
if(thisFailFlag){//异常情况
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println("失败"+(x+1)+",临时用电作业");
|
|
if(!postIsNull){
|
|
System.out.println("post:" + post.toString());
|
|
//XxlJobHelper.log("执行日志:(恒信高科)" + post.toString());
|
|
}
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
fail++;
|
|
Thread.sleep(120000);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
/*XxlJobHelper.log("错误信息:" + e);
|
|
XxlJobHelper.log("请求体:" + jsonObject);*/
|
|
try {
|
|
TimeUnit.MINUTES.sleep(2); // 直接指定分钟
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
|
|
}
|
|
}else{
|
|
//中碳氢能源
|
|
System.out.println(1);
|
|
}
|
|
|
|
|
|
}
|
|
pageNum++;
|
|
|
|
} while (total > (pageNum - 1) * pageSize);
|
|
|
|
|
|
|
|
|
|
//附件上传
|
|
if (total > 0) {
|
|
return true;
|
|
//XxlJobHelper.log("执行日志:本次有" + total + "条需要上传,成功上传" + success + "条,失败" + fail + "条");
|
|
} else {
|
|
return false;
|
|
//XxlJobHelper.log("执行日志:本次无新数据需上传");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public boolean dtzy(String id,File file) {
|
|
//附件上传
|
|
FileUploadUtil fileUploadUtil = new FileUploadUtil();
|
|
Map<String, Object> uploadResult = fileUploadUtil.upload(file);
|
|
Object body1 = uploadResult.get("body");
|
|
String body1json = JSON.toJSONString(body1);
|
|
com.alibaba.fastjson2.JSONObject body1JsonObject = JSON.parseObject(body1json);
|
|
String body2Str = (String)body1JsonObject.get("body");
|
|
System.out.println(body2Str);
|
|
com.alibaba.fastjson2.JSONObject body2JsonObject = JSON.parseObject(body2Str);
|
|
JSONArray dataJsonArr = (JSONArray) body2JsonObject.get("data");
|
|
String dataStr = JSON.toJSONString(dataJsonArr);
|
|
System.out.println(dataStr);
|
|
String zuoyepiao = dataStr;
|
|
String jobParam = "全量";
|
|
//附件上传
|
|
|
|
int pageSize = 1000;
|
|
int success = 0;
|
|
int fail = 0;
|
|
long total = 0;
|
|
|
|
|
|
int pageNum = 1;
|
|
do {
|
|
List<Dtzy> onePage = new ArrayList<>();
|
|
// 1. 启动分页(必须紧邻查询语句)
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 2. 执行查询(此时SQL已被自动拦截并添加分页逻辑)
|
|
if (jobParam.equals("全量")) {
|
|
onePage = zypSingleQueryMapper.getOneDtzysPage("N",id);
|
|
} else {
|
|
onePage = zypSingleQueryMapper.getOneDtzysPage("Y",id);
|
|
}
|
|
|
|
// 3. 封装分页结果
|
|
PageInfo<Dtzy> pageInfo = new PageInfo<>(onePage);
|
|
//设置总数
|
|
total = pageInfo.getTotal();
|
|
System.out.println("总条数:" + total);
|
|
System.out.println("第" + pageNum + "页");
|
|
System.out.println("本页条数:" + pageInfo.getList().size());
|
|
//处理经纬度
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
pageInfo.getList().get(x).setJingweidu(JingWeiDuConverter.createGeoPoint(pageInfo.getList().get(x).getJingweidu()));
|
|
//附件上传
|
|
pageInfo.getList().get(x).setZuoyepiao(zuoyepiao);
|
|
//附件上传
|
|
}
|
|
//对本页数据进行上传
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
|
|
String shenqingdanwei = pageInfo.getList().get(x).getShenqingdanwei();
|
|
String url = "https://ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/dongtuanquanzuoyebao/v1/dongtuanquanzuoyebao";
|
|
if(shenqingdanwei.equals("山东恒信高科能源有限公司")){
|
|
//恒信高科
|
|
//查询安全措施
|
|
ArrayList<Aqcs> aqcsList = fxfxdxService.queryDhAqcsByBianhao(pageInfo.getList().get(x).getBianhao());
|
|
//根据安全措施列表便利处理给当前上传对象赋值相关字段
|
|
for (Aqcs aqcs: aqcsList) {
|
|
DtzyUtil.handle(pageInfo.getList().get(x),aqcs);
|
|
//System.out.println(aqcs);
|
|
}
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(pageInfo.getList().get(x));
|
|
String post = null;
|
|
|
|
//System.out.println(jsonObject);
|
|
|
|
|
|
try {
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "tqAjma93H5xpof6iviSFC57389DC1D1F35EE");
|
|
boolean thisFailFlag = false;
|
|
boolean postIsNull = false;
|
|
boolean postNoMsgs = false;
|
|
if(!StringUtils.isBlank(post)){
|
|
JSONObject postJsonObj = JSONObject.parseObject(post);
|
|
if(postJsonObj.get("msg")!=null && postJsonObj.get("code")!=null && postJsonObj.get("status")!=null && !StringUtils.isBlank(postJsonObj.get("msg").toString())&&!StringUtils.isBlank(postJsonObj.get("code").toString())&&!StringUtils.isBlank(postJsonObj.get("status").toString())){
|
|
if(postJsonObj.get("msg").equals("成功")&&postJsonObj.get("code").toString().equals("1000000")&&postJsonObj.get("status").toString().equals("200")){//status
|
|
//成功
|
|
System.out.println("成功"+(x+1)+",");
|
|
|
|
|
|
/*DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println(jsonObject);
|
|
System.out.println("post:" + post.toString());*/
|
|
|
|
success++;
|
|
}else{
|
|
thisFailFlag = true;
|
|
}
|
|
}else{
|
|
thisFailFlag = true;
|
|
postNoMsgs = true;
|
|
}
|
|
}else{
|
|
postIsNull = true;
|
|
thisFailFlag = true;
|
|
}
|
|
if(thisFailFlag){//异常情况
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println("失败"+(x+1)+",动土作业");
|
|
if(!postIsNull){
|
|
System.out.println("post:" + post.toString());
|
|
//XxlJobHelper.log("执行日志:(恒信高科)" + post.toString());
|
|
}
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
fail++;
|
|
Thread.sleep(120000);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
/*XxlJobHelper.log("错误信息:" + e);
|
|
XxlJobHelper.log("请求体:" + jsonObject);*/
|
|
try {
|
|
TimeUnit.MINUTES.sleep(2); // 直接指定分钟
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
|
|
}
|
|
}else{
|
|
//中碳氢能源
|
|
System.out.println(1);
|
|
}
|
|
|
|
|
|
}
|
|
pageNum++;
|
|
|
|
} while (total > (pageNum - 1) * pageSize);
|
|
|
|
|
|
|
|
|
|
//附件上传
|
|
if (total > 0) {
|
|
return true;
|
|
//XxlJobHelper.log("执行日志:本次有" + total + "条需要上传,成功上传" + success + "条,失败" + fail + "条");
|
|
} else {
|
|
return false;
|
|
//XxlJobHelper.log("执行日志:本次无新数据需上传");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public boolean dlzy(String id,File file) {
|
|
//附件上传
|
|
FileUploadUtil fileUploadUtil = new FileUploadUtil();
|
|
Map<String, Object> uploadResult = fileUploadUtil.upload(file);
|
|
Object body1 = uploadResult.get("body");
|
|
String body1json = JSON.toJSONString(body1);
|
|
com.alibaba.fastjson2.JSONObject body1JsonObject = JSON.parseObject(body1json);
|
|
String body2Str = (String)body1JsonObject.get("body");
|
|
System.out.println(body2Str);
|
|
com.alibaba.fastjson2.JSONObject body2JsonObject = JSON.parseObject(body2Str);
|
|
JSONArray dataJsonArr = (JSONArray) body2JsonObject.get("data");
|
|
String dataStr = JSON.toJSONString(dataJsonArr);
|
|
System.out.println(dataStr);
|
|
String zuoyepiao = dataStr;
|
|
String jobParam = "全量";
|
|
//附件上传
|
|
|
|
int pageSize = 1000;
|
|
int success = 0;
|
|
int fail = 0;
|
|
long total = 0;
|
|
|
|
|
|
int pageNum = 1;
|
|
do {
|
|
List<Dlzy> onePage = new ArrayList<>();
|
|
// 1. 启动分页(必须紧邻查询语句)
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 2. 执行查询(此时SQL已被自动拦截并添加分页逻辑)
|
|
if (jobParam.equals("全量")) {
|
|
onePage = zypSingleQueryMapper.getOneDlzysPage("N",id);
|
|
} else {
|
|
onePage = zypSingleQueryMapper.getOneDlzysPage("Y",id);
|
|
}
|
|
|
|
// 3. 封装分页结果
|
|
PageInfo<Dlzy> pageInfo = new PageInfo<>(onePage);
|
|
//设置总数
|
|
total = pageInfo.getTotal();
|
|
System.out.println("总条数:" + total);
|
|
System.out.println("第" + pageNum + "页");
|
|
System.out.println("本页条数:" + pageInfo.getList().size());
|
|
//处理经纬度
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
pageInfo.getList().get(x).setJingweidu(JingWeiDuConverter.createGeoPoint(pageInfo.getList().get(x).getJingweidu()));
|
|
//附件上传
|
|
pageInfo.getList().get(x).setZuoyepiao(zuoyepiao);
|
|
//附件上传
|
|
}
|
|
//对本页数据进行上传
|
|
for (int x = 0; x < pageInfo.getList().size(); x++) {
|
|
|
|
String shenqingdanwei = pageInfo.getList().get(x).getShenqingdanwei();
|
|
String url = "https://ny-fxfk.com/space-ningyanghuagongchany/sapi/qpaas/tiga/dys/keyAuthentication/duanluanquanzuoyebao/v1/duanluanquanzuoyebao";
|
|
if(shenqingdanwei.equals("山东恒信高科能源有限公司")){
|
|
//恒信高科
|
|
//查询安全措施
|
|
ArrayList<Aqcs> aqcsList = fxfxdxService.queryDhAqcsByBianhao(pageInfo.getList().get(x).getBianhao());
|
|
//根据安全措施列表便利处理给当前上传对象赋值相关字段
|
|
for (Aqcs aqcs: aqcsList) {
|
|
DlzyUtil.handle(pageInfo.getList().get(x),aqcs);
|
|
//System.out.println(aqcs);
|
|
}
|
|
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(pageInfo.getList().get(x));
|
|
String post = null;
|
|
|
|
//System.out.println(jsonObject);
|
|
|
|
|
|
try {
|
|
post = HttpUtils.sendDataUpload(url, jsonObject, HTTP.UTF_8, "vSc603IKlc4iaKAsbCV8880424DAAA87A529");
|
|
boolean thisFailFlag = false;
|
|
boolean postIsNull = false;
|
|
boolean postNoMsgs = false;
|
|
if(!StringUtils.isBlank(post)){
|
|
JSONObject postJsonObj = JSONObject.parseObject(post);
|
|
if(postJsonObj.get("msg")!=null && postJsonObj.get("code")!=null && postJsonObj.get("status")!=null && !StringUtils.isBlank(postJsonObj.get("msg").toString())&&!StringUtils.isBlank(postJsonObj.get("code").toString())&&!StringUtils.isBlank(postJsonObj.get("status").toString())){
|
|
if(postJsonObj.get("msg").equals("成功")&&postJsonObj.get("code").toString().equals("1000000")&&postJsonObj.get("status").toString().equals("200")){//status
|
|
//成功
|
|
System.out.println("成功"+(x+1)+",");
|
|
|
|
|
|
/*DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println(jsonObject);
|
|
System.out.println("post:" + post.toString());*/
|
|
|
|
success++;
|
|
}else{
|
|
thisFailFlag = true;
|
|
}
|
|
}else{
|
|
thisFailFlag = true;
|
|
postNoMsgs = true;
|
|
}
|
|
}else{
|
|
postIsNull = true;
|
|
thisFailFlag = true;
|
|
}
|
|
if(thisFailFlag){//异常情况
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = LocalDateTime.now().format(formatter);
|
|
System.out.println(" 当前时间: " + formattedDate); // 示例输出:2025-03-12 08:29:25
|
|
System.out.println("失败"+(x+1)+",断路作业");
|
|
if(!postIsNull){
|
|
System.out.println("post:" + post.toString());
|
|
//XxlJobHelper.log("执行日志:(恒信高科)" + post.toString());
|
|
}
|
|
|
|
System.out.println(jsonObject);
|
|
|
|
fail++;
|
|
Thread.sleep(120000);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
/*XxlJobHelper.log("错误信息:" + e);
|
|
XxlJobHelper.log("请求体:" + jsonObject);*/
|
|
try {
|
|
TimeUnit.MINUTES.sleep(2); // 直接指定分钟
|
|
} catch (InterruptedException ie) {
|
|
Thread.currentThread().interrupt();
|
|
}
|
|
|
|
}
|
|
}else{
|
|
//中碳氢能源
|
|
System.out.println(1);
|
|
}
|
|
|
|
|
|
}
|
|
pageNum++;
|
|
|
|
} while (total > (pageNum - 1) * pageSize);
|
|
|
|
|
|
|
|
|
|
//附件上传
|
|
if (total > 0) {
|
|
return true;
|
|
//XxlJobHelper.log("执行日志:本次有" + total + "条需要上传,成功上传" + success + "条,失败" + fail + "条");
|
|
} else {
|
|
return false;
|
|
//XxlJobHelper.log("执行日志:本次无新数据需上传");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|