From 5b73689fddccb8da5a9d66cbc1ee27e65f217276 Mon Sep 17 00:00:00 2001 From: liuxy Date: Wed, 29 Jun 2022 17:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=95=88=E7=8E=87OEE?= =?UTF-8?q?=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DevicerunrecordServiceImpl.java | 44 ++++- .../sb/stat/rest/DeviceooestatController.java | 42 +++++ .../sb/stat/service/DeviceooestatService.java | 28 +++ .../impl/DeviceooestatServiceImpl.java | 59 ++++++ .../wms/sb/stat/wql/EM_DEVICEOOESTAT001.wql | 90 ++++++++++ mes/qd/src/api/wms/sb/deviceooestat.js | 27 +++ .../wms/sb/run/devicerunrecord/index.vue | 12 +- .../views/wms/sb/stat/deviceooestat/index.vue | 170 ++++++++++++++++++ 8 files changed, 465 insertions(+), 7 deletions(-) create mode 100644 mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/rest/DeviceooestatController.java create mode 100644 mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/service/DeviceooestatService.java create mode 100644 mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/service/impl/DeviceooestatServiceImpl.java create mode 100644 mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/wql/EM_DEVICEOOESTAT001.wql create mode 100644 mes/qd/src/api/wms/sb/deviceooestat.js create mode 100644 mes/qd/src/views/wms/sb/stat/deviceooestat/index.vue 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 9f02bba8..c55b328f 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 @@ -3,6 +3,7 @@ package org.nl.wms.sb.run.service.impl; import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import lombok.RequiredArgsConstructor; @@ -16,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Pageable; +import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -108,6 +110,16 @@ public class DevicerunrecordServiceImpl implements DevicerunrecordService { String devicerecord_id = whereJson.getString("devicerecord_id"); String run_date = whereJson.getString("run_date"); + JSONObject jsonFile = WQLObject.getWQLObject("EM_BI_EquipmentFile").query("devicerecord_id = '" + devicerecord_id + "'").uniqueResult(0); + + double run_times = whereJson.getDoubleValue("run_times"); //生产时间 + double prepare_times = whereJson.getDoubleValue("prepare_times");//准备时间 + double error_times = whereJson.getDoubleValue("error_times"); //故障时间 + double adjust_times = whereJson.getDoubleValue("adjust_times"); //工装调整时间 + double product_qty = whereJson.getDoubleValue("product_qty"); //生产总量 + double nok_qty = whereJson.getDoubleValue("nok_qty"); //不合格数 + double theory_beat = jsonFile.getDoubleValue("theory_beat"); // 理论节拍 + JSONObject jsonMst = tab.query("devicerecord_id = '" + devicerecord_id + "' and run_date = '" + run_date + "'").uniqueResult(0); if (ObjectUtil.isNotEmpty(jsonMst)) throw new BadRequestException("填报信息已存在"); @@ -121,11 +133,20 @@ public class DevicerunrecordServiceImpl implements DevicerunrecordService { json.put("adjust_times", whereJson.get("adjust_times")); json.put("product_qty", whereJson.get("product_qty")); json.put("nok_qty", whereJson.get("nok_qty")); - json.put("oee_value", 0.0); json.put("remark", whereJson.getString("remark")); json.put("create_id", currentUserId); json.put("create_name", nickName); json.put("create_time", now); + // 计算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)); + json.put("oee_value", oee_value); + } catch (Exception e) { + json.put("oee_value", 0); + tab.insert(json); + } tab.insert(json); } @@ -133,6 +154,17 @@ public class DevicerunrecordServiceImpl implements DevicerunrecordService { @Transactional(rollbackFor = Exception.class) public void update(JSONObject whereJson) { WQLObject tab = WQLObject.getWQLObject("EM_BI_DeviceRunRecord"); + String devicerecord_id = whereJson.getString("devicerecord_id"); + + JSONObject jsonFile = WQLObject.getWQLObject("EM_BI_EquipmentFile").query("devicerecord_id = '" + devicerecord_id + "'").uniqueResult(0); + + double run_times = whereJson.getDoubleValue("run_times"); //生产时间 + double prepare_times = whereJson.getDoubleValue("prepare_times");//准备时间 + double error_times = whereJson.getDoubleValue("error_times"); //故障时间 + double adjust_times = whereJson.getDoubleValue("adjust_times"); //工装调整时间 + double product_qty = whereJson.getDoubleValue("product_qty"); //生产总量 + double nok_qty = whereJson.getDoubleValue("nok_qty"); //不合格数 + double theory_beat = jsonFile.getDoubleValue("theory_beat"); // 理论节拍 JSONObject json = tab.query("runrecord_id = '" + whereJson.getString("runrecord_id") + "'").uniqueResult(0); json.put("run_date", whereJson.getString("run_date")); @@ -144,6 +176,16 @@ public class DevicerunrecordServiceImpl implements DevicerunrecordService { json.put("nok_qty", whereJson.get("nok_qty")); json.put("oee_value", 0); json.put("remark", whereJson.getString("remark")); + // 计算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)); + json.put("oee_value", oee_value); + } catch (Exception e) { + json.put("oee_value", 0); + tab.insert(json); + } tab.update(json); } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/rest/DeviceooestatController.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/rest/DeviceooestatController.java new file mode 100644 index 00000000..b446650c --- /dev/null +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/rest/DeviceooestatController.java @@ -0,0 +1,42 @@ + +package org.nl.wms.sb.stat.rest; + + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.annotation.Log; +import org.nl.wms.sb.stat.service.DeviceooestatService; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * @author Liuxy + * @date 2022-06-28 + **/ +@RestController +@RequiredArgsConstructor +@Api(tags = "设备OEE指标分析") +@RequestMapping("/api/deviceooestat") +@Slf4j +public class DeviceooestatController { + + private final DeviceooestatService deviceooestatService; + + @GetMapping + @Log("设备OEE指标分析查询") + @ApiOperation("设备OEE指标分析查询") + //@PreAuthorize("@el.check('devicesparepartivt:list')") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { + return new ResponseEntity<>(deviceooestatService.queryAll(whereJson, page), HttpStatus.OK); + } + +} diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/service/DeviceooestatService.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/service/DeviceooestatService.java new file mode 100644 index 00000000..4297cc3d --- /dev/null +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/service/DeviceooestatService.java @@ -0,0 +1,28 @@ + +package org.nl.wms.sb.stat.service; + +import org.nl.wms.sb.stat.service.dto.DevicesparepartivtDto; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * @author Liuxy + * @description 服务接口 + * @date 2022-06-28 + **/ +public interface DeviceooestatService { + + /** + * 查询数据分页 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map queryAll(Map whereJson, Pageable page); + +} diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/service/impl/DeviceooestatServiceImpl.java b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/service/impl/DeviceooestatServiceImpl.java new file mode 100644 index 00000000..209f456b --- /dev/null +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/service/impl/DeviceooestatServiceImpl.java @@ -0,0 +1,59 @@ + +package org.nl.wms.sb.stat.service.impl; + + +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.wms.basedata.master.service.ClassstandardService; +import org.nl.wms.sb.stat.service.DeviceooestatService; +import org.nl.wql.WQL; +import org.nl.wql.util.WqlUtil; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Liuxy + * @description 服务实现 + * @date 2022-06-28 + **/ +@Service +@RequiredArgsConstructor +@Slf4j +public class DeviceooestatServiceImpl implements DeviceooestatService { + private final ClassstandardService classstandardService; + + @Override + public Map queryAll(Map whereJson, Pageable page) { + String material_type_id = MapUtil.getStr(whereJson, "material_type_id"); + String class_idStr = MapUtil.getStr(whereJson, "class_idStr"); + String begin_time = MapUtil.getStr(whereJson, "begin_time"); + String end_time = MapUtil.getStr(whereJson, "end_time"); + String device_code = MapUtil.getStr(whereJson, "device_code"); + String dept_code = MapUtil.getStr(whereJson, "dept_code"); + + HashMap map = new HashMap<>(); + map.put("flag", "1"); + map.put("begin_time", begin_time); + map.put("end_time", end_time); + if (ObjectUtil.isNotEmpty(device_code)) map.put("device_code","%"+device_code+"%"); + if (ObjectUtil.isNotEmpty(dept_code)) map.put("dept_code","%"+dept_code+"%"); + //处理物料当前节点的所有子节点 + if (!StrUtil.isEmpty(material_type_id)) { + map.put("material_type_id", material_type_id); + String classIds = classstandardService.getChildIdStr(material_type_id); + map.put("classIds", classIds); + } else if (ObjectUtil.isNotEmpty(class_idStr)) { + String classIds = classstandardService.getAllChildIdStr(class_idStr); + map.put("classIds", classIds); + } + JSONObject json = WQL.getWO("EM_DEVICEOOESTAT001").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "run.create_time DESC"); + return json; + } +} diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/wql/EM_DEVICEOOESTAT001.wql b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/wql/EM_DEVICEOOESTAT001.wql new file mode 100644 index 00000000..3800cba2 --- /dev/null +++ b/mes/hd/nladmin-system/src/main/java/org/nl/wms/sb/stat/wql/EM_DEVICEOOESTAT001.wql @@ -0,0 +1,90 @@ +[交易说明] + 交易名: 设备OOE指标分析分页查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + 输入.classIds TYPEAS f_string + 输入.device_code TYPEAS s_string + 输入.begin_time TYPEAS s_string + 输入.end_time TYPEAS s_string + 输入.dept_code TYPEAS s_string + + +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + PAGEQUERY + SELECT + run.*, + class.class_name, + file.device_code, + file.device_name, + file.theory_beat, + dept.name AS dept_name + FROM + EM_BI_DeviceRunRecord run + LEFT JOIN EM_BI_EquipmentFile file ON file.devicerecord_id = run.devicerecord_id + LEFT JOIN md_pb_classstandard class ON file.material_type_id = class.class_id + LEFT JOIN sys_dept dept ON file.use_deptid = dept.dept_id + WHERE + file.is_delete = '0' + + OPTION 输入.device_code <> "" + (file.device_code like 输入.device_code or + file.device_name like 输入.device_code) + ENDOPTION + + OPTION 输入.dept_code <> "" + (dept.name like 输入.dept_code or + dept.code like 输入.dept_code) + ENDOPTION + + OPTION 输入.classIds <> "" + class.class_id in 输入.classIds + ENDOPTION + + OPTION 输入.begin_time <> "" + run.run_date >= 输入.begin_time + ENDOPTION + + OPTION 输入.end_time <> "" + run.run_date <= 输入.end_time + ENDOPTION + + ENDSELECT + ENDPAGEQUERY + ENDIF + + + diff --git a/mes/qd/src/api/wms/sb/deviceooestat.js b/mes/qd/src/api/wms/sb/deviceooestat.js new file mode 100644 index 00000000..1a74ea96 --- /dev/null +++ b/mes/qd/src/api/wms/sb/deviceooestat.js @@ -0,0 +1,27 @@ +import request from '@/utils/request' + +export function add(data) { + return request({ + url: 'api/deviceooestat', + method: 'post', + data + }) +} + +export function del(ids) { + return request({ + url: 'api/deviceooestat', + method: 'delete', + data: ids + }) +} + +export function edit(data) { + return request({ + url: 'api/deviceooestat', + method: 'put', + data + }) +} + +export default { add, edit, del } diff --git a/mes/qd/src/views/wms/sb/run/devicerunrecord/index.vue b/mes/qd/src/views/wms/sb/run/devicerunrecord/index.vue index 2c76a2cd..7a4c796b 100644 --- a/mes/qd/src/views/wms/sb/run/devicerunrecord/index.vue +++ b/mes/qd/src/views/wms/sb/run/devicerunrecord/index.vue @@ -58,12 +58,12 @@ - + - + @@ -71,12 +71,12 @@ - + - + @@ -84,12 +84,12 @@ - + - + diff --git a/mes/qd/src/views/wms/sb/stat/deviceooestat/index.vue b/mes/qd/src/views/wms/sb/stat/deviceooestat/index.vue new file mode 100644 index 00000000..2b772478 --- /dev/null +++ b/mes/qd/src/views/wms/sb/stat/deviceooestat/index.vue @@ -0,0 +1,170 @@ + + + + +