代码更新

This commit is contained in:
2022-09-29 10:48:52 +08:00
parent 2b53710d83
commit 91263261be
10 changed files with 103 additions and 15 deletions

View File

@@ -62,6 +62,7 @@
WHERE
mst.is_delete = '0'
AND file.is_delete = '0'
AND ISNULL(MST.is_passed)
OPTION 输入.device_code <> ""
(file.device_code like 输入.device_code or

View File

@@ -75,14 +75,43 @@ public class DevicefaultcaeServiceImpl implements DevicefaultcaeService {
}
JSONObject json = WQL.getWO("EM_DEVICEFAULTCAE01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "re.devicerecord_id DESC");
// 处理平均故障间隔时间 && 平均故障修复时间
WQLObject tab = WQLObject.getWQLObject("EM_BI_DeviceRepairRequest");
/* // 处理平均故障间隔时间 && 平均故障修复时间
WQLObject tab = WQLObject.getWQLObject("EM_BI_DeviceRepairRequest");*/
JSONArray content = json.getJSONArray("content");
for (int i = 0; i < content.size(); i++) {
JSONObject jsonObject = content.getJSONObject(i);
String devicerecord_id = jsonObject.getString("devicerecord_id");
JSONArray arr = tab.query("devicerecord_id = '" + devicerecord_id + "' and is_delete = '0'").getResultJSONArray(0);
/*
* 平均故障间隔时间:运行时间/故障次数(运行时间查运行记录表,故障次数查报修单)
* 平均故障修复时间:故障时间/故障次数(故障时间查运行记录表)
*/
// 根据此设备查询运行记录表计算 运行时间和故障时间
map.put("flag", "4");
map.put("devicerecord_id", devicerecord_id);
JSONObject runAndErr_time = WQL.getWO("EM_DEVICEFAULTCAE01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(runAndErr_time)) {
String run_times = runAndErr_time.getString("run_times"); // 运行时间
String error_times = runAndErr_time.getString("error_times"); // 故障时间时间
String error_num = jsonObject.getString("nunm"); // 故障次数
try {
// 计算平均故障间隔时间
String avgVal_time = NumberUtil.div(NumberUtil.div(run_times, error_num).toString(), "60").toString();
jsonObject.put("avgVal_time",NumberUtil.round(avgVal_time,2).toString());
} catch (Exception e) {
jsonObject.put("avgVal_time","0");
}
try {
// 平均故障修复时间
String avgRep_time = NumberUtil.div(NumberUtil.div(error_times, error_num).toString(), "60").toString();
jsonObject.put("avgRep_time",NumberUtil.round(avgRep_time,2).toString());
} catch (Exception e) {
jsonObject.put("avgRep_time","0");
}
}
/*JSONArray arr = tab.query("devicerecord_id = '" + devicerecord_id + "' and is_delete = '0'").getResultJSONArray(0);
// 计算平均故障修复时间
String nunm = jsonObject.getString("nunm");
String create_time_all = "0";
@@ -114,7 +143,7 @@ public class DevicefaultcaeServiceImpl implements DevicefaultcaeService {
BigDecimal add = NumberUtil.add(NumberUtil.sub(re_end_time, re_begin_time).toString(), "1");
BigDecimal avgVal_time = NumberUtil.div(NumberUtil.mul(add, 24).toString(), nunm);
jsonObject.put("avgVal_time",avgVal_time.toString());
jsonObject.put("avgVal_time",avgVal_time.toString());*/
}
json.put("content",content);
return json;

View File

@@ -144,6 +144,34 @@
WHERE
is_delete = '0'
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
SUM(re.run_times) AS run_times,
SUM(re.error_times) AS error_times
FROM
EM_BI_DeviceRunRecord re
WHERE
1=1
OPTION 输入.devicerecord_id <> ""
re.devicerecord_id = 输入.devicerecord_id
ENDOPTION
OPTION 输入.begin_time <> ""
re.run_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
re.run_date <= 输入.end_time
ENDOPTION
group by re.devicerecord_id
ENDSELECT
ENDQUERY
ENDIF