自定义报表 结构调整

yun-zuoyi
wei.peng 5 years ago
parent 02171105fe
commit fe20003918

@ -29,4 +29,13 @@ public interface IReportService {
*/
@ApiOperation(value = "HQL 执行",notes = "执行 HQL")
List selectTemplateModel(TemplateModel model) throws Exception;
/**
* HQL
* @param model HQL Model
* @return
* @throws Exception
*/
@ApiOperation(value = "HQL 执行",notes = "执行 HQL")
Long countTemplateModel(TemplateModel model) throws Exception;
}

@ -1,6 +1,7 @@
package cn.estsh.i3plus.core.apiservice.dao;
import java.util.List;
import java.util.Map;
/**
* @Description :
@ -14,11 +15,11 @@ public interface IReportDao {
/**
*
* @param hql hql
* @param paramName
* @param paramValue
* @return
* @throws Exception
*/
List<Object[]> findByHqlObjects(String hql, String[] paramName, Object[] paramValue) throws Exception;
List<Object[]> findByHqlObjects(String hql, Map<String,Object> findParam) throws Exception;
Long findByHqlCount(String hql, Map<String,Object> findParam) throws Exception;
}

@ -5,10 +5,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.List;
import java.util.Map;
/**
* @Description :
@ -26,17 +28,28 @@ public class ReportDaoImpl implements IReportDao {
private EntityManager entityManager;
@Override
public List<Object[]> findByHqlObjects(String hql, String[] paramName, Object[] paramValue) throws Exception {
LOGGER.info(" find HQL:{} paramName:{} paramValue:{}", hql, paramName, paramValue);
public List<Object[]> findByHqlObjects(String hql, Map<String,Object> findParam) throws Exception {
LOGGER.info(" find HQL:{} find params :{}", hql, findParam);
Query queryObject = entityManager.createQuery(hql);
if(paramName != null && paramValue != null){
for (int i = 0; i < paramName.length; i++) {
if (paramValue[i] != null) {
queryObject.setParameter(paramName[i], paramValue[i].toString());
}
}
if(CollectionUtils.isEmpty(findParam)){
findParam.forEach((K, V) -> queryObject.setParameter(K, V));
}
entityManager.clear();
return queryObject.getResultList();
}
@Override
public Long findByHqlCount(String hql, Map<String, Object> findParam) throws Exception {
LOGGER.info(" find HQL:{} find params :{}", hql, findParam);
Query queryObject = entityManager.createQuery(hql);
if(CollectionUtils.isEmpty(findParam)){
findParam.forEach((K, V) -> queryObject.setParameter(K, V));
}
entityManager.clear();
return (Long)queryObject.getSingleResult();
}
}

@ -4,7 +4,6 @@ import cn.estsh.i3plus.core.api.iservice.base.IReportService;
import cn.estsh.i3plus.core.apiservice.dao.IReportDao;
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
import cn.estsh.i3plus.pojo.model.report.TemplateModel;
import org.hibernate.QueryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -36,8 +35,14 @@ public class ReportService implements IReportService {
}
@Override
public Long countTemplateModel(TemplateModel model) throws Exception {
LOGGER.info("报表执行 model :{}",model);
return reportDao.findByHqlCount(model.getCountHql(), model.getFindParam());
}
@Override
public List selectTemplateModel(TemplateModel model) throws Exception{
LOGGER.info("报表执行 model :{}",model);
return reportDao.findByHqlObjects(model.getHql(), model.getParamName(), model.getParamValue());
return reportDao.findByHqlObjects(model.getSelectHql(), model.getFindParam());
}
}

@ -190,7 +190,7 @@ public class SysMenuService implements ISysMenuService {
public List<SysMenu> refreshSysMenu(List<SysMenu> list) {
LOGGER.info("系统功能 SYS_MENU list :{}", list);
sysMenuRDao.deleteAll();
// sysMenuRDao.deleteAll();
return sysMenuRDao.saveAll(list);
}

Loading…
Cancel
Save