修改
This commit is contained in:
@@ -320,7 +320,7 @@ public class DeviceScreenServiceImpl implements DeviceScreenService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject deviceCensus(JSONObject param) {
|
public JSONObject deviceCensus(JSONObject param) {
|
||||||
JSONArray pro_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "6").process().getResultJSONArray(0);
|
JSONArray pro_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "10").process().getResultJSONArray(0);
|
||||||
JSONArray result = new JSONArray();
|
JSONArray result = new JSONArray();
|
||||||
for (int i = 0; i < pro_rows.size(); i++) {
|
for (int i = 0; i < pro_rows.size(); i++) {
|
||||||
JSONObject pro = pro_rows.getJSONObject(i);
|
JSONObject pro = pro_rows.getJSONObject(i);
|
||||||
@@ -328,15 +328,15 @@ public class DeviceScreenServiceImpl implements DeviceScreenService {
|
|||||||
int total_num = pro.getIntValue("total_num");
|
int total_num = pro.getIntValue("total_num");
|
||||||
String workprocedure_id = pro.getString("workprocedure_id");
|
String workprocedure_id = pro.getString("workprocedure_id");
|
||||||
//查询故障设备
|
//查询故障设备
|
||||||
JSONArray err_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "7").addParam("workprocedure_id",workprocedure_id).process().getResultJSONArray(0);
|
JSONArray err_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "7").addParam("workprocedure_id", workprocedure_id).process().getResultJSONArray(0);
|
||||||
int err_device = err_rows.size();
|
int err_device = err_rows.size();
|
||||||
|
|
||||||
//查询运行设备
|
//查询运行设备
|
||||||
JSONArray run_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "8").addParam("workprocedure_id",workprocedure_id).process().getResultJSONArray(0);
|
JSONArray run_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "8").addParam("workprocedure_id", workprocedure_id).process().getResultJSONArray(0);
|
||||||
int run_device = run_rows.size();
|
int run_device = run_rows.size();
|
||||||
|
|
||||||
//查询有工单,没有故障的设备
|
//查询有工单,没有故障的设备
|
||||||
JSONArray task_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "9").addParam("workprocedure_id",workprocedure_id).process().getResultJSONArray(0);
|
JSONArray task_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "9").addParam("workprocedure_id", workprocedure_id).process().getResultJSONArray(0);
|
||||||
//查询暂未生产设备
|
//查询暂未生产设备
|
||||||
int prepare_device = task_rows.size() - run_device;
|
int prepare_device = task_rows.size() - run_device;
|
||||||
|
|
||||||
@@ -370,13 +370,14 @@ public class DeviceScreenServiceImpl implements DeviceScreenService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject deviceUseRate(JSONObject param) {
|
public JSONObject deviceUseRate(JSONObject param) {
|
||||||
JSONArray pro_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "6").process().getResultJSONArray(0);
|
JSONArray pro_rows = WQL.getWO("QDEVICE_SCREEN").addParam("flag", "10").process().getResultJSONArray(0);
|
||||||
JSONArray result = new JSONArray();
|
JSONArray result = new JSONArray();
|
||||||
for (int i = 0; i < pro_rows.size(); i++) {
|
for (int i = 0; i < pro_rows.size(); i++) {
|
||||||
JSONObject pro = pro_rows.getJSONObject(i);
|
JSONObject pro = pro_rows.getJSONObject(i);
|
||||||
JSONObject jo = new JSONObject();
|
JSONObject jo = new JSONObject();
|
||||||
jo.put("workprocedure_name", pro.getString("workprocedure_name"));
|
jo.put("workprocedure_name", pro.getString("workprocedure_name"));
|
||||||
jo.put("teep",(i+1)*10);
|
jo.put("teep", (i + 1) * 10);
|
||||||
|
result.add(jo);
|
||||||
}
|
}
|
||||||
JSONObject returnjo = new JSONObject();
|
JSONObject returnjo = new JSONObject();
|
||||||
returnjo.put("code", "1");
|
returnjo.put("code", "1");
|
||||||
@@ -394,25 +395,31 @@ public class DeviceScreenServiceImpl implements DeviceScreenService {
|
|||||||
int product_qty = 0;
|
int product_qty = 0;
|
||||||
JSONObject device = device_rows.getJSONObject(i);
|
JSONObject device = device_rows.getJSONObject(i);
|
||||||
String device_id = device.getString("device_id");
|
String device_id = device.getString("device_id");
|
||||||
JSONArray order_rows = WQLObject.getWQLObject("mps_bd_produceshiftorder").query("device_id = '"+device_id+"' AND produce_date like '"+date+"' AND is_delete = '0'").getResultJSONArray(0);
|
JSONArray order_rows = WQLObject.getWQLObject("mps_bd_produceshiftorder").query("device_id = '" + device_id + "' AND produce_date like '" + date + "' AND is_delete = '0'").getResultJSONArray(0);
|
||||||
for (int j = 0; j < order_rows.size(); j++) {
|
for (int j = 0; j < order_rows.size(); j++) {
|
||||||
JSONObject order = order_rows.getJSONObject(i);
|
JSONObject order = order_rows.getJSONObject(i);
|
||||||
product_qty += order.getIntValue("real_qty");
|
product_qty += order.getIntValue("real_qty");
|
||||||
}
|
}
|
||||||
device.put("product_qty",product_qty);
|
device.put("product_qty", product_qty);
|
||||||
|
|
||||||
//查询最近的一条开机状态
|
//查询最近的一条开机状态
|
||||||
JSONObject start_jo = WQLObject.getWQLObject("pdm_bi_devicerunstatusrecord").query("device_id = '"+device_id+"' AND status_type = '02' order by end_time desc").uniqueResult(0);
|
JSONObject start_jo = WQLObject.getWQLObject("pdm_bi_devicerunstatusrecord").query("device_id = '" + device_id + "' AND status_type = '02' order by end_time desc").uniqueResult(0);
|
||||||
device.put("start_time",start_jo.getString("end_time"));
|
if (ObjectUtil.isNotEmpty(start_jo)) {
|
||||||
if (StrUtil.isEmpty(device.getString("end_time"))){
|
device.put("start_time", start_jo.getString("end_time"));
|
||||||
|
}
|
||||||
|
if (StrUtil.isEmpty(device.getString("status_type"))) {
|
||||||
//查询最近的一条关机状态
|
//查询最近的一条关机状态
|
||||||
JSONObject end_jo = WQLObject.getWQLObject("pdm_bi_devicerunstatusrecord").query("device_id = '"+device_id+"' AND status_type = '01' order by end_time desc").uniqueResult(0);
|
JSONObject end_jo = WQLObject.getWQLObject("pdm_bi_devicerunstatusrecord").query("device_id = '" + device_id + "' AND status_type = '01' order by end_time desc").uniqueResult(0);
|
||||||
device.put("end_time",end_jo.getString("end_time"));
|
if (ObjectUtil.isNotEmpty(end_jo)) {
|
||||||
|
device.put("end_time", end_jo.getString("end_time"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询最近的一个工单
|
//查询最近的一个工单
|
||||||
JSONObject order_jo = WQLObject.getWQLObject("mps_bd_produceshiftorder").query("device_id = '"+device_id+"' AND is_delete = '0' AND is_actice = '1' order by realproducestart_date desc").uniqueResult(0);
|
JSONObject order_jo = WQLObject.getWQLObject("mps_bd_produceshiftorder").query("device_id = '" + device_id + "' AND is_delete = '0' order by realproducestart_date desc").uniqueResult(0);
|
||||||
device.put("product_time",order_jo.getString("produce_date"));
|
if (ObjectUtil.isNotEmpty(order_jo)) {
|
||||||
|
device.put("product_time", order_jo.getString("produce_date"));
|
||||||
|
}
|
||||||
result.add(device);
|
result.add(device);
|
||||||
}
|
}
|
||||||
JSONObject returnjo = new JSONObject();
|
JSONObject returnjo = new JSONObject();
|
||||||
@@ -433,58 +440,58 @@ public class DeviceScreenServiceImpl implements DeviceScreenService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject calculate(JSONObject jo) {
|
public JSONObject calculate(JSONObject jo) {
|
||||||
String date = jo.getString("date")+"%";
|
String date = jo.getString("date") + "%";
|
||||||
String device_id = jo.getString("device_id");
|
String device_id = jo.getString("device_id");
|
||||||
//type:1、目标;2、实际
|
//type:1、目标;2、实际
|
||||||
String type = jo.getString("type");
|
String type = jo.getString("type");
|
||||||
|
|
||||||
//查询当天该设备的产量
|
//查询当天该设备的产量
|
||||||
int total_qty = 0;
|
int total_qty = 0;
|
||||||
JSONArray order_rows = WQLObject.getWQLObject("mps_bd_produceshiftorder").query("device_id = '"+device_id+"' AND produce_date like '"+date+"' AND is_delete = '0'").getResultJSONArray(0);
|
JSONArray order_rows = WQLObject.getWQLObject("mps_bd_produceshiftorder").query("device_id = '" + device_id + "' AND produce_date like '" + date + "' AND is_delete = '0'").getResultJSONArray(0);
|
||||||
for (int i = 0; i < order_rows.size(); i++) {
|
for (int i = 0; i < order_rows.size(); i++) {
|
||||||
JSONObject order = order_rows.getJSONObject(i);
|
JSONObject order = order_rows.getJSONObject(i);
|
||||||
total_qty += order.getIntValue("real_qty");
|
total_qty += order.getIntValue("real_qty");
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询该设备对应的产能
|
//查询该设备对应的产能
|
||||||
JSONObject device = WQLObject.getWQLObject("PDM_BI_Device").query("device_id = '"+device_id+"'").uniqueResult(0);
|
JSONObject device = WQLObject.getWQLObject("PDM_BI_Device").query("device_id = '" + device_id + "'").uniqueResult(0);
|
||||||
double productivity = device.getDoubleValue("productivity");
|
double productivity = device.getDoubleValue("productivity");
|
||||||
|
|
||||||
//故障时间汇总
|
//故障时间汇总
|
||||||
JSONArray err_rows = WQLObject.getWQLObject("pdm_bi_devicerunstatusrecord").query("device_id = '"+device_id+"' AND status_type = '05' AND start_time like '"+date+"'").getResultJSONArray(0);
|
JSONArray err_rows = WQLObject.getWQLObject("pdm_bi_devicerunstatusrecord").query("device_id = '" + device_id + "' AND status_type = '05' AND start_time like '" + date + "'").getResultJSONArray(0);
|
||||||
double err_time = 0;
|
double err_time = 0;
|
||||||
for (int i = 0; i < err_rows.size(); i++) {
|
for (int i = 0; i < err_rows.size(); i++) {
|
||||||
JSONObject err_jo = err_rows.getJSONObject(i);
|
JSONObject err_jo = err_rows.getJSONObject(i);
|
||||||
String start_time = err_jo.getString("start_time");
|
String start_time = err_jo.getString("start_time");
|
||||||
String end_time = err_jo.getString("end_time");
|
String end_time = err_jo.getString("end_time");
|
||||||
if (StrUtil.isEmpty(end_time)){
|
if (StrUtil.isEmpty(end_time)) {
|
||||||
end_time = DateUtil.now();
|
end_time = DateUtil.now();
|
||||||
}
|
}
|
||||||
long between = DateUtil.between(DateUtil.parse(start_time), DateUtil.parse(end_time), DateUnit.MINUTE);
|
long between = DateUtil.between(DateUtil.parse(start_time), DateUtil.parse(end_time), DateUnit.MINUTE);
|
||||||
err_time += between;
|
err_time += between;
|
||||||
}
|
}
|
||||||
|
|
||||||
err_time = NumberUtil.round(err_time,2).doubleValue();
|
err_time = NumberUtil.round(err_time, 2).doubleValue();
|
||||||
|
|
||||||
double oee = 0.0;
|
double oee = 0.0;
|
||||||
//OEE计算目标:当天汇总/(产能x负荷时间);实际:(班制时间-故障时间)/班制时间 * (当天工单汇总/(产能*(符合时间-故障时间)))* 98%
|
//OEE计算目标:当天汇总/(产能x负荷时间);实际:(班制时间-故障时间)/班制时间 * (当天工单汇总/(产能*(符合时间-故障时间)))* 98%
|
||||||
if (type.equals("1")){
|
if (type.equals("1")) {
|
||||||
//8是指符合时间,也就是每天的工作时间
|
//8是指符合时间,也就是每天的工作时间
|
||||||
oee = NumberUtil.div(total_qty,NumberUtil.mul(8,productivity));
|
oee = NumberUtil.div(total_qty, NumberUtil.mul(8, productivity));
|
||||||
}else {
|
} else {
|
||||||
//(班制时间-故障时间)/班制时间
|
//(班制时间-故障时间)/班制时间
|
||||||
double value1 = NumberUtil.div(NumberUtil.sub(8*60,err_time),8*60);
|
double value1 = NumberUtil.div(NumberUtil.sub(8 * 60, err_time), 8 * 60);
|
||||||
//(产能*(符合时间-故障时间)
|
//(产能*(符合时间-故障时间)
|
||||||
double value2 = NumberUtil.div(total_qty,NumberUtil.mul(productivity,value1));
|
double value2 = NumberUtil.div(total_qty, NumberUtil.mul(productivity, value1));
|
||||||
oee = NumberUtil.mul(value1,value2);
|
oee = NumberUtil.mul(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
double teep = 0.0;
|
double teep = 0.0;
|
||||||
//TEEP计算:OEE*(班制时间-计划停机时间)/班制时间
|
//TEEP计算:OEE*(班制时间-计划停机时间)/班制时间
|
||||||
teep = NumberUtil.div(oee,0.9);
|
teep = NumberUtil.div(oee, 0.9);
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("oee",oee);
|
result.put("oee", oee);
|
||||||
result.put("teep",teep);
|
result.put("teep", teep);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
IF 输入.flag = "6"
|
IF 输入.flag = "6"
|
||||||
QUERY
|
QUERY
|
||||||
SELECT
|
SELECT
|
||||||
COUNT( record_id ) AS err_times
|
COUNT( record_id ) AS err_times,
|
||||||
MAX( device.device_name ) AS device_name
|
MAX( device.device_name ) AS device_name
|
||||||
FROM
|
FROM
|
||||||
pdm_bi_devicerunstatusrecord run
|
pdm_bi_devicerunstatusrecord run
|
||||||
@@ -161,7 +161,7 @@
|
|||||||
IF 输入.flag = "7"
|
IF 输入.flag = "7"
|
||||||
QUERY
|
QUERY
|
||||||
SELECT
|
SELECT
|
||||||
device_id
|
device.device_id
|
||||||
FROM
|
FROM
|
||||||
pdm_bi_devicerunstatusrecord run
|
pdm_bi_devicerunstatusrecord run
|
||||||
LEFT JOIN pdm_bi_device device ON device.device_id = run.device_id
|
LEFT JOIN pdm_bi_device device ON device.device_id = run.device_id
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
IF 输入.flag = "8"
|
IF 输入.flag = "8"
|
||||||
QUERY
|
QUERY
|
||||||
SELECT
|
SELECT
|
||||||
device_id
|
device.device_id
|
||||||
FROM
|
FROM
|
||||||
pdm_bi_devicerunstatusrecord run
|
pdm_bi_devicerunstatusrecord run
|
||||||
LEFT JOIN pdm_bi_device device ON device.device_id = run.device_id
|
LEFT JOIN pdm_bi_device device ON device.device_id = run.device_id
|
||||||
|
|||||||
Reference in New Issue
Block a user