|
|
|
@ -79,7 +79,7 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 发送处理结果到回调接口
|
|
|
|
|
httpClientUtils.sendResultToCallback(resList, ApiConstants.IN_CALLBACK_URL, ApiConstants.DATA_IMPORT);
|
|
|
|
|
httpClientUtils.sendResultToCallback(resList, ApiConstants.CALLBACK_URL, ApiConstants.DATA_IMPORT);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return resApiContentList;
|
|
|
|
@ -149,12 +149,12 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
String epc = (String) fields.get("EPC");
|
|
|
|
|
selectTagRecord.setEpc(epc);
|
|
|
|
|
}
|
|
|
|
|
if (fields.containsKey("搜索日期起点")) {
|
|
|
|
|
String startDate = (String) fields.get("搜索日期起点");
|
|
|
|
|
if (fields.containsKey("筛选日期起点")) {
|
|
|
|
|
String startDate = (String) fields.get("筛选日期起点");
|
|
|
|
|
selectTagRecord.setStartDate(startDate);
|
|
|
|
|
}
|
|
|
|
|
if (fields.containsKey("搜索日期终点")) {
|
|
|
|
|
String endDate = (String) fields.get("搜索日期终点");
|
|
|
|
|
if (fields.containsKey("筛选日期终点")) {
|
|
|
|
|
String endDate = (String) fields.get("筛选日期终点");
|
|
|
|
|
selectTagRecord.setEndDate(endDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -169,7 +169,7 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
if (data != null) {
|
|
|
|
|
log.info("查询成功 - ID: {}, TID: {}, EPC: {}", queryId, data.getTId(), data.getEpc());
|
|
|
|
|
// 查询成功
|
|
|
|
|
if (data.getQueryResultsNumber() > 1){
|
|
|
|
|
if (data.getQueryResultsNumber() > 1) {
|
|
|
|
|
response.getFields().put(ApiConstants.SELECT_STATUS, "系统错误");
|
|
|
|
|
response.getFields().put(ApiConstants.DESCRIPTION, "存在多个记录,请使用数据导出功能");
|
|
|
|
|
} else {
|
|
|
|
@ -196,12 +196,12 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
log.info("未找到记录 - ID: {}", queryId);
|
|
|
|
|
// 未找到记录
|
|
|
|
|
response.getFields().put(ApiConstants.SELECT_STATUS, "未找到记录");
|
|
|
|
|
if (fields.containsKey("搜索日期起点") && fields.containsKey("搜索日期终点")) {
|
|
|
|
|
if (fields.containsKey("筛选日期起点") && fields.containsKey("筛选日期终点")) {
|
|
|
|
|
String message = String.format("已遍历整个数据库,生产日期从%s到%s,未找到匹配的记录。",
|
|
|
|
|
fields.get("搜索日期起点"), fields.get("搜索日期终点"));
|
|
|
|
|
fields.get("筛选日期起点"), fields.get("筛选日期终点"));
|
|
|
|
|
response.getFields().put(ApiConstants.DESCRIPTION, message);
|
|
|
|
|
log.debug("未找到记录详情 - ID: {}, 日期范围: {} - {}",
|
|
|
|
|
queryId, fields.get("搜索日期起点"), fields.get("搜索日期终点"));
|
|
|
|
|
queryId, fields.get("筛选日期起点"), fields.get("筛选日期终点"));
|
|
|
|
|
} else {
|
|
|
|
|
response.getFields().put(ApiConstants.DESCRIPTION, "未找到匹配的记录");
|
|
|
|
|
}
|
|
|
|
@ -241,19 +241,24 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
// 异步执行导出任务
|
|
|
|
|
executorService.execute(() -> {
|
|
|
|
|
List<ApiContent> resApiContentList = new ArrayList<>();
|
|
|
|
|
Date nowDate = new Date();
|
|
|
|
|
for (ApiContent condition : content) {
|
|
|
|
|
ApiContent response = new ApiContent();
|
|
|
|
|
response.setId(condition.getId());
|
|
|
|
|
try {
|
|
|
|
|
Map<String, Object> fields = condition.getFields();
|
|
|
|
|
String lot = fields.get("LOT") != null ? (String) fields.get("LOT") : "";
|
|
|
|
|
String startDate = fields.get("导出日期起点") != null ? (String) fields.get("导出日期起点") : "";
|
|
|
|
|
String endDate = fields.get("导出日期终点") != null ? (String) fields.get("导出日期终点") : "";
|
|
|
|
|
String tagBatch = fields.get("标签批次号") != null ? (String) fields.get("标签批次号") : "";
|
|
|
|
|
String batchNumber = fields.get("卷编号") != null ? (String) fields.get("卷编号") : "";
|
|
|
|
|
String modelCode = fields.get("型号") != null ? (String) fields.get("型号") : "";
|
|
|
|
|
String startDate = fields.get("筛选日期起点") != null ? (String) fields.get("筛选日期起点") : "";
|
|
|
|
|
String endDate = fields.get("筛选日期终点") != null ? (String) fields.get("筛选日期终点") : "";
|
|
|
|
|
String TID = fields.get("TID") != null ? (String) fields.get("TID") : "";
|
|
|
|
|
String EPC = fields.get("EPC") != null ? (String) fields.get("EPC") : "";
|
|
|
|
|
String remark = fields.get("备注") != null ? (String) fields.get("备注") : "";
|
|
|
|
|
String lot = fields.get("LOT") != null ? (String) fields.get("LOT") : "";
|
|
|
|
|
String tagBatch = fields.get("标签批次号") != null ? (String) fields.get("标签批次号") : "";
|
|
|
|
|
String modelCode = fields.get("型号") != null ? (String) fields.get("型号") : "";
|
|
|
|
|
String destinationInfo = fields.get("去向信息") != null ? (String) fields.get("去向信息") : "";
|
|
|
|
|
String libraryFlag = fields.get("是否在库") != null ? (String) fields.get("是否在库") : "";
|
|
|
|
|
String intendedUse = fields.get("计划用途") != null ? (String) fields.get("计划用途") : "";
|
|
|
|
|
String batchNumber = fields.get("卷编号") != null ? (String) fields.get("卷编号") : "";
|
|
|
|
|
|
|
|
|
|
// 构建查询条件
|
|
|
|
|
HwTagRecord queryCondition = new HwTagRecord();
|
|
|
|
@ -269,9 +274,6 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
if (StringUtils.hasText(tagBatch)) {
|
|
|
|
|
queryCondition.setTagBatch(tagBatch);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(batchNumber)) {
|
|
|
|
|
queryCondition.setBatchNumber(batchNumber);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(modelCode)) {
|
|
|
|
|
queryCondition.setModelCode(modelCode);
|
|
|
|
|
}
|
|
|
|
@ -281,24 +283,55 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
if (StringUtils.hasText(EPC)) {
|
|
|
|
|
queryCondition.setSelectEPC(EPC);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(remark)) {
|
|
|
|
|
queryCondition.setRemark(remark);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(destinationInfo)) {
|
|
|
|
|
queryCondition.setDestinationInfo(destinationInfo);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(libraryFlag)) {
|
|
|
|
|
queryCondition.setLibraryFlag(libraryFlag);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(intendedUse)) {
|
|
|
|
|
queryCondition.setIntendedUse(intendedUse);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(batchNumber) && !batchNumber.contains("-")) {
|
|
|
|
|
queryCondition.setBatchNumber(batchNumber);
|
|
|
|
|
} else if (StringUtils.hasText(batchNumber) && batchNumber.contains("-")) {
|
|
|
|
|
List<String> batchNumberList = TagExcelUtil.splitHorizontalBarString(batchNumber);
|
|
|
|
|
queryCondition.setBatchNumberList(batchNumberList);
|
|
|
|
|
}
|
|
|
|
|
// 执行查询
|
|
|
|
|
log.info("执行数据导出查询 - ID: {}", condition.getId());
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
List<HwTagRecord> records = tagRecordService.selectHwTagRecordList(queryCondition);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> responseFields = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
if (records != null && !records.isEmpty()) {
|
|
|
|
|
try {
|
|
|
|
|
String fileName = String.format("标签数据_%s.xlsx", condition.getId());
|
|
|
|
|
SimpleDateFormat sDate = new SimpleDateFormat("yyyyMMdd-HHmm");
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
//组装数据
|
|
|
|
|
records.get(0).setTeamCenter("导出时间");
|
|
|
|
|
records.get(0).setDatabaseExport(sdf.format(nowDate));
|
|
|
|
|
int classNum = 0;
|
|
|
|
|
for (String string : fields.keySet()) {
|
|
|
|
|
classNum++;
|
|
|
|
|
if (records.size() <= classNum) {
|
|
|
|
|
records.add(new HwTagRecord());
|
|
|
|
|
}
|
|
|
|
|
records.get(classNum).setTeamCenter(string);
|
|
|
|
|
records.get(classNum).setDatabaseExport(String.valueOf(fields.get(string)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String fileName = String.format("团队中心-标签数据总库导出-%s.xlsx", sDate.format(nowDate));
|
|
|
|
|
String filePath = TagExcelUtil.generateTagExcel(records, fileName);
|
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
|
|
Duration duration = Duration.ofMillis(endTime - startTime);
|
|
|
|
|
long minutes = duration.toMinutes();
|
|
|
|
|
long seconds = duration.minusMinutes(minutes).getSeconds();
|
|
|
|
|
Date futureDate = new Date(endTime + ApiConstants.PASS_TIME);
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
|
|
|
log.info("数据库导出完成 - ID: {}, 记录数: {}, 耗时: {}分{}秒", condition.getId(), records.size(), minutes, seconds);
|
|
|
|
|
responseFields.put(ApiConstants.EXPORT_STATUS, "导出成功");
|
|
|
|
|
responseFields.put(ApiConstants.DESCRIPTION, "耗时: " + minutes + "分" + seconds + "秒");
|
|
|
|
@ -316,7 +349,6 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response.setFields(responseFields);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("处理导出任务失败 - ID: {}", condition.getId(), e);
|
|
|
|
|
response.setId(condition.getId());
|
|
|
|
@ -329,7 +361,7 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
resApiContentList.add(response);
|
|
|
|
|
}
|
|
|
|
|
// 发送处理结果到回调接口
|
|
|
|
|
httpClientUtils.sendResultToCallback(resApiContentList, ApiConstants.OUT_CALLBACK_URL, ApiConstants.DATA_EXPORT);
|
|
|
|
|
httpClientUtils.sendResultToCallback(resApiContentList, ApiConstants.CALLBACK_URL, ApiConstants.DATA_EXPORT);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|