package com.vci.server.portal.service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.vci.server.base.persistence.dao.BaseService;
|
import com.vci.server.portal.dao.impl.PLCommandParameterEntityDaoImpl;
|
import com.vci.server.portal.entity.PLCommandParameterEntity;
|
import com.vci.server.portal.entity.PLTabPageEntity;
|
|
public class PLCommandParameterEntityService extends BaseService{
|
// private PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
private static PLCommandParameterEntityService instance = null;
|
|
private PLCommandParameterEntityService(){
|
|
}
|
|
public static PLCommandParameterEntityService getInstance(){
|
if(instance == null){
|
instance = new PLCommandParameterEntityService();
|
}
|
return instance;
|
}
|
/**
|
* 新增对象
|
* @param obj
|
* @throws Throwable
|
*/
|
public boolean savePLCommandParameterEntity(PLCommandParameterEntity obj) throws Throwable {
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
daoImpl.saveOrUpdate(obj);
|
return true;
|
} catch(Throwable e){
|
throw e;
|
}
|
}
|
|
public boolean batchSavePLCommandParameterEntity(PLCommandParameterEntity[] objs) throws Throwable {
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
List<PLCommandParameterEntity> list = new ArrayList<PLCommandParameterEntity>();
|
int batchNum = 200;
|
for (int i = 0; i < objs.length; i++) {
|
list.add(objs[i]);
|
if ((i + 1) % batchNum == 0) {
|
daoImpl.saveOrUpdateAll(list);
|
list = new ArrayList<PLCommandParameterEntity>();
|
}
|
}
|
daoImpl.saveOrUpdateAll(list);
|
return true;
|
} catch(Throwable e){
|
throw e;
|
}
|
}
|
|
/**
|
* 更新对象
|
* @param obj
|
* @return
|
* @throws Throwable
|
*/
|
public boolean updatePLCommandParameterEntity(PLCommandParameterEntity obj) throws Throwable{
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
PLCommandParameterEntity objGet = daoImpl.getById(obj.getId());
|
if (objGet == null) {
|
daoImpl.saveOrUpdate(obj);
|
} else {
|
// objGet.setId(obj.getId());
|
objGet.setPlCommandOId(obj.getPlCommandOId());
|
objGet.setPlKey(obj.getPlKey());
|
objGet.setPlValue(obj.getPlValue());
|
// objGet.setPlCreateTime(obj.getPlCreateTime());
|
objGet.setPlCreateUser(obj.getPlCreateUser());
|
objGet.setPlModifyTime(obj.getPlModifyTime());
|
objGet.setPlModifyUser(obj.getPlModifyUser());
|
objGet.setPlLicensOrs(obj.getPlLicensOrs());
|
daoImpl.saveOrUpdate(objGet);
|
}
|
return true;
|
} catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 删除对象
|
* @param obj
|
* @return
|
* @throws Throwable
|
*/
|
public boolean deletePLCommandParameterEntity(PLCommandParameterEntity obj) throws Throwable{
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
daoImpl.delete(obj);
|
return true;
|
} catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据Id删除指定的对象
|
* @param id
|
* @return
|
* @throws Throwable
|
*/
|
public boolean deletePLCommandParameterEntityById(String id) throws Throwable{
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
PLCommandParameterEntity obj = daoImpl.getById(id);
|
if (obj != null) {
|
daoImpl.delete(obj);
|
}
|
return true;
|
} catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据TabButtonID删除参数信息
|
* @param id
|
* @return
|
* @throws Throwable
|
*/
|
public boolean deletePLCommandParameterByTabButtonId(String id) throws Throwable{
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
String sql = "delete from plcommandparameter t where t.plcommandoid = '" + id + "'";
|
daoImpl.createSQLQuery(sql);
|
return true;
|
} catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据ID获取指定的PLCommandParameter
|
* @param plOId
|
* @return
|
* @throws Throwable
|
*/
|
public PLCommandParameterEntity getPLCommandParameterEntityById(String plOId) throws Throwable {
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
return daoImpl.getById(plOId);
|
} catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据plCommandOId获取PLCommandParameterArray
|
* @param plCommandOId
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLCommandParameterEntity> getPLCommandParameterEntitysByCommandOId(
|
String plCommandOId) throws Throwable {
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
List<PLCommandParameterEntity> list = daoImpl.findEntities("from PLCommandParameterEntity where plCommandOId = '" + plCommandOId + "'");
|
return list;
|
} catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 获取所有结果集,缓存使用
|
* @auther lmh,20150728
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLCommandParameterEntity> getAllPLCommandParameterEntitys() throws Throwable {
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
List<PLCommandParameterEntity> list = daoImpl.findEntities("from PLCommandParameterEntity");
|
return list;
|
} catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据plKey获取PLCommandParameterArray
|
* @param plCommandOId
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLCommandParameterEntity> getPLCommandParameterEntitysByKey(
|
String plkey) throws Throwable {
|
try {
|
PLCommandParameterEntityDaoImpl daoImpl = new PLCommandParameterEntityDaoImpl();
|
List<PLCommandParameterEntity> list = daoImpl.findEntities("from PLCommandParameterEntity where plkey = '" + plkey + "'");
|
return list;
|
} catch(Throwable e){
|
throw e;
|
}
|
|
}
|
}
|