a.id AS "id", a.dog_id AS "dogId", a.detection_type AS "detectionType", a.sampling_code AS "samplingCode", a.active_state AS "activeState", a.sum_zu AS "sumZu", a.dna_result AS "dnaResult", a.dna_result_remark AS "dnaResultRemark", a.dna_code AS "dnaCode", a.create_by AS "createBy.id", a.create_date AS "createDate", a.update_by AS "updateBy.id", a.update_date AS "updateDate", a.remarks AS "remarks", a.del_flag AS "delFlag", b.pedigree_certified_code AS "pedigreeCertifiedCode", b.name_cn AS "nameCn", b.birthdate AS "birthdate", b.gender AS "gender" LEFT JOIN dog b ON a.dog_id = b.id INSERT INTO dog_dna( id, dog_id, detection_type, sampling_code, active_state, sum_zu, dna_result, dna_result_remark, dna_code, create_by, create_date, update_by, update_date, remarks, del_flag ) VALUES ( #{id}, #{dogId}, #{detectionType}, #{samplingCode}, #{activeState}, #{sumZu}, #{dnaResult}, #{dnaResultRemark}, #{dnaCode}, #{createBy.id}, #{createDate}, #{updateBy.id}, #{updateDate}, #{remarks}, #{delFlag} ) UPDATE dog_dna SET dog_id = #{dogId}, detection_type = #{detectionType}, sampling_code = #{samplingCode}, active_state = #{activeState}, sum_zu = #{sumZu}, dna_result = #{dnaResult}, dna_result_remark = #{dnaResultRemark}, dna_code = #{dnaCode}, update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE id = #{id} UPDATE dog_dna SET remarks = concat(IFNULL(remarks,''),#{remarks}), del_flag = #{DEL_FLAG_DELETE} WHERE id = #{id} UPDATE dog_dna SET active_state = #{activeState}, update_by = #{updateBy}, update_date = now() WHERE dog_id = #{dogId} AND active_state != #{activeState}