value
2024-06-04 58c18ed858c0c3eaaa95b6abceceb1f1ad320fcd
inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -16,14 +16,9 @@
        <result property="sampleType" column="sample_type" jdbcType="VARCHAR"/>
        <result property="sample" column="sample" jdbcType="VARCHAR"/>
        <result property="model" column="model" jdbcType="VARCHAR"/>
        <result property="isLeave" column="is_leave" jdbcType="INTEGER"/>
        <result property="leaveNum" column="leave_num" jdbcType="INTEGER"/>
        <result property="insProgress" column="ins_progress" jdbcType="VARCHAR"/>
        <result property="insState" column="ins_state" jdbcType="INTEGER"/>
        <result property="sendTime" column="send_time" jdbcType="TIMESTAMP"/>
        <result property="joinNum" column="join_num" jdbcType="INTEGER"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="appointed" column="appointed" jdbcType="TIMESTAMP"/>
        <result property="createUser" column="create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="update_user" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@@ -31,68 +26,390 @@
    </resultMap>
    <select id="findInsSampleAndOrder" resultType="com.yuanchu.mom.vo.InsOrderPlanVO">
        SELECT DISTINCT
        select * from(
        SELECT
        a.*,ios.ins_state,ios.verify_tell,isu2.order_user_id,(ios.verify_user = #{userId}) verify_user
        FROM
        (
        SELECT
        io.id,
        io.entrust_code,
        io.type,
        tempA.id,
        tempA.sample,
        tempA.sample_code,
        tempA.send_time,
        tempA.appointed,
        tempA.ins_state,
        tempA.ins_result,
        tempA.user_id,
        tempA.ins_order_id,
        tempA.sample_user_id,
        ipr.son_laboratory
        FROM
        (
        SELECT
        temp.*
        FROM
        (
        SELECT
        isa.id,
        isa.sample,
        isa.sample_code,
        isa.send_time,
        isa.appointed,
        isa.ins_state,
        isa.ins_result,
        io.appointed,
        io.send_time,
        io.sample_type,
        isu.user_id,
        isa.ins_order_id,
        isu.id as sample_user_id
        ip.son_laboratory,
        io.ins_time
        FROM
        ins_sample isa
        LEFT JOIN ins_sample_user isu ON isa.id = isu.ins_sample_id
        ) AS temp
        ins_order io
        LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id
        LEFT JOIN ( SELECT * FROM ins_sample_user GROUP BY ins_sample_id, user_id ) isu ON isu.ins_sample_id = io.id
        LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
        WHERE
        temp.user_id = #{ew.userId}
        OR ( SELECT COUNT(*) FROM ins_sample_user WHERE ins_sample_id = temp.id ) = 0
        ) AS tempA
        LEFT JOIN ins_order io ON tempA.ins_order_id = io.id
        LEFT JOIN ins_product ipr ON tempA.id = ipr.ins_sample_id
        io.state = 1
#         AND io.ins_state != 5
        and send_time is not null
        and (isu.user_id = #{userId} OR isu.user_id is NULL)
        GROUP BY
        ip.son_laboratory,
        io.id
        ) a
        LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory
        left join (SELECT td.user_id order_user_id, td.ins_sample_id FROM ins_sample_user td,(SELECT max(id) id FROM ins_sample_user GROUP BY ins_sample_id) md  where td.id = md.id and user_id = #{userId}) isu2 on isu2.ins_sample_id = a.id
        ORDER BY
        a.user_id DESC,
        a.type DESC,
        a.id
        ) b
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
    <select id="inspectionOrderDetailsTaskSwitching" resultType="com.yuanchu.mom.vo.InsOrderPlanTaskSwitchVo">
        select * from(
        SELECT
        a.*,ios.ins_state,ios.verify_tell,isu2.order_user_id,(ios.verify_user = #{userId}) verify_user
        FROM
        (
        SELECT
        io.id,
        io.entrust_code,
        io.type,
        io.appointed,
        io.send_time,
        io.sample_type,
        isu.user_id,
        ip.son_laboratory,
        io.ins_time
        FROM
        ins_order io
        LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id
        LEFT JOIN ( SELECT * FROM ins_sample_user GROUP BY ins_sample_id, user_id ) isu ON isu.ins_sample_id = io.id
        LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
        WHERE
        io.state = #{ew.state}
        AND ipr.state = 1
        AND ipr.son_laboratory = #{ew.childrenLaboratory}
        <if test="ew.insState!=null and ew.insState!=''">
            AND tempA.ins_state = #{ew.insState}
        io.state = 1
        #         AND io.ins_state != 5
        and send_time is not null
        and (isu.user_id = #{userId} OR isu.user_id is NULL)
        GROUP BY
        ip.son_laboratory,
        io.id
        ) a
        LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory
        left join (SELECT td.user_id order_user_id, td.ins_sample_id FROM ins_sample_user td,(SELECT max(id) id FROM ins_sample_user GROUP BY ins_sample_id) md  where td.id = md.id and user_id = #{userId}) isu2 on isu2.ins_sample_id = a.id
        ORDER BY
        a.user_id DESC,
        a.type DESC,
        a.id
        ) b
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
        <if test="ew.sampleName!=null and ew.sampleName!=''">
            AND tempA.sample like concat('%',#{ew.sampleName},'%')
        </if>
        <if test="ew.viewSelf==true">
            AND tempA.sample_user_id is not null
        </if>
        ORDER BY io.type DESC,tempA.id
    </select>
    <select id="selectSampleProductListByOrderId" resultMap="sampleDto">
        select isa.*,ip.id, inspection_item, inspection_item_classify, inspection_item_subclass, ip.factory, ip.laboratory, ip.sample_type, ip.sample, ip.model, son_laboratory, unit, price, man_hour, man_hour_group, inspection_item_type, inspection_value_type, device_group, checkout_number, section, value_type, method, man_day, bsm, ask, `last_value`, ip.ins_result, state, ins_sample_id, ip.create_user, ip.update_user, ip.create_time, ip.update_time, template_id
        select isa.*,
               ip.id ip_id,
               inspection_item,
               inspection_item_en,
               inspection_item_classify,
               inspection_item_subclass,
               inspection_item_subclass_en,
               ip.factory ip_factory,
               ip.laboratory ip_laboratory,
               ip.sample_type ip_sample_type,
               ip.sample ip_sample,
               ip.model ip_model,
               son_laboratory,
               ip.unit ip_unit,
               price,
               man_hour,
               man_hour_group,
               inspection_item_type,
               inspection_value_type,
               device_group,
               checkout_number,
               section,
               value_type,
               method,
               man_day,
               bsm,
               ask,
               `last_value`,
               ip.ins_result ip_ins_result,
               state,
               ins_sample_id,
               ip.create_user ip_create_user,
               ip.update_user ip_update_user,
               ip.create_time ip_create_time,
               ip.update_time ip_update_time,
               template_id,
               ipr.ins_value,
               ipr.com_value,
               ipr.equip_value,
               ip.method_s
        from ins_sample isa
        left join ins_product ip on isa.id = ip.ins_sample_id
        left join ins_product_result ipr on ip.id = ipr.ins_product_id
        where ins_order_id = #{id}
        and state = 1
        and ins_fiber_id is null
        and ins_fibers_id is null
    </select>
    <select id="getInsOrderAndSample" resultMap="sampleDto">
        select isa.*,
               ip.id ip_id,
               inspection_item,
               inspection_item_en,
               inspection_item_classify,
               inspection_item_subclass,
               inspection_item_subclass_en,
               ip.factory ip_factory,
               ip.laboratory ip_laboratory,
               ip.sample_type ip_sample_type,
               ip.sample ip_sample,
               ip.model ip_model,
               son_laboratory,
               ip.unit ip_unit,
               price,
               man_hour,
               man_hour_group,
               inspection_item_type,
               inspection_value_type,
               device_group,
               checkout_number,
               section,
               value_type,
               method,
               man_day,
               bsm,
               ask,
               `last_value`,
               ip.ins_result ip_ins_result,
               state,
               ins_sample_id,
               ip.create_user ip_create_user,
               ip.update_user ip_update_user,
               ip.create_time ip_create_time,
               ip.update_time ip_update_time,
               template_id,
               ipr.ins_value,
               ipr.com_value,
               ipr.equip_value,
               ipr.equip_name,
               ip.method_s,
               ip.tell,
               ip.dic
        from ins_sample isa
        left join ins_product ip on isa.id = ip.ins_sample_id
        left join ins_product_result ipr on ip.id = ipr.ins_product_id
        where ins_order_id = #{id}
        and state = 1
        and ip.son_laboratory = #{laboratory}
        and ins_fiber_id is null
        and ins_fibers_id is null
    </select>
    <select id="getSampleEn" resultType="java.lang.String">
        select name_en from `center-lims`.product
        where name = #{sample}
    </select>
    <select id="selectSampleProductListByOrderId2" resultMap="sampleDto">
        select isa.*,
               ip.id ip_id,
               inspection_item,
               inspection_item_en,
               inspection_item_classify,
               inspection_item_subclass,
               inspection_item_subclass_en,
               ip.factory ip_factory,
               ip.laboratory ip_laboratory,
               ip.sample_type ip_sample_type,
               ip.sample ip_sample,
               ip.model ip_model,
               son_laboratory,
               ip.unit ip_unit,
               price,
               man_hour,
               man_hour_group,
               inspection_item_type,
               inspection_value_type,
               device_group,
               checkout_number,
               section,
               value_type,
               method,
               man_day,
               bsm,
               ask,
               `last_value`,
               ip.ins_result ip_ins_result,
               state,
               ins_sample_id,
               ip.create_user ip_create_user,
               ip.update_user ip_update_user,
               ip.create_time ip_create_time,
               ip.update_time ip_update_time,
               template_id,
               ipr.ins_value,
               ipr.com_value,
               ipr.equip_value,
               ip.method_s
        from ins_sample isa
                 left join ins_product ip on isa.id = ip.ins_sample_id
                 left join ins_product_result ipr on ip.id = ipr.ins_product_id
        where ins_order_id = #{id}
          and state = 1
    </select>
    <select id="getInsProduct1" resultMap="product">
        select ip.id ip_id,
               inspection_item,
               inspection_item_en,
               inspection_item_classify,
               inspection_item_subclass,
               inspection_item_subclass_en,
               ip.factory ip_factory,
               ip.laboratory ip_laboratory,
               ip.sample_type ip_sample_type,
               ip.sample ip_sample,
               ip.model ip_model,
               son_laboratory,
               ip.unit ip_unit,
               price,
               man_hour,
               man_hour_group,
               inspection_item_type,
               inspection_value_type,
               device_group,
               checkout_number,
               section,
               value_type,
               method,
               man_day,
               bsm,
               ask,
               `last_value`,
               ip.ins_result ip_ins_result,
               state,
               ins_sample_id,
               ip.create_user ip_create_user,
               ip.update_user ip_update_user,
               ip.create_time ip_create_time,
               ip.update_time ip_update_time,
               template_id,
               ipr.ins_value,
               ipr.com_value,
               ipr.equip_value,
               ipr.equip_name,
               ip.method_s,
               ip.tell,
               ip.dic
        from ins_product ip
        left join ins_product_result ipr on ip.id = ipr.ins_product_id
        where ins_sample_id = #{id}
          and state = 1
          and ip.son_laboratory = #{laboratory}
          and ins_fiber_id is null
          and ins_fibers_id is null
    </select>
    <select id="getInsProduct2" resultMap="product">
        select ip.id ip_id,
               inspection_item,
               inspection_item_en,
               inspection_item_classify,
               inspection_item_subclass,
               inspection_item_subclass_en,
               ip.factory ip_factory,
               ip.laboratory ip_laboratory,
               ip.sample_type ip_sample_type,
               ip.sample ip_sample,
               ip.model ip_model,
               son_laboratory,
               ip.unit ip_unit,
               price,
               man_hour,
               man_hour_group,
               inspection_item_type,
               inspection_value_type,
               device_group,
               checkout_number,
               section,
               value_type,
               method,
               man_day,
               bsm,
               ask,
               `last_value`,
               ip.ins_result ip_ins_result,
               state,
               ins_sample_id,
               ip.create_user ip_create_user,
               ip.update_user ip_update_user,
               ip.create_time ip_create_time,
               ip.update_time ip_update_time,
               template_id,
               ipr.ins_value,
               ipr.com_value,
               ipr.equip_value,
               ipr.equip_name,
               ip.method_s,
               ip.tell,
               ip.dic
        from ins_product ip
        left join ins_product_result ipr on ip.id = ipr.ins_product_id
        where ins_fibers_id = #{id}
          and state = 1
          and ins_fiber_id is null
    </select>
    <select id="getInsProduct3" resultMap="product">
        select ip.id ip_id,
               inspection_item,
               inspection_item_en,
               inspection_item_classify,
               inspection_item_subclass,
               inspection_item_subclass_en,
               ip.factory ip_factory,
               ip.laboratory ip_laboratory,
               ip.sample_type ip_sample_type,
               ip.sample ip_sample,
               ip.model ip_model,
               son_laboratory,
               ip.unit ip_unit,
               price,
               man_hour,
               man_hour_group,
               inspection_item_type,
               inspection_value_type,
               device_group,
               checkout_number,
               section,
               value_type,
               method,
               man_day,
               bsm,
               ask,
               `last_value`,
               ip.ins_result ip_ins_result,
               state,
               ins_sample_id,
               ip.create_user ip_create_user,
               ip.update_user ip_update_user,
               ip.create_time ip_create_time,
               ip.update_time ip_update_time,
               template_id,
               ipr.ins_value,
               ipr.com_value,
               ipr.equip_value,
               ipr.equip_name,
               ip.method_s,
               ip.tell,
               ip.dic
        from ins_product ip
        left join ins_product_result ipr on ip.id = ipr.ins_product_id
        where ins_fiber_id = #{id}
          and state = 1
          and ins_fibers_id is null
    </select>
    <resultMap id="sampleDto" type="com.yuanchu.mom.dto.SampleProductDto">
@@ -107,33 +424,32 @@
        <result property="sampleType" column="sample_type" jdbcType="VARCHAR"/>
        <result property="sample" column="sample" jdbcType="VARCHAR"/>
        <result property="model" column="model" jdbcType="VARCHAR"/>
        <result property="isLeave" column="is_leave" jdbcType="INTEGER"/>
        <result property="leaveNum" column="leave_num" jdbcType="INTEGER"/>
        <result property="insProgress" column="ins_progress" jdbcType="VARCHAR"/>
        <result property="insState" column="ins_state" jdbcType="INTEGER"/>
        <result property="sendTime" column="send_time" jdbcType="TIMESTAMP"/>
        <result property="joinNum" column="join_num" jdbcType="INTEGER"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="appointed" column="appointed" jdbcType="TIMESTAMP"/>
        <result property="createUser" column="create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="update_user" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="standardMethodListId" column="standard_method_list_id"/>
        <result property="unit" column="unit"/>
        <collection property="insProduct" resultMap="product"/>
    </resultMap>
    <resultMap id="product" type="com.yuanchu.mom.pojo.InsProduct">
        <id property="id" column="ip.id" jdbcType="INTEGER"/>
        <id property="id" column="ip_id" jdbcType="INTEGER"/>
        <result property="inspectionItem" column="inspection_item" jdbcType="VARCHAR"/>
        <result property="inspectionItemEn" column="inspection_item_en" jdbcType="VARCHAR"/>
        <result property="inspectionItemClassify" column="inspection_item_classify" jdbcType="VARCHAR"/>
        <result property="inspectionItemSubclass" column="inspection_item_subclass" jdbcType="VARCHAR"/>
        <result property="factory" column="ip.factory" jdbcType="VARCHAR"/>
        <result property="laboratory" column="ip.laboratory" jdbcType="VARCHAR"/>
        <result property="sampleType" column="ip.sample_type" jdbcType="VARCHAR"/>
        <result property="sample" column="ip.sample" jdbcType="VARCHAR"/>
        <result property="model" column="ip.model" jdbcType="VARCHAR"/>
        <result property="inspectionItemSubclassEn" column="inspection_item_subclass_en" jdbcType="VARCHAR"/>
        <result property="factory" column="ip_factory" jdbcType="VARCHAR"/>
        <result property="laboratory" column="ip_laboratory" jdbcType="VARCHAR"/>
        <result property="sampleType" column="ip_sample_type" jdbcType="VARCHAR"/>
        <result property="sample" column="ip_sample" jdbcType="VARCHAR"/>
        <result property="model" column="ip_model" jdbcType="VARCHAR"/>
        <result property="sonLaboratory" column="son_laboratory" jdbcType="VARCHAR"/>
        <result property="unit" column="unit" jdbcType="VARCHAR"/>
        <result property="unit" column="ip_unit" jdbcType="VARCHAR"/>
        <result property="price" column="price" jdbcType="DECIMAL"/>
        <result property="manHour" column="man_hour" jdbcType="DOUBLE"/>
        <result property="manHourGroup" column="man_hour_group" jdbcType="VARCHAR"/>
@@ -148,13 +464,24 @@
        <result property="bsm" column="bsm" jdbcType="VARCHAR"/>
        <result property="ask" column="ask" jdbcType="VARCHAR"/>
        <result property="lastValue" column="last_value" jdbcType="VARCHAR"/>
        <result property="insResult" column="ip.ins_result" jdbcType="INTEGER"/>
        <result property="insResult" column="ip_ins_result" jdbcType="INTEGER"/>
        <result property="state" column="state" jdbcType="INTEGER"/>
        <result property="insSampleId" column="ins_sample_id" jdbcType="INTEGER"/>
        <result property="createUser" column="ip.create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="ip.update_user" jdbcType="INTEGER"/>
        <result property="createTime" column="ip.create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="ip.update_time" jdbcType="TIMESTAMP"/>
        <result property="templateId" column="ip.template_id" jdbcType="INTEGER"/>
        <result property="createUser" column="ip_create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="ip_update_user" jdbcType="INTEGER"/>
        <result property="createTime" column="ip_create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="ip_update_time" jdbcType="TIMESTAMP"/>
        <result property="templateId" column="template_id" jdbcType="INTEGER"/>
        <result property="methodS" column="method_s"/>
        <result property="tell" column="tell"/>
        <result property="dic" column="dic"/>
        <collection property="insProductResult" resultMap="insProductResult"/>
    </resultMap>
    <resultMap id="insProductResult" type="com.yuanchu.mom.pojo.InsProductResult">
        <result property="insValue" column="ins_value" jdbcType="VARCHAR"/>
        <result property="comValue" column="com_value" jdbcType="VARCHAR"/>
        <result property="equipValue" column="equip_value" jdbcType="VARCHAR"/>
        <result property="equipName" column="equip_name" jdbcType="VARBINARY"/>
    </resultMap>
</mapper>