main
HuangHai 1 month ago
parent ba99a799fa
commit 49b87f30c7

@ -15,19 +15,15 @@ import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import io.github.yedaxia.apidocs.ApiDoc;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.IndexedColors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@ApiDoc
public class MetaDataController extends Controller {
//实例化model
MetaDataModel metaDataModel = new MetaDataModel();
@ -42,10 +38,6 @@ public class MetaDataController extends Controller {
@Before({GET.class})
@IsNumericInterface({"task_id"})
public void downloadDataTemplate(int task_id) throws Exception{
HttpServletRequest request = getRequest();
HttpServletResponse response = getResponse();
JSONObject result = new JSONObject();
String templatePath = CommonUtil.getClassPath() +
@ -66,10 +58,20 @@ public class MetaDataController extends Controller {
JSONObject titleObject = new JSONObject();
titleObject.put("task_id",task_id);
titleObject.put("template","metadataTemplate");
HSSFRow firstRow = sheet.createRow(0);
firstRow.setHeight((short) 0);
HSSFCell firstCell = firstRow.createCell(0);
firstCell.setCellValue(titleObject.toString());
HSSFRow firstRow = null;
if (sheet != null) {
firstRow = sheet.createRow(0);
}
if (firstRow != null) {
firstRow.setHeight((short) 0);
}
HSSFCell firstCell = null;
if (firstRow != null) {
firstCell = firstRow.createCell(0);
}
if (firstCell != null) {
firstCell.setCellValue(titleObject.toString());
}
// 空白单元格样式
HSSFCellStyle dataCellStyle = ImportExcelController.createCellColorStyle(workbook, IndexedColors.WHITE.getIndex());
@ -77,7 +79,7 @@ public class MetaDataController extends Controller {
metaDataModel.handleSheetData(sheetTable1, dataCellStyle);
metaDataModel.handleSheetData(sheetTable2, dataCellStyle);
ImportExcelController.downloadExcel(request, response, workbook, "元数据信息导入模板",false);
ImportExcelController.downloadExcel(getResponse(),workbook, "元数据信息导入模板",false);
renderNull();
}
@ -91,8 +93,7 @@ public class MetaDataController extends Controller {
*/
@Before({POST.class})
@IsNumericInterface({"task_id","system_id"})
public void importDataTemplate(int task_id, int system_id) throws URISyntaxException, ParseException {
public void importDataTemplate(int task_id, int system_id) throws ParseException {
//操作人
Record rPerson = JwtUtil.getPersonInfo(getRequest());
String person_id = rPerson.getStr("person_id");
@ -161,8 +162,6 @@ public class MetaDataController extends Controller {
JSONObject importToDBResult = metaDataModel.importMetadataToDB(dataMap, columns, task_id, system_id, supplier_id, person_id, bureau_id);
renderJson(importToDBResult);
return;
}
@ -183,7 +182,7 @@ public class MetaDataController extends Controller {
String bureau_id = rPerson.getStr("bureau_id");
Page<Record> dt;
if (system_name == null || "".equals(system_name)) {
if (system_name == null || system_name.isEmpty()) {
dt = metaDataModel.getSystemList(bureau_id, page, limit);
} else {
dt = metaDataModel.getSystemListBySystemName(bureau_id, page, limit, system_name);
@ -235,7 +234,7 @@ public class MetaDataController extends Controller {
@Before({GET.class})
@IsNumericInterface({"id"})
public void getSystemById(int id) {
Record record = new Record();
Record record;
try {
record = metaDataModel.getSystemInfoBySystemId(id);
if (record != null) {
@ -301,7 +300,7 @@ public class MetaDataController extends Controller {
String bureau_id = rPerson.getStr("bureau_id");
Page<Record> dt;
if (supplier_name == null || "".equals(supplier_name)) {
if (supplier_name == null || supplier_name.isEmpty()) {
dt = metaDataModel.getSupplierList(bureau_id, page, limit);
} else {
dt = metaDataModel.getSupplierListBySupplierName(bureau_id, page, limit, supplier_name);
@ -337,10 +336,10 @@ public class MetaDataController extends Controller {
renderJson(resultJson);
return;
}
if (supplier_info_json == null || "".equals(supplier_info_json)) {
if (supplier_info_json == null || supplier_info_json.isEmpty()) {
supplier_info_json = "{}";
}
if (contact_person_json == null || "".equals(contact_person_json)) {
if (contact_person_json == null || contact_person_json.isEmpty()) {
contact_person_json = "{}";
}
// 供应商基本信息
@ -393,7 +392,7 @@ public class MetaDataController extends Controller {
@Before({GET.class})
@IsNumericInterface({"id"})
public void getSupplierById(int id) {
Record record = new Record();
Record record;
try {
record = metaDataModel.getSupplierInfoBySupplierId(id);
if (record != null) {
@ -459,7 +458,7 @@ public class MetaDataController extends Controller {
String bureau_id = rPerson.getStr("bureau_id");
Page<Record> dt;
if (task_name == null || "".equals(task_name)) {
if (task_name == null || task_name.isEmpty()) {
dt = metaDataModel.getTaskList(bureau_id, page, limit);
} else {
dt = metaDataModel.getTaskListByTaskName(bureau_id, page, limit, task_name);
@ -508,7 +507,7 @@ public class MetaDataController extends Controller {
@Before({GET.class})
@IsNumericInterface({"id"})
public void getTaskById(int id) {
Record record = new Record();
Record record;
try {
record = metaDataModel.getTaskInfoByTaskId(id);
if (record != null) {
@ -662,7 +661,7 @@ public class MetaDataController extends Controller {
int supplier_id = supplierRecord.getInt("id");
Page<Record> dt;
if (task_name == null || "".equals(task_name)) {
if (task_name == null || task_name.isEmpty()) {
dt = metaDataModel.getSupplierTaskList(bureau_id, supplier_id, page, limit);
} else {
dt = metaDataModel.getSupplierTaskListByTaskName(bureau_id, supplier_id, page, limit, task_name);
@ -955,26 +954,4 @@ public class MetaDataController extends Controller {
renderJson(result);
}
/**
* MetaData-Task-Collect-9-
* Kalman.CHENG
* 2025/6/18 14:44
*
**/
/*@Before({GET.class})
@IsNumericInterface({"task_id", "supplier_id"})
@EmptyInterface({"task_id"})
public void exportTaskCollectTableColumn(int task_id, int supplier_id) {
// supplier_id 为0的时候表示管理员导出整个任务的数据 不为0的时候表示供应商自己导出自己
JSONObject result = metaDataModel.createExportTaskInfo(task_id, supplier_id);
}*/
}

@ -270,42 +270,6 @@ public class MetaDataModel {
}
/**
* excel
* Kalman.CHENG
* 2025-06-09
*
*/
/*public JSONObject importMetadataTemplate(File file, int task_id, int supplier_id, int system_id, String person_id, String bureau_id) {
final JSONObject[] importResult = {new JSONObject()};
final String[] db_tx_error = {""};
boolean db_tx_flag = Db.tx(new IAtom() {
public boolean run() throws SQLException {
boolean rtn = true;
try {
} catch (Exception e) {
e.printStackTrace();
db_tx_error[0] = e.getMessage();
rtn = false;
}
return rtn;
}
});
if (!db_tx_flag){
if ("".equals(importResult[0].getString("message"))) {
importResult[0].put("message", db_tx_error[0]);
}
importResult[0].put("success", false);
}
return importResult[0];
}*/
/**
* metaData

@ -5,7 +5,7 @@ import com.jfinal.core.Controller;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
@ -35,7 +35,7 @@ public class ImportExcelController extends Controller {
}
public static void downloadExcel(HttpServletRequest request, HttpServletResponse response, HSSFWorkbook workbook, String fileName, Boolean addCurdate) throws IOException {
public static void downloadExcel(HttpServletResponse response, HSSFWorkbook workbook, String fileName, Boolean addCurdate) throws IOException {
if (workbook != null){
OutputStream out = null;
try {

Loading…
Cancel
Save