269 lines
8.0 KiB
Java
269 lines
8.0 KiB
Java
package com.example.sso.controller;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.example.sso.dao.FuZhi;
|
|
import com.example.sso.util.TimeUtil;
|
|
import com.example.sso.util.V5utils;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
|
|
@Component
|
|
public class ShengJiDingWei {
|
|
@Scheduled(cron = "0 0 10 * * ?")
|
|
public void shengji() throws IOException {
|
|
String riqi = TimeUtil.riqi();
|
|
|
|
|
|
DataFormatter formatter = new DataFormatter(); // 统一格式化工具
|
|
|
|
String desktopPath = System.getProperty("user.home") + "/Desktop/";
|
|
|
|
// 要移动的Excel文件名
|
|
String fileName = "省际定位报备名单" + riqi + ".xlsx";
|
|
FuZhi.fuzhi(fileName);
|
|
String excelFilePath = desktopPath + fileName;
|
|
|
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
|
|
|
FileInputStream inputStream = new FileInputStream(new File(excelFilePath));
|
|
|
|
Workbook workbook = WorkbookFactory.create(inputStream);
|
|
Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
|
|
|
// 迭代行(从第二行开始,因为第一行通常是标题)
|
|
for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
|
|
Row row = sheet.getRow(rowIndex);
|
|
if (row != null) {
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
// 读取每列数据
|
|
Cell cell = row.getCell(0);
|
|
String dingdanhao = new DataFormatter().formatCellValue(cell);
|
|
jsonObject.put("dingdanhao", dingdanhao);
|
|
|
|
|
|
|
|
|
|
String dingdanleixing = row.getCell(1).getStringCellValue();
|
|
jsonObject.put("dingdanleixing", dingdanleixing);
|
|
|
|
String qiyemingcheng = row.getCell(2).getStringCellValue();
|
|
jsonObject.put("qiyemingcheng", qiyemingcheng);
|
|
|
|
String chepaihaoma = row.getCell(3).getStringCellValue();
|
|
jsonObject.put("chepaihaoma", chepaihaoma);
|
|
|
|
|
|
|
|
|
|
Cell cell1 = row.getCell(4);
|
|
String biaozhipaihao = new DataFormatter().formatCellValue(cell1);
|
|
jsonObject.put("biaozhipaihao", biaozhipaihao);
|
|
|
|
String Zhujiashiyuanxingming = row.getCell(5).getStringCellValue();
|
|
jsonObject.put("Zhujiashiyuanxingming", Zhujiashiyuanxingming);
|
|
|
|
Cell cell2 = row.getCell(6);
|
|
String Zhujiashiyuandianhua = new DataFormatter().formatCellValue(cell2);
|
|
jsonObject.put("Zhujiashiyuandianhua", Zhujiashiyuandianhua);
|
|
|
|
|
|
String dingdanzhuangtai = row.getCell(7).getStringCellValue();
|
|
jsonObject.put("dingdanzhuangtai", dingdanzhuangtai);
|
|
|
|
String cheliangdiaoduzhuangtai = row.getCell(8).getStringCellValue();
|
|
jsonObject.put("cheliangdiaoduzhuangtai", cheliangdiaoduzhuangtai);
|
|
|
|
|
|
String youxiaoqizi = row.getCell(9).getStringCellValue();
|
|
jsonObject.put("youxiaoqizi", youxiaoqizi);
|
|
|
|
String youxiaoqizhi = row.getCell(10).getStringCellValue();
|
|
jsonObject.put("youxiaoqizhi", youxiaoqizhi);
|
|
|
|
String chengcheqidian = row.getCell(11).getStringCellValue();
|
|
jsonObject.put("chengcheqidian", chengcheqidian);
|
|
|
|
String chengqidian = row.getCell(12).getStringCellValue();
|
|
jsonObject.put("chengqidian", chengqidian);
|
|
|
|
|
|
|
|
|
|
jsonArray.add(jsonObject);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
workbook.close();
|
|
|
|
|
|
JSONArray datasall = new JSONArray();
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("app_id", "667cc6dbaa923599ad735201");
|
|
jsonObject.put("entry_id", "681d6ad347f52adcb2b5d853");
|
|
jsonObject.put("is_start_trigger", true);
|
|
|
|
if (jsonArray.size() > 0) {
|
|
|
|
|
|
for (Object o : jsonArray) {
|
|
JSONObject te = (JSONObject) o;
|
|
String dingdanhao = te.getString("dingdanhao");
|
|
String dingdanleixing = te.getString("dingdanleixing");
|
|
String qiyemingcheng = te.getString("qiyemingcheng");
|
|
|
|
String chepaihaoma = te.getString("chepaihaoma");
|
|
|
|
String biaozhipaihao = te.getString("biaozhipaihao");
|
|
|
|
|
|
|
|
|
|
String Zhujiashiyuanxingming = te.getString("Zhujiashiyuanxingming");
|
|
String Zhujiashiyuandianhua = te.getString("Zhujiashiyuandianhua");
|
|
String dingdanzhuangtai = te.getString("dingdanzhuangtai");
|
|
String cheliangdiaoduzhuangtai = te.getString("cheliangdiaoduzhuangtai");
|
|
String youxiaoqizi = te.getString("youxiaoqizi");
|
|
String youxiaoqizhi = te.getString("youxiaoqizhi");
|
|
String chengcheqidian = te.getString("chengcheqidian");
|
|
String chengqidian = te.getString("chengqidian");
|
|
|
|
|
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
JSONObject dingdanhao1 = new JSONObject();
|
|
dingdanhao1.put("value", dingdanhao);
|
|
data.put("dingdanhao", dingdanhao1);
|
|
|
|
JSONObject dingdanleixing1 = new JSONObject();
|
|
dingdanleixing1.put("value", dingdanleixing);
|
|
data.put("dingdanleixing", dingdanleixing1);
|
|
|
|
JSONObject qiyemingcheng1 = new JSONObject();
|
|
qiyemingcheng1.put("value", qiyemingcheng);
|
|
data.put("qiyemingcheng", qiyemingcheng1);
|
|
|
|
JSONObject chepaihaoma1 = new JSONObject();
|
|
chepaihaoma1.put("value", chepaihaoma);
|
|
data.put("chepaihaoma", chepaihaoma1);
|
|
|
|
|
|
JSONObject biaozhipaihao1 = new JSONObject();
|
|
biaozhipaihao1.put("value", biaozhipaihao);
|
|
data.put("biaozhipaihao", biaozhipaihao1);
|
|
|
|
|
|
JSONObject Zhujiashiyuanxingming1 = new JSONObject();
|
|
Zhujiashiyuanxingming1.put("value", Zhujiashiyuanxingming);
|
|
data.put("zhujiashiyuanxingming", Zhujiashiyuanxingming1);
|
|
|
|
JSONObject Zhujiashiyuandianhua1 = new JSONObject();
|
|
Zhujiashiyuandianhua1.put("value", Zhujiashiyuandianhua);
|
|
data.put("zhujiashiyuandianhua", Zhujiashiyuandianhua1);
|
|
|
|
JSONObject dingdanzhuangtai1 = new JSONObject();
|
|
dingdanzhuangtai1.put("value", dingdanzhuangtai);
|
|
data.put("dingdanzhuangtai", dingdanzhuangtai1);
|
|
|
|
JSONObject cheliangdiaoduzhuangtai1 = new JSONObject();
|
|
cheliangdiaoduzhuangtai1.put("value", cheliangdiaoduzhuangtai);
|
|
data.put("cheliangdiaoduzhuangtai", cheliangdiaoduzhuangtai1);
|
|
|
|
JSONObject youxiaoqizi1 = new JSONObject();
|
|
youxiaoqizi1.put("value", youxiaoqizi);
|
|
data.put("youxiaoqizi", youxiaoqizi1);
|
|
|
|
JSONObject youxiaoqizhi1 = new JSONObject();
|
|
youxiaoqizhi1.put("value", youxiaoqizhi);
|
|
data.put("youxiaoqizhi", youxiaoqizhi1);
|
|
|
|
JSONObject chengcheqidian1 = new JSONObject();
|
|
chengcheqidian1.put("value", chengcheqidian);
|
|
data.put("chengcheqidian", chengcheqidian1);
|
|
|
|
JSONObject chengqidian1 = new JSONObject();
|
|
chengqidian1.put("value", chengqidian);
|
|
data.put("chengqidian", chengqidian1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
datasall.add(data);
|
|
if (datasall.size() == 100) {
|
|
jsonObject.put("data_list", datasall);
|
|
String jsonString = jsonObject.toJSONString();
|
|
V5utils.adds(jsonString);
|
|
datasall = new JSONArray();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
jsonObject.put("data_list", datasall);
|
|
String jsonString = jsonObject.toJSONString();
|
|
// log.info("我是参数+++ " + jsonString);
|
|
|
|
V5utils.adds(jsonString);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|