| | |
| | | <?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.yuanchu.mom.mapper.InspectionItemMapper"> |
| | | |
| | | <!--把原有的检验项目的数据清空--> |
| | | <update id="updateBatch"> |
| | | UPDATE mom_ocean.inspection_item o |
| | | <trim prefix="set" suffixOverrides=","> |
| | | <trim prefix="inspection_value=case" suffix="end,"> |
| | | <foreach collection="inspectionItems" item="item" index="index"> |
| | | WHEN o.id = #{item.id} THEN null |
| | | </foreach> |
| | | </trim> |
| | | <trim prefix="device_id=case" suffix="end,"> |
| | | <foreach collection="inspectionItems" item="item" index="index"> |
| | | WHEN o.id = #{item.id} THEN null |
| | | </foreach> |
| | | </trim> |
| | | <trim prefix="result=case" suffix="end,"> |
| | | <foreach collection="inspectionItems" item="item" index="index"> |
| | | WHEN o.id = #{item.id} THEN null |
| | | </foreach> |
| | | </trim> |
| | | <trim prefix="username=case" suffix="end,"> |
| | | <foreach collection="inspectionItems" item="item" index="index"> |
| | | WHEN o.id = #{item.id} THEN null |
| | | </foreach> |
| | | </trim> |
| | | </trim> |
| | | WHERE o.id in |
| | | <foreach collection="inspectionItems" index="index" item="item" separator="," open="(" close=")"> |
| | | #{item.id, jdbcType=BIGINT} |
| | | </foreach> |
| | | </update> |
| | | <resultMap id="selectInspectionItemMap" type="inspectionItemDto"> |
| | | <id property="father" column="father"/> |
| | | <id property="father" column="ifather"/> |
| | | <association property="children" resultMap="selectInspectionItemDto2Map"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="selectInspectionItemDto2Map" type="inspectionItemDto2"> |
| | | <id property="id" column="id"/> |
| | | <result property="name" column="name"/> |
| | |
| | | <result property="internal" column="internal"/> |
| | | <result property="required" column="required"/> |
| | | <result property="inspectionValue" column="inspection_value"/> |
| | | <result property="deviceId" column="device_id"/> |
| | | <result property="did" column="did"/> |
| | | <result property="dname" column="dname"/> |
| | | <result property="result" column="result"/> |
| | | <result property="username" column="username"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectInspectionItem" resultMap="selectInspectionItemMap"> |
| | | SELECT i.`id`, IFNULL(i.`father`,i.`name`) father, i.`name`, i.`unit`, i.`internal`, i.`required`, i.`inspection_value`, i.`device_id`, i.`result` |
| | | FROM inspection_item i |
| | | WHERE i.`finish_inspect_id` = #{finishInspectId} |
| | | SELECT i.`id`, |
| | | i.`father` ifather, |
| | | i.`name`, |
| | | i.`unit`, |
| | | i.`internal`, |
| | | i.`required`, |
| | | i.`inspection_value`, |
| | | device.id did, |
| | | device.name dname, |
| | | i.`result`, |
| | | username |
| | | FROM mom_ocean.inspection_item i |
| | | left join mom_ocean.device on i.device_id = device.id |
| | | WHERE i.`inspect_id` = #{id} |
| | | AND i.`state` = 1 |
| | | and i.type = #{type} |
| | | </select> |
| | | |
| | | <!--获取该检验单下检验项目的结果集--> |
| | | <select id="getResult" resultType="java.lang.Integer"> |
| | | select distinct result |
| | | from mom_ocean.inspection_item |
| | | where state = 1 |
| | | and type = #{type} |
| | | and inspect_id = #{id} |
| | | </select> |
| | | </mapper> |