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.vo.BufferVO; import com.ipsplm.entity.simulation.vo.OeeVO; import com.ipsplm.entity.simulation.vo.PlantEquipmentUtilizationVO; import com.ipsplm.service.simulation.ISimulationAnalysisService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * @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 List getPlantEquipmentUtilization(Long flag) { List plantEquipmentUtilization = simulationAnalysisMapper.getPlantEquipmentUtilization(flag); List oeeVOList = beanToKeyValue(plantEquipmentUtilization); return oeeVOList; } /** * 获取工序列表 * * @param tableCode * @return */ @Override public List getProcessList(String tableCode) { return simulationAnalysisMapper.getProcessList(tableCode); } /** * 获取缓存数量时间 * * @param process * @return */ @Override public Object getBufferNum(String process) { List bufferNameList = simulationAnalysisMapper.getBufferName(process); String tableCode = bufferNameList.get(0).getTableCode(); switch (tableCode) { case "buffernum_bxg": { List bufferNumBxgList = simulationAnalysisMapper.getBufferNumBxg(bufferNameList); return bufferNumBxgList; } case "buffernum_dj": { List bufferNumDjList = simulationAnalysisMapper.getBufferNumDj(bufferNameList); return bufferNumDjList; } case "buffernum_xe": { List bufferNumXeList = simulationAnalysisMapper.getBufferNumXe(bufferNameList); return bufferNumXeList; } case "buffernum_xy": { List bufferNumXyList = simulationAnalysisMapper.getBufferNumXy(bufferNameList); return bufferNumXyList; } case "buffernum_ze": { List bufferNumZeList = simulationAnalysisMapper.getBufferNumZe(bufferNameList); return bufferNumZeList; } case "buffernum_zy": { List bufferNumZyList = simulationAnalysisMapper.getBufferNumZy(bufferNameList); return bufferNumZyList; } default: break; } return null; } /** * 获取OEE数据 * * @param tableCode * @return */ @Override public Object getOee(String tableCode) { switch (tableCode) { case "oee_bxg": { List oeeBxgList = simulationAnalysisMapper.getOeeBxg(); List oeeVOList = beanToKeyValue(oeeBxgList); return oeeVOList; } case "oee_dj": { List oeeDjList = simulationAnalysisMapper.getOeeDj(); List oeeVOList = beanToKeyValue(oeeDjList); return oeeVOList; } case "oee_xe": { List oeeXeList = simulationAnalysisMapper.getOeeXe(); List oeeVOList = beanToKeyValue(oeeXeList); return oeeVOList; } case "oee_xy": { List oeeXyList = simulationAnalysisMapper.getOeeXy(); List oeeVOList = beanToKeyValue(oeeXyList); return oeeVOList; } case "oee_ze": { List oeeZeList = simulationAnalysisMapper.getOeeZe(); List oeeVOList = beanToKeyValue(oeeZeList); return oeeVOList; } case "oee_zy": { List oeeZyList = simulationAnalysisMapper.getOeeZy(); List oeeVOList = beanToKeyValue(oeeZyList); return oeeVOList; } default: break; } return null; } /** * 获取对象的属性名和属性值并存入OeeVO对象的集合 * @param oeeList * @return */ public List beanToKeyValue(List oeeList) { List oeeVOList = new ArrayList<>(); for (Object object : oeeList) { JSONObject jsonObject = (JSONObject) JSON.toJSON(object); Object status = jsonObject.get("status"); for (Map.Entry 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; } }