From adf182f1d993e494df76158a921e70d6ab36d2d0 Mon Sep 17 00:00:00 2001 From: "ZHOUZ\\Noble'lift" <1014987728@qq.com> Date: Sat, 9 Jul 2022 23:14:56 +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 --- .../nl/pda/sb/rest/SparePartController.java | 21 +++++ .../nl/pda/sb/service/SparePartService.java | 6 ++ .../sb/service/impl/SparePartServiceImpl.java | 78 +++++++++++++++++++ .../org/nl/pda/sb/wql/QPDAEM_BI_SPAREPART.wql | 23 ++++++ 4 files changed, 128 insertions(+) diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/rest/SparePartController.java b/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/rest/SparePartController.java index f99bb0e9..4ee5305d 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/rest/SparePartController.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/rest/SparePartController.java @@ -151,4 +151,25 @@ public class SparePartController { public ResponseEntity queryDevice(@RequestBody Map whereJson) { return new ResponseEntity<>(sparePartService.queryDevice(whereJson),HttpStatus.OK); } + + @PostMapping("/queryRunRecord") + @Log("运行记录查询") + @ApiOperation("运行记录查询") + public ResponseEntity queryRunRecord(@RequestBody Map whereJson) { + return new ResponseEntity<>(sparePartService.queryRunRecord(whereJson),HttpStatus.OK); + } + + @PostMapping("/calculate") + @Log("计算") + @ApiOperation("计算") + public ResponseEntity calculate(@RequestBody Map whereJson) { + return new ResponseEntity<>(sparePartService.calculate(whereJson),HttpStatus.OK); + } + + @PostMapping("/save") + @Log("保存") + @ApiOperation("保存") + public ResponseEntity save(@RequestBody Map whereJson) { + return new ResponseEntity<>(sparePartService.save(whereJson),HttpStatus.OK); + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/service/SparePartService.java b/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/service/SparePartService.java index b8ba9379..211eb92f 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/service/SparePartService.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/service/SparePartService.java @@ -45,5 +45,11 @@ public interface SparePartService { Map queryDevice(Map jsonObject); + Map queryRunRecord(Map jsonObject); + + Map calculate(Map jsonObject); + + Map save(Map jsonObject); + Map repairs(Map map, HttpServletRequest request); } 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 e060c598..d62c4d71 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 @@ -45,6 +45,7 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -706,6 +707,83 @@ public class SparePartServiceImpl implements SparePartService { return returnjo; } + @Override + public Map queryRunRecord(Map jsonObject) { + if (ObjectUtil.isEmpty(jsonObject)) { + throw new PdaRequestException("传入参数不能为空!"); + } + 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); + JSONObject returnjo = new JSONObject(); + returnjo.put("code", "1"); + returnjo.put("content", content); + returnjo.put("desc", "操作成功!"); + return returnjo; + } + + @Override + public Map calculate(Map jsonObject) { + if (ObjectUtil.isEmpty(jsonObject)) { + throw new PdaRequestException("传入参数不能为空!"); + } + JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject)); + + JSONObject jsonFile = WQLObject.getWQLObject("EM_BI_EquipmentFile").query("device_code = '" + jo.getString("device_code") + "'").uniqueResult(0); + + double run_times = jo.getDoubleValue("run_times"); //生产时间 + double prepare_times = jo.getDoubleValue("prepare_times");//准备时间 + double error_times = jo.getDoubleValue("error_times"); //故障时间 + double adjust_times = jo.getDoubleValue("adjust_times"); //工装调整时间 + double product_qty = jo.getDoubleValue("product_qty"); //生产总量 + double nok_qty = jo.getDoubleValue("nok_qty"); //不合格数 + double theory_beat = jsonFile.getDoubleValue("theory_beat"); // 理论节拍 + + JSONObject content = new JSONObject(); + // 计算OEE指标 + try { + 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)); + content.put("oee_value", oee_value); + } catch (Exception e) { + content.put("oee_value", 0); + } + + JSONObject returnjo = new JSONObject(); + returnjo.put("code", "1"); + returnjo.put("content", content); + returnjo.put("desc", "操作成功!"); + return returnjo; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public Map save(Map jsonObject) { + if (ObjectUtil.isEmpty(jsonObject)) { + throw new PdaRequestException("传入参数不能为空!"); + } + JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject)); + + 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)){ + throw new PdaRequestException("设备不存在!"); + } + + 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.isEmpty(run)){ + + } + + JSONObject returnjo = new JSONObject(); + returnjo.put("code", "1"); + returnjo.put("desc", "操作成功!"); + return returnjo; + } + @Transactional(rollbackFor = Exception.class) @Override public Map repairs(Map map, HttpServletRequest request) { diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/wql/QPDAEM_BI_SPAREPART.wql b/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/wql/QPDAEM_BI_SPAREPART.wql index ba5af20e..4c37348f 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/wql/QPDAEM_BI_SPAREPART.wql +++ b/mes/hd/nladmin-system/src/main/java/org/nl/pda/sb/wql/QPDAEM_BI_SPAREPART.wql @@ -244,5 +244,28 @@ ENDQUERY ENDIF + IF 输入.flag = "7" + QUERY + SELECT + file.device_code, + run.run_times, + run.prepare_times, + run.error_times, + run.adjust_times, + run.product_qty, + run.nok_qty, + run.oee_value + FROM + em_bi_equipmentfile file + LEFT JOIN em_bi_devicerunrecord run ON run.devicerecord_id = file.devicerecord_id + WHERE + file.is_delete = '0' + OPTION 输入.device_code <> "" + file.device_code = 输入.device_code + ENDOPTION + ENDSELECT + ENDQUERY + ENDIF +