Commit 25ebaacd authored by 李秀明's avatar 李秀明

Merge remote-tracking branch 'origin/develop_dl_bugfix' into develop_dl_bugfix

parents 0ec7035d 7474492a
......@@ -24,12 +24,13 @@ import java.util.Properties;
@Intercepts({
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),
}
}
)
public class PluginInterceptor implements Interceptor {
/**
* 进行拦截的时候要执行的方法
*
* @param invocation
* @return
* @throws Throwable
......@@ -56,25 +57,25 @@ public class PluginInterceptor implements Interceptor {
cacheKey = (CacheKey) args[4];
boundSql = (BoundSql) args[5];
}
//id为执行的mapper方法的全路径名,如com.metro.dao.UserMapper.insertUser
//id为执行的mapper方法的全路径名,如com.metro.dao.UserMapper.insertUser
String id = mappedStatement.getId();
//获取到原始sql语句
String sql = boundSql.getSql();
if("com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper.selectPersonListCount".equals(id) ||
"com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper.selectPersonList".equals(id)) {
if ("com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper.selectPersonListCount".equals(id) ||
"com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper.selectPersonList".equals(id)) {
HashMap par = new HashMap();
if(parameter instanceof HashMap) {
par = (HashMap)((HashMap<?, ?>) parameter).get("map");
if (parameter instanceof HashMap) {
par = (HashMap) ((HashMap<?, ?>) parameter).get("map");
}
LinkedHashMap<String,String> fieldsValue = (LinkedHashMap<String, String>) par.get("fieldsValue");
LinkedHashMap<String, String> fieldsValue = (LinkedHashMap<String, String>) par.get("fieldsValue");
Iterator<String> iterator = fieldsValue.keySet().stream().iterator();
while (iterator.hasNext()) {
String next = iterator.next();
sql = sql.replaceFirst("item",next).replaceFirst("ietmValue", new StringBuffer().append("'").append(fieldsValue.get(next)).append("'").toString());
sql = sql.replaceFirst("item", next).replaceFirst("ietmValue", new StringBuffer().append("'").append(fieldsValue.get(next)).append("'").toString());
}
//通过反射修改sql语句
......@@ -82,7 +83,7 @@ public class PluginInterceptor implements Interceptor {
field.setAccessible(true);
field.set(boundSql, sql);
return executor.query(mappedStatement, parameter, rowBounds, resultHandler, cacheKey, boundSql);
} else {
} else {
return invocation.proceed();
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper">
<select id="calMaxPersonAndShiftNum" resultType="java.util.Map">
select
(select
IFNULL(max(num),0)
from
(SELECT
ifnull(count(1),0) num
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
ds.sequence_nbr = s.shift_id
and s.instance_id = i.instance_id
AND i.field_code = 'userId'
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]>
#{endDate}
AND s.shift_id is not null <!--// BUG 2807 更新人员车辆排版值班的保存逻辑 如果没有填写数据则保存空数据 。
namespace="com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper">
<select id="calMaxPersonAndShiftNum" resultType="java.util.Map">
select
(select
IFNULL(max(num),0)
from
(SELECT
ifnull(count(1),0) num
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
ds.sequence_nbr = s.shift_id
and s.instance_id = i.instance_id
AND i.field_code = 'userId'
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]>
#{endDate}
AND s.shift_id is not null <!--// BUG 2807 更新人员车辆排版值班的保存逻辑 如果没有填写数据则保存空数据 。
同步修改 查询 导出相关逻辑 by kongfm 2021-09-14 -->
and s.app_Key = #{appKey}
GROUP BY s.duty_date,s.shift_id <!--增添分组条件 根据班次分组技术 -->
) a) as maxDutyPersonNumDay,
(select
IFNULL(max(num),0)
from
(SELECT
ifnull(count(DISTINCT(s.shift_id)),0) num
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
ds.sequence_nbr = s.shift_id
and s.instance_id = i.instance_id
AND i.field_code = 'userId'
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]>
#{endDate}
and s.app_Key = #{appKey}
GROUP BY s.duty_date) b) as maxShiftNumDay
</select>
<select id="bankViewData" resultType="java.util.Map">
SELECT
S1.*,
S2.name as shiftName
from
(SELECT
s.shift_id as shiftId,
GROUP_CONCAT(i.field_value) AS userName
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
s.instance_id = i.instance_id
AND ds.sequence_nbr = s.shift_id
AND i.field_code = 'userName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
AND s.app_key = #{appKey}
and i.group_code =#{groupCode}
GROUP BY
s.shift_id
) S1,
cb_duty_shift S2
where
s1.shiftId = s2.sequence_nbr
</select>
<select id="stationViewData" resultType="java.util.Map">
select
i.field_value as postTypeName,
count(1) as total
from
cb_duty_person_shift s,
cb_dynamic_form_instance i
where
s.instance_id = i.instance_id
and i.field_code = 'postTypeName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
AND s.app_key = #{appKey}
and i.group_code =#{groupCode}
GROUP BY i.field_value
</select>
<select id="newStationViewData" resultType="java.util.Map">
select
i.field_value as postTypeName,
count(1) as total
from
cb_duty_person_shift s,
cb_dynamic_form_instance i
where
s.instance_id = i.instance_id
and i.field_code = 'postTypeName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
and i.group_code =#{groupCode}
GROUP BY i.field_value
</select>
<select id="newStationViewDataByFieldCode" resultType="java.util.Map">
select
i.field_value as postTypeName,
count(1) as total
from
cb_duty_person_shift s,
cb_dynamic_form_instance i
where
s.instance_id = i.instance_id
and i.field_code = #{fieldCode}
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
and i.group_code =#{groupCode}
AND i.field_value is not null
AND i.field_value != ''
GROUP BY i.field_value
</select>
<select id="dayDutyStatistics" resultType="java.util.Map">
SELECT
i.field_value AS postTypeName,
count( 1 ) AS total,
d.`code`,
MAX( CASE d.`code` WHEN '1601' THEN 'firePerson' WHEN '1602' THEN 'opsPerson' WHEN '1603' THEN 'securityPerson' WHEN '1604' THEN 'overhaulPerson' ELSE 'otherPerson' END ) AS postType
FROM
cb_duty_person_shift s,
cb_dynamic_form_instance i
LEFT JOIN cb_data_dictionary d ON i.field_value = d.`name`
WHERE
s.instance_id = i.instance_id
<if test="fieldCode != null and fieldCode != ''">
AND i.field_code = #{fieldCode}
</if>
<if test="date != null and date != ''">
AND s.duty_date = #{date}
</if>
AND s.shift_id IS NOT NULL
<if test="groupCode != null and groupCode != ''">
AND i.group_code = #{groupCode}
</if>
AND i.field_value IS NOT NULL
AND i.field_value != ''
<if test="dictType != null and dictType != ''">
AND d.type = #{dictType}
</if>
GROUP BY
i.field_value
</select>
<select id="dayDutyList" resultType="java.util.Map">
SELECT
id,
userName,
telephone,
peopleType
FROM
(
SELECT
ou.sequence_nbr AS id,
ou.biz_org_name AS userName,
IFNULL( MAX( CASE WHEN cfi.field_code = 'telephone' THEN field_value END ), '' ) AS telephone,
IFNULL( MAX( CASE WHEN cfi.field_code = 'positionType' THEN field_value END ), '' ) AS postTypeName,
IFNULL( MAX( CASE WHEN cfi.field_code = 'personImg' THEN field_value END ), '' ) AS personImg,
IFNULL( MAX( CASE WHEN cfi.field_code = 'peopleType' THEN field_value END ), '' ) AS peopleType
FROM
(
SELECT
IFNULL( max( CASE WHEN fi.field_code = 'userId' THEN fi.field_value END ), ps.instance_id ) AS id
FROM
cb_duty_person_shift ps
LEFT JOIN cb_dynamic_form_instance fi ON fi.instance_id = ps.instance_id
<where>
<if test="date != null and date != ''">
ps.duty_date = #{date}
</if>
</where>
GROUP BY
fi.instance_id
) a
LEFT JOIN cb_org_usr ou ON ou.sequence_nbr = a.id
LEFT JOIN cb_dynamic_form_instance cfi ON ou.sequence_nbr = cfi.instance_id
GROUP BY
a.id
) b
<where>
<if test="dictCodes != null and dictCodes.split(',').length >0">
b.peopleType IN
<foreach collection="dictCodes.split(',')" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
GROUP BY
b.id
</select>
<select id="genRangeDate" resultType="map">
SELECT
DATE_FORMAT(DATE( DATE_ADD( #{beginDate}, INTERVAL @s DAY )),'%Y-%m-%d') AS date,
and s.app_Key = #{appKey}
GROUP BY s.duty_date,s.shift_id <!--增添分组条件 根据班次分组技术 -->
) a) as maxDutyPersonNumDay,
(select
IFNULL(max(num),0)
from
(SELECT
ifnull(count(DISTINCT(s.shift_id)),0) num
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
ds.sequence_nbr = s.shift_id
and s.instance_id = i.instance_id
AND i.field_code = 'userId'
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]>
#{endDate}
and s.app_Key = #{appKey}
GROUP BY s.duty_date) b) as maxShiftNumDay
</select>
<select id="bankViewData" resultType="java.util.Map">
SELECT S1.*,
S2.name as shiftName
from (SELECT s.shift_id as shiftId,
GROUP_CONCAT(i.field_value) AS userName
FROM cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE s.instance_id = i.instance_id
AND ds.sequence_nbr = s.shift_id
AND i.field_code = 'userName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
AND s.app_key = #{appKey}
and i.group_code = #{groupCode}
GROUP BY s.shift_id
) S1,
cb_duty_shift S2
where s1.shiftId = s2.sequence_nbr
</select>
<select id="stationViewData" resultType="java.util.Map">
select i.field_value as postTypeName,
count(1) as total
from cb_duty_person_shift s,
cb_dynamic_form_instance i
where s.instance_id = i.instance_id
and i.field_code = 'postTypeName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
AND s.app_key = #{appKey}
and i.group_code = #{groupCode}
GROUP BY i.field_value
</select>
<select id="newStationViewData" resultType="java.util.Map">
select i.field_value as postTypeName,
count(1) as total
from cb_duty_person_shift s,
cb_dynamic_form_instance i
where s.instance_id = i.instance_id
and i.field_code = 'postTypeName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
and i.group_code = #{groupCode}
GROUP BY i.field_value
</select>
<select id="newStationViewDataByFieldCode" resultType="java.util.Map">
select i.field_value as postTypeName,
count(1) as total
from cb_duty_person_shift s,
cb_dynamic_form_instance i
where s.instance_id = i.instance_id
and i.field_code = #{fieldCode}
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
and i.group_code = #{groupCode}
AND i.field_value is not null
AND i.field_value != ''
GROUP BY i.field_value
</select>
<select id="dayDutyStatistics" resultType="java.util.Map">
SELECT
i.field_value AS postTypeName,
count( 1 ) AS total,
d.`code`,
MAX( CASE d.`code` WHEN '1601' THEN 'firePerson' WHEN '1602' THEN 'opsPerson' WHEN '1603' THEN 'securityPerson'
WHEN '1604' THEN 'overhaulPerson' ELSE 'otherPerson' END ) AS postType
FROM
cb_duty_person_shift s,
cb_dynamic_form_instance i
LEFT JOIN cb_data_dictionary d ON i.field_value = d.`name`
WHERE
s.instance_id = i.instance_id
<if test="fieldCode != null and fieldCode != ''">
AND i.field_code = #{fieldCode}
</if>
<if test="date != null and date != ''">
AND s.duty_date = #{date}
</if>
AND s.shift_id IS NOT NULL
<if test="groupCode != null and groupCode != ''">
AND i.group_code = #{groupCode}
</if>
AND i.field_value IS NOT NULL
AND i.field_value != ''
<if test="dictType != null and dictType != ''">
AND d.type = #{dictType}
</if>
GROUP BY
i.field_value
</select>
<select id="dayDutyList" resultType="java.util.Map">
SELECT
id,
userName,
telephone,
peopleType
FROM
(
SELECT
ou.sequence_nbr AS id,
ou.biz_org_name AS userName,
IFNULL( MAX( CASE WHEN cfi.field_code = 'telephone' THEN field_value END ), '' ) AS telephone,
IFNULL( MAX( CASE WHEN cfi.field_code = 'positionType' THEN field_value END ), '' ) AS postTypeName,
IFNULL( MAX( CASE WHEN cfi.field_code = 'personImg' THEN field_value END ), '' ) AS personImg,
IFNULL( MAX( CASE WHEN cfi.field_code = 'peopleType' THEN field_value END ), '' ) AS peopleType
FROM
(
SELECT
IFNULL( max( CASE WHEN fi.field_code = 'userId' THEN fi.field_value END ), ps.instance_id ) AS id
FROM
cb_duty_person_shift ps
LEFT JOIN cb_dynamic_form_instance fi ON fi.instance_id = ps.instance_id
<where>
<if test="date != null and date != ''">
ps.duty_date = #{date}
</if>
</where>
GROUP BY
fi.instance_id
) a
LEFT JOIN cb_org_usr ou ON ou.sequence_nbr = a.id
LEFT JOIN cb_dynamic_form_instance cfi ON ou.sequence_nbr = cfi.instance_id
GROUP BY
a.id
) b
<where>
<if test="dictCodes != null and dictCodes.split(',').length >0">
b.peopleType IN
<foreach collection="dictCodes.split(',')" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
GROUP BY
b.id
</select>
<select id="genRangeDate" resultType="map">
SELECT DATE_FORMAT(DATE( DATE_ADD( #{beginDate}, INTERVAL @s DAY)), '%Y-%m-%d') AS date,
@s := @s + 1 AS `index`
FROM
mysql.help_topic,
( SELECT @s := 0 ) temp
WHERE
@s <![CDATA[<=]]>
DATEDIFF(#{endDate},#{beginDate})
</select>
FROM
mysql.help_topic,
( SELECT @s := 0 ) temp
WHERE
@s <![CDATA[<=]]>
DATEDIFF(#{endDate}
, #{beginDate})
</select>
<select id='getSpecifyDateList' resultType='map'>
SELECT
GROUP_CONCAT(cd.field_value) AS
value
,
cds.name
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.field_code = 'userName'
<if test="params != null and params!='' ">
and cd.field_value !='消防车驾驶员'
</if>
AND cd.instance_id IN
<foreach collection='instanceIds' item='instanceId' index='index' open="(" close=")" separator=",">
#{instanceId}
</foreach>
GROUP BY
cds.`name`
</select>
<select id='getEquipmentForSpecifyDate' resultType='map'>
select * from (
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentId} THEN
cd.FIELD_VALUE
END
) AS #{equipmentId},
<select id='getSpecifyDateList' resultType='map'>
SELECT
GROUP_CONCAT(cd.field_value) AS
value
,
cds.name
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.field_code = 'userName'
<if test="params != null and params!='' ">
and cd.field_value !='消防车驾驶员'
</if>
AND cd.instance_id IN
<foreach collection ='instanceIds' item='instanceId' index='index' open="(" close= ")" separator=",">
#{instanceId}
</foreach>
GROUP BY
cds.`name`
</select>
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
<select id='getEquipmentForSpecifyDate' resultType='map'>
select * from (
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentId} THEN
cd.FIELD_VALUE
END
) AS #{equipmentId},
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName},
MAX(
CASE
WHEN cd.FIELD_CODE = #{teamName} THEN
cd.FIELD_VALUE
END
) AS #{teamName}
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName},
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate} and dp.is_delete=0
) cds ON cd.instance_id = cds.instance_id
where cd.group_code =#{groupCode} and cds.instance_id is not null and
cd.is_delete=0
group by cd.instance_id
) result
<if test="groupByName != null and groupByName!='' and groupByName=='result.carId'">
group by result.carId
</if>
<if test="groupByName != null and groupByName!='' and groupByName=='result.fireFightingId'">
group by result.fireFightingId
</if>
<if test="groupByName != null and groupByName!='' and groupByName=='result.firstAidId'">
group by result.firstAidId
</if>
</select>
MAX(
CASE
WHEN cd.FIELD_CODE = #{teamName} THEN
cd.FIELD_VALUE
END
) AS #{teamName}
<select id='getNewEquipmentForSpecifyDate' resultType='map'>
select * from (
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentId} THEN
cd.FIELD_VALUE
END
) AS #{equipmentId},
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate} and dp.is_delete=0
) cds ON cd.instance_id = cds.instance_id
where cd.group_code =#{groupCode} and cds.instance_id is not null and
cd.is_delete=0
group by cd.instance_id
) result
<if test="groupByName != null and groupByName!='' and groupByName=='result.carId'">
group by result.carId
</if>
<if test="groupByName != null and groupByName!='' and groupByName=='result.fireFightingId'">
group by result.fireFightingId
</if>
<if test="groupByName != null and groupByName!='' and groupByName=='result.firstAidId'">
group by result.firstAidId
</if>
</select>
<select id='getNewEquipmentForSpecifyDate' resultType='map'>
select * from (
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentId} THEN
cd.FIELD_VALUE
END
) AS #{equipmentId},
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName}
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate} and dp.is_delete=0
) cds ON cd.instance_id = cds.instance_id
where cd.group_code =#{groupCode} and cds.instance_id is not null and
cd.is_delete=0
group by cd.instance_id
) result
<if test="groupByName != null and groupByName!='' and groupByName=='result.deptId'">
group by result.deptId
</if>
</select>
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName}
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate} and dp.is_delete=0
) cds ON cd.instance_id = cds.instance_id
where cd.group_code =#{groupCode} and cds.instance_id is not null and
cd.is_delete=0
group by cd.instance_id
) result
<if test="groupByName != null and groupByName!='' and groupByName=='result.deptId'">
group by result.deptId
</if>
</select>
<select id='getInstanceIdForSpecifyDateAndEquipment'
resultType='map'>
SELECT
GROUP_CONCAT(cd.instance_id) as instanceIds
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.field_value = #{targetId}
</select>
<select id='getEquipmentOperator' resultType='map'>
SELECT
result.userName
FROM
(
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = 'postTypeName' THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
cds. NAME
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.instance_id IN
<foreach collection ='instanceIds' item='instanceId' index='index' open="(" close= ")" separator=",">
#{instanceId}
</foreach>
) result
WHERE
result.postTypeName = #{operator} and result.name =#{duty}
</select>
<select id='getInstanceIdForSpecifyDateAndEquipment'
resultType='map'>
SELECT GROUP_CONCAT(cd.instance_id) as instanceIds
FROM cb_dynamic_form_instance cd
LEFT JOIN (
SELECT dp.instance_id,
ds.`name`
FROM cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.field_value = #{targetId}
</select>
<select id='getEquipmentOperator' resultType='map'>
SELECT
result.userName
FROM
(
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = 'postTypeName' THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
cds. NAME
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.instance_id IN
<foreach collection='instanceIds' item='instanceId' index='index' open="(" close=")" separator=",">
#{instanceId}
</foreach>
) result
WHERE
result.postTypeName = #{operator} and result.name =#{duty}
</select>
<select id ='getPositionStaffDutyForSpecifyDate' resultType="map">
SELECT
GROUP_CONCAT(ss.userName) AS userName,
ss.postTypeName
FROM
(
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
<choose>
<when test="fieldCode != null and fieldCode != ''">
MAX(
CASE
WHEN cd.FIELD_CODE = #{fieldCode} THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
</when>
<otherwise>
MAX(
CASE
WHEN cd.FIELD_CODE = 'postTypeName' THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
</otherwise>
</choose>
cd.instance_id
FROM
cb_dynamic_form_instance cd
WHERE
cd.instance_id in
<foreach collection ='instanceIds' item='instanceId' index='index' open="(" close= ")" separator=",">
#{instanceId}
</foreach>
AND cd.group_code = #{groupCode}
AND cd.is_delete = 0
GROUP BY
cd.instance_id
) ss
<!-- LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
AND NAME IS NOT NULL
) cds ON ss.instance_id = cds.instance_id
WHERE
cds.NAME =#{duty} -->
GROUP BY
ss.postTypeName
</select>
<select id='getPositionStaffDutyForSpecifyDate' resultType="map">
SELECT
GROUP_CONCAT(ss.userName) AS userName,
ss.postTypeName
FROM
(
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
<choose>
<when test="fieldCode != null and fieldCode != ''">
MAX(
CASE
WHEN cd.FIELD_CODE = #{fieldCode} THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
</when>
<otherwise>
MAX(
CASE
WHEN cd.FIELD_CODE = 'postTypeName' THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
</otherwise>
</choose>
cd.instance_id
FROM
cb_dynamic_form_instance cd
WHERE
cd.instance_id in
<foreach collection='instanceIds' item='instanceId' index='index' open="(" close=")" separator=",">
#{instanceId}
</foreach>
AND cd.group_code = #{groupCode}
AND cd.is_delete = 0
GROUP BY
cd.instance_id
) ss
<!-- LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
AND NAME IS NOT NULL
) cds ON ss.instance_id = cds.instance_id
WHERE
cds.NAME =#{duty} -->
GROUP BY
ss.postTypeName
</select>
<select id='getDutyForSpecifyDate' resultType="map">
SELECT
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
AND NAME IS NOT NULL
GROUP BY
NAME
</select>
<select id='getDutyForSpecifyDate' resultType="map">
SELECT ds.`name`
FROM cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
AND NAME IS NOT NULL
GROUP BY NAME
</select>
<select id='getFireTeamBySequenceNbr' resultType="map">
SELECT
name
FROM
cb_fire_team
WHERE
sequence_nbr = #{sequenceNbr} and is_delete=0
<select id='getFireTeamBySequenceNbr' resultType="map">
SELECT name
FROM cb_fire_team
WHERE sequence_nbr = #{sequenceNbr}
and is_delete = 0
</select>
</select>
<select id='getFirstAidCompanyId' resultType="string">
SELECT
sequence_nbr
FROM
cb_org_usr a
WHERE
a.is_delete = 0
AND
a.biz_org_name = '消防救援保障部'
</select>
<select id='getFirstAidCompanyId' resultType="string">
SELECT sequence_nbr
FROM cb_org_usr a
WHERE a.is_delete = 0
AND a.biz_org_name = '消防救援保障部'
</select>
<select id='getFirstAidForTypeCodeAndCompanyId' resultType="map">
SELECT
cft.name,
cft.sequence_nbr
FROM
cb_fire_team cft
WHERE
cft.is_delete = 0
AND cft.type_code = (
SELECT
CODE
FROM
cb_data_dictionary cd
WHERE
cd.name = '企(事)业单位医疗救援队(站)'
AND cd.type = 'XFJGLX'
)
AND cft.company = #{company}
</select>
<select id='getFirstAidForTypeCodeAndCompanyId' resultType="map">
SELECT cft.name,
cft.sequence_nbr
FROM cb_fire_team cft
WHERE cft.is_delete = 0
AND cft.type_code = (
SELECT CODE
FROM cb_data_dictionary cd
WHERE cd.name = '企(事)业单位医疗救援队(站)'
AND cd.type = 'XFJGLX'
)
AND cft.company = #{company}
</select>
<select id='queryByCompanyId' resultType="map">
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId,companyName from (
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId, cou1.biz_org_name companyName
from (select * from cb_org_usr cou where is_delete = 0 ) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId from (
select cb.duty_date,a.deptId,c.userId from cb_duty_person_shift cb
left join (select i.instance_id id1 ,if(i.field_code = 'deptId',
i.field_value, null) as 'deptId' from cb_dynamic_form_instance i
where i.field_code = 'deptId' and i.field_value is not null) a
on cb.instance_id = a.id1
left join (select i.instance_id id3 ,if(i.field_code = 'userId',
i.field_value, null) as 'userId' from cb_dynamic_form_instance i
where i.field_code = 'userId' and i.field_value is not null) c
on cb.instance_id = c.id3
where to_days(cb.duty_date) = to_days(now()) and
a.deptId in ( select sequence_nbr from cb_org_usr cou where biz_org_name in
<foreach item="item" index="index" collection="bizNames" open="(" separator="," close=")">
#{item}
</foreach>
)) r )
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId,companyName from
(
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId, cou1.biz_org_name
companyName
from (select * from cb_org_usr cou where is_delete = 0 ) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId from (
select cb.duty_date,a.deptId,c.userId from cb_duty_person_shift cb
left join (select i.instance_id id1 ,if(i.field_code = 'deptId',
i.field_value, null) as 'deptId' from cb_dynamic_form_instance i
where i.field_code = 'deptId' and i.field_value is not null) a
on cb.instance_id = a.id1
left join (select i.instance_id id3 ,if(i.field_code = 'userId',
i.field_value, null) as 'userId' from cb_dynamic_form_instance i
where i.field_code = 'userId' and i.field_value is not null) c
on cb.instance_id = c.id3
where to_days(cb.duty_date) = to_days(now()) and
a.deptId in ( select sequence_nbr from cb_org_usr cou where biz_org_name in
<foreach item="item" index="index" collection="bizNames" open="(" separator="," close=")">
#{item}
</foreach>
)) r )
</select>
<select id='queryByCompanyNew' resultType="map">
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId,companyName from (
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId, cou1.biz_org_name companyName
from (select * from cb_org_usr cou where is_delete = 0 ) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId from (
select cb.duty_date,a.deptId,c.userId from cb_duty_person_shift cb
left join (select i.instance_id id1 ,if(i.field_code = 'deptId',
i.field_value, null) as 'deptId' from cb_dynamic_form_instance i
where i.field_code = 'deptId' and i.field_value is not null) a
on cb.instance_id = a.id1
left join (select i.instance_id id3 ,if(i.field_code = 'userId',
i.field_value, null) as 'userId' from cb_dynamic_form_instance i
where i.field_code = 'userId' and i.field_value is not null) c
on cb.instance_id = c.id3
where to_days(cb.duty_date) = to_days(now()) and
a.deptId in ( select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})) r )
<select id='queryByCompanyNew' resultType="map">
select biz_org_name as bizOrgName, sequence_nbr sequenceNbr, field_value as telephone, amosUserId, companyName
from (
select orgUsr.biz_org_name,
i.field_value,
orgUsr.sequence_nbr,
orgUsr.amos_org_id amosUserId,
cou1.biz_org_name companyName
from (select * from cb_org_usr cou where is_delete = 0) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id
where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId
from (
select cb.duty_date, a.deptId, c.userId
from cb_duty_person_shift cb
left join (select i.instance_id id1,
if(i.field_code = 'deptId',
i.field_value, null) as 'deptId'
from cb_dynamic_form_instance i
where i.field_code = 'deptId'
and i.field_value is not null) a
on cb.instance_id = a.id1
left join (select i.instance_id id3,
if(i.field_code = 'userId',
i.field_value, null) as 'userId'
from cb_dynamic_form_instance i
where i.field_code = 'userId'
and i.field_value is not null) c
on cb.instance_id = c.id3
where to_days(cb.duty_date) = to_days(now())
and a.deptId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})) r)
</select>
</mapper>
......@@ -18,210 +18,225 @@
<select id="selectPersonListCount" resultType="Integer">
select count(1) from (
SELECT
DISTINCT
u.sequence_nbr sequenceNbr,
u.biz_org_name bizOrgName,
u.biz_org_code bizOrgCode,
u.amos_org_id amosOrgId,
u.parent_id parent_id,
g.*
FROM
cb_org_usr u
LEFT JOIN
( SELECT
v.`instance_id`,
max(case v.field_code when 'personNumber' then IFNULL(v.field_value_label,v.field_value) end) personNumber,
max(case v.field_code when 'certificatesTypeCode' then IFNULL(v.field_value_label,v.field_value) end) certificatesTypeCode,
max(case v.field_code when 'gender' then IFNULL(v.field_value_label,v.field_value) end) gender,
max(case v.field_code when 'certificatesNumber' then IFNULL(v.field_value_label,v.field_value) end) certificatesNumber,
max(case v.field_code when 'telephone' then IFNULL(v.field_value_label,v.field_value) end) telephone,
max(case v.field_code when 'state' then IFNULL(v.field_value_label,v.field_value) end) state,
max(case v.field_code when 'safetyTraining' then IFNULL(v.field_value_label,v.field_value) end) safetyTraining,
max(case v.field_code when 'administrativePositionCode' then IFNULL(v.field_value_label,v.field_value) end) administrativePositionCode,
max(case v.field_code when 'internalPositionCode' then IFNULL(v.field_value_label,v.field_value) end) internalPositionCode,
max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,v.field_value) end) fireManagementPostCode,
max(case v.field_code when 'fireManagementPostCode' then v.field_value end) fireManagementPost,
max(case v.field_code when 'positionType' then IFNULL(v.field_value,v.field_value_label) end) positionType,
max(case v.field_code when 'certificateType' then IFNULL(v.field_value_label,v.field_value) end) certificateType,
max(case v.field_code when 'holdingTime' then IFNULL(v.field_value_label,v.field_value) end) holdingTime,
max(case v.field_code when 'auditCycle' then IFNULL(v.field_value_label,v.field_value) end) auditCycle,
max(case v.field_code when 'personImg' then IFNULL(v.field_value_label,v.field_value) end) personImg,
max(case v.field_code when 'certificateImg' then IFNULL(v.field_value_label,v.field_value) end) certificateImg,
max(case v.field_code when 'peopleType' then v.field_value end) peopleType
FROM
`cb_dynamic_form_instance` v
WHERE
v.group_code = 246
GROUP BY
v.`instance_id`
) g
on u.sequence_nbr = g.instance_id
where
u.biz_org_type = 'person'
AND
u.is_delete = 0
<if test="map.bizOrgName != null">
AND u.biz_org_name like concat('%',#{map.bizOrgName},'%')
</if>
<if test="map.personNumber!= null">
AND v.field_value like concat('%',#{map.personNumber},'%')
</if>
<if test="map.bizOrgCode != null and map.bizOrgCode != '-1'">
AND u.biz_org_code like concat(#{map.bizOrgCode}, '%')
</if>
<if test="map.amosOrgCode != null and map.amosOrgCode != ''">
AND u.amos_org_code like concat('%', #{map.amosOrgCode}, '%')
</if>
<if test="map.company != null and map.company != '-1'">
AND u.parent_id = #{map.company}
</if>
<if test="map.positionType != null and map.positionType != ''">
AND FIND_IN_SET(#{map.positionType},g.positionType)
</if>
<if test="map.peopleTypes != null and map.peopleTypes.size() > 0">
AND g.peopleType IN
<foreach item="item" index="index" collection="map.peopleTypes" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.fireManagementPostOne != null and map.fireManagementPostOne != ''">
AND locate(#{map.fireManagementPostOne}, g.fireManagementPost)
</if>
<if test="map.fireManagementPost != null">
AND g.fireManagementPost IN
<foreach item="item" index="index" collection="map.fireManagementPost" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.personStatus != null and map.personStatus != ''">
AND u.person_status = #{map.personStatus}
</if>
GROUP BY
u.sequence_nbr ,
u.biz_org_name ,
u.biz_org_code
order by u.rec_date desc
)a where a.sequenceNbr is not null
<if test="map.fieldsValue != null">
<foreach collection="map.fieldsValue.keys" item="item">
<if test="item != 'bizOrgName'">
AND a.item = ietmValue
</if>
</foreach>
</if>
</select>
SELECT
DISTINCT
u.sequence_nbr sequenceNbr,
u.biz_org_name bizOrgName,
u.biz_org_code bizOrgCode,
u.amos_org_id amosOrgId,
u.parent_id parent_id,
g.*
FROM
cb_org_usr u
LEFT JOIN
( SELECT
v.`instance_id`,
max(case v.field_code when 'personNumber' then IFNULL(v.field_value_label,v.field_value) end) personNumber,
max(case v.field_code when 'certificatesTypeCode' then IFNULL(v.field_value_label,v.field_value) end)
certificatesTypeCode,
max(case v.field_code when 'gender' then IFNULL(v.field_value_label,v.field_value) end) gender,
max(case v.field_code when 'certificatesNumber' then IFNULL(v.field_value_label,v.field_value) end)
certificatesNumber,
max(case v.field_code when 'telephone' then IFNULL(v.field_value_label,v.field_value) end) telephone,
max(case v.field_code when 'state' then IFNULL(v.field_value_label,v.field_value) end) state,
max(case v.field_code when 'safetyTraining' then IFNULL(v.field_value_label,v.field_value) end) safetyTraining,
max(case v.field_code when 'administrativePositionCode' then IFNULL(v.field_value_label,v.field_value) end)
administrativePositionCode,
max(case v.field_code when 'internalPositionCode' then IFNULL(v.field_value_label,v.field_value) end)
internalPositionCode,
max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,v.field_value) end)
fireManagementPostCode,
max(case v.field_code when 'fireManagementPostCode' then v.field_value end) fireManagementPost,
max(case v.field_code when 'positionType' then IFNULL(v.field_value,v.field_value_label) end) positionType,
max(case v.field_code when 'certificateType' then IFNULL(v.field_value_label,v.field_value) end)
certificateType,
max(case v.field_code when 'holdingTime' then IFNULL(v.field_value_label,v.field_value) end) holdingTime,
max(case v.field_code when 'auditCycle' then IFNULL(v.field_value_label,v.field_value) end) auditCycle,
max(case v.field_code when 'personImg' then IFNULL(v.field_value_label,v.field_value) end) personImg,
max(case v.field_code when 'certificateImg' then IFNULL(v.field_value_label,v.field_value) end) certificateImg,
max(case v.field_code when 'peopleType' then v.field_value end) peopleType
FROM
`cb_dynamic_form_instance` v
WHERE
v.group_code = 246
GROUP BY
v.`instance_id`
) g
on u.sequence_nbr = g.instance_id
where
u.biz_org_type = 'person'
AND
u.is_delete = 0
<if test="map.bizOrgName != null">
AND u.biz_org_name like concat('%',#{map.bizOrgName},'%')
</if>
<if test="map.personNumber!= null">
AND v.field_value like concat('%',#{map.personNumber},'%')
</if>
<if test="map.bizOrgCode != null and map.bizOrgCode != '-1'">
AND u.biz_org_code like concat(#{map.bizOrgCode}, '%')
</if>
<if test="map.amosOrgCode != null and map.amosOrgCode != ''">
AND u.amos_org_code like concat('%', #{map.amosOrgCode}, '%')
</if>
<if test="map.company != null and map.company != '-1'">
AND u.parent_id = #{map.company}
</if>
<if test="map.positionType != null and map.positionType != ''">
AND FIND_IN_SET(#{map.positionType},g.positionType)
</if>
<if test="map.peopleTypes != null and map.peopleTypes.size() > 0">
AND g.peopleType IN
<foreach item="item" index="index" collection="map.peopleTypes" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.fireManagementPostOne != null and map.fireManagementPostOne != ''">
AND locate(#{map.fireManagementPostOne}, g.fireManagementPost)
</if>
<if test="map.fireManagementPost != null">
AND g.fireManagementPost IN
<foreach item="item" index="index" collection="map.fireManagementPost" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.personStatus != null and map.personStatus != ''">
AND u.person_status = #{map.personStatus}
</if>
GROUP BY
u.sequence_nbr ,
u.biz_org_name ,
u.biz_org_code
order by u.rec_date desc
)a where a.sequenceNbr is not null
<if test="map.fieldsValue != null">
<foreach collection="map.fieldsValue.keys" item="item">
<if test="item != 'bizOrgName'">
AND a.item = ietmValue
</if>
</foreach>
</if>
</select>
<!--机场单位人员按时间倒叙排列add order by u.rec_date desc 2021-09-08 by kongfm -->
<select id="selectPersonList" resultType="Map">
select * from (
SELECT
DISTINCT
u.sequence_nbr sequenceNbr,
u.biz_org_name bizOrgName,
u.amos_org_id amosOrgId,
u.biz_org_code bizOrgCode,
u.parent_id parentId,
u.person_status personStatus,
u.rec_date recDate,
(select biz_org_name from cb_org_usr where sequence_nbr = u.parent_id) as companyName,
(SELECT IFNULL(SUM(IF(aqr.SOURCE = 'patrol', 1, 0)), 0) FROM dl_amos_idx_biz.idx_access_qrcode_record aqr WHERE aqr.buss_id = u.sequence_nbr ) as 'patrol',
(SELECT IFNULL(SUM(IF(aqr.SOURCE != 'patrol', 1, 0)), 0) FROM dl_amos_idx_biz.idx_access_qrcode_record aqr WHERE aqr.buss_id = u.sequence_nbr ) as 'other',
g.*
FROM
cb_org_usr u
select * from (
SELECT
DISTINCT
u.sequence_nbr sequenceNbr,
u.biz_org_name bizOrgName,
u.amos_org_id amosOrgId,
u.biz_org_code bizOrgCode,
u.parent_id parentId,
u.person_status personStatus,
u.rec_date recDate,
(select biz_org_name from cb_org_usr where sequence_nbr = u.parent_id) as companyName,
(SELECT IFNULL(SUM(IF(aqr.SOURCE = 'patrol', 1, 0)), 0) FROM dl_amos_idx_biz.idx_access_qrcode_record aqr WHERE
aqr.buss_id = u.sequence_nbr ) as 'patrol',
(SELECT IFNULL(SUM(IF(aqr.SOURCE != 'patrol', 1, 0)), 0) FROM dl_amos_idx_biz.idx_access_qrcode_record aqr WHERE
aqr.buss_id = u.sequence_nbr ) as 'other',
g.*
FROM
cb_org_usr u
LEFT JOIN
( SELECT
v.`instance_id`,
max(case v.field_code when 'personNumber' then IFNULL(v.field_value_label,v.field_value) end) personNumber,
max(case v.field_code when 'certificatesTypeCode' then IFNULL(v.field_value_label,v.field_value) end) certificatesTypeCode,
max(case v.field_code when 'gender' then IFNULL(v.field_value_label,v.field_value) end) gender,
max(case v.field_code when 'certificatesNumber' then IFNULL(v.field_value_label,v.field_value) end) certificatesNumber,
max(case v.field_code when 'telephone' then IFNULL(v.field_value_label,v.field_value) end) telephone,
max(case v.field_code when 'stateCode' then IFNULL(v.field_value_label,v.field_value) end) state,
max(case v.field_code when 'safetyTraining' then IFNULL(v.field_value_label,v.field_value) end) safetyTraining,
max(case v.field_code when 'administrativePositionCode' then IFNULL(v.field_value_label,v.field_value) end) administrativePositionCode,
max(case v.field_code when 'internalPositionCode' then IFNULL(v.field_value_label,v.field_value) end) internalPositionCode,
max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,v.field_value) end) fireManagementPostCode,
max(case v.field_code when 'fireManagementPostCode' then v.field_value end) fireManagementPost,
max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,'其他') end) fireManagementPostName,
max(case v.field_code when 'positionType' then IFNULL(v.field_value,v.field_value_label) end) positionType,
max(case v.field_code when 'positionType' then IFNULL(v.field_value_label,'其他') end) positionTypeName,
max(case v.field_code when 'certificateType' then IFNULL(v.field_value_label,v.field_value) end) certificateType,
max(case v.field_code when 'holdingTime' then IFNULL(v.field_value_label,v.field_value) end) holdingTime,
max(case v.field_code when 'auditCycle' then IFNULL(v.field_value_label,v.field_value) end) auditCycle,
max(case v.field_code when 'personImg' then IFNULL(v.field_value_label,v.field_value) end) personImg,
max(case v.field_code when 'certificateImg' then IFNULL(v.field_value_label,v.field_value) end) certificateImg,
max(case v.field_code when 'peopleType' then v.field_value end) peopleType
FROM
`cb_dynamic_form_instance` v
WHERE
v.group_code = 246
GROUP BY
v.`instance_id`
) g
LEFT JOIN
( SELECT
v.`instance_id`,
max(case v.field_code when 'personNumber' then IFNULL(v.field_value_label,v.field_value) end) personNumber,
max(case v.field_code when 'certificatesTypeCode' then IFNULL(v.field_value_label,v.field_value) end)
certificatesTypeCode,
max(case v.field_code when 'gender' then IFNULL(v.field_value_label,v.field_value) end) gender,
max(case v.field_code when 'certificatesNumber' then IFNULL(v.field_value_label,v.field_value) end)
certificatesNumber,
max(case v.field_code when 'telephone' then IFNULL(v.field_value_label,v.field_value) end) telephone,
max(case v.field_code when 'stateCode' then IFNULL(v.field_value_label,v.field_value) end) state,
max(case v.field_code when 'safetyTraining' then IFNULL(v.field_value_label,v.field_value) end) safetyTraining,
max(case v.field_code when 'administrativePositionCode' then IFNULL(v.field_value_label,v.field_value) end)
administrativePositionCode,
max(case v.field_code when 'internalPositionCode' then IFNULL(v.field_value_label,v.field_value) end)
internalPositionCode,
max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,v.field_value) end)
fireManagementPostCode,
max(case v.field_code when 'fireManagementPostCode' then v.field_value end) fireManagementPost,
max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,'其他') end)
fireManagementPostName,
max(case v.field_code when 'positionType' then IFNULL(v.field_value,v.field_value_label) end) positionType,
max(case v.field_code when 'positionType' then IFNULL(v.field_value_label,'其他') end) positionTypeName,
max(case v.field_code when 'certificateType' then IFNULL(v.field_value_label,v.field_value) end)
certificateType,
max(case v.field_code when 'holdingTime' then IFNULL(v.field_value_label,v.field_value) end) holdingTime,
max(case v.field_code when 'auditCycle' then IFNULL(v.field_value_label,v.field_value) end) auditCycle,
max(case v.field_code when 'personImg' then IFNULL(v.field_value_label,v.field_value) end) personImg,
max(case v.field_code when 'certificateImg' then IFNULL(v.field_value_label,v.field_value) end) certificateImg,
max(case v.field_code when 'peopleType' then v.field_value end) peopleType
FROM
`cb_dynamic_form_instance` v
WHERE
v.group_code = 246
GROUP BY
v.`instance_id`
) g
on u.sequence_nbr = g.instance_id
on u.sequence_nbr = g.instance_id
where
u.biz_org_type = 'person'
AND
u.is_delete = 0
<if test="map.bizOrgName != null">
AND u.biz_org_name like concat('%',#{map.bizOrgName},'%')
</if>
<if test="map.personNumber!= null">
AND v.field_value like concat('%',#{map.personNumber},'%')
</if>
<if test="map.bizOrgCode != null and map.bizOrgCode != '-1'">
AND u.biz_org_code like concat(#{map.bizOrgCode}, '%')
</if>
<if test="map.amosOrgCode != null and map.amosOrgCode != ''">
AND u.amos_org_code like concat('%',#{map.amosOrgCode}, '%')
</if>
<if test="map.company != null and map.company != '-1'">
where
u.biz_org_type = 'person'
AND
u.is_delete = 0
<if test="map.bizOrgName != null">
AND u.biz_org_name like concat('%',#{map.bizOrgName},'%')
</if>
<if test="map.personNumber!= null">
AND v.field_value like concat('%',#{map.personNumber},'%')
</if>
<if test="map.bizOrgCode != null and map.bizOrgCode != '-1'">
AND u.biz_org_code like concat(#{map.bizOrgCode}, '%')
</if>
<if test="map.amosOrgCode != null and map.amosOrgCode != ''">
AND u.amos_org_code like concat('%',#{map.amosOrgCode}, '%')
</if>
<if test="map.company != null and map.company != '-1'">
AND u.parent_id = #{map.company}
</if>
<if test="map.positionType != null and map.positionType != ''">
</if>
<if test="map.positionType != null and map.positionType != ''">
AND FIND_IN_SET(#{map.positionType},g.positionType)
</if>
<if test="map.peopleTypes != null and map.peopleTypes.size() > 0">
AND g.peopleType IN
<foreach item="item" index="index" collection="map.peopleTypes" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.fireManagementPostOne != null and map.fireManagementPostOne != ''">
AND locate(#{map.fireManagementPostOne}, g.fireManagementPost)
</if>
<if test="map.fireManagementPost != null">
AND g.fireManagementPost IN
<foreach item="item" index="index" collection="map.fireManagementPost" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.personStatus != null and map.personStatus != ''">
AND u.person_status = #{map.personStatus}
</if>
GROUP BY
u.sequence_nbr ,
u.biz_org_name ,
u.biz_org_code
) a where a.sequenceNbr is not null
<if test="map.fieldsValue != null">
<foreach collection="map.fieldsValue.keys" item="item">
<if test="item != 'bizOrgName'">
AND a.item = ietmValue
</if>
</foreach>
</if>
order by CONVERT(a.companyName USING gbk) ASC, a.personStatus DESC, a.recDate DESC
LIMIT #{map.pageNum}, #{map.pageSize}
</if>
<if test="map.peopleTypes != null and map.peopleTypes.size() > 0">
AND g.peopleType IN
<foreach item="item" index="index" collection="map.peopleTypes" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.fireManagementPostOne != null and map.fireManagementPostOne != ''">
AND locate(#{map.fireManagementPostOne}, g.fireManagementPost)
</if>
<if test="map.fireManagementPost != null">
AND g.fireManagementPost IN
<foreach item="item" index="index" collection="map.fireManagementPost" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.personStatus != null and map.personStatus != ''">
AND u.person_status = #{map.personStatus}
</if>
GROUP BY
u.sequence_nbr ,
u.biz_org_name ,
u.biz_org_code
) a where a.sequenceNbr is not null
<if test="map.fieldsValue != null">
<foreach collection="map.fieldsValue.keys" item="item">
<if test="item != 'bizOrgName'">
AND a.item = ietmValue
</if>
</foreach>
</if>
order by CONVERT(a.companyName USING gbk) ASC, a.personStatus DESC, a.recDate DESC
LIMIT #{map.pageNum}, #{map.pageSize}
</select>
<!--机场单位查询机构下所有子数据 2021-09-16 by litw -->
......@@ -233,7 +248,7 @@
FROM
cb_org_usr u
where
u.is_delete = 0
u.is_delete = 0
<if test="map.bizOrgCode != null and map.bizOrgCode != '-1'">
AND u.biz_org_code like concat(#{map.bizOrgCode}, '%')
</if>
......@@ -248,7 +263,8 @@
u.biz_org_name bizOrgName,
u.biz_org_code bizOrgCode,
<if test="fields != null">
<foreach collection="fields" item="item" separator=",">MAX(case f.field_code when #{item} then IFNULL(v.field_value_label, v.field_value)
<foreach collection="fields" item="item" separator=",">MAX(case f.field_code when #{item} then
IFNULL(v.field_value_label, v.field_value)
end) as #{item}
</foreach>
</if>
......@@ -275,8 +291,8 @@
amos_org_id
FROM `cb_org_usr`
WHERE is_delete = 0
and (biz_org_type = "COMPANY"
or biz_org_type = "DEPARTMENT")
and (biz_org_type = "COMPANY"
or biz_org_type = "DEPARTMENT")
</select>
<select id="queryOrgUsrListByBizOrgCode" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
......@@ -358,28 +374,27 @@
SELECT *
FROM cb_org_usr
WHERE is_delete = 0
<if test="orgUserId != null">
AND biz_org_code LIKE CONCAT((SELECT biz_org_code FROM cb_org_usr WHERE sequence_nbr = #{orgUserId}),'%');
</if>
<if test="orgUserId != null">
AND biz_org_code LIKE CONCAT((SELECT biz_org_code FROM cb_org_usr WHERE sequence_nbr = #{orgUserId}),'%');
</if>
</select>
<select id="selectOrgUsrList" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgUsrDto">
SELECT DISTINCT
cb_org_usr.sequence_nbr ,
cb_org_usr.biz_org_name,
cb_org_usr.biz_org_code,
cb_org_usr.amos_org_id,
cb_org_usr.amos_org_code,
cb_org_usr.biz_org_type,
cb_org_usr.build_name,
cb_org_usr.build_id,
cb_org_usr.parent_id,
cb_contract.sequence_nbr as contract_id
FROM
cb_org_usr
LEFT JOIN cb_contract on cb_org_usr.sequence_nbr = cb_contract.signed_company_id and cb_contract.company_id = #{seq}
WHERE
cb_org_usr.sequence_nbr IN ( SELECT DISTINCT signed_company_id FROM cb_contract WHERE company_id = #{seq} and is_delete = 0 )
SELECT DISTINCT cb_org_usr.sequence_nbr,
cb_org_usr.biz_org_name,
cb_org_usr.biz_org_code,
cb_org_usr.amos_org_id,
cb_org_usr.amos_org_code,
cb_org_usr.biz_org_type,
cb_org_usr.build_name,
cb_org_usr.build_id,
cb_org_usr.parent_id,
cb_contract.sequence_nbr as contract_id
FROM cb_org_usr
LEFT JOIN cb_contract on cb_org_usr.sequence_nbr = cb_contract.signed_company_id and
cb_contract.company_id = #{seq}
WHERE cb_org_usr.sequence_nbr IN
(SELECT DISTINCT signed_company_id FROM cb_contract WHERE company_id = #{seq} and is_delete = 0)
AND cb_org_usr.biz_org_type = "COMPANY"
AND cb_org_usr.is_delete = 0
</select>
......@@ -394,19 +409,20 @@
a.companyMaleEmployees,
a.companyFemaleEmployees,
a.managementType,
a. keySiteCompany as isKeyPoint,
a. keySiteCompany as isKeyPoint,
Round(st_distance(point(a.longitude,a.latitude),point(#{par.longitude},#{par.latitude}))*111195,1) AS distance,
case when cks_d.count is null then 0 else cks_d.count end as keySiteNum
case when cks_d.count is null then 0 else cks_d.count end as keySiteNum
FROM important_companys a left join (
SELECT cks.belong_id ,count(cks.belong_id) count from cb_key_site cks where cks.is_delete=0 GROUP BY cks.belong_id
SELECT cks.belong_id ,count(cks.belong_id) count from cb_key_site cks where cks.is_delete=0 GROUP BY
cks.belong_id
)cks_d
on a.id=cks_d.belong_id
where a.longitude is not null and a.latitude is not null and a.keySiteCompany = 1
on a.id=cks_d.belong_id
where a.longitude is not null and a.latitude is not null and a.keySiteCompany = 1
<if test='par.distance!=null'>
and Round(st_distance(point(a.longitude,a.latitude),point(#{par.longitude},#{par.latitude}))*111195,1) &lt;=
#{par.distance}
</if>
ORDER BY distance limit #{pageNum},#{pageSize}
ORDER BY distance limit #{pageNum},#{pageSize}
</select>
<select id="listContractDtoCount" resultType="Integer">
......@@ -421,145 +437,124 @@
</select>
<select id="getOrgUsrzhDto" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgUsrzhDto">
SELECT
a.biz_org_name bizOrgName,
a.build_name buildName,
a.build_id buildId,
c.keySiteCount keySiteCount,
( SELECT v.biz_org_name FROM cb_org_usr v WHERE v.sequence_nbr = a.parent_id ) parentName,
max( CASE b.field_code WHEN 'businessCategory' THEN b.field_value_label ELSE "" END ) AS 'businessCategory',
max( CASE b.field_code WHEN 'companyFemaleEmployees' THEN b.field_value ELSE "" END ) AS 'companyFemaleEmployees',
max( CASE b.field_code WHEN 'companyLocation' THEN b.field_value ELSE "" END ) AS 'companyLocation',
max( CASE b.field_code WHEN 'companyMaleEmployees' THEN b.field_value ELSE "" END ) AS 'companyMaleEmployees',
max( CASE b.field_code WHEN 'companyNature' THEN b.field_value_label ELSE "" END ) AS 'companyNature',
max( CASE b.field_code WHEN 'companyPhone' THEN b.field_value ELSE "" END ) AS 'companyPhone',
max( CASE b.field_code WHEN 'companyPhoto' THEN b.field_value ELSE "" END ) AS 'companyPhoto',
max( CASE b.field_code WHEN 'managementType' THEN b.field_value_label ELSE "" END ) AS 'managementType'
FROM
cb_org_usr a
LEFT JOIN cb_dynamic_form_instance b ON a.sequence_nbr = b.instance_id
LEFT JOIN (select belong_id belongId , count(*) keySiteCount from cb_key_site group by belong_id) c on c.belongId = a.sequence_nbr
WHERE
a.biz_org_name = #{bizOrgName}
SELECT a.biz_org_name bizOrgName,
a.build_name buildName,
a.build_id buildId,
c.keySiteCount keySiteCount,
(SELECT v.biz_org_name FROM cb_org_usr v WHERE v.sequence_nbr = a.parent_id) parentName,
max(CASE b.field_code
WHEN 'businessCategory' THEN b.field_value_label
ELSE "" END) AS 'businessCategory',
max(CASE b.field_code
WHEN 'companyFemaleEmployees' THEN b.field_value
ELSE "" END) AS 'companyFemaleEmployees',
max(CASE b.field_code WHEN 'companyLocation' THEN b.field_value ELSE "" END) AS 'companyLocation',
max(CASE b.field_code
WHEN 'companyMaleEmployees' THEN b.field_value
ELSE "" END) AS 'companyMaleEmployees',
max(CASE b.field_code WHEN 'companyNature' THEN b.field_value_label ELSE "" END) AS 'companyNature',
max(CASE b.field_code WHEN 'companyPhone' THEN b.field_value ELSE "" END) AS 'companyPhone',
max(CASE b.field_code WHEN 'companyPhoto' THEN b.field_value ELSE "" END) AS 'companyPhoto',
max(CASE b.field_code WHEN 'managementType' THEN b.field_value_label ELSE "" END) AS 'managementType'
FROM cb_org_usr a
LEFT JOIN cb_dynamic_form_instance b ON a.sequence_nbr = b.instance_id
LEFT JOIN (select belong_id belongId, count(*) keySiteCount from cb_key_site group by belong_id) c
on c.belongId = a.sequence_nbr
WHERE a.biz_org_name = #{bizOrgName}
</select>
<select id="getCompanyAndCountDepartment" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgUsrTreeDto">
SELECT result_main.sequenceNbr AS sequenceNbr,
result_main.bizOrgName AS bizOrgName,
result_main.parentId AS parentId,
result_main.num1 + result_main.num2 AS num
FROM (
SELECT CASE
WHEN result1.num IS NULL THEN
0
ELSE
result1.num
END AS num1,
CASE
WHEN result2.num IS NULL THEN
0
ELSE
result2.num
END AS num2,
result1.sequenceNbr,
result1.bizOrgName,
result1.parentId
FROM (
SELECT company_sur.sequence_nbr AS sequenceNbr,
company_sur.biz_org_name AS bizOrgName,
company_sur.parent_id AS parentId,
CASE
WHEN keysite_sur.num IS NULL THEN
0
ELSE
keysite_sur.num
END AS num
FROM (
SELECT company.sequence_nbr,
company.parent_id,
company.biz_org_name
FROM cb_org_usr company
WHERE company.biz_org_type = 'COMPANY'
AND company.is_delete = FALSE
) company_sur
LEFT JOIN (
SELECT keysite.belong_id,
COUNT(keysite.belong_id) AS num
FROM cb_key_site keysite
WHERE keysite.is_delete = FALSE
GROUP BY keysite.belong_id
) keysite_sur ON company_sur.sequence_nbr = keysite_sur.belong_id
) result1
LEFT JOIN (
SELECT company_sur.sequence_nbr AS sequenceNbr,
company_sur.biz_org_name AS bizOrgName,
company_sur.parent_id AS parentId,
CASE
WHEN keysite_sur.num IS NULL THEN
0
ELSE
keysite_sur.num
END AS num
FROM (
SELECT company.sequence_nbr,
company.parent_id,
company.biz_org_name
FROM cb_org_usr company
WHERE company.biz_org_type = 'COMPANY'
AND company.is_delete = FALSE
) company_sur
LEFT JOIN (
SELECT keysite.belong_id,
COUNT(keysite.belong_id) AS num
FROM cb_key_site keysite
WHERE keysite.is_delete = FALSE
GROUP BY keysite.belong_id
) keysite_sur ON company_sur.sequence_nbr = keysite_sur.belong_id
) result2 ON result1.sequenceNbr = result2.parentId
) result_main
GROUP BY result_main.sequenceNbr
</select>
<select id="getCompanyAndCountDepartment" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgUsrTreeDto">
SELECT
result_main.sequenceNbr AS sequenceNbr,
result_main.bizOrgName AS bizOrgName,
result_main.parentId AS parentId,
result_main.num1 + result_main.num2 AS num
FROM
(
SELECT
CASE
WHEN result1.num IS NULL THEN
0
ELSE
result1.num
END AS num1,
CASE
WHEN result2.num IS NULL THEN
0
ELSE
result2.num
END AS num2,
result1.sequenceNbr,
result1.bizOrgName,
result1.parentId
FROM
(
SELECT
company_sur.sequence_nbr AS sequenceNbr,
company_sur.biz_org_name AS bizOrgName,
company_sur.parent_id AS parentId,
CASE
WHEN keysite_sur.num IS NULL THEN
0
ELSE
keysite_sur.num
END AS num
FROM
(
SELECT
company.sequence_nbr,
company.parent_id,
company.biz_org_name
FROM
cb_org_usr company
WHERE
company.biz_org_type = 'COMPANY'
AND company.is_delete = FALSE
) company_sur
LEFT JOIN (
SELECT
keysite.belong_id,
COUNT(keysite.belong_id) AS num
FROM
cb_key_site keysite
WHERE
keysite.is_delete = FALSE
GROUP BY
keysite.belong_id
) keysite_sur ON company_sur.sequence_nbr = keysite_sur.belong_id
) result1
LEFT JOIN (
SELECT
company_sur.sequence_nbr AS sequenceNbr,
company_sur.biz_org_name AS bizOrgName,
company_sur.parent_id AS parentId,
CASE
WHEN keysite_sur.num IS NULL THEN
0
ELSE
keysite_sur.num
END AS num
FROM
(
SELECT
company.sequence_nbr,
company.parent_id,
company.biz_org_name
FROM
cb_org_usr company
WHERE
company.biz_org_type = 'COMPANY'
AND company.is_delete = FALSE
) company_sur
LEFT JOIN (
SELECT
keysite.belong_id,
COUNT(keysite.belong_id) AS num
FROM
cb_key_site keysite
WHERE
keysite.is_delete = FALSE
GROUP BY
keysite.belong_id
) keysite_sur ON company_sur.sequence_nbr = keysite_sur.belong_id
) result2 ON result1.sequenceNbr = result2.parentId
) result_main
GROUP BY
result_main.sequenceNbr
</select>
<select id="getparent" resultType="Map">
SELECT important_companys.id ,important_companys.name
SELECT important_companys.id, important_companys.name
FROM important_companys
FROM important_companys
</select>
<select id="getUserUnit" resultType="com.yeejoin.amos.boot.module.common.api.dto.UserUnitDto">
SELECT
u.sequence_nbr AS personSeq,
u.biz_org_name AS personName,
'2' AS identityType,
IFNULL( u.biz_org_code, '' ) AS companyId
u.sequence_nbr AS personSeq,
u.biz_org_name AS personName,
'2' AS identityType,
IFNULL( u.biz_org_code, '' ) AS companyId
FROM
`cb_org_usr` u
`cb_org_usr` u
<where>
<if test="id != null and id != ''">
u.amos_org_id = #{id}
......@@ -572,22 +567,22 @@ GROUP BY
</if>
</where>
ORDER BY
u.sequence_nbr DESC
u.sequence_nbr DESC
</select>
<select id="getUserInfo" resultType="com.yeejoin.amos.boot.module.common.api.dto.UserDto">
SELECT
u.sequence_nbr AS personSeq,
u.biz_org_name AS personName,
'2' AS identityType,
u.biz_org_code,
f.field_code,
f.field_value,
u.biz_org_type
u.sequence_nbr AS personSeq,
u.biz_org_name AS personName,
'2' AS identityType,
u.biz_org_code,
f.field_code,
f.field_value,
u.biz_org_type
FROM
`cb_org_usr` u
LEFT JOIN cb_dynamic_form_instance f ON f.instance_id = u.sequence_nbr
`cb_org_usr` u
LEFT JOIN cb_dynamic_form_instance f ON f.instance_id = u.sequence_nbr
<where>
u. is_delete = 0
u. is_delete = 0
<if test="id != null and id != ''">
AND u.amos_org_id = #{id}
</if>
......@@ -605,256 +600,259 @@ GROUP BY
</if>
</where>
ORDER BY
u.sequence_nbr DESC
u.sequence_nbr DESC
</select>
<!--BUG2655 导出机场人员存在已删除数据 bykongfm-->
<select id="exportToExcel" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgUsrExcelDto">
select
a.biz_org_name bizOrgName,
(select c.biz_org_name from cb_org_usr c where c.sequence_nbr=a.parent_id) parentId,
select
a.biz_org_name bizOrgName,
(select c.biz_org_name from cb_org_usr c where c.sequence_nbr=a.parent_id) parentId,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fe.first_degree
AND type = 'XLLX'
) AS first_degree,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fe.highest_education
AND type = 'XLLX'
) AS highest_education,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fe.academic_degree
AND type = 'XWLX'
) AS academic_degree,
fe.school,
fe.professional_name,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fp.employee_hierarchy
AND type = 'YGCJ'
) AS employee_hierarchy,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fp.internal_position_code
AND type = 'JGNBZW'
) AS internal_position_code,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fp.audit_cycle
AND type = 'SHZQ'
) AS audit_cycle,
fp.administrative_position as administrativePositionCode,
fp.job_title as positionType,
fp.post_qualification as postQualification,
fp.fire_management_post as fireManagementPostCode,
fp.certificate_type as certificateType,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fc.relationship
AND type = 'RJGX'
) AS relationship,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.gender
AND type = 'XB'
) AS gender,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.safetyTraining
AND type = 'AQPX'
) AS safetyTraining,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.peopleType
AND type = 'DLRYLX'
) AS peopleType,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.certificatesTypeCode
AND type = 'RYZJLX'
) AS certificatesTypeCode,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.stateCode
AND type = 'RYZT'
) AS stateCode,
fc.emergency_contact,
fc.emergency_contact_phone,
fp.employee_hierarchy employeeHierarchy,
cast(b.birthdayTime as datetime) as birthdayTime,
b.*,
fw.*
from cb_org_usr a LEFT JOIN
(SELECT
instance_id,
max(case field_code when 'auditCycle' then field_value_label end) auditCycle,
max(case field_code when 'certificatesNumber' then field_value end) certificatesNumber,
max(case field_code when 'certificatesTypeCode' then field_value end) certificatesTypeCode,
max(case field_code when 'certificateType' then field_value_label end) certificateType,
max(case field_code when 'fireManagementPostCode' then field_value_label end) fireManagementPostCode,
max(case field_code when 'gender' then field_value end) gender,
max(case field_code when 'internalPositionCode' then field_value_label end) internalPositionCode,
max(case field_code when 'personNumber' then field_value end) personNumber,
max(case field_code when 'positionType' then field_value_label end) positionType,
max(case field_code when 'safetyTraining' then field_value end) safetyTraining,
max(case field_code when 'stateCode' then field_value end) stateCode,
max(case field_code when 'telephone' then field_value end) telephone,
max(case field_code when 'peopleType' then field_value end) peopleType,
max(case field_code when 'nation' then field_value end) nation,
max(case field_code when 'birthdayTime' then field_value end) birthdayTime,
max(case field_code when 'maritalStatus' then field_value end) maritalStatus,
max(case field_code when 'nativePlaceCode' then field_value_label end) nativePlace,
max(case field_code when 'nativePlaceVal' then field_value end) nativePlaceVal,
max(case field_code when 'politicalOutlook' then field_value end) politicalOutlook,
max(case field_code when 'residenceDetailsCode' then field_value_label end) residenceDetails,
max(case field_code when 'residenceDetailVal' then field_value end) residenceDetailVal,
max(case field_code when 'airportAccommodation' then field_value end) airportAccommodation
FROM cb_dynamic_form_instance GROUP BY instance_id) b
on b.instance_id=a.sequence_nbr
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fe.first_degree
AND type = 'XLLX'
) AS first_degree,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fe.highest_education
AND type = 'XLLX'
) AS highest_education,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fe.academic_degree
AND type = 'XWLX'
) AS academic_degree,
fe.school,
fe.professional_name,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fp.employee_hierarchy
AND type = 'YGCJ'
) AS employee_hierarchy,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fp.internal_position_code
AND type = 'JGNBZW'
) AS internal_position_code,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fp.audit_cycle
AND type = 'SHZQ'
) AS audit_cycle,
fp.administrative_position as administrativePositionCode,
fp.job_title as positionType,
fp.post_qualification as postQualification,
fp.fire_management_post as fireManagementPostCode,
fp.certificate_type as certificateType,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = fc.relationship
AND type = 'RJGX'
) AS relationship,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.gender
AND type = 'XB'
) AS gender,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.safetyTraining
AND type = 'AQPX'
) AS safetyTraining,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.peopleType
AND type = 'DLRYLX'
) AS peopleType,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.certificatesTypeCode
AND type = 'RYZJLX'
) AS certificatesTypeCode,
(
SELECT
NAME
FROM
cb_data_dictionary
WHERE
CODE = b.stateCode
AND type = 'RYZT'
) AS stateCode,
fc.emergency_contact,
fc.emergency_contact_phone,
fp.employee_hierarchy employeeHierarchy,
cast(b.birthdayTime as datetime) as birthdayTime,
b.*,
fw.*
from cb_org_usr a LEFT JOIN
(SELECT
instance_id,
max(case field_code when 'auditCycle' then field_value_label end) auditCycle,
max(case field_code when 'certificatesNumber' then field_value end) certificatesNumber,
max(case field_code when 'certificatesTypeCode' then field_value end) certificatesTypeCode,
max(case field_code when 'certificateType' then field_value_label end) certificateType,
max(case field_code when 'fireManagementPostCode' then field_value_label end) fireManagementPostCode,
max(case field_code when 'gender' then field_value end) gender,
max(case field_code when 'internalPositionCode' then field_value_label end) internalPositionCode,
max(case field_code when 'personNumber' then field_value end) personNumber,
max(case field_code when 'positionType' then field_value_label end) positionType,
max(case field_code when 'safetyTraining' then field_value end) safetyTraining,
max(case field_code when 'stateCode' then field_value end) stateCode,
max(case field_code when 'telephone' then field_value end) telephone,
max(case field_code when 'peopleType' then field_value end) peopleType,
max(case field_code when 'nation' then field_value end) nation,
max(case field_code when 'birthdayTime' then field_value end) birthdayTime,
max(case field_code when 'maritalStatus' then field_value end) maritalStatus,
max(case field_code when 'nativePlaceCode' then field_value_label end) nativePlace,
max(case field_code when 'nativePlaceVal' then field_value end) nativePlaceVal,
max(case field_code when 'politicalOutlook' then field_value end) politicalOutlook,
max(case field_code when 'residenceDetailsCode' then field_value_label end) residenceDetails,
max(case field_code when 'residenceDetailVal' then field_value end) residenceDetailVal,
max(case field_code when 'airportAccommodation' then field_value end) airportAccommodation
FROM cb_dynamic_form_instance GROUP BY instance_id) b
on b.instance_id=a.sequence_nbr
LEFT JOIN cb_firefighters_contacts fc ON CAST(a.sequence_nbr as char) = fc.org_usr_id
LEFT JOIN cb_firefighters_workexperience fw ON CAST(a.sequence_nbr as char) = fw.org_usr_id
LEFT JOIN cb_firefighters_education fe ON CAST(a.sequence_nbr as char) = fe.org_usr_id
LEFT JOIN cb_firefighters_post fp ON CAST(a.sequence_nbr as char) = fp.org_usr_id
where a.biz_org_name is not null and a.is_delete = 0 and a.biz_org_type = 'PERSON'
<if test="parentId != null and parentId != '' and parentId != '-1'">
and a.parent_id = #{parentId}
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND a.biz_org_code LIKE CONCAT( '%',#{bizOrgCode}, '%')
</if>
<if test="internalPositionCode != null and internalPositionCode != ''">
and b.internalPositionCode = #{internalPositionCode}
</if>
<if test="positionType != null and positionType != ''">
b.positionType = #{positionType}
</if>
where a.biz_org_name is not null and a.is_delete = 0 and a.biz_org_type = 'PERSON'
<if test="parentId != null and parentId != '' and parentId != '-1'">
and a.parent_id = #{parentId}
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND a.biz_org_code LIKE CONCAT( '%',#{bizOrgCode}, '%')
</if>
<if test="internalPositionCode != null and internalPositionCode != ''">
and b.internalPositionCode = #{internalPositionCode}
</if>
<if test="positionType != null and positionType != ''">
b.positionType = #{positionType}
</if>
</select>
<select id="getCompanyAndKeySite" resultType="com.yeejoin.amos.boot.module.common.api.dto.CheckObjectDto" >
<select id="getCompanyAndKeySite" resultType="com.yeejoin.amos.boot.module.common.api.dto.CheckObjectDto">
SELECT
SELECT
company_sur.sequence_nbr as sequenceNbr,
company_sur.biz_org_name as bizOrgName,
company_sur.biz_org_code as bizOrgCode,
company_sur.parent_id as parentId,
company_sur.biz_org_type as bizOrgType,
-- cb.field_value_label,
(SELECT field_value_label FROM cb_dynamic_form_instance as cb WHERE company_sur.sequence_nbr = cb.instance_id AND field_code = 'companyNature' ) as companyNature,
(SELECT field_value_label FROM cb_dynamic_form_instance as cb WHERE company_sur.sequence_nbr = cb.instance_id AND field_code = 'businessCategory' ) as managementType,
-- cb.field_value_label,
(SELECT field_value_label FROM cb_dynamic_form_instance as cb WHERE company_sur.sequence_nbr = cb.instance_id
AND field_code = 'companyNature' ) as companyNature,
(SELECT field_value_label FROM cb_dynamic_form_instance as cb WHERE company_sur.sequence_nbr = cb.instance_id
AND field_code = 'businessCategory' ) as managementType,
CASE
WHEN keysite_sur.num IS NULL THEN
0
0
ELSE
keysite_sur.num
keysite_sur.num
END AS num
FROM
FROM
(
SELECT
company.sequence_nbr,
company.parent_id,
company.biz_org_name,
company.biz_org_code,
company.biz_org_type
FROM
cb_org_usr company
WHERE
(company.biz_org_type = 'COMPANY' OR company.biz_org_type = 'DEPARTMENT')
AND company.is_delete = FALSE
<if test="companyId != null and companyId != ''">
AND biz_org_code LIKE CONCAT((SELECT biz_org_code FROM cb_org_usr WHERE sequence_nbr = #{companyId}),'%')
</if>
SELECT
company.sequence_nbr,
company.parent_id,
company.biz_org_name,
company.biz_org_code,
company.biz_org_type
FROM
cb_org_usr company
WHERE
(company.biz_org_type = 'COMPANY' OR company.biz_org_type = 'DEPARTMENT')
AND company.is_delete = FALSE
<if test="companyId != null and companyId != ''">
AND biz_org_code LIKE CONCAT((SELECT biz_org_code FROM cb_org_usr WHERE sequence_nbr = #{companyId}),'%')
</if>
) company_sur
LEFT JOIN (
LEFT JOIN (
SELECT
keysite.belong_id,
keysite.belong_id,
COUNT(keysite.belong_id) as num
FROM
cb_key_site keysite
cb_key_site keysite
WHERE
keysite.is_delete = FALSE
keysite.is_delete = FALSE
GROUP BY
keysite.belong_id
) keysite_sur ON company_sur.sequence_nbr = keysite_sur.belong_id
-- LEFT JOIN cb_dynamic_form_instance as cb ON company_sur.sequence_nbr = cb.instance_id where field_code = 'companyNature'
keysite.belong_id
) keysite_sur ON company_sur.sequence_nbr = keysite_sur.belong_id
-- LEFT JOIN cb_dynamic_form_instance as cb ON company_sur.sequence_nbr = cb.instance_id where field_code =
'companyNature'
</select>
</select>
<!--BUG2657 导出选中单位及子单位人员数据 by kongfm-->
<select id="exportPersonToExcelByParentId" resultType="com.yeejoin.amos.boot.module.common.api.dto.OrgUsrExcelDto">
select
a.biz_org_name bizOrgName,
(select c.biz_org_name from cb_org_usr c where c.sequence_nbr=a.parent_id) parentId,
b.*
from cb_org_usr a LEFT JOIN
(SELECT
instance_id,
max(case field_code when 'administrativePositionCode' then field_value_label end) administrativePositionCode,
max(case field_code when 'auditCycle' then field_value_label end) auditCycle,
max(case field_code when 'certificatesNumber' then field_value end) certificatesNumber,
max(case field_code when 'certificatesTypeCode' then field_value_label end) certificatesTypeCode,
max(case field_code when 'certificateType' then field_value_label end) certificateType,
max(case field_code when 'fireManagementPostCode' then field_value_label end) fireManagementPostCode,
max(case field_code when 'gender' then field_value_label end) gender,
max(case field_code when 'internalPositionCode' then field_value_label end) internalPositionCode,
max(case field_code when 'personNumber' then field_value end) personNumber,
max(case field_code when 'positionType' then field_value_label end) positionType,
max(case field_code when 'safetyTraining' then field_value_label end) safetyTraining,
max(case field_code when 'stateCode' then field_value_label end) stateCode,
max(case field_code when 'telephone' then field_value end) telephone
FROM cb_dynamic_form_instance GROUP BY instance_id) b
on b.instance_id=a.sequence_nbr where a.biz_org_name is not null and a.is_delete = 0
select
a.biz_org_name bizOrgName,
(select c.biz_org_name from cb_org_usr c where c.sequence_nbr=a.parent_id) parentId,
b.*
from cb_org_usr a LEFT JOIN
(SELECT
instance_id,
max(case field_code when 'administrativePositionCode' then field_value_label end) administrativePositionCode,
max(case field_code when 'auditCycle' then field_value_label end) auditCycle,
max(case field_code when 'certificatesNumber' then field_value end) certificatesNumber,
max(case field_code when 'certificatesTypeCode' then field_value_label end) certificatesTypeCode,
max(case field_code when 'certificateType' then field_value_label end) certificateType,
max(case field_code when 'fireManagementPostCode' then field_value_label end) fireManagementPostCode,
max(case field_code when 'gender' then field_value_label end) gender,
max(case field_code when 'internalPositionCode' then field_value_label end) internalPositionCode,
max(case field_code when 'personNumber' then field_value end) personNumber,
max(case field_code when 'positionType' then field_value_label end) positionType,
max(case field_code when 'safetyTraining' then field_value_label end) safetyTraining,
max(case field_code when 'stateCode' then field_value_label end) stateCode,
max(case field_code when 'telephone' then field_value end) telephone
FROM cb_dynamic_form_instance GROUP BY instance_id) b
on b.instance_id=a.sequence_nbr where a.biz_org_name is not null and a.is_delete = 0
and a.biz_org_type = "PERSON"
<if test="parentId != null and parentId != -1 ">
......@@ -866,72 +864,67 @@ GROUP BY
</select>
<select id="amosIdExist" resultType="int">
SELECT
count(*) AS num
FROM cb_org_usr
WHERE
amos_org_id = #{amosId}
<if test="orgUsrId != null ">
and sequence_nbr != #{orgUsrId}
</if>
and is_delete = 0
SELECT
count(*) AS num
FROM cb_org_usr
WHERE
amos_org_id = #{amosId}
<if test="orgUsrId != null ">
and sequence_nbr != #{orgUsrId}
</if>
and is_delete = 0
</select>
<select id="amosIdExistTeam" resultType="int">
SELECT count(*) AS num FROM cb_firefighters WHERE amos_user_id = #{amosId} and is_delete = 0;
SELECT count(*) AS num
FROM cb_firefighters
WHERE amos_user_id = #{amosId}
and is_delete = 0;
</select>
<update id="updatelistByParentId">
UPDATE cb_org_usr
SET biz_org_code=replace(biz_org_code,#{code},#{codex})
WHERE biz_org_code like concat(#{code}, '%');
UPDATE cb_org_usr
SET biz_org_code=replace(biz_org_code, #{code}, #{codex})
WHERE biz_org_code like concat(#{code}, '%');
</update>
<update id="updatePersonStatus">
update cb_org_usr set person_status = #{status} where sequence_nbr = #{id}
update cb_org_usr
set person_status = #{status}
where sequence_nbr = #{id}
</update>
<select id ='getPersonSimpleDetail' resultType='Map'>
SELECT
person.biz_org_name as name,
cdf.field_value as phone
FROM
(
SELECT
sequence_nbr,
biz_org_name
FROM
cb_org_usr
WHERE
biz_org_type = 'PERSON'
AND is_delete = 0
) person
LEFT JOIN (
SELECT
field_value,
instance_id
FROM
cb_dynamic_form_instance
WHERE
group_code = '246'
AND field_code = 'telephone'
) cdf ON person.sequence_nbr = cdf.instance_id
</select>
<select id='getPersonSimpleDetail' resultType='Map'>
SELECT person.biz_org_name as name,
cdf.field_value as phone
FROM (
SELECT sequence_nbr,
biz_org_name
FROM cb_org_usr
WHERE biz_org_type = 'PERSON'
AND is_delete = 0
) person
LEFT JOIN (
SELECT field_value,
instance_id
FROM cb_dynamic_form_instance
WHERE group_code = '246'
AND field_code = 'telephone'
) cdf ON person.sequence_nbr = cdf.instance_id
</select>
<select id="countDeptByCompanyId" resultType="java.util.Map">
SELECT (SELECT count(1)
FROM cb_org_usr
WHERE biz_org_code LIKE concat(t1.biz_org_code, '%')
AND biz_org_type = 'DEPARTMENT'
AND parent_id = t1.sequence_nbr and is_delete = 0 ) count,
sequence_nbr
FROM cb_org_usr
WHERE biz_org_code LIKE concat(t1.biz_org_code, '%')
AND biz_org_type = 'DEPARTMENT'
AND parent_id = t1.sequence_nbr and is_delete = 0 ) count,
sequence_nbr
FROM cb_org_usr t1
WHERE sequence_nbr IN
<foreach collection ='companyIdList' item='companyId' index='index' open="(" close= ")" separator=",">
<foreach collection='companyIdList' item='companyId' index='index' open="(" close=")" separator=",">
#{companyId}
</foreach>
</select>
......@@ -939,32 +932,49 @@ LEFT JOIN (
<select id="queryCompanyId" resultType="map">
select d.*,cbo.biz_org_name companyName from (
select cou.biz_org_name bizOrgName,cou.sequence_nbr sequenceNbr ,cou .parent_id parentId,
a.fireManagementPostCode, b.telephone,cou.amos_org_id amosUserId from ( select * from cb_org_usr cou where is_delete = 0 ) cou
a.fireManagementPostCode, b.telephone,cou.amos_org_id amosUserId from ( select * from cb_org_usr cou where
is_delete = 0 ) cou
left join (select i.instance_id id1 ,if(i.field_code = 'fireManagementPostCode',
i.field_value, null) as 'fireManagementPostCode' from cb_dynamic_form_instance i where i.field_code = 'fireManagementPostCode'
and i.field_value_label is not null) a on cou .sequence_nbr = a.id1
i.field_value, null) as 'fireManagementPostCode' from cb_dynamic_form_instance i where i.field_code =
'fireManagementPostCode'
and i.field_value_label is not null) a on cou .sequence_nbr = a.id1
left join (select i.instance_id id2,if(i.field_code = 'telephone',
i.field_value, null) as 'telephone' from cb_dynamic_form_instance i where i.field_code = 'telephone'
and i.field_value is not null) b on cou .sequence_nbr = b.id2
) d left join cb_org_usr cbo on cbo.sequence_nbr = d.parentId where d.parentId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})
i.field_value, null) as 'telephone' from cb_dynamic_form_instance i where i.field_code = 'telephone'
and i.field_value is not null) b on cou .sequence_nbr = b.id2
) d left join cb_org_usr cbo on cbo.sequence_nbr = d.parentId where d.parentId in (select sequence_nbr from
cb_org_usr cou where biz_org_name = #{bizOrgName})
and (d.fireManagementPostCode in
<foreach item="item" index="index" collection="codes" open="(" separator="," close=")">
<foreach item="item" index="index" collection="codes" open="(" separator="," close=")">
#{item}
</foreach>
)
</select>
<select id="queryCompanyIdNew" resultType="map">
select d.*,cbo.biz_org_name companyName from (
select cou.biz_org_name bizOrgName,cou.sequence_nbr sequenceNbr ,cou .parent_id parentId,
a.administrativePositionCode, b.telephone, cou.amos_org_id amosUserId from ( select * from cb_org_usr cou where is_delete = 0 ) cou
left join (select i.instance_id id1 ,if(i.field_code = 'administrativePositionCode',
i.field_value_label, null) as 'administrativePositionCode' from cb_dynamic_form_instance i where i.field_code = 'administrativePositionCode'
and i.field_value_label is not null) a on cou .sequence_nbr = a.id1
inner join (select i.instance_id id2,if(i.field_code = 'telephone',
i.field_value, null) as 'telephone' from cb_dynamic_form_instance i where i.field_code = 'telephone'
and i.field_value is not null) b on cou .sequence_nbr = b.id2
) d left join cb_org_usr cbo on cbo.sequence_nbr = d.parentId where d.parentId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})
select d.*, cbo.biz_org_name companyName
from (
select cou.biz_org_name bizOrgName,
cou.sequence_nbr sequenceNbr,
cou.parent_id parentId,
a.administrativePositionCode,
b.telephone,
cou.amos_org_id amosUserId
from (select * from cb_org_usr cou where is_delete = 0) cou
left join (select i.instance_id id1,
if(i.field_code = 'administrativePositionCode',
i.field_value_label, null) as 'administrativePositionCode'
from cb_dynamic_form_instance i
where i.field_code = 'administrativePositionCode'
and i.field_value_label is not null) a on cou.sequence_nbr = a.id1
inner join (select i.instance_id id2,
if(i.field_code = 'telephone',
i.field_value, null) as 'telephone'
from cb_dynamic_form_instance i
where i.field_code = 'telephone'
and i.field_value is not null) b on cou.sequence_nbr = b.id2
) d
left join cb_org_usr cbo on cbo.sequence_nbr = d.parentId
where d.parentId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})
</select>
......@@ -988,9 +998,9 @@ LEFT JOIN (
</select>
<select id="companyTreeByUserAndType" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
*
*
FROM
cb_org_usr usr
cb_org_usr usr
<where>
usr.is_delete = false
<choose>
......@@ -1008,59 +1018,59 @@ LEFT JOIN (
</where>
</select>
<select id="equipCompanyExport" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
*
FROM
cb_org_usr
WHERE is_delete = false AND biz_org_code LIKE CONCAT(#{bizOrgCode}, '%') AND( biz_org_type = 'COMPANY' || biz_org_type = 'DEPARTMENT')
SELECT *
FROM cb_org_usr
WHERE is_delete = false
AND biz_org_code LIKE CONCAT(#{bizOrgCode}, '%')
AND (biz_org_type = 'COMPANY' || biz_org_type = 'DEPARTMENT')
</select>
<select id="companyDeptListWithPersonCount"
resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
usr.*,
(select count(1) from cb_org_usr u where u.biz_org_type = 'PERSON' and u.is_delete = false and u.biz_org_code like CONCAT(usr.biz_org_code,'%')) as total
FROM
cb_org_usr usr
where
(usr.biz_org_type = 'COMPANY' OR usr.biz_org_type = 'DEPARTMENT')
and usr.is_delete = false
SELECT usr.*,
(select count(1)
from cb_org_usr u
where u.biz_org_type = 'PERSON'
and u.is_delete = false
and u.biz_org_code like CONCAT(usr.biz_org_code, '%')) as total
FROM cb_org_usr usr
where (usr.biz_org_type = 'COMPANY' OR usr.biz_org_type = 'DEPARTMENT')
and usr.is_delete = false
</select>
<select id="companyDeptListWithPersonCountNew"
resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
usr.*,
(select count(1) from cb_org_usr u where u.biz_org_type = 'PERSON' and u.is_delete = false and u.biz_org_code like CONCAT(usr.biz_org_code,'%')) as total
FROM
cb_org_usr usr
where
(usr.biz_org_type = 'COMPANY' OR usr.biz_org_type = 'DEPARTMENT') and usr.biz_org_code like concat (#{bizOrgCode},'%')
SELECT usr.*,
(select count(1)
from cb_org_usr u
where u.biz_org_type = 'PERSON'
and u.is_delete = false
and u.biz_org_code like CONCAT(usr.biz_org_code, '%')) as total
FROM cb_org_usr usr
where (usr.biz_org_type = 'COMPANY' OR usr.biz_org_type = 'DEPARTMENT')
and usr.biz_org_code like concat(#{bizOrgCode}, '%')
and usr.is_delete = false
</select>
<select id="companyTreeByUser"
resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
usr.*
FROM
cb_org_usr usr
where
(usr.biz_org_type = 'COMPANY' OR usr.biz_org_type = 'DEPARTMENT')
SELECT usr.*
FROM cb_org_usr usr
where (usr.biz_org_type = 'COMPANY' OR usr.biz_org_type = 'DEPARTMENT')
and usr.is_delete = false
and usr.biz_org_code like CONCAT(#{bizOrgCode},'%')
and usr.biz_org_code like CONCAT(#{bizOrgCode}, '%')
</select>
<select id="listByOrgTypes" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
select
*
*
from
cb_org_usr usr
cb_org_usr usr
where
usr.is_delete = false
<if test="orgTypeList != null and orgTypeList.size > 0 ">
and usr.biz_org_type in
and usr.biz_org_type in
<foreach collection="orgTypeList" item="bizOrgType" open="(" close=")" separator=",">
#{bizOrgType}
</foreach>
......@@ -1069,19 +1079,24 @@ LEFT JOIN (
</select>
<select id="selectPersonone" resultType="Map">
select group_concat( CONCAT( u.biz_org_name,' ',
IFNULL((select c.field_value from cb_dynamic_form_instance c where field_code='telephone' and c.instance_id=u.sequence_nbr),"")
)) name
from cb_org_usr u LEFT JOIN
cb_dynamic_form_instance g on g.instance_id=u.sequence_nbr
where u.biz_org_type='PERSON' and g.field_code='fireManagementPostCode' and g.field_value_label =#{name} and u.parent_id=#{id}
select group_concat(CONCAT(u.biz_org_name, ' ',
IFNULL((select c.field_value
from cb_dynamic_form_instance c
where field_code = 'telephone' and c.instance_id = u.sequence_nbr), "")
)) name
from cb_org_usr u
LEFT JOIN
cb_dynamic_form_instance g on g.instance_id = u.sequence_nbr
where u.biz_org_type = 'PERSON'
and g.field_code = 'fireManagementPostCode'
and g.field_value_label = #{name}
and u.parent_id = #{id}
</select>
</select>
<select id="getParentList" resultType="java.lang.String">
select getParentList(#{id}) as id;
select getParentList(#{id}) as id;
</select>
<select id="selectPersonListByCompanyIdList"
resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
......@@ -1099,36 +1114,38 @@ LEFT JOIN (
<select id="getManagePerson" resultType="Map">
SELECT
group_concat(
DISTINCT
CONCAT(
u.biz_org_name,
' ',
IFNULL(( SELECT c.field_value FROM cb_dynamic_form_instance c WHERE field_code = 'telephone' AND c.instance_id = u.sequence_nbr ), "" )
)) uname
DISTINCT
CONCAT(
u.biz_org_name,
' ',
IFNULL(( SELECT c.field_value FROM cb_dynamic_form_instance c WHERE field_code = 'telephone' AND c.instance_id =
u.sequence_nbr ), "" )
)) uname
FROM
cb_org_usr u
LEFT JOIN cb_dynamic_form_instance g ON g.instance_id = u.sequence_nbr
LEFT JOIN cb_firefighters_post p ON p.org_usr_id = u.sequence_nbr
cb_org_usr u
LEFT JOIN cb_dynamic_form_instance g ON g.instance_id = u.sequence_nbr
LEFT JOIN cb_firefighters_post p ON p.org_usr_id = u.sequence_nbr
WHERE
u.biz_org_type = 'PERSON'
AND p.fire_management_post like CONCAT('%',#{name},'%')
AND u.sequence_nbr in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>;
u.biz_org_type = 'PERSON'
AND p.fire_management_post like CONCAT('%',#{name},'%')
AND u.sequence_nbr in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>;
</select>
<select id="checkCertificatesNumber" resultType="com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance">
<select id="checkCertificatesNumber"
resultType="com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance">
SELECT
*
*
FROM
cb_dynamic_form_instance cdf
LEFT JOIN cb_org_usr cou ON cdf.instance_id = cou.sequence_nbr
cb_dynamic_form_instance cdf
LEFT JOIN cb_org_usr cou ON cdf.instance_id = cou.sequence_nbr
WHERE
cdf.field_code = 'certificatesNumber' AND cdf.field_value = #{certificatesNumber}
cdf.field_code = 'certificatesNumber' AND cdf.field_value = #{certificatesNumber}
<if test="orgUserId != null">
AND cdf.instance_id <![CDATA[<>]]> #{orgUserId}
</if>
AND cou.is_delete = 0
AND cou.is_delete = 0
</select>
<select id="queryByCompanyCode" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
......@@ -1187,21 +1204,26 @@ LEFT JOIN (
cfp.fire_management_post,
cft.type_code,
cf.certificate_number certificatesNumber,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'personNumber' AND dfi.instance_id = u.sequence_nbr ) AS employee_number,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'telephone' AND dfi.instance_id = u.sequence_nbr ) AS telephone,
( CASE WHEN cfp.post_qualification IS NULL or cfp.post_qualification = '' THEN 0 ELSE 1 END ) AS is_certificate,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'personNumber' AND dfi.instance_id
= u.sequence_nbr ) AS employee_number,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'telephone' AND dfi.instance_id =
u.sequence_nbr ) AS telephone,
( CASE WHEN cfp.post_qualification IS NULL or cfp.post_qualification = '' THEN 0 ELSE 1 END ) AS is_certificate,
IF
(
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'peopleType' AND dfi.instance_id = u.sequence_nbr ) = 1601,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'peopleType' AND dfi.instance_id =
u.sequence_nbr ) = 1601,
1,
IF
(
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'peopleType' AND dfi.instance_id = u.sequence_nbr ) = 1602,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'peopleType' AND dfi.instance_id =
u.sequence_nbr ) = 1602,
0,
2
)
) AS is_firefighters,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'personImg' AND dfi.instance_id = u.sequence_nbr ) AS personImg,
( SELECT field_value FROM cb_dynamic_form_instance dfi WHERE dfi.field_code = 'personImg' AND dfi.instance_id =
u.sequence_nbr ) AS personImg,
cfp.job_title
FROM
cb_org_usr u
......@@ -1218,100 +1240,88 @@ LEFT JOIN (
</select>
<select id="companyTreeByUserToPatrolRoute" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
usr.*,
(select count(1) from cb_org_usr u where u.biz_org_type = 'PERSON' and u.is_delete = false and u.biz_org_code like CONCAT(usr.biz_org_code,'%')) as total
FROM
cb_org_usr usr
where
(usr.biz_org_type = 'COMPANY' OR usr.biz_org_type = 'DEPARTMENT') and usr.biz_org_code like concat (#{bizOrgCode},'%')
SELECT usr.*,
(select count(1)
from cb_org_usr u
where u.biz_org_type = 'PERSON'
and u.is_delete = false
and u.biz_org_code like CONCAT(usr.biz_org_code, '%')) as total
FROM cb_org_usr usr
where (usr.biz_org_type = 'COMPANY' OR usr.biz_org_type = 'DEPARTMENT')
and usr.biz_org_code like concat(#{bizOrgCode}, '%')
and usr.is_delete = false
</select>
<select id="companyUserTreeByUserAndType"
resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
usr.*
FROM
cb_org_usr usr
where
usr.is_delete = false
and usr.biz_org_code like CONCAT(#{bizOrgCode},'%')
SELECT usr.*
FROM cb_org_usr usr
where usr.is_delete = false
and usr.biz_org_code like CONCAT(#{bizOrgCode}, '%')
</select>
<select id="companyUserTreeByUserAndTypeALL"
resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
usr.*
FROM
cb_org_usr usr
where
usr.is_delete = false
and usr.biz_org_code like CONCAT(#{bizorgcode},'%')
GROUP BY biz_org_name
SELECT usr.*
FROM cb_org_usr usr
where usr.is_delete = false
and usr.biz_org_code like CONCAT(#{bizorgcode}, '%')
GROUP BY biz_org_name
</select>
<select id="getUserByPeopleTypeCount" resultType="Integer">
select
count(*)
from (
SELECT
DISTINCT
u.sequence_nbr sequenceNbr,
u.biz_org_name bizOrgName,
g.telephone,
g.positionType
FROM
cb_org_usr u
LEFT JOIN
( SELECT
v.`instance_id`,
max(case v.field_code when 'telephone' then IFNULL(v.field_value,'') end) telephone,
max(case v.field_code when 'positionType' then IFNULL(v.field_value_label,'') end) positionType,
max(case v.field_code when 'peopleType' then IFNULL(v.field_value,'') end) peopleType
FROM
`cb_dynamic_form_instance` v
WHERE
v.group_code = 246
GROUP BY
v.`instance_id`
) g
on u.sequence_nbr = g.instance_id
where
u.biz_org_type = 'person'
AND
u.is_delete = 0
and g.peopleType=1601
GROUP BY
u.sequence_nbr
order by u.rec_date desc
)a where a.sequenceNbr is not null
select count(*)
from (
SELECT DISTINCT u.sequence_nbr sequenceNbr,
u.biz_org_name bizOrgName,
g.telephone,
g.positionType
FROM cb_org_usr u
LEFT JOIN
(SELECT v.`instance_id`,
max(case v.field_code when 'telephone' then IFNULL(v.field_value, '') end) telephone,
max(case v.field_code
when 'positionType' then IFNULL(v.field_value_label, '') end) positionType,
max(case v.field_code when 'peopleType' then IFNULL(v.field_value, '') end) peopleType
FROM `cb_dynamic_form_instance` v
WHERE v.group_code = 246
GROUP BY v.`instance_id`
) g
on u.sequence_nbr = g.instance_id
where u.biz_org_type = 'person'
AND u.is_delete = 0
and g.peopleType = 1601
GROUP BY u.sequence_nbr
order by u.rec_date desc
) a
where a.sequenceNbr is not null
</select>
<select id="getUserByPeopleType" resultType="Map">
SET @rownum = #{map.pageNum};
select
@rownum := @rownum + 1 AS rownum,
a.* from (
SET
@rownum =
#{map.pageNum};
select @rownum := @rownum + 1 AS rownum,
a.*
from (
SELECT
DISTINCT
u.sequence_nbr sequenceNbr,
u.biz_org_name bizOrgName,
g.telephone,
g.positionType
g.positionType
FROM
cb_org_usr u
LEFT JOIN
( SELECT
( SELECT
v.`instance_id`,
max(case v.field_code when 'telephone' then IFNULL(v.field_value,'') end) telephone,
max(case v.field_code when 'positionType' then IFNULL(v.field_value_label,'') end) positionType,
max(case v.field_code when 'peopleType' then IFNULL(v.field_value,'') end) peopleType
max (case v.field_code when 'telephone' then IFNULL(v.field_value, '') end) telephone,
max (case v.field_code when 'positionType' then IFNULL(v.field_value_label, '') end) positionType,
max (case v.field_code when 'peopleType' then IFNULL(v.field_value, '') end) peopleType
FROM
`cb_dynamic_form_instance` v
WHERE
......@@ -1324,16 +1334,20 @@ LEFT JOIN (
u.biz_org_type = 'person'
AND
u.is_delete = 0
and g.peopleType=1601
GROUP BY
and g.peopleType=1601
GROUP BY
u.sequence_nbr
order by u.rec_date desc
)a where a.sequenceNbr is not null
LIMIT #{map.pageNum}, #{map.pageSize}
) a
where a.sequenceNbr is not null
LIMIT #{map.pageNum}
, #{map.pageSize}
</select>
<select id="selectStaticFire" resultType="java.util.Map">
SELECT count( postName ) as num,( count( postName )/( SELECT count(*) AS count FROM cb_org_usr a WHERE is_delete = 0 AND biz_org_type = 'PERSON'
AND biz_org_code like concat(#{bizOrgCode}, '%')
SELECT count(postName) as num,
(count(postName) /
(SELECT count(*) AS count FROM cb_org_usr a WHERE is_delete = 0 AND biz_org_type = 'PERSON'
AND biz_org_code like concat( #{bizOrgCode} , '%')
))* 100 AS percent, postName
FROM
(
......@@ -1350,12 +1364,12 @@ LEFT JOIN (
LEFT JOIN (
SELECT
v.`instance_id`,
max( CASE v.field_code WHEN 'fireManagementPostCode' THEN IFNULL( v.field_value_label, v.field_value ) END ) fireManagementPostCode,
max( CASE v.field_code WHEN 'fireManagementPostCode' THEN v.field_value END ) fireManagementPost,
max( CASE v.field_code WHEN 'fireManagementPostCode' THEN v.field_value_label END ) fireManagementPostName,
max( CASE v.field_code WHEN 'positionType' THEN IFNULL( v.field_value, v.field_value_label ) END ) positionType,
max( CASE v.field_code WHEN 'positionType' THEN v.field_value_label END ) positionTypeName,
max( CASE v.field_code WHEN 'peopleType' THEN v.field_value END ) peopleType
max ( CASE v.field_code WHEN 'fireManagementPostCode' THEN IFNULL( v.field_value_label, v.field_value ) END ) fireManagementPostCode,
max ( CASE v.field_code WHEN 'fireManagementPostCode' THEN v.field_value END ) fireManagementPost,
max ( CASE v.field_code WHEN 'fireManagementPostCode' THEN v.field_value_label END ) fireManagementPostName,
max ( CASE v.field_code WHEN 'positionType' THEN IFNULL( v.field_value, v.field_value_label ) END ) positionType,
max ( CASE v.field_code WHEN 'positionType' THEN v.field_value_label END ) positionTypeName,
max ( CASE v.field_code WHEN 'peopleType' THEN v.field_value END ) peopleType
FROM
`cb_dynamic_form_instance` v
WHERE
......@@ -1383,8 +1397,10 @@ LEFT JOIN (
postName
</select>
<select id="selectStaticYw" resultType="java.util.Map">
SELECT count( postName ) as num, (count( postName )/( SELECT count(*) AS count FROM cb_org_usr a WHERE is_delete = 0 AND biz_org_type = 'PERSON'
AND biz_org_code like concat(#{bizOrgCode}, '%')
SELECT count(postName) as num,
(count(postName) /
(SELECT count(*) AS count FROM cb_org_usr a WHERE is_delete = 0 AND biz_org_type = 'PERSON'
AND biz_org_code like concat( #{bizOrgCode} , '%')
))* 100 AS percent, postName
FROM
(
......@@ -1401,9 +1417,9 @@ LEFT JOIN (
LEFT JOIN (
SELECT
v.`instance_id`,
max( CASE v.field_code WHEN 'positionType' THEN v.field_value END ) positionType,
max( CASE v.field_code WHEN 'positionType' THEN v.field_value_label END ) positionTypeName,
max( CASE v.field_code WHEN 'peopleType' THEN v.field_value END ) peopleType
max ( CASE v.field_code WHEN 'positionType' THEN v.field_value END ) positionType,
max ( CASE v.field_code WHEN 'positionType' THEN v.field_value_label END ) positionTypeName,
max ( CASE v.field_code WHEN 'peopleType' THEN v.field_value END ) peopleType
FROM
`cb_dynamic_form_instance` v
WHERE
......@@ -1432,42 +1448,38 @@ LEFT JOIN (
</select>
<select id="getPersonType" resultType="Map">
SELECT
dfi.field_value_label AS peopleType
FROM
cb_org_usr u
LEFT JOIN cb_dynamic_form_instance dfi ON dfi.instance_id = u.sequence_nbr
WHERE
u.is_delete = FALSE
SELECT dfi.field_value_label AS peopleType
FROM cb_org_usr u
LEFT JOIN cb_dynamic_form_instance dfi ON dfi.instance_id = u.sequence_nbr
WHERE u.is_delete = FALSE
AND u.amos_org_id IS NOT NULL
AND dfi.field_value = #{typeCode}
AND dfi.field_code = 'peopleType'
limit 1
AND dfi.field_code = 'peopleType' limit 1
</select>
<select id="reportResult" resultType="java.util.Map">
SELECT
*
FROM
(
SELECT
*
FROM
(
SELECT
person.biz_org_name AS NAME,
person.biz_org_code AS bizOrgCode,
person.parent_id AS parentId,
cdf.field_value AS peopleType
FROM
( SELECT sequence_nbr, biz_org_name, biz_org_code, parent_id FROM cb_org_usr WHERE biz_org_type = 'PERSON' AND is_delete = 0 AND biz_org_code LIKE concat(#{bizOrgCode}, '%')
AND rec_date >= #{startTime} AND #{endTime} >= rec_date ) person
LEFT JOIN ( SELECT field_value, instance_id FROM cb_dynamic_form_instance WHERE group_code = '246' AND field_code = 'peopleType' ) cdf ON person.sequence_nbr = cdf.instance_id
) AS a
WHERE
a.peopleType IS NOT NULL
AND a.peopleType = '1601'
) AS a
GROUP BY
parentId
SELECT *
FROM (
SELECT *
FROM (
SELECT person.biz_org_name AS NAME,
person.biz_org_code AS bizOrgCode,
person.parent_id AS parentId,
cdf.field_value AS peopleType
FROM (SELECT sequence_nbr, biz_org_name, biz_org_code, parent_id
FROM cb_org_usr
WHERE biz_org_type = 'PERSON'
AND is_delete = 0
AND biz_org_code LIKE concat(#{bizOrgCode}, '%')
AND rec_date >= #{startTime}
AND #{endTime} >= rec_date) person
LEFT JOIN (SELECT field_value, instance_id
FROM cb_dynamic_form_instance
WHERE group_code = '246' AND field_code = 'peopleType') cdf
ON person.sequence_nbr = cdf.instance_id
) AS a
WHERE a.peopleType IS NOT NULL
AND a.peopleType = '1601'
) AS a
GROUP BY parentId
</select>
</mapper>
......@@ -22,12 +22,13 @@ import java.util.Properties;
@Intercepts({
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class, CacheKey.class, BoundSql.class}),
}
}
)
public class PluginInterceptor implements Interceptor {
/**
* 进行拦截的时候要执行的方法
*
* @param invocation
* @return
* @throws Throwable
......@@ -54,17 +55,17 @@ public class PluginInterceptor implements Interceptor {
cacheKey = (CacheKey) args[4];
boundSql = (BoundSql) args[5];
}
//id为执行的mapper方法的全路径名,如com.metro.dao.UserMapper.insertUser
//id为执行的mapper方法的全路径名,如com.metro.dao.UserMapper.insertUser
String id = mappedStatement.getId();
//获取到原始sql语句
String sql = boundSql.getSql();
if("com.yeejoin.equipmanage.mapper.FormInstanceMapper.queryForMapList".equals(id)) {
if ("com.yeejoin.equipmanage.mapper.FormInstanceMapper.queryForMapList".equals(id)) {
//执行结果
HashMap<String,String> par = new LinkedHashMap<>();
if(parameter instanceof HashMap) {
par = (HashMap<String, String>)((HashMap<?, ?>) parameter).get("params");
HashMap<String, String> par = new LinkedHashMap<>();
if (parameter instanceof HashMap) {
par = (HashMap<String, String>) ((HashMap<?, ?>) parameter).get("params");
}
......@@ -72,7 +73,7 @@ public class PluginInterceptor implements Interceptor {
while (iterator.hasNext()) {
String next = iterator.next();
sql = sql.replace("item",next);
sql = sql.replace("item", next);
}
//通过反射修改sql语句
......
......@@ -6,58 +6,57 @@
<result column="fieldValue" property="fieldValue"/>
<result column="groupType" property="groupType"/>
</resultMap>
<!-- <select id="queryInstancePage" resultType="map">-->
<!-- select-->
<!-- d.*-->
<!-- from-->
<!-- (-->
<!-- select-->
<!-- i.INSTANCE_ID instanceId,-->
<!-- i.GROUP_CODE groupCode,-->
<!-- <foreach collection="fieldNames" item="value" index="key" separator=",">-->
<!-- MAX(CASE WHEN i.FIELD_NAME = #{key} THEN i.FIELD_VALUE END) as #{key}-->
<!-- </foreach>-->
<!-- from-->
<!-- wl_form_instance i-->
<!-- where i.GROUP_CODE = #{groupCode}-->
<!-- GROUP by-->
<!-- i.INSTANCE_ID)d-->
<!-- <if test="params != null and params.size() > 0">-->
<!-- where-->
<!-- 1=1-->
<!-- <foreach collection="params" index="key" item="value" separator="">-->
<!-- <choose>-->
<!-- <when test="fieldNames[key] == 'like' and value !=null and value !=''">-->
<!-- and d.item like concat('%',#{value},'%')-->
<!-- </when>-->
<!-- <when test="fieldNames[key] == 'eq' and value !=null and value !=''">-->
<!-- and d.item = #{value}-->
<!-- </when>-->
<!-- </choose>-->
<!-- </foreach>-->
<!-- </if>-->
<!-- order by instanceId desc-->
<!-- </select>-->
<!-- <select id="queryInstancePage" resultType="map">-->
<!-- select-->
<!-- d.*-->
<!-- from-->
<!-- (-->
<!-- select-->
<!-- i.INSTANCE_ID instanceId,-->
<!-- i.GROUP_CODE groupCode,-->
<!-- <foreach collection="fieldNames" item="value" index="key" separator=",">-->
<!-- MAX(CASE WHEN i.FIELD_NAME = #{key} THEN i.FIELD_VALUE END) as #{key}-->
<!-- </foreach>-->
<!-- from-->
<!-- wl_form_instance i-->
<!-- where i.GROUP_CODE = #{groupCode}-->
<!-- GROUP by-->
<!-- i.INSTANCE_ID)d-->
<!-- <if test="params != null and params.size() > 0">-->
<!-- where-->
<!-- 1=1-->
<!-- <foreach collection="params" index="key" item="value" separator="">-->
<!-- <choose>-->
<!-- <when test="fieldNames[key] == 'like' and value !=null and value !=''">-->
<!-- and d.item like concat('%',#{value},'%')-->
<!-- </when>-->
<!-- <when test="fieldNames[key] == 'eq' and value !=null and value !=''">-->
<!-- and d.item = #{value}-->
<!-- </when>-->
<!-- </choose>-->
<!-- </foreach>-->
<!-- </if>-->
<!-- order by instanceId desc-->
<!-- </select>-->
<select id="getChildListdate" resultType="map">
SELECT getChildListdate ( #{id} ) ids
SELECT getChildListdate(#{id}) ids
</select>
<update id="updateListChild" >
<update id="updateListChild">
UPDATE wl_form_instance set field_value =#{value}
UPDATE wl_form_instance set field_value =#{value}
where wl_form_instance.group_type in('building','room','floor')
<if test ="ids != null and ids.size()>0">
and wl_form_instance.instance_id in
<foreach collection="ids" index="index" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
<if test="ids != null and ids.size()>0">
and wl_form_instance.instance_id in
<foreach collection="ids" index="index" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
and wl_form_instance.field_name=#{fieldName}
and wl_form_instance.field_name=#{fieldName}
</update>
<select id="queryForMapList" resultType="map">
select
d.*
......@@ -272,54 +271,38 @@
sa.instanceId DESC
</select>
<select id="findDetailByInstanceId" resultType="java.util.LinkedHashMap">
SELECT
a.field_label AS `key`,
a.field_value AS `value`
FROM
`wl_form_instance` a
WHERE
a.instance_id = #{instanceId}
AND
a.field_label != '父级id'
SELECT a.field_label AS `key`,
a.field_value AS `value`
FROM `wl_form_instance` a
WHERE a.instance_id = #{instanceId}
AND a.field_label != '父级id'
ORDER BY a.group_column_id
</select>
<select id="findByInstanceId" resultType="java.util.LinkedHashMap">
SELECT
fi.NAME AS '建筑名称',
fi.dutyUser AS '负责人',
fi.buildType AS '建筑结构',
fi.dutyUserPhone AS '负责人电话',
fi.buildUseType AS '使用性质',
fi.structureType AS '结构类型',
fi.address AS '详细地址'
FROM
(
SELECT
a.instance_id,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS NAME,
MAX( CASE WHEN a.field_name = 'dutyUser' THEN a.field_value END ) AS dutyUser,
MAX( CASE WHEN a.field_name = 'buildType' THEN a.field_value END ) AS buildType,
MAX( CASE WHEN a.field_name = 'dutyUserPhone' THEN a.field_value END ) AS dutyUserPhone,
MAX( CASE WHEN a.field_name = 'buildUseType' THEN a.field_value END ) AS buildUseType,
MAX( CASE WHEN a.field_name = 'structureType' THEN a.field_value END ) AS structureType,
MAX( CASE WHEN a.field_name = 'address' THEN a.field_value END ) AS address
FROM
`wl_form_instance` a
WHERE
a.instance_id = #{instanceId}
GROUP BY
a.instance_id
) fi
SELECT fi.NAME AS '建筑名称', fi.dutyUser AS '负责人', fi.buildType AS '建筑结构', fi.dutyUserPhone AS '负责人电话', fi.buildUseType AS '使用性质', fi.structureType AS '结构类型', fi.address AS '详细地址'
FROM (
SELECT a.instance_id,
MAX(CASE WHEN a.field_name = 'name' THEN a.field_value END) AS NAME,
MAX(CASE WHEN a.field_name = 'dutyUser' THEN a.field_value END) AS dutyUser,
MAX(CASE WHEN a.field_name = 'buildType' THEN a.field_value END) AS buildType,
MAX(CASE WHEN a.field_name = 'dutyUserPhone' THEN a.field_value END) AS dutyUserPhone,
MAX(CASE WHEN a.field_name = 'buildUseType' THEN a.field_value END) AS buildUseType,
MAX(CASE WHEN a.field_name = 'structureType' THEN a.field_value END) AS structureType,
MAX(CASE WHEN a.field_name = 'address' THEN a.field_value END) AS address
FROM `wl_form_instance` a
WHERE a.instance_id = #{instanceId}
GROUP BY a.instance_id
) fi
</select>
<select id="getFormInstanceById" resultType="java.util.Map">
SELECT
a.instance_id AS instanceId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS `name`,
MAX( CASE WHEN a.field_name = 'code' THEN a.field_value END ) AS `code`,
MAX( CASE WHEN a.field_name = 'address' THEN a.field_value END ) AS address,
MAX( CASE WHEN a.field_name = 'riskPointId' THEN a.field_value END ) AS riskSourceId
a.instance_id AS instanceId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS `name`,
MAX( CASE WHEN a.field_name = 'code' THEN a.field_value END ) AS `code`,
MAX( CASE WHEN a.field_name = 'address' THEN a.field_value END ) AS address,
MAX( CASE WHEN a.field_name = 'riskPointId' THEN a.field_value END ) AS riskSourceId
FROM
`wl_form_instance` a
`wl_form_instance` a
<where>
<if test="instanceId != null">
a.instance_id = #{instanceId}
......@@ -328,45 +311,46 @@
</select>
<!-- 消防建筑视屏监控统计树 -->
<select id="getBuildVideoListCount" resultType="hashmap">
SELECT * FROM(
SELECT * FROM(
SELECT
sa.*,
b.total
FROM
(
SELECT
sa.*,
b.total
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
MAX( CASE WHEN a.field_name = 'parentId' THEN a.field_value END ) AS parentId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS instanceName,
MAX( CASE WHEN a.field_name = 'biz_org_code' THEN a.field_value END ) AS bizOrgCode
FROM
(
SELECT
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
MAX( CASE WHEN a.field_name = 'parentId' THEN a.field_value END ) AS parentId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS instanceName,
MAX( CASE WHEN a.field_name = 'biz_org_code' THEN a.field_value END ) AS bizOrgCode
FROM
`wl_form_instance` a
GROUP BY
a.instance_id
) sa
LEFT JOIN ( SELECT wlv.source_id, count( wlv.source_id ) AS total FROM `wl_video_source` wlv GROUP BY wlv.source_id ) b ON b.source_id = sa.instanceId
union all
select
123456789123456789 as instanceId,
'else' as groupCode,
'else' as groupType,
0 as parentId,
'其他' as instanceName,
NULL AS bizOrgCode,
count(1) as total
from
wl_video where id not in (select video_id from wl_video_source)
) tmp
<where>
<if test="list != null and list.size() >0">
AND tmp.bizOrgCode IN
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
`wl_form_instance` a
GROUP BY
a.instance_id
) sa
LEFT JOIN ( SELECT wlv.source_id, count( wlv.source_id ) AS total FROM `wl_video_source` wlv GROUP BY
wlv.source_id ) b ON b.source_id = sa.instanceId
union all
select
123456789123456789 as instanceId,
'else' as groupCode,
'else' as groupType,
0 as parentId,
'其他' as instanceName,
NULL AS bizOrgCode,
count(1) as total
from
wl_video where id not in (select video_id from wl_video_source)
) tmp
<where>
<if test="list != null and list.size() >0">
AND tmp.bizOrgCode IN
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="getColaBuildVideoListCount" resultType="hashmap">
......@@ -409,205 +393,209 @@
<insert id="saveStucture">
insert into wl_warehouse_structure
(id,
code,
name,
full_name,
parent_id,
warehouse_id,
create_date,
biz_org_code,
biz_org_name,
source_id)
VALUES(
#{instanceId},
#{code},
#{name},
#{address},
#{parentId},
0,
now(),
#{bizOrgCode},
#{bizOrgName},
#{instanceId})
(id,
code,
name,
full_name,
parent_id,
warehouse_id,
create_date,
biz_org_code,
biz_org_name,
source_id)
VALUES (#{instanceId},
#{code},
#{name},
#{address},
#{parentId},
0,
now(),
#{bizOrgCode},
#{bizOrgName},
#{instanceId})
</insert>
<select id="getStuctureName" resultType="String">
select full_name from wl_warehouse_structure
select full_name
from wl_warehouse_structure
where id = #{id}
</select>
<select id="getStuName" resultType="String">
select name from wl_warehouse_structure
select name
from wl_warehouse_structure
where id = #{id}
</select>
<select id="getStructureParentId" resultType="Long">
select parent_id from wl_warehouse_structure
select parent_id
from wl_warehouse_structure
where id = #{id}
</select>
<delete id="deleteStuById">
DELETE FROM wl_warehouse_structure WHERE id = #{id}
DELETE
FROM wl_warehouse_structure
WHERE id = #{id}
</delete>
<update id="updateStr">
update wl_warehouse_structure
set name = #{name} ,
full_name = #{fullName},
parent_id = #{parentId},
code = #{code},
biz_org_code = #{bizOrgCode},
biz_org_name= #{bizOrgName}
set name = #{name},
full_name = #{fullName},
parent_id = #{parentId},
code = #{code},
biz_org_code = #{bizOrgCode},
biz_org_name= #{bizOrgName}
where id = #{id}
</update>
<update id="updateFormFieldValue">
update wl_form_instance
set
field_value = #{value}
where instance_id = #{id} AND field_name = #{name}
set field_value = #{value}
where instance_id = #{id}
AND field_name = #{name}
</update>
<update id="updateStrFullName">
update wl_warehouse_structure
set full_name=replace(full_name,#{name},#{fullName})
where
id in (
select instance_id from wl_form_instance where field_name = 'parentId' and field_value = #{id}
update wl_warehouse_structure
set full_name=replace(full_name, #{name}, #{fullName})
where id in (
select instance_id
from wl_form_instance
where field_name = 'parentId'
and field_value = #{id}
union all
select instance_id from wl_form_instance where field_name = 'parentId' and field_value in (
select instance_id from wl_form_instance where field_name = 'parentId' and field_value = #{id}
select instance_id
from wl_form_instance
where field_name = 'parentId'
and field_value in (
select instance_id from wl_form_instance where field_name = 'parentId' and field_value = #{id}
)
)
)
</update>
<update id="clearSystemId">
update wl_form_instance
set field_value = null
where field_name like '%system%'
and field_value = #{id}
update wl_form_instance
set field_value = null
where field_name like '%system%'
and field_value = #{id}
</update>
<select id="getChildrenNotIsRiskList" resultType="com.yeejoin.equipmanage.common.entity.dto.BuildIsRiskDTO">
select * from (SELECT
a.instance_id AS instanceId,
MAX(
CASE
WHEN a.field_name = 'parentId' THEN
a.field_value
END
) AS parentId,
MAX(
CASE
WHEN a.field_name = 'isRisk' THEN
a.field_value
END
) AS isRisk
FROM
`wl_form_instance` a
GROUP BY
a.instance_id) sa where sa.parentId = #{instanceId} and sa.isRisk = 'false' and sa.isRisk is not null
select *
from (SELECT a.instance_id AS instanceId,
MAX(
CASE
WHEN a.field_name = 'parentId' THEN
a.field_value
END
) AS parentId,
MAX(
CASE
WHEN a.field_name = 'isRisk' THEN
a.field_value
END
) AS isRisk
FROM `wl_form_instance` a
GROUP BY a.instance_id) sa
where sa.parentId = #{instanceId}
and sa.isRisk = 'false'
and sa.isRisk is not null
</select>
<update id="clearRegionBind">
UPDATE
wl_form_instance
SET field_value = (
CASE field_name
WHEN 'isRisk' THEN
'false'
WHEN 'riskPointId' THEN
''
END
)
WHERE
instance_id = #{instanceId} and (field_name = 'isRisk' or field_name = 'riskPointId')
CASE field_name
WHEN 'isRisk' THEN
'false'
WHEN 'riskPointId' THEN
''
END
)
WHERE instance_id = #{instanceId}
and (field_name = 'isRisk' or field_name = 'riskPointId')
</update>
<select id="getParentId" resultType="map">
select
*
from
wl_warehouse_structure
where
parent_id = #{parentId}
select *
from wl_warehouse_structure
where parent_id = #{parentId}
</select>
<select id="getIdAndType" resultType="hashmap">
select
ins.field_value as id,
inst.group_code as type,
str.full_name as address
from
wl_form_instance as ins
left join wl_form_instance as inst on ins.field_value = inst.instance_id
left join wl_warehouse_structure as str on ins.instance_id = str.source_id
where ins.instance_id =#{id}
and ins.field_name ='parentId'
group by ins.field_value
select ins.field_value as id,
inst.group_code as type,
str.full_name as address
from wl_form_instance as ins
left join wl_form_instance as inst on ins.field_value = inst.instance_id
left join wl_warehouse_structure as str on ins.instance_id = str.source_id
where ins.instance_id = #{id}
and ins.field_name = 'parentId'
group by ins.field_value
</select>
<!-- // 需求958 导出模板需要列表获取建筑 by kongfm 2021-09-15-->
<select id="getAllBuilding" resultType="hashmap">
select * from (SELECT
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
a.field_value AS fieldValue,
a.field_label AS fieldLabel,
MAX(CASE WHEN a.field_name = 'parentId' THEN a.field_value END) AS parentId,
MAX(CASE WHEN a.field_name = 'name' THEN a.field_value END)AS buildName
FROM
`wl_form_instance` a
where a.group_type = 'building'
GROUP BY
a.instance_id) sa
select *
from (SELECT a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
a.field_value AS fieldValue,
a.field_label AS fieldLabel,
MAX(CASE WHEN a.field_name = 'parentId' THEN a.field_value END) AS parentId,
MAX(CASE WHEN a.field_name = 'name' THEN a.field_value END) AS buildName
FROM `wl_form_instance` a
where a.group_type = 'building'
GROUP BY a.instance_id) sa
ORDER BY sa.instanceId DESC
</select>
<select id="getBuildingToLongitudeAndLatitude" resultType="hashmap">
SELECT
max(CASe WHEN field_name = 'latitude' THEN field_value end ) AS latitude,
max(CASe WHEN field_name = 'longitude' THEN field_value end ) AS longitude
FROM
wl_form_instance
WHERE
instance_id = #{instanceId}
</select>
<!--<select id="getBuildVideoCount" resultType="hashmap">-->
<!-- SELECT-->
<!-- wlv.source_id AS buildId,-->
<!-- count( wlv.source_id ) AS total-->
<!-- FROM-->
<!-- `wl_video_source` wlv-->
<!-- GROUP BY-->
<!-- wlv.source_id-->
<!--</select>-->
<select id="getBuildVideoCount" resultType="hashmap">
SELECT
b.instanceId AS buildId,
COUNT( vs.video_id ) AS total
FROM
get_building_tree b
JOIN wl_video_source vs ON FIND_IN_SET( b.instanceId, vs.parent_source_ids )
JOIN wl_video v on v.id = vs.video_id
GROUP BY
b.instanceId
</select>
<update id ="updateFormInstanceByInstanceAndFieldName">
UPDATE wl_form_instance
SET field_value = #{value}
WHERE
instance_id =#{instanceId}
AND field_name =#{name}
<select id="getBuildingToLongitudeAndLatitude" resultType="hashmap">
SELECT max(CASe WHEN field_name = 'latitude' THEN field_value end) AS latitude,
max(CASe WHEN field_name = 'longitude' THEN field_value end) AS longitude
FROM wl_form_instance
WHERE instance_id = #{instanceId}
</select>
<!--<select id="getBuildVideoCount" resultType="hashmap">-->
<!-- SELECT-->
<!-- wlv.source_id AS buildId,-->
<!-- count( wlv.source_id ) AS total-->
<!-- FROM-->
<!-- `wl_video_source` wlv-->
<!-- GROUP BY-->
<!-- wlv.source_id-->
<!--</select>-->
<select id="getBuildVideoCount" resultType="hashmap">
SELECT b.instanceId AS buildId,
COUNT(vs.video_id) AS total
FROM get_building_tree b
JOIN wl_video_source vs ON FIND_IN_SET(b.instanceId, vs.parent_source_ids)
JOIN wl_video v on v.id = vs.video_id
GROUP BY b.instanceId
</select>
<update id="updateFormInstanceByInstanceAndFieldName">
</update>
<select id="selectChildListdate" resultType="java.lang.String">
SELECT distinct a.instance_id FROM
UPDATE wl_form_instance
SET field_value = #{value}
WHERE instance_id = #{instanceId}
AND field_name = #{name}
(select instance_id ,field_value from wl_form_instance where group_type in('building','room','floor') and field_name='parentId') a
WHERE a.field_value = #{id} union all SELECT distinct b.instance_id FROM
(select instance_id ,field_value from wl_form_instance where group_type in('building','room','floor') and field_name='parentId') b
WHERE b.field_value in (SELECT distinct c.instance_id FROM
</update>
(select instance_id ,field_value from wl_form_instance where group_type in('building','room','floor') and field_name='parentId') c
WHERE c.field_value = #{id})
<select id="selectChildListdate" resultType="java.lang.String">
SELECT distinct a.instance_id
FROM (select instance_id, field_value
from wl_form_instance
where group_type in ('building', 'room', 'floor')
and field_name = 'parentId') a
WHERE a.field_value = #{id}
union all
SELECT distinct b.instance_id
FROM (select instance_id, field_value
from wl_form_instance
where group_type in ('building', 'room', 'floor')
and field_name = 'parentId') b
WHERE b.field_value in (SELECT distinct c.instance_id
FROM (select instance_id, field_value
from wl_form_instance
where group_type in ('building', 'room', 'floor')
and field_name = 'parentId') c
WHERE c.field_value = #{id})
</select>
......@@ -648,9 +636,14 @@ AND field_name =#{name}
<select id="queryVideoCountByBizOrgCode" resultType="java.lang.Long">
select count(1) from wl_video where biz_org_code like concat(#{bizOrgCode}, '%')
select count(1)
from wl_video
where biz_org_code like concat(#{bizOrgCode}, '%')
</select>
<select id="selectParentBuildId" resultType="java.lang.String">
SELECT instance_id FROM `wl_form_instance` f where f.field_name = 'code' and f.field_value = #{code}
SELECT instance_id
FROM `wl_form_instance` f
where f.field_name = 'code'
and f.field_value = #{code}
</select>
</mapper>
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