cn.foxtech.common.entity.service.devicevalue.task.DeviceValueExTaskMaker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fox-edge-server-common-entity-service Show documentation
Show all versions of fox-edge-server-common-entity-service Show documentation
fox-edge-server-common-entity-service
package cn.foxtech.common.entity.service.devicevalue.task;
import cn.foxtech.common.entity.entity.BaseEntity;
import cn.foxtech.common.entity.entity.DeviceValueExTaskEntity;
import cn.foxtech.common.entity.entity.DeviceValueExTaskPo;
import cn.foxtech.common.utils.json.JsonUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* OperateTemplatePo是数据库格式的对象,OperateTemplateEntity是内存格式的对象,两者需要进行转换
*/
public class DeviceValueExTaskMaker {
/**
* PO转Entity
*
* @param poList PO列表
* @return 实体列表
*/
public static List makePoList2EntityList(List poList) {
List operateRecordList = new ArrayList<>();
for (BaseEntity entity : poList) {
DeviceValueExTaskPo po = (DeviceValueExTaskPo) entity;
DeviceValueExTaskEntity config = DeviceValueExTaskMaker.makePo2Entity(po);
operateRecordList.add(config);
}
return operateRecordList;
}
public static DeviceValueExTaskPo makeEntity2Po(DeviceValueExTaskEntity entity) {
DeviceValueExTaskPo result = new DeviceValueExTaskPo();
result.bind(entity);
result.setTaskParam(JsonUtils.buildJsonWithoutException(entity.getTaskParam()));
return result;
}
public static DeviceValueExTaskEntity makePo2Entity(DeviceValueExTaskPo entity) {
DeviceValueExTaskEntity result = new DeviceValueExTaskEntity();
result.bind(entity);
try {
Map params = JsonUtils.buildObject(entity.getTaskParam(), Map.class);
if (params != null) {
result.setTaskParam(params);
} else {
System.out.println("设备配置参数转换Json对象失败:" + entity.getTaskName() + ":" + entity.getTaskParam());
}
} catch (Exception e) {
System.out.println("设备配置参数转换Json对象失败:" + entity.getTaskName() + ":" + entity.getTaskParam());
e.printStackTrace();
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy