update 查改接口添加查改数限制

master
yinq 2 months ago
parent e51186c02c
commit 911ff84ea5

@ -12,9 +12,9 @@ public class ApiConstants {
/**
* IP
*/
public static final String BASE_URL = "http://1.13.177.47/docs/export/";
// public static final String BASE_URL = "http://127.0.0.1:9000/docs/export/";
// public static final String BASE_URL = "http://database.rfidtire.com/docs/export/";
public static final String BASE_URL = "http://1.13.177.47/docs/export/";
/**
* () 6
@ -27,14 +27,15 @@ public class ApiConstants {
public static final Integer TE_LENGTH = 24;
/**
*
*
*/
public static final String IN_CALLBACK_URL = "https://www.kdocs.cn/chatflow/api/v2/func/webhook/2w7TqqdGMqmLwdfQY3wFidcBF4K";
public static final Long CHECK_MAX_DATA = 10000L;
/**
*
*
*/
public static final String OUT_CALLBACK_URL = "https://www.kdocs.cn/chatflow/api/v2/func/webhook/2w7TqqdGMqmLwdfQY3wFidcBF4K";
public static final String CALLBACK_URL = "https://www.kdocs.cn/chatflow/api/v2/func/webhook/2w7TqqdGMqmLwdfQY3wFidcBF4K";//正式
// public static final String CALLBACK_URL = "https://www.kdocs.cn/chatflow/api/v2/func/webhook/2uZIRSpxLvtfaoCjRoLg4EvwIc5";//测试
/**
*
@ -73,17 +74,46 @@ public class ApiConstants {
*/
public static final String DATA_EXPORT = "30";
/** 导入状态 */
/**
*
*/
public static final String DATA_CHECK_REVISE = "40";
/**
*
*/
public static final String IMPORT_STATUS = "导入状态";
public static final String DESCRIPTION = "情况说明";
public static final String STATUS_IMPORTING = "导入中";
public static final String STATUS_SYSTEM_ERROR = "系统错误";
public static final String IMPORT_SUCCESS = "导入成功";
/** 搜索状态 */
/**
*
*/
public static final String SELECT_STATUS = "搜索状态";
/** 导出状态 */
/**
*
*/
public static final String EXPORT_STATUS = "导出状态";
/**
*
*/
public static final String CHECK_STATUS = "查改状态";
/**
*
*/
public static final String UPDATE_FLAG = "!clear!";
/**
*
*/
public static final String IMPORT_TEMPLATE_ONE = "1";//导出再导入模板
public static final String IMPORT_TEMPLATE_TWO = "2";//桌面读写器盘点模板
public static final String IMPORT_TEMPLATE_THREE = "3";//标签模板
public static final String IMPORT_TEMPLATE_FOUR = "4";//写码机写读盘点模板
}

@ -418,6 +418,15 @@ public class KDocsServiceImpl implements IKDocsService {
Map<String, Object> fields = query.getFields();
HwTagRecord selectTagRecord = new HwTagRecord();
// 处理查询结果
int successCount = 0;
int failCount = 0;
List<String> errorMessages = new ArrayList<>();
Map<String, Object> responseFields = new HashMap<>();
response.setFields(responseFields);
result.add(response);
String limitNumber = String.valueOf(fields.getOrDefault("查改数限制", ""));
// 获取更新字段
String upPassword = String.valueOf(fields.getOrDefault("改-密码", ""));
String upOrderCode = String.valueOf(fields.getOrDefault("改-LOT", ""));
@ -502,18 +511,22 @@ public class KDocsServiceImpl implements IKDocsService {
}
// 执行查询
log.info("执行数据库查询 - ID: {}", queryId);
log.info("执行查改数据库查询 - ID: {}", queryId);
long startTime = System.currentTimeMillis();
List<HwTagRecord> tagRecordList = tagRecordService.selectHwTagRecordList(selectTagRecord);
int tagRecordListSize = tagRecordList.size();
long endTime = System.currentTimeMillis();
log.info("数据库查询完成 - ID: {}, 耗时: {}ms, 查询到记录数: {}", queryId, (endTime - startTime), tagRecordListSize);
// 处理查询结果
int successCount = 0;
int failCount = 0;
List<String> errorMessages = new ArrayList<>();
Map<String, Object> responseFields = new HashMap<>();
try {
TagExcelUtil.validateRecordLimit(limitNumber, tagRecordListSize);
} catch (Exception e) {
responseFields.put(ApiConstants.CHECK_STATUS, "查改失败");
responseFields.put(ApiConstants.DESCRIPTION, e.getMessage());
responseFields.put("查改记录数", tagRecordListSize);
return result;
}
for (HwTagRecord tagRecord : tagRecordList) {
try {
@ -554,7 +567,6 @@ public class KDocsServiceImpl implements IKDocsService {
failCount++;
String errorMsg = String.format("更新失败 - TID: %s, 错误: %s", tagRecord.getTId(), e.getMessage());
errorMessages.add(errorMsg);
log.error(errorMsg, e);
}
}
@ -569,9 +581,7 @@ public class KDocsServiceImpl implements IKDocsService {
responseFields.put(ApiConstants.DESCRIPTION, "");
responseFields.put("查改记录数", tagRecordListSize);
}
response.setFields(responseFields);
log.info("查改处理完成 - ID: {}, 成功: {}, 失败: {}", queryId, successCount, failCount);
result.add(response);
}
return result;
}

@ -394,4 +394,36 @@ public class TagExcelUtil {
params.setRemark(String.valueOf(fields.getOrDefault("备注", "")));
return params;
}
/**
*
*
* @param limitRule "<100" "=156"
* @param actualCount
* @throws IllegalArgumentException
*/
public static void validateRecordLimit(String limitRule, int actualCount) {
if (limitRule == null || limitRule.isEmpty()) {
throw new IllegalArgumentException("限制规则不能为空");
}
if (limitRule.startsWith("<")) {
int maxLimit = Integer.parseInt(limitRule.substring(1));
if (actualCount >= maxLimit) {
throw new IllegalArgumentException(
String.format("待修改记录数 %d 超过最大限制 %d", actualCount, maxLimit)
);
}
} else if (limitRule.startsWith("=")) {
int requiredCount = Integer.parseInt(limitRule.substring(1));
if (actualCount != requiredCount) {
throw new IllegalArgumentException(
String.format("待修改记录数必须等于 %d实际为 %d", requiredCount, actualCount)
);
}
} else {
throw new IllegalArgumentException("无效的限制规则格式,示例: '<100' 或 '=156'");
}
}
}
Loading…
Cancel
Save