设备效率OEE分析

This commit is contained in:
2022-06-29 17:16:04 +08:00
parent f2c8ca9502
commit 5b73689fdd
8 changed files with 465 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -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<Object> query(@RequestParam Map whereJson, Pageable page) {
return new ResponseEntity<>(deviceooestatService.queryAll(whereJson, page), HttpStatus.OK);
}
}

View File

@@ -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<String, Object>
*/
Map<String, Object> queryAll(Map whereJson, Pageable page);
}

View File

@@ -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<String, Object> 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<String, String> 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;
}
}

View File

@@ -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

View File

@@ -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 }

View File

@@ -58,12 +58,12 @@
<el-row>
<el-col :span="12">
<el-form-item label="工作时间分钟:">
<el-input v-model="form.run_times" style="width: 200px;" />
<el-input-number :controls="false" :min="0" :precision="0" v-model="form.run_times" style="width: 200px;"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="准备时间分钟:">
<el-input v-model="form.prepare_times" style="width: 200px;" />
<el-input-number :controls="false" :min="0" :precision="0" v-model="form.prepare_times" style="width: 200px;" />
</el-form-item>
</el-col>
</el-row>
@@ -71,12 +71,12 @@
<el-row>
<el-col :span="12">
<el-form-item label="故障时间分钟:">
<el-input v-model="form.error_times" style="width: 200px;" />
<el-input-number :controls="false" :min="0" :precision="0" v-model="form.error_times" style="width: 200px;" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="工装调整时间分钟:">
<el-input v-model="form.adjust_times" style="width: 200px;" />
<el-input-number :controls="false" :precision="0" :min="0" v-model="form.adjust_times" style="width: 200px;" />
</el-form-item>
</el-col>
</el-row>
@@ -84,12 +84,12 @@
<el-row>
<el-col :span="12">
<el-form-item label="生产总量:">
<el-input v-model="form.product_qty" style="width: 200px;" />
<el-input-number :controls="false" :min="0" :precision="2" v-model="form.product_qty" style="width: 200px;" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="不合格数:">
<el-input v-model="form.nok_qty" style="width: 200px;" />
<el-input-number :controls="false" :min="0" :precision="2" v-model="form.nok_qty" style="width: 200px;" />
</el-form-item>
</el-col>
</el-row>

View File

@@ -0,0 +1,170 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-form
:inline="true"
class="demo-form-inline"
label-position="right"
label-width="110px"
label-suffix=":"
>
<el-form-item label="统计日期">
<date-range-picker v-model="query.createTime" class="date-item" />
</el-form-item>
<el-form-item label="设备类别">
<treeselect
v-model="query.material_type_id"
:load-options="loadClass"
:options="classes"
style="width: 200px;"
placeholder="请选择"
/>
</el-form-item>
<el-form-item label="设备编码">
<el-input
v-model="query.device_code"
clearable
size="mini"
placeholder="请输入设备编码、名称"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="使用部门">
<el-input
v-model="query.dept_code"
clearable
size="mini"
placeholder="请输入部门编码、名称"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<rrOperation />
</el-form>
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<!--表单组件-->
<!--表格渲染-->
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column v-if="false" prop="runrecord_id" label="记录标识" />
<el-table-column prop="dept_name" label="使用部门" />
<el-table-column prop="class_name" label="设备类型" />
<el-table-column prop="device_code" label="设备编码" />
<el-table-column prop="device_name" label="设备名称" width="120px" show-overflow-tooltip />
<el-table-column prop="run_times" label="工作时间(分钟)" width="120px" />
<el-table-column prop="prepare_times" label="准备时间(分钟)" width="120px" />
<el-table-column prop="error_times" label="故障时间(分钟)" width="120px" />
<el-table-column prop="adjust_times" label="工装调整时间(分钟)" width="140px" />
<el-table-column prop="product_qty" label="生产总量" :formatter="crud.formatNum2" />
<el-table-column prop="nok_qty" label="不合格数" :formatter="crud.formatNum2" />
<el-table-column prop="theory_beat" label="理论生产节拍(分钟)" width="140px" />
<el-table-column prop="oee_value" label="OEE指标(%)" width="120px" />
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>
<script>
import crudDeviceooestat from '@/api/wms/sb/deviceooestat'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import crudClassstandard from '@/api/wms/basedata/master/classstandard'
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import crudMaterialbase from '@/api/wms/basedata/master/materialbase'
import DateRangePicker from '@/components/DateRangePicker'
const defaultForm = { runrecord_id: null, devicerecord_id: null, run_date: null, run_times: null, prepare_times: null, error_times: null, adjust_times: null, product_qty: null, nok_qty: null, oee_value: null, remark: null, create_id: null, create_name: null, create_time: null }
export default {
name: 'Deviceooestat',
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect, DateRangePicker },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
title: '设备OEE指标',
url: 'api/deviceooestat',
idField: 'runrecord_id',
sort: 'runrecord_id,desc',
crudMethod: { ...crudDeviceooestat },
optShow: {
add: false,
edit: false,
del: false,
download: false,
reset: true
}
})
},
data() {
return {
classes: [],
class_idStr: null,
materOpt_code: '23',
deviceDialog: false,
permission: {
}
}
},
created() {
const param = {
'materOpt_code': this.materOpt_code
}
crudMaterialbase.getMaterOptType(param).then(res => {
this.class_idStr = res.class_idStr
this.crud.query.class_idStr = this.class_idStr
this.crud.toQuery()
this.queryClassId()
})
},
methods: {
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
},
hand(value) {
this.crud.toQuery()
},
loadClass({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
crudClassstandard.getClass({ pid: parentNode.id }).then(res => {
parentNode.children = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 100)
})
}
},
queryClassId() {
const param = {
'class_idStr': this.class_idStr
}
crudClassstandard.queryClassById(param).then(res => {
this.classes = res.content.map(obj => {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
})
}
}
}
</script>
<style scoped>
</style>