You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
9.1 KiB
Java

package com.ipsplm.service.simulation.impl;
9 months ago
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ipsplm.dao.simulation.SimulationAnalysisMapper;
9 months ago
import com.ipsplm.entity.simulation.*;
9 months ago
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;
9 months ago
import java.util.*;
9 months ago
/**
* @Description 仿
* @Author lulicheng
* @Date 2024-07-31 1020
* @Version 1.0
*/
@Service
public class SimulationAnalysisServiceImpl implements ISimulationAnalysisService {
@Autowired
private SimulationAnalysisMapper simulationAnalysisMapper;
/**
*
*
* @param flag
* @return
*/
@Override
9 months ago
public Map<String,Object> getPlantEquipmentUtilization(Long flag) {
String simEndTime = simulationAnalysisMapper.getSimEndTime();
9 months ago
List<PlantEquipmentUtilizationVO> plantEquipmentUtilization = simulationAnalysisMapper.getPlantEquipmentUtilization(flag);
List<OeeVO> oeeVOList = beanToKeyValue(plantEquipmentUtilization);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(null,1);
9 months ago
Map<String,Object> result = new HashMap<>();
result.put("simEndTime",simEndTime);
result.put("oeeList",fieldNameToChinese(fieldCnVOList,oeeVOList));
return result;
9 months ago
}
/**
*
*
* @param tableCode
* @return
*/
@Override
public List<String> getProcessList(String tableCode) {
return simulationAnalysisMapper.getProcessList(tableCode);
}
/**
*
9 months ago
*
* @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);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(1,2);
return beanToKeyValue(bufferNumBxgList,fieldCnVOList);
}
case "buffernum_dj": {
List<BufferNumDj> bufferNumDjList = simulationAnalysisMapper.getBufferNumDj(bufferNameList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(2,2);
return beanToKeyValue(bufferNumDjList,fieldCnVOList);
}
case "buffernum_xe": {
List<BufferNumXe> bufferNumXeList = simulationAnalysisMapper.getBufferNumXe(bufferNameList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(3,2);
return beanToKeyValue(bufferNumXeList,fieldCnVOList);
}
case "buffernum_xy": {
List<BufferNumXy> bufferNumXyList = simulationAnalysisMapper.getBufferNumXy(bufferNameList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(6,2);
return beanToKeyValue(bufferNumXyList,fieldCnVOList);
}
case "buffernum_ze": {
List<BufferNumZe> bufferNumZeList = simulationAnalysisMapper.getBufferNumZe(bufferNameList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(5,2);
return beanToKeyValue(bufferNumZeList,fieldCnVOList);
}
case "buffernum_zy": {
List<BufferNumZy> bufferNumZyList = simulationAnalysisMapper.getBufferNumZy(bufferNameList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(4,2);
return beanToKeyValue(bufferNumZyList,fieldCnVOList);
}
default:
break;
}
return null;
}
9 months ago
/**
* 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);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(7,1);
return fieldNameToChinese(fieldCnVOList,oeeVOList);
9 months ago
}
case "oee_dj": {
List<OeeDj> oeeDjList = simulationAnalysisMapper.getOeeDj();
List<OeeVO> oeeVOList = beanToKeyValue(oeeDjList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(12,1);
return fieldNameToChinese(fieldCnVOList,oeeVOList);
9 months ago
}
case "oee_xe": {
List<OeeXe> oeeXeList = simulationAnalysisMapper.getOeeXe();
List<OeeVO> oeeVOList = beanToKeyValue(oeeXeList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(9,1);
return fieldNameToChinese(fieldCnVOList,oeeVOList);
9 months ago
}
case "oee_xy": {
List<OeeXy> oeeXyList = simulationAnalysisMapper.getOeeXy();
List<OeeVO> oeeVOList = beanToKeyValue(oeeXyList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(8,1);
return fieldNameToChinese(fieldCnVOList,oeeVOList);
9 months ago
}
case "oee_ze": {
List<OeeZe> oeeZeList = simulationAnalysisMapper.getOeeZe();
List<OeeVO> oeeVOList = beanToKeyValue(oeeZeList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(11,1);
return fieldNameToChinese(fieldCnVOList,oeeVOList);
9 months ago
}
case "oee_zy": {
List<OeeZy> oeeZyList = simulationAnalysisMapper.getOeeZy();
List<OeeVO> oeeVOList = beanToKeyValue(oeeZyList);
9 months ago
List<FieldCnVO> fieldCnVOList = simulationAnalysisMapper.getFieldInfo(10,1);
return fieldNameToChinese(fieldCnVOList,oeeVOList);
9 months ago
}
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;
}
9 months ago
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;
}
}