select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time ,d.ji_bie, d.dept_address, d.oil_gun_num, d.station_pic, d.station_longitude, d.station_latitude, d.mno, discount_setting,card_enabled_flag,d.app_id, d.app_secret,gzh_app_id,gzh_app_secret,ali_app_id,gzh_app_secret, ali_app_id,ali_public_key,ali_private_key,ali_encrypt_key,image1,image2,image3,image4,image5,ws_print_flag,print_setting,notice,integral_print_flag, d.integral_flag,d.integral_rule_flag,d.card_rule_flag,d.coupon_flag,d.label_flag,d.print_device_type,d.balance,d.is_lng_flag,d.city,coupon_enabled_flag, d.merchant_no,d.terminal_id,d.yun_key,d.mno_array,mno_proportion,mno_status,refund_examin_status,is_alipay_flag,third_payment from sys_dept d insert into sys_dept( dept_id, parent_id, dept_name, ancestors, order_num, leader, phone, email, status, create_by, ji_bie, dept_address, oil_gun_num, station_pic, station_longitude, station_latitude, mno, app_id, app_secret, discount_setting, card_enabled_flag, gzh_app_id, gzh_app_secret, ali_app_id, ali_public_key, ali_private_key, ali_encrypt_key, image1, image2, image3, image4, image5, ws_print_flag, print_setting, notice, integral_print_flag, integral_flag, integral_rule_flag, card_rule_flag, coupon_flag, label_flag, print_device_type, balance, city, is_lng_flag, merchant_no, terminal_id, yun_key, coupon_enabled_flag, mno_array, mno_proportion, mno_status, is_alipay_flag, refund_examin_status, third_payment, create_time )values( #{deptId}, #{parentId}, #{deptName}, #{ancestors}, #{orderNum}, #{leader}, #{phone}, #{email}, #{status}, #{createBy}, #{jiBie}, #{deptAddress}, #{oilGunNum}, #{stationPic}, #{stationLongitude}, #{stationLatitude}, #{mno}, #{appId}, #{appSecret}, #{discountSetting}, #{cardEnabledFlag}, #{gzhAppId}, #{gzhAppSecret}, #{aliAppId}, #{aliPublicKey}, #{aliPrivateKey}, #{aliEncryptKey}, #{image1}, #{image2}, #{image3}, #{image4}, #{image5}, #{wsPrintFlag}, #{printSetting}, #{notice}, #{integralPrintFlag}, #{integralFlag}, #{integralRuleFlag}, #{cardRuleFlag}, #{couponFlag}, #{labelFlag}, #{printDeviceType}, #{balance}, #{city}, #{isLngFlag}, #{merchantNo}, #{terminalId}, #{yunKey}, #{couponEnabledFlag}, #{mnoArray}, #{mnoProportion}, #{mnoStatus}, #{isAlipayFlag}, #{refundExaminStatus}, #{thirdPayment}, sysdate() ) update sys_dept parent_id = #{parentId}, dept_name = #{deptName}, ancestors = #{ancestors}, order_num = #{orderNum}, leader = #{leader}, phone = #{phone}, email = #{email}, status = #{status}, update_by = #{updateBy}, ji_bie = #{jiBie}, dept_address = #{deptAddress}, oil_gun_num = #{oilGunNum}, station_pic = #{stationPic}, station_longitude = #{stationLongitude}, station_latitude = #{stationLatitude}, mno = #{mno}, app_id = #{appId}, app_secret = #{appSecret}, discount_setting= #{discountSetting}, card_enabled_flag= #{cardEnabledFlag}, gzh_app_id= #{gzhAppId}, gzh_app_secret= #{gzhAppSecret}, ali_app_id= #{aliAppId}, ali_public_key= #{aliPublicKey}, ali_private_key= #{aliPrivateKey}, ali_encrypt_key= #{aliEncryptKey}, image1= #{image1}, image2= #{image2}, image3= #{image3}, image4= #{image4}, image5= #{image5}, ws_print_flag= #{wsPrintFlag}, print_setting= #{printSetting}, notice= #{notice}, integral_print_flag= #{integralPrintFlag}, integral_flag= #{integralFlag}, integral_rule_flag= #{integralRuleFlag}, card_rule_flag= #{cardRuleFlag}, coupon_flag= #{couponFlag}, label_flag= #{labelFlag}, print_device_type= #{printDeviceType}, balance= #{balance}, city= #{city}, is_lng_flag= #{isLngFlag}, merchant_no= #{merchantNo}, terminal_id= #{terminalId}, yun_key= #{yunKey}, coupon_enabled_flag= #{couponEnabledFlag}, mno_array= #{mnoArray}, mno_proportion= #{mnoProportion}, mno_status= #{mnoStatus}, is_alipay_flag= #{isAlipayFlag}, third_payment= #{thirdPayment}, refund_examin_status= #{refundExaminStatus}, update_time = sysdate() where dept_id = #{deptId} update sys_dept set ancestors = when #{item.deptId} then #{item.ancestors} where dept_id in #{item.deptId} update sys_dept status = #{status}, update_by = #{updateBy}, update_time = sysdate() where dept_id in (${ancestors}) update sys_dept set del_flag = '2' where dept_id = #{deptId}