Commit 5a964b33 authored by 邬友楠's avatar 邬友楠

多数据源 SQLServer2012 序列只有2012之后的版本支持

parent a196bea6
......@@ -185,7 +185,7 @@ public enum Dialect {
}
result = StringHelper.replace(result, "__hibernate_row_nr__", "_ROW_NUM_");
// Replace a special top tag
result = StringHelper.replaceOnce(result, " $Top_Tag(?) ", " TOP(" + totalRows + ") ");
result = StringHelper.replaceOnce(result, " TOP(?) ", " TOP(" + totalRows + ") ");
result = StringHelper.replaceOnce(result, "_ROW_NUM_ >= ? AND _ROW_NUM_ < ?", "_ROW_NUM_ >= " + (skipRows + 1) + " AND _ROW_NUM_ < " + (totalRows + 1));
result = StringHelper.replaceOnce(result, "offset ? rows fetch next ? rows only", "offset " + skipRows + " rows fetch next " + pageSize + " rows only");
result = StringHelper.replaceOnce(result, "offset 0 rows fetch next ? rows only", "offset 0 rows fetch next " + pageSize + " rows only");
......
package com.huigou.data.dialect;
public class SQLServer2012Dialect extends org.hibernate.dialect.SQLServer2008Dialect {
@Override
public String getSelectGUIDString() {
return "SELECT REPLACE(NEWID(),'-','')";
}
}
......@@ -9,6 +9,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
/**
* 查询模型描述符
......
......@@ -128,6 +128,7 @@ public class DictionaryApplicationImpl extends BaseApplication implements Dictio
QueryModel queryModel = new QueryModel();
queryModel.setSql(sql);
queryModel.putParam("code", code);
queryModel.setDefaultOrderBy("sequence");
return this.sqlExecutorDao.executeQuery(queryModel);
}
......
......@@ -51,6 +51,7 @@ public class PersonQuerySchemeApplicationImpl extends BaseApplication implements
queryModel.setSql(sql);
queryModel.putParam("personId", personId);
queryModel.putParam("kindId", kindId);
queryModel.setDefaultOrderBy("sequence");
return this.sqlExecutorDao.executeQuery(queryModel);
}
......
......@@ -130,6 +130,7 @@ public class DataManagementApplicationImpl extends BaseApplication implements Da
QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "opdatamanagedetailresource");
QueryModel model = this.sqlExecutorDao.getQueryModel(queryDescriptor, queryRequest);
model.putDictionary("dataKind", DataResourceKind.getData());
model.setDefaultOrderBy("sequence,data_kind_id");
return this.sqlExecutorDao.executeQuery(model);
}
......
......@@ -51,7 +51,6 @@
and m.status = 1
and d.status = 1
and m.code = :code
order by d.sequence
</sql>
<condition column="dictionary_id" name="parentId" symbol="=" alias="t" append="false"/>
</query>
......@@ -71,7 +70,6 @@
from SA_PersonQueryScheme
where person_id = :personId
and kind_id = :kindId
order by sequence
</sql>
</query>
......
......@@ -81,12 +81,13 @@
t.full_name,
k.code,
k.name,
k.data_kind
k.data_kind,
k.sequence,
t.data_kind_id
from sa_opdatamanagedetailresource t
left join sa_opdatakind k
on t.data_kind_id = k.id
where t.data_managedetal_id = :dataManagedetalId
order by k.sequence, t.data_kind_id asc
</sql-query>
</query>
......
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="bizclassification" label="业务分类配置">
<sql-query>
select t.* from sa_bizclassification t where 1=1
</sql-query>
<condition column="parent_Id" name="parentId" symbol="=" alias="t" />
<condition column="code" name="code" symbol="like" alias="t" />
<condition column="name" name="name" symbol="like" alias="t" />
<sql name="queryTree">
select t.*,
(select count(0) from sa_bizclassification where parent_id = t.id) as has_Children
from sa_bizclassification t
where 1=1
</sql>
<condition column="id" name="excludeIds" symbol="in" alias="t" >
t.id not in :excludeIds
</condition>
<sql name="queryTreeByPermission">
select t.*,
(select count(0) from sa_bizclassification where parent_id = t.id) as has_Children
from sa_bizclassification t
where t.id in (select pp.resource_id
from SA_OPOrg p,
SA_OPOrg o,
SA_OPAuthorize a,
SA_OPRole r,
SA_OPRolePermission rp,
SA_OPPermission pp
where p.person_id = ?
and p.full_id like o.full_id+'%'
and o.id = a.org_id
and a.role_id = r.id
and r.id = rp.role_id
and rp.permission_id = pp.id
and pp.resource_kind_id = ?
and pp.node_kind_id = ?
and p.status = 1
and o.status = 1
and r.status = 1
and pp.status = 1)
and t.status = 1
and t.parent_id = ?
order by t.sequence asc
</sql>
</query>
<query name="bizclassificationdetail" label="业务分类配置明细">
<sql-query>
select f.code, f.name, f.biz_code,f.status, t.*
from sa_bizclassificationdetail t, sa_flexfieldbizgroup f
where t.biz_property_id = f.id
and t.biz_classification_id = :bizClassificationId
</sql-query>
<condition column="biz_classification_id" name="bizClassificationId" append="false" symbol="=" alias="t"/>
<sql name="checkByBizCode">
select c.name
from sa_bizclassificationdetail t,
sa_bizclassification c,
sa_flexfieldbizgroup g
where t.biz_classification_id = c.id
and t.biz_property_id = g.id
and g.biz_code = ?
</sql>
<sql name="queryByClassificationId">
select t.id,
t.biz_property_id,
t.biz_type,
t.biz_name,
t.dialog_width,
t.entity_class_name,
g.code,
g.biz_code
from sa_bizclassificationdetail t, sa_flexfieldbizgroup g
where t.biz_property_id = g.id
and t.biz_classification_id = ?
order by t.sequence asc
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="bizClassificationFun" label="业务分类配置">
<sql name="findParameterByFullId">
select d.value
from sa_flexfieldstorage t, sa_oporg o
where t.biz_kind_id = ?
and t.field_name = ?
and t.biz_id = o.id
and ? like o.full_id+'%'
order by o.full_sequence desc
</sql>
<sql name="findParameterByOrgId">
select d.value
from sa_flexfieldstorage t, sa_oporg o, sa_oporg op
where t.biz_kind_id = ?
and t.field_name = ?
and t.biz_id = o.id
and op.id = ?
and op.full_id like o.full_id+'%'
order by o.full_sequence desc
</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 = :newFullName + substring(full_name, length(:oldFullName) + 1, length(full_name)),
full_id = :newFullId + substring(full_Id, length(:oldFullId) + 1, length(full_Id)),
version = (next value for 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 value for VERSION_SEQ
</sql>
<sql name="nextSequence">
select next value for %s
</sql>
<sql name="updateFullName">
update %s
set full_Name = concat(:newFullName, substr(full_Name,
length(:oldFullName) + 1,
length(full_Name))),
version = (next value for 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 = (next value for VERSION_SEQ)
where full_Id like :likeFullId
</sql>
<sql name="moveSqlByFolderId">
update %s set folder_Id = :folderId, version = (next value for VERSION_SEQ) where id in :ids
</sql>
<sql name="moveSqlByParentId">
update %s set %s = :parentId, version = (next value for VERSION_SEQ) where id in :ids
</sql>
<sql name="updateStatusSql">
update %s set status = :status, version = (next value for VERSION_SEQ) where id = :id
</sql>
<sql name="updateStatusesSql">
update %s set status = :status, version = (next value for VERSION_SEQ) where id in :ids
</sql>
<sql name="updateSequenceSql">
update %s set sequence = :sequence, version = (next value for 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="orgPropertyDefinition" label="组织机构">
<sql-query>
select t.* from SA_OPOrgPropertyDefinition t where 1 = 1
</sql-query>
<condition column="org_kind_id" name="orgKindId" symbol="=" alias="t"/>
</query>
<query name="person" label="用户查询">
<sql-query>
select p.*, o.full_sequence
from SA_OPOrg o, SA_OPPerson p
where o.person_id = p.id
and p.main_org_id = o.parent_id
</sql-query>
<condition column="code" name="code" symbol="like" alias="p"/>
<condition column="name" name="name" symbol="like" alias="p"/>
<sql name="checkDuplication">
select o
from Person o
where id != :id
and (upper(code) = :code or upper(coalesce(loginName, code)) = :loginName %s )
</sql>
</query>
<query name="org" label="组织机构">
<sql name="updateChildrenStatus">
update SA_OPOrg o
set o.status = :newStatus, o.version = (next value for 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 = (next value for 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 = (next value for 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 = :parentNewFullCode +
substring(full_Code,
length(:parentOldFullCode) + 1,
length(full_Code)),
full_Name = :parentNewFullName +
substring(full_Name,
length(:parentOldFullName) + 1,
length(full_Name)), version = (next value for 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 = (next value for VERSION_SEQ)
where t.id = :id
</sql>
<sql name="updateOrgChildrenFullOrgKindId">
update SA_OPOrg
set full_org_kind_Id = :parentNewFullOrgKindId +
substring(full_Org_Kind_Id,
length(:parentOldOrgKindId) + 1,
length(full_Org_Kind_Id)),
version = (next value for VERSION_SEQ)
where full_Id like :likeFullId
</sql>
<sql name="updateOrgChildrenFullSequence">
update SA_OPOrg
set full_Sequence = :parentNewSequence +
substring(full_Sequence,
length(:parentOldSequence) + 1,
length(full_Sequence)),
version = (next value for VERSION_SEQ)
where full_Id like :fullId
</sql>
<sql name="updateOrgSequence">
update SA_OPOrg
set full_sequence = :fullSequence, sequence = :sequence,
version = (next value for VERSION_SEQ)
where id = :id
</sql>
<sql name="queryOrgProperties">
select p.*, d.data_source, d.description
from SA_OPOrgProperty p, SA_OPOrgPropertyDefinition d
where p.property_definition_id = d.id
and p.org_id = :orgId
</sql>
<sql name="getOrgNextSequence">
select max(sequence) as maxSequence
from Org
where parentId = :parentId
</sql>
<sql name="orgQuery">
select o.id, o.type_id, o.code, o.name, o.long_Name, o.parent_Id, o.full_Id,
o.full_Code, o.full_Name, o.org_Id, o.org_Code, o.org_Name, o.dept_Id,
o.dept_Code, o.dept_Name, o.position_Id, o.position_Code,
o.position_Name, o.org_Kind_Id, p.id as person_Id, o.description,
o.status, o.full_Sequence, p.sex, p.certificate_no, p.status as personStatus,
o.full_Org_Kind_Id, p.main_Org_Id, o.is_Virtual, o.sequence,
o.version
from SA_OPOrg o left join SA_OPPerson p on o.person_id = p.id
where 1=1
</sql>
<sql name="queryOrgExcludePos">
select o.id, o.type_id, o.code, o.name, o.long_Name, o.parent_Id, o.full_Id,
o.full_Code, o.full_Name, o.org_Id, o.org_Code, o.org_Name, o.dept_Id,
o.dept_Code, o.dept_Name, o.position_Id, o.position_Code,
o.position_Name, o.org_Kind_Id, p.id as person_Id, o.description,
o.status, o.full_Sequence, p.sex, p.certificate_no, p.status as personStatus,
o.full_Org_Kind_Id, p.main_Org_Id, o.is_Virtual, o.sequence,
o.version
from V_SA_OPOrg_Exclude_Pos o left join SA_OPPerson p on o.person_id = p.id
where 1=1
</sql>
<sql name="queryCount">
select count(o.id)
from SA_OPOrg o left join SA_OPPerson p on o.person_id = p.id
where o.parent_id = :parentId
</sql>
</query>
</query-mappings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<query-mappings>
<query name="queryExecutingProcs" label="处理中的流程">
<sql-query>
select t.description_ as title,
t.status_name_,
p.start_time_ as start_time,
p.end_time_ as end_time,
c.proc_id,
c.proc_Name,
t.business_key_ as biz_Id,
t.APPLICANT_DEPT_NAME_ as dept_name
from act_hi_procinst p, act_hi_procinst_extension t, wf_procdef c
where p.id_ = t.proc_inst_id_
and p.proc_def_id_ like c.proc_id +':%'
and c.node_kind_id = 'proc'
and t.status_id_ = 'executing'
and not exists
(select a.id from JD_Ask a where a.biz_id = t.business_key_)
and exists (select h.id
from wf_procunithandler h
where h.biz_id = t.business_key_)
</sql-query>
<condition column="proc_id" name="procId" symbol="=" alias="c"/>
<condition column="start_time_" name="startTime" symbol="&gt;=" alias="p">
p.start_time_ &gt;= cast(:startTime as date)
</condition>
<condition column="start_time_" name="endTime" symbol="&lt;=" alias="p">
p.start_time_ &lt;= cast(:endTime as date)
</condition>
<condition column="description" name="procName" symbol="like" alias="t"/>
<condition column="APPLICANT_DEPT_NAME" name="deptName" symbol="like" alias="t"/>
</query>
<query name="queryCompletedProcs" label="已完成的流程">
<sql-query>
select t.description_ as title,
t.status_name_,
p.start_time_ as start_time,
p.end_time_ as end_time,
c.proc_id,
c.proc_name,
t.business_key_ as biz_Id,
t.APPLICANT_DEPT_NAME_ as dept_Name
from act_hi_procinst p, act_hi_procinst_extension t, wf_procdef c
where p.id_ = t.proc_inst_id_
and p.proc_def_id_ like c.proc_id + ':%'
and c.node_kind_id = 'proc'
and t.status_id_ = 'completed'
and not exists
(select a.id from JD_Ask a where a.biz_id = t.business_key_)
</sql-query>
<condition column="proc_id" name="procId" symbol="=" alias="c"/>
<condition column="start_time_" name="startTime" symbol="&gt;=" alias="p">
p.start_time_ &gt;= cast(:startTime as date)
</condition>
<condition column="start_time_" name="endTime" symbol="&lt;=" alias="p">
p.start_time_ &lt;= cast(:endTime as date)
</condition>
<condition column="description" name="procName" symbol="like" alias="t"/>
<condition column="APPLICANT_DEPT_NAME" name="deptName" symbol="like" alias="t"/>
</query>
</query-mappings>
\ No newline at end of file
......@@ -35,6 +35,7 @@
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.dialect">${system.hibernate.dialect}</prop>
<prop key="hibernate.enable_lazy_load_no_trans">true</prop>
<prop key="hibernate.globally_quoted_identifiers">true</prop>
</props>
</property>
</bean>
......
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