Commit a1fd855b authored by 雍欢's avatar 雍欢

自定义查询SQL方言

parent c37b9fd1
create or replace view `v_sa_oporg_exclude_pos` (`id`, `type_id`, `code`, `name`, `long_name`, `parent_id`, `full_id`, `full_code`, `full_name`, `org_kind_id`, `depth`, `person_id`, `node_kind_id`, `description`, `status`, `sequence`, `version`, `org_code`, `dept_code`, `position_code`, `person_member_code`, `is_center`, `center_code`, `org_id`, `dept_id`, `position_id`, `person_member_id`, `center_id`, `org_name`, `dept_name`, `position_name`, `person_member_name`, `center_name`, `full_sequence`, `full_org_kind_id`, `is_virtual`) as
select id, type_id, code, name, long_name,
(case org_kind_id when 'psm' then dept_id else parent_id end) parent_id,
full_id,
full_code, full_name, org_kind_id, depth, person_id, node_kind_id,
description, status, sequence, version, org_code, dept_code,
position_code, person_member_code, is_center, center_code, org_id,
dept_id, position_id, person_member_id, center_id, org_name,
dept_name, position_name, person_member_name, center_name,
full_sequence, full_org_kind_id, is_virtual
from sa_oporg
where org_kind_id != 'pos';
CREATE
OR REPLACE VIEW V_ACT_HI_PROCINST (
PROC_INST_ID_,
BUSINESS_KEY_,
PROC_DEF_ID_,
PROCESS_DEFINITION_KEY_,
PROC_FULL_ID,
PROC_FULL_NAME,
PROC_NAME,
PROC_SYS_NAME,
START_TIME_,
END_TIME_,
APPLICANT_PERSON_MEMBER_ID_,
APPLICANT_PERSON_MEMBER_NAME_,
APPLICANT_DEPT_NAME_,
APPLICANT_ORG_NAME_,
PROC_STATUS_ID_
) AS SELECT
pe.id_ AS proc_inst_id_,
pe.business_key_,
pe.proc_def_id_,
pe.key_ AS process_definition_key_,
pdf.full_id proc_full_id,
pdf.full_name proc_full_name,
pdf. NAME proc_name,
substr(
pdf.full_name,
2,
instr(substr(pdf.full_name,3), '/') - 2
) proc_sys_name,
pe.start_time_,
pe.end_time_,
pe.applicant_person_member_id_,
pe.applicant_person_member_name_,
pe.applicant_dept_name_,
pe.applicant_org_name_,
pe.status_id_ proc_status_id_
FROM
act_hi_procinst_extension pe
join act_re_procdef pd on pe.proc_def_id_ = pd.id_
left join wf_procdef pdf on pd.key_ = pdf.proc_id
WHERE
pdf.node_kind_id = 'proc';
\ No newline at end of file
DROP VIEW "SYS_USERS_VIEW"; DROP VIEW "SYS_USERS_VIEW"; -- 不需要
DROP VIEW "V_ACT_HI_PROCINST"; DROP VIEW "V_ACT_HI_PROCINST";
DROP VIEW "V_ACT_HI_TASK"; DROP VIEW "V_ACT_HI_TASK"; -- 不需要
DROP VIEW "V_ACT_HI_TASK_FOR_DELETE"; DROP VIEW "V_ACT_HI_TASK_FOR_DELETE"; -- 不需要
DROP VIEW "V_ACT_RU_TASK"; DROP VIEW "V_ACT_RU_TASK"; -- 不需要
DROP VIEW "V_SA_OPORG_EXCLUDE_POS"; DROP VIEW "V_SA_OPORG_EXCLUDE_POS";
CREATE OR REPLACE VIEW "SYS_USERS_VIEW" ("EMPID", "EMPNAME", "USERID", "STATUS", "PASSWORD", "ORGID_ID") AS CREATE OR REPLACE VIEW "SYS_USERS_VIEW" ("EMPID", "EMPNAME", "USERID", "STATUS", "PASSWORD", "ORGID_ID") AS
......
...@@ -48,12 +48,12 @@ public class AgentApplicationImpl extends BaseApplication implements AgentApplic ...@@ -48,12 +48,12 @@ public class AgentApplicationImpl extends BaseApplication implements AgentApplic
@Override @Override
public Agent loadValidAgent(String clientPsmId) { public Agent loadValidAgent(String clientPsmId) {
QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "agent"); QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "agent");
String sql = queryDescriptor.getSqlByName("loadValid"); String jpql = queryDescriptor.getSqlByName("loadValid");
Map<String, Object> params = new HashMap<String, Object>(1); Map<String, Object> params = new HashMap<>(1);
params.put("psmId", clientPsmId); params.put("psmId", clientPsmId);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<Agent> agents = this.generalRepository.query(sql, params); List<Agent> agents = this.generalRepository.query(jpql, params);
if (agents.size() > 0) { if (agents.size() > 0) {
return agents.get(0); return agents.get(0);
} }
......
...@@ -18,8 +18,7 @@ public class VersionListener { ...@@ -18,8 +18,7 @@ public class VersionListener {
private Long getNextId() { private Long getNextId() {
SQLExecutorDao sqlExecutor = ApplicationContextWrapper.getBean("sqlExecutorDao", SQLExecutorDao.class); SQLExecutorDao sqlExecutor = ApplicationContextWrapper.getBean("sqlExecutorDao", SQLExecutorDao.class);
QueryDescriptor queryDescriptor = sqlExecutor.getQuery("config/uasp/query/bmp/common.xml", "common"); QueryDescriptor queryDescriptor = sqlExecutor.getQuery("config/uasp/query/bmp/common.xml", "common");
Long version = sqlExecutor.getSqlQuery().getJDBCDao().queryToLong(queryDescriptor.getSqlByName("nextVersion")); return sqlExecutor.getSqlQuery().getJDBCDao().queryToLong(String.format(queryDescriptor.getSqlByName("nextSequence"), "version_seq"));
return version;
} }
@PrePersist @PrePersist
......
package com.huigou.data.domain.service; package com.huigou.data.domain.service;
import java.sql.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
......
...@@ -13,7 +13,7 @@ public interface JDBCDao { ...@@ -13,7 +13,7 @@ public interface JDBCDao {
/** /**
* 正则表达式去除空格,制表符及换行符 * 正则表达式去除空格,制表符及换行符
*/ */
static final Pattern pattern = Pattern.compile("\t|\r|\n"); Pattern pattern = Pattern.compile("\t|\r|\n");
DataSource getDataSource(); DataSource getDataSource();
...@@ -63,12 +63,12 @@ public interface JDBCDao { ...@@ -63,12 +63,12 @@ public interface JDBCDao {
/** /**
* 执行带参数的查询方法返回一个List,通过mapper组合查询结果 * 执行带参数的查询方法返回一个List,通过mapper组合查询结果
* *
* @author
* @param sql * @param sql
* @param mapper * @param mapper
* @param param * @param param
* @return * @return
* @throws * @throws
* @author
*/ */
List<?> queryToListByMapperMapParam(String sql, QueryRowMapper<?> mapper, Map<String, Object> param); List<?> queryToListByMapperMapParam(String sql, QueryRowMapper<?> mapper, Map<String, Object> param);
...@@ -190,7 +190,9 @@ public interface JDBCDao { ...@@ -190,7 +190,9 @@ public interface JDBCDao {
* @param name * @param name
* @return * @return
* @throws Exception * @throws Exception
* @deprecated 已被 {@link com.huigou.data.repository.GeneralRepositorySuper#getSequence(String)} 替代。
*/ */
@Deprecated
Long getSequence(String name); Long getSequence(String name);
/** /**
...@@ -266,30 +268,30 @@ public interface JDBCDao { ...@@ -266,30 +268,30 @@ public interface JDBCDao {
/** /**
* 保存clob字段 * 保存clob字段
* *
* @author
* @param sql * @param sql
* @param data * @param data
* @param param * @param param
* @author
*/ */
void saveClob(String sql, final String data, final Object... param); void saveClob(String sql, final String data, final Object... param);
/** /**
* 从数据库中查询clob字段 * 从数据库中查询clob字段
* *
* @author
* @param sql * @param sql
* @param clobNames * @param clobNames
* @param param * @param param
* @author
*/ */
Map<String, Object> loadClob(String sql, final String[] clobNames, final Object... param); Map<String, Object> loadClob(String sql, final String[] clobNames, final Object... param);
/** /**
* 从数据库中查询clob字段 * 从数据库中查询clob字段
* *
* @author
* @param sql * @param sql
* @param param * @param param
* @return * @return
* @author
*/ */
String loadClob(String sql, final Object... param); String loadClob(String sql, final Object... param);
......
...@@ -299,6 +299,7 @@ public class JDBCDaoImpl implements JDBCDao { ...@@ -299,6 +299,7 @@ public class JDBCDaoImpl implements JDBCDao {
* @return * @return
* @throws Exception * @throws Exception
*/ */
@Override
public Long getSequence(String name) { public Long getSequence(String name) {
String sql = "select " + name + ".nextval from dual"; String sql = "select " + name + ".nextval from dual";
SqlRowSet srs = (SqlRowSet) jdbcTemplate.query(sql, getResultSetExtractor()); SqlRowSet srs = (SqlRowSet) jdbcTemplate.query(sql, getResultSetExtractor());
......
...@@ -132,7 +132,7 @@ public class QueryPermissionBuilderImpl implements QueryPermissionBuilder { ...@@ -132,7 +132,7 @@ public class QueryPermissionBuilderImpl implements QueryPermissionBuilder {
} }
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("select * from (").append(sql).append(")"); sb.append("select * from (").append(sql).append(") t_t_");
sb.append(" where 1=1 "); sb.append(" where 1=1 ");
if (StringUtil.hasField(sql, "full_id")) { if (StringUtil.hasField(sql, "full_id")) {
List<OrgUnit> list = findSubordinations(operator.getUserId(), operator.getPersonMemberFullIds(), manageType); List<OrgUnit> list = findSubordinations(operator.getUserId(), operator.getPersonMemberFullIds(), manageType);
......
...@@ -15,36 +15,11 @@ ...@@ -15,36 +15,11 @@
*/ */
package com.huigou.data.repository; package com.huigou.data.repository;
import static org.springframework.data.jpa.repository.query.QueryUtils.COUNT_QUERY_STRING;
import static org.springframework.data.jpa.repository.query.QueryUtils.DELETE_ALL_QUERY_STRING;
import static org.springframework.data.jpa.repository.query.QueryUtils.applyAndBind;
import static org.springframework.data.jpa.repository.query.QueryUtils.getQueryString;
import static org.springframework.data.jpa.repository.query.QueryUtils.toOrders;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.LockModeType;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.huigou.data.query.executor.SQLExecutorDao; import com.huigou.data.query.executor.SQLExecutorDao;
import com.huigou.data.query.model.QueryDescriptor; import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.util.ApplicationContextWrapper; import com.huigou.util.ApplicationContextWrapper;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.type.DbTimestampType;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
...@@ -55,21 +30,28 @@ import org.springframework.data.jpa.domain.Specification; ...@@ -55,21 +30,28 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.provider.PersistenceProvider; import org.springframework.data.jpa.provider.PersistenceProvider;
import org.springframework.data.jpa.repository.support.JpaEntityInformation; import org.springframework.data.jpa.repository.support.JpaEntityInformation;
import org.springframework.data.jpa.repository.support.JpaEntityInformationSupport; import org.springframework.data.jpa.repository.support.JpaEntityInformationSupport;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.persistence.*;
import javax.persistence.criteria.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.*;
import static org.springframework.data.jpa.repository.query.QueryUtils.*;
/** /**
* Default implementation of the {@link org.springframework.data.repository.CrudRepository} interface. This * Default implementation of the {@link org.springframework.data.repository.CrudRepository} interface. This
* will offer you a more sophisticated interface than the plain {@link EntityManager} . * will offer you a more sophisticated interface than the plain {@link EntityManager} .
* *
* @param <T> the type of the entity to handle
* @param <ID> the type of the entity's identifier
* @author Oliver Gierke * @author Oliver Gierke
* @author Eberhard Wolff * @author Eberhard Wolff
* @param <T>
* the type of the entity to handle
* @param <ID>
* the type of the entity's identifier
*/ */
@Transactional()
abstract public class GeneralRepositorySuper { abstract public class GeneralRepositorySuper {
abstract public EntityManager getEntityManager(); abstract public EntityManager getEntityManager();
...@@ -420,12 +402,9 @@ abstract public class GeneralRepositorySuper { ...@@ -420,12 +402,9 @@ abstract public class GeneralRepositorySuper {
/** /**
* Reads the given {@link TypedQuery} into a {@link Page} applying the given {@link Pageable} and {@link Specification}. * Reads the given {@link TypedQuery} into a {@link Page} applying the given {@link Pageable} and {@link Specification}.
* *
* @param query * @param query must not be {@literal null}.
* must not be {@literal null}. * @param spec can be {@literal null}.
* @param spec * @param pageable can be {@literal null}.
* can be {@literal null}.
* @param pageable
* can be {@literal null}.
* @return * @return
*/ */
private <T> Page<T> readPage(Class<T> domainClass, TypedQuery<T> query, Pageable pageable, Specification<T> spec) { private <T> Page<T> readPage(Class<T> domainClass, TypedQuery<T> query, Pageable pageable, Specification<T> spec) {
...@@ -433,7 +412,7 @@ abstract public class GeneralRepositorySuper { ...@@ -433,7 +412,7 @@ abstract public class GeneralRepositorySuper {
query.setMaxResults(pageable.getPageSize()); query.setMaxResults(pageable.getPageSize());
Long total = getCountQuery(domainClass, spec).getSingleResult(); Long total = getCountQuery(domainClass, spec).getSingleResult();
List<T> content = total > pageable.getOffset() ? query.getResultList() : Collections.<T> emptyList(); List<T> content = total > pageable.getOffset() ? query.getResultList() : Collections.<T>emptyList();
return new PageImpl<T>(content, pageable, total); return new PageImpl<T>(content, pageable, total);
} }
...@@ -441,10 +420,8 @@ abstract public class GeneralRepositorySuper { ...@@ -441,10 +420,8 @@ abstract public class GeneralRepositorySuper {
/** /**
* Creates a new {@link TypedQuery} from the given {@link Specification}. * Creates a new {@link TypedQuery} from the given {@link Specification}.
* *
* @param spec * @param spec can be {@literal null}.
* can be {@literal null}. * @param pageable can be {@literal null}.
* @param pageable
* can be {@literal null}.
* @return * @return
*/ */
private <T> TypedQuery<T> getQuery(Class<T> domainClass, Specification<T> spec, Pageable pageable) { private <T> TypedQuery<T> getQuery(Class<T> domainClass, Specification<T> spec, Pageable pageable) {
...@@ -455,10 +432,8 @@ abstract public class GeneralRepositorySuper { ...@@ -455,10 +432,8 @@ abstract public class GeneralRepositorySuper {
/** /**
* Creates a {@link TypedQuery} for the given {@link Specification} and {@link Sort}. * Creates a {@link TypedQuery} for the given {@link Specification} and {@link Sort}.
* *
* @param spec * @param spec can be {@literal null}.
* can be {@literal null}. * @param sort can be {@literal null}.
* @param sort
* can be {@literal null}.
* @return * @return
*/ */
private <T> TypedQuery<T> getQuery(Class<T> domainClass, Specification<T> spec, Sort sort) { private <T> TypedQuery<T> getQuery(Class<T> domainClass, Specification<T> spec, Sort sort) {
...@@ -479,8 +454,7 @@ abstract public class GeneralRepositorySuper { ...@@ -479,8 +454,7 @@ abstract public class GeneralRepositorySuper {
/** /**
* Creates a new count query for the given {@link Specification}. * Creates a new count query for the given {@link Specification}.
* *
* @param spec * @param spec can be {@literal null}.
* can be {@literal null}.
* @return * @return
*/ */
private <T> TypedQuery<Long> getCountQuery(Class<T> domainClass, Specification<T> spec) { private <T> TypedQuery<Long> getCountQuery(Class<T> domainClass, Specification<T> spec) {
...@@ -497,10 +471,8 @@ abstract public class GeneralRepositorySuper { ...@@ -497,10 +471,8 @@ abstract public class GeneralRepositorySuper {
/** /**
* Applies the given {@link Specification} to the given {@link CriteriaQuery}. * Applies the given {@link Specification} to the given {@link CriteriaQuery}.
* *
* @param spec * @param spec can be {@literal null}.
* can be {@literal null}. * @param query must not be {@literal null}.
* @param query
* must not be {@literal null}.
* @return * @return
*/ */
private <T, S> Root<T> applySpecificationToCriteria(Class<T> domainClass, Specification<T> spec, CriteriaQuery<S> query) { private <T, S> Root<T> applySpecificationToCriteria(Class<T> domainClass, Specification<T> spec, CriteriaQuery<S> query) {
...@@ -609,8 +581,7 @@ abstract public class GeneralRepositorySuper { ...@@ -609,8 +581,7 @@ abstract public class GeneralRepositorySuper {
/** /**
* 构建统计数量HQL * 构建统计数量HQL
* *
* @param hql * @param hql hql
* hql
* @return * @return
*/ */
private String buildCountHql(String hql) { private String buildCountHql(String hql) {
...@@ -622,7 +593,7 @@ abstract public class GeneralRepositorySuper { ...@@ -622,7 +593,7 @@ abstract public class GeneralRepositorySuper {
return sb.toString(); return sb.toString();
} }
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
public Page query(String hql, Map<String, Object> ps, Pageable pageable) { public Page query(String hql, Map<String, Object> ps, Pageable pageable) {
if (!hql.contains(" order by ")) { if (!hql.contains(" order by ")) {
hql += buildOrderBy(pageable); hql += buildOrderBy(pageable);
...@@ -643,7 +614,7 @@ abstract public class GeneralRepositorySuper { ...@@ -643,7 +614,7 @@ abstract public class GeneralRepositorySuper {
return new PageImpl(content, pageable, total.longValue()); return new PageImpl(content, pageable, total.longValue());
} }
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
public Page query(String hql, Pageable pageable) { public Page query(String hql, Pageable pageable) {
if (!hql.contains(" order by ")) { if (!hql.contains(" order by ")) {
hql += buildOrderBy(pageable); hql += buildOrderBy(pageable);
...@@ -658,7 +629,7 @@ abstract public class GeneralRepositorySuper { ...@@ -658,7 +629,7 @@ abstract public class GeneralRepositorySuper {
return new PageImpl(content, pageable, total); return new PageImpl(content, pageable, total);
} }
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
public Page<?> queryByNativeSql(String sql, Map<String, Object> ps, Pageable pageable) { public Page<?> queryByNativeSql(String sql, Map<String, Object> ps, Pageable pageable) {
Query query = getEntityManager().createNativeQuery(sql); Query query = getEntityManager().createNativeQuery(sql);
...@@ -714,12 +685,9 @@ abstract public class GeneralRepositorySuper { ...@@ -714,12 +685,9 @@ abstract public class GeneralRepositorySuper {
/** /**
* 使用本地SQL更新数据 * 使用本地SQL更新数据
* *
* @param sql * @param sql SQL
* SQL * @param parameterMap 参数
* @param parameterMap * @return 更新或删除的记录数
* 参数
* @return
* 更新或删除的记录数
*/ */
public int updateByNativeSql(String sql, Map<String, Object> parameterMap) { public int updateByNativeSql(String sql, Map<String, Object> parameterMap) {
Query query = this.getEntityManager().createNativeQuery(sql); Query query = this.getEntityManager().createNativeQuery(sql);
...@@ -818,15 +786,27 @@ abstract public class GeneralRepositorySuper { ...@@ -818,15 +786,27 @@ abstract public class GeneralRepositorySuper {
private long getNextId(String sequenceName) { private long getNextId(String sequenceName) {
SQLExecutorDao sqlExecutor = ApplicationContextWrapper.getBean("sqlExecutorDao", SQLExecutorDao.class); SQLExecutorDao sqlExecutor = ApplicationContextWrapper.getBean("sqlExecutorDao", SQLExecutorDao.class);
QueryDescriptor queryDescriptor = sqlExecutor.getQuery("config/uasp/query/bmp/common.xml", "common"); QueryDescriptor queryDescriptor = sqlExecutor.getQuery("config/uasp/query/bmp/common.xml", "common");
Query q = getEntityManager().createNativeQuery(String.format(queryDescriptor.getSqlByName("nextVersion"), sequenceName)); return sqlExecutor.getSqlQuery().getJDBCDao().queryToLong(String.format(queryDescriptor.getSqlByName("nextSequence"), sequenceName));
BigDecimal result = (BigDecimal) q.getSingleResult();
return result.longValue();
} }
/**
* 获取序列
*
* @param sequenceName 序列名称
* @return 序列
* @since 1.1.3
*/
@Transactional(rollbackFor = RuntimeException.class, propagation = Propagation.REQUIRES_NEW)
public long getSequence(String sequenceName) {
return getNextId(sequenceName);
}
@Transactional(rollbackFor = RuntimeException.class, propagation = Propagation.REQUIRES_NEW)
public long getVersionNextId() { public long getVersionNextId() {
return getNextId("version_seq"); return getNextId("version_seq");
} }
@Transactional(rollbackFor = RuntimeException.class, propagation = Propagation.REQUIRES_NEW)
public long getImportExcelNextId() { public long getImportExcelNextId() {
return getNextId("seq_imp_temp_table"); return getNextId("seq_imp_temp_table");
} }
...@@ -834,12 +814,12 @@ abstract public class GeneralRepositorySuper { ...@@ -834,12 +814,12 @@ abstract public class GeneralRepositorySuper {
/** /**
* 得到数据库系统时间 * 得到数据库系统时间
* *
* @return * @return 数据库系统时间
*/ */
public Date getDBSystemDateTime() { public Date getDBSystemDateTime() {
Query query = getEntityManager().createNativeQuery("select sysdate from dual"); EntityManager em = getEntityManager();
Timestamp result = (Timestamp) query.getSingleResult(); SessionImplementor session = (SessionImplementor) em.getDelegate();
return new Date(result.getTime()); return DbTimestampType.INSTANCE.seed(session);
} }
} }
...@@ -7,6 +7,8 @@ import java.util.Iterator; ...@@ -7,6 +7,8 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.huigou.data.query.executor.SQLExecutorDao;
import com.huigou.util.*;
import org.activiti.engine.impl.context.Context; import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity; import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
...@@ -49,11 +51,6 @@ import com.huigou.uasp.bpm.engine.repository.HistoricTaskInstanceExtensionReposi ...@@ -49,11 +51,6 @@ import com.huigou.uasp.bpm.engine.repository.HistoricTaskInstanceExtensionReposi
import com.huigou.uasp.bpm.engine.repository.HistoricTaskInstanceRelationRepository; import com.huigou.uasp.bpm.engine.repository.HistoricTaskInstanceRelationRepository;
import com.huigou.uasp.bpm.engine.repository.RuntimeTaskExtensionRepository; import com.huigou.uasp.bpm.engine.repository.RuntimeTaskExtensionRepository;
import com.huigou.uasp.bpm.managment.application.ProcDefinitionApplication; import com.huigou.uasp.bpm.managment.application.ProcDefinitionApplication;
import com.huigou.util.ClassHelper;
import com.huigou.util.CommonUtil;
import com.huigou.util.Constants;
import com.huigou.util.StringUtil;
import com.huigou.util.Util;
@Service("actApplication") @Service("actApplication")
public class ActApplicationImpl extends BaseApplication implements ActApplication { public class ActApplicationImpl extends BaseApplication implements ActApplication {
...@@ -160,7 +157,8 @@ public class ActApplicationImpl extends BaseApplication implements ActApplicatio ...@@ -160,7 +157,8 @@ public class ActApplicationImpl extends BaseApplication implements ActApplicatio
HistoricTaskInstanceExtension historicTaskInstExtension = new HistoricTaskInstanceExtension(runtimeTaskExtension); HistoricTaskInstanceExtension historicTaskInstExtension = new HistoricTaskInstanceExtension(runtimeTaskExtension);
// 增加版本号保存 // 增加版本号保存
Long version = this.sqlExecutorDao.getSequence("version_seq"); QueryDescriptor queryDescriptor = sqlExecutorDao.getQuery("config/uasp/query/bmp/common.xml", "common");
long version = sqlExecutorDao.getSqlQuery().getJDBCDao().queryToLong(String.format(queryDescriptor.getSqlByName("nextVersion")));
runtimeTaskExtension.setVersion(version); runtimeTaskExtension.setVersion(version);
runtimeTaskExtensionRepository.save(runtimeTaskExtension); runtimeTaskExtensionRepository.save(runtimeTaskExtension);
historicTaskInstExtension.setVersion(version); historicTaskInstExtension.setVersion(version);
...@@ -317,8 +315,7 @@ public class ActApplicationImpl extends BaseApplication implements ActApplicatio ...@@ -317,8 +315,7 @@ public class ActApplicationImpl extends BaseApplication implements ActApplicatio
/** /**
* 检查任务ID不能为空 * 检查任务ID不能为空
* *
* @param taskId * @param taskId 任务ID
* 任务ID
*/ */
private void checkTaskIdNotNull(String taskId) { private void checkTaskIdNotNull(String taskId) {
Util.check(!StringUtil.isBlank(taskId), "任务ID不能为空,请刷新页面后重试。"); Util.check(!StringUtil.isBlank(taskId), "任务ID不能为空,请刷新页面后重试。");
......
...@@ -18,10 +18,10 @@ public interface HistoricTaskInstanceExtensionRepository extends JpaRepository<H ...@@ -18,10 +18,10 @@ public interface HistoricTaskInstanceExtensionRepository extends JpaRepository<H
List<HistoricTaskInstanceExtension> findByProcUnitHandlerIdOrderByVersion(String procUnitHandlerId); List<HistoricTaskInstanceExtension> findByProcUnitHandlerIdOrderByVersion(String procUnitHandlerId);
@Query(name = "historicTaskInstExtension.findApplicantTask", value = "from HistoricTaskInstanceExtension o where o.businessKey = ?1 and o.taskDefinitionKey = 'Apply' and o.previousId is null") @Query(name = "historicTaskInstExtension.findApplicantTask", value = "from HistoricTaskInstanceExtension o where o.businessKey = ?1 and o.taskDefinitionKey = 'Apply' and (o.previousId is null or o.previousId='')")
HistoricTaskInstanceExtension findApplicantTask(String bizId); HistoricTaskInstanceExtension findApplicantTask(String bizId);
@Query(name = "historicTaskInstExtension.findApplicantTaskByBizCode", value = "from HistoricTaskInstanceExtension o where o.businessCode = ?1 and o.taskDefinitionKey = 'Apply' and o.previousId is null") @Query(name = "historicTaskInstExtension.findApplicantTaskByBizCode", value = "from HistoricTaskInstanceExtension o where o.businessCode = ?1 and o.taskDefinitionKey = 'Apply' and (o.previousId is null or o.previousId='')")
HistoricTaskInstanceExtension findApplicantTaskByBizCode(String bizCode); HistoricTaskInstanceExtension findApplicantTaskByBizCode(String bizCode);
List<HistoricTaskInstanceExtension> findByBusinessKeyAndTaskDefinitionKey(String bizId, String procUnitId); List<HistoricTaskInstanceExtension> findByBusinessKeyAndTaskDefinitionKey(String bizId, String procUnitId);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
select next_sequence('version_seq') select next_sequence('version_seq')
</sql> </sql>
<sql name="nextSequence"> <sql name="nextSequence">
SELECT next_sequence(%s) SELECT next_sequence('%s')
</sql> </sql>
<sql name="updateFullName"> <sql name="updateFullName">
update %s update %s
......
...@@ -783,7 +783,7 @@ ...@@ -783,7 +783,7 @@
from Agent o left join o.client from Agent o left join o.client
where o.client.id = :psmId where o.client.id = :psmId
and o.status = 1 and o.status = 1
and sysdate between o.startDate and o.endDate and current_date between o.startDate and o.endDate
</sql> </sql>
<condition column="start_date" name="startDate" symbol="&gt;=" type="java.util.Date" alias="t"/> <condition column="start_date" name="startDate" symbol="&gt;=" type="java.util.Date" alias="t"/>
<condition column="end_date" name="endDate" symbol="&lt;=" type="java.util.Date" alias="t"/> <condition column="end_date" name="endDate" symbol="&lt;=" type="java.util.Date" alias="t"/>
......
...@@ -90,6 +90,11 @@ ...@@ -90,6 +90,11 @@
<artifactId>huigou-uasp</artifactId> <artifactId>huigou-uasp</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-demo</artifactId>
<version>${project.version}</version>
</dependency>
<!-- 公用的组件包 --> <!-- 公用的组件包 -->
<dependency> <dependency>
<groupId>commons-lang</groupId> <groupId>commons-lang</groupId>
......
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
<property name="queryXmlManager" ref="queryXmlManager" /> <property name="queryXmlManager" ref="queryXmlManager" />
</bean> </bean>
<bean id="mapperScannerConfigurer" class="com.topsunit.query.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.huigou.**.mapper"/>
<property name="sqlExecutorBeanName" value="sqlExecutorDao" />
</bean>
<bean id="generalRepository" class="com.huigou.data.repository.GeneralRepository"> <bean id="generalRepository" class="com.huigou.data.repository.GeneralRepository">
</bean> </bean>
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<module>huigou-uasp</module> <module>huigou-uasp</module>
<module>huigou-loader</module> <module>huigou-loader</module>
<module>huigou-xt</module> <module>huigou-xt</module>
<module>huigou-demo</module>
</modules> </modules>
<properties> <properties>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment