YearPigBaseDao.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.huimv.apiservice.dao.PigDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.huimv.apiservice.entity.YearPigBaseEntity" id="yearPigBaseMap">
  6. <result property="id" column="id"/>
  7. <result property="eartag" column="eartag"/>
  8. <result property="dayAge" column="day_age"/>
  9. <result property="unitId" column="unit_id"/>
  10. <result property="weight" column="weight"/>
  11. <result property="fosterStatus" column="foster_status"/>
  12. <result property="healthStatus" column="health_status"/>
  13. <result property="whereDidYouGo" column="where_did_you_go"/>
  14. <result property="breed" column="breed"/>
  15. <result property="sex" column="sex"/>
  16. <result property="birthday" column="birthday"/>
  17. <result property="pigstyId" column="pigsty_id"/>
  18. <result property="periodId" column="period_id"/>
  19. <result property="deleted" column="deleted"/>
  20. <result property="gmtCreate" column="gmt_create"/>
  21. <result property="gmtModified" column="gmt_modified"/>
  22. </resultMap>
  23. <resultMap id="pigBaseVoMap" type="com.huimv.apiservice.entity.vo.PigBaseVo">
  24. <result property="eartag" column="c_eartag" />
  25. <result property="weight" column="weight" />
  26. <result property="dayAge" column="day_age" />
  27. <result property="breed" column="breed" />
  28. <result property="birthday" column="birthday" />
  29. <result property="feeder" column="feeder" />
  30. <result property="pigsty" column="pigsty" />
  31. <result property="periodNumber" column="period_number" />
  32. <result property="inFenceTime" column="in_fence_time" />
  33. <result property="outFenceTime" column="out_fence_time" />
  34. <association property="mother" javaType="com.huimv.apiservice.entity.vo.PigPedigreeMotherVo">
  35. <result property="eartag" column="m_eartag" />
  36. <result property="breed" column="m_breed" />
  37. <result property="childbirthWeight" column="m_weight" />
  38. <result property="originPlace" column="m_origin_place" />
  39. <result property="pregnancyDate" column="pregnancy_date" />
  40. <result property="childCount" column="child_count" />
  41. </association>
  42. <association property="father" javaType="com.huimv.apiservice.entity.vo.PigPedigreeFatherVo">
  43. <result property="eartag" column="f_eartag" />
  44. <result property="breed" column="f_breed" />
  45. <result property="originPlace" column="f_origin_place" />
  46. </association>
  47. </resultMap>
  48. <select id="selectFeederInfoByPigEarTagNo" parameterType="string" resultType="com.huimv.apiservice.entity.EmployeeEntity">
  49. SELECT me.*
  50. FROM mgt_employee me
  51. JOIN mgt_pigsty mp
  52. ON me.id = mp.feeder_id
  53. JOIN mgt_pigsty_pig mpp
  54. ON mpp.pigsty_id = mp.id
  55. WHERE mpp.eartag = #{pigEarTagNo}
  56. </select>
  57. <select id="selectPastureNameByPigstyId" resultType="java.lang.String">
  58. SELECT mc.name
  59. FROM mgt_pigsty zs
  60. JOIN mgt_farm mc
  61. ON zs.pasture_id = mc.id
  62. WHERE zs.id = #{pigstyId}
  63. </select>
  64. <select id="selectHealthStatus" parameterType="string" resultType="java.lang.Boolean">
  65. SELECT health_status FROM mgt_year_pig_base WHERE eartag = #{pigEarTagNo} AND deleted = 0
  66. </select>
  67. <select id="selectPagePigBaseVoByBreedName" resultMap="pigBaseVoMap">
  68. SELECT
  69. child.eartag c_eartag,
  70. child.weight,
  71. child.day_age,
  72. child.breed,
  73. child.birthday,
  74. feeder.`name` feeder,
  75. zs.number pigsty,
  76. p.number period_number,
  77. child.in_fence_time,
  78. child.out_fence_time,
  79. m.eartag m_eartag,
  80. m.breed m_breed,
  81. mother.childbirth_weight m_weight,
  82. m.origin_place m_origin_place,
  83. mother.pregnancy_date pregnancy_date,
  84. mother.childbirth_count child_count,
  85. father.eartag f_eartag,
  86. father.breed f_breed,
  87. father.origin_place f_origin_place
  88. FROM mgt_year_pig_base child
  89. LEFT JOIN mgt_pigsty zs ON child.pigsty_id = zs.id
  90. LEFT JOIN mgt_period p ON child.period_id = p.id
  91. LEFT JOIN mgt_employee feeder ON zs.feeder_id = feeder.id
  92. LEFT JOIN mgt_sow_childbirth mother ON child.mother_eartag = mother.eartag
  93. LEFT JOIN mgt_year_pig_base m ON child.mother_eartag = m.eartag
  94. LEFT JOIN mgt_year_pig_base father ON child.father_eartag = father.eartag
  95. WHERE child.deleted = 0 AND child.breed = #{breedName}
  96. <if test="periodId != null">
  97. AND child.period_id = #{periodId}
  98. </if>
  99. </select>
  100. <insert id="batchInsertData">
  101. 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
  102. <foreach collection="list" item="item" separator=",">
  103. (#{item.eartag},
  104. #{item.dayAge},
  105. #{item.unitId},
  106. #{item.weight},
  107. #{item.breed},
  108. #{item.sex},
  109. #{item.birthday},
  110. #{item.originPlace},
  111. #{item.pigstyId},
  112. #{item.periodId},
  113. #{item.inFenceTime},
  114. #{item.motherEartag},
  115. #{item.fatherEartag})
  116. </foreach>
  117. </insert>
  118. </mapper>