cuijian
2025-06-05 c17e36e49be715a3305c79625187631184278c19
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/mapper/xml/ToolLedgerDetailMapper.xml
@@ -19,4 +19,156 @@
        LEFT JOIN tms_warehouse q on t.warehouse_id = q.id
        ${ew.customSqlSegment}
    </select>
    <!--<select id="queryToolByStatus"  resultType="map" parameterType="String">
        SELECT
            t.id,
            t.tool_code toolCodeId,
            p.tool_code toolCode,
            t.tool_id onlyCode,
            p.chinese_name chineseName,
            p.accuracy_class accuracyClass,
            p.tool_model toolModel,
            t.quantity,
            t.warehouse_id warehouseId,
            ISNULL(q.warehouse_id, '') + '/' + ISNULL(q.warehouse_name, '') warehouseName,
            t.position_code positionCode,
            t2.item_text applicationTypeName
        FROM tms_tool_ledger_detail t
                 LEFT JOIN tms_base_tools p on t.tool_code = p.id
                 LEFT JOIN tms_warehouse q on t.warehouse_id = q.id
                 left join tms_tools_config_property t1 on t1.tool_code = p.id
                 left join (select * from v_sys_dict where dict_code = 'application_type') t2 on t2.item_value = t1.application_type
            ${ew.customSqlSegment}
    </select>-->
    <select id="queryLendTool"  resultType="map" parameterType="String">
        SELECT
            temp.id,
            temp.toolCodeId,
            temp.toolCode,
            temp.onlyCode,
            temp.chineseName,
            temp.accuracyClass,
            temp.toolModel,
            temp.quantity,
            temp.warehouseId,
            temp.warehouseName,
            temp.positionCode,
            temp.applicationTypeName
        FROM
            (
                SELECT
                    t.id,
                    t.tool_code toolCodeId,
                    p.tool_code toolCode,
                    t.tool_id onlyCode,
                    p.chinese_name chineseName,
                    p.accuracy_class accuracyClass,
                    p.tool_model toolModel,
                    1 quantity,
                    t.warehouse_id warehouseId,
                    ISNULL( q.warehouse_id, '' ) + '/' + ISNULL( q.warehouse_name, '' ) warehouseName,
                    t.position_code positionCode,
                    t2.item_text applicationTypeName
                FROM
                    tms_tool_ledger_detail t
                        LEFT JOIN tms_base_tools p ON t.tool_code = p.id
                        LEFT JOIN tms_warehouse q ON t.warehouse_id = q.id
                        LEFT JOIN tms_tools_config_property t1 ON t1.tool_code = p.id
                        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'application_type' ) t2 ON t2.item_value = t1.application_type
                        ${ew.customSqlSegment}
                    UNION ALL
                    (
                    SELECT
                        t.id,
                        t.tool_code toolCodeId,
                        p.tool_code toolCode,
                        t.tool_id onlyCode,
                        p.chinese_name chineseName,
                        p.accuracy_class accuracyClass,
                        p.tool_model toolModel,
                        t3.lend_count quantity,
                        t.warehouse_id warehouseId,
                        ISNULL( q.warehouse_id, '' ) + '/' + ISNULL( q.warehouse_name, '' ) warehouseName,
                        t.position_code positionCode,
                        t2.item_text applicationTypeName
                    FROM
                        tms_tool_ledger_detail t
                            LEFT JOIN tms_tool_ledger t3 ON t3.tool_id = t.tool_code
                            LEFT JOIN tms_base_tools p ON t.tool_code = p.id
                            LEFT JOIN tms_warehouse q ON t.warehouse_id = q.id
                            LEFT JOIN tms_tools_config_property t1 ON t1.tool_code = p.id
                            LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'application_type' ) t2 ON t2.item_value = t1.application_type
                            WHERE
                        p.accuracy_class != 1
         AND t3.lend_count != 0
                )
            ) temp
    </select>
    <select id="querySharpenTool"  resultType="map" parameterType="String">
        SELECT
            temp.id,
            temp.toolCodeId,
            temp.toolCode,
            temp.onlyCode,
            temp.chineseName,
            temp.accuracyClass,
            temp.toolModel,
            temp.quantity,
            temp.warehouseId,
            temp.warehouseName,
            temp.positionCode,
            temp.applicationTypeName
        FROM
            (
                SELECT
                    t.id,
                    t.tool_code toolCodeId,
                    p.tool_code toolCode,
                    t.tool_id onlyCode,
                    p.chinese_name chineseName,
                    p.accuracy_class accuracyClass,
                    p.tool_model toolModel,
                    1 quantity,
                    t.warehouse_id warehouseId,
                    ISNULL( q.warehouse_id, '' ) + '/' + ISNULL( q.warehouse_name, '' ) warehouseName,
                    t.position_code positionCode,
                    t2.item_text applicationTypeName
                FROM
                    tms_tool_ledger_detail t
                        LEFT JOIN tms_base_tools p ON t.tool_code = p.id
                        LEFT JOIN tms_warehouse q ON t.warehouse_id = q.id
                        LEFT JOIN tms_tools_config_property t1 ON t1.tool_code = p.id
                        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'application_type' ) t2 ON t2.item_value = t1.application_type
                    ${ew.customSqlSegment}
                UNION ALL
                (
                SELECT
                    t.id,
                    t.tool_code toolCodeId,
                    p.tool_code toolCode,
                    t.tool_id onlyCode,
                    p.chinese_name chineseName,
                    p.accuracy_class accuracyClass,
                    p.tool_model toolModel,
                    t3.sharpening_count quantity,
                    t.warehouse_id warehouseId,
                    ISNULL( q.warehouse_id, '' ) + '/' + ISNULL( q.warehouse_name, '' ) warehouseName,
                    t.position_code positionCode,
                    t2.item_text applicationTypeName
                FROM
                    tms_tool_ledger_detail t
                    LEFT JOIN tms_tool_ledger t3 ON t3.tool_id = t.tool_code
                    LEFT JOIN tms_base_tools p ON t.tool_code = p.id
                    LEFT JOIN tms_warehouse q ON t.warehouse_id = q.id
                    LEFT JOIN tms_tools_config_property t1 ON t1.tool_code = p.id
                    LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'application_type' ) t2 ON t2.item_value = t1.application_type
                WHERE
                    p.accuracy_class != 1
                  AND t3.sharpening_count != 0
                    )
            ) temp
    </select>
</mapper>