use of org.springframework.cglib.beans.BeanMap in project jeecg-boot by jeecgboot.
the class RedisServiceImpl method getMapForReport.
/**
* 查询redis信息for报表
* @param type 1redis key数量 2 占用内存 3redis信息
* @return
* @throws RedisConnectException
*/
@Override
public Map<String, JSONArray> getMapForReport(String type) throws RedisConnectException {
Map<String, JSONArray> mapJson = new HashMap<String, JSONArray>();
JSONArray json = new JSONArray();
if ("3".equals(type)) {
List<RedisInfo> redisInfo = getRedisInfo();
for (RedisInfo info : redisInfo) {
Map<String, Object> map = Maps.newHashMap();
BeanMap beanMap = BeanMap.create(info);
for (Object key : beanMap.keySet()) {
map.put(key + "", beanMap.get(key));
}
json.add(map);
}
mapJson.put("data", json);
return mapJson;
}
for (int i = 0; i < 5; i++) {
JSONObject jo = new JSONObject();
Map<String, Object> map;
if ("1".equals(type)) {
map = getKeysSize();
jo.put("value", map.get("dbSize"));
} else {
map = getMemoryInfo();
Integer used_memory = Integer.valueOf(map.get("used_memory").toString());
jo.put("value", used_memory / 1000);
}
String create_time = DateUtil.formatTime(DateUtil.date((Long) map.get("create_time") - (4 - i) * 1000));
jo.put("name", create_time);
json.add(jo);
}
mapJson.put("data", json);
return mapJson;
}
use of org.springframework.cglib.beans.BeanMap in project easyexcel by alibaba.
the class TempWriteTest method cglib.
@Test
public void cglib() {
TempWriteData tempWriteData = new TempWriteData();
tempWriteData.setName("1");
tempWriteData.setName1("2");
BeanMap beanMap = BeanMapUtils.create(tempWriteData);
log.info("d1{}", beanMap.get("name"));
log.info("d2{}", beanMap.get("name1"));
TempWriteData tempWriteData2 = new TempWriteData();
Map<String, String> map = new HashMap<>();
map.put("name", "zs");
BeanMap beanMap2 = BeanMapUtils.create(tempWriteData2);
beanMap2.putAll(map);
log.info("3{}", tempWriteData2.getName());
}
use of org.springframework.cglib.beans.BeanMap in project easyexcel by alibaba.
the class ModelBuildEventListener method buildUserModel.
private Object buildUserModel(Map<Integer, ReadCellData<?>> cellDataMap, ReadSheetHolder readSheetHolder, AnalysisContext context) {
ExcelReadHeadProperty excelReadHeadProperty = readSheetHolder.excelReadHeadProperty();
Object resultModel;
try {
resultModel = excelReadHeadProperty.getHeadClazz().newInstance();
} catch (Exception e) {
throw new ExcelDataConvertException(context.readRowHolder().getRowIndex(), 0, new ReadCellData<>(CellDataTypeEnum.EMPTY), null, "Can not instance class: " + excelReadHeadProperty.getHeadClazz().getName(), e);
}
Map<Integer, Head> headMap = excelReadHeadProperty.getHeadMap();
BeanMap dataMap = BeanMapUtils.create(resultModel);
for (Map.Entry<Integer, Head> entry : headMap.entrySet()) {
Integer index = entry.getKey();
Head head = entry.getValue();
String fieldName = head.getFieldName();
if (!cellDataMap.containsKey(index)) {
continue;
}
ReadCellData<?> cellData = cellDataMap.get(index);
Object value = ConverterUtils.convertToJavaObject(cellData, head.getField(), ClassUtils.declaredExcelContentProperty(dataMap, readSheetHolder.excelReadHeadProperty().getHeadClazz(), fieldName), readSheetHolder.converterMap(), context, context.readRowHolder().getRowIndex(), index);
if (value != null) {
dataMap.put(fieldName, value);
}
}
return resultModel;
}
use of org.springframework.cglib.beans.BeanMap in project SaaS_IHRM by Han-YLun.
the class BeanMapUtils method mapToBean.
/**
* 将map集合中的数据转化为指定对象的同名属性中
*/
public static <T> T mapToBean(Map<String, Object> map, Class<T> clazz) throws Exception {
T bean = clazz.newInstance();
BeanMap beanMap = BeanMap.create(bean);
beanMap.putAll(map);
return bean;
}
use of org.springframework.cglib.beans.BeanMap in project bubble-fireworks by fxbin.
the class BeanUtils method object2Map.
/**
* object2Map
*
* @since 2020/5/28 10:36
* @param object java.lang.Object
* @param timestampDefault 日期类型是否默认默认转时间戳
* @return java.util.Map<java.lang.String,java.lang.Object>
*/
public Map<String, Object> object2Map(Object object, boolean timestampDefault) {
Assert.notNull(object, "object can't be null");
BeanMap beanMap = BeanMap.create(object);
if (timestampDefault) {
Map<String, Object> map = new HashMap<>();
beanMap.keySet().forEach(key -> map.put(String.valueOf(key), DateUtils.isDateType(beanMap.get(key)) ? DateUtils.toEpochMilli(beanMap.get(key)) : beanMap.get(key)));
return map;
}
return beanMap;
}
Aggregations