YearPigBaseDao.xml 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. <association property="mother" javaType="com.huimv.apiservice.entity.vo.PigPedigreeMotherVo">
  32. <result property="eartag" column="m_eartag" />
  33. <result property="breed" column="m_breed" />
  34. <result property="childbirthWeight" column="m_weight" />
  35. <result property="originPlace" column="m_origin_place" />
  36. <result property="pregnancyDate" column="pregnancy_date" />
  37. <result property="childCount" column="child_count" />
  38. </association>
  39. <association property="father" javaType="com.huimv.apiservice.entity.vo.PigPedigreeFatherVo">
  40. <result property="eartag" column="f_eartag" />
  41. <result property="breed" column="f_breed" />
  42. <result property="originPlace" column="f_origin_place" />
  43. </association>
  44. </resultMap>
  45. <select id="selectFeederInfoByPigEarTagNo" parameterType="string" resultType="com.huimv.apiservice.entity.EmployeeEntity">
  46. SELECT me.*
  47. FROM mgt_employee me
  48. JOIN mgt_pigsty mp
  49. ON me.id = mp.feeder_id
  50. JOIN mgt_pigsty_pig mpp
  51. ON mpp.pigsty_id = mp.id
  52. WHERE mpp.eartag = #{pigEarTagNo}
  53. </select>
  54. <select id="selectPastureNameByPigstyId" resultType="java.lang.String">
  55. SELECT mc.name
  56. FROM mgt_pigsty zs
  57. JOIN mgt_pasture mc
  58. ON zs.pasture_id = mc.id
  59. WHERE zs.id = #{pigstyId}
  60. </select>
  61. <select id="selectPagePigBaseVoByBreedName" resultMap="pigBaseVoMap">
  62. SELECT child.eartag c_eartag,child.weight,child.day_age,child.breed,child.birthday,feeder.`name` feeder,zs.number pigsty,
  63. mother.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,
  64. father.eartag f_eartag,father.breed f_breed,father.origin_place f_origin_place
  65. FROM mgt_year_pig_base child
  66. LEFT JOIN mgt_pigsty zs ON child.pigsty_id = zs.id
  67. LEFT JOIN mgt_employee feeder ON zs.feeder_id = feeder.id
  68. LEFT JOIN mgt_sow_childbirth mother ON child.mother_eartag = mother.eartag
  69. LEFT JOIN mgt_year_pig_base m ON child.mother_eartag = m.eartag
  70. LEFT JOIN mgt_year_pig_base father ON child.father_eartag = father.eartag
  71. WHERE child.deleted = 0 AND child.breed = #{breedName}
  72. </select>
  73. </mapper>