<?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.op.mes.mapper.MesMapper" >
<!-- 手持指定下一机台 -->
<insert id= "saveRfidWithEquip" >
insert into mes_next_machine
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "recordId != null" > record_id,</if>
<if test= "rfid != null and rfid != ''" > rfid,</if>
<if test= "nextMachineCode != null" > next_machine_code,</if>
<if test= "status != null" > status,</if>
<if test= "remark != null" > remark,</if>
<if test= "attr1 != null" > attr1,</if>
<if test= "attr2 != null" > attr2,</if>
<if test= "attr3 != null" > attr3,</if>
<if test= "attr4 != null" > attr4,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "factoryCode != null" > factory_code,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "recordId != null" > #{recordId},</if>
<if test= "rfid != null and rfid != ''" > #{rfid},</if>
<if test= "nextMachineCode != null" > #{nextMachineCode},</if>
<if test= "status != null" > #{status},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "attr1 != null" > #{attr1},</if>
<if test= "attr2 != null" > #{attr2},</if>
<if test= "attr3 != null" > #{attr3},</if>
<if test= "attr4 != null" > #{attr4},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "factoryCode != null" > #{factoryCode},</if>
</trim>
</insert>
<insert id= "addBatchLGInfo" >
insert into pro_lg_used_log(
id,device_code,
used,used_unit,
createDate,lg_create_time,
factory_code,create_time
) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
(
#{item.id},#{item.deviceCode},
#{item.used},#{item.usedUnit},
#{item.createDate},#{item.lgCreateTime},
#{item.factoryCode},#{item.createTime}
)
</foreach>
</insert>
<delete id= "deleteDateByTableName" >
delete from ${table} where #{ymdhms} > CONVERT(varchar(30),create_time, 120)
</delete>
<select id= "getWetPlanDetail" resultType= "com.op.system.api.domain.dto.WCSDataItemsDTO" >
select
bucket_code loadNo
from pro_wet_material_plan_detail
where material_code = #{sku} and CONVERT(varchar(10),plan_time, 120) = CONVERT(varchar(10),#{reqTime}, 120)
and del_flag = '0'
</select>
<select id= "getAllEquipments" resultType= "com.op.mes.domain.dto.BaseEquipmentDto" >
select equipment_id equipmentId,
equipment_code equipmentCode,
equipment_name equipmentName,
equipment_type_code equipmentTypeCode,
equipment_type_name equipmentTypeName
from base_equipment
where del_flag = '0'
and status = '1'
<if test= "equipmentTypeCode != null and equipmentTypeCode != ''" >
and equipment_type_code = #{equipmentTypeCode}
</if>
<if test= "equipmentCode != null and equipmentCode != ''" >
and equipment_code like concat('%', #{equipmentCode}, '%')
</if>
<if test= "equipmentName != null and equipmentName != ''" >
and equipment_name like concat('%', #{equipmentName}, '%')
</if>
</select>
<select id= "getTotalNum" resultType= "com.op.system.api.domain.dto.BoardDTO" >
select count(0) totalNum,
equ.equipment_type_code equTypeCode,
equ.equipment_type_name equTypeName
from mes_material_transfer_result mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
where CONVERT(varchar(10),mt.update_time, 120) = #{ymd} and equ.equipment_name is not null
and equ.equipment_type_code = #{equTypeCode}
<if test= "shiftId != null and shiftId != ''" >
and mt.shift_id = #{shiftId}
</if>
group by equ.equipment_type_code,
equ.equipment_type_name
</select>
<select id= "getEveryNum" resultType= "com.op.system.api.domain.dto.BoardDTO" >
select count(0) totalNum,
mt.equipmentCode equCode,
equ.equipment_name equName,
equ.equipment_type_code equTypeCode
from mes_material_transfer_result mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
where CONVERT(varchar(10),mt.update_time, 120) = #{ymd} and equ.equipment_name is not null
and equ.equipment_type_code = #{equTypeCode}
<if test= "shiftId != null and shiftId != ''" >
and mt.shift_id = #{shiftId}
</if>
group by mt.equipmentCode,
equ.equipment_name,
equ.equipment_type_code
</select>
<select id= "getBoardFactory" resultType= "com.op.system.api.domain.SysDept" >
select SUBSTRING(pool_name, 4, 6) parentName,
park_name deptName
from sys_datasource where del_flag = '0' and status = '0'
</select>
<select id= "getTotalNumL" resultType= "com.op.system.api.domain.dto.BoardDTO" >
select count(0) totalNum,
equ.equipment_type_code equTypeCode,
equ.equipment_type_name equTypeName
from mes_material_transfer_result mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
where CONVERT(varchar(10),mt.create_time, 120) = #{ymd} and equ.equipment_name is not null
and equ.equipment_type_code = #{equTypeCode} and mt.status = 2
<if test= "shiftId != null and shiftId != ''" >
and mt.shift_id = #{shiftId}
</if>
group by equ.equipment_type_code,
equ.equipment_type_name
</select>
<select id= "getEveryNumL" resultType= "com.op.system.api.domain.dto.BoardDTO" >
select count(0) totalNum,
mt.equipmentCode equCode,
equ.equipment_name equName,
equ.equipment_type_code equTypeCode
from mes_material_transfer_result mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
where CONVERT(varchar(10),mt.create_time, 120) = #{ymd} and equ.equipment_name is not null
and equ.equipment_type_code = #{equTypeCode} and mt.status = 2
<if test= "shiftId != null and shiftId != ''" >
and mt.shift_id = #{shiftId}
</if>
group by mt.equipmentCode,
equ.equipment_name,
equ.equipment_type_code
</select>
<!-- 创建新表 -->
<insert id= "createNewTable" >
SELECT TOP 0 * INTO ${tableNew} FROM mes_material_transfer_result
</insert>
<insert id= "addSapLog" >
insert into sys_sap_log
(id,messsge,create_time,reqcode,method,remark,status)
values(
#{id},#{messsge}, #{createTime}, #{reqcode},#{method},#{remark},#{status})
</insert>
<select id= "copyBkDateByTable" >
insert into ${table}
select * FROM mes_material_transfer_result
where create_time >= #{startDate} and #{endDate}>create_time
</select>
<select id= "selectcxjList" resultType= "java.util.Map" >
SELECT * FROM [dbo].[base_equipment]
</select>
<select id= "selectdryingRoomListInfo" resultType= "java.util.Map" >
SELECT
CONVERT(INT, SUBSTRING(PivotTable.equipment_code, 2, LEN(PivotTable.equipment_code) - 1)) as i,
PivotTable.*,
DATEDIFF(MINUTE, T2.last_update_time, GETDATE()) as waitmin
FROM
(
SELECT
be.equipment_code,
be.status,
bea.isvalue,
bea.property
FROM
base_equipment be
LEFT JOIN base_equipment_attached bea ON be.equipment_code = bea.device_code
WHERE
be.equipment_type_code = 'equ_type_hf'
AND del_flag = '0'
) AS SourceTable PIVOT ( MAX ( isvalue ) FOR property IN ( [dollyNumber], [Intheoven], [temperature] ) ) AS PivotTable LEFT JOIN base_equipment_attached T2 ON PivotTable.equipment_code=T2.device_code WHERE T2.property='dollyNumber'
ORDER BY i asc
</select>
<delete id= "deleteBkDateByTable" >
delete from mes_material_transfer_result
where create_time >= #{startDate} and #{endDate}>create_time
</delete>
<delete id= "deleteBkDate" >
delete from ${table}
where create_time >= #{startDate} and #{endDate}>create_time
</delete>
<delete id= "deleteDateByTableName0" >
delete from ${table} where #{ymdhms} > CONVERT(varchar(30),creter_time, 120)
</delete>
<select id= "getTechnologyBoard" resultType= "com.op.mes.domain.MesBoard" >
select pow.workorder_code workorderCode,
pow.workorder_code_sap workorderCodeSap,
pow.workorder_name workorderName,
pow.product_code productCode,
pow.product_name productName,
pr.route_code routeCode,
pr.route_id routeId,
equ.equipment_name equipmentName,
equ.workshop_code workshopCode,
equ.workshop_name workshopName
from pro_order_workorder pow
left join pro_route pr on pow.route_code = pr.route_code
left join base_equipment equ on pow.workorder_name = equ.equipment_code
where pow.parent_order = '0'
and pow.product_date = CONVERT(varchar(10),GETDATE(), 120)
and pow.del_flag='0'
</select>
<select id= "getTechnologyFiles" resultType= "com.op.common.core.domain.BaseFileData" >
select file_name fileName,
file_address fileAddress
from base_file
where source_id = #{routeId}
</select>
<select id= "sumPlanQuantity" resultType= "java.lang.String" >
SELECT
SUM(quantity) AS sumplanquantity
FROM
pro_order
WHERE
order_type = 'LJ88'
AND parent_order=''
AND CONVERT ( DATE, plan_pro_date ) = CONVERT ( DATE, GETDATE( ) )
AND CONVERT ( DATE, plan_complete ) = CONVERT ( DATE, GETDATE( ) );
</select>
<select id= "sumFinshQuantity" resultType= "java.lang.String" >
SELECT SUM
( quantity ) AS sumplanquantity
FROM
mes_report_work
WHERE
parent_order = '0'
AND CONVERT ( DATE, create_time ) = CONVERT ( DATE, GETDATE( ) )
</select>
<select id= "daySenvenProduction" resultType= "java.util.Map" >
SELECT
CONVERT(DATE, create_time) AS day,
SUM(quantity) AS sum_quantity
FROM
mes_report_work
WHERE
parent_order = '0'
AND CONVERT(DATE, create_time) BETWEEN DATEADD(DAY, -7, CONVERT(DATE, GETDATE())) AND CONVERT(DATE, GETDATE())
GROUP BY
CONVERT(DATE, create_time);
</select>
<select id= "ProductionInProgress" resultType= "java.util.Map" >
SELECT
A.workorder_code,
A.workorder_name,
C.equipment_name,
A.product_name,
SUM ( B.quantity ) AS total_quantity,
A.unit
FROM
pro_order_workorder A
LEFT JOIN mes_report_work B ON A.workorder_code = B.workorder_code
LEFT JOIN base_equipment C ON A.workorder_name= C.equipment_code
WHERE
A.status = 'w2'
AND A.parent_order = '0'
AND CONVERT ( DATE, A.product_date ) = CONVERT ( DATE, GETDATE( ) )
GROUP BY
A.workorder_code,
A.workorder_name,
A.product_name,
A.workorder_name,
A.unit,
C.equipment_name;
</select>
<select id= "getLineList" resultType= "com.op.system.api.domain.dto.BoardDTO" >
select equipment_code equCode,
equipment_name equName
from base_equipment
where equipment_type_code = #{equipmentTypeCode}
and status = '1' and del_flag='0'
</select>
<select id= "getProduction15Days" resultType= "com.op.mes.domain.MesReportWork" >
select sum(pow.quantity_split) quantity,
pow.product_date productDate
from pro_order_workorder pow
where pow.del_flag='0'
and pow.workorder_name = #{equCode}
and CONVERT(DATE, pow.product_date) BETWEEN DATEADD(DAY, -15, CONVERT(DATE, GETDATE())) AND CONVERT(DATE, GETDATE())
group by pow.product_date
</select>
<select id= "getProduction15DaysAct" resultType= "com.op.mes.domain.MesReportWork" >
select sum(mrw.quantity_feedback) quantityFeedback,
pow.product_date productDate
from mes_report_work mrw
left join pro_order_workorder pow on pow.workorder_code = mrw.workorder_code
where mrw.del_flag='0' and pow.del_flag='0' and mrw.parent_order = '0'
and pow.workorder_name = #{equCode}
and CONVERT(DATE, pow.product_date) BETWEEN DATEADD(DAY, -15, CONVERT(DATE, GETDATE())) AND CONVERT(DATE, GETDATE())
group by pow.product_date
</select>
<select id= "getWorkOrder" resultType= "com.op.system.api.domain.dto.BoardDTO" >
select
pow.workorder_name equCode,
be.equipment_name equName,
pow.product_code productCode,
pow.product_name productName,
pow.workorder_code_sap workorderCodeSap,
pow.quantity_split totalNum,
pow.unit
from pro_order_workorder pow
left join base_equipment be on pow.workorder_name = be.equipment_code and be.equipment_type_code = 'equ_type_bzx'
where pow.workorder_name = #{equCode} and pow.status = 'w2'
and CONVERT ( DATE, pow.product_date ) = CONVERT ( DATE, GETDATE( ) )
and pow.parent_order = '0' and pow.del_flag='0'
</select>
</mapper>