|
@ -9,10 +9,16 @@ import com.yihu.ehr.framework.util.operator.CollectionUtil;
|
|
|
import com.yihu.ehr.framework.util.operator.StringUtil;
|
|
|
import com.yihu.ehr.framework.util.sql.RequestParamTransformer;
|
|
|
import com.yihu.ehr.framework.util.sql.SqlCreator;
|
|
|
import com.yihu.ehr.standard.model.adapter.AdapterSchemeVersionModel;
|
|
|
import com.yihu.ehr.standard.model.standard.StandardModel;
|
|
|
import com.yihu.ehr.standard.model.standard.StandardVersionModel;
|
|
|
import com.yihu.ehr.system.model.SystemOrganization;
|
|
|
import org.hibernate.Criteria;
|
|
|
import org.hibernate.Query;
|
|
|
import org.hibernate.SQLQuery;
|
|
|
import org.hibernate.Session;
|
|
|
import org.hibernate.criterion.Order;
|
|
|
import org.hibernate.criterion.Restrictions;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@ -41,51 +47,39 @@ public class StdPublisherService extends SQLGeneralDAO {
|
|
|
}
|
|
|
|
|
|
private List<SystemOrganization> getList(Map<String, String> query, Map<String, String> order, Integer limit, Integer offset) {
|
|
|
SqlCreator sqlCreator = new SqlCreator(SystemOrganization.class);
|
|
|
for (String key : query.keySet()) {
|
|
|
sqlCreator.equalCondition(key, query.get(key));
|
|
|
}
|
|
|
for (String key : order.keySet()) {
|
|
|
sqlCreator.order(key, order.get(key));
|
|
|
Session session = getCurrentSession();
|
|
|
Criteria criteria = session.createCriteria(SystemOrganization.class);
|
|
|
if (query != null) {
|
|
|
for (String key : query.keySet()) {
|
|
|
criteria.add(Restrictions.eq(key, query.get(key)));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String sql = sqlCreator.selectData("system_organization");
|
|
|
|
|
|
Query sessionQuery = getQuery(sqlCreator, sql);
|
|
|
if (limit != null) {
|
|
|
sessionQuery.setMaxResults(limit);
|
|
|
criteria.setMaxResults(limit);
|
|
|
if (offset != null) {
|
|
|
sessionQuery.setFirstResult((offset - 1) * limit);
|
|
|
criteria.setFirstResult((offset - 1) * limit);
|
|
|
}
|
|
|
}
|
|
|
return (List<SystemOrganization>) sessionQuery.list();
|
|
|
}
|
|
|
|
|
|
|
|
|
public SystemOrganization get(Integer stdPublisherId) {
|
|
|
try {
|
|
|
SqlCreator sqlCreator = new SqlCreator(SystemOrganization.class);
|
|
|
sqlCreator.equalCondition("id", stdPublisherId);
|
|
|
String sql = sqlCreator.selectData("system_organization");
|
|
|
Query query = getQuery(sqlCreator, sql);
|
|
|
return (SystemOrganization) query.uniqueResult();
|
|
|
} catch (Exception e) {
|
|
|
throw new ApiException(ErrorCode.GetPublisherFailed);
|
|
|
if (order != null) {
|
|
|
for (String key : order.keySet()) {
|
|
|
if (order.get(key).equals(Constants.ASC)) {
|
|
|
criteria.addOrder(Order.asc(key));
|
|
|
} else if (order.get(key).equals(Constants.DESC)) {
|
|
|
criteria.addOrder(Order.desc(key));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
List<SystemOrganization> systemOrganizationList = criteria.list();
|
|
|
|
|
|
return systemOrganizationList;
|
|
|
}
|
|
|
|
|
|
public SystemOrganization getStandardPublisher() {
|
|
|
public SystemOrganization get(Integer stdPublisherId) {
|
|
|
try {
|
|
|
SqlCreator sqlCreator = new SqlCreator(SystemOrganization.class);
|
|
|
String paramSql = "select s.org_id from system_param s where s.param_key = '"+ Constants.STANDARD+"'";
|
|
|
Query paramQuery = getCurrentSession().createSQLQuery(paramSql);
|
|
|
List list = paramQuery.list();
|
|
|
String publisherCode = StringUtil.toString(list.get(0));
|
|
|
|
|
|
sqlCreator.equalCondition("code", publisherCode);
|
|
|
String sql = sqlCreator.selectData("system_organization");
|
|
|
Query query = getQuery(sqlCreator, sql);
|
|
|
return (SystemOrganization) query.uniqueResult();
|
|
|
Session session = getCurrentSession();
|
|
|
Criteria criteria = session.createCriteria(SystemOrganization.class);
|
|
|
criteria.add(Restrictions.eq("id", stdPublisherId));
|
|
|
return (SystemOrganization) criteria.uniqueResult();
|
|
|
} catch (Exception e) {
|
|
|
throw new ApiException(ErrorCode.GetPublisherFailed);
|
|
|
}
|