|
|
|
|
@ -17,6 +17,7 @@ import java.net.http.HttpClient; |
|
|
|
|
import java.net.http.HttpRequest; |
|
|
|
|
import java.net.http.HttpResponse; |
|
|
|
|
import java.time.Duration; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
|
@ -32,7 +33,7 @@ public class IMeasurementRecordsServiceImpl implements IMeasurementRecordsServic |
|
|
|
|
private String limsUrl; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<JSONObject> selectMeasurementRecordsPage(IPage<JSONObject> page, Integer cmType) { |
|
|
|
|
public IPage<MeasurementRecordsEntity> selectMeasurementRecordsPage(IPage<MeasurementRecordsEntity> page, Integer cmType) { |
|
|
|
|
|
|
|
|
|
// 构建请求体JSON
|
|
|
|
|
JSONObject requestBody = buildRequestBody(page, cmType); |
|
|
|
|
@ -55,6 +56,7 @@ public class IMeasurementRecordsServiceImpl implements IMeasurementRecordsServic |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("获取计量记录记录数据接口调用失败: {}", e.getMessage(), e); |
|
|
|
|
List<MeasurementRecordsEntity> entityList1 = new ArrayList<>(); |
|
|
|
|
return page.setRecords(List.of()); // 返回空列表而不是null
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -62,7 +64,7 @@ public class IMeasurementRecordsServiceImpl implements IMeasurementRecordsServic |
|
|
|
|
/** |
|
|
|
|
* 构建请求体 |
|
|
|
|
*/ |
|
|
|
|
private JSONObject buildRequestBody(IPage<JSONObject> page, Integer cmType) { |
|
|
|
|
private JSONObject buildRequestBody(IPage<MeasurementRecordsEntity> page, Integer cmType) { |
|
|
|
|
JSONObject requestBody = new JSONObject(); |
|
|
|
|
requestBody.put("currPage", page.getCurrent()); |
|
|
|
|
requestBody.put("pageSize", page.getSize()); |
|
|
|
|
@ -77,12 +79,224 @@ public class IMeasurementRecordsServiceImpl implements IMeasurementRecordsServic |
|
|
|
|
/** |
|
|
|
|
* 处理HTTP响应 |
|
|
|
|
*/ |
|
|
|
|
private IPage<JSONObject> processResponse(HttpResponse<String> response, IPage<JSONObject> page) { |
|
|
|
|
private IPage<MeasurementRecordsEntity> processResponse(HttpResponse<String> response, IPage<MeasurementRecordsEntity> page) { |
|
|
|
|
if (response.statusCode() != 200) { |
|
|
|
|
log.error("HTTP请求失败,状态码: {}", response.statusCode()); |
|
|
|
|
throw new RuntimeException("HTTP请求失败,状态码: " + response.statusCode()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*String responseBody = "{\n" + |
|
|
|
|
" \"success\": true,\n" + |
|
|
|
|
" \"rows\": [\n" + |
|
|
|
|
" {\n" + |
|
|
|
|
" \"alarmState\": 1,\n" + |
|
|
|
|
" \"assetsCode\": \"LS321295\",\n" + |
|
|
|
|
" \"belong\": \"在用\",\n" + |
|
|
|
|
" \"createdBy\": \"1397884728111006697\",\n" + |
|
|
|
|
" \"createdByName\": \"超级管理员\",\n" + |
|
|
|
|
" \"describe\": \"\",\n" + |
|
|
|
|
" \"deviceName\": \"钢直尺\",\n" + |
|
|
|
|
" \"deviceNameNo\": \"钢直尺 null\",\n" + |
|
|
|
|
" \"deviceSource\": \"市计量所\",\n" + |
|
|
|
|
" \"deviceWhere\": \"\",\n" + |
|
|
|
|
" \"guaranteePeriod\": 0,\n" + |
|
|
|
|
" \"id\": \"20542\",\n" + |
|
|
|
|
" \"isOverDue\": \"4\",\n" + |
|
|
|
|
" \"labId\": \"2\",\n" + |
|
|
|
|
" \"labelNo\": \"长度\",\n" + |
|
|
|
|
" \"model\": \"0-50cm\",\n" + |
|
|
|
|
" \"needDoPage\": false,\n" + |
|
|
|
|
" \"objectCheckState\": 0,\n" + |
|
|
|
|
" \"objectState\": 0,\n" + |
|
|
|
|
" \"serialNo\": \"\",\n" + |
|
|
|
|
" \"startPage\": 1,\n" + |
|
|
|
|
" \"state\": 1,\n" + |
|
|
|
|
" \"str1\": \"1\",\n" + |
|
|
|
|
" \"str10\": \"一次性检定合格\",\n" + |
|
|
|
|
" \"str2\": \"钢直尺\",\n" + |
|
|
|
|
" \"str20\": \"长度外检\",\n" + |
|
|
|
|
" \"str5\": \"\",\n" + |
|
|
|
|
" \"str6\": \"\",\n" + |
|
|
|
|
" \"str7\": \"\",\n" + |
|
|
|
|
" \"str8\": \"JJG1钢直尺检定规程\",\n" + |
|
|
|
|
" \"str9\": \"\",\n" + |
|
|
|
|
" \"unit\": \"C\",\n" + |
|
|
|
|
" \"verificationCycle\": 1,\n" + |
|
|
|
|
" \"verifyState\": 0,\n" + |
|
|
|
|
" \"whenAccept\": 1464105600000,\n" + |
|
|
|
|
" \"workGuideNo\": \"热表分厂\",\n" + |
|
|
|
|
" \"total\": \"3809\",\n" + |
|
|
|
|
" \"isOverStr\": \"正常\"\n" + |
|
|
|
|
" },\n" + |
|
|
|
|
" {\n" + |
|
|
|
|
" \"alarmState\": 1,\n" + |
|
|
|
|
" \"assetsCode\": \"LS321294\",\n" + |
|
|
|
|
" \"belong\": \"在用\",\n" + |
|
|
|
|
" \"createdBy\": \"1397884728111006697\",\n" + |
|
|
|
|
" \"createdByName\": \"超级管理员\",\n" + |
|
|
|
|
" \"describe\": \"\",\n" + |
|
|
|
|
" \"deviceName\": \"钢直尺\",\n" + |
|
|
|
|
" \"deviceNameNo\": \"钢直尺 null\",\n" + |
|
|
|
|
" \"deviceSource\": \"市计量所\",\n" + |
|
|
|
|
" \"deviceWhere\": \"\",\n" + |
|
|
|
|
" \"guaranteePeriod\": 0,\n" + |
|
|
|
|
" \"id\": \"20606\",\n" + |
|
|
|
|
" \"isOverDue\": \"4\",\n" + |
|
|
|
|
" \"labId\": \"2\",\n" + |
|
|
|
|
" \"labelNo\": \"长度\",\n" + |
|
|
|
|
" \"model\": \"0-30cm\",\n" + |
|
|
|
|
" \"needDoPage\": false,\n" + |
|
|
|
|
" \"objectCheckState\": 0,\n" + |
|
|
|
|
" \"objectState\": 0,\n" + |
|
|
|
|
" \"serialNo\": \"\",\n" + |
|
|
|
|
" \"startPage\": 1,\n" + |
|
|
|
|
" \"state\": 1,\n" + |
|
|
|
|
" \"str1\": \"1\",\n" + |
|
|
|
|
" \"str10\": \"一次性检定合格\",\n" + |
|
|
|
|
" \"str2\": \"钢直尺\",\n" + |
|
|
|
|
" \"str20\": \"长度外检\",\n" + |
|
|
|
|
" \"str5\": \"\",\n" + |
|
|
|
|
" \"str6\": \"\",\n" + |
|
|
|
|
" \"str7\": \"\",\n" + |
|
|
|
|
" \"str8\": \"JJG1钢直尺检定规程\",\n" + |
|
|
|
|
" \"str9\": \"\",\n" + |
|
|
|
|
" \"unit\": \"C\",\n" + |
|
|
|
|
" \"verificationCycle\": 1,\n" + |
|
|
|
|
" \"verifyState\": 0,\n" + |
|
|
|
|
" \"whenAccept\": 1464105600000,\n" + |
|
|
|
|
" \"workGuideNo\": \"热表分厂\",\n" + |
|
|
|
|
" \"total\": \"3809\",\n" + |
|
|
|
|
" \"isOverStr\": \"正常\"\n" + |
|
|
|
|
" },\n" + |
|
|
|
|
" {\n" + |
|
|
|
|
" \"alarmState\": 1,\n" + |
|
|
|
|
" \"assetsCode\": \"LS321296\",\n" + |
|
|
|
|
" \"belong\": \"在用\",\n" + |
|
|
|
|
" \"createdBy\": \"1397884728111006697\",\n" + |
|
|
|
|
" \"createdByName\": \"超级管理员\",\n" + |
|
|
|
|
" \"describe\": \"\",\n" + |
|
|
|
|
" \"deviceName\": \"钢直尺\",\n" + |
|
|
|
|
" \"deviceNameNo\": \"钢直尺 null\",\n" + |
|
|
|
|
" \"deviceSource\": \"市计量所\",\n" + |
|
|
|
|
" \"deviceWhere\": \"\",\n" + |
|
|
|
|
" \"guaranteePeriod\": 0,\n" + |
|
|
|
|
" \"id\": \"22798\",\n" + |
|
|
|
|
" \"isOverDue\": \"4\",\n" + |
|
|
|
|
" \"labId\": \"2\",\n" + |
|
|
|
|
" \"labelNo\": \"长度\",\n" + |
|
|
|
|
" \"model\": \"0-50cm\",\n" + |
|
|
|
|
" \"needDoPage\": false,\n" + |
|
|
|
|
" \"objectCheckState\": 0,\n" + |
|
|
|
|
" \"objectState\": 0,\n" + |
|
|
|
|
" \"serialNo\": \"\",\n" + |
|
|
|
|
" \"startPage\": 1,\n" + |
|
|
|
|
" \"state\": 1,\n" + |
|
|
|
|
" \"str1\": \"1\",\n" + |
|
|
|
|
" \"str10\": \"一次性检定合格\",\n" + |
|
|
|
|
" \"str2\": \"钢直尺\",\n" + |
|
|
|
|
" \"str20\": \"长度外检\",\n" + |
|
|
|
|
" \"str5\": \"\",\n" + |
|
|
|
|
" \"str6\": \"\",\n" + |
|
|
|
|
" \"str7\": \"\",\n" + |
|
|
|
|
" \"str8\": \"\",\n" + |
|
|
|
|
" \"str9\": \"\",\n" + |
|
|
|
|
" \"unit\": \"C\",\n" + |
|
|
|
|
" \"verificationCycle\": 1,\n" + |
|
|
|
|
" \"verifyState\": 0,\n" + |
|
|
|
|
" \"whenAccept\": 1464105600000,\n" + |
|
|
|
|
" \"workGuideNo\": \"热表分厂\",\n" + |
|
|
|
|
" \"total\": \"3809\",\n" + |
|
|
|
|
" \"isOverStr\": \"正常\"\n" + |
|
|
|
|
" },\n" + |
|
|
|
|
" {\n" + |
|
|
|
|
" \"alarmState\": 1,\n" + |
|
|
|
|
" \"assetsCode\": \"LS321296\",\n" + |
|
|
|
|
" \"belong\": \"在用\",\n" + |
|
|
|
|
" \"createdBy\": \"1397884728111006697\",\n" + |
|
|
|
|
" \"createdByName\": \"超级管理员\",\n" + |
|
|
|
|
" \"describe\": \"\",\n" + |
|
|
|
|
" \"deviceName\": \"钢直尺\",\n" + |
|
|
|
|
" \"deviceNameNo\": \"钢直尺 null\",\n" + |
|
|
|
|
" \"deviceSource\": \"市计量所\",\n" + |
|
|
|
|
" \"deviceWhere\": \"\",\n" + |
|
|
|
|
" \"guaranteePeriod\": 0,\n" + |
|
|
|
|
" \"id\": \"23798\",\n" + |
|
|
|
|
" \"isOverDue\": \"4\",\n" + |
|
|
|
|
" \"labId\": \"2\",\n" + |
|
|
|
|
" \"labelNo\": \"长度\",\n" + |
|
|
|
|
" \"model\": \"0-50cm\",\n" + |
|
|
|
|
" \"needDoPage\": false,\n" + |
|
|
|
|
" \"objectCheckState\": 0,\n" + |
|
|
|
|
" \"objectState\": 0,\n" + |
|
|
|
|
" \"serialNo\": \"\",\n" + |
|
|
|
|
" \"startPage\": 1,\n" + |
|
|
|
|
" \"state\": 1,\n" + |
|
|
|
|
" \"str1\": \"1\",\n" + |
|
|
|
|
" \"str10\": \"一次性检定合格\",\n" + |
|
|
|
|
" \"str2\": \"钢直尺\",\n" + |
|
|
|
|
" \"str20\": \"长度外检\",\n" + |
|
|
|
|
" \"str5\": \"\",\n" + |
|
|
|
|
" \"str6\": \"\",\n" + |
|
|
|
|
" \"str7\": \"\",\n" + |
|
|
|
|
" \"str8\": \"\",\n" + |
|
|
|
|
" \"str9\": \"\",\n" + |
|
|
|
|
" \"unit\": \"C\",\n" + |
|
|
|
|
" \"verificationCycle\": 1,\n" + |
|
|
|
|
" \"verifyState\": 0,\n" + |
|
|
|
|
" \"whenAccept\": 1464105600000,\n" + |
|
|
|
|
" \"workGuideNo\": \"热表分厂\",\n" + |
|
|
|
|
" \"total\": \"3809\",\n" + |
|
|
|
|
" \"isOverStr\": \"正常\"\n" + |
|
|
|
|
" },{\n" + |
|
|
|
|
" \"alarmState\": 1,\n" + |
|
|
|
|
" \"assetsCode\": \"YQ202512057\",\n" + |
|
|
|
|
" \"belong\": \"在用\",\n" + |
|
|
|
|
" \"createdBy\": \"1413079875727655913\",\n" + |
|
|
|
|
" \"createdByName\": \"张曼\",\n" + |
|
|
|
|
" \"date1\": 1795708800000,\n" + |
|
|
|
|
" \"describe\": \"±5%\",\n" + |
|
|
|
|
" \"deviceName\": \"磁导率测试仪\",\n" + |
|
|
|
|
" \"deviceNameNo\": \"磁导率测试仪 null\",\n" + |
|
|
|
|
" \"deviceSource\": \"FOERSTER\",\n" + |
|
|
|
|
" \"deviceWhere\": \"FOERSTER\",\n" + |
|
|
|
|
" \"guaranteePeriod\": 12,\n" + |
|
|
|
|
" \"id\": \"1527021013731116009\",\n" + |
|
|
|
|
" \"isOverDue\": \"0\",\n" + |
|
|
|
|
" \"labId\": \"2\",\n" + |
|
|
|
|
" \"labelNo\": \"电学\",\n" + |
|
|
|
|
" \"model\": \"MAGNETOSCOP1.070\",\n" + |
|
|
|
|
" \"modifiedBy\": \"1413079875727655913\",\n" + |
|
|
|
|
" \"modifiedByName\": \"张曼\",\n" + |
|
|
|
|
" \"needDoPage\": false,\n" + |
|
|
|
|
" \"objectCheckState\": 0,\n" + |
|
|
|
|
" \"objectState\": 0,\n" + |
|
|
|
|
" \"serialNo\": \"17175\",\n" + |
|
|
|
|
" \"startPage\": 1,\n" + |
|
|
|
|
" \"state\": 1,\n" + |
|
|
|
|
" \"str1\": \"1\",\n" + |
|
|
|
|
" \"str12\": \"1413079875727655913,1413079965921969129\",\n" + |
|
|
|
|
" \"str13\": \"张曼,高佳璇\",\n" + |
|
|
|
|
" \"str2\": \"磁导率测试仪\",\n" + |
|
|
|
|
" \"str20\": \"电学\",\n" + |
|
|
|
|
" \"str5\": \"1.068/1.069\",\n" + |
|
|
|
|
" \"str6\": \"\",\n" + |
|
|
|
|
" \"str8\": \"厂家检测报告\",\n" + |
|
|
|
|
" \"unit\": \"B\",\n" + |
|
|
|
|
" \"verificationCycle\": 1,\n" + |
|
|
|
|
" \"verifyState\": 0,\n" + |
|
|
|
|
" \"whenAccept\": 1764259200000,\n" + |
|
|
|
|
" \"whenCreated\": 1768448919000,\n" + |
|
|
|
|
" \"whenModified\": 1768448919000,\n" + |
|
|
|
|
" \"whenUse\": 1764259200000,\n" + |
|
|
|
|
" \"workGuideNo\": \"热表分厂\",\n" + |
|
|
|
|
" \"total\": \"3809\",\n" + |
|
|
|
|
" \"isOverStr\": \"正常\"\n" + |
|
|
|
|
" }\n" + |
|
|
|
|
" ],\n" + |
|
|
|
|
" \"total\": \"3809\",\n" + |
|
|
|
|
" \"recordsTotal\": \"3809\",\n" + |
|
|
|
|
" \"recordsFiltered\": \"3809\"\n" + |
|
|
|
|
"}";*/ |
|
|
|
|
String responseBody = response.body(); |
|
|
|
|
if (responseBody == null || responseBody.trim().isEmpty()) { |
|
|
|
|
log.error("响应体为空"); |
|
|
|
|
@ -92,11 +306,43 @@ public class IMeasurementRecordsServiceImpl implements IMeasurementRecordsServic |
|
|
|
|
try { |
|
|
|
|
JSONObject result = JSONObject.parseObject(responseBody); |
|
|
|
|
if (result != null && result.getBoolean("success")) { |
|
|
|
|
JSONObject data = result.getJSONObject("data"); |
|
|
|
|
JSONArray data = result.getJSONArray("rows"); |
|
|
|
|
if (data != null) { |
|
|
|
|
List<JSONObject> records = JSONArray.parseArray(data.toJSONString(), JSONObject.class); |
|
|
|
|
log.info("成功获取{}条计量记录记录", records != null ? records.size() : 0); |
|
|
|
|
return page.setRecords(records != null ? records : List.of()); |
|
|
|
|
MeasurementRecordsEntity measurementRecordsEntity; |
|
|
|
|
List<MeasurementRecordsEntity> list = new ArrayList<>(); |
|
|
|
|
for (JSONObject jsonObj : records) { |
|
|
|
|
measurementRecordsEntity = new MeasurementRecordsEntity(); |
|
|
|
|
measurementRecordsEntity.setMcName(jsonObj.getString("deviceName")); |
|
|
|
|
measurementRecordsEntity.setNorms(jsonObj.getString("model")); |
|
|
|
|
measurementRecordsEntity.setMcClass(jsonObj.getString("unit")); |
|
|
|
|
measurementRecordsEntity.setLabelNo(jsonObj.getString("labelNo")); |
|
|
|
|
measurementRecordsEntity.setStr2(jsonObj.getString("str2")); |
|
|
|
|
measurementRecordsEntity.setMcCode(jsonObj.getString("assetsCode")); |
|
|
|
|
measurementRecordsEntity.setUseUnit(jsonObj.getString("workGuideNo")); |
|
|
|
|
measurementRecordsEntity.setAccuracy(jsonObj.getString("describe")); |
|
|
|
|
measurementRecordsEntity.setOemCode(jsonObj.getString("serialNo")); |
|
|
|
|
measurementRecordsEntity.setMcOem(jsonObj.getString("deviceWhere")); |
|
|
|
|
measurementRecordsEntity.setEnableDate(jsonObj.getDate("whenUse")); |
|
|
|
|
measurementRecordsEntity.setWhenDccept(jsonObj.getString("whenDccept")); |
|
|
|
|
measurementRecordsEntity.setMcType(jsonObj.getString("str5")); |
|
|
|
|
measurementRecordsEntity.setTestCycle(jsonObj.getInteger("guaranteePeriod")); |
|
|
|
|
measurementRecordsEntity.setDueDate(jsonObj.getDate("date1")); |
|
|
|
|
measurementRecordsEntity.setDate2(jsonObj.getDate("date2")); |
|
|
|
|
measurementRecordsEntity.setBelong(jsonObj.getString("belong")); |
|
|
|
|
measurementRecordsEntity.setWhenBuy(jsonObj.getDate("whenBuy")); |
|
|
|
|
measurementRecordsEntity.setTestDept(jsonObj.getString("deviceSource")); |
|
|
|
|
measurementRecordsEntity.setTestMethod(jsonObj.getString("str8")); |
|
|
|
|
measurementRecordsEntity.setStr9(jsonObj.getString("str9")); |
|
|
|
|
measurementRecordsEntity.setStr10(jsonObj.getString("str10")); |
|
|
|
|
measurementRecordsEntity.setAssetsNo(jsonObj.getString("assetsNo")); |
|
|
|
|
measurementRecordsEntity.setStr6(jsonObj.getString("str6")); |
|
|
|
|
measurementRecordsEntity.setPurposeClass(jsonObj.getString("str7")); |
|
|
|
|
measurementRecordsEntity.setIsOverStr(jsonObj.getString("isOverStr")); |
|
|
|
|
list.add(measurementRecordsEntity); |
|
|
|
|
} |
|
|
|
|
return page.setRecords(list != null ? list : List.of()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
String errorMsg = result != null ? result.getString("message") : "未知错误"; |
|
|
|
|
|