|
|
|
|
@ -1,10 +1,14 @@ |
|
|
|
|
package org.springblade.desk.produce.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
@ -14,6 +18,7 @@ import org.springblade.desk.device.pojo.entity.EquipmentEntity; |
|
|
|
|
import org.springblade.desk.device.pojo.entity.RackSetEntity; |
|
|
|
|
import org.springblade.desk.device.service.IEquipmentService; |
|
|
|
|
import org.springblade.desk.device.service.IRackSetService; |
|
|
|
|
import org.springblade.desk.energy.util.HttpRequestService; |
|
|
|
|
import org.springblade.desk.produce.mapper.MacToolUseMapper; |
|
|
|
|
import org.springblade.desk.produce.pojo.dto.MesMacToolUseDTO; |
|
|
|
|
import org.springblade.desk.produce.pojo.entity.MacToolUse; |
|
|
|
|
@ -25,9 +30,11 @@ import org.springblade.desk.produce.pojo.vo.MacToolUseVO; |
|
|
|
|
import org.springblade.desk.produce.pojo.vo.MesMacToolUseVO; |
|
|
|
|
import org.springblade.desk.produce.pojo.vo.ProduceMonitorSlotListVO; |
|
|
|
|
import org.springblade.desk.produce.service.IMacToolUseService; |
|
|
|
|
import org.springblade.desk.produce.service.IMesQcProduceRunService; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.text.DecimalFormat; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
@ -50,6 +57,15 @@ public class MacToolUseServiceImpl extends BaseServiceImpl<MacToolUseMapper, Mac |
|
|
|
|
|
|
|
|
|
private final IEquipmentService equipmentService; |
|
|
|
|
|
|
|
|
|
private final IMesQcProduceRunService mesQcProduceRunService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private HttpRequestService httpRequestService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String heat1 = "实际温度1", sjzkd = "实际真空度", ld = "露点", ls = "链速", heat2 = "实际温度2", heat3 = "实际温度3", heat4 = "实际温度4", heat5 = "实际温度5", heat6 = "实际温度6", heat7 = "实际温度7", heat8 = "实际温度8", |
|
|
|
|
heat9 = "实际温度9", heat10 = "实际温度10", heat11 = "实际温度11", sdwd01 = "设定温度1", sdwd02 = "设定温度2", sdwd03 = "设定温度3", sdwd04 = "设定温度4", sdwd05 = "设定温度5", sdwd06 = "设定温度6", sdwd07 = "设定温度7", sdwd08 = "设定温度8", sdwd09 = "设定温度9"; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String nextCode(int i) { |
|
|
|
|
// 编码模式
|
|
|
|
|
@ -214,6 +230,180 @@ public class MacToolUseServiceImpl extends BaseServiceImpl<MacToolUseMapper, Mac |
|
|
|
|
return baseMapper.getMaterialMess(goodsCode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setSjDataCapture(MesQcProduceRunEntity produceRun, Boolean unBind) { |
|
|
|
|
MesQcProduceRunEntity qcProduceRun = mesQcProduceRunService.getById(produceRun.getId()); |
|
|
|
|
List<JSONObject> eneUsed; |
|
|
|
|
ArrayList<String> params = Lists.newArrayList(); // 参数
|
|
|
|
|
String prodLineLevel = null; // 温度上下浮动值
|
|
|
|
|
List<JSONObject> jsonList = null; // 根据参数获取到的设备参数信息
|
|
|
|
|
Double heat = 0d; // 最高温度
|
|
|
|
|
if (qcProduceRun.getTempSlot() != null && Double.parseDouble(qcProduceRun.getTempSlot()) > 0) { |
|
|
|
|
heat = Double.valueOf(qcProduceRun.getTempSlot()); |
|
|
|
|
} |
|
|
|
|
Double vacuity = 1000000d; // 真空度
|
|
|
|
|
if (qcProduceRun.getDataFourteen() != null && Double.parseDouble(qcProduceRun.getDataFourteen()) < vacuity) { |
|
|
|
|
vacuity = Double.valueOf(qcProduceRun.getDataFourteen()); |
|
|
|
|
} |
|
|
|
|
Double setHeat = 20000d; // 设定温度
|
|
|
|
|
List<JSONObject> aaaList = new ArrayList<>(); // 温度大于200 得集合
|
|
|
|
|
// 获取设备所需参数
|
|
|
|
|
JSONObject deviceParams = this.getDeviceParams(qcProduceRun); |
|
|
|
|
if (deviceParams != null) { |
|
|
|
|
prodLineLevel = deviceParams.getString("prodLineLevel"); |
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(prodLineLevel)) { |
|
|
|
|
prodLineLevel = "0"; |
|
|
|
|
} |
|
|
|
|
jsonList = JSONArray.parseArray(deviceParams.getJSONArray("prodLineMeasurePoint").toJSONString(), JSONObject.class); |
|
|
|
|
if (jsonList != null && jsonList.size() > 0) { |
|
|
|
|
// 处理参数
|
|
|
|
|
for (JSONObject jsonObject : jsonList) { |
|
|
|
|
params.add(jsonObject.getString("attrCode")); |
|
|
|
|
} |
|
|
|
|
String startTime = qcProduceRun.getInDate(); |
|
|
|
|
// 获取当前时间字符串格式
|
|
|
|
|
String endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if (unBind) { |
|
|
|
|
endTime = qcProduceRun.getOutDate(); |
|
|
|
|
} |
|
|
|
|
// 获取数据
|
|
|
|
|
eneUsed = httpRequestService.getEneUsed(qcProduceRun.getDeviceId(), params, startTime, endTime); |
|
|
|
|
// 处理数据
|
|
|
|
|
if (eneUsed != null && !eneUsed.isEmpty()) { |
|
|
|
|
// 只有一个温度并且等于实际温度1
|
|
|
|
|
Map<String, JSONObject> eUMap = jsonList.stream().map(cbsSupplier -> new AbstractMap.SimpleEntry<>(cbsSupplier.getString("attrName"), cbsSupplier)) |
|
|
|
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); |
|
|
|
|
// 获取设定温度
|
|
|
|
|
if (eUMap.get(sdwd01) != null && eneUsed.get(0).getString(eUMap.get(sdwd01).getString("attrCode")) != null) { |
|
|
|
|
setHeat = Double.valueOf(eneUsed.get(0).getString(eUMap.get(sdwd01).getString("attrCode"))); |
|
|
|
|
} else if (qcProduceRun.getDataTwo() != null) { |
|
|
|
|
setHeat = Double.valueOf(qcProduceRun.getDataTwo()); |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat2) != null) { // 如果实际温度2存在代表分区
|
|
|
|
|
for (JSONObject jsonObject : eneUsed) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat2).getString("attrCode")) == null) return; |
|
|
|
|
// 获取最高温度
|
|
|
|
|
heat = this.setMaxHeat(eUMap, jsonObject, heat); |
|
|
|
|
} |
|
|
|
|
qcProduceRun.setTempSlot(String.valueOf(heat)); |
|
|
|
|
} else { // 如果实际温度2不存在代表不是分区
|
|
|
|
|
for (JSONObject jsonObject : eneUsed) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat1).getString("attrCode")) == null) return; |
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(jsonObject.getString(eUMap.get(heat1).getString("attrCode")))) |
|
|
|
|
continue; |
|
|
|
|
Double value = Double.valueOf(jsonObject.getString(eUMap.get(heat1).getString("attrCode"))); |
|
|
|
|
// 获取最高温度
|
|
|
|
|
if (value > heat) { |
|
|
|
|
heat = value; |
|
|
|
|
} |
|
|
|
|
// 存储温度大于200 的数据 用与获取真空度
|
|
|
|
|
if (value > 200) { |
|
|
|
|
aaaList.add(jsonObject); |
|
|
|
|
} |
|
|
|
|
// 存储保温开始时间
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(qcProduceRun.getDataThirteen())) { |
|
|
|
|
if (value >= setHeat) { |
|
|
|
|
qcProduceRun.setDataThirteen(String.valueOf(jsonObject.getString("timestamp"))); |
|
|
|
|
} |
|
|
|
|
} else if (value < setHeat && org.apache.commons.lang3.StringUtils.isNotBlank(qcProduceRun.getDataThirteen()) && org.apache.commons.lang3.StringUtils.isBlank(qcProduceRun.getDataTwelve())) { |
|
|
|
|
// 存储保温结束时间
|
|
|
|
|
qcProduceRun.setDataTwelve(String.valueOf(jsonObject.getString("timestamp"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (aaaList.size() > 0 && eUMap.get(sjzkd) != null) { |
|
|
|
|
for (JSONObject jsonObject : aaaList) { |
|
|
|
|
if (Double.valueOf(jsonObject.getString(eUMap.get(sjzkd).getString("attrCode"))) < vacuity) { |
|
|
|
|
vacuity = Double.valueOf(jsonObject.getString(eUMap.get(sjzkd).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 真空度
|
|
|
|
|
qcProduceRun.setDataFourteen(new DecimalFormat("#.000000").format(vacuity)); |
|
|
|
|
} |
|
|
|
|
qcProduceRun.setTempSlot(String.valueOf(heat)); |
|
|
|
|
} |
|
|
|
|
// 获取链速
|
|
|
|
|
if (eUMap.get(ls) != null) { |
|
|
|
|
if (eneUsed.get(0).getString(eUMap.get(ls).getString("attrCode")) != null) { |
|
|
|
|
String string = eneUsed.get(0).getString(eUMap.get(ls).getString("attrCode")); |
|
|
|
|
qcProduceRun.setVSpeed(string); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 获取露点
|
|
|
|
|
if (eUMap.get(ld) != null) { |
|
|
|
|
if (eneUsed.get(0).getString(eUMap.get(ld).getString("attrCode")) != null) { |
|
|
|
|
String string = eneUsed.get(0).getString(eUMap.get(ld).getString("attrCode")); |
|
|
|
|
qcProduceRun.setDataEleven(string); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
mesQcProduceRunService.updateById(qcProduceRun); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Double setMaxHeat(Map<String, JSONObject> eUMap, JSONObject jsonObject, Double heat) { |
|
|
|
|
if (eUMap.get(heat1) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat1).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat1).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat1).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat2) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat2).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat2).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat2).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat3) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat3).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat3).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat3).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat4) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat4).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat4).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat4).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat5) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat5).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat5).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat5).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat6) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat6).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat6).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat6).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat7) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat7).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat7).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat7).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat8) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat8).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat8).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat8).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat9) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat9).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat9).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat9).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat10) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat10).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat10).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat10).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (eUMap.get(heat11) != null) { |
|
|
|
|
if (jsonObject.getString(eUMap.get(heat11).getString("attrCode")) != null && Double.valueOf(jsonObject.getString(eUMap.get(heat11).getString("attrCode"))) > heat) { |
|
|
|
|
heat = Double.valueOf(jsonObject.getString(eUMap.get(heat11).getString("attrCode"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return heat; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JSONObject getDeviceParams(MesQcProduceRunEntity qcProduceRun) { |
|
|
|
|
return httpRequestService.getParams(qcProduceRun.getDeviceId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static final int time2Integer(Date d) { |
|
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
|
cal.setTime(d); |
|
|
|
|
|