package com.vci.server.portal.service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import org.hibernate.Criteria;
|
import org.hibernate.criterion.Criterion;
|
import org.hibernate.criterion.MatchMode;
|
import org.hibernate.criterion.Order;
|
import org.hibernate.criterion.Projections;
|
import org.hibernate.criterion.Restrictions;
|
import org.omg.CORBA.IntHolder;
|
|
import com.vci.server.base.persistence.dao.BaseService;
|
import com.vci.server.portal.dao.impl.PLUILayoutEntityDaoImpl;
|
import com.vci.server.portal.entity.PLUILayoutEntity;
|
|
public class PLUILayoutEntityService extends BaseService{
|
// private PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
private static PLUILayoutEntityService instance = null;
|
|
private PLUILayoutEntityService(){
|
|
}
|
|
public static PLUILayoutEntityService getInstance(){
|
if(instance == null){
|
instance = new PLUILayoutEntityService();
|
}
|
return instance;
|
}
|
/**
|
* 新增对象
|
* @param obj
|
* @throws Throwable
|
*/
|
public boolean savePLUILayoutEntity(PLUILayoutEntity obj) throws Throwable {
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
daoImpl.saveOrUpdate(obj);
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
public boolean batchsavePLUILayoutEntity(PLUILayoutEntity[] objs) throws Throwable {
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
List<PLUILayoutEntity> list = new ArrayList<PLUILayoutEntity>();
|
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<PLUILayoutEntity>();
|
}
|
}
|
daoImpl.saveOrUpdateAll(list);
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
/**
|
* 更新对象
|
* @param obj
|
* @return
|
* @throws Throwable
|
*/
|
public boolean updatePLUILayoutEntity(PLUILayoutEntity obj) throws Throwable{
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
PLUILayoutEntity objGet = daoImpl.getById(obj.getId());
|
if (objGet == null) {
|
daoImpl.saveOrUpdate(obj);
|
} else {
|
// objGet.setId(obj.getId());
|
objGet.setPlCode(obj.getPlCode());
|
objGet.setPlName(obj.getPlName());
|
objGet.setPlRelatedType(obj.getPlRelatedType());
|
objGet.setPlStyle(obj.getPlStyle());
|
objGet.setPlDesc(obj.getPlDesc());
|
objGet.setPlIsShowTab(obj.getPlIsShowTab());
|
objGet.setPlIsShowForm(obj.getPlIsShowForm());
|
objGet.setPlIsShowNavigator(obj.getPlIsShowNavigator());
|
// 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 deletePLUILayoutEntity(PLUILayoutEntity obj) throws Throwable{
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
daoImpl.delete(obj);
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据Id删除指定的对象
|
* @param id
|
* @return
|
* @throws Throwable
|
*/
|
public boolean deletePLUILayoutEntityById(String id) throws Throwable{
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
PLUILayoutEntity obj = daoImpl.getById(id);
|
if (obj != null) {
|
daoImpl.delete(obj);
|
}
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据ID获取指定的PLUILayout
|
* @param plOId
|
* @return
|
* @throws Throwable
|
*/
|
public PLUILayoutEntity getPLUILayoutEntityById(
|
String plOId) throws Throwable {
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
return daoImpl.getById(plOId);
|
}catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据关联类型获取PLUILayoutArray
|
* @param plRelatedType
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLUILayoutEntity> getPLUILayoutsByRelatedType(
|
String plRelatedType) throws Throwable {
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
List<PLUILayoutEntity> list = daoImpl.findEntities("from PLUILayoutEntity where plRelatedType = '" + plRelatedType + "'");
|
return list;
|
}catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
public List<PLUILayoutEntity> getPLUILayoutsByRelatedTypeAndQueryInfo(
|
String plRelatedType, String name, String code,
|
int pageIndex, int pageSize, IntHolder total) throws Throwable{
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
Criteria cter = daoImpl.createCriteria();
|
cter.add(Restrictions.eq("plRelatedType", plRelatedType));
|
cter.setFirstResult((pageIndex - 1) * pageSize);
|
cter.setMaxResults(pageIndex * pageSize);
|
|
List<Criterion> cs = new ArrayList<Criterion>();
|
if(name != null && !"".equals(name)){
|
Criterion c = Restrictions.like("plName", name, MatchMode.ANYWHERE);
|
cter.add(c);
|
cs.add(c);
|
}
|
if(code != null && !"".equals(code)){
|
Criterion c = Restrictions.like("plCode", code, MatchMode.ANYWHERE);
|
cter.add(c);
|
cs.add(c);
|
}
|
cter.addOrder(Order.asc("plCode"));
|
@SuppressWarnings("unchecked")
|
List<PLUILayoutEntity> list = cter.list();
|
|
Criteria cterCount = daoImpl.createCriteria();
|
cterCount.add(Restrictions.eq("plRelatedType", plRelatedType));
|
cterCount.setProjection(Projections.rowCount());
|
for (Criterion c : cs){
|
cterCount.add( c);
|
}
|
int totalValue = ((Number) cterCount.list().get(0)).intValue();
|
total.value = totalValue;
|
return list;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
|
/**
|
* 根据关联类型以及编号获取PLUILayoutArray
|
* @param plRelatedType
|
* @param code
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLUILayoutEntity> getPLUILayoutEntity(
|
String plRelatedType, String code) throws Throwable {
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
List<PLUILayoutEntity> list = daoImpl.findEntities("from PLUILayoutEntity where plRelatedType = '" + plRelatedType + "' and plCode = '" + code + "'");
|
return list;
|
}catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 通过对plname,plcode两个值 的模糊查询获取列表
|
* @param contentStr
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLUILayoutEntity> getPLUILayoutEntity(String contentStr) throws Throwable {
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
List<PLUILayoutEntity> list = daoImpl.findEntities("from PLUILayoutEntity where plName like '%" + contentStr + "%' or plCode like '%" +contentStr + "%'");
|
return list;
|
}catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 查询全量列表,缓存使用
|
* @author lmh,2015-07-22
|
* @param
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLUILayoutEntity> getAllPLUILayoutEntitys() throws Throwable {
|
try {
|
PLUILayoutEntityDaoImpl daoImpl = new PLUILayoutEntityDaoImpl();
|
//List<PLUILayoutEntity> list = daoImpl.findEntities("from PLUILayoutEntity where plRelatedType in (SELECT name FROM PLBTMTYPE) OR plRelatedType in (select name from pllinktype)");
|
List<PLUILayoutEntity> list = daoImpl.findEntities("from PLUILayoutEntity");
|
return list;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
}
|