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