|
|
|
@ -10,6 +10,7 @@ import com.ipsplm.service.simulation.ISimulationAnalysisService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -157,20 +158,28 @@ public class SimulationAnalysisServiceImpl implements ISimulationAnalysisService
|
|
|
|
|
*/
|
|
|
|
|
public List<OeeVO> beanToKeyValue(List oeeList) {
|
|
|
|
|
List<OeeVO> oeeVOList = new ArrayList<>();
|
|
|
|
|
//通过反射获取字段
|
|
|
|
|
Class<?> clazz = oeeList.get(0).getClass();
|
|
|
|
|
Field[] fields = clazz.getDeclaredFields();
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
// 按字段顺序处理
|
|
|
|
|
for (Field field : fields) {
|
|
|
|
|
String key = field.getName();
|
|
|
|
|
if ("flag".equals(key) || "id".equals(key) || "status".equals(key)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
oeeVO.setName(key);
|
|
|
|
|
oeeVO.setValue(value);
|
|
|
|
|
oeeVO.setStatus(status);
|
|
|
|
|
oeeVOList.add(oeeVO);
|
|
|
|
|
|
|
|
|
|
if (jsonObject.containsKey(key)) {
|
|
|
|
|
OeeVO oeeVO = new OeeVO();
|
|
|
|
|
oeeVO.setName(key);
|
|
|
|
|
oeeVO.setValue(jsonObject.get(key));
|
|
|
|
|
oeeVO.setStatus(status);
|
|
|
|
|
oeeVOList.add(oeeVO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return oeeVOList;
|
|
|
|
|