You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

492 lines
22 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
1 year ago
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>
2 years ago
<insert id="addBatchLGInfo">
insert into pro_lg_used_log(
1 year ago
id,device_code,
used,used_unit,
createDate,lg_create_time,
factory_code,create_time
2 years ago
) values
<foreach item="item" index="index" collection="list" separator=",">
(
1 year ago
#{item.id},#{item.deviceCode},
#{item.used},#{item.usedUnit},
2 years ago
#{item.createDate},#{item.lgCreateTime},
1 year ago
#{item.factoryCode},#{item.createTime}
2 years ago
)
</foreach>
</insert>
<update id="updateTransferResult">
<foreach collection="list" item="item" separator=";">
update mes_material_transfer_result
set change_order = #{item.changeOrderWorkId},
change_shift_id = #{item.shiftId},
change_time = #{item.changeTime},
change_work_date = #{item.changeWorkDate}
where id = #{item.recordId}
</foreach>
</update>
1 year ago
<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>
2 years ago
<select id="getAllEquipments" resultType="com.op.mes.domain.dto.BaseEquipmentDto">
select equipment_id equipmentId,
1 year ago
equipment_code equipmentCode,
equipment_name equipmentName,
equipment_type_code equipmentTypeCode,
equipment_type_name equipmentTypeName
from base_equipment
where del_flag = '0'
2 years ago
and status = '1'
<if test="equipmentTypeCode != null and equipmentTypeCode != ''">
1 year ago
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>
2 years ago
<select id="getTotalNum" resultType="com.op.system.api.domain.dto.BoardDTO">
select count(0) totalNum,
1 year ago
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
2 years ago
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>
2 years ago
group by equ.equipment_type_code,
1 year ago
equ.equipment_type_name
2 years ago
</select>
<select id="getEveryNum" resultType="com.op.system.api.domain.dto.BoardDTO">
select count(0) totalNum,
1 year ago
mt.equipmentCode equCode,
equ.equipment_name equName,
equ.equipment_type_code equTypeCode
from mes_material_transfer_result mt
1 year ago
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
2 years ago
where CONVERT(varchar(10),mt.update_time, 120) = #{ymd} and equ.equipment_name is not null
4 months ago
and equ.equipment_type_code = #{equTypeCode} and mt.equipmentCode not in('H61','H62','H63')
<if test="shiftId != null and shiftId != ''">
and mt.shift_id = #{shiftId}
</if>
group by mt.equipmentCode,
1 year ago
equ.equipment_name,
equ.equipment_type_code
5 months ago
order by equ.equipment_name
2 years ago
</select>
<select id="getBoardFactory" resultType="com.op.system.api.domain.SysDept">
1 year ago
select SUBSTRING(pool_name, 4, 6) parentName,
park_name deptName
from sys_datasource where del_flag = '0' and status = '0'
2 years ago
</select>
2 years ago
<select id="getTotalNumL" resultType="com.op.system.api.domain.dto.BoardDTO">
select count(0) totalNum,
1 year ago
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
1 year ago
and equ.equipment_type_code = #{equTypeCode} and mt.status = 2
<if test="shiftId != null and shiftId != ''">
1 year ago
and mt.shift_id = #{shiftId}
</if>
2 years ago
group by equ.equipment_type_code,
1 year ago
equ.equipment_type_name
2 years ago
</select>
<select id="getEveryNumL" resultType="com.op.system.api.domain.dto.BoardDTO">
select count(0) totalNum,
1 year ago
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
5 months ago
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,
1 year ago
equ.equipment_name,
equ.equipment_type_code
5 months ago
order by equ.equipment_name
2 years ago
</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,
be.attr2,
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],[humidity] ) ) 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>
1 year ago
<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())
12 months ago
and pow.parent_order='0'
group by pow.product_date
</select>
<select id="getProduction15DaysAct" resultType="com.op.mes.domain.MesReportWork">
1 year ago
select sum(mrw.quantity_feedback) quantityFeedback,
pow.product_date productDate
1 year ago
from mes_report_work mrw
left join pro_order_workorder pow on pow.workorder_code = mrw.workorder_code
1 year ago
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())
12 months ago
and pow.parent_order='0'
group by pow.product_date
1 year ago
</select>
1 year ago
<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,
10 months ago
pow.workorder_code workorderCode,
1 year ago
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'-->
1 year ago
and CONVERT ( DATE, pow.product_date ) = CONVERT ( DATE, GETDATE( ) )
and pow.parent_order = '0' and pow.del_flag='0'
<if test="workorderCodeSap != null and workorderCodeSap != ''">
and pow.workorder_code_sap = #{workorderCodeSap}
</if>
1 year ago
</select>
12 months ago
<select id="getTaskInfo" resultType="com.op.system.api.domain.quality.QcCheckTaskDTO">
select count(0) quality,
sum(sample_quality) sampleQuality
from qc_check_task
where check_type = 'checkTypeSCXJ' and del_flag = '0'
and check_loc = #{equCode}
and CONVERT(varchar(10),create_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
</select>
<select id="getCheckList" resultType="com.op.system.api.domain.quality.QcCheckTaskDTO">
select count(0) quality,
case when check_result='Y' then '合格'
when check_result='N' then '不合格'
else check_result end checkResult
from qc_check_task
where check_type = 'checkTypeSCXJ' and del_flag = '0'
and check_loc = #{equCode}
and CONVERT(varchar(10),create_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
and check_result is not null
group by check_result
</select>
<select id="getPorOrderList" resultType="com.op.mes.domain.ProOrderWorkorder">
select t0.*,t.quantityProduced from
(
select pow.workorder_code_sap workorderCodeSap,
pow.workorder_code workorderCode,
pow.product_name productName,
powb.batch_code batchCode,
powb.batch_quantity quantitySplit
from pro_order_workorder pow
left join pro_order_workorder_batch powb on powb.workorder_id = pow.workorder_id
where pow.del_flag = '0' and CONVERT(varchar(10),pow.product_date, 120) = CONVERT(varchar(10),GETDATE(), 120)
and pow.workorder_name = #{equCode} and pow.parent_order ='0' and powb.del_flag = '0'
) t0
left join (
select workorder_code,batch,sum(quantity_feedback) quantityProduced from mes_report_work
where CONVERT(varchar(10),feedback_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
and del_flag = '0'
group by workorder_code,batch
)t on t0.workorderCode = t.workorder_code and t0.batchCode = t.batch
order by t0.batchCode
12 months ago
</select>
<select id="getHFProInfo" resultType="com.op.system.api.domain.dto.BoardDTO">
select t.*,isnull(be.unit_working_hours,0) unitPro from
(
select count(0) totalNum,
device_code equCode
from mes_dryinghouse_result
where type = '1' and CONVERT(varchar(10),create_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
GROUP BY device_code
) t
left join base_equipment be on be.equipment_code = t.equCode
</select>
<select id="getHFQcInfo" resultType="com.op.system.api.domain.dto.BoardDTO">
select rfid,
isqua,
machine_code equCode,
product_name productName,
create_time createTime
from qc_pro_check
where CONVERT(varchar(10),create_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
11 months ago
and isqua = '0'
order by create_time desc
</select>
<select id="getHFxlInfo" resultType="com.op.system.api.domain.dto.BoardDTO">
select t2.totalNum0,t1.* from
(
select count(0) totalNum,
device_code equCode
from mes_dryinghouse_result
where type = '1' and CONVERT(varchar(10),create_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
GROUP BY device_code
) t1
left join (
select count(0) totalNum0,
device_code equCode
from mes_dryinghouse_result
where type = '0' and CONVERT(varchar(10),create_time, 120) = CONVERT(varchar(10),GETDATE(), 120)
GROUP BY device_code
) t2 on t1.equCode = t2.equCode
</select>
<select id="getStartTime" resultType="java.lang.String">
select remark from base_dict_data
where dict_type= 'change_shift_time'
and dict_value = concat('time_',#{equipmentCode})
</select>
<select id="getUnChangeList" resultType="com.op.mes.domain.MesStationArrive">
select id recordId,equipmentCode,OrderCode,shift_id,work_date
from mes_material_transfer_result mmtr
where mmtr.equipmentCode = #{stationNo}
and mmtr.update_time >= #{startTime} and #{endTime}> mmtr.update_time
and shift_id != #{shiftId}
</select>
<select id="getChangeInfos" resultType="com.op.mes.domain.MesShift">
select top 1 shift_code shiftId,
change_time startTime,
work_date,
device_code deviceCode
from mes_changeshift_info
where work_date =#{ymd} and shift_code = #{shiftId} and device_code = #{equipmentCode} order by change_time desc
</select>
<select id="getActOrderWork" resultType="com.op.system.api.domain.mes.ProOrderWorkorderDTO">
select top 1 workorder_id workorderId,
shift_id shiftId,
product_date productDate,
prod_line_code prodLineCode
from pro_order_workorder
where shift_id=#{shiftId} and product_date = #{reqCode} and del_flag='0'
and prod_line_code like concat('%"',#{stationNo},'"%')
order by create_time desc
</select>
<select id="getMesLineInfo" resultType="com.op.mes.domain.MesLine">
select
10 months ago
mlp.use_man standarMan,
ROUND(mlp.hour_efficiency/bp.umrez,2) AS standarXl
from mes_line_product mlp
left join base_product bp on bp.product_code=mlp.product_code
where mlp.line_code = #{equCode} and mlp.product_code = #{productCode}
and mlp.del_flag='0' and bp.del_flag='0'
</select>
5 months ago
<select id="getEveryDayMap" resultType="com.op.system.api.domain.dto.BoardDTO">
select count(0) totalNum,CONVERT(varchar(10),mt.update_time, 120) ymd,
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,CONVERT(varchar(10),mt.update_time, 120),
equ.equipment_type_name
</select>
<select id="getPlanDayMap" resultType="com.op.system.api.domain.dto.BoardDTO">
select pow.product_date ymd ,sum(po.car_num) totalNum
from pro_order_workorder pow
left join pro_order po on pow.order_code = po.order_code
where pow.product_date>=#{ymd} and pow.del_flag = '0' and pow.shift_id = #{shiftId} and pow.parent_order = '0'
group by pow.product_date
</select>
</mapper>