wms/nflg-wms-repository/src/main/resources/mapper/WmsShipmentPackagingCodeMap...

90 lines
4.5 KiB
XML
Raw Normal View History

<?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.nflg.wms.repository.mapper.WmsShipmentPackagingCodeMapper">
<update id="updateStatus">
UPDATE wms_shipment_packaging_code
SET status=CASE WHEN EXISTS(SELECT id FROM wms_shipment_packaging_code_item WHERE packaging_code_id=wms_shipment_packaging_code."id") THEN 1 ELSE 0 END
where id = #{packagingCodeId}
</update>
<select id="getVOByCode" resultType="com.nflg.wms.common.pojo.vo.ShipmentPackagingCodeVO">
SELECT c.*,di."name" AS "type_name"
FROM wms_shipment_packaging_code c
LEFT JOIN dictionary_item di ON c."type"=di."id"
where c.no=#{code}
<if test="status!=null">
and c.status=#{status}
</if>
</select>
<select id="searchInCar" resultType="com.nflg.wms.common.pojo.vo.BoxVO">
SELECT pc.id,d."no" AS "delivery_no",pc."name" AS "box_name",d.plate_number,d.driver_name,d.driver_phone
,pc.status as "box_status",di.create_by as "pack_user",di.create_time as "pack_time"
FROM wms_shipment_packaging_code pc
INNER JOIN wms_shipment_delivery_item di ON di.packaging_code_id=pc."id"
INNER JOIN wms_shipment_delivery d ON di.delivery_id=d."id"
<where>
<if test="qo.boxStatus != null">
AND pc.status = #{qo.boxStatus}
</if>
<if test="qo.startDate != null">
AND di.create_time >= #{qo.startDate}
</if>
<if test="qo.endDate != null">
AND di.create_time &lt;= #{qo.endDate}
</if>
<if test="qo.deliveryNo != null and qo.deliveryNo != ''">
and d.no like concat('%', #{qo.deliveryNo}, '%')
</if>
<if test="qo.contractNo != null and qo.contractNo != ''">
and d.contract_no like concat('%', #{qo.contractNo}, '%')
</if>
<if test="qo.soNo != null and qo.soNo != ''">
and d.so_no like concat('%', #{qo.soNo}, '%')
</if>
<if test="qo.materialDrawingNo != null and qo.materialDrawingNo != ''">
and d.material_drawing_no like concat('%', #{qo.materialDrawingNo}, '%')
</if>
<if test="qo.materialNo != null and qo.materialNo != ''">
and d.material_no like concat('%', #{qo.materialNo}, '%')
</if>
<if test="qo.deviceNo != null and qo.deviceNo != ''">
and d.device_no like concat('%', #{qo.deviceNo}, '%')
</if>
<if test="qo.customerName != null and qo.customerName != ''">
and d.customer_name like concat('%', #{qo.customerName}, '%')
</if>
<if test="qo.plateNumber != null and qo.plateNumber != ''">
and d.plate_number like concat('%', #{qo.plateNumber}, '%')
</if>
</where>
</select>
<select id="searchForUnload" resultType="com.nflg.wms.common.pojo.vo.ShipmentPackagingCodeVO">
SELECT pc.*,di."name" AS "type_name"
FROM wms_shipment_packaging_code pc
LEFT JOIN dictionary_item di ON pc."type"=di."id"
INNER JOIN wms_shipment_delivery_item di ON di.packaging_code_id=pc."id"
INNER JOIN wms_shipment_delivery d ON di.delivery_id=d."id"
where pc.status=3 and d.no=#{code}
</select>
<select id="getForInstall" resultType="com.nflg.wms.common.pojo.vo.ShipmentMaterialCodeQRVO">
SELECT mciq."id",mciq."no",mci.material_no,mci.material_describe,mciq.num,mci.unit,mciq.status
FROM wms_shipment_packaging_code_item pci
INNER JOIN wms_shipment_material_code_item_qr mciq ON pci.material_code_item_qr_id=mciq."id"
INNER JOIN wms_shipment_material_code_item mci ON mciq.item_id=mci."id"
where mciq.status!=5 and pci.packaging_code_id=#{id}
</select>
<select id="getItemsVOById" resultType="com.nflg.wms.common.pojo.vo.ShipmentMaterialCodeItemVO">
SELECT mci.material_no,mci.material_describe,mci.num,mciq.num as "actual_num",mci.unit,mci.project_type
,mci.parent_material_describe,mci.production_order_number,mci.box_no,mciq.status
FROM wms_shipment_packaging_code_item pci
INNER JOIN wms_shipment_material_code_item_qr mciq ON pci.material_code_item_qr_id=mciq."id"
INNER JOIN wms_shipment_material_code_item mci ON mciq.item_id=mci."id"
where mciq.status!=5 and pci.packaging_code_id=#{qo.id}
</select>
</mapper>