Commit cdb27125 authored by tangwei's avatar tangwei

解决冲突

parents 16e8c7bf d89f06ee
......@@ -2,9 +2,13 @@ package com.yeejoin.amos.boot.module.common.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto;
import com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift;
import lombok.Data;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -152,4 +156,13 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
List<Map<String, Object>> getNewEquipmentForSpecifyDate(String dutyDate,String groupCode,String equipmentId,String equipmentName,String groupByName);
String getFirstAidCompanyId ();
/**
* 获取指定人 指定日期下所有的排班
* @param instanceId 动态表单 关联id
* @param minDate 最小日期
* @param maxDate 最大日期
*/
List<DutyPersonShiftDto> queryDutyByPersonAndData(Long instanceId, Date minDate, Date maxDate);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper">
<select id="calMaxPersonAndShiftNum" resultType="java.util.Map">
select
(select
IFNULL(max(num),0)
from
(SELECT
ifnull(count(1),0) num
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
ds.sequence_nbr = s.shift_id
and s.instance_id = i.instance_id
AND i.field_code = 'userId'
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]>
#{endDate}
AND s.shift_id is not null <!--// BUG 2807 更新人员车辆排版值班的保存逻辑 如果没有填写数据则保存空数据 。
namespace="com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper">
<select id="calMaxPersonAndShiftNum" resultType="java.util.Map">
select
(select
IFNULL(max(num),0)
from
(SELECT
ifnull(count(1),0) num
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
ds.sequence_nbr = s.shift_id
and s.instance_id = i.instance_id
AND i.field_code = 'userId'
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]>
#{endDate}
AND s.shift_id is not null <!--// BUG 2807 更新人员车辆排版值班的保存逻辑 如果没有填写数据则保存空数据 。
同步修改 查询 导出相关逻辑 by kongfm 2021-09-14 -->
and s.app_Key = #{appKey}
GROUP BY s.duty_date,s.shift_id <!--增添分组条件 根据班次分组技术 -->
) a) as maxDutyPersonNumDay,
(select
IFNULL(max(num),0)
from
(SELECT
ifnull(count(DISTINCT(s.shift_id)),0) num
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
ds.sequence_nbr = s.shift_id
and s.instance_id = i.instance_id
AND i.field_code = 'userId'
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]>
#{endDate}
and s.app_Key = #{appKey}
GROUP BY s.duty_date) b) as maxShiftNumDay
</select>
and s.app_Key = #{appKey}
GROUP BY s.duty_date,s.shift_id <!--增添分组条件 根据班次分组技术 -->
) a) as maxDutyPersonNumDay,
(select
IFNULL(max(num),0)
from
(SELECT
ifnull(count(DISTINCT(s.shift_id)),0) num
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
ds.sequence_nbr = s.shift_id
and s.instance_id = i.instance_id
AND i.field_code = 'userId'
and s.duty_date >= #{beginDate}
and s.duty_date <![CDATA[<=]]>
#{endDate}
and s.app_Key = #{appKey}
GROUP BY s.duty_date) b) as maxShiftNumDay
</select>
<select id="nowDutyCarPersonNum" resultType="java.util.Map">
SELECT
`a`.`name` AS `name`,
a.id,
(
SELECT
count( DISTINCT `cb_duty_person_shift`.`instance_id` ) AS `num`
FROM
( `cb_duty_shift` LEFT JOIN `cb_duty_person_shift` ON ( ( `cb_duty_person_shift`.`shift_id` = `cb_duty_shift`.`sequence_nbr` ) ) )
WHERE
(
( `cb_duty_person_shift`.`is_delete` = 0 )
AND `cb_duty_person_shift`.`instance_id` IN (
SELECT
`cb_dynamic_form_instance`.`instance_id`
FROM
`cb_dynamic_form_instance`
WHERE
(
( `cb_dynamic_form_instance`.`group_id` = ( SELECT `cb_dynamic_form_group`.`sequence_nbr` FROM `cb_dynamic_form_group` WHERE ( `cb_dynamic_form_group`.`group_code` = 'dutyCar' ) ) )
AND ( `cb_dynamic_form_instance`.`group_code` = 'dutyCar' )
AND ( `cb_dynamic_form_instance`.`field_value` = `a`.`id` )
)
)
AND (
CONVERT ( date_format( now( ), '%Y-%m-%d %H:%i' ) USING utf8mb3 ) BETWEEN (
CASE
LEFT ( `cb_duty_shift`.`start_time`, 3 )
WHEN '当日:' THEN
REPLACE ( `cb_duty_shift`.`start_time`, '当日:', `cb_duty_person_shift`.`duty_date` ) ELSE REPLACE ( `cb_duty_shift`.`start_time`, '次日:', ( `cb_duty_person_shift`.`duty_date` + INTERVAL 1 DAY ) )
END
)
AND (
CASE
LEFT ( `cb_duty_shift`.`end_time`, 3 )
WHEN '当日:' THEN
REPLACE ( `cb_duty_shift`.`end_time`, '当日:', `cb_duty_person_shift`.`duty_date` ) ELSE REPLACE ( `cb_duty_shift`.`end_time`, '次日:', ( `cb_duty_person_shift`.`duty_date` + INTERVAL 1 DAY ) )
END
)
)
)
) AS `num`
FROM
(
(
`xiy_safety_business_v3.0.1_20100712`.`wl_car` `a`
LEFT JOIN `jc_power_transfer_company_resources` `b` ON ( ( ( `a`.`id` = `b`.`resources_id` ) AND ( `b`.`status` = 'executing' ) ) )
)
LEFT JOIN `cb_data_dictionary` `c` ON ( ( ( `c`.`code` = `b`.`car_status` ) AND ( `c`.`type` = 'CARSTATE' ) ) )
)
<select id="nowDutyCarPersonNum" resultType="java.util.Map">
SELECT `a`.`name` AS `name`,
a.id,
(
SELECT count(DISTINCT `cb_duty_person_shift`.`instance_id`) AS `num`
FROM (`cb_duty_shift` LEFT JOIN `cb_duty_person_shift` ON ((`cb_duty_person_shift`.`shift_id` = `cb_duty_shift`.`sequence_nbr`)))
WHERE (
(`cb_duty_person_shift`.`is_delete` = 0)
AND `cb_duty_person_shift`.`instance_id` IN (
SELECT `cb_dynamic_form_instance`.`instance_id`
FROM `cb_dynamic_form_instance`
WHERE (
(`cb_dynamic_form_instance`.`group_id` =
(SELECT `cb_dynamic_form_group`.`sequence_nbr`
FROM `cb_dynamic_form_group`
WHERE (`cb_dynamic_form_group`.`group_code` = 'dutyCar')))
AND (`cb_dynamic_form_instance`.`group_code` = 'dutyCar')
AND (`cb_dynamic_form_instance`.`field_value` = `a`.`id`)
)
)
AND (
CONVERT(date_format(now(), '%Y-%m-%d %H:%i') USING utf8mb3) BETWEEN (
CASE
LEFT ( `cb_duty_shift`.`start_time`, 3 )
WHEN '当日:' THEN
REPLACE ( `cb_duty_shift`.`start_time`, '当日:', `cb_duty_person_shift`.`duty_date` ) ELSE REPLACE ( `cb_duty_shift`.`start_time`, '次日:', ( `cb_duty_person_shift`.`duty_date` + INTERVAL 1 DAY ) )
END
)
AND (
CASE
LEFT ( `cb_duty_shift`.`end_time`, 3 )
WHEN '当日:' THEN
REPLACE ( `cb_duty_shift`.`end_time`, '当日:', `cb_duty_person_shift`.`duty_date` ) ELSE REPLACE ( `cb_duty_shift`.`end_time`, '次日:', ( `cb_duty_person_shift`.`duty_date` + INTERVAL 1 DAY ) )
END
)
)
)
) AS `num`
FROM (
(
`xiy_safety_business_v3.0.1_20100712`.`wl_car` `a`
LEFT JOIN `jc_power_transfer_company_resources` `b` ON (((`a`.`id` = `b`.`resources_id`) AND (`b`.`status` = 'executing')))
)
LEFT JOIN `cb_data_dictionary` `c` ON (((`c`.`code` = `b`.`car_status`) AND (`c`.`type` = 'CARSTATE')))
)
</select>
<select id="bankViewData" resultType="java.util.Map">
SELECT
S1.*,
S2.name as shiftName
from
(SELECT
s.shift_id as shiftId,
GROUP_CONCAT(i.field_value) AS userName
FROM
cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE
s.instance_id = i.instance_id
AND ds.sequence_nbr = s.shift_id
AND i.field_code = 'userName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
AND s.app_key = #{appKey}
and i.group_code =#{groupCode}
GROUP BY
s.shift_id
) S1,
cb_duty_shift S2
where
s1.shiftId = s2.sequence_nbr
</select>
<select id="stationViewData" resultType="java.util.Map">
select
i.field_value as postTypeName,
count(1) as total
from
cb_duty_person_shift s,
cb_dynamic_form_instance i
where
s.instance_id = i.instance_id
and i.field_code = 'postTypeName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
AND s.app_key = #{appKey}
and i.group_code =#{groupCode}
GROUP BY i.field_value
</select>
<select id="newStationViewData" resultType="java.util.Map">
select
i.field_value as postTypeName,
count(1) as total
from
cb_duty_person_shift s,
cb_dynamic_form_instance i
where
s.instance_id = i.instance_id
and i.field_code = 'postTypeName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
and i.group_code =#{groupCode}
GROUP BY i.field_value
</select>
<select id="newStationViewDataByFieldCode" resultType="java.util.Map">
select
i.field_value as postTypeName,
count(1) as total
from
cb_duty_person_shift s,
cb_dynamic_form_instance i
where
s.instance_id = i.instance_id
and i.field_code = #{fieldCode}
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
and i.group_code =#{groupCode}
AND i.field_value is not null
AND i.field_value != ''
GROUP BY i.field_value
</select>
<select id="genRangeDate" resultType="map">
SELECT
DATE_FORMAT(DATE( DATE_ADD( #{beginDate}, INTERVAL @s DAY )),'%Y-%m-%d') AS date,
</select>
<select id="bankViewData" resultType="java.util.Map">
SELECT S1.*,
S2.name as shiftName
from (SELECT s.shift_id as shiftId,
GROUP_CONCAT(i.field_value) AS userName
FROM cb_duty_person_shift s,
cb_duty_shift ds,
cb_dynamic_form_instance i
WHERE s.instance_id = i.instance_id
AND ds.sequence_nbr = s.shift_id
AND i.field_code = 'userName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
AND s.app_key = #{appKey}
and i.group_code = #{groupCode}
GROUP BY s.shift_id
) S1,
cb_duty_shift S2
where s1.shiftId = s2.sequence_nbr
</select>
<select id="stationViewData" resultType="java.util.Map">
select i.field_value as postTypeName,
count(1) as total
from cb_duty_person_shift s,
cb_dynamic_form_instance i
where s.instance_id = i.instance_id
and i.field_code = 'postTypeName'
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
AND s.app_key = #{appKey}
and i.group_code = #{groupCode}
GROUP BY i.field_value
</select>
<select id="newStationViewData" resultType="java.util.Map">
SELECT result.postTypeName as postTypeName,
count(result.postTypeName) as total
FROM (
select
(
SELECT
cdd.sort_num
FROM
cb_data_dictionary cdd
WHERE
cdd.NAME = MAX( CASE WHEN i.FIELD_CODE = 'postTypeName' THEN i.FIELD_VALUE END )
AND cdd.type = 'DUTY_POST_TYPE'
) AS personSort,
MAX(CASE WHEN i.FIELD_CODE = 'postTypeName' THEN i.FIELD_VALUE END) as postTypeName
from cb_dynamic_form_instance i
LEFT JOIN
cb_duty_person_shift s on s.instance_id = i.instance_id and s.shift_id is not null
WHERE s.duty_date = #{dutyDate}
and i.group_code = #{groupCode}
GROUP BY i.instance_id
) result
GROUP BY result.postTypeName
ORDER BY result.personSort + 0 asc
</select>
<select id="newStationViewDataByFieldCode" resultType="java.util.Map">
select i.field_value as postTypeName,
count(1) as total
from cb_duty_person_shift s,
cb_dynamic_form_instance i
where s.instance_id = i.instance_id
and i.field_code = #{fieldCode}
AND s.duty_date = #{dutyDate}
AND s.shift_id is not null
and i.group_code = #{groupCode}
AND i.field_value is not null
AND i.field_value != ''
GROUP BY i.field_value
</select>
<select id="genRangeDate" resultType="map">
SELECT DATE_FORMAT(DATE( DATE_ADD( #{beginDate}, INTERVAL @s DAY)), '%Y-%m-%d') AS date,
@s := @s + 1 AS `index`
FROM
mysql.help_topic,
( SELECT @s := 0 ) temp
WHERE
@s <![CDATA[<=]]>
DATEDIFF(#{endDate},#{beginDate})
</select>
FROM
mysql.help_topic,
( SELECT @s := 0 ) temp
WHERE
@s <![CDATA[<=]]>
DATEDIFF(#{endDate}
, #{beginDate})
</select>
<select id='getSpecifyDateList' resultType='map'>
SELECT
GROUP_CONCAT(cd.field_value) AS
value
,
cds.name
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.field_code = 'userName'
<if test="params != null and params!='' ">
and cd.field_value !='消防车驾驶员'
</if>
AND cd.instance_id IN
<foreach collection ='instanceIds' item='instanceId' index='index' open="(" close= ")" separator=",">
#{instanceId}
</foreach>
GROUP BY
cds.`name`
</select>
<select id='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='getEquipmentForSpecifyDate' resultType='map'>
select * from (
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentId} THEN
cd.FIELD_VALUE
END
) AS #{equipmentId},
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName},
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName},
MAX(
CASE
WHEN cd.FIELD_CODE = #{teamName} THEN
cd.FIELD_VALUE
END
) AS #{teamName}
MAX(
CASE
WHEN cd.FIELD_CODE = #{teamName} THEN
cd.FIELD_VALUE
END
) AS #{teamName}
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate} and dp.is_delete=0
) cds ON cd.instance_id = cds.instance_id
where cd.group_code =#{groupCode} and cds.instance_id is not null and
cd.is_delete=0
group by cd.instance_id
) result
<if test="groupByName != null and groupByName!='' ">
group by ${groupByName}
</if>
</select>
<select id='getNewEquipmentForSpecifyDate' resultType='map'>
select *,
(SELECT
org.org_expand_attr1
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
cb_org_usr org
WHERE
dp.duty_date = #{dutyDate} and dp.is_delete=0 and dp.shift_id is not null
) 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!='' ">
group by ${groupByName}
</if>
</select>
<select id='getNewEquipmentForSpecifyDate' resultType='map'>
select * from (
org.sequence_nbr = result.deptId ) AS sort
from (
SELECT
MAX(
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentId} THEN
cd.FIELD_VALUE
cd.FIELD_VALUE
END
) AS #{equipmentId},
) AS #{equipmentId},
MAX(
CASE
......@@ -290,13 +290,13 @@ select * from (
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName}
FROM
MAX(
CASE
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName}
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
......@@ -306,250 +306,279 @@ select * 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
dp.duty_date = #{dutyDate} and dp.is_delete=0 and dp.shift_id is not null
) 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
) result
<if test="groupByName != null and groupByName!='' ">
group by ${groupByName}
</if>
</select>
<select id='getInstanceIdForSpecifyDateAndEquipment'
resultType='map'>
SELECT
GROUP_CONCAT(cd.instance_id) as instanceIds
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.field_value = #{targetId}
</select>
<select id='getEquipmentOperator' resultType='map'>
SELECT
result.userName
FROM
(
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = 'postTypeName' THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
cds. NAME
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.instance_id IN
<foreach collection ='instanceIds' item='instanceId' index='index' open="(" close= ")" separator=",">
#{instanceId}
</foreach>
) result
WHERE
result.postTypeName = #{operator} and result.name =#{duty}
ORDER BY sort+0
</select>
<select id ='getPositionStaffDutyForSpecifyDate' resultType="map">
SELECT
GROUP_CONCAT(ss.userName) AS userName,
ss.postTypeName
FROM
(
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
<choose>
<when test="fieldCode != null and fieldCode != ''">
MAX(
CASE
WHEN cd.FIELD_CODE = #{fieldCode} THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
</when>
<otherwise>
MAX(
CASE
WHEN cd.FIELD_CODE = 'postTypeName' THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
</otherwise>
</choose>
cd.instance_id
FROM
cb_dynamic_form_instance cd
WHERE
cd.instance_id in
<foreach collection ='instanceIds' item='instanceId' index='index' open="(" close= ")" separator=",">
#{instanceId}
</foreach>
AND cd.group_code = #{groupCode}
AND cd.is_delete = 0
GROUP BY
cd.instance_id
) ss
<!-- LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
AND NAME IS NOT NULL
) cds ON ss.instance_id = cds.instance_id
WHERE
cds.NAME =#{duty} -->
GROUP BY
ss.postTypeName
</select>
<select id='getDutyForSpecifyDate' resultType="map">
SELECT
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
AND NAME IS NOT NULL
GROUP BY
NAME
</select>
<select id='getFireTeamBySequenceNbr' resultType="map">
SELECT
name
FROM
cb_fire_team
WHERE
sequence_nbr = #{sequenceNbr} and is_delete=0
</select>
<select id='getFirstAidCompanyId' resultType="string">
SELECT
sequence_nbr
FROM
cb_org_usr a
WHERE
a.is_delete = 0
AND
a.biz_org_name = '消防救援保障部'
</select>
<select id='getFirstAidForTypeCodeAndCompanyId' resultType="map">
SELECT
cft.name,
cft.sequence_nbr
FROM
cb_fire_team cft
WHERE
cft.is_delete = 0
AND cft.type_code = (
SELECT
CODE
FROM
cb_data_dictionary cd
WHERE
cd.name = '企(事)业单位医疗救援队(站)'
AND cd.type = 'XFJGLX'
)
AND cft.company = #{company}
</select>
<select id='getInstanceIdForSpecifyDateAndEquipment'
resultType='map'>
SELECT GROUP_CONCAT(cd.instance_id) as instanceIds
FROM cb_dynamic_form_instance cd
LEFT JOIN (
SELECT dp.instance_id,
ds.`name`
FROM cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.field_value = #{targetId}
</select>
<select id='getEquipmentOperator' resultType='map'>
SELECT
result.userName
FROM
(
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
MAX(
CASE
WHEN cd.FIELD_CODE = 'postTypeName' THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
cds. NAME
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
) cds ON cd.instance_id = cds.instance_id
WHERE
cd.group_code = #{groupCode}
AND cds.instance_id IS NOT NULL
AND cd.is_delete = 0
AND cd.instance_id IN
<foreach collection='instanceIds' item='instanceId' index='index' open="(" close=")" separator=",">
#{instanceId}
</foreach>
) result
WHERE
result.postTypeName = #{operator} and result.name =#{duty}
</select>
<select id='getPositionStaffDutyForSpecifyDate' resultType="map">
SELECT
GROUP_CONCAT(ss.userName) AS userName,
ss.postTypeName,
(select cdd.sort_num from cb_data_dictionary cdd WHERE cdd.name = ss.postTypeName and cdd.type = 'DUTY_POST_TYPE') as sort
FROM
(
SELECT
MAX(
CASE
WHEN cd.FIELD_CODE = 'userName' THEN
cd.FIELD_VALUE
END
) AS 'userName',
<choose>
<when test="fieldCode != null and fieldCode != ''">
MAX(
CASE
WHEN cd.FIELD_CODE = #{fieldCode} THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
</when>
<otherwise>
MAX(
CASE
WHEN cd.FIELD_CODE = 'postTypeName' THEN
cd.FIELD_VALUE
END
) AS 'postTypeName',
</otherwise>
</choose>
cd.instance_id
FROM
cb_dynamic_form_instance cd
WHERE
cd.instance_id in
<foreach collection='instanceIds' item='instanceId' index='index' open="(" close=")" separator=",">
#{instanceId}
</foreach>
AND cd.group_code = #{groupCode}
AND cd.is_delete = 0
GROUP BY
cd.instance_id
ORDER BY CONVERT(userName USING GBK) ASC
) ss
<!-- LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE
dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
AND NAME IS NOT NULL
) cds ON ss.instance_id = cds.instance_id
WHERE
cds.NAME =#{duty} -->
GROUP BY
ss.postTypeName
ORDER BY
sort ASC
</select>
<select id='getDutyForSpecifyDate' resultType="map">
SELECT ds.`name`
FROM cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
WHERE dp.duty_date = #{dutyDate}
AND dp.is_delete = 0
AND NAME IS NOT NULL
GROUP BY NAME
</select>
<select id='getFireTeamBySequenceNbr' resultType="map">
SELECT name
FROM cb_fire_team
WHERE sequence_nbr = #{sequenceNbr}
and is_delete = 0
</select>
<select id='getFirstAidCompanyId' resultType="string">
SELECT sequence_nbr
FROM cb_org_usr a
WHERE a.is_delete = 0
AND a.biz_org_name = '消防救援保障部'
</select>
<select id='getFirstAidForTypeCodeAndCompanyId' resultType="map">
SELECT cft.name,
cft.sequence_nbr
FROM cb_fire_team cft
WHERE cft.is_delete = 0
AND cft.type_code = (
SELECT CODE
FROM cb_data_dictionary cd
WHERE cd.name = '企(事)业单位医疗救援队(站)'
AND cd.type = 'XFJGLX'
)
AND cft.company = #{company}
</select>
<select id='queryByCompanyId' resultType="map">
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId,companyName from (
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId, cou1.biz_org_name companyName
from (select * from cb_org_usr cou where is_delete = 0 ) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId from (
select cb.duty_date,a.deptId,c.userId from cb_duty_person_shift cb
left join (select i.instance_id id1 ,if(i.field_code = 'deptId',
i.field_value, null) as 'deptId' from cb_dynamic_form_instance i
where i.field_code = 'deptId' and i.field_value is not null) a
on cb.instance_id = a.id1
left join (select i.instance_id id3 ,if(i.field_code = 'userId',
i.field_value, null) as 'userId' from cb_dynamic_form_instance i
where i.field_code = 'userId' and i.field_value is not null) c
on cb.instance_id = c.id3
where to_days(cb.duty_date) = to_days(now()) and
a.deptId in ( select sequence_nbr from cb_org_usr cou where biz_org_name in
<foreach item="item" index="index" collection="bizNames" open="(" separator="," close=")">
#{item}
</foreach>
)) r )
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId,companyName from
(
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId, cou1.biz_org_name
companyName
from (select * from cb_org_usr cou where is_delete = 0 ) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId from (
select cb.duty_date,a.deptId,c.userId from cb_duty_person_shift cb
left join (select i.instance_id id1 ,if(i.field_code = 'deptId',
i.field_value, null) as 'deptId' from cb_dynamic_form_instance i
where i.field_code = 'deptId' and i.field_value is not null) a
on cb.instance_id = a.id1
left join (select i.instance_id id3 ,if(i.field_code = 'userId',
i.field_value, null) as 'userId' from cb_dynamic_form_instance i
where i.field_code = 'userId' and i.field_value is not null) c
on cb.instance_id = c.id3
where to_days(cb.duty_date) = to_days(now()) and
a.deptId in ( select sequence_nbr from cb_org_usr cou where biz_org_name in
<foreach item="item" index="index" collection="bizNames" open="(" separator="," close=")">
#{item}
</foreach>
)) r )
</select>
<select id='queryByCompanyNew' resultType="map">
select biz_org_name as bizOrgName,sequence_nbr sequenceNbr,field_value as telephone, amosUserId,companyName from (
select orgUsr.biz_org_name,i.field_value,orgUsr.sequence_nbr,orgUsr.amos_org_id amosUserId, cou1.biz_org_name companyName
from (select * from cb_org_usr cou where is_delete = 0 ) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId from (
select cb.duty_date,a.deptId,c.userId from cb_duty_person_shift cb
left join (select i.instance_id id1 ,if(i.field_code = 'deptId',
i.field_value, null) as 'deptId' from cb_dynamic_form_instance i
where i.field_code = 'deptId' and i.field_value is not null) a
on cb.instance_id = a.id1
left join (select i.instance_id id3 ,if(i.field_code = 'userId',
i.field_value, null) as 'userId' from cb_dynamic_form_instance i
where i.field_code = 'userId' and i.field_value is not null) c
on cb.instance_id = c.id3
where to_days(cb.duty_date) = to_days(now()) and
a.deptId in ( select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})) r )
<select id='queryByCompanyNew' resultType="map">
select biz_org_name as bizOrgName, sequence_nbr sequenceNbr, field_value as telephone, amosUserId, companyName
from (
select orgUsr.biz_org_name,
i.field_value,
orgUsr.sequence_nbr,
orgUsr.amos_org_id amosUserId,
cou1.biz_org_name companyName
from (select * from cb_org_usr cou where is_delete = 0) orgUsr
left join cb_org_usr cou1 on orgUsr.parent_id = cou1.sequence_nbr
left join cb_dynamic_form_instance i on orgUsr.sequence_nbr =
i.instance_id
where i.field_code = 'telephone') as d
where d.sequence_nbr in (
select userId
from (
select cb.duty_date, a.deptId, c.userId
from cb_duty_person_shift cb
left join (select i.instance_id id1,
if(i.field_code = 'deptId',
i.field_value, null) as 'deptId'
from cb_dynamic_form_instance i
where i.field_code = 'deptId'
and i.field_value is not null) a
on cb.instance_id = a.id1
left join (select i.instance_id id3,
if(i.field_code = 'userId',
i.field_value, null) as 'userId'
from cb_dynamic_form_instance i
where i.field_code = 'userId'
and i.field_value is not null) c
on cb.instance_id = c.id3
where to_days(cb.duty_date) = to_days(now())
and a.deptId in (select sequence_nbr from cb_org_usr cou where biz_org_name = #{bizOrgName})) r)
</select>
<select id='queryDutyByPersonAndData' resultType="com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto">
SELECT
*
FROM
`cb_duty_person_shift`
WHERE
duty_date BETWEEN #{minDate} AND #{maxDate}
AND
instance_id = #{instanceId}
</select>
</mapper>
......@@ -27,7 +27,14 @@
ps.shift_id as shiftId,
ps.duty_date as dutyDate,
ds.name as shiftName,
'在岗' state
'在岗' state,
(SELECT
org.org_expand_attr1
FROM
cb_org_usr org
WHERE
org.sequence_nbr = d.deptId ) AS sort
FROM
from
(
select
......@@ -35,7 +42,16 @@
i.GROUP_CODE groupCode,
<foreach collection="fieldCodes" item="value" index="key" separator=",">
MAX(CASE WHEN i.FIELD_CODE = #{key} THEN i.FIELD_VALUE END) as ${key}
</foreach>
</foreach>,
(
SELECT
cdd.sort_num
FROM
cb_data_dictionary cdd
WHERE
cdd.NAME = MAX( CASE WHEN i.FIELD_CODE = 'postTypeName' THEN i.FIELD_VALUE END )
AND cdd.type = 'DUTY_POST_TYPE'
) AS personSort
from
cb_dynamic_form_instance i
where i.GROUP_CODE = #{groupCode}
......@@ -54,13 +70,13 @@
( `cb_org_usr`.`biz_org_code` LIKE concat( ( SELECT `cb_org_usr`.`biz_org_code` FROM `cb_org_usr` WHERE ( `cb_org_usr`.`sequence_nbr` = 1435847345328660481 ) ), '%' ) )
AND ( `cb_org_usr`.`biz_org_type` = 'DEPARTMENT' )
))
and ps.shift_id = ds.sequence_nbr
and ps.duty_date = #{dutyDate}
<if test="shiftId != null and shiftId != ''">
and ps.shift_id in (#{shiftId})
</if>
order by instanceId desc
ORDER BY
sort+0 DESC ,d.personSort+0 ,CONVERT(username USING GBK) ASC
</select>
<select id="listAll" resultType="java.util.Map">
......@@ -216,7 +232,13 @@
ps.shift_id as shiftId,
ps.duty_date as dutyDate,
ds.name as shiftName,
'在岗' state
'在岗' state,
(SELECT
org.org_expand_attr1
FROM
cb_org_usr org
WHERE
org.sequence_nbr = d.deptId ) AS sort
from
(
select
......@@ -224,7 +246,16 @@
i.GROUP_CODE groupCode,
<foreach collection="fieldCodes" item="value" index="key" separator=",">
MAX(CASE WHEN i.FIELD_CODE = #{key} THEN i.FIELD_VALUE END) as ${key}
</foreach>
</foreach>,
(
SELECT
cdd.sort_num
FROM
cb_data_dictionary cdd
WHERE
cdd.NAME = MAX( CASE WHEN i.FIELD_CODE = 'postTypeName' THEN i.FIELD_VALUE END )
AND cdd.type = 'DUTY_POST_TYPE'
) AS personSort
from
cb_dynamic_form_instance i
where i.GROUP_CODE = #{groupCode}
......@@ -248,7 +279,8 @@
<if test="shiftId != null and shiftId != ''">
and ps.shift_id in (${shiftId})
</if>
order by instanceId desc
ORDER BY
sort+0 DESC,d.personSort+0 ,CONVERT(username USING GBK) ASC
</select>
<select id="getInstanceByCodeAndValue" resultType="com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance">
SELECT
......
......@@ -124,23 +124,6 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
List<Map<String, Object>> orgUsrList = orgUsrService.selectForShowByListId(ids);
maps.forEach(item -> {
String userId = String.valueOf(item.get("userId"));
//此处是用来给119日常值班首页值班岗位排序用
String sort = "";
switch ( item.get("postType").toString() ){
case "826" :
sort = "4";
break;
case "824" :
sort = "3";
break;
case "825" :
sort = "2";
break;
case "827" :
sort = "1";
break;
}
item.put("postSort",sort);
for (Map<String, Object> usr : orgUsrList) {
if (userId.equals(String.valueOf(usr.get("sequenceNbr")))) {
item.put("personImg", usr.get("personImg"));
......@@ -152,17 +135,6 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
}
}
});
maps= maps.stream().sorted((map1,map2)->{
if (map1.get("companyId").toString().equals(map2.get("companyId").toString())){
if (map1.get("deptId").toString().equals(map2.get("deptId").toString())){
return map2.get("postSort").toString().compareTo(map1.get("postSort").toString());
}else {
return map1.get("deptId").toString().compareTo(map2.get("deptId").toString());
}
}else {
return map2.get("companyId").toString().compareTo(map1.get("companyId").toString());
}
}).collect(Collectors.toList());
} catch (Exception e) {
e.printStackTrace();
}
......@@ -698,23 +670,6 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
List<Map<String, Object>> orgUsrList = orgUsrService.selectForShowByListId(ids);
maps.forEach(item -> {
String userId = String.valueOf(item.get("userId"));
//此处是用来给119日常值班首页值班岗位排序用
String sort = "";
switch (item.get("postType").toString()) {
case "826":
sort = "4";
break;
case "824":
sort = "3";
break;
case "825":
sort = "2";
break;
case "827":
sort = "1";
break;
}
item.put("postSort", sort);
for (Map<String, Object> usr : orgUsrList) {
if (userId.equals(String.valueOf(usr.get("sequenceNbr")))) {
item.put("personImg", usr.get("personImg"));
......@@ -726,17 +681,6 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
}
}
});
maps = maps.stream().sorted((map1, map2) -> {
if (map1.get("companyId").toString().equals(map2.get("companyId").toString())) {
if (map1.get("deptId").toString().equals(map2.get("deptId").toString())) {
return map2.get("postSort").toString().compareTo(map1.get("postSort").toString());
} else {
return map1.get("deptId").toString().compareTo(map2.get("deptId").toString());
}
} else {
return map2.get("companyId").toString().compareTo(map1.get("companyId").toString());
}
}).collect(Collectors.toList());
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -10,6 +10,9 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -17,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -165,6 +169,32 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
}
private void insertPersonShift(Long instanceId, DutyPersonDto dutyPersonDto) {
//此处代码针对页面操作 已有排班人员排班日期情况下 仍继续执行新增操作所造成的索引报错
//拿到排班月份
if (!ValidationUtil.isEmpty(dutyPersonDto.getDutyShift().get(0)) && ValidationUtil.isEmpty(dutyPersonDto.getDutyShift().get(0).getSequenceNbr()) ){
try {
//获取本次排班数据
List<DutyPersonShiftDto> dutyShiftList = dutyPersonDto.getDutyShift();
//获取排班月份的最大及最小日期
Date maxDate = DateUtils.maxDateOfMonth(dutyShiftList.get(0).getDutyDate());
Date minDate = DateUtils.minDateOfMonth(dutyShiftList.get(0).getDutyDate());
//拿到当前这个人指定月所有排班数据
List<DutyPersonShiftDto> currentData = dutyPersonShiftMapper.queryDutyByPersonAndData(instanceId, minDate, maxDate);
//对本次排班数据和历史排班数据的交集做主键赋值 执行更新 避免索引冲突
dutyShiftList.forEach(e->{
currentData.stream().forEach(data->{
if ( DateUtils.dateCompare(e.getDutyDate(),data.getDutyDate()) == 0){
e.setSequenceNbr(data.getSequenceNbr());
};
});
});
} catch (Exception e) {
e.printStackTrace();
}
}
Set<DutyPersonShift> personShiftList = dutyPersonDto.getDutyShift().stream().map(dto -> {
DutyPersonShift dutyPersonShift = new DutyPersonShift();
dto.setInstanceId(instanceId);
......
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