设备效率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