Commit 0e94b7ab authored by 雍欢's avatar 雍欢

自定义查询SQL方言

parent 01bd2920
...@@ -54,4 +54,14 @@ public class ApplicationContextWrapper { ...@@ -54,4 +54,14 @@ public class ApplicationContextWrapper {
} }
return getInstance().getApplicationContext().getBean(name, type); return getInstance().getApplicationContext().getBean(name, type);
} }
/**
* @since 1.1.3
*/
public static <T> T getBean(Class<T> type) {
if (getInstance().getApplicationContext() == null) {
return null;
}
return getInstance().getApplicationContext().getBean(type);
}
} }
...@@ -159,10 +159,12 @@ public class Agent extends AbstractEntity { ...@@ -159,10 +159,12 @@ public class Agent extends AbstractEntity {
this.remark = remark; this.remark = remark;
} }
@Override
public List<AgentProc> getDetails() { public List<AgentProc> getDetails() {
return details; return details;
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void setDetails(List<? extends AbstractEntity> details) { public void setDetails(List<? extends AbstractEntity> details) {
this.details = (List<AgentProc>) details; this.details = (List<AgentProc>) details;
......
package com.huigou.data.domain.listener; package com.huigou.data.domain.listener;
import com.huigou.data.jdbc.SQLQuery; import com.huigou.data.query.executor.SQLExecutorDao;
import com.huigou.data.repository.GeneralRepositorySuper; import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.domain.IdentifiedEntity; import com.huigou.domain.IdentifiedEntity;
import com.huigou.util.ApplicationContextWrapper; import com.huigou.util.ApplicationContextWrapper;
import org.springframework.beans.factory.annotation.Configurable; import org.springframework.beans.factory.annotation.Configurable;
import javax.persistence.EntityManager;
import javax.persistence.PrePersist; import javax.persistence.PrePersist;
import javax.persistence.PreUpdate; import javax.persistence.PreUpdate;
import javax.persistence.metamodel.Metamodel;
@Configurable @Configurable
public class VersionListener { public class VersionListener {
@Deprecated
public final static String GET_NEXT_SEQ_SQL = "SELECT version_seq.nextval from DUAL"; public final static String GET_NEXT_SEQ_SQL = "SELECT version_seq.nextval from DUAL";
private boolean inited = false;
private SQLQuery sqlQuery;
private Long getNextId() { private Long getNextId() {
GeneralRepositorySuper generalRepository = ApplicationContextWrapper.getBean("generalRepository", GeneralRepositorySuper.class); SQLExecutorDao sqlExecutor = ApplicationContextWrapper.getBean("sqlExecutorDao", SQLExecutorDao.class);
EntityManager em = generalRepository.getEntityManager(); QueryDescriptor queryDescriptor = sqlExecutor.getQuery("config/uasp/query/bmp/common.xml", "common");
Metamodel metamodel = em.getMetamodel(); Long version = sqlExecutor.getSqlQuery().getJDBCDao().queryToLong(queryDescriptor.getSqlByName("nextVersion"));
if (!inited) {
sqlQuery = ApplicationContextWrapper.getBean("sqlQuery", SQLQuery.class);
inited = true;
}
Long version = sqlQuery.getJDBCDao().queryToLong(GET_NEXT_SEQ_SQL);
return version; return version;
} }
@PrePersist @PrePersist
public void beforeCreate(IdentifiedEntity target) { public void beforeCreate(IdentifiedEntity target) {
// target.setVersion(getNextId()); target.setVersion(getNextId());
} }
@PreUpdate @PreUpdate
public void beforeUpdate(IdentifiedEntity target) { public void beforeUpdate(IdentifiedEntity target) {
// target.setVersion(getNextId()); target.setVersion(getNextId());
} }
} }
...@@ -46,7 +46,6 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable { ...@@ -46,7 +46,6 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
/** /**
* 实体版本号 * 实体版本号
*/ */
@GeneratedValue(strategy = GenerationType.TABLE)
private Long version; private Long version;
@Transient @Transient
...@@ -55,10 +54,12 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable { ...@@ -55,10 +54,12 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
@Transient @Transient
private List<? extends AbstractEntity> inputDetails_; private List<? extends AbstractEntity> inputDetails_;
@Override
public String getId() { public String getId() {
return id; return id;
} }
@Override
public void setId(String id) { public void setId(String id) {
if ("".equals(id)) { if ("".equals(id)) {
id = null; id = null;
...@@ -66,10 +67,12 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable { ...@@ -66,10 +67,12 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
this.id = id; this.id = id;
} }
@Override
public Long getVersion() { public Long getVersion() {
return this.version; return this.version;
} }
@Override
public void setVersion(Long version) { public void setVersion(Long version) {
this.version = version; this.version = version;
} }
...@@ -105,6 +108,7 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable { ...@@ -105,6 +108,7 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
return id == null ? 0 : id.hashCode(); return id == null ? 0 : id.hashCode();
} }
@Override
@JsonIgnore @JsonIgnore
public boolean isNew() { public boolean isNew() {
return StringUtil.isBlank(this.id); return StringUtil.isBlank(this.id);
...@@ -191,6 +195,7 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable { ...@@ -191,6 +195,7 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
return updateFields_; return updateFields_;
} }
@Override
public void setUpdateFields_(Collection<String> names) { public void setUpdateFields_(Collection<String> names) {
if (names != null && names.size() > 0) { if (names != null && names.size() > 0) {
this.updateFields_ = names.toArray(new String[names.size()]); this.updateFields_ = names.toArray(new String[names.size()]);
......
...@@ -59,12 +59,28 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion { ...@@ -59,12 +59,28 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
return querys.get(0); return querys.get(0);
} }
/**
* @deprecated 已被 {@link #getDeclaredQueries(String)} 替代。
*/
@Deprecated
public Query getQuery(String name) { public Query getQuery(String name) {
return querys.stream().map(query -> query.get(name)) return querys.stream().map(query -> query.get(name))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.findFirst().get(); .findFirst().get();
} }
/**
* 获取所有同名的query。
*
* @param name queryName
* @since 1.1.3
*/
public List<Query> getDeclaredQueries(String name) {
return querys.stream().map(query -> query.get(name))
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
public void setVersion(Long version) { public void setVersion(Long version) {
this.version = version; this.version = version;
} }
......
...@@ -59,7 +59,7 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao { ...@@ -59,7 +59,7 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao {
@Override @Override
public QueryDescriptor getQuery(String queryFilePath, String queryName) { public QueryDescriptor getQuery(String queryFilePath, String queryName) {
QueryXmlModel model = getQueryXmlModel(queryFilePath); QueryXmlModel model = getQueryXmlModel(queryFilePath);
QueryDescriptor queryDescriptor = new QueryDescriptor(model.getQuery(queryName)); QueryDescriptor queryDescriptor = new QueryDescriptor(model.getDeclaredQueries(queryName));
return queryDescriptor; return queryDescriptor;
} }
...@@ -93,7 +93,7 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao { ...@@ -93,7 +93,7 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao {
@Override @Override
public QueryModel getQueryModel(QueryDescriptor queryDescriptor, QueryAbstractRequest queryRequest, String sqlName) throws EntityExecutorException { public QueryModel getQueryModel(QueryDescriptor queryDescriptor, QueryAbstractRequest queryRequest, String sqlName) throws EntityExecutorException {
SQLExecutor executor = sqlBuilder.buildSqlByName(queryDescriptor.getQuery(), sqlName, queryRequest); SQLExecutor executor = sqlBuilder.buildSqlByName(queryDescriptor.getQuery(sqlName), sqlName, queryRequest);
QueryModel queryModel = queryRequest.initQueryModel(); QueryModel queryModel = queryRequest.initQueryModel();
queryModel.setQueryParams(executor.parseParamMap()); queryModel.setQueryParams(executor.parseParamMap());
queryModel.setSql(executor.getSql()); queryModel.setSql(executor.getSql());
......
...@@ -3,7 +3,10 @@ package com.huigou.data.query.model; ...@@ -3,7 +3,10 @@ package com.huigou.data.query.model;
import com.huigou.data.query.XMLParseUtil; import com.huigou.data.query.XMLParseUtil;
import com.huigou.exception.NotFoundException; import com.huigou.exception.NotFoundException;
import com.huigou.uasp.bmp.query.QueryDocument.Query; import com.huigou.uasp.bmp.query.QueryDocument.Query;
import com.huigou.uasp.bmp.query.SqlDocument.Sql;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/** /**
* 查询模型描述符 * 查询模型描述符
...@@ -13,38 +16,60 @@ import com.huigou.uasp.bmp.query.SqlDocument.Sql; ...@@ -13,38 +16,60 @@ import com.huigou.uasp.bmp.query.SqlDocument.Sql;
public class QueryDescriptor { public class QueryDescriptor {
private Query query; private List<Query> queries;
public QueryDescriptor(Query query) { public QueryDescriptor(Query query) {
this.query = query; this.queries = Collections.singletonList(query);
}
/**
* @since 1.1.3
*/
public QueryDescriptor(List<Query> queries) {
this.queries = queries;
}
/**
* 根据sqlName获取 Query对象。
*
* @param sqlName sql名称
* @return Query对象
* @since 1.1.3
*/
public Query getQuery(String sqlName) {
return queries.stream()
.filter(query -> Arrays.stream(query.getSqlArray()).filter(sql -> sql.getName().equals(sqlName)).findFirst().isPresent())
.findFirst()
.get();
} }
public Query getQuery() { public Query getQuery() {
return query; // 优先从方言xml中取
return queries.stream().findFirst().get();
} }
public void setQuery(Query query) { public void setQuery(Query query) {
this.query = query; this.queries = Collections.singletonList(query);
} }
public String getName() { public String getName() {
return query.getName(); return getQuery().getName();
} }
public String getLabel() { public String getLabel() {
return query.getLabel(); return getQuery().getLabel();
} }
public String getSql() { public String getSql() {
return query.getSqlQuery(); return getQuery().getSqlQuery();
} }
public String getSqlByName(String sqlName) { public String getSqlByName(String sqlName) {
for (Sql sql : query.getSqlArray()) { Query query = getQuery(sqlName);
if (sql.getName().equals(sqlName)) { if (query == null) {
return XMLParseUtil.getNodeTextValue(sql); throw new NotFoundException(String.format("实体%s中没有SQL(%s)的配置!", queries.get(0).getName(), sqlName));
} }
return XMLParseUtil.getNodeTextValue(query);
} }
throw new NotFoundException(String.format("实体%s中没有SQL(%s)的配置!", query.getName(), sqlName));
}
} }
...@@ -2,6 +2,7 @@ package com.huigou.data.query.parser; ...@@ -2,6 +2,7 @@ package com.huigou.data.query.parser;
import com.huigou.data.domain.query.QueryAbstractRequest; import com.huigou.data.domain.query.QueryAbstractRequest;
import com.huigou.data.query.SQLExecutor; import com.huigou.data.query.SQLExecutor;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.uasp.bmp.query.QueryDocument.Query; import com.huigou.uasp.bmp.query.QueryDocument.Query;
public interface SQLBuilder { public interface SQLBuilder {
...@@ -9,32 +10,30 @@ public interface SQLBuilder { ...@@ -9,32 +10,30 @@ public interface SQLBuilder {
/** /**
* 构造查询SQL语句 * 构造查询SQL语句
* *
* @param entity * @param entity 实体文档对象
* 实体文档对象 * @param queryRequest 参数
* @param queryRequest
* 参数
* @return * @return
*/ */
public SQLExecutor buildQuerySql(Query query, QueryAbstractRequest queryRequest); SQLExecutor buildQuerySql(Query query, QueryAbstractRequest queryRequest);
/** /**
* 根据SQLName获取配置在实体中的sql语句 * 根据SQLName获取配置在实体中的sql语句
* *
* @author
* @param entity * @param entity
* @param sqlName * @param sqlName
* @return String * @return String
* @author
*/ */
public String getSqlByName(Query query, String sqlName); public String getSqlByName(Query query, String sqlName);
/** /**
* 根据SQLName获取配置在实体中的sql语句,并构造SQL * 根据SQLName获取配置在实体中的sql语句,并构造SQL
* *
* @author
* @param entity * @param entity
* @param sqlName * @param sqlName
* @param queryRequest * @param queryRequest
* @return SQLExecutor * @return SQLExecutor
* @author
*/ */
public SQLExecutor buildSqlByName(Query query, String sqlName, QueryAbstractRequest queryRequest); public SQLExecutor buildSqlByName(Query query, String sqlName, QueryAbstractRequest queryRequest);
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ import com.huigou.data.domain.query.QueryAbstractRequest; ...@@ -7,6 +7,7 @@ import com.huigou.data.domain.query.QueryAbstractRequest;
import com.huigou.data.query.QueryPermissionBuilder; import com.huigou.data.query.QueryPermissionBuilder;
import com.huigou.data.query.SQLExecutor; import com.huigou.data.query.SQLExecutor;
import com.huigou.data.query.XMLParseUtil; import com.huigou.data.query.XMLParseUtil;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.data.query.parser.SQLBuilder; import com.huigou.data.query.parser.SQLBuilder;
import com.huigou.data.query.parser.model.ConditionModel; import com.huigou.data.query.parser.model.ConditionModel;
import com.huigou.data.query.parser.model.DataFilterGroup; import com.huigou.data.query.parser.model.DataFilterGroup;
......
...@@ -42,6 +42,9 @@ import javax.persistence.criteria.Path; ...@@ -42,6 +42,9 @@ import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import com.huigou.data.query.executor.SQLExecutorDao;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.util.ApplicationContextWrapper;
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;
...@@ -813,7 +816,9 @@ abstract public class GeneralRepositorySuper { ...@@ -813,7 +816,9 @@ abstract public class GeneralRepositorySuper {
} }
private long getNextId(String sequenceName) { private long getNextId(String sequenceName) {
Query q = getEntityManager().createNativeQuery(String.format("SELECT %s.nextval from DUAL", sequenceName)); SQLExecutorDao sqlExecutor = ApplicationContextWrapper.getBean("sqlExecutorDao", SQLExecutorDao.class);
QueryDescriptor queryDescriptor = sqlExecutor.getQuery("config/uasp/query/bmp/common.xml", "common");
Query q = getEntityManager().createNativeQuery(String.format(queryDescriptor.getSqlByName("nextVersion"), sequenceName));
BigDecimal result = (BigDecimal) q.getSingleResult(); BigDecimal result = (BigDecimal) q.getSingleResult();
return result.longValue(); return result.longValue();
} }
......
...@@ -145,6 +145,7 @@ public class BpmProcessNodeFunction extends AbstractEntity { ...@@ -145,6 +145,7 @@ public class BpmProcessNodeFunction extends AbstractEntity {
this.isFunction = isFunction; this.isFunction = isFunction;
} }
@Override
public void checkConstraints() { public void checkConstraints() {
Assert.hasText(viewId, "节点ID不能为空!"); Assert.hasText(viewId, "节点ID不能为空!");
Assert.hasText(businessProcessId, "流程ID不能为空!"); Assert.hasText(businessProcessId, "流程ID不能为空!");
......
package com.huigou.uasp.bmp.codingrule.application.impl; package com.huigou.uasp.bmp.codingrule.application.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.huigou.data.domain.listener.VersionListener;
import com.huigou.data.query.executor.SQLExecutorDao; import com.huigou.data.query.executor.SQLExecutorDao;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.uasp.bmp.codingrule.application.MaxSerialApplication; import com.huigou.uasp.bmp.codingrule.application.MaxSerialApplication;
import com.huigou.uasp.bmp.codingrule.domain.query.CodingRuleDetailDesc; import com.huigou.uasp.bmp.codingrule.domain.query.CodingRuleDetailDesc;
import com.huigou.uasp.bmp.codingrule.repository.MaxSerialRepository; import com.huigou.uasp.bmp.codingrule.repository.MaxSerialRepository;
...@@ -17,6 +9,13 @@ import com.huigou.uasp.bmp.configuration.domain.query.IntermilCodeDesc; ...@@ -17,6 +9,13 @@ import com.huigou.uasp.bmp.configuration.domain.query.IntermilCodeDesc;
import com.huigou.uasp.bmp.configuration.domain.query.MaxSerialDesc; import com.huigou.uasp.bmp.configuration.domain.query.MaxSerialDesc;
import com.huigou.util.CommonUtil; import com.huigou.util.CommonUtil;
import com.huigou.util.StringUtil; import com.huigou.util.StringUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Service("maxSerialApplication") @Service("maxSerialApplication")
public class MaxSerialApplicationImpl implements MaxSerialApplication { public class MaxSerialApplicationImpl implements MaxSerialApplication {
...@@ -198,7 +197,8 @@ public class MaxSerialApplicationImpl implements MaxSerialApplication { ...@@ -198,7 +197,8 @@ public class MaxSerialApplicationImpl implements MaxSerialApplication {
maxSerialId = CommonUtil.createGUID(); maxSerialId = CommonUtil.createGUID();
Long version = this.sqlExecutorDao.queryToLong(VersionListener.GET_NEXT_SEQ_SQL); QueryDescriptor queryDescriptor = sqlExecutorDao.getQuery("config/uasp/query/bmp/common.xml", "common");
Long version = sqlExecutorDao.getSqlQuery().getJDBCDao().queryToLong(queryDescriptor.getSqlByName("nextVersion"));
this.sqlExecutorDao.executeUpdate(sb.toString(), maxSerialId, codingRuleDetailDesc.getId(), sortItemValue, codingRuleDetailDesc.getInitialValue(), this.sqlExecutorDao.executeUpdate(sb.toString(), maxSerialId, codingRuleDetailDesc.getId(), sortItemValue, codingRuleDetailDesc.getInitialValue(),
"", codingRuleDetailDesc.getInitialValue(), version); "", codingRuleDetailDesc.getInitialValue(), version);
......
...@@ -9,10 +9,8 @@ import com.huigou.util.ResourceLoadManager; ...@@ -9,10 +9,8 @@ import com.huigou.util.ResourceLoadManager;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
...@@ -28,13 +26,20 @@ import java.util.stream.Collectors; ...@@ -28,13 +26,20 @@ import java.util.stream.Collectors;
* *
* @author xx * @author xx
*/ */
public class QueryXmlManager extends ResourceLoadManager<QueryXmlModel> implements QueryXmlLoadInterface, InitializingBean { public class QueryXmlManager extends ResourceLoadManager<QueryXmlModel> implements QueryXmlLoadInterface {
/** /**
* SQL 方言。 * SQL 方言。
*
* @since 1.1.3
*/ */
private String sqlDialect; private String sqlDialect;
/**
* 设置SQL方言。
*
* @since 1.1.3
*/
public void setSqlDialect(String sqlDialect) { public void setSqlDialect(String sqlDialect) {
this.sqlDialect = sqlDialect; this.sqlDialect = sqlDialect;
} }
...@@ -91,9 +96,4 @@ public class QueryXmlManager extends ResourceLoadManager<QueryXmlModel> implemen ...@@ -91,9 +96,4 @@ public class QueryXmlManager extends ResourceLoadManager<QueryXmlModel> implemen
Path dialectXmlPath = filePath.getParent().resolve(sqlDialect).resolve(filePath.getFileName()); Path dialectXmlPath = filePath.getParent().resolve(sqlDialect).resolve(filePath.getFileName());
return dialectXmlPath.toString(); return dialectXmlPath.toString();
} }
@Override
public void afterPropertiesSet() throws Exception {
Assert.hasText(sqlDialect, "sql方言不能为空");
}
} }
\ No newline at end of file
...@@ -189,6 +189,7 @@ public class OpdatamanagebusinessField extends AbstractEntity { ...@@ -189,6 +189,7 @@ public class OpdatamanagebusinessField extends AbstractEntity {
this.sequence = sequence; this.sequence = sequence;
} }
@Override
public void checkConstraints() { public void checkConstraints() {
Assert.hasText(datamanagebusinessId, "datamanagebusinessId不能为空!"); Assert.hasText(datamanagebusinessId, "datamanagebusinessId不能为空!");
Assert.hasText(dataKindCode, "dataKindCode不能为空!"); Assert.hasText(dataKindCode, "dataKindCode不能为空!");
......
...@@ -133,6 +133,7 @@ public class Opdatamanagedetailresource extends AbstractEntity { ...@@ -133,6 +133,7 @@ public class Opdatamanagedetailresource extends AbstractEntity {
this.orgDataKind = orgDataKind; this.orgDataKind = orgDataKind;
} }
@Override
public void checkConstraints() { public void checkConstraints() {
Assert.hasText(dataManagedetalId, "dataManagedetalId不能为空!"); Assert.hasText(dataManagedetalId, "dataManagedetalId不能为空!");
Assert.hasText(dataKindId, "dataKindId不能为空!"); Assert.hasText(dataKindId, "dataKindId不能为空!");
......
...@@ -82,6 +82,7 @@ public class Opdatamanagement extends AbstractEntity { ...@@ -82,6 +82,7 @@ public class Opdatamanagement extends AbstractEntity {
this.creator = creator; this.creator = creator;
} }
@Override
public void checkConstraints() { public void checkConstraints() {
Assert.hasText(dataManageId, "管理权限类别ID不能为空!"); Assert.hasText(dataManageId, "管理权限类别ID不能为空!");
Assert.hasText(dataManagedetalId, "管理权限数据取值定义ID不能为空!"); Assert.hasText(dataManagedetalId, "管理权限数据取值定义ID不能为空!");
......
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="approvalRule" label="审批规则">
<sql name="updateChildrenFullName">
update WF_ApprovalRule
set full_name = concat(:newFullName, substr(full_name, length(:oldFullName) + 1, length(full_name))),
full_id = concat(:newFullId, substr(full_Id, length(:oldFullId) + 1, length(full_Id))),
version = (select next_sequence('version_seq'))
where full_Id like :fullId
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="common" label="通用sql">
<sql name="nextVersion">
select next_sequence('version_seq')
</sql>
<sql name="nextSequence">
SELECT next_sequence(%s)
</sql>
<sql name="updateFullName">
update %s
set full_Name = concat(:newFullName, substr(full_Name,
length(:oldFullName) + 1,
length(full_Name))),
version = (select next_sequence('version_seq'))
where full_id like :fullId
</sql>
<sql name="updateFullIdAndName">
update %s
set full_id = concat(:parentNewFullId,
substr(full_Id,
length(:parentOldFullId) + 1,
length(full_Id))),
full_Name = concat(:parentNewFullName,
substr(full_Name, length(:parentOldFullName) + 1,
length(full_Name))),
version = (select next_sequence('version_seq'))
where full_Id like :likeFullId
</sql>
<sql name="moveSqlByFolderId">
update %s set folder_Id = :folderId, version = (select next_sequence('version_seq')) where id in :ids
</sql>
<sql name="moveSqlByParentId">
update %s set %s = :parentId, version = (select next_sequence('version_seq')) where id in :ids
</sql>
<sql name="updateStatusSql">
update %s set status = :status, version = (select next_sequence('version_seq')) where id = :id
</sql>
<sql name="updateStatusesSql">
update %s set status = :status, version = (select next_sequence('version_seq')) where id in :ids
</sql>
<sql name="updateSequenceSql">
update %s set sequence = :sequence, version = (select next_sequence('version_seq')) where id = :id
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="org" label="组织机构">
<sql name="updateChildrenStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = (select next_sequence('version_seq'))
where o.status in (:oldStatus)
and o.full_Id like :fullId
and (o.org_Kind_Id != 'psm' or
(select p.status from SA_OPPerson p where p.id = o.person_Id) >= :newStatus)
</sql>
<sql name="updateSubordinatePsmStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = (select next_sequence('version_seq'))
where o.org_Kind_Id = 'psm'
and o.status in (:oldStatus)
and (select p.status from SA_OPOrg p where p.id = o.parent_Id) >= :newStatus
and exists (select 1
from SA_OPPerson person, SA_OPOrg org
where person.status = :newStatus
and org.org_Kind_Id = 'psm'
and org.status in (:oldStatus)
and org.full_Id like :fullId
and person.main_Org_Id = org.parent_Id
and person.id = org.person_Id
and o.person_Id = person.id
and o.parent_Id != person.main_Org_Id)
</sql>
<sql name="updateMainOrgPersonStatus">
update SA_OPPerson p
set p.status = :newStatus, p.version = (select next_sequence('version_seq'))
where (p.Status in (:oldStatus))
and exists (select 1
from SA_OPOrg o
where (o.org_Kind_Id = 'psm')
and (p.main_Org_Id = o.parent_Id)
and (p.id = o.person_Id)
and (o.status in (:oldStatus))
and (o.full_Id like :fullId))
</sql>
<sql name="updateOrgChildrenFullCodeAndName">
update SA_OPOrg
set full_Code = concat(:parentNewFullCode,
substr(full_Code,
length(:parentOldFullCode) + 1,
length(full_Code))),
full_Name = concat(:parentNewFullName,
substr(full_Name,
length(:parentOldFullName) + 1,
length(full_Name))), version = (select next_sequence('version_seq'))
where full_Id like :likeFullId
</sql>
<sql name="updateRedundantData">
update SA_OPOrg t
set t.org_Id = :orgId, t.org_Code = :orgCode, t.org_Name = :orgName,
t.dept_Id = :deptId, t.dept_Code = :deptCode, t.dept_Name = :deptName,
t.position_Id = :positionId, t.position_Code = :positionCode,
t.position_Name = :positionName, version = (select next_sequence('version_seq'))
where t.id = :id
</sql>
<sql name="updateOrgChildrenFullOrgKindId">
update SA_OPOrg
set full_OrgKind_Id = concat(:parentNewFullOrgKindId,
substr(full_Org_Kind_Id,
length(:parentOldOrgKindId) + 1,
length(full_Org_Kind_Id))),
version = (select next_sequence('version_seq'))
where full_Id like :likeFullId
</sql>
<sql name="updateOrgChildrenFullSequence">
update SA_OPOrg
set full_Sequence = concat(:parentNewSequence,
substr(full_Sequence,
length(:parentOldSequence) + 1,
length(full_Sequence))),
version = (select next_sequence('version_seq'))
where full_Id like :fullId
</sql>
<sql name="updateOrgSequence">
update SA_OPOrg
set full_sequence = :fullSequence, sequence = :sequence,
version = (select next_sequence('version_seq'))
where id = :id
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="org" label="组织机构">
<sql name="updateChildrenStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = (select next_sequence('version_seq'))
where o.status in (:oldStatus)
and o.full_Id like :fullId
and (o.org_Kind_Id != 'psm' or
(select p.status from SA_OPPerson p where p.id = o.person_Id) >= :newStatus)
</sql>
<sql name="updateSubordinatePsmStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = (select next_sequence('version_seq'))
where o.org_Kind_Id = 'psm'
and o.status in (:oldStatus)
and (select p.status from SA_OPOrg p where p.id = o.parent_Id) >= :newStatus
and exists (select 1
from SA_OPPerson person, SA_OPOrg org
where person.status = :newStatus
and org.org_Kind_Id = 'psm'
and org.status in (:oldStatus)
and org.full_Id like :fullId
and person.main_Org_Id = org.parent_Id
and person.id = org.person_Id
and o.person_Id = person.id
and o.parent_Id != person.main_Org_Id)
</sql>
<sql name="updateMainOrgPersonStatus">
update SA_OPPerson p
set p.status = :newStatus, p.version = (select next_sequence('version_seq'))
where (p.Status in (:oldStatus))
and exists (select 1
from SA_OPOrg o
where (o.org_Kind_Id = 'psm')
and (p.main_Org_Id = o.parent_Id)
and (p.id = o.person_Id)
and (o.status in (:oldStatus))
and (o.full_Id like :fullId))
</sql>
<sql name="updateOrgChildrenFullCodeAndName">
update SA_OPOrg
set full_Code = concat(:parentNewFullCode,
substr(full_Code,
length(:parentOldFullCode) + 1,
length(full_Code))),
full_Name = concat(:parentNewFullName,
substr(full_Name,
length(:parentOldFullName) + 1,
length(full_Name))), version = (select next_sequence('version_seq'))
where full_Id like :likeFullId
</sql>
<sql name="updateRedundantData">
update SA_OPOrg t
set t.org_Id = :orgId, t.org_Code = :orgCode, t.org_Name = :orgName,
t.dept_Id = :deptId, t.dept_Code = :deptCode, t.dept_Name = :deptName,
t.position_Id = :positionId, t.position_Code = :positionCode,
t.position_Name = :positionName, version = (select next_sequence('version_seq'))
where t.id = :id
</sql>
<sql name="updateOrgChildrenFullOrgKindId">
update SA_OPOrg
set full_OrgKind_Id = concat(:parentNewFullOrgKindId,
substr(full_Org_Kind_Id,
length(:parentOldOrgKindId) + 1,
length(full_Org_Kind_Id))),
version = (select next_sequence('version_seq'))
where full_Id like :likeFullId
</sql>
<sql name="updateOrgChildrenFullSequence">
update SA_OPOrg
set full_Sequence = concat(:parentNewSequence,
substr(full_Sequence,
length(:parentOldSequence) + 1,
length(full_Sequence))),
version = (select next_sequence('version_seq'))
where full_Id like :fullId
</sql>
<sql name="updateOrgSequence">
update SA_OPOrg
set full_sequence = :fullSequence, sequence = :sequence,
version = (select next_sequence('version_seq'))
where id = :id
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="approvalRule" label="审批规则">
<sql name="updateChildrenFullName">
update WF_ApprovalRule
set full_name = concat(:newFullName, substr(full_name, length(:oldFullName) + 1, length(full_name))),
full_id = concat(:newFullId, substr(full_Id, length(:oldFullId) + 1, length(full_Id))),
version = version_seq.Nextval
where full_Id like :fullId
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="common" label="通用sql">
<sql name="nextVersion">
SELECT version_seq.nextval from DUAL
</sql>
<sql name="nextSequence">
SELECT %s.nextval from DUAL
</sql>
<sql name="updateFullName">
update %s
set full_Name = concat(:newFullName, substr(full_Name,
length(:oldFullName) + 1,
length(full_Name))),
version = version_seq.nextval
where full_id like :fullId
</sql>
<sql name="updateFullIdAndName">
update %s
set full_id = concat(:parentNewFullId,
substr(full_Id,
length(:parentOldFullId) + 1,
length(full_Id))),
full_Name = concat(:parentNewFullName,
substr(full_Name, length(:parentOldFullName) + 1,
length(full_Name))),
version = version_seq.nextval
where full_Id like :likeFullId
</sql>
<sql name="moveSqlByFolderId">
update %s set folder_Id = :folderId, version = version_seq.nextval where id in :ids
</sql>
<sql name="moveSqlByParentId">
update %s set %s = :parentId, version = version_seq.nextval where id in :ids
</sql>
<sql name="updateStatusSql">
update %s set status = :status, version = version_seq.nextval where id = :id
</sql>
<sql name="updateStatusesSql">
update %s set status = :status, version = version_seq.nextval where id in :ids
</sql>
<sql name="updateSequenceSql">
update %s set sequence = :sequence, version = version_seq.nextval where id = :id
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="org" label="组织机构">
<sql name="updateChildrenStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = version_seq.nextval
where o.status in (:oldStatus)
and o.full_Id like :fullId
and (o.org_Kind_Id != 'psm' or
(select p.status from SA_OPPerson p where p.id = o.person_Id) >= :newStatus)
</sql>
<sql name="updateSubordinatePsmStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = version_seq.Nextval
where o.org_Kind_Id = 'psm'
and o.status in (:oldStatus)
and (select p.status from SA_OPOrg p where p.id = o.parent_Id) >= :newStatus
and exists (select 1
from SA_OPPerson person, SA_OPOrg org
where person.status = :newStatus
and org.org_Kind_Id = 'psm'
and org.status in (:oldStatus)
and org.full_Id like :fullId
and person.main_Org_Id = org.parent_Id
and person.id = org.person_Id
and o.person_Id = person.id
and o.parent_Id != person.main_Org_Id)
</sql>
<sql name="updateMainOrgPersonStatus">
update SA_OPPerson p
set p.status = :newStatus, p.version = version_seq.nextval
where (p.Status in (:oldStatus))
and exists (select 1
from SA_OPOrg o
where (o.org_Kind_Id = 'psm')
and (p.main_Org_Id = o.parent_Id)
and (p.id = o.person_Id)
and (o.status in (:oldStatus))
and (o.full_Id like :fullId))
</sql>
<sql name="updateOrgChildrenFullCodeAndName">
update SA_OPOrg
set full_Code = concat(:parentNewFullCode,
substr(full_Code,
length(:parentOldFullCode) + 1,
length(full_Code))),
full_Name = concat(:parentNewFullName,
substr(full_Name,
length(:parentOldFullName) + 1,
length(full_Name))), version = version_seq.Nextval
where full_Id like :likeFullId
</sql>
<sql name="updateRedundantData">
update SA_OPOrg t
set t.org_Id = :orgId, t.org_Code = :orgCode, t.org_Name = :orgName,
t.dept_Id = :deptId, t.dept_Code = :deptCode, t.dept_Name = :deptName,
t.position_Id = :positionId, t.position_Code = :positionCode,
t.position_Name = :positionName, version = version_seq.Nextval
where t.id = :id
</sql>
<sql name="updateOrgChildrenFullOrgKindId">
update SA_OPOrg
set full_OrgKind_Id = concat(:parentNewFullOrgKindId,
substr(full_Org_Kind_Id,
length(:parentOldOrgKindId) + 1,
length(full_Org_Kind_Id))),
version = version_seq.Nextval
where full_Id like :likeFullId
</sql>
<sql name="updateOrgChildrenFullSequence">
update SA_OPOrg
set full_Sequence = concat(:parentNewSequence,
substr(full_Sequence,
length(:parentOldSequence) + 1,
length(full_Sequence))),
version = version_seq.nextval
where full_Id like :fullId
</sql>
<sql name="updateOrgSequence">
update SA_OPOrg
set full_sequence = :fullSequence, sequence = :sequence,
version = version_seq.Nextval
where id = :id
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="org" label="组织机构">
<sql name="updateChildrenStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = version_seq.nextval
where o.status in (:oldStatus)
and o.full_Id like :fullId
and (o.org_Kind_Id != 'psm' or
(select p.status from SA_OPPerson p where p.id = o.person_Id) >= :newStatus)
</sql>
<sql name="updateSubordinatePsmStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = version_seq.Nextval
where o.org_Kind_Id = 'psm'
and o.status in (:oldStatus)
and (select p.status from SA_OPOrg p where p.id = o.parent_Id) >= :newStatus
and exists (select 1
from SA_OPPerson person, SA_OPOrg org
where person.status = :newStatus
and org.org_Kind_Id = 'psm'
and org.status in (:oldStatus)
and org.full_Id like :fullId
and person.main_Org_Id = org.parent_Id
and person.id = org.person_Id
and o.person_Id = person.id
and o.parent_Id != person.main_Org_Id)
</sql>
<sql name="updateMainOrgPersonStatus">
update SA_OPPerson p
set p.status = :newStatus, p.version = version_seq.nextval
where (p.Status in (:oldStatus))
and exists (select 1
from SA_OPOrg o
where (o.org_Kind_Id = 'psm')
and (p.main_Org_Id = o.parent_Id)
and (p.id = o.person_Id)
and (o.status in (:oldStatus))
and (o.full_Id like :fullId))
</sql>
<sql name="updateOrgChildrenFullCodeAndName">
update SA_OPOrg
set full_Code = concat(:parentNewFullCode,
substr(full_Code,
length(:parentOldFullCode) + 1,
length(full_Code))),
full_Name = concat(:parentNewFullName,
substr(full_Name,
length(:parentOldFullName) + 1,
length(full_Name))), version = version_seq.Nextval
where full_Id like :likeFullId
</sql>
<sql name="updateRedundantData">
update SA_OPOrg t
set t.org_Id = :orgId, t.org_Code = :orgCode, t.org_Name = :orgName,
t.dept_Id = :deptId, t.dept_Code = :deptCode, t.dept_Name = :deptName,
t.position_Id = :positionId, t.position_Code = :positionCode,
t.position_Name = :positionName, version = version_seq.Nextval
where t.id = :id
</sql>
<sql name="updateOrgChildrenFullOrgKindId">
update SA_OPOrg
set full_OrgKind_Id = concat(:parentNewFullOrgKindId,
substr(full_Org_Kind_Id,
length(:parentOldOrgKindId) + 1,
length(full_Org_Kind_Id))),
version = version_seq.Nextval
where full_Id like :likeFullId
</sql>
<sql name="updateOrgChildrenFullSequence">
update SA_OPOrg
set full_Sequence = concat(:parentNewSequence,
substr(full_Sequence,
length(:parentOldSequence) + 1,
length(full_Sequence))),
version = version_seq.nextval
where full_Id like :fullId
</sql>
<sql name="updateOrgSequence">
update SA_OPOrg
set full_sequence = :fullSequence, sequence = :sequence,
version = version_seq.Nextval
where id = :id
</sql>
</query>
</query-mappings>
\ No newline at end of file
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
<junit.version>4.9</junit.version> <junit.version>4.9</junit.version>
<spring-data-mongodb.version>1.9.3.RELEASE</spring-data-mongodb.version> <spring-data-mongodb.version>1.9.3.RELEASE</spring-data-mongodb.version>
<huigou.uasp.version>1.1.3-SNAPSHOT</huigou.uasp.version> <huigou.uasp.version>1.1.3-SNAPSHOT</huigou.uasp.version>
<query.spring.version>1.0.1-SNAPSHOT</query.spring.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
...@@ -1953,7 +1954,6 @@ ...@@ -1953,7 +1954,6 @@
<artifactId>spring-data-mongodb</artifactId> <artifactId>spring-data-mongodb</artifactId>
<version>${spring-data-mongodb.version}</version> <version>${spring-data-mongodb.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<distributionManagement> <distributionManagement>
......
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