SELECT
sas.id,
sas.ear_number,
sas.sheepfold,
sas.ranch_id,
sas.father,
sas.mother,
sas.born_weight,
sas.birthday,
sas.gender,
sas.parity,
sas.variety_id,
sas.type_id,
sas.join_date,
sas.comment,
sas.technician,
sas.create_by,
sas.create_time,
sas.user_id,
sas.dept_id,
sf.sheepfold_name AS sheepfoldName,
bv.variety AS varietyName,
st.type_name AS typeName
FROM sc_add_sheep sas
LEFT JOIN da_sheepfold sf ON sas.sheepfold = sf.id
LEFT JOIN bas_sheep_variety bv ON sas.variety_id = bv.id
LEFT JOIN bas_sheep_type st ON sas.type_id = st.id
INSERT INTO sc_add_sheep
ear_number,
sheepfold,
ranch_id,
father,
mother,
born_weight,
birthday,
gender,
parity,
variety_id,
type_id,
join_date,
comment,
technician,
create_by,
create_time,
user_id,
dept_id,
#{earNumber},
#{sheepfold},
#{ranchId},
#{father},
#{mother},
#{bornWeight},
#{birthday},
#{gender},
#{parity},
#{varietyId},
#{typeId},
#{joinDate},
#{comment},
#{technician},
#{createBy},
#{createTime},
#{userId},
#{deptId},
UPDATE sc_add_sheep
ear_number = #{earNumber},
ranch_id = #{ranchId},
sheepfold = #{sheepfold},
father = #{father},
mother = #{mother},
born_weight = #{bornWeight},
birthday = #{birthday},
gender = #{gender},
parity = #{parity},
variety_id = #{varietyId},
type_id = #{typeId},
join_date = #{joinDate},
comment = #{comment},
technician = #{technician},
update_by = #{updateBy},
update_time = NOW()
WHERE id = #{id}
DELETE FROM sc_add_sheep WHERE id IN
#{id}