Commit 07602a7b authored by kang.nie@inzymeits.com's avatar kang.nie@inzymeits.com
Browse files

提交代码

parent e0c7be76
<?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.ssi.mapper.VmsChargingTotalMapper">
<select id="getChargingPileUseRate" resultType="double">
SELECT
IFNULL((SUM( duration )/ 2
/
<choose>
<when test="startDate !=null and endDate !=null">
( UNIX_TIMESTAMP(#{endDate})*1000
- UNIX_TIMESTAMP(#{startDate})*1000)
</when>
<otherwise>
(3600*24)
</otherwise>
</choose>
),0) AS chargingPileUseRate
FROM
vms_charging_total
<where>
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<if test="startDate !=null ">
and start_time &gt;= UNIX_TIMESTAMP(#{startDate})*1000
</if>
<if test="endDate !=null">
and start_time &lt;= UNIX_TIMESTAMP(#{endDate})*1000
</if>
</where>
</select>
<select id="getChargingPileUseRateTrendByDay" resultType="com.ssi.entity.vo.ChargingPileUseRateTrendByDayVo">
SELECT
FROM_UNIXTIME ( start_time/1000, '%Y-%m-%d' ) AS date,
IFNULL((SUM( duration ) / 1000 / 3600 / 24 / 2),0) AS chargingPileUseRate,
IFNULL((SUM( charging_energy )),0) AS chargingEnergy,
IFNULL((SUM( duration ) / 1000 / 3600),0) AS duration
FROM
vms_charging_total
WHERE
start_time >= UNIX_TIMESTAMP(#{startTime})*1000
AND
start_time &lt;= UNIX_TIMESTAMP(#{endTime})*1000
GROUP BY
FROM_UNIXTIME ( start_time/1000, '%Y-%m-%d' )
</select>
<select id="getChargingFrequencyByVehicle" resultType="java.util.Map">
SELECT
t.vin,
v.vehicle_num AS vehicleNum,
COUNT( 1 ) / DATEDIFF( NOW( ), '2022-03-01' ) * 7 AS chargingFrequency
FROM
vms_charging_total t
LEFT JOIN vms_vehicle v on v.vin = t.vin
where v.`status`=0 and v.vehicle_type =2
GROUP BY
t.vin
ORDER BY vehicleNum
</select>
<select id="getOverallChargingFrequency" resultType="double">
SELECT
COUNT( 1 ) / DATEDIFF( NOW( ), '2020-10-01' ) * 7 / COUNT( DISTINCT vin )
FROM
vms_charging_total
</select>
<select id="queryChargingTimes" resultType="java.lang.Integer">
select count(1) from vms_charging_total
<where>
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<if test="startDate !=null ">
and start_time &gt;= UNIX_TIMESTAMP(#{startDate})*1000
</if>
<if test="endDate !=null">
and start_time &lt;= UNIX_TIMESTAMP(#{endDate})*1000
</if>
</where>
</select>
<select id="queryUsedEnergy" resultType="java.lang.Double">
select SUM(energy_consumption) from vms_vehicle_energy
<where>
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<if test="startDate !=null ">
and `date` &gt;= DATE_FORMAT(#{startDate},'%Y%m%d')
</if>
<if test="endDate !=null">
and `date` &lt;= DATE_FORMAT(#{endDate},'%Y%m%d')
</if>
</where>
</select>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsCranePadBindMapper">
<resultMap type="com.ssi.entity.VmsCranePadBind" id="vmsCranePadBindMap">
<result property="id" column="id"/>
<result property="craneNo" column="crane_no"/>
<result property="padNo" column="pad_no"/>
<result property="padMac" column="pad_mac"/>
<result property="lockAreaId" column="lock_area_id"/>
<result property="lockAreaNo" column="lock_area_no"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<update id="clearByAreaNo">
update vms_crane_pad_bind set lock_area_id = null,lock_area_no = null where lock_area_no = #{0}
</update>
<update id="updateByIds">
update vms_crane_pad_bind set lock_area_id = #{lockAreaId} , lock_area_no = #{lockAreaNo} where crane_no in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsDebugAppMapper">
<select id="getKey" resultType="java.lang.String">
select param_value from ${adminDatabaseName}.config where param_key = #{debugAppKey}
</select>
<select id="updateKey">
<if test="flag == true">
update ${adminDatabaseName}.config set param_value = #{key} where param_key = #{debugAppKey}
</if>
<if test="flag == false">
insert into ${adminDatabaseName}.config (param_key,param_value,remark)
values(#{debugAppKey},#{key},'调试APP密钥')
</if>
</select>
<select id="getDistance" resultType="java.lang.String">
select param_value from ${adminDatabaseName}.config where param_key = #{debugAppDistance}
</select>
<select id="updateDiStance">
<if test="flag == true">
update ${adminDatabaseName}.config set param_value = #{distance} where param_key = #{debugAppDistance}
</if>
<if test="flag == false">
insert into ${adminDatabaseName}.config (param_key,param_value,remark)
values(#{debugAppDistance},#{distance},'遥控接管最大距离')
</if>
</select>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsElectAlertInfoMapper">
<resultMap id="BaseResultMap" type="com.ssi.entity.VmsElectAlertInfo">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="vin" column="vin" jdbcType="VARCHAR"/>
<result property="vehicleId" column="vehicle_id" jdbcType="VARCHAR"/>
<result property="regionId" column="region_id" jdbcType="INTEGER"/>
<result property="regionName" column="region_name" jdbcType="VARCHAR"/>
<result property="enterOutStatus" column="enter_out_status" jdbcType="INTEGER"/>
<result property="enterSpeed" column="enter_speed" jdbcType="DOUBLE"/>
<result property="enterLon" column="enter_lon" jdbcType="DOUBLE"/>
<result property="enterLat" column="enter_lat" jdbcType="DOUBLE"/>
<result property="enterTime" column="enter_time" jdbcType="VARCHAR"/>
<result property="enterLocation" column="enter_location" jdbcType="VARCHAR"/>
<result property="fenceType" column="fence_type" jdbcType="INTEGER"/>
<result property="centerpoint" column="centerPoint" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,vin,vehicle_id,
region_id,region_name,enter_out_status,
enter_speed,enter_lon,enter_lat,
enter_time,enter_location,fence_type,
centerPoint,create_time
</sql>
</mapper>
<?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.ssi.mapper.VehicleEmergencyMapper">
<select id="getEmergencyRecordList" resultType="com.ssi.entity.vo.VmsVehicleEmergencyVo">
SELECT t1.`id` AS id,t1.`vin` AS vin,t1.`receive_time` AS receiveTime,
t1.`feedback_time` AS feedbackTime,t2.`receive_time` AS relieveTime,
t2.`feedback_time` AS relieveSuccessTime,vv.`vehicle_num` as vehicleNum,
(CASE WHEN t2.`result` IS NOT NULL THEN t2.`result` ELSE t1.`result` END) AS result
FROM `vms_vehicle_emergency_stop` t1
LEFT JOIN vms_vehicle_emergency_stop t2
ON t1.`id` = t2.`parent_id`
LEFT JOIN `vms_vehicle` vv
ON t1.`vin` = vv.`vin`
<where>
t1.`emergency_type` = 1
<if test="param.vin != null">
and t1.vin = #{param.vin}
</if>
<if test="param.startTime != null">
and t1.receive_time >= #{param.startTime}
</if>
<if test="param.stopTime != null">
and t1.receive_time &lt;= #{param.stopTime}
</if>
<if test="param.vehicleNum != null">
and vv.vehicle_num = #{param.vehicleNum}
</if>
</where>
ORDER BY
t1.receive_time DESC
</select>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsIndividuationConfigMapper">
<resultMap id="BaseResultMap" type="com.ssi.entity.VmsIndividuationConfig">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="configKey" column="config_key" jdbcType="VARCHAR"/>
<result property="configValue" column="config_value" jdbcType="VARCHAR"/>
<result property="modelId" column="model_id" jdbcType="VARCHAR"/>
<result property="valueType" column="value_type" jdbcType="TINYINT"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,config_key,config_value,
model_id,value_type,status,
remark,create_time,update_time
</sql>
<select id="listByParent" resultType="com.ssi.entity.VmsIndividuationConfig">
select t2.* from
(select id from vms_individuation_config where config_key = #{0}) t1
left join vms_individuation_config t2 on t1.id = t2.model_id
</select>
</mapper>
<?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.ssi.mapper.VmsKpiAnalysisMapper">
<resultMap id="BaseResultMap" type="com.ssi.entity.VmsKpiAnalysis">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="vin" column="vin" jdbcType="VARCHAR"/>
<result property="vehicleTaskLabel" column="vehicle_task_label" jdbcType="TINYINT"/>
<result property="voyageNo" column="voyage_no" jdbcType="VARCHAR"/>
<result property="portCode" column="port_code" jdbcType="VARCHAR"/>
<result property="portType" column="port_type" jdbcType="TINYINT"/>
<result property="containerSize" column="container_size" jdbcType="TINYINT"/>
<result property="containerType" column="container_type" jdbcType="VARCHAR"/>
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
<result property="mileage" column="mileage" jdbcType="DOUBLE"/>
<result property="energyConsumption" column="energy_consumption" jdbcType="DOUBLE"/>
<result property="workTime" column="work_time" jdbcType="BIGINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="containerId" column="container_id" jdbcType="VARCHAR"/>
<result property="taskType" column="task_type" jdbcType="TINYINT"/>
<result property="parentTaskNo" column="parent_task_no" jdbcType="VARCHAR"/>
<result property="taskNo" column="task_no" jdbcType="VARCHAR"/>
<result property="taskNoMapping" column="task_no_mapping" jdbcType="VARCHAR"/>
<result property="standardBoxNum" column="standard_box_num" jdbcType="DOUBLE"/>
<result property="alignmentTime" column="alignment_time" jdbcType="BIGINT"/>
<result property="lockingOperationTime" column="locking_operation_time" jdbcType="BIGINT"/>
<result property="bufferWaitTime" column="buffer_wait_time" jdbcType="BIGINT"/>
<result property="otherWaitingTime" column="other_waiting_time" jdbcType="BIGINT"/>
<result property="commandWaitingTime" column="command_waiting_time" jdbcType="BIGINT"/>
<result property="workPointTime" column="work_point_time" jdbcType="BIGINT"/>
<result property="waitingPointTime" column="waiting_point_time" jdbcType="BIGINT"/>
<result property="movePointTime" column="move_point_time" jdbcType="BIGINT"/>
<result property="collectTime" column="collect_time" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
id,vin,vehicle_task_label,
voyage_no,port_code,port_type,
container_size,container_type,start_time,
end_time,mileage,energy_consumption,
work_time,create_time,container_id,
task_type,parent_task_no,task_no,
task_no_mapping,standard_box_num,alignment_time,
locking_operation_time,buffer_wait_time,other_waiting_time,
command_waiting_time,work_point_time,waiting_point_time,
move_point_time,collect_time
</sql>
<select id="staticsWorkTime" parameterType="com.ssi.entity.vo.KpiCostTimeVo" resultType="com.alibaba.fastjson.JSONObject">
SELECT
vv.vehicle_num vin,
sum(if(port_type=1,if(vka.alignment_time is null,0,vka.alignment_time),0)) qcTime,
sum(if(port_type=2,0,if(vka.alignment_time is null,0,vka.alignment_time))) rtgTime,
sum(if(vehicle_task_label=1 and task_type=4,if(vka.locking_operation_time is null,0,vka.locking_operation_time),0)) unlockTime,
sum(if(vka.buffer_wait_time is null ,0,vka.buffer_wait_time)) cacheTime,
sum(if(vka.other_waiting_time is null,0,vka.other_waiting_time)) otherTime,
sum(if(vka.command_waiting_time is null,0,vka.command_waiting_time)) orderTime,
sum(if((vka.vehicle_task_label=1 and vka.port_type=2) or (vka.vehicle_task_label=2 and vka.port_type=1),vka.work_point_time,0)) getBoxWorkTime,
sum(if((vka.vehicle_task_label=1 and vka.port_type=1) or (vka.vehicle_task_label=2 and vka.port_type=2),vka.work_point_time,0)) putBoxWorkTime,
sum(if((vka.vehicle_task_label=1 and vka.port_type=2) or (vka.vehicle_task_label=2 and vka.port_type=1),vka.waiting_point_time,0)) getBoxWaitTime,
sum(if((vka.vehicle_task_label=1 and vka.port_type=1) or (vka.vehicle_task_label=2 and vka.port_type=2),vka.waiting_point_time,0)) putBoxWaitTime,
sum(if((vka.vehicle_task_label=1 and vka.port_type=1) or (vka.vehicle_task_label=2 and vka.port_type=2),vka.move_point_time,0)) putBoxMoveTime
FROM
vms_kpi_analysis vka
left join vms_vehicle vv on vv.vin = vka.vin
<where>
<if test="startTime != null">
AND vka.start_time &gt;= #{startTime}
</if>
<if test="endTime != null">
AND vka.start_time &lt;= #{endTime}
</if>
<if test="vehicleTaskLabel != null">
AND vka.vehicle_task_label = #{vehicleTaskLabel}
</if>
<if test="containerSize != null">
AND vka.container_size = #{containerSize}
</if>
<if test="portCode != null and portCode !=''">
AND vka.port_code = #{portCode}
</if>
<if test="vin != null and vin !=''">
AND vka.vin = #{vin}
</if>
<if test="voyageNo != null and voyageNo !=''">
AND vka.voyage_no = #{voyageNo}
</if>
</where>
GROUP BY
vin
</select>
<select id="taskAnalysis" parameterType="com.ssi.entity.vo.KpiCostTimeVo" resultMap="BaseResultMap">
SELECT
id,vin,vehicle_task_label,voyage_no,port_code,port_type,
container_size,container_type,start_time,end_time,mileage,energy_consumption,
round(work_time/60000,2) work_time,create_time,container_id,task_type,parent_task_no,task_no,
task_no_mapping,standard_box_num,round(alignment_time/60000,2) alignment_time,
round(locking_operation_time/60000,2) locking_operation_time,round(buffer_wait_time/60000,2) buffer_wait_time,
round(other_waiting_time/60000,2) other_waiting_time,
round(command_waiting_time/60000,2) command_waiting_time,round(work_point_time/60000,2) work_point_time,round(waiting_point_time/60000,2) waiting_point_time,
round(move_point_time/60000,2) move_point_time,collect_time
FROM
vms_kpi_analysis vka
<where>
<if test="vehicleTaskLabels !=null and vehicleTaskLabels.size()>0">
vka.vehicle_task_label in
<foreach collection="vehicleTaskLabels" item="item" separator="," open="(" close=")" index="index">
#{item}
</foreach>
</if>
<if test="vins != null and vins.size()>0">
and vka.vin in
<foreach collection="vins" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="startTime != null">
AND vka.start_time &gt;= #{startTime}
</if>
<if test="endTime != null">
AND vka.start_time &lt;= #{endTime}
</if>
<if test="vehicleTaskLabel != null">
AND vka.vehicle_task_label = #{vehicleTaskLabel}
</if>
<if test="containerSize != null">
AND vka.container_size = #{containerSize}
</if>
<if test="portCode != null and portCode !=''">
AND vka.port_code = #{portCode}
</if>
<if test="vin != null and vin !=''">
AND vka.vin = #{vin}
</if>
<if test="voyageNo != null and voyageNo !=''">
AND vka.voyage_no like CONCAT('%',#{voyageNo},'%')
</if>
</where>
order by collect_time asc;
</select>
<select id="staticsSpeciParam" parameterType="com.ssi.entity.vo.KpiCostTimeVo" resultMap="BaseResultMap">
select round(sum(vka.energy_consumption),2) energy_consumption, round(sum(work_time)/3600000,2) work_time,round(sum(mileage)/1000,2) mileage
from vms_kpi_analysis vka
<where>
<if test="startTime != null">
AND vka.start_time &gt;= #{startTime}
</if>
<if test="endTime != null">
AND vka.start_time &lt;= #{endTime}
</if>
<if test="vin != null and vin !=''">
AND vka.vin = #{vin}
</if>
<if test="vins != null and vins.size()>0">
and vka.vin in
<foreach collection="vins" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="getTaskTrend" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
vms_kpi_analysis vka
<where>
<if test="startTime != null">
AND vka.collect_time &gt;= #{startTime}
</if>
<if test="endTime != null">
AND vka.collect_time &lt;= #{endTime}
</if>
</where>
order by vka.collect_time asc;
</select>
<select id="getVoyageNo" resultType="java.lang.String">
select distinct voyage_no from vms_kpi_analysis order by voyage_no desc
</select>
</mapper>
<?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.ssi.mapper.VmsPositionInfoMapper">
<resultMap id="BaseResultMap" type="com.ssi.entity.VmsPositionInfo">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="positionType" column="position_type" jdbcType="VARCHAR"/>
<result property="yardNum" column="yard_num" jdbcType="VARCHAR"/>
<result property="bayNum" column="bay_num" jdbcType="VARCHAR"/>
<result property="containerSize" column="container_size" jdbcType="BOOLEAN"/>
<result property="containerPosition" column="container_position" jdbcType="BOOLEAN"/>
<result property="latitude" column="latitude" jdbcType="DOUBLE"/>
<result property="longitude" column="longitude" jdbcType="DOUBLE"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="version" column="version" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id,position_type,yard_num,
bay_num,container_size,container_position,
latitude,longitude,create_time,
update_time,version
</sql>
</mapper>
<?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.ssi.mapper.VehicleRemoteInstructionMapper">
<select id="getRemoteInstructionList" resultType="com.ssi.entity.vo.VmsVehicleRemoteInstructionVo">
SELECT t.id,t.`instruction_type` AS instructionType,t.`instruction`,t.`result`,t.`instruction_content` instructionContent,
vv.`vehicle_num` AS vehicleNum,app.`remark` AS operator,t.`create_time` AS createTime
FROM `vms_vehicle_remote_instruction` t
LEFT JOIN `vms_vehicle` vv ON t.`vin` = vv.`vin`
LEFT JOIN `vms_debug_app` app ON t.`mac` = app.`app_mac`
<where>
<if test="param.vin != null">
and t.vin = #{param.vin}
</if>
<if test="param.startTime != null">
and t.create_time >= #{param.startTime}
</if>
<if test="param.stopTime != null">
and t.create_time &lt;= #{param.stopTime}
</if>
<if test="param.vehicleNum != null">
and vv.vehicle_num = #{param.vehicleNum}
</if>
<if test="param.result != null">
and t.result = #{param.result}
</if>
<if test="param.instructionType != null">
and t.instruction_type = #{param.instructionType}
</if>
</where>
ORDER BY
t.create_time DESC
</select>
<select id="getAppChargedTask" resultType="java.lang.String">
SELECT
distinct task_id
FROM
vms_vehicle_remote_instruction
WHERE
instruction_type = 'APP'
AND result = 1
AND task_id IS NOT NULL
</select>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsShipsDrawingMapper">
<!-- 查询有多少贝位 -->
<select id="queryShipDrawByCode" resultType="com.ssi.entity.VmsShipsDrawing" >
SELECT t.BAY_NO ,t.ship_cod FROM tos_ship_map t WHERE t.SHIP_COD = #{params.shipCod}
<if test="params.bayNo != null">
and t.BAY_NO = #{params.bayNo}
</if>
GROUP BY t.BAY_NO ,t.ship_cod
</select>
<select id="queryShipWorkBay" resultType="java.lang.String" >
SELECT DISTINCT SUBSTR(BAY_NO, 1,3) BAY_NO FROM TOS_SHIP_NCL tsn WHERE tsn.VOYAGE_NO = #{voyageNo}
</select>
<!-- 根据船代码,甲板类型,贝位,分别查询有多少层 -->
<select id="queryShipDrawBylayNo" resultType="com.ssi.entity.VmsShipsDrawing" >
SELECT t.LAY_NO FROM tos_ship_map t WHERE t.SHIP_COD = #{shipCod} AND t.DECK_ID= #{deck} AND T.bay_no= #{bayNo} GROUP BY t.LAY_NO order by t.lay_no desc
</select>
<!-- 根据船代码,甲板类型,贝位,层分别查询有多少槽 -->
<select id="queryShipDrawByRowNo" resultType="com.ssi.entity.VmsShipsDrawing" >
SELECT t.ROW_NO FROM tos_ship_map t WHERE t.SHIP_COD = #{shipCod} AND t.DECK_ID= #{deck} AND T.bay_no= #{bayNo} and T.lay_no= #{layNo} GROUP BY t.ROW_NO
</select>
<!--根据箱体代码查询箱体信息 附带强制状态 -->
<select id="queryShipNclByShortBayNo" resultType="com.ssi.entity.VmsShipNcl" >
SELECT tsn.*, dag.allow_flag from (
(SELECT t.* FROM TOS_SHIP_NCL t WHERE t.VOYAGE_NO =#{voyageNo} and t.bay_no like '${shortBayNo}%') tsn
LEFT JOIN
dcv_allow_go_ship_lane_tx dag
ON tsn.SHIP_NO = dag.SHIP_NO AND tsn.BAY_NO = dag.BAY_NO)
</select>
<!-- 根据箱体代码查询箱体信息 -->
<select id="queryShipNcl" resultType="com.ssi.entity.VmsShipNcl" >
SELECT tl.VOYAGE_NO as voyageNo,
tl.SHIP_NO as shipNo,
tl.CNTR as cntr,
tl.CNTR_CLASS as cntrClass,
tl.CNTR_SIZ_COD as cntrSizCod,
tl.CNTR_TYP_COD as cntrTypCod,
tl.CNTR_CORP_COD as cntrCorpCod,
tl.TRANS_PORT_COD as cntrCorpCod,
tl.CNTR_PLAC as cntrPlac ,
tl.BAY_NO as bayNo,
tl.COMM_STATUS as commStatus
FROM TOS_SHIP_NCL tl where tl.VOYAGE_NO =#{voyageNo} and tl.bay_no in
(SELECT concat(concat(t.bay_no,t.lay_no),row_no) FROM TOS_SHIP_MAP t where t.ship_cod= #{shipCod} and t.bay_no= #{bayNo} )
</select>
<select id="queryShipNclByCntr" resultType="com.ssi.entity.VmsShipNcl" >
SELECT tl.VOYAGE_NO as voyageNo,
tl.SHIP_NO as shipNo,
tl.CNTR as cntr,
tl.CNTR_CLASS as cntrClass,
tl.CNTR_SIZ_COD as cntrSizCod,
tl.CNTR_TYP_COD as cntrTypCod,
tl.CNTR_CORP_COD as cntrCorpCod,
tl.TRANS_PORT_COD as cntrCorpCod,
tl.CNTR_PLAC as cntrPlac ,
tl.BAY_NO as bayNo,
tl.COMM_STATUS as commStatus
FROM TOS_SHIP_NCL tl where tl.cntr = #{cntr}
<!-- <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach> -->
</select>
<select id="queryshipInfoList" resultType="com.ssi.entity.VmsShipInfo">
select t.* from TOS_SHIP_INFO t
<where>
1=1
<if test="params.voyageNo != null">
and t.voyage_no LIKE CONCAT(CONCAT('%',#{params.voyageNo}),'%')
</if>
<if test="params.shipCod != null">
and t.SHIP_COD LIKE CONCAT(CONCAT('%',#{params.shipCod}),'%')
</if>
<if test="params.berthCod != null">
and t.berth_cod =#{params.berthCod}
</if>
<if test="params.shipStatId != null">
and t.ship_stat_id =#{params.shipStatId}
</if>
</where>
order by t.eta asc
</select>
<select id="cableList" resultType="com.ssi.entity.VmsCable">
select t.* from c_cable t order by cast(cable_cod as int) asc
</select>
<select id="queryshipInfoCoor" resultType="com.ssi.entity.VmsShipInfo">
select t.*,
(select c.coor from cable_coor c where cast(c.cable_cod as int)=cast(t.beg_cable as int)) begcoor ,
(select c.coor from cable_coor c where cast(c.cable_cod as int)=cast(t.end_cable as int)) endcoor ,
(cast(t.beg_cable as int)+cast(t.end_cable as int))/2 cenCable,
(select c.coor from cable_coor c where c.cable_cod= ceil((cast(t.end_cable as int)+cast(t.beg_cable as int))/2)) centercoor
from tos_ship_info t where t.ship_stat_id='Y'
</select>
<update id ="updateShipTx" parameterType="com.ssi.entity.DcvAllowGoShipLaneTx" >
UPDATE Dcv_Allow_Go_Ship_Lane_Tx d SET ALLOW_FLAG= #{allowFlag} where SHIP_NO= #{shipNo} and CNTR= #{cntr} and BAY_NO= #{bayNo}
</update>
<insert id ="saveShipTx" parameterType="com.ssi.entity.DcvAllowGoShipLaneTx" >
INSERT INTO Dcv_Allow_Go_Ship_Lane_Tx (SHIP_NO,CNTR,BAY_NO,ALLOW_FLAG,REC_USER)
values( #{shipNo}, #{cntr}, #{bayNo}, #{allowFlag}, #{recUser} )
</insert>
<insert id="saveBatch" parameterType="java.util.List" >
MERGE INTO Dcv_Allow_Go_Ship_Lane_Tx T
USING (
<foreach collection="list" item="item" index="index" separator="union" >
select
#{item.shipNo} as SHIP_NO, #{item.cntr} as CNTR, #{item.bayNo} as BAY_NO, #{item.allowFlag} as ALLOW_FLAG, #{item.recUser} as REC_USER FROM DUAL
</foreach>) T1
ON (T1.SHIP_NO= T.SHIP_NO AND T1.CNTR= T.CNTR and T1.BAY_NO=T.BAY_NO)
WHEN MATCHED THEN
UPDATE SET T.ALLOW_FLAG=T1.ALLOW_FLAG
WHEN NOT MATCHED THEN
INSERT
(SHIP_NO,CNTR,BAY_NO,ALLOW_FLAG,REC_USER)
VALUES
(T1.SHIP_NO,T1.CNTR,T1.BAY_NO,T1.ALLOW_FLAG,T1.REC_USER)
</insert>
<select id="findShipNcl" resultType="com.ssi.entity.VmsShipNcl" >
SELECT tl.VOYAGE_NO as voyageNo,
tl.SHIP_NO as shipNo,
tl.CNTR as cntr,
tl.CNTR_CLASS as cntrClass,
tl.CNTR_SIZ_COD as cntrSizCod,
tl.CNTR_TYP_COD as cntrTypCod,
tl.CNTR_CORP_COD as cntrCorpCod,
tl.TRANS_PORT_COD as cntrCorpCod,
tl.CNTR_PLAC as cntrPlac ,
tl.BAY_NO as bayNo,
tl.COMM_STATUS as commStatus
FROM TOS_SHIP_NCL tl where tl.VOYAGE_NO = #{voyageNo}
</select>
<select id="findShipMap" resultType="com.ssi.entity.VmsShipsDrawing" >
select * from TOS_SHIP_MAP t where t.ship_cod= #{shipCod} and t.bay_no= #{bayNo}
</select>
<!-- 查龙门吊堆场的视图 -->
<select id="getPileInfo" resultType="java.util.HashMap" >
select * from DCV_CY_AREA_MACH_VW where MACH_NO= #{portCode}
</select>
<!-- 查指定船、指定桥吊下 正在作业的贝位 -->
<select id="getShipWorkingBay" resultType="java.lang.String" >
select f_get_ops_bay_no(#{voyageNo},#{portCode}) from dual
</select>
<!-- 删除贝位设置 -->
<delete id="deleteBatch">
delete from DCV_ALLOW_GO_SHIP_LANE_TX where
<foreach collection="list" item="item" index="index" separator="or" open="(" close=")">
SHIP_NO= #{item.shipNo} AND CNTR= #{item.cntr} and BAY_NO=#{item.bayNo}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsTosOrdersAnalysisMapper">
<resultMap type="com.ssi.entity.VmsTosOrdersAnalysis" id="vmsTosOrdersAnalysisMap">
<result property="id" column="id"/>
<result property="vin" column="vin"/>
<result property="analysisDate" column="analysis_date"/>
<result property="loadContainerNum" column="load_container_num"/>
<result property="unloadContainerNum" column="unload_container_num"/>
<result property="handleContainerNum" column="handle_container_num"/>
<result property="loadContainerTime" column="load_container_time"/>
<result property="unloadContainerTime" column="unload_container_time"/>
<result property="handleContainerTime" column="handle_container_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="getTaskTrendByDay" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
analysis_date AS date,
SUM( load_container_num ) AS loadContainerNum,
SUM( unload_container_num ) AS unloadContainerNum,
SUM( handle_container_num ) AS handleContainerNum,
ROUND( SUM( load_container_time ) / 60 / SUM( load_container_num ), 2 ) AS loadContainerAvgTime,
ROUND( SUM( unload_container_time ) / 60 / SUM( unload_container_num ), 2 ) AS unloadContainerAvgTime,
ROUND( SUM( handle_container_time ) / 60 / SUM( handle_container_num ), 2 ) AS handleContainerAvgTime
FROM
`vms_tos_orders_analysis`
WHERE
analysis_date >= #{startTime}
AND
analysis_date &lt;= #{endTime}
AND
deleted = 0
GROUP BY
analysis_date
</select>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsTosOrdersMapper">
<select id="getListAsStream" resultSetType="FORWARD_ONLY" fetchSize="1000" resultType="com.ssi.entity.VmsTosOrders">
SELECT
*
FROM
vms_tos_orders t
<where>
<if test="vmsTosOrdersVo.taskType != null">
and t.task_type = #{vmsTosOrdersVo.taskType}
</if>
<if test="vmsTosOrdersVo.status != null">
and t.status = #{vmsTosOrdersVo.status}
</if>
<if test="vmsTosOrdersVo.taskNo != null and vmsTosOrdersVo.taskNo != ''">
and t.task_no like concat('%',#{vmsTosOrdersVo.taskNo},'%')
</if>
<if test="vmsTosOrdersVo.vin != null and vmsTosOrdersVo.vin != ''">
and t.vin like concat('%',#{vmsTosOrdersVo.vin},'%')
</if>
<if test="vmsTosOrdersVo.queryStartTime != null">
and t.collect_time >= #{vmsTosOrdersVo.queryStartTime}
</if>
<if test="vmsTosOrdersVo.queryEndTime != null">
or t.collect_time &lt;= #{vmsTosOrdersVo.queryEndTime}
</if>
</where>
ORDER BY t.collect_time desc
</select>
<select id="queryContainerNumByDay" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
analysis_date AS date,
SUM( load_container_num ) AS loadContainerNum,
SUM( unload_container_num ) AS unloadContainerNum,
SUM( handle_container_num ) AS handleContainerNum
FROM
`vms_tos_orders_analysis`
<where>
<if test="startTime != null">
AND analysis_date >= #{startTime}
</if>
<if test="endTime != null">
AND analysis_date &lt;= #{endTime}
</if>
AND deleted = 0
</where>
GROUP BY
analysis_date
</select>
<select id="queryContainerNum" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
IFNULL(SUM( loadContainerNum ),0) AS loadContainerNum,
IFNULL(SUM( unloadContainerNum ),0) AS unloadContainerNum,
IFNULL(SUM( handleContainerNum ),0) AS handleContainerNum
FROM
( SELECT
SUM( load_container_num ) AS loadContainerNum,
SUM( unload_container_num ) AS unloadContainerNum,
SUM( handle_container_num ) AS handleContainerNum
FROM
`vms_tos_orders_analysis`
WHERE
deleted = 0
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<if test="startDate !=null">
and date(analysis_date) &gt;= #{startDate}
</if>
<if test="endDate !=null">
and date(analysis_date) &lt;= #{endDate}
</if>
UNION ALL
SELECT
SUM( CASE WHEN (task_type = 2 and vehicle_task_label = 1) THEN container_num END ) AS loadContainerNum,
SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 2) THEN container_num END ) AS unloadContainerNum,
SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 3) THEN container_num END ) AS handleContainerNum
FROM
`vms_tos_orders`
WHERE
start_time >= curdate()
AND
deleted = 0
AND
( STATUS = 3 OR STATUS = 49 OR STATUS = 38 OR STATUS = 39 OR STATUS = 37 )
AND ( task_location_type = 1 OR task_location_type = 5 ) ) temp
</select>
<select id="queryContainerAvgTimeByDay" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
analysis_date AS date,
ifnull(ROUND( SUM( load_container_time ) / 60 / SUM( load_container_num ), 2 ) ,0) AS loadContainerAvgTime,
ifnull(ROUND( SUM( unload_container_time ) / 60 / SUM( unload_container_num ), 2 ) ,0) AS unloadContainerAvgTime,
ifnull(ROUND( SUM( handle_container_time ) / 60 / SUM( handle_container_num ), 2 ) ,0) AS handleContainerAvgTime
FROM
`vms_tos_orders_analysis`
<where>
<if test="startTime != null">
AND analysis_date >= #{startTime}
</if>
<if test="endTime != null">
AND analysis_date &lt;= #{endTime}
</if>
AND deleted = 0
</where>
GROUP BY
analysis_date
</select>
<select id="queryContainerAvgTime" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
ifnull(ROUND( SUM( load_container_time ) / 60 / SUM( load_container_num ), 2 ),0) AS loadContainerAvgTime,
ifnull(ROUND( SUM( unload_container_time ) / 60 / SUM( unload_container_num ), 2) ,0) AS unloadContainerAvgTime,
ifnull(ROUND( SUM( handle_container_time ) / 60 / SUM( handle_container_num ), 2 ),0) AS handleContainerAvgTime
FROM
`vms_tos_orders_analysis`
WHERE
deleted = 0
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<if test="startDate !=null">
and date(analysis_date) &gt;= #{startDate}
</if>
<if test="endDate !=null">
and date(analysis_date) &lt;= #{endDate}
</if>
</select>
<select id="getVehicleTrip" resultType="com.ssi.entity.VmsTosOrders">
SELECT
*
FROM vms_tos_orders
WHERE vin = #{vin}
AND
end_time IS NOT NULL
AND
(( end_time BETWEEN #{startTime} AND #{endTime} )
OR ( start_time BETWEEN #{startTime} AND #{endTime} ))
OR
( start_time &lt;= #{startTime} AND end_time >= #{endTime} )
ORDER BY
start_time DESC
</select>
<select id="getVehicleByPadMac" resultType="com.ssi.entity.vo.VehicleOrderVo">
select v.*,tmp.startTime,tmp.taskNo from vehicle v inner join
(select distinct vto.vin,vto.start_time as startTime,vto.task_no as taskNo from vms_tos_orders vto inner join vms_crane_pad_bind cpb on vto.port_code = cpb.crane_no
where cpb.pad_mac = #{padMac}) tmp on tmp.vin = v.vin
order by startTime asc
</select>
<!-- <select id="getDailyKpi" resultType="com.ssi.entity.vo.VehicleKpiVo$HourKpi">-->
<!-- SELECT-->
<!-- vin,-->
<!-- HOUR( start_time ) AS `hour`,-->
<!-- SUM( CASE WHEN (task_type = 1 and status = 37) THEN container_num END ) AS containerNum,-->
<!-- SUM( 1 ) AS orderNum,-->
<!-- SUM( CASE WHEN (status = 37) THEN 1 END ) AS finishedOrderNum-->
<!-- FROM-->
<!-- `vms_tos_orders`-->
<!-- WHERE-->
<!-- start_time >= #{startTime}-->
<!-- AND start_time &lt;= #{endTime}-->
<!-- /*任务逻辑删除,表示任务没完成被覆盖了,KPI这里不限制删除与否*/-->
<!-- /*AND deleted = 0*/-->
<!-- AND vehicle_task_label in (1,2,3)-->
<!-- GROUP BY-->
<!-- vin,HOUR ( start_time )-->
<!-- </select>-->
<select id="getDailyKpi" resultType="com.ssi.entity.vo.VehicleKpiVo$HourKpi">
SELECT
vin,
HOUR( start_time ) AS `hour`,
SUM(
(
`task_location_type` = 1
AND `vehicle_task_label` = 2
)
OR (
`task_location_type` = 5
AND `vehicle_task_label` = 1
)
) AS containerNum,
SUM( 1 ) AS orderNum,
SUM( CASE WHEN (status = 37) THEN 1 END ) AS finishedOrderNum
FROM
`vms_tos_orders`
WHERE
start_time >= #{startTime}
AND start_time &lt;= #{endTime}
/*任务逻辑删除,表示任务没完成被覆盖了,KPI这里不限制删除与否*/
AND deleted = 0
and execute_status = 1
AND vehicle_task_label in (1,2,3) AND (`task_location_type` = 5 or `task_location_type` = 1)
GROUP BY
vin,HOUR ( start_time )
</select>
<select id="getContainNum" resultType="map">
select t.vin, count(t.container_id) count from
(SELECT
t.`vin`,
t.`container_id`
FROM
`vms_tos_orders` t
WHERE
start_time >= #{startTime}
AND start_time &lt;= #{endTime}
AND (
(
t.`task_location_type` = 1
AND t.`vehicle_task_label` = 2
)
OR (
t.`task_location_type` = 5
AND t.`vehicle_task_label` = 1
)
)
AND deleted = 0
and execute_status = 1
-- AND t.task_source = 1
GROUP BY
t.`vin`,
t.`container_id`) t
GROUP BY t.vin;
</select>
<select id="getTaskTrendByDay" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
CONVERT( start_time, date ) AS date,
SUM( CASE WHEN (task_type = 2 and vehicle_task_label = 1) THEN container_num END ) AS loadContainerNum,
SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 2) THEN container_num END ) AS unloadContainerNum,
SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 3) THEN container_num END ) AS handleContainerNum,
ROUND(
SUM( CASE WHEN ( vehicle_task_label = 1 ) THEN TIMESTAMPDIFF( MINUTE, start_time, end_time ) END ) / SUM( CASE WHEN ( task_type = 2 AND vehicle_task_label = 1 ) THEN container_num END ),
2
) AS loadContainerAvgTime,
ROUND(
SUM( CASE WHEN ( vehicle_task_label = 2 ) THEN TIMESTAMPDIFF( MINUTE, start_time, end_time ) END ) / SUM( CASE WHEN ( task_type = 1 AND vehicle_task_label = 2 ) THEN container_num END ),
2
) AS unloadContainerAvgTime,
ROUND(
SUM( CASE WHEN ( vehicle_task_label = 3 ) THEN TIMESTAMPDIFF( MINUTE, start_time, end_time ) END ) / SUM( CASE WHEN ( task_type = 1 AND vehicle_task_label = 3 ) THEN container_num END ),
2
) AS handleContainerAvgTime
FROM
`vms_tos_orders`
WHERE
start_time >= #{startTime}
AND
start_time &lt;= #{endTime}
AND
deleted = 0
AND
status = 37
GROUP BY
CONVERT ( start_time, date )
</select>
<select id="getTaskTrendByHour" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
HOUR( start_time ) AS hour,
SUM( CASE WHEN (task_type = 2 and vehicle_task_label = 1) THEN container_num END ) AS loadContainerNum,
SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 2) THEN container_num END ) AS unloadContainerNum,
SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 3) THEN container_num END ) AS handleContainerNum,
ROUND(
SUM( CASE WHEN ( vehicle_task_label = 1 ) THEN TIMESTAMPDIFF( SECOND, start_time, end_time ) END ) / 60 / SUM( CASE WHEN ( task_type = 2 AND vehicle_task_label = 1 ) THEN container_num END ),
2
) AS loadContainerAvgTime,
ROUND(
SUM( CASE WHEN ( vehicle_task_label = 2 ) THEN TIMESTAMPDIFF( SECOND, start_time, end_time ) END ) / 60 / SUM( CASE WHEN ( task_type = 1 AND vehicle_task_label = 2 ) THEN container_num END ),
2
) AS unloadContainerAvgTime,
ROUND(
SUM( CASE WHEN ( vehicle_task_label = 3 ) THEN TIMESTAMPDIFF( SECOND, start_time, end_time ) END ) / 60 / SUM( CASE WHEN ( task_type = 1 AND vehicle_task_label = 3 ) THEN container_num END ),
2
) AS handleContainerAvgTime
FROM
`vms_tos_orders`
WHERE
collect_time >= #{startTimeStamp}
AND
start_time >= #{startTime}
AND
start_time &lt;= #{endTime}
AND
deleted = 0
AND
(task_location_type = 1 OR task_location_type = 5)
AND
(status=3 OR status=49 OR status=38 OR status=39 OR status=37)
GROUP BY
HOUR ( start_time )
</select>
<select id="getTaskNumTimeByDay" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
CONVERT( start_time, date ) AS date,
vin,
SUM( CASE WHEN (task_type = 2 and vehicle_task_label = 1) THEN container_num END ) AS loadContainerNum,
SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 2) THEN container_num END ) AS unloadContainerNum,
SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 3) THEN container_num END ) AS handleContainerNum,
SUM( CASE WHEN ( vehicle_task_label = 1 ) THEN TIMESTAMPDIFF( SECOND, start_time, end_time ) END ) AS loadContainerTime,
SUM( CASE WHEN ( vehicle_task_label = 2 ) THEN TIMESTAMPDIFF( SECOND, start_time, end_time ) END ) AS unloadContainerTime,
SUM( CASE WHEN ( vehicle_task_label = 3 ) THEN TIMESTAMPDIFF( SECOND, start_time, end_time ) END ) AS handleContainerTime
FROM
`vms_tos_orders`
WHERE
collect_time >= #{startTimeStamp}
AND
start_time >= #{startTime}
AND
start_time &lt; #{endTime}
AND
deleted = 0
AND
(task_location_type = 1 OR task_location_type = 5)
AND
(status=3 OR status=49 OR status=38 OR status=39 OR status=37)
GROUP BY
CONVERT ( start_time, date ),
vin
</select>
<!-- 任务KPI-效率OEE分析 -->
<select id="taskKPI" resultType="com.ssi.entity.vo.TaskKPIVo">
SELECT
b.task_no as taskNo,
a.vin,
a.vehicle_num as vehicleNum,
FROM_UNIXTIME(b.collect_time/1000,'%Y-%m-%d %H:%i:%s') AS instructionWaitingTime,
IFNULL(SUM(container_num),0) AS boxQuantity
FROM
vms_vehicle AS a
LEFT JOIN vms_tos_orders AS b ON a.vin = b.vin
<where>
b.deleted=0
<if test="vmsTosOrders.taskType != null"> <!-- 作业类型 -->
and b.task_type = #{vmsTosOrders.taskType}
</if>
<if test="vmsTosOrders.containerSize != null"><!-- 箱尺寸 -->
and b.container_size = #{vmsTosOrders.containerSize}
</if>
<if test="vmsTosOrders.vin != null and vmsTosOrders.vin != ''">
and a.vin like concat('%',#{vmsTosOrders.vin},'%')
</if>
<if test="vmsTosOrders.portCode != null"><!-- 岸桥编号 -->
and b.port_code = #{vmsTosOrders.portCode}
</if>
<if test="nowStartTime != null and nowEndTime != null">
<!-- 三天前的数据,不含今天 -->
<!-- and DATE_SUB(DATE_SUB(CURDATE(), INTERVAL 1 DAY),INTERVAL 3 DAY) &lt;= DATE(FROM_UNIXTIME(b.collect_time/1000)) -->
and b.collect_time &lt; #{nowStartTime} and b.collect_time > #{nowEndTime}
</if>
<if test="vmsTosOrders.startTime != null and vmsTosOrders.endTime != null">
and b.collect_time >= #{vmsTosOrders.startTime} and b.collect_time &lt;= #{vmsTosOrders.endTime}
</if>
</where>
GROUP BY
a.vin
</select>
<select id="queryPageByAllStatus" resultType="com.ssi.entity.dto.VmsTosOrdersDto">
SELECT t.`vin`,t.`task_no` as taskNo,t.`start_time` as startTime,t.`end_time` as endTime,t.`status`,
t.`port_code` as portCode,t.`port_type` as portType,t.`task_source` as taskSource,
t.`container_size` as containerSize,t.`vehicle_task_label` as vehicleTaskLabel,
t.`container_id` as containerId,t.`container_weight` as containerWeight,
t.`container_size` as containerSize,t.`container_num` as containerNum,
t.`vehicle_location` as vehicleLocation,t.collect_time as collectTime,
t.task_location_type as taskLocationType,
case when vvri.taskNo is null then 0 else 1 end appControl
FROM (
select * from `vms_tos_orders` where deleted = 0 and execute_status = 1 AND `vehicle_task_label` in (1,2,3) AND `task_location_type` IN (1,5)
<if test="ordersVo.queryStartTime != null and ordersVo.queryEndTime != null">
and collect_time >= unix_timestamp(#{ordersVo.queryStartTime})*1000
and collect_time &lt;= unix_timestamp(#{ordersVo.queryEndTime})*1000
</if>
) t
LEFT JOIN vms_vehicle v ON t.vin = v.vin
LEFT JOIN (
SELECT DISTINCT
SUBSTRING_INDEX(task_id, ',', 1) taskNo,
SUBSTRING_INDEX(task_id, ',', -1) taskNoMapping
FROM vms_vehicle_remote_instruction
WHERE instruction_type = 'APP' AND result = 1 AND task_id IS NOT NULL
) vvri ON t.task_no = vvri.taskNo AND t.task_no_mapping = vvri.taskNoMapping
<where>
<if test="ordersVo.vehicleNum != null and ordersVo.vehicleNum != ''">
and v.vehicle_num = #{ordersVo.vehicleNum}
</if>
</where>
ORDER BY t.vin,t.`collect_time` ASC;
</select>
<select id="pageQuery" resultType="com.ssi.entity.VmsTosOrders">
select * from (
SELECT
vto.*, case when vvri.taskNo is null then 0 else 1 end appControl
FROM
(
SELECT * FROM vms_tos_orders
<where>
deleted = 0
and execute_status = 1
<if test="ordersVo.taskType != null">
and task_type = #{ordersVo.taskType}
</if>
<if test="ordersVo.status != null">
and status = #{ordersVo.status}
</if>
<if test="ordersVo.taskNo != null and ordersVo.taskNo != ''">
and task_no like concat('%',#{ordersVo.taskNo},'%')
</if>
<if test="ordersVo.vin != null and ordersVo.vin != ''">
and vin like concat('%',#{ordersVo.vin},'%')
</if>
<if test="ordersVo.queryStartTime != null">
and start_time &gt;= #{ordersVo.queryStartTime}
</if>
<if test="ordersVo.queryEndTime != null">
and start_time &lt;= #{ordersVo.queryEndTime}
</if>
<if test="ordersVo.taskSource != null">
and task_source = #{ordersVo.taskSource}
</if>
<if test="ordersVo.vehicleTaskLabels!=null and ordersVo.vehicleTaskLabels.size()>0">
and vehicle_task_label in
<foreach collection="ordersVo.vehicleTaskLabels" separator="," open="(" close=")" item="item" >
#{item}
</foreach>
</if>
</where>
) vto
LEFT JOIN (
SELECT DISTINCT
SUBSTRING_INDEX(task_id, ',', 1) taskNo,
SUBSTRING_INDEX(task_id, ',', -1) taskNoMapping
FROM
vms_vehicle_remote_instruction
WHERE
instruction_type = 'APP'
AND result = 1
AND task_id IS NOT NULL
) vvri ON vto.task_no = vvri.taskNo
AND vto.task_no_mapping = vvri.taskNoMapping
) tt
<where>
<if test="ordersVo.appControl != null">
tt.appControl = #{ordersVo.appControl}
</if>
</where>
order by tt.collect_time desc
</select>
<select id="queryOrderNum" resultType="com.ssi.entity.vo.TaskAnalysisVo">
SELECT
ifnull(SUM( CASE WHEN (task_type = 2 and vehicle_task_label = 1) THEN 1 END ),0) AS loadContainerNum,
ifnull(SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 2) THEN 1 END ),0) AS unloadContainerNum,
ifnull(SUM( CASE WHEN (task_type = 1 and vehicle_task_label = 3) THEN 1 END ),0) AS handleContainerNum
FROM
`vms_tos_orders`
WHERE deleted = 0
AND
( STATUS = 3 OR STATUS = 49 OR STATUS = 38 OR STATUS = 39 OR STATUS = 37 )
AND ( task_location_type = 1 OR task_location_type = 5 )
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<if test="startDate !=null">
and collect_time &gt;= UNIX_TIMESTAMP(#{startDate})*1000
</if>
<if test="endDate !=null">
and collect_time &lt;= UNIX_TIMESTAMP(#{endDate})*1000
</if>
</select>
<select id="queryOrderNumByDate" resultType="java.lang.Integer">
SELECT
count(1) orderNum
FROM
`vms_tos_orders`
WHERE deleted = 0
AND
( STATUS = 3 OR STATUS = 49 OR STATUS = 38 OR STATUS = 39 OR STATUS = 37 )
<choose>
<when test="totalType == 2">
and task_type = 1 and vehicle_task_label = 1 and task_location_type = 5
</when>
<when test="totalType == 3">
and task_type = 2 and vehicle_task_label = 2 and task_location_type = 1
</when>
<when test="totalType == 4">
and task_type = 1 and vehicle_task_label = 3 and task_location_type = 1
</when>
</choose>
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<choose>
<when test="flag != 1">
and FROM_UNIXTIME(collect_time/1000,'%Y-%m-%d') = #{startDate}
</when>
<otherwise>
and FROM_UNIXTIME(collect_time/1000,'%Y%m%d%h') = #{startDate}
</otherwise>
</choose>
</select>
<select id="staticsAppCaveOrdersByDate" resultType="java.lang.Integer">
SELECT
count(1) orderNum
FROM
`vms_tos_orders` t
left join (
SELECT DISTINCT
SUBSTRING_INDEX(task_id, ',', 1) taskNo,
SUBSTRING_INDEX(task_id, ',', -1) taskNoMapping
FROM
vms_vehicle_remote_instruction
WHERE
instruction_type = 'APP'
and result = 1
and task_id IS NOT NULL
) vvri ON t.task_no = vvri.taskNo and t.task_no_mapping = vvri.taskNoMapping
WHERE
vvri.taskNo is not null
and t.deleted = 0
and
( t.STATUS = 3 OR t.STATUS = 49 OR t.STATUS = 38 OR t.STATUS = 39 OR t.STATUS = 37 )
<choose>
<when test="totalType == 2">
and t.task_type = 1 and t.vehicle_task_label = 1 and t.task_location_type = 5
</when>
<when test="totalType == 3">
and t.task_type = 2 and t.vehicle_task_label = 2 and t.task_location_type = 1
</when>
<when test="totalType == 4">
and t.task_type = 1 and t.vehicle_task_label = 3 and t.task_location_type = 1
</when>
</choose>
<if test="vins !=null and vins.size() > 0">
and t.vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<choose>
<when test="flag != 1">
and FROM_UNIXTIME(collect_time/1000,'%Y-%m-%d') = #{startDate}
</when>
<otherwise>
and FROM_UNIXTIME(collect_time/1000,'%Y%m%d%h') = #{startDate}
</otherwise>
</choose>
</select>
<select id="staticsContainerNumsByDate" resultType="java.lang.Integer">
SELECT
sum(container_num) AS containerNum
FROM
`vms_tos_orders`
WHERE
deleted = 0
AND
( STATUS = 3 OR STATUS = 49 OR STATUS = 38 OR STATUS = 39 OR STATUS = 37 )
<choose>
<when test="totalType == 2">
and task_type = 1 and vehicle_task_label = 1 and task_location_type = 5
</when>
<when test="totalType == 3">
and task_type = 2 and vehicle_task_label = 2 and task_location_type = 1
</when>
<when test="totalType == 4">
and task_type = 1 and vehicle_task_label = 3 and task_location_type = 1
</when>
</choose>
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<choose>
<when test="flag != 1">
and FROM_UNIXTIME(collect_time/1000,'%Y-%m-%d') = #{startDate}
</when>
<otherwise>
and FROM_UNIXTIME(collect_time/1000,'%Y%m%d%h') = #{startDate}
</otherwise>
</choose>
</select>
<select id="queryTosOrderByDate" resultType="java.lang.Integer">
SELECT
count(1) orderNum
FROM
`vms_tos_orders`
WHERE deleted = 0 and task_source = 1
AND
( STATUS = 3 OR STATUS = 49 OR STATUS = 38 OR STATUS = 39 OR STATUS = 37 )
<choose>
<when test="totalType == 2">
and task_type = 1 and vehicle_task_label = 1 and task_location_type = 5
</when>
<when test="totalType == 3">
and task_type = 2 and vehicle_task_label = 2 and task_location_type = 1
</when>
<when test="totalType == 4">
and task_type = 1 and vehicle_task_label = 3 and task_location_type = 1
</when>
</choose>
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<choose>
<when test="flag != 1">
and FROM_UNIXTIME(collect_time/1000,'%Y-%m-%d') = #{startDate}
</when>
<otherwise>
and FROM_UNIXTIME(collect_time/1000,'%Y%m%d%h') = #{startDate}
</otherwise>
</choose>
</select>
<select id="queryOrdersByDate" resultType="java.lang.Integer">
select count(1) from (SELECT
task_no
FROM
`vms_tos_orders`
WHERE deleted = 0
AND
( STATUS = 3 OR STATUS = 49 OR STATUS = 38 OR STATUS = 39 OR STATUS = 37 )
<choose>
<when test="totalType == 2">
and task_type = 1 and vehicle_task_label = 1 and task_location_type = 5
</when>
<when test="totalType == 3">
and task_type = 2 and vehicle_task_label = 2 and task_location_type = 1
</when>
<when test="totalType == 4">
and task_type = 1 and vehicle_task_label = 3 and task_location_type = 1
</when>
</choose>
<if test="vins !=null and vins.size() > 0">
and vin in
<foreach collection="vins" open="(" close=")" separator="," item="item" index="index">
#{item}
</foreach>
</if>
<choose>
<when test="flag != 1">
and FROM_UNIXTIME(collect_time/1000,'%Y-%m-%d') = #{startDate}
</when>
<otherwise>
and FROM_UNIXTIME(collect_time/1000,'%Y%m%d%h') = #{startDate}
</otherwise>
</choose>
group by task_no
) tmp
</select>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsTosOrdersOeeMapper">
<resultMap type="com.ssi.entity.VmsTosOrdersOee" id="vmsTosOrdersOeeMap">
<result property="id" column="id"/>
<result property="vin" column="vin"/>
<result property="vehicleNum" column="vehicle_num"/>
<result property="taskNo" column="task_no"/>
<result property="taskLocationType" column="task_location_type"/>
<result property="taskType" column="task_type"/>
<result property="portType" column="port_type"/>
<result property="portCode" column="port_code"/>
<result property="vehicleTaskType" column="vehicle_task_type"/>
<result property="vehicleTaskLabel" column="vehicle_task_label"/>
<result property="containerType" column="container_type"/>
<result property="containerNum" column="container_num"/>
<result property="containerWeight" column="container_weight"/>
<result property="containerSize" column="container_size"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="collectTime" column="collect_time"/>
<result property="receiveTime" column="receive_time"/>
<result property="voyageNo" column="voyage_no"/>
<result property="instructionWaitingTime" column="instruction_waiting_time"/>
<result property="homeworkPreparationTime" column="homework_preparation_time"/>
<result property="moveTheBoxTime" column="move_the_box_time"/>
<result property="pickingTime" column="picking_time"/>
<result property="deleted" column="deleted"/>
</resultMap>
<select id="taskOee" resultType="com.ssi.entity.vo.TaskKPIVo">
SELECT
vin,
vehicle_num as vehicleNum,
ROUND( AVG( instruction_waiting_time ) / 1000 / 60 , 2 ) AS instructionWaitingTime,
ROUND( AVG( homework_preparation_time ) / 1000 / 60 , 2 ) AS homeworkPreparationTime,
ROUND( AVG( move_the_box_time ) / 1000 / 60 , 2 ) AS moveTheBoxTime,
ROUND( AVG( picking_time ) / 1000 / 60 , 2 ) AS pickingTime,
IFNULL(SUM(container_num),0) AS boxQuantity
FROM
vms_tos_orders_oee
<where>
deleted = 0
<if test="taskType != null"> <!-- 作业类型 -->
and task_type = #{taskType}
</if>
<if test="containerSize != null"><!-- 箱尺寸 -->
and container_size = #{containerSize}
</if>
<if test="vin != null and vin != ''">
and vin like concat('%',#{vin},'%')
</if>
<if test="portCode != null"><!-- 岸桥编号 -->
and port_code = #{portCode}
</if>
<if test="startTime != null">
and collect_time >= #{startTime}
</if>
<if test="endTime != null">
and collect_time &lt;= #{endTime}
</if>
</where>
GROUP BY
vehicle_num ASC
</select>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsTosOriginalOrdersMapper">
<resultMap id="BaseResultMap" type="com.ssi.entity.VmsTosOriginalOrders">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="vin" column="vin" jdbcType="VARCHAR"/>
<result property="taskNo" column="task_no" jdbcType="VARCHAR"/>
<result property="taskLocationType" column="task_location_type" jdbcType="TINYINT"/>
<result property="taskType" column="task_type" jdbcType="TINYINT"/>
<result property="vehicleTaskLabel" column="vehicle_task_label" jdbcType="TINYINT"/>
<result property="containerId" column="container_id" jdbcType="VARCHAR"/>
<result property="containerSize" column="container_size" jdbcType="TINYINT"/>
<result property="containerPosition" column="container_position" jdbcType="TINYINT"/>
<result property="containerLabel" column="container_label" jdbcType="TINYINT"/>
<result property="vehicleTaskType" column="vehicle_task_type" jdbcType="TINYINT"/>
<result property="vehicleLocation" column="vehicle_location" jdbcType="VARCHAR"/>
<result property="parentTaskNo" column="parent_task_no" jdbcType="VARCHAR"/>
<result property="seq" column="seq" jdbcType="VARCHAR"/>
<result property="voyageNo" column="voyage_no" jdbcType="VARCHAR"/>
<result property="collectTime" column="collect_time" jdbcType="BIGINT"/>
<result property="containerType" column="container_type" jdbcType="VARCHAR"/>
<result property="containerWeight" column="container_weight" jdbcType="FLOAT"/>
<result property="portCode" column="port_code" jdbcType="VARCHAR"/>
<result property="portType" column="port_type" jdbcType="TINYINT"/>
<result property="localLabel" column="local_label" jdbcType="VARCHAR"/>
<result property="taskAssociation" column="task_association" jdbcType="VARCHAR"/>
<result property="overSign" column="over_sign" jdbcType="VARCHAR"/>
<result property="cartonCondition" column="carton_condition" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
id,vin,task_no,
task_location_type,task_type,vehicle_task_label,
container_id,container_size,container_position,
container_label,vehicle_task_type,vehicle_location,
parent_task_no,seq,voyage_no,
collect_time,container_type,container_weight,
port_code,port_type,local_label,
task_association,over_sign,carton_condition
</sql>
<select id="pageQuery" resultType="com.ssi.entity.VmsTosOriginalOrders">
select * from (SELECT
vto.*, case when vvri.taskNo is null then 0 else 1 end appControl
FROM
(
SELECT t1.*,t2.start_time,t2.end_time,t2.update_time,t2.task_no_mapping,t2.task_source,t2.container_num FROM vms_tos_original_orders t1
LEFT JOIN (select vin,status,task_no,start_time,end_time,update_time,task_no_mapping,task_source,container_num from vms_tos_orders GROUP BY task_no,vin) t2
ON t2.task_no = t1.task_no AND t1.vin = t2.vin
<where>
<if test="ordersVo.taskType != null">
and t1.task_type = #{ordersVo.taskType}
</if>
<if test="ordersVo.status != null">
and t2.status = #{ordersVo.status}
</if>
<if test="ordersVo.taskNo != null and ordersVo.taskNo != ''">
and t1.task_no like concat('%',#{ordersVo.taskNo},'%')
</if>
<if test="ordersVo.vin != null and ordersVo.vin != ''">
and t1.vin like concat('%',#{ordersVo.vin},'%')
</if>
<if test="ordersVo.queryStartTime != null">
and t2.start_time >= #{ordersVo.queryStartTime}
</if>
<if test="ordersVo.queryEndTime != null">
and t2.start_time &lt;= #{ordersVo.queryEndTime}
</if>
<if test="ordersVo.taskSource != null">
and t2.task_source = #{ordersVo.taskSource}
</if>
</where>
) vto
LEFT JOIN (
SELECT DISTINCT
SUBSTRING_INDEX(task_id, ',', 1) taskNo,
SUBSTRING_INDEX(task_id, ',', -1) taskNoMapping
FROM
vms_vehicle_remote_instruction
WHERE
instruction_type = 'APP'
AND result = 1
AND task_id IS NOT NULL
) vvri ON vto.task_no = vvri.taskNo
AND vto.task_no_mapping = vvri.taskNoMapping
) tt
<where>
<if test="ordersVo.appControl != null">
tt.appControl = #{ordersVo.appControl}
</if>
</where>
order by tt.collect_time desc
</select>
</mapper>
<?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.ssi.mapper.VmsTrafficLightInfoMapper">
<resultMap id="BaseResultMap" type="com.ssi.entity.VmsTrafficLightInfo">
<id property="crossId" column="cross_id" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="enable" column="enable" jdbcType="TINYINT"/>
<result property="location" column="location" jdbcType="VARCHAR"/>
<result property="isLock" column="is_lock" jdbcType="TINYINT"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
cross_id,status,enable,
location,is_lock,update_time,update_user
</sql>
</mapper>
<?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.ssi.mapper.VehicleTroubleHistoryMapper">
<select id="getAlertHistoryList" resultType="com.ssi.entity.vo.VmsVehicleAlertHistoryVo">
SELECT
t1.id,
v.`vehicle_num` as vehicleNum,
t1.vin,
t1.fault_code,
t1.spn,
t1.fmi,
t1.trouble_status,
t1.alarm_time,
t1.relieve_alarm_time,
t1.longitude,
t1.latitude,
t1.alarm_position,
t2.describition,
t2.fault_grade,
t2.fault_name,
t2.fault_type,
t2.fault_source_type,
t2.fault_source_type_name,
t2.fault_label,
t2.fault_dm_code,
t2.fault_module,
t2.fault_reason,
t2.fault_solution
FROM
`vms_vehicle_alert_history` t1
LEFT JOIN vms_fault_code t2 ON t1.FMI = t2.FMI
AND t1.SPN = t2.SPN
left join `vms_vehicle` v on t1.`vin` = v.`vin`
<where>
t2.deleted = 0 and v.vehicle_type is not null and v.status=0
<if test="param.vins != null and param.vins.size > 0">
and t1.vin in
<foreach collection="param.vins" item="vin" open="(" close=")" separator=",">
#{vin}
</foreach>
</if>
<if test="param.startTime != null">
and t1.alarm_time >= #{param.startTime}
</if>
<if test="param.stopTime != null">
and t1.alarm_time &lt;= #{param.stopTime}
</if>
<if test="param.faultName != null">
and t2.fault_name like concat('%',#{param.faultName},'%')
</if>
<if test="param.faultGrades != null and param.faultGrades.size > 0">
and t2.fault_grade in
<foreach collection="param.faultGrades" item="faultGrade" open="(" close=")" separator=",">
#{faultGrade}
</foreach>
</if>
<if test="param.faultTypes != null and param.faultTypes.size > 0">
and t2.fault_type in
<foreach collection="param.faultTypes" item="faultType" open="(" close=")" separator=",">
#{faultType}
</foreach>
</if>
</where>
ORDER BY
t1.alarm_time DESC
</select>
<select id="getFaultTrendByHour" resultType="com.ssi.entity.vo.VmsVehicleFaultVo">
SELECT
HOUR(alarm_time) AS hour,
count(1) AS faultNum
FROM
`vms_vehicle_alert_history`
WHERE
alarm_time >= #{startTimeStamp}
AND
alarm_time >= #{startTime}
AND
alarm_time &lt;= #{endTime}
<if test="params.vehiclesNums != null and params.vehiclesNums.size > 0">
and vin in
<foreach collection="params.vehiclesNums" item="vehiclesNum" open="(" close=")" separator=",">
#{vehiclesNum}
</foreach>
</if>
GROUP BY
HOUR (alarm_time)
</select>
<select id="getFaultTrendByDay" resultType="com.ssi.entity.vo.VmsVehicleFaultVo">
SELECT
analysis_date AS date,
sum(fault_num) AS faultNum
FROM
`vms_fault_analysis_perday`
WHERE
analysis_date >= #{startTime}
AND
analysis_date &lt;= #{endTime}
<if test="params.vehiclesNums != null and params.vehiclesNums.size > 0">
and vin in
<foreach collection="params.vehiclesNums" item="vehiclesNum" open="(" close=")" separator=",">
#{vehiclesNum}
</foreach>
</if>
GROUP BY
analysis_date
</select>
<select id="getFaultDistribution" resultType="com.ssi.entity.vo.VmsVehicleFaultVo">
SELECT
max(fault_name) as faultName,
max(fault_name) as faultCode,
sum(fault_num) AS faultNum
FROM
`vms_fault_analysis_perday` t
left join `vms_vehicle` v on t.`vin` = v.`vin`
WHERE
analysis_date >= #{startTime}
AND
analysis_date &lt;= #{endTime}
AND
t.`fault_name` IS NOT NULL
<if test="params.vehiclesNums != null and params.vehiclesNums.size > 0">
and v.vehicle_num in
<foreach collection="params.vehiclesNums" item="vehiclesNum" open="(" close=")" separator=",">
#{vehiclesNum}
</foreach>
</if>
group by t.`fault_code`,t.`fmi`,t.`spn`
order by faultNum desc limit 0,10;
</select>
<select id="getFaultTypeTrendByHour" resultType="com.ssi.entity.vo.VmsVehicleFaultVo">
SELECT
HOUR(alarm_time) AS HOUR,
vfc.`fault_type` AS faultType,
COUNT(1) AS faultNum
FROM
`vms_vehicle_alert_history` t
left join `vms_fault_code` vfc on t.`fault_code` = vfc.`fault_code` and t.`spn` = vfc.`SPN` and t.`fmi`=vfc.`FMI`
left join `vms_vehicle` v on t.`vin` = v.`vin`
WHERE
alarm_time >= #{startTimeStamp}
AND
alarm_time >= #{startTime}
AND
alarm_time &lt;= #{endTime}
<if test="params.vehiclesNums != null and params.vehiclesNums.size > 0">
and v.vehicle_num in
<foreach collection="params.vehiclesNums" item="vehiclesNum" open="(" close=")" separator=",">
#{vehiclesNum}
</foreach>
</if>
AND
vfc.`fault_type` is not null
GROUP BY
HOUR (alarm_time),vfc.`fault_type`;
</select>
<select id="getFaultTypeTrendByDay" resultType="com.ssi.entity.vo.VmsVehicleFaultVo">
SELECT
t.analysis_date AS DATE,
vfc.`fault_type` as faultType,
SUM(t.fault_num) AS faultNum
FROM
`vms_fault_analysis_perday` t
left join `vms_fault_code` vfc on t.`fault_code` = vfc.`fault_code` and t.`spn` = vfc.`SPN` and t.`fmi`=vfc.`FMI`
left join `vms_vehicle` v on t.`vin` = v.`vin`
WHERE
analysis_date >= #{startTime}
AND
analysis_date &lt;= #{endTime}
<if test="params.vehiclesNums != null and params.vehiclesNums.size > 0">
and v.vehicle_num in
<foreach collection="params.vehiclesNums" item="vehiclesNum" open="(" close=")" separator=",">
#{vehiclesNum}
</foreach>
</if>
AND
vfc.`fault_type` is not null
GROUP BY
analysis_date,vfc.`fault_type`
</select>
<select id="getFaultLevelTrendByHour" resultType="com.ssi.entity.vo.VmsVehicleFaultVo">
SELECT
HOUR(alarm_time) AS HOUR,
vfc.`fault_grade` AS faultGrade,
COUNT(1) AS faultNum
FROM
`vms_vehicle_alert_history` t
left join `vms_fault_code` vfc on t.`fault_code` = vfc.`fault_code` and t.`spn` = vfc.`SPN` and t.`fmi`=vfc.`FMI`
left join `vms_vehicle` v on t.`vin` = v.`vin`
WHERE
alarm_time >= #{startTimeStamp}
AND
alarm_time >= #{startTime}
AND
alarm_time &lt;= #{endTime}
<if test="params.vehiclesNums != null and params.vehiclesNums.size > 0">
and v.vehicle_num in
<foreach collection="params.vehiclesNums" item="vehiclesNum" open="(" close=")" separator=",">
#{vehiclesNum}
</foreach>
</if>
AND
vfc.`fault_grade` is not null
GROUP BY
HOUR (alarm_time),vfc.`fault_grade`;
</select>
<select id="getFaultLevelTrendByDay" resultType="com.ssi.entity.vo.VmsVehicleFaultVo">
SELECT
t.analysis_date AS DATE,
vfc.`fault_grade` as faultGrade,
SUM(t.fault_num) AS faultNum
FROM
`vms_fault_analysis_perday` t
left join `vms_fault_code` vfc on t.`fault_code` = vfc.`fault_code` and t.`spn` = vfc.`SPN` and t.`fmi`=vfc.`FMI`
left join `vms_vehicle` v on t.`vin` = v.`vin`
WHERE
analysis_date >= #{startTime}
AND
analysis_date &lt;= #{endTime}
<if test="params.vehiclesNums != null and params.vehiclesNums.size > 0">
and v.vehicle_num in
<foreach collection="params.vehiclesNums" item="vehiclesNum" open="(" close=")" separator=",">
#{vehiclesNum}
</foreach>
</if>
AND
vfc.`fault_grade` is not null
GROUP BY
analysis_date,vfc.`fault_grade`
</select>
</mapper>
\ No newline at end of file
<?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.ssi.mapper.VmsVehicleAlertProcessMapper">
<resultMap id="BaseResultMap" type="com.ssi.entity.VmsVehicleAlertProcess">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="vin" column="vin" jdbcType="VARCHAR"/>
<result property="faultCode" column="fault_code" jdbcType="VARCHAR"/>
<result property="spn" column="spn" jdbcType="VARCHAR"/>
<result property="fmi" column="fmi" jdbcType="VARCHAR"/>
<result property="resolveStatus" column="resolve_status" jdbcType="INTEGER"/>
<result property="alarmTime" column="alarm_time" jdbcType="TIMESTAMP"/>
<result property="alarmPosition" column="alarm_position" jdbcType="VARCHAR"/>
<result property="resolveAlarmTime" column="resolve_alarm_time" jdbcType="TIMESTAMP"/>
<result property="lastModifiedDate" column="last_modified_date" jdbcType="TIMESTAMP"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,vin,fault_code,
spn,fmi,resolve_status,
alarm_time,alarm_position,resolve_alarm_time,
last_modified_date,create_time
</sql>
</mapper>
<?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.ssi.mapper.VmsVehicleMapper">
<select id="queryVehicleByVin" resultType="com.ssi.entity.dto.VmsVehicleDto">
select t.vin as vin ,t.vehicle_num as vehicleNum,t.terminal_num as terminalNum,
vv.`vin` as vinSSI,vv.`vehicle_num`as vehicleNumSSI,t.video_terminal_num as videoTerminalNum
from `vms_vehicle` t
left join vms_vehicle vv
on concat(t.`vehicle_num` ,'_SSI') = vv.`vehicle_num`
where t.vin = #{vin}
</select>
<select id="getVmsCranePosMapInfo" resultType="java.util.HashMap" >
select start_lng as startLng,start_lat as startLat,end_lng as endLng,end_lat as endLat from vms_crane_pos_map where name= #{name}
</select>
<!-- 查询车辆vin -->
<select id="getVmsVehicle" resultType="java.util.HashMap" >
SELECT t.vin as vin ,t.vehicle_num as vehicleNum FROM vms_vehicle t WHERE t.status=0 AND t.vehicle_type IN (1,2)
</select>
</mapper>
\ No newline at end of file
package com.ssi.test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DemoApplicationTests {
}
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