a.id AS "id", a.sampling_code AS "samplingCode", a.dog_id AS "dogId", a.dog_source_type AS "dogSourceType", a.dog_code AS "dogCode", a.distribution_channel AS "distributionChannel", a.member_code AS "memberCode", a.member_name AS "memberName", a.bind_type AS "bindType", a.bind_by AS "bindBy", a.bind_member_code AS "bindMemberCode", a.bind_user_name AS "bindUserName", a.bind_time AS "bindTime", a.send_time AS "sendTime", a.flow_state AS "flowState", 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" CASE WHEN d.identification_flag IS NOT NULL THEN d.identification_flag WHEN dbc.identification_flag IS NOT NULL THEN dbc.identification_flag WHEN dpc.dog_chip IS NOT NULL THEN dpc.dog_chip ELSE null END AS "chip_code" LEFT JOIN dog d ON d.id = a.dog_id AND a.dog_id IS NOT NULL LEFT JOIN dog_birth_certificate dbc ON dbc.birth_cer_reg_code = a.dog_code AND a.dog_id IS NULL AND a.dog_source_type = '1' LEFT JOIN dog_pedigree_certified_change dpc ON dpc.overseas_pedigree_certified = a.dog_code AND a.dog_id IS NULL AND a.dog_source_type = '2' INSERT INTO sampling( id, sampling_code, dog_id, dog_source_type, dog_code, distribution_channel, member_code, member_name, bind_type, bind_by, bind_member_code, bind_user_name, bind_time, send_time, flow_state, create_by, create_date, update_by, update_date, remarks, del_flag ) VALUES ( #{id}, #{samplingCode}, #{dogId}, #{dogSourceType}, #{dogCode}, #{distributionChannel}, #{memberCode}, #{memberName}, #{bindType}, #{bindBy}, #{bindMemberCode}, #{bindUserName}, #{bindTime}, #{sendTime}, #{flowState}, #{createBy.id}, #{createDate}, #{updateBy.id}, #{updateDate}, #{remarks}, #{delFlag} ) INSERT INTO `sampling`(`id`,`sampling_code`,`bind_type`,`flow_state`,`create_by`,`create_date`,`update_by`,`update_date`,`remarks`,`del_flag`) VALUES (#{item.id},#{item.samplingCode},#{item.bindType},#{item.flowState},#{item.createBy.id},#{item.createDate},#{item.updateBy.id},#{item.updateDate},#{item.remarks},#{item.delFlag}) UPDATE sampling SET flow_state = #{flowState}, dog_id = #{dogId}, dog_source_type = #{dogSourceType}, dog_code = #{dogCode}, distribution_channel = #{distributionChannel}, member_code = #{memberCode}, member_name = #{memberName}, bind_type = #{bindType}, bind_by = #{bindBy}, bind_member_code = #{bindMemberCode}, bind_user_name = #{bindUserName}, bind_time = #{bindTime}, update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE id = #{id} UPDATE sampling SET update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE id = #{id} UPDATE sampling SET dog_id = #{dogId}, dog_source_type = #{dogSourceType}, dog_code = #{dogCode}, bind_type = #{bindType}, bind_by = #{bindBy}, bind_member_code = #{bindMemberCode}, bind_user_name = #{bindUserName}, bind_time = #{bindTime}, update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE id = #{id} UPDATE sampling SET dog_id = #{dogId}, dog_source_type = #{dogSourceType}, dog_code = #{dogCode}, member_code = #{memberCode}, member_name = #{memberName}, bind_type = #{bindType}, bind_by = #{bindBy}, bind_member_code = #{bindMemberCode}, bind_user_name = #{bindUserName}, bind_time = #{bindTime}, update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE id = #{id} UPDATE sampling SET dog_id = NULL, dog_source_type = NULL, dog_code = NULL, bind_type = '0', bind_by = NULL, bind_member_code = NULL, bind_user_name = NULL, bind_time = NULL, update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE id = #{id} UPDATE sampling SET flow_state = '1', distribution_channel = #{distributionChannel}, member_code = #{memberCode}, member_name = #{memberName}, update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE id = #{id} UPDATE sampling SET flow_state = '0', distribution_channel = NULL, member_code = NULL, member_name = NULL, update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE id = #{id} UPDATE sampling SET flow_state = '1', distribution_channel = #{distributionChannel}, member_code = #{memberCode}, member_name = #{memberName}, update_by = #{updateBy}, update_date = #{updateDate}, remarks = #{remarks} WHERE id IN #{id} UPDATE sampling SET flow_state = '0', distribution_channel = NULL, member_code = NULL, member_name = NULL, update_by = #{updateBy}, update_date = #{updateDate}, remarks = #{remarks} WHERE id IN #{id} UPDATE sampling SET del_flag = #{DEL_FLAG_DELETE} WHERE id = #{id} UPDATE sampling SET flow_state = #{flowState}, update_by = #{updateBy.id}, update_date = #{updateDate}, remarks = #{remarks} WHERE sampling_code = #{samplingCode} UPDATE sampling SET flow_state = #{flowState}, update_by = #{updateBy}, update_date = #{updateDate}, remarks = #{remarks} WHERE id IN #{id} UPDATE sampling SET flow_state = #{flowState}, send_time = now(), update_by = #{updateBy.id}, update_date = #{updateDate} WHERE sampling_code = #{samplingCode} UPDATE sampling SET flow_state = #{flowState}, send_time = now(), update_by = #{updateBy}, update_date = #{updateDate} WHERE id IN #{id} UPDATE sampling SET dog_id = #{dogId} WHERE id = #{id} UPDATE sampling SET dog_id = #{dogId}, dog_source_type = #{dogSourceType}, dog_code = #{dogCode}, update_by = #{updateBy.id}, update_date = #{updateDate} WHERE id = #{id}