|
|
|
@ -78,7 +78,7 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
resContent.setFields(result.getFields());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("导入任务执行失败: {}", e.getMessage(), e);
|
|
|
|
|
Map<String, String> errorFields = new HashMap<>();
|
|
|
|
|
Map<String, Object> errorFields = new HashMap<>();
|
|
|
|
|
errorFields.put(ApiConstants.IMPORT_STATUS, "系统错误");
|
|
|
|
|
errorFields.put(ApiConstants.DESCRIPTION, "导入任务执行失败: " + e.getMessage());
|
|
|
|
|
resContent.setFields(errorFields);
|
|
|
|
@ -102,7 +102,7 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
List<ApiContent> resApiContentList = new ArrayList<>();
|
|
|
|
|
for (ApiContent apiContent : contentList) {
|
|
|
|
|
// 创建初始响应
|
|
|
|
|
Map<String, String> resFields = new HashMap<>();
|
|
|
|
|
Map<String, Object> resFields = new HashMap<>();
|
|
|
|
|
resFields.put(ApiConstants.IMPORT_STATUS, "导入中");
|
|
|
|
|
resFields.put(ApiConstants.DESCRIPTION, "后台处理中");
|
|
|
|
|
ApiContent responseContent = new ApiContent();
|
|
|
|
@ -120,12 +120,12 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
* @return 处理后的ApiContent对象
|
|
|
|
|
*/
|
|
|
|
|
public ApiContent importData(ApiContent apiContent) {
|
|
|
|
|
Map<String, String> fields = apiContent.getFields();
|
|
|
|
|
String importMode = fields.get("导入模式");
|
|
|
|
|
String model = fields.getOrDefault("型号", "");
|
|
|
|
|
String fileUrl = fields.get("文件链接");
|
|
|
|
|
Map<String, Object> fields = apiContent.getFields();
|
|
|
|
|
String importMode = String.valueOf(fields.get("导入模式"));
|
|
|
|
|
String model = String.valueOf(fields.getOrDefault("型号", ""));
|
|
|
|
|
String fileUrl = String.valueOf(fields.get("文件链接"));
|
|
|
|
|
List<HwTagRecord> batchList = new ArrayList<>();
|
|
|
|
|
Map<String, String> resFields = new HashMap<>();
|
|
|
|
|
Map<String, Object> resFields = new HashMap<>();
|
|
|
|
|
apiContent.setFields(resFields);
|
|
|
|
|
try {
|
|
|
|
|
log.info("开始处理文件,URL: {}", fileUrl);
|
|
|
|
@ -160,6 +160,7 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
record.setBatchNumber(orderInfo.get("batchNo"));
|
|
|
|
|
record.setOperatorId(orderInfo.get("operatorId"));
|
|
|
|
|
record.setProcessingTime(sdf.parse(orderInfo.get("processTime")));
|
|
|
|
|
record.setTotalQuantity(Long.valueOf(orderInfo.get("totalCount")));
|
|
|
|
|
// 设置标签数据
|
|
|
|
|
record.setModelCode(model);
|
|
|
|
|
record.setTagSequence(tagData.get("序号"));
|
|
|
|
@ -176,8 +177,13 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
tagRecordService.updateHwTagRecordByTID(record);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 添加到批处理列表
|
|
|
|
|
//校验tId唯一
|
|
|
|
|
HwTagRecord tagRecord = tagRecordService.selectHwTagRecordByTID(record.gettId());
|
|
|
|
|
if (tagRecord != null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
record.setrId(IdGenerator.nextId());
|
|
|
|
|
// 添加到批处理列表
|
|
|
|
|
batchList.add(record);
|
|
|
|
|
if (batchList.size() >= BATCH_SIZE) {
|
|
|
|
|
tagRecordService.batchInsertHwTagRecord(batchList);
|
|
|
|
@ -221,21 +227,107 @@ public class KDocsServiceImpl implements IKDocsService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String deleteData(String id) {
|
|
|
|
|
// TODO: 实现数据删除逻辑
|
|
|
|
|
return getSystemStatus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String queryData(String query) {
|
|
|
|
|
// TODO: 实现数据查询逻辑
|
|
|
|
|
return getSystemStatus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String exportData(String query) {
|
|
|
|
|
// TODO: 实现数据导出逻辑
|
|
|
|
|
return getSystemStatus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询数据
|
|
|
|
|
*
|
|
|
|
|
* @param content 查询条件列表
|
|
|
|
|
* @return 查询结果列表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<ApiContent> queryDataList(List<ApiContent> content) {
|
|
|
|
|
List<ApiContent> result = new ArrayList<>();
|
|
|
|
|
if (content == null || content.isEmpty()) {
|
|
|
|
|
log.warn("查询条件列表为空");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("开始处理查询请求,查询条件数量: {}", content.size());
|
|
|
|
|
for (ApiContent query : content) {
|
|
|
|
|
String queryId = query.getId();
|
|
|
|
|
log.info("处理查询条件 ID: {}, 查询参数: {}", queryId, query.getFields());
|
|
|
|
|
|
|
|
|
|
ApiContent response = new ApiContent();
|
|
|
|
|
response.setId(queryId);
|
|
|
|
|
response.setFields(new HashMap<>());
|
|
|
|
|
Map<String, Object> fields = query.getFields();
|
|
|
|
|
HwTagRecord selectTagRecord = new HwTagRecord();
|
|
|
|
|
|
|
|
|
|
// 检查查询条件
|
|
|
|
|
if (!fields.containsKey("TID") && !fields.containsKey("EPC")) {
|
|
|
|
|
log.warn("查询条件错误 - ID: {}, 缺少必要的查询参数(TID或EPC)", queryId);
|
|
|
|
|
response.getFields().put("搜索状态", "查询条件错误");
|
|
|
|
|
response.getFields().put("情况说明", "查询条件必须包含TID或EPC");
|
|
|
|
|
result.add(response);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置查询条件
|
|
|
|
|
if (fields.containsKey("TID")) {
|
|
|
|
|
String tid = (String) fields.get("TID");
|
|
|
|
|
selectTagRecord.settId(tid);
|
|
|
|
|
}
|
|
|
|
|
if (fields.containsKey("EPC")) {
|
|
|
|
|
String epc = (String) fields.get("EPC");
|
|
|
|
|
selectTagRecord.setEpc(epc);
|
|
|
|
|
}
|
|
|
|
|
if (fields.containsKey("搜索日期起点")) {
|
|
|
|
|
String startDate = (String) fields.get("搜索日期起点");
|
|
|
|
|
selectTagRecord.setStartDate(startDate);
|
|
|
|
|
}
|
|
|
|
|
if (fields.containsKey("搜索日期终点")) {
|
|
|
|
|
String endDate = (String) fields.get("搜索日期终点");
|
|
|
|
|
selectTagRecord.setEndDate(endDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 执行查询
|
|
|
|
|
log.info("执行数据库查询 - ID: {}", queryId);
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
HwTagRecord data = tagRecordService.selectHwTagRecordData(selectTagRecord);
|
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
|
|
log.info("数据库查询完成 - ID: {}, 耗时: {}ms", queryId, (endTime - startTime));
|
|
|
|
|
|
|
|
|
|
// 处理查询结果
|
|
|
|
|
if (data != null) {
|
|
|
|
|
log.info("查询成功 - ID: {}, TID: {}, EPC: {}", queryId, data.gettId(), data.getEpc());
|
|
|
|
|
// 查询成功
|
|
|
|
|
response.getFields().put("搜索状态", "搜索成功");
|
|
|
|
|
response.getFields().put("TID", data.gettId());
|
|
|
|
|
response.getFields().put("EPC", data.getEpc());
|
|
|
|
|
response.getFields().put("标签序号", data.getTagSequence());
|
|
|
|
|
response.getFields().put("密码", data.getPassword() != null ? data.getPassword() : "");
|
|
|
|
|
response.getFields().put("RID", data.getrId());
|
|
|
|
|
response.getFields().put("LOT", data.getOrderCode());
|
|
|
|
|
response.getFields().put("卷编号", data.getBatchNumber());
|
|
|
|
|
response.getFields().put("本卷数量", data.getTotalQuantity() != null ? data.getTotalQuantity() : "");
|
|
|
|
|
response.getFields().put("标签批次号", data.getTagBatch() != null ? data.getTagBatch() : "");
|
|
|
|
|
response.getFields().put("型号", data.getModelCode() != null ? data.getModelCode() : "");
|
|
|
|
|
response.getFields().put("加工时间", new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(data.getProcessingTime()));
|
|
|
|
|
response.getFields().put("生产人员编号", data.getOperatorId());
|
|
|
|
|
log.debug("查询结果详情 - ID: {}, 结果: {}", queryId, response.getFields());
|
|
|
|
|
} else {
|
|
|
|
|
log.info("未找到记录 - ID: {}", queryId);
|
|
|
|
|
// 未找到记录
|
|
|
|
|
response.getFields().put("搜索状态", "未找到记录");
|
|
|
|
|
if (fields.containsKey("搜索日期起点") && fields.containsKey("搜索日期终点")) {
|
|
|
|
|
String message = String.format("已遍历整个数据库,生产日期从%s到%s,未查询到该TID。",
|
|
|
|
|
fields.get("搜索日期起点"), fields.get("搜索日期终点"));
|
|
|
|
|
response.getFields().put("情况说明", message);
|
|
|
|
|
log.debug("未找到记录详情 - ID: {}, 日期范围: {} - {}",
|
|
|
|
|
queryId, fields.get("搜索日期起点"), fields.get("搜索日期终点"));
|
|
|
|
|
} else {
|
|
|
|
|
response.getFields().put("情况说明", "未找到匹配的记录");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.add(response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|