|
|
|
|
package com.ipsplm.service.simulation.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ipsplm.dao.simulation.SimulationAnalysisMapper;
|
|
|
|
|
import com.ipsplm.entity.simulation.*;
|
|
|
|
|
import com.ipsplm.entity.simulation.dto.BufferNumDTO;
|
|
|
|
|
import com.ipsplm.entity.simulation.vo.*;
|
|
|
|
|
import com.ipsplm.service.simulation.ISimulationAnalysisService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description 仿真分析实现类
|
|
|
|
|
* @Author lulicheng
|
|
|
|
|
* @Date 2024-07-31 10:20
|
|
|
|
|
* @Version 1.0
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class SimulationAnalysisServiceImpl implements ISimulationAnalysisService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private SimulationAnalysisMapper simulationAnalysisMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取厂房设备利用率信息
|
|
|
|
|
*
|
|
|
|
|
* @param flag
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String,Object> getPlantEquipmentUtilization(Long flag) {
|
|
|
|
|
String simEndTime = simulationAnalysisMapper.getSimEndTime();
|
|
|
|
|
List<PlantEquipmentUtilizationVO> plantEquipmentUtilization = simulationAnalysisMapper.getPlantEquipmentUtilization(flag);
|
|
|
|
|
List<OeeVO> oeeVOList = beanToKeyValue(plantEquipmentUtilization);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(null,1);
|
|
|
|
|
Map<String,Object> result = new HashMap<>();
|
|
|
|
|
result.put("simEndTime",simEndTime);
|
|
|
|
|
result.put("oeeList",fieldNameToChinese(fieldCnVOList,oeeVOList));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取工序列表
|
|
|
|
|
*
|
|
|
|
|
* @param tableCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> getProcessList(String tableCode) {
|
|
|
|
|
return simulationAnalysisMapper.getProcessList(tableCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取缓存数量时间
|
|
|
|
|
*
|
|
|
|
|
* @param process
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Object getBufferNum(String process) {
|
|
|
|
|
List<BufferVO> bufferNameList = simulationAnalysisMapper.getBufferName(process);
|
|
|
|
|
String tableCode = bufferNameList.get(0).getTableCode();
|
|
|
|
|
switch (tableCode) {
|
|
|
|
|
case "buffernum_bxg": {
|
|
|
|
|
List<BufferNumBxg> bufferNumBxgList = simulationAnalysisMapper.getBufferNumBxg(bufferNameList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(1,2);
|
|
|
|
|
return beanToKeyValue(bufferNumBxgList,fieldCnVOList);
|
|
|
|
|
}
|
|
|
|
|
case "buffernum_dj": {
|
|
|
|
|
List<BufferNumDj> bufferNumDjList = simulationAnalysisMapper.getBufferNumDj(bufferNameList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(2,2);
|
|
|
|
|
return beanToKeyValue(bufferNumDjList,fieldCnVOList);
|
|
|
|
|
}
|
|
|
|
|
case "buffernum_xe": {
|
|
|
|
|
List<BufferNumXe> bufferNumXeList = simulationAnalysisMapper.getBufferNumXe(bufferNameList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(3,2);
|
|
|
|
|
return beanToKeyValue(bufferNumXeList,fieldCnVOList);
|
|
|
|
|
}
|
|
|
|
|
case "buffernum_xy": {
|
|
|
|
|
List<BufferNumXy> bufferNumXyList = simulationAnalysisMapper.getBufferNumXy(bufferNameList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(6,2);
|
|
|
|
|
return beanToKeyValue(bufferNumXyList,fieldCnVOList);
|
|
|
|
|
}
|
|
|
|
|
case "buffernum_ze": {
|
|
|
|
|
List<BufferNumZe> bufferNumZeList = simulationAnalysisMapper.getBufferNumZe(bufferNameList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(5,2);
|
|
|
|
|
return beanToKeyValue(bufferNumZeList,fieldCnVOList);
|
|
|
|
|
}
|
|
|
|
|
case "buffernum_zy": {
|
|
|
|
|
List<BufferNumZy> bufferNumZyList = simulationAnalysisMapper.getBufferNumZy(bufferNameList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(4,2);
|
|
|
|
|
return beanToKeyValue(bufferNumZyList,fieldCnVOList);
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取OEE数据
|
|
|
|
|
*
|
|
|
|
|
* @param tableCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Object getOee(String tableCode) {
|
|
|
|
|
switch (tableCode) {
|
|
|
|
|
case "oee_bxg": {
|
|
|
|
|
List<OeeBxg> oeeBxgList = simulationAnalysisMapper.getOeeBxg();
|
|
|
|
|
List<OeeVO> oeeVOList = beanToKeyValue(oeeBxgList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(7,1);
|
|
|
|
|
return fieldNameToChinese(fieldCnVOList,oeeVOList);
|
|
|
|
|
}
|
|
|
|
|
case "oee_dj": {
|
|
|
|
|
List<OeeDj> oeeDjList = simulationAnalysisMapper.getOeeDj();
|
|
|
|
|
List<OeeVO> oeeVOList = beanToKeyValue(oeeDjList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(12,1);
|
|
|
|
|
return fieldNameToChinese(fieldCnVOList,oeeVOList);
|
|
|
|
|
}
|
|
|
|
|
case "oee_xe": {
|
|
|
|
|
List<OeeXe> oeeXeList = simulationAnalysisMapper.getOeeXe();
|
|
|
|
|
List<OeeVO> oeeVOList = beanToKeyValue(oeeXeList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(9,1);
|
|
|
|
|
return fieldNameToChinese(fieldCnVOList,oeeVOList);
|
|
|
|
|
}
|
|
|
|
|
case "oee_xy": {
|
|
|
|
|
List<OeeXy> oeeXyList = simulationAnalysisMapper.getOeeXy();
|
|
|
|
|
List<OeeVO> oeeVOList = beanToKeyValue(oeeXyList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(8,1);
|
|
|
|
|
return fieldNameToChinese(fieldCnVOList,oeeVOList);
|
|
|
|
|
}
|
|
|
|
|
case "oee_ze": {
|
|
|
|
|
List<OeeZe> oeeZeList = simulationAnalysisMapper.getOeeZe();
|
|
|
|
|
List<OeeVO> oeeVOList = beanToKeyValue(oeeZeList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(11,1);
|
|
|
|
|
return fieldNameToChinese(fieldCnVOList,oeeVOList);
|
|
|
|
|
}
|
|
|
|
|
case "oee_zy": {
|
|
|
|
|
List<OeeZy> oeeZyList = simulationAnalysisMapper.getOeeZy();
|
|
|
|
|
List<OeeVO> oeeVOList = beanToKeyValue(oeeZyList);
|
|
|
|
|
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(10,1);
|
|
|
|
|
return fieldNameToChinese(fieldCnVOList,oeeVOList);
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取对象的属性名和属性值并存入OeeVO对象的集合
|
|
|
|
|
* @param oeeList
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<OeeVO> beanToKeyValue(List oeeList) {
|
|
|
|
|
List<OeeVO> oeeVOList = new ArrayList<>();
|
|
|
|
|
for (Object object : oeeList) {
|
|
|
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(object);
|
|
|
|
|
Object status = jsonObject.get("status");
|
|
|
|
|
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
|
|
|
|
OeeVO oeeVO = new OeeVO();
|
|
|
|
|
Object value = entry.getValue();
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
if ("flag".equals(key) || "id".equals(key) || "status".equals(key)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
oeeVO.setName(key);
|
|
|
|
|
oeeVO.setValue(value);
|
|
|
|
|
oeeVO.setStatus(status);
|
|
|
|
|
oeeVOList.add(oeeVO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return oeeVOList;
|
|
|
|
|
}
|
|
|
|
|
public List<OeeVO> fieldNameToChinese(List<FieldCnVO> fieldCnVOList,List<OeeVO> oeeVOList) {
|
|
|
|
|
for (OeeVO oeeVO : oeeVOList) {
|
|
|
|
|
for (FieldCnVO fieldCnVO : fieldCnVOList) {
|
|
|
|
|
if (oeeVO.getName().equals(fieldCnVO.getFieldCode())) {
|
|
|
|
|
oeeVO.setName(fieldCnVO.getFieldName());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return oeeVOList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<BufferNumVO> beanToKeyValue(List bufferNumList,List<FieldCnVO> fieldCnVOList) {
|
|
|
|
|
List<BufferNumVO> bufferNumVOList = new ArrayList<>();
|
|
|
|
|
for (Object buffernum : bufferNumList) {
|
|
|
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(buffernum);
|
|
|
|
|
String recordTime = jsonObject.getString("recordTime");
|
|
|
|
|
List<BufferNumDTO> bufferNumDTOList = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
|
|
|
|
BufferNumDTO bufferNumDTO = new BufferNumDTO();
|
|
|
|
|
Object value = entry.getValue();
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
if(value == null || "recordTime".equals(key)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (FieldCnVO fieldCnVO : fieldCnVOList) {
|
|
|
|
|
if(key.equals(fieldCnVO.getFieldCode())){
|
|
|
|
|
bufferNumDTO.setBufferName(fieldCnVO.getFieldName());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bufferNumDTO.setBufferNum((String) value);
|
|
|
|
|
bufferNumDTOList.add(bufferNumDTO);
|
|
|
|
|
}
|
|
|
|
|
BufferNumVO bufferNumVO = new BufferNumVO();
|
|
|
|
|
bufferNumVO.setRecordTime(recordTime);
|
|
|
|
|
bufferNumVO.setBufferNumVOList(bufferNumDTOList);
|
|
|
|
|
bufferNumVOList.add(bufferNumVO);
|
|
|
|
|
}
|
|
|
|
|
return bufferNumVOList;
|
|
|
|
|
}
|
|
|
|
|
}
|