From 8e77ee7aaa2f1a2cd59cc54fdced76881935c462 Mon Sep 17 00:00:00 2001 From: "ZHOUZ\\Noble'lift" <1014987728@qq.com> Date: Fri, 15 Jul 2022 14:21:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sb/service/impl/SparePartServiceImpl.java | 27 ++++++++++++------- .../impl/DevicerunrecordServiceImpl.java | 1 - 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/service/impl/SparePartServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/service/impl/SparePartServiceImpl.java index a0e12d6c..7eb74fd2 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/service/impl/SparePartServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/service/impl/SparePartServiceImpl.java @@ -530,11 +530,16 @@ public class SparePartServiceImpl implements SparePartService { map.put("flag", "6"); map.put("maintenance_flag", maintenance_flag); map.put("device_code", device_code); - JSONObject rows = WQL.getWO("QPDAEM_BI_SPAREPART").addParamMap(map).process().uniqueResult(0); + JSONArray rows = WQL.getWO("QPDAEM_BI_SPAREPART").addParamMap(map).process().getResultJSONArray(0); + if (ObjectUtil.isEmpty(rows)) { + rows = new JSONArray(); + } + JSONObject content = new JSONObject(); + content.put("rows",rows); JSONObject returnjo = new JSONObject(); returnjo.put("code", "1"); - returnjo.put("rows", rows); + returnjo.put("content", content); returnjo.put("desc", "操作成功!"); return returnjo; } @@ -715,8 +720,8 @@ public class SparePartServiceImpl implements SparePartService { JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject)); String device_code = jo.getString("device_code"); - JSONObject content = WQL.getWO("QPDAEM_BI_SPAREPART").addParam("flag","7").addParam("device_code",device_code).process().uniqueResult(0); - if (ObjectUtil.isEmpty(content)){ + JSONObject content = WQL.getWO("QPDAEM_BI_SPAREPART").addParam("flag", "7").addParam("device_code", device_code).process().uniqueResult(0); + if (ObjectUtil.isEmpty(content)) { throw new PdaRequestException("未查询到相关设备信息!"); } JSONObject returnjo = new JSONObject(); @@ -750,6 +755,7 @@ public class SparePartServiceImpl implements SparePartService { BigDecimal div = NumberUtil.div(NumberUtil.sub(run_times, prepare_times, error_times, adjust_times), NumberUtil.sub(run_times, prepare_times, adjust_times)); BigDecimal div1 = NumberUtil.div(NumberUtil.mul(div, theory_beat, product_qty), NumberUtil.sub(run_times, prepare_times, error_times, adjust_times)); BigDecimal oee_value = NumberUtil.mul(div1, NumberUtil.div(NumberUtil.sub(product_qty, nok_qty), product_qty)); + oee_value = NumberUtil.round(oee_value, 3); content.put("oee_value", oee_value); } catch (Exception e) { content.put("oee_value", 0); @@ -768,12 +774,13 @@ public class SparePartServiceImpl implements SparePartService { if (ObjectUtil.isEmpty(jsonObject)) { throw new PdaRequestException("传入参数不能为空!"); } - JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject)); + JSONObject form = JSONObject.parseObject(JSON.toJSONString(jsonObject)); + JSONObject jo = form.getJSONObject("form"); String device_code = jo.getString("device_code"); JSONObject jsonFile = WQLObject.getWQLObject("EM_BI_EquipmentFile").query("device_code = '" + jo.getString("device_code") + "' AND is_delete = '0' AND status IN (10,11,20,30,40)").uniqueResult(0); - if (ObjectUtil.isEmpty(jsonFile)){ + if (ObjectUtil.isEmpty(jsonFile)) { throw new PdaRequestException("设备不存在!"); } @@ -790,9 +797,9 @@ public class SparePartServiceImpl implements SparePartService { double oee_value = jo.getDoubleValue("oee_value"); //不合格数 double theory_beat = jsonFile.getDoubleValue("theory_beat"); // 理论节拍 - JSONObject run = WQLObject.getWQLObject("EM_BI_DeviceRunRecord").query("devicerecord_id = '"+jsonFile.getString("devicerecord_id")+"' AND run_date = '"+jo.getString("run_date")+"'").uniqueResult(0); + JSONObject run = WQLObject.getWQLObject("EM_BI_DeviceRunRecord").query("devicerecord_id = '" + jsonFile.getString("devicerecord_id") + "' AND run_date = '" + jo.getString("run_date") + "'").uniqueResult(0); - if (ObjectUtil.isNotEmpty(run)){ + if (ObjectUtil.isNotEmpty(run)) { run.put("run_date", run_date); run.put("run_times", run_times); run.put("prepare_times", prepare_times); @@ -802,9 +809,9 @@ public class SparePartServiceImpl implements SparePartService { run.put("nok_qty", nok_qty); run.put("oee_value", oee_value); WQLObject.getWQLObject("EM_BI_DeviceRunRecord").update(run); - }else { + } else { JSONObject json = new JSONObject(); - json.put("runrecord_id", IdUtil.getSnowflake(1,1).nextId()); + json.put("runrecord_id", IdUtil.getSnowflake(1, 1).nextId()); json.put("devicerecord_id", jsonFile.get("devicerecord_id")); json.put("run_date", run_date); json.put("run_times", run_times); diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/run/service/impl/DevicerunrecordServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/run/service/impl/DevicerunrecordServiceImpl.java index 622b9848..71cf4b7d 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/run/service/impl/DevicerunrecordServiceImpl.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/run/service/impl/DevicerunrecordServiceImpl.java @@ -183,7 +183,6 @@ public class DevicerunrecordServiceImpl implements DevicerunrecordService { json.put("oee_value", oee_value); } catch (Exception e) { json.put("oee_value", 0); - tab.insert(json); } tab.update(json); }