123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?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.huimv.apiservice.dao.PigDao">
- <!-- 可根据自己的需求,是否要使用 -->
- <resultMap type="com.huimv.apiservice.entity.YearPigBaseEntity" id="yearPigBaseMap">
- <result property="id" column="id"/>
- <result property="eartag" column="eartag"/>
- <result property="dayAge" column="day_age"/>
- <result property="unitId" column="unit_id"/>
- <result property="weight" column="weight"/>
- <result property="fosterStatus" column="foster_status"/>
- <result property="healthStatus" column="health_status"/>
- <result property="whereDidYouGo" column="where_did_you_go"/>
- <result property="breed" column="breed"/>
- <result property="sex" column="sex"/>
- <result property="birthday" column="birthday"/>
- <result property="pigstyId" column="pigsty_id"/>
- <result property="periodId" column="period_id"/>
- <result property="deleted" column="deleted"/>
- <result property="gmtCreate" column="gmt_create"/>
- <result property="gmtModified" column="gmt_modified"/>
- </resultMap>
- <resultMap id="pigBaseVoMap" type="com.huimv.apiservice.entity.vo.PigBaseVo">
- <result property="eartag" column="c_eartag" />
- <result property="weight" column="weight" />
- <result property="dayAge" column="day_age" />
- <result property="breed" column="breed" />
- <result property="birthday" column="birthday" />
- <result property="feeder" column="feeder" />
- <result property="pigsty" column="pigsty" />
- <result property="periodNumber" column="period_number" />
- <result property="inFenceTime" column="in_fence_time" />
- <result property="outFenceTime" column="out_fence_time" />
- <association property="mother" javaType="com.huimv.apiservice.entity.vo.PigPedigreeMotherVo">
- <result property="eartag" column="m_eartag" />
- <result property="breed" column="m_breed" />
- <result property="childbirthWeight" column="m_weight" />
- <result property="originPlace" column="m_origin_place" />
- <result property="pregnancyDate" column="pregnancy_date" />
- <result property="childCount" column="child_count" />
- </association>
- <association property="father" javaType="com.huimv.apiservice.entity.vo.PigPedigreeFatherVo">
- <result property="eartag" column="f_eartag" />
- <result property="breed" column="f_breed" />
- <result property="originPlace" column="f_origin_place" />
- </association>
- </resultMap>
- <select id="selectFeederInfoByPigEarTagNo" parameterType="string" resultType="com.huimv.apiservice.entity.EmployeeEntity">
- SELECT me.*
- FROM mgt_employee me
- JOIN mgt_pigsty mp
- ON me.id = mp.feeder_id
- JOIN mgt_pigsty_pig mpp
- ON mpp.pigsty_id = mp.id
- WHERE mpp.eartag = #{pigEarTagNo}
- </select>
- <select id="selectPastureNameByPigstyId" resultType="java.lang.String">
- SELECT mc.name
- FROM mgt_pigsty zs
- JOIN mgt_farm mc
- ON zs.pasture_id = mc.id
- WHERE zs.id = #{pigstyId}
- </select>
- <select id="selectHealthStatus" parameterType="string" resultType="java.lang.Boolean">
- SELECT health_status FROM mgt_year_pig_base WHERE eartag = #{pigEarTagNo} AND deleted = 0
- </select>
- <select id="selectPagePigBaseVoByBreedName" resultMap="pigBaseVoMap">
- SELECT
- child.eartag c_eartag,
- child.weight,
- child.day_age,
- child.breed,
- child.birthday,
- feeder.`name` feeder,
- zs.number pigsty,
- p.number period_number,
- child.in_fence_time,
- child.out_fence_time,
- m.eartag m_eartag,
- m.breed m_breed,
- mother.childbirth_weight m_weight,
- m.origin_place m_origin_place,
- mother.pregnancy_date pregnancy_date,
- mother.childbirth_count child_count,
- father.eartag f_eartag,
- father.breed f_breed,
- father.origin_place f_origin_place
- FROM mgt_year_pig_base child
- LEFT JOIN mgt_pigsty zs ON child.pigsty_id = zs.id
- LEFT JOIN mgt_period p ON child.period_id = p.id
- LEFT JOIN mgt_employee feeder ON zs.feeder_id = feeder.id
- LEFT JOIN mgt_sow_childbirth mother ON child.mother_eartag = mother.eartag
- LEFT JOIN mgt_year_pig_base m ON child.mother_eartag = m.eartag
- LEFT JOIN mgt_year_pig_base father ON child.father_eartag = father.eartag
- WHERE child.deleted = 0 AND child.breed = #{breedName}
- <if test="periodId != null">
- AND child.period_id = #{periodId}
- </if>
- </select>
- <insert id="batchInsertData">
- insert into mgt_year_pig_base(eartag,day_age,unit_id,weight,breed,sex,birthday,origin_place,pigsty_id,period_id,in_fence_time,mother_eartag,father_eartag) values
- <foreach collection="list" item="item" separator=",">
- (#{item.eartag},
- #{item.dayAge},
- #{item.unitId},
- #{item.weight},
- #{item.breed},
- #{item.sex},
- #{item.birthday},
- #{item.originPlace},
- #{item.pigstyId},
- #{item.periodId},
- #{item.inFenceTime},
- #{item.motherEartag},
- #{item.fatherEartag})
- </foreach>
- </insert>
- </mapper>
|