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

自定义查询SQL方言

parent 01bd2920
......@@ -4,7 +4,7 @@ import org.springframework.context.ApplicationContext;
/**
* spring 环境包装类
*
*
* @author xx
*/
public class ApplicationContextWrapper {
......@@ -43,7 +43,7 @@ public class ApplicationContextWrapper {
/**
* 根据服务器上下文获取 Spring 管理的bean
*
*
* @param name
* @param type
* @return
......@@ -54,4 +54,14 @@ public class ApplicationContextWrapper {
}
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 {
this.remark = remark;
}
@Override
public List<AgentProc> getDetails() {
return details;
}
@Override
@SuppressWarnings("unchecked")
public void setDetails(List<? extends AbstractEntity> details) {
this.details = (List<AgentProc>) details;
......
package com.huigou.data.domain.listener;
import com.huigou.data.jdbc.SQLQuery;
import com.huigou.data.repository.GeneralRepositorySuper;
import com.huigou.data.query.executor.SQLExecutorDao;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.domain.IdentifiedEntity;
import com.huigou.util.ApplicationContextWrapper;
import org.springframework.beans.factory.annotation.Configurable;
import javax.persistence.EntityManager;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.metamodel.Metamodel;
@Configurable
public class VersionListener {
@Deprecated
public final static String GET_NEXT_SEQ_SQL = "SELECT version_seq.nextval from DUAL";
private boolean inited = false;
private SQLQuery sqlQuery;
private Long getNextId() {
GeneralRepositorySuper generalRepository = ApplicationContextWrapper.getBean("generalRepository", GeneralRepositorySuper.class);
EntityManager em = generalRepository.getEntityManager();
Metamodel metamodel = em.getMetamodel();
if (!inited) {
sqlQuery = ApplicationContextWrapper.getBean("sqlQuery", SQLQuery.class);
inited = true;
}
Long version = sqlQuery.getJDBCDao().queryToLong(GET_NEXT_SEQ_SQL);
SQLExecutorDao sqlExecutor = ApplicationContextWrapper.getBean("sqlExecutorDao", SQLExecutorDao.class);
QueryDescriptor queryDescriptor = sqlExecutor.getQuery("config/uasp/query/bmp/common.xml", "common");
Long version = sqlExecutor.getSqlQuery().getJDBCDao().queryToLong(queryDescriptor.getSqlByName("nextVersion"));
return version;
}
@PrePersist
public void beforeCreate(IdentifiedEntity target) {
// target.setVersion(getNextId());
target.setVersion(getNextId());
}
@PreUpdate
public void beforeUpdate(IdentifiedEntity target) {
// target.setVersion(getNextId());
target.setVersion(getNextId());
}
}
......@@ -46,7 +46,6 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
/**
* 实体版本号
*/
@GeneratedValue(strategy = GenerationType.TABLE)
private Long version;
@Transient
......@@ -55,10 +54,12 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
@Transient
private List<? extends AbstractEntity> inputDetails_;
@Override
public String getId() {
return id;
}
@Override
public void setId(String id) {
if ("".equals(id)) {
id = null;
......@@ -66,10 +67,12 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
this.id = id;
}
@Override
public Long getVersion() {
return this.version;
}
@Override
public void setVersion(Long version) {
this.version = version;
}
......@@ -105,6 +108,7 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
return id == null ? 0 : id.hashCode();
}
@Override
@JsonIgnore
public boolean isNew() {
return StringUtil.isBlank(this.id);
......@@ -191,6 +195,7 @@ public abstract class AbstractEntity implements IdentifiedEntity, Serializable {
return updateFields_;
}
@Override
public void setUpdateFields_(Collection<String> names) {
if (names != null && names.size() > 0) {
this.updateFields_ = names.toArray(new String[names.size()]);
......
......@@ -59,12 +59,28 @@ public class QueryXmlModel implements Serializable, ConfigFileVersion {
return querys.get(0);
}
/**
* @deprecated 已被 {@link #getDeclaredQueries(String)} 替代。
*/
@Deprecated
public Query getQuery(String name) {
return querys.stream().map(query -> query.get(name))
.filter(Objects::nonNull)
.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) {
this.version = version;
}
......
......@@ -59,7 +59,7 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao {
@Override
public QueryDescriptor getQuery(String queryFilePath, String queryName) {
QueryXmlModel model = getQueryXmlModel(queryFilePath);
QueryDescriptor queryDescriptor = new QueryDescriptor(model.getQuery(queryName));
QueryDescriptor queryDescriptor = new QueryDescriptor(model.getDeclaredQueries(queryName));
return queryDescriptor;
}
......@@ -93,7 +93,7 @@ public class SQLExecutorDaoImpl extends JDBCDaoImpl implements SQLExecutorDao {
@Override
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.setQueryParams(executor.parseParamMap());
queryModel.setSql(executor.getSql());
......
......@@ -3,48 +3,73 @@ package com.huigou.data.query.model;
import com.huigou.data.query.XMLParseUtil;
import com.huigou.exception.NotFoundException;
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;
/**
* 查询模型描述符
*
*
* @author xx
*/
public class QueryDescriptor {
private Query query;
private List<Query> queries;
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() {
return query;
// 优先从方言xml中取
return queries.stream().findFirst().get();
}
public void setQuery(Query query) {
this.query = query;
this.queries = Collections.singletonList(query);
}
public String getName() {
return query.getName();
return getQuery().getName();
}
public String getLabel() {
return query.getLabel();
return getQuery().getLabel();
}
public String getSql() {
return query.getSqlQuery();
return getQuery().getSqlQuery();
}
public String getSqlByName(String sqlName) {
for (Sql sql : query.getSqlArray()) {
if (sql.getName().equals(sqlName)) {
return XMLParseUtil.getNodeTextValue(sql);
}
Query query = getQuery(sqlName);
if (query == null) {
throw new NotFoundException(String.format("实体%s中没有SQL(%s)的配置!", queries.get(0).getName(), sqlName));
}
throw new NotFoundException(String.format("实体%s中没有SQL(%s)的配置!", query.getName(), sqlName));
return XMLParseUtil.getNodeTextValue(query);
}
}
......@@ -2,39 +2,38 @@ package com.huigou.data.query.parser;
import com.huigou.data.domain.query.QueryAbstractRequest;
import com.huigou.data.query.SQLExecutor;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.uasp.bmp.query.QueryDocument.Query;
public interface SQLBuilder {
/**
* 构造查询SQL语句
*
* @param entity
* 实体文档对象
* @param queryRequest
* 参数
*
* @param entity 实体文档对象
* @param queryRequest 参数
* @return
*/
public SQLExecutor buildQuerySql(Query query, QueryAbstractRequest queryRequest);
SQLExecutor buildQuerySql(Query query, QueryAbstractRequest queryRequest);
/**
* 根据SQLName获取配置在实体中的sql语句
*
* @author
*
* @param entity
* @param sqlName
* @return String
* @author
*/
public String getSqlByName(Query query, String sqlName);
/**
* 根据SQLName获取配置在实体中的sql语句,并构造SQL
*
* @author
*
* @param entity
* @param sqlName
* @param queryRequest
* @return SQLExecutor
* @author
*/
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;
import com.huigou.data.query.QueryPermissionBuilder;
import com.huigou.data.query.SQLExecutor;
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.model.ConditionModel;
import com.huigou.data.query.parser.model.DataFilterGroup;
......
......@@ -42,6 +42,9 @@ 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.model.QueryDescriptor;
import com.huigou.util.ApplicationContextWrapper;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
......@@ -813,7 +816,9 @@ abstract public class GeneralRepositorySuper {
}
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();
return result.longValue();
}
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.huigou</groupId>
<artifactId>root</artifactId>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.huigou</groupId>
<artifactId>root</artifactId>
<version>1.1.3-SNAPSHOT</version>
</parent>
<artifactId>huigou-uasp</artifactId>
<name>huigou-uasp</name>
<description>huigou-uasp</description>
<dependencies>
<!-- 公用的组件包 -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<!--
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
-->
<!-- JSON -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
</dependency>
<!-- 缓存 -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
</dependency>
<!-- 日志 -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
</dependency>
<!-- 工作流 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
</dependency>
<!-- 面向切面的框架 -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>
</dependency>
<!-- freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
</parent>
<artifactId>huigou-uasp</artifactId>
<name>huigou-uasp</name>
<description>huigou-uasp</description>
<dependencies>
<!-- 公用的组件包 -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<!--
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
-->
<!-- JSON -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
</dependency>
<!-- 缓存 -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
</dependency>
<!-- 日志 -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
</dependency>
<!-- 工作流 -->
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
</dependency>
<!-- 面向切面的框架 -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>
</dependency>
<!-- freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</dependency>
<!-- 汉字转换拼音 -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
</dependency>
<!-- 汉字转换拼音 -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<!-- 内部项目依赖 -->
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-query</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-easysearch</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-treeview</artifactId>
</dependency>
<!-- 解析XML文件 -->
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
<!-- Microsoft Office格式档案读和写 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-excelant</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</dependency>
<!-- 内部项目依赖 -->
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-query</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-easysearch</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-treeview</artifactId>
</dependency>
<!-- 解析XML文件 -->
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
<!-- Microsoft Office格式档案读和写 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-excelant</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</dependency>
<!-- 规则引擎 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>QLExpress</artifactId>
</dependency>
<!-- 表达式语言 -->
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
</dependency>
<!-- 分析、编辑和创建Java字节码 -->
<!--<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>-->
<!-- 生成PDF报表 -->
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</dependency>
<!-- 规则引擎 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>QLExpress</artifactId>
</dependency>
<!-- 表达式语言 -->
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
</dependency>
<!-- 分析、编辑和创建Java字节码 -->
<!--<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>-->
<!-- 生成PDF报表 -->
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!-- Shiro dependencies -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
</dependency>
<!-- Shiro dependencies -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
</dependency>
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-cas</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-cas</artifactId>
</dependency>
<dependency>
<groupId>org.jasig.cas.client</groupId>
<artifactId>cas-client-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
</dependency>
<!-- MongoDB依赖 -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<!-- 微信 -->
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-cp</artifactId>
<version>2.4.3</version>
<exclusions>
<exclusion>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-core-api</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-core-proxy</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-data</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-common</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<id>copy-dev-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependency>
<groupId>org.jasig.cas.client</groupId>
<artifactId>cas-client-core</artifactId>
</dependency>
<!-- MongoDB依赖 -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<!-- 微信 -->
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-cp</artifactId>
<version>2.4.3</version>
<exclusions>
<exclusion>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-core-api</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-core-proxy</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-data</artifactId>
</dependency>
<dependency>
<groupId>com.huigou</groupId>
<artifactId>huigou-common</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<id>copy-dev-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
......@@ -145,6 +145,7 @@ public class BpmProcessNodeFunction extends AbstractEntity {
this.isFunction = isFunction;
}
@Override
public void checkConstraints() {
Assert.hasText(viewId, "节点ID不能为空!");
Assert.hasText(businessProcessId, "流程ID不能为空!");
......
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.model.QueryDescriptor;
import com.huigou.uasp.bmp.codingrule.application.MaxSerialApplication;
import com.huigou.uasp.bmp.codingrule.domain.query.CodingRuleDetailDesc;
import com.huigou.uasp.bmp.codingrule.repository.MaxSerialRepository;
......@@ -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.util.CommonUtil;
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")
public class MaxSerialApplicationImpl implements MaxSerialApplication {
......@@ -198,7 +197,8 @@ public class MaxSerialApplicationImpl implements MaxSerialApplication {
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(),
"", codingRuleDetailDesc.getInitialValue(), version);
......
......@@ -9,10 +9,8 @@ import com.huigou.util.ResourceLoadManager;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.xmlbeans.XmlException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import java.io.IOException;
import java.io.InputStream;
......@@ -28,13 +26,20 @@ import java.util.stream.Collectors;
*
* @author xx
*/
public class QueryXmlManager extends ResourceLoadManager<QueryXmlModel> implements QueryXmlLoadInterface, InitializingBean {
public class QueryXmlManager extends ResourceLoadManager<QueryXmlModel> implements QueryXmlLoadInterface {
/**
* SQL 方言。
*
* @since 1.1.3
*/
private String sqlDialect;
/**
* 设置SQL方言。
*
* @since 1.1.3
*/
public void setSqlDialect(String sqlDialect) {
this.sqlDialect = sqlDialect;
}
......@@ -91,9 +96,4 @@ public class QueryXmlManager extends ResourceLoadManager<QueryXmlModel> implemen
Path dialectXmlPath = filePath.getParent().resolve(sqlDialect).resolve(filePath.getFileName());
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 {
this.sequence = sequence;
}
@Override
public void checkConstraints() {
Assert.hasText(datamanagebusinessId, "datamanagebusinessId不能为空!");
Assert.hasText(dataKindCode, "dataKindCode不能为空!");
......
......@@ -133,6 +133,7 @@ public class Opdatamanagedetailresource extends AbstractEntity {
this.orgDataKind = orgDataKind;
}
@Override
public void checkConstraints() {
Assert.hasText(dataManagedetalId, "dataManagedetalId不能为空!");
Assert.hasText(dataKindId, "dataKindId不能为空!");
......
......@@ -82,6 +82,7 @@ public class Opdatamanagement extends AbstractEntity {
this.creator = creator;
}
@Override
public void checkConstraints() {
Assert.hasText(dataManageId, "管理权限类别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 @@
<junit.version>4.9</junit.version>
<spring-data-mongodb.version>1.9.3.RELEASE</spring-data-mongodb.version>
<huigou.uasp.version>1.1.3-SNAPSHOT</huigou.uasp.version>
<query.spring.version>1.0.1-SNAPSHOT</query.spring.version>
</properties>
<dependencyManagement>
......@@ -1953,7 +1954,6 @@
<artifactId>spring-data-mongodb</artifactId>
<version>${spring-data-mongodb.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<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